MorphoVaultV1Adapter
Code
v2.0 repositoryIntroduction
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
| Name | Type | Description |
|---|---|---|
factory | address | The factory contract that deployed this adapter. |
parentVault | address | The Morpho Vault V2 that this adapter belongs to. |
morphoVaultV1 | address | The Morpho Vault V1 (MetaMorpho) contract that this adapter deposits into. |
adapterId | bytes32 | Unique identifier for this adapter instance, computed as keccak256(abi.encode("this", address(this))). |
Owner Functions
setSkimRecipient
function setSkimRecipient(address newSkimRecipient) externalSets the address that receives skimmed token balances.
Callable by: Owner of the parent vault (instant — no timelock)
Parameters:
| Name | Type | Description |
|---|---|---|
newSkimRecipient | address | The new skim recipient address. |
Other Functions
skim
function skim(address token) externalTransfers the adapter's entire balance of token to skimRecipient.
Callable by: skimRecipient
Parameters:
| Name | Type | Description |
|---|---|---|
token | address | The 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:
| Name | Type | Description |
|---|---|---|
data | bytes | Must be empty (0x). |
assets | uint256 | The amount of assets to deposit. |
The bytes4 and address parameters are part of the shared adapter interface but unused by this implementation.
Return Values:
| Name | Type | Description |
|---|---|---|
ids | bytes32[] | The allocation IDs affected (contains adapterId). |
delta | int256 | The 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:
| Name | Type | Description |
|---|---|---|
data | bytes | Must be empty (0x). |
assets | uint256 | The amount of assets to withdraw. |
The bytes4 and address parameters are part of the shared adapter interface but unused by this implementation.
Return Values:
| Name | Type | Description |
|---|---|---|
ids | bytes32[] | The allocation IDs affected (contains adapterId). |
delta | int256 | The 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:
| Name | Type | Description |
|---|---|---|
assets | uint256 | The 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:
| Name | Type | Description |
|---|---|---|
assets | uint256 | The 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:
| Name | Type | Description |
|---|---|---|
ids_ | bytes32[] | Array of 1 ID: adapterId (keccak256(abi.encode("this", address(this)))). |
skimRecipient
address public skimRecipientReturns the address that receives skimmed token balances.
Return Values:
| Name | Type | Description |
|---|---|---|
recipient | address | The current skim recipient address. |
