# Technical Architecture

## Diamond Pattern Implementation

The protocol leverages the **EIP-2535 Diamond Pattern** to achieve modularity, upgradeability, and well-organized shared storage management.

#### Core Components

1. **Diamond Contract**

   Acts as the main entry point, delegating function calls to the appropriate facets.
2. **Facets**

   Modular contracts that implement specific areas of functionality.
3. **Shared Storage**

   Structured storage layout that is accessible across all facets, ensuring consistency and upgrade safety.

## Storage Architecture

| **Storage Contract**     | **Purpose**                | **Key Data Structures**                                                        |
| ------------------------ | -------------------------- | ------------------------------------------------------------------------------ |
| **AppStorage**           | Global configuration       | System version, collateral whitelist, limits, timeouts, Party B 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

**1. Account Management**

* **Account Facet**

  Manages user deposits, withdrawals, balances, and collateral allocation.

2. **Trading Operations**

* **Party A Open Facet** & **Party A Close Facet**

  Handle Party A’s position opening and closing intents.
* **Party B Open Facet** & **Party B Close Facet**

  Manage Party B’s intent locking, unlocking, and filling intents.
* **Trade Facet**

  Manage trade execution and cancelation.


---

# Agent Instructions: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
