ERC-4626 Tokenized Vault Standard
ERC-4626 is a standard to optimize and unify the technical parameters of yield-bearing vaults. It provides a standard API for tokenized yield-bearing vaults that represent shares of a single underlying ERC-20 token. ERC-4626 also outlines an optional extension for tokenized vaults utilizing ERC-20, offering basic functionality for depositing, withdrawing tokens and reading balances.
The role of ERC-4626 in yield-bearing vaults
Lending markets, aggregators, and intrinsically interest-bearing tokens help users find the best yield on their crypto tokens by executing different strategies. These strategies are done with slight variation, which might be error-prone or waste development resources.
ERC-4626 in yield-bearing vaults will lower the integration effort and unlock access to yield in various applications with little specialized effort from developers by creating more consistent and robust implementation patterns.
The ERC-4626 token is described fully in EIP-4626.
1function deposit(address _to, uint256 _value) public returns (uint256 _shares)2Копіювати
This function deposits the
_value tokens into the vault and grants ownership to
1function withdraw(address _to, uint256 _value) public returns (uint256 _shares)2Копіювати
This function withdraws
_value token from the vault and transfers them to
1function totalHoldings() public view returns (uint256)2Копіювати
This function returns the total amount of underlying tokens held by the vault.
1function balanceOfUnderlying(address _owner) public view returns (uint256)2Копіювати
This function returns the total amount of underlying tokens held in the vault for
1function underlying() public view returns (address)2Копіювати
Returns the address of the token the vault uses for accounting, depositing, and withdrawing.
1function totalSupply() public view returns (uint256)2Копіювати
Returns the total number of unredeemed vault shares in circulation.
1function balanceOf(address _owner) public view returns (uint256)2Копіювати
Returns the total amount of vault shares the
_owner currently has.
1function redeem(address _to, uint256 _shares) public returns (uint256 _value)2Копіювати
Redeems a specific number of
_shares for underlying tokens and transfers them to
1function exchangeRate() public view returns (uint256)2Копіювати
The amount of underlying tokens one
baseUnit of vault shares is redeemable for. For example:
1_shares * exchangeRate() / baseUnit() = _value.2Копіювати
1exchangeRate() * totalSupply() MUST equal totalHoldings().2Копіювати
1function baseUnit() public view returns(uint256)2Копіювати
The decimal scalar for vault shares and operations involving
MUST be emitted when tokens are deposited into the vault
1event Deposit(address indexed _from, address indexed _to, uint256 _value)2Копіювати
_from is the user who triggered the deposit and approved
_value underlying tokens to the vault, and
_to is the user who can withdraw the deposited tokens.
MUST be emitted when tokens are withdrawn from the vault by a depositor.
1event Withdraw(address indexed _owner, address indexed _to, uint256 _value)2Копіювати
_from is the user who triggered the withdrawal and held
_value underlying tokens in the vault, and
_to is the user who received the withdrawn tokens.
Note: All batch functions, including the hook, are also available in non-batch versions. This is done to save gas, as transferring just one asset will likely remain to be the most common method. For clarity in the explanations, we've left them out, including the safe transfer rules. Remove the 'Batch' and the names are identical.