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)
Parameters | Description | Value (based on above function call) |
---|---|---|
from | shareholder's address | 0x0000000000000000000000000000000000000000 |
to | share recipient's address | to |
amount | amount of shares minted | calculated based on assets deposited |
Deposit(address by, address owner, uint256 assets, uint256 shares)
Parameters | Description | Value (based on above function call) |
---|---|---|
by | address of the caller | msg.sender |
owner | share recipient's address | to |
assets | amount of assets deposited | assets |
shares | amount of shares minted | calculated based on assets deposited |
deposit(uint256 assets, address to, uint256 minSharesOut)
Events:
Transfer(address from,address to,uint256 amount)
Parameters | Description | Value (based on above function call) |
---|---|---|
from | shareholder's address | 0x0000000000000000000000000000000000000000 |
to | share recipient's address | to |
amount | amount of shares minted | calculated based on assets deposited |
Deposit(address by, address owner, uint256 assets, uint256 shares)
Parameters | Description | Value (based on above function call) |
---|---|---|
by | address of the caller | msg.sender |
owner | share recipient's address | to |
assets | amount of assets deposited | assets |
shares | amount of shares minted | calculated based on assets deposited |
mint(uint256 shares, address to)
Events:
Transfer(address from,address to,uint256 amount)
Parameters | Description | Value (based on above function call) |
---|---|---|
from | shareholder's address | 0x0000000000000000000000000000000000000000 |
to | share recipient's address | to |
amount | amount of shares minted | shares |
Deposit(address by, address owner, uint256 assets, uint256 shares)
Parameters | Description | Value (based on above function call) |
---|---|---|
by | address of the caller | msg.sender |
owner | share recipient's address | to |
assets | amount of assets deposited | calculated based on the shares |
shares | amount of shares minted | shares |
Withdraw flow (1 path)
startRedeem(uint256 shares, address beneficiary)
Events:
Transfer(address from,address to,uint256 amount)
Parameters | Description | Value (based on above function call) |
---|---|---|
from | shareholder's address | msg.sender |
to | share recipient's address | vault's address |
amount | shares to withdraw | shares |
StartedRedeem(address staker, address operator, uint256 shares, bytes32 withdrawKey, uint256 assets);
Parameters | Description | Value (based on above function call) |
---|---|---|
staker | address of the caller | msg.sender |
operator | vault's operator address | as per vault's config |
shares | shares to withdraw | shares |
withdrawKey | unique withdrawal key | calculated based on input data |
assets | assets to be returned | calculated based on shares to be withdrawn |
finishRedeem(bytes32 withdrawalKey)
Events:
Transfer(address from,address to,uint256 amount)
Parameters | Description | Value (based on above function call) |
---|---|---|
from | shareholder's address | vault's address |
to | share recipient's address | 0x0000000000000000000000000000000000000000 |
amount | shares to withdraw | shares withdrawn as per withdrawalKey |
FinishedRedeem(address staker, address beneficiary, address operator, uint256 shares, uint256 assetsClaimed, bytes32 withdrawRoot)
Parameters | Description | Value (based on above function call) |
---|---|---|
staker | address of the staker | stored as per withdrawalKey |
beneficiary | receiver of the assets | stored as per withdrawalKey |
operator | vault's operator address | as per vault's config |
shares | shares to withdraw | stored as per withdrawalKey |
assetsClaimed | assets to be returned | calculated based on shares to be withdrawn |
withdrawKey | unique withdrawal key | withdrawalKey |
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