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

# Architecture

## Overview

Gremlix smart contracts are deployed on **Arbitrum One** and built on the **ERC4626 tokenized vault standard**. The architecture separates concerns into four main components:

<figure><img src="https://3603376872-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlgA9ZMNVOvkQvQDUuKgk%2Fuploads%2FtL1JkiJ6ZusdYCyhAp2t%2Fimage.png?alt=media&amp;token=a4a02683-7494-4b39-afa0-b3f2977fb674" alt=""><figcaption></figcaption></figure>

## Contracts

### Vault.sol

The core ERC4626 vault. Each vault instance manages a single asset (USDC or BTC) and one or more strategies.

**Key responsibilities:**

* Accept deposits and mint shares
* Track total assets across vault balance + deployed strategies
* Allocate/deallocate capital to strategies via Keeper
* Accrue performance, management, and withdrawal fees
* Pause/unpause deposits and withdrawals independently

**Security features:**

* Virtual shares offset (Morpho V2-inspired, prevents inflation attacks)
* Explicit `_totalTrackedAssets` (donation-immune accounting)
* `ReentrancyGuard` on all state-mutating functions
* Staleness window on harvests

### Strategy.sol

Base contract for all strategy implementations. The concrete strategy deployed for each vault and manages deployed assets with a different chains/protocols.

**Key responsibilities:**

* Accept capital from vault (`deposit()`)
* Return capital to vault (`withdraw()`)
* Track `totalTrackedAssets()` — the current real value of deployed capital
* Allow Keeper to update tracked assets after off-chain reconciliation

### Keeper.sol

Authorized operator contract that orchestrates vault operations requiring off-chain data.

**Key responsibilities:**

* Whitelist of authorized operator addresses
* Call `allocate()` / `deallocate()` on vaults
* Call `reconcileAndHarvest()` to update strategy values and trigger vault harvest
* Batch operations across multiple vaults in one transaction

## Deployment Addresses

<table><thead><tr><th width="231">Contract</th><th width="166">Network</th><th width="390">Address</th></tr></thead><tbody><tr><td>USDC Dual Grid Vault</td><td>Arbitrum One</td><td>0x973Ae12aC9078E9f9B1708C477A9670bB3fB0886</td></tr><tr><td>BTC Growth Capital Vault</td><td>Arbitrum One</td><td>0xd519EF317Be061b310D3caA4565Fa1ef466c36C8</td></tr><tr><td>Keeper</td><td>Arbitrum One</td><td>0xc6B58F7680a90865ACf10Ff3931E273cDec852B5</td></tr><tr><td>USDC Strategy</td><td>Arbitrum One</td><td>0x546b5510BDaa7359bB7AdB66d7AE165335078a1a</td></tr><tr><td>BTC Strategy</td><td>Arbitrum One</td><td>0x696225e0e6a04AA34ef82d1EBa64857Af231Cc56</td></tr></tbody></table>

> Addresses will be published here after mainnet deployment.

## Audits

> Smart contract audit is pending. Links to audit reports will be published here when available.
