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

# 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.symm.io/options-protocol-architecture/technical-architecture.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
