# afiUSD Vault

AFI POR USD Vaults are the foundational layer for generating and distributing yield across the protocol. Each vault adheres to the ERC-4626 standard and includes advanced features such as yield vesting, withdrawal cooldowns, and global cross-chain coordination. These vaults form the asset layer backing AFI’s index products such as afiUSD ( POR-USD Vault )

### afiUSD Vault <a href="#afiusd-vault" id="afiusd-vault"></a>

The <kbd>afiUSD</kbd> Vault is the primary implementation of the AFI yield infrastructure on supported chains. It is a fully compliant ERC-4626 vault with protocol-specific enhancements.

#### Key Features - <a href="#key-features" id="key-features"></a>

* **ERC-4626 Compliance** - Implements the full ERC-4626 tokenized vault interface, allowing seamless interoperability with other DeFi protocols.
* **Withdrawal Cooldown** - Introduces a **72-hour cooldown period** post-withdrawal request to allow strategy unwinding and ensure liquidity availability.
* **Yield Vesting** - Yield generated by AFI is incorporated into the vault's exchange rate **gradually**, smoothing accrual and preventing front-running or deposit-timing arbitrage.
* **Fee Management -** Fee Management supports configurable deposit and withdrawal fees, programmable at the vault or strategy level. Currently, both fees are set to 0.
* **Virtual Asset Accounting** - Tracks total assets under management, including **vested and unvested yield**, to provide accurate NAV computation.

***

### Cross-Chain Yield Distribution <a href="#cross-chain-yield-distribution" id="cross-chain-yield-distribution"></a>

afiUSD will operate vaults across multiple chains - each independently collecting deposits and generating yield. However, yield distribution is coordinated globally to ensure fairness and consistency in `afiUSD` value across all deployments.

#### Objectives - <a href="#objectives" id="objectives"></a>

* Maintain **one unified global exchange rate** for `afiUSD`
* Ensure users on all chains receive proportional yield
* Prevent liquidity fragmentation across deployments

### How Yield Distribution Works <a href="#how-yield-distribution-works" id="how-yield-distribution-works"></a>

#### Step 1: Collect Chain-Level Data <a href="#step-1-collect-chain-level-data" id="step-1-collect-chain-level-data"></a>

* **Vault Deposits:** Track total deposits per chain (e.g., Ethereum: 500K USDC, Arbitrum: 300K USDC)
* **Vault Yields:** Track yield generated by agents on each chain (e.g., Ethereum: 10K USDC, Arbitrum: 3K USDC)

#### Step 2: Aggregate Global Totals <a href="#step-2-aggregate-global-totals" id="step-2-aggregate-global-totals"></a>

Copy

```
totalDeposit = ethDeposit + arbDeposit  
             = 500,000 + 300,000  
             = 800,000 USDC

totalYield = ethYield + arbYield  
           = 10,000 + 3,000  
           = 13,000 USDC
```

#### Step 3: Calculate Global Exchange Rate <a href="#step-3-calculate-global-exchange-rate" id="step-3-calculate-global-exchange-rate"></a>

The exchange rate is updated globally using:

```
newExchangeRate = ((totalDeposit + totalYield) * 1e6) / totalDeposit 
                = ((800,000 + 13,000) * 1,000,000) / 800,000
                = 1,016,250 (scaled by 1e6 for USDC precision)
```

This exchange rate reflects the updated value of 1 vault share across all chains.

#### Step 4: Compute Chain-Specific Yield Distribution <a href="#step-4-compute-chain-specific-yield-distribution" id="step-4-compute-chain-specific-yield-distribution"></a>

```
vaultYield = (newExchangeRate * vaultDeposit) / 1e6 - vaultDeposit
```

For each vault:

* **Ethereum Vault:**

  ```
  ethVaultYield = (1,016,250 * 500,000) / 1,000,000 - 500,000  
                = 8,125 USDC
  ```
* **Arbitrum Vault:**

  ```
  arbVaultYield = (1,016,250 * 300,000) / 1,000,000 - 300,000  
                   = 4,875 USDC
  ```

**Total Distributed Yield:**

```
8,125 + 4,875 = 13,000 USDC (matches total global yield)
```

<table><thead><tr><th width="249">Chain</th><th>Deposits</th><th>Yield Generated</th><th>Yield Distributed</th></tr></thead><tbody><tr><td>ETH</td><td>500,000 USDC</td><td>10,000 USDC</td><td>8,125 USDC</td></tr><tr><td>Arbitrum</td><td>300,000 USDC</td><td>3,000 USDC</td><td>4,875 USDC</td></tr><tr><td><strong>Total</strong></td><td><strong>800,000 USDC</strong></td><td><strong>13,000 USDC</strong></td><td><p><strong>13,000 USDC</strong></p><h3 id="distribution-process"><br></h3></td></tr></tbody></table>

***

### Distribution Process - <a href="#distribution-process" id="distribution-process"></a>

1. **Off-chain Calculation:**
   * Our off-chain Engine collects deposit and yield data from all chains.
   * It computes the new global exchange rate and the yield to distribute to each vault.
2. **On-chain Distribution:**
   * The yield rebalancer (authorized address) calls the `distributeYield` function on each vault’s Yield contract, passing the calculated yield for that vault.
   * The vault contract updates its internal accounting and distributes the yield to users (usually with vesting).
