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

function convertToShares(uint256 assets) external view returns (uint256 shares)

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

function convertToAssets(uint256 shares) external view returns (uint256 assets)

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

function maxDeposit(address caller) external view returns (uint256 maxAssets)

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

function previewDeposit(uint256 assets) external view returns (uint256 shares)

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

function deposit(uint256 assets, address receiver) external returns (uint256 shares)

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

function maxMint(address caller) external view returns (uint256 maxShares)

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

function previewMint(uint256 shares) external view returns (uint256 assets)

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

function mint(uint256 shares, address receiver) external returns (uint256 assets)

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

function maxWithdraw(address owner) external view returns (uint256 maxAssets)

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

function previewWithdraw(uint256 assets) external view returns (uint256 shares)

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

function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares)

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

function maxRedeem(address owner) external view returns (uint256 maxShares)

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

function previewRedeem(uint256 shares) external view returns (uint256 assets)

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

function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets)

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