For the complete documentation index, see llms.txt. This page is also available as Markdown.

Technical Architecture

Diamond pattern

The protocol is built on the EIP-2535 Diamond pattern for modularity, upgradeability, and shared storage:

  1. Diamond contract: the main entry point, delegating function calls to the appropriate facets.

  2. Facets: modular contracts, each implementing one area of functionality.

  3. Shared storage: a structured storage layout accessible across all facets, which keeps state consistent and upgrades safe.

Storage architecture

Storage contract
Purpose
Key data structures

AppStorage

Global configuration

System version, collateral whitelist, limits, timeouts, PartyB configurations

AccountStorage

User balances and accounts

Scheduled releases, withdrawal records, nonces

SymbolStorage

Trading instruments

Symbol definitions, oracle references, instrument configurations

TradeStorage

Active positions

Open intents, close intents, active trades

StateControlStorage

System state management

Pause states, emergency flags, suspended addresses

AccessControlStorage

Permission management

User roles, access rights

Facet organization

Account management

  • Account Facet: manages user deposits, withdrawals, balances, and collateral allocation.

Trading operations

  • PartyA Open Facet and PartyA Close Facet: handle PartyA's position opening and closing intents.

  • PartyB Open Facet and PartyB Close Facet: manage PartyB's intent locking, unlocking, and filling.

  • Trade Facet: manages trade execution and cancellation.

Last updated