> 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
