> For the complete documentation index, see [llms.txt](https://noiho.gitbook.io/noiho/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://noiho.gitbook.io/noiho/architecture/diamond.md).

# Diamond

One bridge address routes contract calls to facets with shared storage.

BridgeDiamond follows EIP-2535. You call one stable address with the merged ABI. The fallback maps each four-byte selector to a facet and delegatecalls it, so every facet runs in the diamond's context. Application state lives in a single append-only AppStorage struct at slot 0; diamond selector and ownership storage use a separate hashed slot.

1. Caller sends a selector to BridgeDiamond
2. The fallback resolves that selector to a facet
3. The facet executes by delegatecall
4. The facet reads and writes shared AppStorage
5. XMRn and HYPE transfers enter or leave diamond custody

| Facet               | Responsibility                                       | Representative calls                                                           |
| ------------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------ |
| WrapFacet           | Create and reveal XMR → XMRn orders                  | requestWrap, fulfillWrap                                                       |
| UnwrapFacet         | Escrow XMRn, manage LP intent, reveal the XMR payout | requestUnwrap, submitUnwrapIntent, removeUnwrapIntent, fulfillUnwrap           |
| LifecycleFacet      | Commitments, cancellations, failed HYPE claims       | commitFulfillment, removeFulfillment, cancel, claimETHTo                       |
| LiquidityFacet      | LP registry and XMRn liquidity accounting            | registerLiquidityProvider, addLiquidity, removeLiquidity, getProviderForAmount |
| WitnessFacet        | Witness registry, bonds, attestation, finalization   | upsertWitness, witnessOrder, withdrawBond, releaseBond                         |
| DisputeFacet        | Challenge window and owner arbitration               | dispute, resolveDispute                                                        |
| OrderViewFacet      | Single-order and paginated reads                     | getOrder, getOrdersPagedInclusive, filtered paginated getters                  |
| AdminFacet          | Pause and protocol parameters                        | panic/unpanic, fee, timing, and oracle setters                                 |
| SanctionFacet       | Sanctions list and quarantined payouts               | isSanctioned, quarantineSanctionedStake                                        |
| Core diamond facets | Upgrade routing, introspection, ownership            | diamondCut, facets, owner                                                      |

The XMRn ERC-20/OFT remains a separate contract, not a facet. Approve that token for the diamond; call bridge functions at the diamond address.

The owner controls upgrades, protocol parameters, pausing and dispute resolution. Facet separation does not remove those trust assumptions.
