Skip to main content
Standard interface for tokenized vaults (EIP-4626). Provides deposit, withdraw, mint, redeem and preview functions for any conforming vault.

What it offers

  • deposit: Deposit underlying assets, receive vault shares
  • withdraw: Withdraw by specifying asset amount to receive
  • redeem: Withdraw by specifying share amount to burn
  • mint: Mint exact number of shares by depositing required assets
  • previewDeposit: Preview how many shares a deposit would yield
  • previewWithdraw: Preview how many shares would be burned for a withdrawal
  • convertToShares: Convert asset amount to equivalent shares
  • convertToAssets: Convert share amount to equivalent assets

Notes

  • Standard interface (EIP-4626) - protocols that implement it: sDAI, sfrxETH, pufETH, Yearn V3, sUSDe, Beefy vaults
  • deposit/withdraw operate in asset terms; mint/redeem operate in share terms
  • preview* functions account for fees; convert* are pure exchange rate calculations
  • Approve the underlying asset to the vault before calling deposit
  • owner parameter in withdraw/redeem allows withdrawal on behalf of another address (requires approval)
  • Share price typically increases over time as yield accrues

Its names in a program

The registry records no deployment: VaultABI is an interface, bound to an address the program is given.

ABI

Where a line says what an address it returns is, a program that calls the function through its namespace calls that contract’s methods on the result directly: <Namespace>.<Contract>.<function>(...).<method>(...). A token’s methods are the ERC-20 functions, and its writes are SafeERC20.

VaultABI

import VaultABI from "./protocols/erc4626/VaultABI.json";
  • deposit(uint256 assets, address receiver) returns (uint256 shares)
  • mint(uint256 shares, address receiver) returns (uint256 assets)
  • withdraw(uint256 assets, address receiver, address owner) returns (uint256 shares)
  • redeem(uint256 shares, address receiver, address owner) returns (uint256 assets)
  • totalAssets() view returns (uint256)
  • convertToShares(uint256 assets) view returns (uint256)
  • convertToAssets(uint256 shares) view returns (uint256)
  • previewDeposit(uint256 assets) view returns (uint256)
  • previewMint(uint256 shares) view returns (uint256)
  • previewWithdraw(uint256 assets) view returns (uint256)
  • previewRedeem(uint256 shares) view returns (uint256)
  • maxDeposit(address receiver) view returns (uint256)
  • maxMint(address receiver) view returns (uint256)
  • maxWithdraw(address owner) view returns (uint256)
  • maxRedeem(address owner) view returns (uint256)
  • asset() view returns (address): the address is a token

Next steps