General ERC-4626 Vault Interface

Generic interface for ERC-4626 vaults.

Contract Interface

Events

Deposit

event Deposit(address sender, address receiver, uint256 assets, uint256 shares)

Withdraw

event Withdraw(address sender, address receiver, address owner, uint256 assets, uint256 shares)

Functions

asset

function asset() external view returns (address assetTokenAddress)

The address of the underlying token used by the Vault for valuing, depositing, and withdrawing.

totalAssets

function totalAssets() external view returns (uint256 totalManagedAssets)

Total amount of the underlying asset that is “managed” by vault.

convertToShares

The amount of shares that the Vault would exchange for the amount of assets provided, in an ideal scenario where all the conditions are met.

Parameters

Name
Type
Description

assets

uint256

The amount of underlying assets to be convert to vault shares.

Return Values

Name
Type
Description

shares

uint256

The amount of vault shares converted from the underlying assets.

convertToAssets

The amount of assets that the Vault would exchange for the amount of shares provided, in an ideal scenario where all the conditions are met.

Parameters

Name
Type
Description

shares

uint256

The amount of vault shares to be converted to the underlying assets.

Return Values

Name
Type
Description

assets

uint256

The amount of underlying assets converted from the vault shares.

maxDeposit

The maximum number of underlying assets that caller can deposit.

Parameters

Name
Type
Description

caller

address

Account that the assets will be transferred from.

Return Values

Name
Type
Description

maxAssets

uint256

The maximum amount of underlying assets the caller can deposit.

previewDeposit

Allows an on-chain or off-chain user to simulate the effects of their deposit at the current transaction, given current on-chain conditions.

Parameters

Name
Type
Description

assets

uint256

The amount of underlying assets to be transferred.

Return Values

Name
Type
Description

shares

uint256

The amount of vault shares that will be minted.

deposit

Mint vault shares to receiver by transferring exact amount of underlying asset tokens from the caller.

Parameters

Name
Type
Description

assets

uint256

The amount of underlying assets to be transferred to the vault.

receiver

address

The account that the vault shares will be minted to.

Return Values

Name
Type
Description

shares

uint256

The amount of vault shares that were minted.

maxMint

The maximum number of vault shares that caller can mint.

Parameters

Name
Type
Description

caller

address

Account that the underlying assets will be transferred from.

Return Values

Name
Type
Description

maxShares

uint256

The maximum amount of vault shares the caller can mint.

previewMint

Allows an on-chain or off-chain user to simulate the effects of their mint at the current transaction, given current on-chain conditions.

Parameters

Name
Type
Description

shares

uint256

The amount of vault shares to be minted.

Return Values

Name
Type
Description

assets

uint256

The amount of underlying assests that will be transferred from the caller.

mint

Mint exact amount of vault shares to the receiver by transferring enough underlying asset tokens from the caller.

Parameters

Name
Type
Description

shares

uint256

The amount of vault shares to be minted.

receiver

address

The account the vault shares will be minted to.

Return Values

Name
Type
Description

assets

uint256

The amount of underlying assets that were transferred from the caller.

maxWithdraw

The maximum number of underlying assets that owner can withdraw.

Parameters

Name
Type
Description

owner

address

Account that owns the vault shares.

Return Values

Name
Type
Description

maxAssets

uint256

The maximum amount of underlying assets the owner can withdraw.

previewWithdraw

Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current transaction, given current on-chain conditions.

Parameters

Name
Type
Description

assets

uint256

The amount of underlying assets to be withdrawn.

Return Values

Name
Type
Description

shares

uint256

The amount of vault shares that will be burnt.

withdraw

Burns enough vault shares from owner and transfers the exact amount of underlying asset tokens to the receiver.

Parameters

Name
Type
Description

assets

uint256

The amount of underlying assets to be withdrawn from the vault.

receiver

address

The account that the underlying assets will be transferred to.

owner

address

Account that owns the vault shares to be burnt.

Return Values

Name
Type
Description

shares

uint256

The amount of vault shares that were burnt.

maxRedeem

The maximum number of shares an owner can redeem for underlying assets.

Parameters

Name
Type
Description

owner

address

Account that owns the vault shares.

Return Values

Name
Type
Description

maxShares

uint256

The maximum amount of shares the owner can redeem.

previewRedeem

Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current transaction, given current on-chain conditions.

Parameters

Name
Type
Description

shares

uint256

The amount of vault shares to be burnt.

Return Values

Name
Type
Description

assets

uint256

The amount of underlying assests that will transferred to the receiver.

redeem

Burns exact amount of vault shares from owner and transfers the underlying asset tokens to the receiver.

Parameters

Name
Type
Description

shares

uint256

The amount of vault shares to be burnt.

receiver

address

The account the underlying assets will be transferred to.

owner

address

The account that owns the vault shares to be burnt.

Return Values

Name
Type
Description

assets

uint256

The amount of underlying assets that were transferred to the receiver.

Last updated

Was this helpful?