Technical Architecture

Overview

The vault system is designed to abstract complex DeFi strategy execution into a simple and transparent interface for users. Through a layered architecture and clearly defined flows, users can deposit stablecoins, receive yield-bearing vault tokens, and withdraw assets, all while the system optimally manages funds across integrated protocols.

System Architecture

The vault system consists of four primary layers:

1. Smart Wallet Layer

  • User spins up a smart wallet that interacts with the afiUSD Vault to deposit and withdraw assets.

  • Deposits are converted into vault shares at the current exchange rate.

2. Core Contracts

  • afiUSD Vault: Central vault contract handling deposits, withdrawals, and yield accrual.

  • Yield: Receives strategy performance updates and facilitates yield distribution over time.

  • Manager: Executes asset allocation into supported external DeFi protocols.

3. Admin Layer

  • Admin / Operator / Rebalancer: Authorized roles responsible for yield updates, vault operations, rebalancing, and governance proposals.

    • ADMIN_ROLE: Multi-signature governance (3/5)

    • OPERATOR_ROLE: Operational functions

    • REBALANCER_ROLE: Yield distribution

4. External Protocols

  • Capital is deployed across multiple integrated protocols through the Manager, aiming for optimal yield based on strategy logic.

Flow Summary

Deposit Flow -

Sequence Diagram

  • Users approve the vault to spend their assets.

  • Vault transfers the assets to the Manager.

  • Vault mints shares to the user based on the current exchange rate.

  • Fee shares (if applicable) are minted to the Treasury.

  • The Manager deploys capital across selected DeFi protocols.

Step-by-Step:

  1. When a user joins our platform, they are provided with a new ERC-4337 smart wallet.

  2. Once a user approves asset spending, our platform gains the necessary permission to interact with the Vault contract on their behalf.

  3. At a predetermined time, our backend service automatically invokes the deposit() function from the user's wallet. This function includes the specified amount and the receiver's address, facilitating the direct transfer of funds to the Vault.

  4. Vault transfers funds to the Manager.

  5. Vault mints shares to the user.

  6. Manager deploys funds across integrated protocols.

Withdrawal Flow -

Sequence Diagram

  • Users initiate a withdrawal request with their vault share amount.

  • A cooldown period (e.g., 24h) is triggered.

  • Once complete, the withdrawal is executed and shares are burned.

  • Funds are retrieved from protocols and sent to the user.

Step-by-Step

  1. User calls requestWithdrawal(shares).

  2. 24-hour cooldown period begins.

  3. Manager retrieves funds from protocols.

  4. Once cooldown ends, user executes withdrawal.

  5. Vault burns user shares.

  6. Assets transferred back to user.

Yield Distribution Flow -

Sequence Diagram

  • The off-chain engine calculates strategy profits and pushes them on-chain.

  • The Rebalancer role calls distributeYield() on the Yield contract.

  • Vault's virtual assets are updated.

  • Treasury receives a portion of the yield as fee shares.

  • Exchange rate increases for all vault holders.

Step-by-Step

  1. Off-chain system computes yield from deployed strategies.

  2. Rebalancer initiates on-chain yield distribution.

  3. Yield is allocated to the vault and recorded.

  4. Fee shares (if configured) are minted to Treasury.

  5. Exchange rate increases gradually as yield vests.

Vault Mechanics

Yield Vesting -

To protect against front-running and provide a fair yield experience:

  • Yield accrues linearly over a vesting period (typically 24 hours).

  • This smooths out exchange rate increases and reduces volatility.

  • Prevents “sniping” behavior around profit distribution events.

Cooldown Period (Withdrawals) -

  • Designed to ensure liquidity before honoring withdrawal requests.

  • The Manager begins to unwind deployed positions during this period.

  • Helps avoid slippage or capital inefficiency during high withdrawal demand.

Last updated