Skip to content
Lattice

IERC4626

Git Source

Inherits: IERC20

Title: IERC4626

Author: Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/interfaces/IERC4626.sol)

Interface for the ERC-4626 Tokenized Vault Standard.

Inherits IERC20 — the vault itself is an ERC-20 share token. See https://eips.ethereum.org/EIPS/eip-4626

OZ v5.6.1 declares interface IERC4626 is IERC20, IERC20Metadata to expose the metadata surface (name(), symbol(), decimals()) through the interface. Lattice's IERC20 already includes the metadata surface, unlike OZ which splits IERC20 + IERC20Metadata — so inheriting IERC20Metadata separately would be redundant in this setup. The metadata functions are fully implemented in the ERC4626 facet and accessible on any vault.

Functions

asset

Returns the address of the underlying asset token.

function asset() external view returns (address);

Returns

NameTypeDescription
<none>address

totalAssets

Returns the total amount of underlying assets held by the vault.

function totalAssets() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256

convertToShares

Returns the number of vault shares equivalent to assets underlying tokens (floor rounding).

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

Parameters

NameTypeDescription
assetsuint256

Returns

NameTypeDescription
<none>uint256

convertToAssets

Returns the number of underlying tokens equivalent to shares vault shares (floor rounding).

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

Parameters

NameTypeDescription
sharesuint256

Returns

NameTypeDescription
<none>uint256

maxDeposit

Returns the maximum amount of underlying assets receiver can deposit.

function maxDeposit(address receiver) external view returns (uint256);

Parameters

NameTypeDescription
receiveraddress

Returns

NameTypeDescription
<none>uint256

maxMint

Returns the maximum number of shares receiver can receive via mint.

function maxMint(address receiver) external view returns (uint256);

Parameters

NameTypeDescription
receiveraddress

Returns

NameTypeDescription
<none>uint256

maxWithdraw

Returns the maximum amount of underlying assets owner can withdraw.

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

Parameters

NameTypeDescription
owneraddress

Returns

NameTypeDescription
<none>uint256

maxRedeem

Returns the maximum number of shares owner can redeem.

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

Parameters

NameTypeDescription
owneraddress

Returns

NameTypeDescription
<none>uint256

previewDeposit

Simulates the number of shares minted for a deposit of assets.

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

Parameters

NameTypeDescription
assetsuint256

Returns

NameTypeDescription
<none>uint256

previewMint

Simulates the number of assets required to mint exactly shares.

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

Parameters

NameTypeDescription
sharesuint256

Returns

NameTypeDescription
<none>uint256

previewWithdraw

Simulates the number of shares burned for a withdraw of assets.

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

Parameters

NameTypeDescription
assetsuint256

Returns

NameTypeDescription
<none>uint256

previewRedeem

Simulates the number of assets returned for redeeming shares.

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

Parameters

NameTypeDescription
sharesuint256

Returns

NameTypeDescription
<none>uint256

deposit

Deposits assets underlying tokens and mints shares to receiver.

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

Parameters

NameTypeDescription
assetsuint256
receiveraddress

Returns

NameTypeDescription
sharesuint256The number of shares minted.

mint

Mints exactly shares to receiver by pulling the required underlying assets.

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

Parameters

NameTypeDescription
sharesuint256
receiveraddress

Returns

NameTypeDescription
assetsuint256The number of assets transferred.

withdraw

Burns shares from owner and sends assets underlying tokens to receiver.

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

Parameters

NameTypeDescription
assetsuint256
receiveraddress
owneraddress

Returns

NameTypeDescription
sharesuint256The number of shares burned.

redeem

Burns exactly shares from owner and sends underlying tokens to receiver.

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

Parameters

NameTypeDescription
sharesuint256
receiveraddress
owneraddress

Returns

NameTypeDescription
assetsuint256The number of assets transferred.

Events

Deposit

Emitted when assets are deposited into the vault by sender, minting shares to owner.

event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);

Parameters

NameTypeDescription
senderaddress
owneraddress
assetsuint256
sharesuint256

Withdraw

Emitted when shares are redeemed from the vault by sender on behalf of owner, transferring assets to receiver.

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

Parameters

NameTypeDescription
senderaddress
receiveraddress
owneraddress
assetsuint256
sharesuint256

Errors

MathOverflowedMulDiv

Raised by ERC4626 facets released through 0.4.0 when the share-math quotient overflows uint256 (on mulDiv's 512-bit path). Kept so their reverts still decode; current builds use Math.mulDiv, which raises Panic(0x11) instead.

error MathOverflowedMulDiv();

SafeERC20FailedOperation

A token transfer failed (covers tokens that return false or do not return a bool).

error SafeERC20FailedOperation(address token);

Parameters

NameTypeDescription
tokenaddress

ERC4626ExceededMaxDeposit

The deposit would exceed the maximum allowed for receiver.

error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max);

Parameters

NameTypeDescription
receiveraddress
assetsuint256
maxuint256

ERC4626ExceededMaxMint

The mint would exceed the maximum allowed for receiver.

error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max);

Parameters

NameTypeDescription
receiveraddress
sharesuint256
maxuint256

ERC4626ExceededMaxWithdraw

The withdrawal would exceed the maximum allowed for owner.

error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max);

Parameters

NameTypeDescription
owneraddress
assetsuint256
maxuint256

ERC4626ExceededMaxRedeem

The redemption would exceed the maximum allowed for owner.

error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max);

Parameters

NameTypeDescription
owneraddress
sharesuint256
maxuint256