Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

← Back to contracts

MorphoVaultV1Adapter

Code

v2.0 repository

Introduction

MorphoVaultV1Adapter is an adapter that connects a Morpho Vault V2 to a Morpho Vault V1. It wraps deposits and withdrawals to/from the underlying Vault V1 on behalf of the parent Vault V2.

Timelock System

This adapter has no timelock system. All functions are callable directly by their respective roles with no submit/execute delay.

Immutables

NameTypeDescription
factoryaddressThe factory contract that deployed this adapter.
parentVaultaddressThe Morpho Vault V2 that this adapter belongs to.
morphoVaultV1addressThe Morpho Vault V1 (MetaMorpho) contract that this adapter deposits into.
adapterIdbytes32Unique identifier for this adapter instance, computed as keccak256(abi.encode("this", address(this))).

Owner Functions

setSkimRecipient

function setSkimRecipient(address newSkimRecipient) external

Sets the address that receives skimmed token balances.

Callable by: Owner of the parent vault (instant — no timelock)

Parameters:

NameTypeDescription
newSkimRecipientaddressThe new skim recipient address.

Other Functions

skim

function skim(address token) external

Transfers the adapter's entire balance of token to skimRecipient.

Callable by: skimRecipient

Parameters:

NameTypeDescription
tokenaddressThe token to skim. Must not be the morphoVaultV1 share token.

allocate

function allocate(bytes memory data, uint256 assets, bytes4, address) external returns (bytes32[] memory, int256)

Deposits assets into the underlying Morpho Vault V1.

Callable by: parentVault

Parameters:

NameTypeDescription
databytesMust be empty (0x).
assetsuint256The amount of assets to deposit.

The bytes4 and address parameters are part of the shared adapter interface but unused by this implementation.

Return Values:

NameTypeDescription
idsbytes32[]The allocation IDs affected (contains adapterId).
deltaint256The change in allocation (new allocation minus old allocation).

deallocate

function deallocate(bytes memory data, uint256 assets, bytes4, address) external returns (bytes32[] memory, int256)

Withdraws assets from the underlying Morpho Vault V1 back to the parent vault.

Callable by: parentVault

Parameters:

NameTypeDescription
databytesMust be empty (0x).
assetsuint256The amount of assets to withdraw.

The bytes4 and address parameters are part of the shared adapter interface but unused by this implementation.

Return Values:

NameTypeDescription
idsbytes32[]The allocation IDs affected (contains adapterId).
deltaint256The change in allocation (new allocation minus old allocation).

View Functions

realAssets

function realAssets() external view returns (uint256)

Returns the current value of the adapter's Vault V1 share balance in underlying assets. Returns 0 if the parent vault has no recorded allocation for this adapter.

Return Values:

NameTypeDescription
assetsuint256The current value of held Vault V1 shares, or 0 if allocation is zero.

allocation

function allocation() public view returns (uint256)

Returns the vault's current allocation for this adapter, as recorded in the parent vault (keyed by adapterId).

Return Values:

NameTypeDescription
assetsuint256The current allocation amount in the parent vault.

ids

function ids() public view returns (bytes32[] memory)

Returns the allocation IDs used by this adapter. Contains a single entry: adapterId.

Return Values:

NameTypeDescription
ids_bytes32[]Array of 1 ID: adapterId (keccak256(abi.encode("this", address(this)))).

skimRecipient

address public skimRecipient

Returns the address that receives skimmed token balances.

Return Values:

NameTypeDescription
recipientaddressThe current skim recipient address.