This article covers the basics of ERC4626. Take a helicopter view of how it works and what are the main security concerns that need to be addressed.

What does ERC4626 enable?

ERC4626 standardizes how vaults can handle and manage various assets. The main reason it was created was to enable easy and consistent integrations between DeFi projects. Tokenized vault allows for easy distribution of yield/rewards via shares. Essentially, it creates a more uniform and interoperable way to manage these investment products.

How ERC4626 works?

Depositing Money: When you put your ERC20 token (like a stablecoin) into the vault, you receive another special ERC20 token in return. These special tokens represent your share of the vault.

Earning Interest: The vault takes your money and invests it in various ways (like lending it out) to earn interest.

Withdrawing Funds: When you want your money back, you can exchange your special ERC20 tokens for the proportional value of your shares (your original deposit plus an adequate proportion of the total interest earned).

Example:

  1. User A deposits 10 tokenA and gets 10 tokenS(shares)

  2. User B deposits 10 tokenA and gets 10 tokenS(shares)

  3. User C deposits 5 tokenA and gets 5 tokenS(shares)

    There are 25 tokenA total in the vault with 25 tokenS(shares) so each share represents 1 tokenA.

    Then, by making loans, an additional 10 tokenA were accumulated in the vault.

    Now, there are 35 tokenA total in the vault with 25 tokenS(shares) so each share represents 1,4 tokenA.

  4. User A withdraws 14 tokenA for their 10 tokenS(shares).

    Now, there are 21 tokenA total in the vault with 15 tokenS(shares) so each share still represents 1,4 tokenA.

  5. User C now must deposit 7 tokenA (instead of 5) to get 5 tokenS(shares), as the proportion changed from 1:1 to 1,4:1.

For which tokens?

While ERC4626 can theoretically be used with any ERC-20 token, its practical applications are most commonly seen with stablecoins and yield-bearing tokens within DeFi ecosystems. When creating a vault, the selected underlying token is defined as an asset.

The constructor of ERC4626 vault

Each ERC-4626 vault is designed to handle only one underlying asset, which means you cannot deposit multiple kinds of tokens into a single ERC4626 contract and receive shares back for those deposits. However, there is an evolving proposal known as ERC7575, which extends the ERC4626 interface to support multi-asset vaults.

How do these tokens work (business-wise)?

Collaboration Between Protocols: The standard allows different DeFi protocols to work together more easily. This can lead to better opportunities for users, as they can move their assets across platforms seamlessly.

New Offerings: The ERC4626 standard opens the door for creative financial products. Developers can create various vault strategies tailored to different risk appetites and investment goals.

Liquidity for users: User funds remain liquid and without withdrawal they may trade on the market and use their tokens as collateral because at any time another person can exchange the shares back to the original token.

Who currently uses ERC4626?

Aave: Aave has integrated ERC4626 into its platform, enabling users to deposit and withdraw ERC20 tokens supported by Aave v3. It manages the supply and withdrawal of these assets in Aave, and allows a vault manager to take a fee on yield earned.

Yearn Finance: Yearn utilizes the "Tokenized Strategy" to simplify the creation and deployment of ERC-4626 compliant yield-generating vaults. It allows anyone to create their own strategy-specific vault by outsourcing standard vault logic to a shared implementation contract via delegatecall.

Euler: Euler utilizes the ERC4626 standard through its Euler Vault Kit (EVK), which is designed to construct ERC4626 vaults with enhanced functionalities for lending platforms.

To see more examples check the ERC4626 vaults repository.

A repository of live ERC4626 vaults across chains

ERC4626 main security concerns

At the time of writing, Solodit indicates 265 findings related to ERC4626, of which 169 are HIGH and MEDIUM severity findings. That clearly indicates that mistakes happen during the implementation of this standard and they have a significant impact on the security of the entire project. The most common issues concern:

Manipulation of exchange rate:

Vaults are designed to allow the exchange rate between shares and assets to change over time. To determine the price of a vault share, you can simply divide the total amount of tokenA deposited in the vault by the total number of tokenS (shares) issued. As the vault earns more yield, the exchange rate for the shares improves, benefiting the holders.

However, attackers might want to influence this exchange rate by various types of donations (direct, stealth).

To prevent:

  • Audit the code
  • Run invariant checks
  • Round favorably for the protocol
  • Use virtual deposit and discarding stealth donations

Lack of compliance with ERC4626:

Not following the standard strictly not only introduces new risks but also makes integration with other projects more difficult. In this way, both your users and projects that will be integrated with you might be exposed to vulnerabilities.

To prevent:

  • Audit the code
  • Be compliant with all MUST of ERC4626

Sample ERC4626 implementations:

Property tests for ERC4626 vaults

To assist vault developers in identifying potential violations of standard that could disrupt integrations or introduce vulnerabilities in the future, we recommend checking prepared by a16z properties for fuzzing and symbolic execution techniques.

Want to increase the security of your project?

Composable Security 🛡️⛓️ is an elite team of 2 experienced Security Researchers who specialize in (re)staking, AVS and UniswapV4 projects.

Uniswap Foundation grant recipient. Creators of the Smart Contract Security Verification Standard and the first Security Guide for DApps CTOs, Lead Developers, and Security Enthusiasts.

Have peace of mind like: Braintrust, Enjin, Tellor, Volmex Finance and many more.

Paweł Kuryłowicz

Paweł Kuryłowicz

Managing Partner & Smart Contract Security Auditor

About the author

Co-author of SCSVS and White Hat. Professionally dealing with security since 2017 and since 2019 contributing to the crypto space. Big DeFi fan and smart contract security researcher.

View all posts (16)