MetaVaultWrapper

The MetaVaultWrapper is the user-facing contract for MetaVaults. It implements ERC-7540arrow-up-right (asynchronous deposit/redeem), ERC-7575arrow-up-right, and ERC-165arrow-up-right. Wrapper shares are ERC-20 tokens representing the depositor's pro-rata claim on the underlying infrastructure vault.

The wrapper delegates asset custody to an infrastructure vault (AsyncVault) and maintains its own epoch tracking to correctly account for per-user request balances.

Code for MetaVaultWrapper.sol can be found on GitHubarrow-up-right.

Methods

requestDeposit

function requestDeposit(
    uint256 assets,
    address controller,
    address owner
) external nonReentrant whenNotPaused returns (uint256 requestId)

Requests a deposit of assets (underlying token) into the MetaVault. Assets are transferred from owner to the wrapper and forwarded to the infrastructure vault. The request is recorded for the current epoch.

If the controller has a claimable deposit from a previous epoch, it is automatically claimed first.

circle-exclamation
Input Parameter
Type
Description

assets

uint256

Amount of underlying assets to deposit. Must be > 0.

controller

address

Address that the deposit request is recorded for

owner

address

Address that the assets are transferred from

Return Parameter
Type
Description

requestId

uint256

Always returns 0 (request ID is not used in this implementation)

decreaseDepositRequest

Decreases the caller's pending deposit request by assets. The assets are refunded to msg.sender.

Input Parameter
Type
Description

assets

uint256

Amount of assets to remove from the pending request. Must be > 0 and ≤ pending balance.

deposit

Claims all claimable shares for the controller from a previously settled deposit request. Wrapper shares are minted to receiver.

circle-info

The assets parameter is not used — all claimable shares are always claimed in full.

Input Parameter
Type
Description

assets

uint256

Not used (included for ERC-7540 interface compliance)

receiver

address

Address that will receive the minted wrapper shares

controller

address

Address whose claimable deposit is being claimed

Return Parameter
Type
Description

shares

uint256

Amount of wrapper shares minted to receiver

requestRedeem

Requests a redemption of shares (wrapper shares). Shares are burned from owner and the equivalent infrastructure vault shares are queued for redemption.

If the controller has a claimable redeem from a previous epoch, it is automatically claimed first.

Input Parameter
Type
Description

shares

uint256

Amount of wrapper shares to redeem. Must be > 0.

controller

address

Address that the redeem request is recorded for

owner

address

Address that the shares are burned from

Return Parameter
Type
Description

requestId

uint256

Always returns 0

decreaseRedeemRequest

Decreases the caller's pending redeem request by shares. The shares are minted back to msg.sender.

Input Parameter
Type
Description

shares

uint256

Amount of shares to remove from the pending request. Must be > 0 and ≤ pending balance.

redeem

Claims all claimable assets for the controller from a previously settled redeem request. Assets are transferred to receiver.

circle-info

The shares parameter is not used — all claimable assets are always claimed in full.

Input Parameter
Type
Description

shares

uint256

Not used (included for ERC-7540 interface compliance)

receiver

address

Address that will receive the underlying assets

controller

address

Address whose claimable redeem is being claimed

Return Parameter
Type
Description

assets

uint256

Amount of underlying assets transferred to receiver

setOperator

Approves or revokes operator to act on behalf of msg.sender for deposit/redeem operations.

Input Parameter
Type
Description

operator

address

Address to approve/revoke as operator

approved

bool

true to approve, false to revoke

updateEpochID

Synchronizes the wrapper's internal epoch ID with the infrastructure vault's current epoch. Called automatically by requestDeposit, deposit, requestRedeem, and redeem, but can also be called manually.

View Methods

getInfraVault

Returns the address of the underlying infrastructure vault.

isOperator

Returns whether operator is approved to act on behalf of controller.

totalVaultShares

Returns the total infrastructure vault shares held by the wrapper.

epochId

Returns the current epoch ID from the infrastructure vault.

lastUserDepositRequestEpoch

Returns the epoch ID of the user's last deposit request.

lastUserRedeemRequestEpoch

Returns the epoch ID of the user's last redeem request.

convertToShares

Converts assets to wrapper shares using the last settled epoch rate.

convertToShares

Converts assets to wrapper shares using a specific epoch rate.

convertToAssets

Converts wrapper shares to assets using the last settled epoch rate.

convertToAssets

Converts wrapper shares to assets using a specific epoch rate.

maxDeposit

Returns the maximum amount the receiver can claim via deposit. Returns 0 if paused or if the user's last deposit request is for the current (unsettled) epoch.

maxRedeem

Returns the maximum amount the owner can claim via redeem. Returns 0 if paused or if the user's last redeem request is for the current (unsettled) epoch.

pendingDepositRequest

Returns the amount of assets the controller has pending in the current epoch's deposit queue.

claimableDepositRequest

Returns the amount of assets the controller can claim from a settled deposit request.

pendingRedeemRequest

Returns the amount of shares the controller has pending in the current epoch's redeem queue.

claimableRedeemRequest

Returns the amount of shares the controller can claim from a settled redeem request.

totalAssets

Returns an estimate of the wrapper's total assets using the last settled epoch rate: convertToAssets(totalSupply()).

decimals

Returns the decimals of the underlying asset.

share

Returns the address of the share token (the wrapper itself). ERC-7575 compliance.

supportsInterface

Returns true for IERC165, IERC7540, IERC7575, IERC7540Deposit, IERC7540Redeem, and IERC7540Operator.

circle-exclamation

Events

DepositRequest

Emitted when a deposit request is created.

RedeemRequest

Emitted when a redeem request is created.

OperatorSet

Emitted when an operator approval is set or revoked.

DecreaseDepositRequest

Emitted when a deposit request is decreased.

DecreaseRedeemRequest

Emitted when a redeem request is decreased.

ClaimPendingDeposit

Emitted when the wrapper claims pending deposits from the infrastructure vault.

ClaimPendingRedeem

Emitted when the wrapper claims pending redeems from the infrastructure vault.

MetaVaultWrapperInitialized

Emitted when the wrapper is initialized.

Errors

Error
Description

ZeroAddress()

An address parameter is address(0)

ZeroAssets()

Assets amount is 0

ZeroShares()

Shares amount is 0

ERC7540InvalidOperator()

Caller is not the owner or an approved operator

ZeroDecreaseAmount()

Decrease amount is 0

DecreaseAmountExceedsPending(uint256 pendingAmount, uint256 decreaseAmount)

Decrease amount exceeds the pending balance

InvalidUnderlying()

Underlying asset does not match the infrastructure vault's asset

NoClaimAvailable(address owner)

No settled request available to claim

Last updated