Levva
  • Welcome to Levva
  • About Levva
    • Protocol overview
    • DeFi portfolios
    • Advanced strategies
    • AI in Levva
  • Tokenomics
    • LVVA token
    • veLVVA
    • Governance
  • HOW TO
    • Connect Wallet
    • Earn
      • Deposit Liquidity
        • Deposit in Vault
        • Deposit in Pool
      • Add Liquidity
      • Withdraw Liquidity
    • Farm
      • Open Farm Position
  • PROTOCOL ARCHITECTURE
    • Smart Contract Architecture of Levva Vaults
    • Levva Vault Liquidity Balancing
Powered by GitBook
On this page
  • Vault
  • Roles supported by the Vault smart contract:
  • General Vault Functions:
  • ConfigManager
  • Roles supported by the ConfigManager smart contract:
  • LendingProtocolAdapter
  1. PROTOCOL ARCHITECTURE

Smart Contract Architecture of Levva Vaults

Lear how Smart Contract Architecture of Levva Vault is working.

PreviousOpen Farm PositionNextLevva Vault Liquidity Balancing

Last updated 6 months ago

The Levva Vault Smart Contract Architecture architecture consists of three smart contracts:

  • Vault

  • ConfigManager

  • LendingProtocolAdapter (Levva, Aave, EtherFi, Morpho and etc.).

Vault

The Vault is an upgradeable smart contract compatible with the ERC-4626 “Tokenized Vault” standard. It references ConfigManager, and lending protocol adapters can be connected to the smart contract. (Currently, there are three adapters implemented for the Levva, Aave, EtherFi protocols.) The vault smart contract invests users' funds in lending protocols via functions implemented in adapter contracts.

Roles supported by the Vault smart contract:

  • User: The end user or smart contract; has access to deposit and withdrawal functions.

  • AVS: Has access to invest users' funds into lending protocols connected to the vault and to withdraw previously invested funds from these protocols.

  • Governance: A service role with functions available for contract upgrades, adding lending protocol adapters, and assigning AVS.

All user deposits in the vault are categorized as "free" or "invested" (invested in a lending protocol for profit). The current investment strategy specifies that 10% of all tokens remain free, while the rest are invested in lending protocols.

General Vault Functions:

  • Deposit/Mint: The user calls the deposit function, agreeing to transfer (following an ERC-20.approve call) an ERC-20 token matching the vault token to the vault smart contract and receiving in exchange an ERC-20 shares token. Upon deposit, the current shares token price is calculated. After deposit, the user's funds remain in the “free” pool (ready for investment or instant withdrawal).

  • Withdraw/Redeem: The user calls the withdrawal function to exchange their ERC-20 share tokens for vault ERC-20 tokens. Before exchange, the current share token price is calculated. The user can successfully complete the transaction only if there are sufficient “free” funds available for the exchange.

  • RequestWithdraw: Allows users to request a token withdrawal if there aren’t enough “free” funds available. This function accepts the number of share tokens to be exchanged for the vault token. The request initiates the withdrawal of invested tokens from lending protocols and locks the user’s shares until the exchange is complete.

  • ExecuteProtocolAction: A function available to the AVS role, which accepts an array of actions and the type of protocol (deposits, withdrawals, withdrawal requests) that the smart contract should perform.

ConfigManager

The ConfigManager is an upgradeable smart contract that stores settings for lending protocol adapters for each vault. One ConfigManager contract serves multiple vaults.

Roles supported by the ConfigManager smart contract:

  • Governance: Changes adapter settings, adds/removes Levva pools.

LendingProtocolAdapter

A non-upgradeable smart contract without internal state storage, the adapter implements functions for depositing/withdrawing funds into/from lending protocols(Levva, Aave, and EtherFi) and querying the current balance, including accumulated interest.