Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

VaultAdapter

Git Source

Inherits: ERC4626, Ownable2Step, IYieldAdapter

Title: VaultAdapter

ERC4626-compliant wrapper that deposits into a Morpho vault for yield.

Interchangeable with other yield adapters. Only accepts deposits from SyntheticSplitter.

Note: security-contact: contact@plether.com

Constants

VAULT

Morpho vault (ERC4626) that generates yield.

IERC4626 public immutable VAULT

SPLITTER

SyntheticSplitter authorized to deposit.

address public immutable SPLITTER

Functions

constructor

Deploys adapter targeting a Morpho vault.

constructor(
    IERC20 _asset,
    address _vault,
    address _owner,
    address _splitter
) ERC4626(_asset) ERC20("Vault Yield Wrapper", "vyUSDC") Ownable(_owner);

Parameters

NameTypeDescription
_assetIERC20Underlying asset (USDC).
_vaultaddressMorpho vault address (must have same underlying asset).
_owneraddressAdmin address for rescue operations.
_splitteraddressSyntheticSplitter authorized to deposit.

maxWithdraw

Maximum USDC withdrawable by owner.

Does not cap by VAULT.maxWithdraw() — Morpho Vault V2 returns 0 for all max* functions due to its gate system. Actual liquidity is enforced at withdrawal time.

function maxWithdraw(
    address owner
) public view override returns (uint256);

maxRedeem

Maximum adapter shares redeemable by owner.

See maxWithdraw for rationale on not delegating to vault.

function maxRedeem(
    address owner
) public view override returns (uint256);

maxDeposit

Maximum USDC depositable.

See maxWithdraw for rationale on not delegating to vault.

function maxDeposit(
    address
) public view override returns (uint256);

maxMint

Maximum adapter shares mintable.

See maxWithdraw for rationale on not delegating to vault.

function maxMint(
    address
) public view override returns (uint256);

totalAssets

Returns total USDC value of this adapter’s vault position.

function totalAssets() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256Total assets held in the Morpho vault, converted from vault shares.

_deposit

Deposits assets to Morpho vault after ERC4626 share minting.

function _deposit(
    address caller,
    address receiver,
    uint256 assets,
    uint256 shares
) internal override;

Parameters

NameTypeDescription
calleraddressMust be SPLITTER.
receiveraddressReceiver of adapter shares.
assetsuint256Amount of USDC to deposit.
sharesuint256Amount of adapter shares minted.

_withdraw

Withdraws assets from Morpho vault before ERC4626 share burning.

function _withdraw(
    address caller,
    address receiver,
    address owner,
    uint256 assets,
    uint256 shares
) internal override;

Parameters

NameTypeDescription
calleraddressCaller requesting withdrawal.
receiveraddressReceiver of withdrawn USDC.
owneraddressOwner of adapter shares being burned.
assetsuint256Amount of USDC to withdraw.
sharesuint256Amount of adapter shares burned.

accrueInterest

No-op — Morpho vault accrues interest on underlying markets during deposit/withdraw.

View functions (totalAssets, convertToAssets) may lag by a few blocks of unaccrued interest across the vault’s markets. This is negligible for an actively-used vault and self-corrects on the next state-changing interaction.

function accrueInterest() external;

rescueToken

Recovers stuck tokens (excluding the underlying asset and vault shares).

function rescueToken(
    address token,
    address to
) external onlyOwner;

Parameters

NameTypeDescription
tokenaddressToken to rescue.
toaddressRecipient address.

claimRewards

Claims rewards from an external distributor (Merkl, URD, etc.).

Reward tokens land in this contract; use rescueToken() to extract them.

function claimRewards(
    address target,
    bytes calldata data
) external onlyOwner;

Parameters

NameTypeDescription
targetaddressDistributor contract to call.
databytesABI-encoded call data for the claim function.

Errors

VaultAdapter__OnlySplitter

Thrown when caller is not the SyntheticSplitter.

error VaultAdapter__OnlySplitter();

VaultAdapter__InvalidAddress

Thrown when a zero address is provided.

error VaultAdapter__InvalidAddress();

VaultAdapter__InvalidVault

Thrown when vault’s underlying asset doesn’t match this adapter’s asset.

error VaultAdapter__InvalidVault();

VaultAdapter__CannotRescueUnderlying

Thrown when attempting to rescue the underlying asset.

error VaultAdapter__CannotRescueUnderlying();

VaultAdapter__CannotRescueVaultShares

Thrown when attempting to rescue vault share tokens.

error VaultAdapter__CannotRescueVaultShares();

VaultAdapter__CallFailed

Thrown when a reward claim call fails.

error VaultAdapter__CallFailed();

VaultAdapter__ForbiddenTarget

Thrown when claimRewards targets a forbidden address.

error VaultAdapter__ForbiddenTarget();