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

# Architecture

Definitive’s technical architecture borrows the best concepts from traditional finance execution while integrating DeFi native elements such as on-chain activity monitoring and cross-protocol smart contract execution.&#x20;

\
The architecture is composed of 2 main components

* [**Definitive Contracts**](/developers/technical-overview/contracts.md)**:** Modular, non-custodial, on-chain smart contracts that can be comp
* [**Definitive Core**](/developers/technical-overview/core.md)**:** Proprietary off-chain Execution Engine

#### **TradingVault Smart Contract**

The `TradingVault` is the main contract used to support advanced execution at Definitive. It is a fully non-custodial contract composed of modules that perform specific tasks such as swapping and access control.

OpenZeppelin's `AccessControl`is used for role management. The different roles on a `TradingVault` are:

<table><thead><tr><th width="236">Roles</th><th width="195">Description</th><th width="232">Functionality</th><th>Address</th></tr></thead><tbody><tr><td>DEFAULT_ADMIN_ROLE</td><td>Owner of the contract.<br>It is set to address provided by the client or Definitive’s Multisig (for retail clients).</td><td><p></p><ul><li>Can add/remove other roles below.</li></ul></td><td>One</td></tr><tr><td>ROLE_CLIENT</td><td>Address provided by the client.</td><td><p></p><ul><li>Can deposit/withdraw funds from the TradingVault .</li><li>Can initiate a Trading Session on the Definitive UI</li><li>Can initiate swaps from the Definitive UI.</li></ul></td><td>Many</td></tr><tr><td>ROLE_DEFINITIVE</td><td>Address owned by the Definitive team.</td><td><p></p><ul><li>Can perform swaps with assets in the TradingVault.</li></ul></td><td>Many</td></tr></tbody></table>

#### **TradingVault Setup**

* Definitive deploys a bespoke `TradingVault` (smart contract) per user per chain. The address of the `TradingVault` is the same across all EVM chains.
* The client's address is designated as `ROLE_CLIENT` and only this address is able to deposit and withdraw funds.
* Definitive's address is designated as `ROLE_DEFINITIVE` and can perform predefined actions like swaps. This address **CAN NOT** withdraw funds from the `TradingVault` .
* The `DEFAULT_ADMIN_ROLE` is set to a backup address owned by the client. There can only be one `DEFAULT_ADMIN_ROLE` per `TradingVault`.
  * We recommend using a different address than what is set for `ROLE_CLIENT`. In case the `ROLE_CLIENT` address is compromised or lost, only the `DEFAULT_ADMIN_ROLE` can set a new `ROLE_CLIENT`.
* All roles can be verified on-chain.

#### Executing Trades

* Let's assume a client wants to swap ETH for USDC.
* Once a `TradingVault` is set up, the client connects with their desired wallet provider (Fireblocks, Metamask Institutional, any EOA, etc.).
* `ROLE_CLIENT` deposits ETH into the `TradingVault`.
* `ROLE_CLIENT` initiates a trading session by signing a payload that verifies that the address connected to the UI is, in fact, the same address with `ROLE_CLIENT` on the `TradingVault` smart contract.
* Once the trading session is active, the client can execute trades on the UI in a way similar to how they would execute in CeFi.

<figure><img src="/files/nXPETGQctRXAqs7x1Fqg" alt=""><figcaption><p>Trading session authentication UI                                                                        Verfied Trading UI</p></figcaption></figure>

* To execute the trade on-chain, the `ROLE_DEFINITIVE` address call the `TradingVault` with a `swapPayload` (data such as from asset, to asset, slippage, price impact), and this triggers an on-chain swap at a whitelisted venue.
* If the swap is successful, the client now has USDC in the `TradingVault`.
* The funds can only be withdrawn from the `TradingVault` by `ROLE_CLIENT` .

The same architecture is applied to Definitive’s Automated Yield product. Individual smart contracts are deployed per user per position, with the same roles and access control as listed in this document.
