VaultAdapter
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
| Name | Type | Description |
|---|---|---|
_asset | IERC20 | Underlying asset (USDC). |
_vault | address | Morpho vault address (must have same underlying asset). |
_owner | address | Admin address for rescue operations. |
_splitter | address | SyntheticSplitter 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
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Total 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
| Name | Type | Description |
|---|---|---|
caller | address | Must be SPLITTER. |
receiver | address | Receiver of adapter shares. |
assets | uint256 | Amount of USDC to deposit. |
shares | uint256 | Amount 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
| Name | Type | Description |
|---|---|---|
caller | address | Caller requesting withdrawal. |
receiver | address | Receiver of withdrawn USDC. |
owner | address | Owner of adapter shares being burned. |
assets | uint256 | Amount of USDC to withdraw. |
shares | uint256 | Amount 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
| Name | Type | Description |
|---|---|---|
token | address | Token to rescue. |
to | address | Recipient 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
| Name | Type | Description |
|---|---|---|
target | address | Distributor contract to call. |
data | bytes | ABI-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();