Skip to content

V2 Standard ERC20 Vault Indexing Guide

Please refer here to learn about a vault's deposit and redeem functionality.

Deposit flows (3 paths)

deposit(uint256 assets, address to)

Events:

  • Transfer(address from,address to,uint256 amount)
ParametersDescriptionValue (based on above function call)
fromshareholder's address0x0000000000000000000000000000000000000000
toshare recipient's addressto
amountamount of shares mintedcalculated based on assets deposited
  • Deposit(address by, address owner, uint256 assets, uint256 shares)
ParametersDescriptionValue (based on above function call)
byaddress of the callermsg.sender
ownershare recipient's addressto
assetsamount of assets depositedassets
sharesamount of shares mintedcalculated based on assets deposited

deposit(uint256 assets, address to, uint256 minSharesOut)

Events:

  • Transfer(address from,address to,uint256 amount)
ParametersDescriptionValue (based on above function call)
fromshareholder's address0x0000000000000000000000000000000000000000
toshare recipient's addressto
amountamount of shares mintedcalculated based on assets deposited
  • Deposit(address by, address owner, uint256 assets, uint256 shares)
ParametersDescriptionValue (based on above function call)
byaddress of the callermsg.sender
ownershare recipient's addressto
assetsamount of assets depositedassets
sharesamount of shares mintedcalculated based on assets deposited

mint(uint256 shares, address to)

Events:

  • Transfer(address from,address to,uint256 amount)
ParametersDescriptionValue (based on above function call)
fromshareholder's address0x0000000000000000000000000000000000000000
toshare recipient's addressto
amountamount of shares mintedshares
  • Deposit(address by, address owner, uint256 assets, uint256 shares)
ParametersDescriptionValue (based on above function call)
byaddress of the callermsg.sender
ownershare recipient's addressto
assetsamount of assets depositedcalculated based on the shares
sharesamount of shares mintedshares

Withdraw flow (1 path)

startRedeem(uint256 shares, address beneficiary)

Events:

  • Transfer(address from,address to,uint256 amount)
ParametersDescriptionValue (based on above function call)
fromshareholder's addressmsg.sender
toshare recipient's addressvault's address
amountshares to withdrawshares
  • StartedRedeem(address staker, address operator, uint256 shares, bytes32 withdrawKey, uint256 assets);
ParametersDescriptionValue (based on above function call)
stakeraddress of the callermsg.sender
operatorvault's operator addressas per vault's config
sharesshares to withdrawshares
withdrawKeyunique withdrawal keycalculated based on input data
assetsassets to be returnedcalculated based on shares to be withdrawn

finishRedeem(bytes32 withdrawalKey)

Events:

  • Transfer(address from,address to,uint256 amount)
ParametersDescriptionValue (based on above function call)
fromshareholder's addressvault's address
toshare recipient's address0x0000000000000000000000000000000000000000
amountshares to withdrawshares withdrawn as per withdrawalKey
  • FinishedRedeem(address staker, address beneficiary, address operator, uint256 shares, uint256 assetsClaimed, bytes32 withdrawRoot)
ParametersDescriptionValue (based on above function call)
stakeraddress of the stakerstored as per withdrawalKey
beneficiaryreceiver of the assetsstored as per withdrawalKey
operatorvault's operator addressas per vault's config
sharesshares to withdrawstored as per withdrawalKey
assetsClaimedassets to be returnedcalculated based on shares to be withdrawn
withdrawKeyunique withdrawal keywithdrawalKey

On-chain helper functions

isWithdrawalPending(address staker, uint256 _withdrawNonce) returns (bool)

  • staker: address of the staker
  • _withdrawNonce: withdrawal nonce of the staker at the time of withdrawal
  • Checks if the withdrawal is pending for given nonce
  • Returns true if pending, false otherwise

getQueuedWithdrawal(address staker, uint256 _withdrawNonce) returns(QueuedWithdrawal)

  • staker: address of the staker
  • _withdrawNonce: withdrawal nonce of the staker at the time of withdrawal
  • Fetches queued withdrawal metadata for given nonce
  • returns QueuedWithdrawal
struct QueuedWithdrawal {
    address staker;
    uint96 start;
    uint256 shares;
    address beneficiary;
}

getNextWithdrawNonce(address staker) returns(uint256)

  • staker: address of the staker
  • Fetches the next withdrawal nonce of the staker

convertToShares(uint256 assets) returns(uint256)

  • assets : Amount of assets to convert into shares.
  • Returns the amount of shares that the Vault will exchange for the amount of assets provided

convertToAssets(uint256 shares) returns(uint256)

  • shares : Amount of shares to convert into assets.
  • Returns the amount of assets that the Vault will exchange for the amount of shares provided