# High Level Architecture

<figure><img src="https://3978617066-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJHNY2cWUA8ooxRaSq4DZ%2Fuploads%2Fo2Db4iyOm95TQ9AaTC4E%2Fartkis-trade-2.9_%20Decouple%20Liquidation%20Interface.jpg?alt=media&#x26;token=936e8f44-3f80-4fee-a126-5da2cd5d41b4" alt=""><figcaption></figcaption></figure>

**Arkis** delivers upgradable smart contract infrastructure, enabling a dynamic, secure, and efficient way to deploy new features faster. Arkis actively leverages two key concepts: [proxies](https://docs.openzeppelin.com/contracts/3.x/api/proxy) and [diamonds](https://eips.ethereum.org/EIPS/eip-2535). To deploy an Agreement or a Margin Account, the Arkis DMA uses the Arkis Agreement Factory and the Arkis Account Factory, respectively. Each factory maintains a pool of pre-deployed contracts to minimise transaction costs. When a contract is no longer in use, it is returned to the pool for future reuse.

<table data-header-hidden><thead><tr><th width="201.46875">Component</th><th width="379.1875">Functions</th><th width="198.59375">Address</th></tr></thead><tbody><tr><td><strong>Dispatcher</strong><br><code>ERC2535</code></td><td><ul><li><strong>Register MA</strong> triggered by borrower to initiate MA allocation. Borrower either uses a predeployed MA or a new instance is deployed if not available. Borrower has to provide collateral so Arkis can allocate MA once the registered event is received.</li><li><strong>Allocate MA</strong> and transfer funds from pool to Asset Managers' margin account according to terms of agreement</li><li><strong>Close MA</strong> and return funds from Asset Managers' margin account to pool</li></ul></td><td><a href="https://etherscan.io/address/0x2f01D7CFfe62673B3D2b680295A2D047F3848e4c">0x2f01D7CFfe62673B3D2b680295A2D047F3848e4c</a></td></tr><tr><td><strong>Liquidator</strong><br><code>ERC2535</code></td><td><ul><li><strong>Liquidate MA</strong> to close all opened positions, and swap to borrowed asset, return funds to pool and retain remaining balance in Arkis treasury for further investigation</li><li><strong>Withdraw MA</strong> triggered by Arkis Security Officer to initiate withdrawal from MA to external address for <strong>overcollateralised trading</strong></li></ul></td><td><a href="https://etherscan.io/address/0x286496C568368e036062781F807db5ea3E56d3e8">0x286496C568368e036062781F807db5ea3E56d3e8</a></td></tr><tr><td><p><strong>Account Factory</strong> <br><code>Beacon Proxy</code></p><p><code>ERC2535</code></p></td><td><ul><li>Create <em><strong>margin account</strong></em> linked to agreement</li><li>Maintain available MAs for reuse (deploy new if necessary)</li><li>Contain Margin Account implementation</li></ul></td><td><a href="https://etherscan.io/address/0xbbC9c04348E093473C5b176Cb4b103fF706528bf">0xbbC9c04348E093473C5b176Cb4b103fF706528bf</a></td></tr><tr><td><strong>Margin Account</strong><br><code>Beacon Proxy</code></td><td><ul><li>Provide <strong>trading interface</strong> to Asset Managers based on whitelisted operations registered in compliance module and governed by the terms of agreement</li></ul></td><td> </td></tr><tr><td><p><strong>Agreement Factory V2</strong> <br><code>Beacon Proxy</code></p><p><code>ERC1967</code></p><p><code>ERC1167</code></p></td><td><ul><li>Create <em><strong>agreement</strong></em> between counterparties on fix terms</li><li>Contain <strong>AgreementV2</strong> implementation</li></ul></td><td><a href="https://etherscan.io/address/0xe70d11D23F36826C58f30C61B4DeAf0A89a6D837">0xe70d11D23F36826C58f30C61B4DeAf0A89a6D837</a></td></tr><tr><td><p><strong>AgreementV2</strong></p><p><code>Beacon Proxy</code> </p><p><code>ERC4626</code></p></td><td><ul><li>Account <em><strong>accrued interest</strong></em> for Liquidity Provider</li><li><em><strong>Provide funds</strong></em> to the Asset Manager accordingly to agreement</li><li>Expose <strong>terms of agreement</strong> to enquirer</li><li>Issue LPT to Lender</li></ul></td><td></td></tr><tr><td><p><strong>Vault Factory</strong> <br><code>Beacon Proxy</code></p><p><code>ERC1967</code></p><p><code>ERC1167</code></p></td><td><ul><li>Create <em><strong>vault</strong></em> </li><li>Contain <strong>Vault</strong> implementation</li></ul></td><td><a href="https://etherscan.io/address/0x7ad1dd2516F1499852aAEb95a33D7Ec1BA31b5C3">0x7ad1dd2516F1499852aAEb95a33D7Ec1BA31b5C3</a></td></tr><tr><td><p><strong>Vault</strong></p><p><code>Beacon Proxy</code> </p><p><code>ERC4626</code></p></td><td><ul><li>Account accrued interest for Investor</li><li>Issue LPT to investors</li><li>Provide interface to curator for fund allocation</li></ul></td><td></td></tr><tr><td><strong>Compliance</strong><br><code>ERC2535</code></td><td><ul><li>Maintain master-set of Arkis whitelists</li><li>Ensure <strong>trading instruction compliant</strong> with terms of agreement (tenant-set of Arkis whitelist)</li></ul></td><td><a href="https://etherscan.io/address/0x76D46cb4c5cA64ba5aDCf3376E4BD3B75f0e61D2">0x76D46cb4c5cA64ba5aDCf3376E4BD3B75f0e61D2</a></td></tr><tr><td><strong>Compiler</strong><br><code>ERC2535</code></td><td><ul><li>Compile Arkis DSL into executable EVM commands</li></ul></td><td><a href="https://etherscan.io/address/0x1f797CC91BB598AA5aa8bafF1B1aF65f578fbAf2">0x1f797CC91BB598AA5aa8bafF1B1aF65f578fbAf2</a></td></tr><tr><td><strong>Pauser</strong><br><code>ERC1967</code></td><td><ul><li>Pause / Unpause other Arkis smart contracts atomically</li></ul></td><td> </td></tr><tr><td><p><mark style="color:red;">deprecated</mark></p><p><strong>Agreement Factory</strong> <br><code>Beacon Proxy</code><br><br></p><p><code>ERC1967</code></p><p><code>ERC1167</code></p></td><td><ul><li>Create <em><strong>agreement</strong></em> between counterparties on fix terms</li><li>Contain <strong>Agreement</strong> implementation</li></ul></td><td><br><a href="https://etherscan.io/address/0xEA623eebd9c5bFd56067e36C89Db0C13e6c70ba8">0xEA623eebd9c5bFd56067e36C89Db0C13e6c70ba8</a></td></tr><tr><td><p><mark style="color:red;">deprecated</mark></p><p><strong>Agreement</strong><br><code>Beacon Proxy</code> </p></td><td><ul><li>Account <em><strong>accrued interest</strong></em> for Liquidity Provider</li><li><em><strong>Provide funds</strong></em> to the Asset Manager accordingly to agreement</li><li>Expose <strong>terms of agreement</strong> to enquirer</li></ul></td><td> </td></tr></tbody></table>
