Skip to content

ERC-4626

ERC-4626

Overview

ERC-4626 is Ethereum's Tokenized Vault Standard, proposed and finalized in March 2022. This standard provides a unified API interface for yield-bearing vaults, enabling different DeFi protocols to implement token staking, yield distribution, and share management in a standardized way.

Think of ERC-4626 as the "universal language for yield-bearing vaults" -- just as ERC-20 defines the standard interface for tokens, ERC-4626 defines the standard interface for vaults, allowing developers and users to interact with various yield protocols in a consistent manner.

Core Concepts

Tokenized Vaults An ERC-4626 vault is a smart contract that: - Accepts a specific ERC-20 token as deposits (underlying asset) - Mints vault share tokens to depositors - Share tokens are themselves ERC-20 tokens - Accumulates yield over time, with share value growing relative to the underlying asset

Share Mechanism When a user deposits 100 USDC into a vault: 1. The vault receives 100 USDC (underlying asset) 2. Mints share tokens based on the current exchange rate (e.g., 95 vUSDC) 3. As the vault generates yield, the value of these 95 vUSDC grows 4. Upon redemption, the user burns share tokens and receives more underlying assets

Core Interface

Deposit and Mint

// Deposit a specified amount of assets, receive corresponding shares
function deposit(uint256 assets, address receiver) returns (uint256 shares)

// Mint a specified amount of shares, requiring the corresponding amount of assets
function mint(uint256 shares, address receiver) returns (uint256 assets)

Withdraw and Redeem

// Withdraw a specified amount of assets, burning corresponding shares
function withdraw(uint256 assets, address receiver, address owner) returns (uint256 shares)

// Redeem a specified amount of shares, receiving corresponding assets
function redeem(uint256 shares, address receiver, address owner) returns (uint256 assets)

Query Functions

// Query the conversion rate between assets and shares
function convertToShares(uint256 assets) returns (uint256 shares)
function convertToAssets(uint256 shares) returns (uint256 assets)

// Query maximum deposit/withdrawal limits
function maxDeposit(address receiver) returns (uint256 maxAssets)
function maxWithdraw(address owner) returns (uint256 maxAssets)

Core Properties

// Underlying asset token address
function asset() returns (address assetTokenAddress)

// Total assets and total shares
function totalAssets() returns (uint256 totalManagedAssets)
function totalSupply() returns (uint256 totalShares) // Inherited from ERC-20

Design Advantages

Unified Interface Before ERC-4626, each DeFi protocol had its own vault implementation: - Yearn's yVault - Compound's cToken - Aave's aToken - Rari's fToken

This required integrators to write different adapters for each protocol. ERC-4626 solves this problem through a unified interface.

Composability A standardized interface makes vaults easy to compose: - Aggregators can manage multiple ERC-4626 vaults simultaneously - Vaults can nest (one vault's underlying asset is another vault's shares) - Strategies can optimize yield across protocols

Development Efficiency - Reduces duplicate code and adapter development - Lowers audit costs (standard implementations are easier to audit) - Improves security (well-tested standard implementations)

Use Cases

Yield Aggregators Yield aggregators like Yearn Finance can use ERC-4626 to uniformly manage multiple strategies: - Automatically allocate funds to the optimal strategy - Users only need to interact with a single standard interface - Easy to add new yield sources

Lending Protocols Lending protocols like Compound and Aave can use ERC-4626 to represent deposit certificates: - cUSDC, aUSDC can become standard ERC-4626 tokens - A unified interface simplifies cross-protocol lending - Easy to build lending aggregators

Staking Protocols Liquid staking protocols (like Lido, Rocket Pool) can use ERC-4626: - stETH, rETH can serve as ERC-4626 share tokens - Standardized staking and redemption processes - Improved interoperability with other DeFi protocols

Index Funds Decentralized index funds and ETF products: - Users deposit base assets (such as ETH) - The vault automatically allocates to multiple assets - Share tokens represent fund shares

Notable Implementations

Yearn Finance V3 Yearn V3 fully adopts the ERC-4626 standard; all vaults are ERC-4626 compatible.

Balancer Boosted Pools Balancer's boosted pools use ERC-4626 vaults to improve capital efficiency.

OpenZeppelin Contracts OpenZeppelin provides a standard ERC-4626 implementation library widely used in new project development.

Morpho The lending optimizer Morpho uses ERC-4626 to implement its vault functionality.

Sommelier The DeFi asset management protocol Sommelier's strategy vaults use ERC-4626.

Extension Standards

ERC-7540: Asynchronous Vaults Extends ERC-4626 to support asynchronous operations, suitable for: - Withdrawals requiring time delays (e.g., Liquid Staking) - Cross-chain vault operations - Operations requiring batch processing

ERC-7575: Multi-Asset Vaults Handles multi-asset or multi-entry point vault scenarios: - Liquidity provider tokens - Multi-collateral vaults - Externalized ERC-20 implementation

Security Considerations

Share Inflation Attack Early implementations may face the "first deposit attack": - The attacker deposits 1 wei as the first depositor - Then directly transfers a large amount of assets to the vault - This causes the share value to become extremely high, rounding subsequent depositors' shares to 0

Defense Measures: - Pre-mint "virtual shares" in the constructor - Set a minimum deposit amount - Use OpenZeppelin's secure implementation

Reentrancy Attacks Vault operations involve token transfers and require reentrancy protection: - Use ReentrancyGuard - Follow the Checks-Effects-Interactions pattern - Carefully audit callback logic

Development Resources

*OpenZeppelin* Implementation**

import "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol";

contract MyVault is ERC4626 {
    constructor(IERC20 asset)
        ERC4626(asset)
        ERC20("My Vault Token", "vTKN")
    {}

    // Implement yield logic
    function _totalAssets() internal view override returns (uint256) {
        // Return total assets managed by the vault (including yield)
    }
}

Testing Tools - ERC-4626 Test Suite - 4626 Alliance Tools

Ecosystem Impact

Protocol Integration Major DeFi protocols are migrating to ERC-4626: - Reduces integration complexity - Improves composability between protocols - Promotes DeFi innovation

User Experience A standardized interface brings a better user experience: - Wallets can uniformly display all ERC-4626 vaults - Unified interaction interface - Easier to compare yields across different vaults

Future Outlook

ERC-4626 is becoming the de facto standard for DeFi yield products, with future directions including: - More protocol adoption and migration - Cross-chain ERC-4626 vaults - Integration with account abstraction - Standardization of more complex yield strategies