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

MorphoMarketV1AdapterV2

Code

v2.0 repository

Introduction

MorphoMarketV1AdapterV2 is an adapter that connects a Morpho Vault V2 to Morpho Market V1. It manages supply positions across multiple markets and implements its own timelock system using the same submit/execute pattern as Morpho Vault V2, with its own distinct set of timelocked functions.


Function Selectors

Timelocked Functions and Selectors

Function NameSelector
increaseTimelock0x47966291
decreaseTimelock0x5c1a1a4f
abdicate0xb2e32848
setSkimRecipient0x2b30997b
burnShares0x3b2de5ac

Immutables

NameTypeDescription
factoryaddressThe factory contract that deployed this adapter.
parentVaultaddressThe Morpho Vault V2 that this adapter belongs to.
assetaddressThe underlying asset of the parent vault (must match the loan token of all managed markets).
morphoaddressThe Morpho (Morpho Blue) contract address.
adapterIdbytes32Unique identifier for this adapter instance, computed as keccak256(abi.encode("this", address(this))).
adaptiveCurveIrmaddressThe AdaptiveCurveIRM address. All managed markets must use this IRM.

Timelock System

The timelock system works identically to the one in Morpho Vault V2. The curator must submit a timelocked action, wait for the timelock to expire, then anyone can call the function directly.


submit

function submit(bytes calldata data) external

Submits a timelocked action for later execution.

Callable by: Curator

Parameters:

NameTypeDescription
databytesThe ABI-encoded function call data.

revoke

function revoke(bytes calldata data) external

Cancels a pending timelocked action.

Callable by: Curator, Sentinel

Parameters:

NameTypeDescription
databytesThe ABI-encoded function call data to revoke.

increaseTimelock

function increaseTimelock(bytes4 selector, uint256 newDuration) external

Increases the timelock duration for a specific function selector.

Callable by: Curator (timelocked — submit first, then anyone can execute after delay)

Selector: 0x47966291

Parameters:

NameTypeDescription
selectorbytes4The function selector whose timelock to increase.
newDurationuint256The new timelock duration in seconds. Must be greater than or equal to the current duration.

decreaseTimelock

function decreaseTimelock(bytes4 selector, uint256 newDuration) external

Decreases the timelock duration for a specific function selector. This action's own timelock equals the current timelock of the function being decreased.

Callable by: Curator (timelocked — submit first, then anyone can execute after delay)

Selector: 0x5c1a1a4f

Parameters:

NameTypeDescription
selectorbytes4The function selector whose timelock to decrease.
newDurationuint256The new timelock duration in seconds. Must be less than or equal to the current duration.

abdicate

function abdicate(bytes4 selector) external

Irreversibly disables the ability to execute a specific type of action.

Callable by: Curator (timelocked — submit first, then anyone can execute after delay)

Selector: 0xb2e32848

Parameters:

NameTypeDescription
selectorbytes4The function selector to permanently abdicate.

Curator Functions

setSkimRecipient

function setSkimRecipient(address newSkimRecipient) external

Sets the address that receives skimmed token balances (e.g., reward tokens earned by the adapter).

Callable by: Curator (timelocked — submit first, then anyone can execute after delay)

Selector: 0x2b30997b

Parameters:

NameTypeDescription
newSkimRecipientaddressThe new skim recipient address.

burnShares

function burnShares(bytes32 marketId) external

Burns the adapter's tracked supply shares for a market, setting supplyShares[marketId] to zero.

Callable by: Curator (timelocked — submit first, then anyone can execute after delay)

Selector: 0x3b2de5ac

Parameters:

NameTypeDescription
marketIdbytes32The market ID whose shares to burn.

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.

allocate

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

Supplies assets into the specified Morpho Market V1 market.

Callable by: parentVault

Parameters:

NameTypeDescription
databytesABI-encoded MarketParams struct identifying the target market.
assetsuint256The amount of assets to supply.

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 by this operation.
deltaint256The change in allocation (new allocation minus old allocation). Positive for allocate, negative for deallocate.

deallocate

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

Withdraws assets from the specified Morpho Market V1 market back to the parent vault.

Callable by: parentVault

Parameters:

NameTypeDescription
databytesABI-encoded MarketParams struct identifying the target market.
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 by this operation.
deltaint256The change in allocation (new allocation minus old allocation). Positive for allocate, negative for deallocate.

View Functions

realAssets

function realAssets() external view returns (uint256)

Returns the total expected supply assets across all managed markets, used by the parent vault during interest accrual.

Return Values:

NameTypeDescription
assetsuint256The total assets across all markets in marketIds.

expectedSupplyAssets

function expectedSupplyAssets(bytes32 marketId) public view returns (uint256)

Returns the expected supply assets for a specific market, accounting for the adapter's internal share balance.

Parameters:

NameTypeDescription
marketIdbytes32The market ID to query.

Return Values:

NameTypeDescription
assetsuint256The expected supply assets for the given market.

allocation

function allocation(MarketParams memory marketParams) public view returns (uint256)

Returns the vault's current allocation for this market, as recorded in the parent vault.

Parameters:

NameTypeDescription
marketParamsMarketParamsThe market parameters struct.

Return Values:

NameTypeDescription
assetsuint256The current allocation amount in the parent vault.

ids

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

Returns the three allocation IDs used by this adapter for a given market.

Parameters:

NameTypeDescription
marketParamsMarketParamsThe market parameters struct.

Return Values:

NameTypeDescription
ids_bytes32[]Array of 3 IDs: adapterId, keccak256(abi.encode("collateralToken", collateralToken)), and keccak256(abi.encode("this/marketParams", address(this), marketParams)).

marketIdsLength

function marketIdsLength() external view returns (uint256)

Returns the number of markets currently tracked by this adapter. Use this as the upper bound when iterating over marketIds.

Return Values:

NameTypeDescription
lengthuint256The number of market IDs in marketIds.

marketIds

bytes32[] public marketIds

Returns the market ID at the given position in the list of markets with non-zero allocation currently managed by this adapter.

Parameters:

NameTypeDescription
indexuint256The position in the array. Must be less than marketIdsLength().

Return Values:

NameTypeDescription
marketIdbytes32The market ID at the given index.

timelock

mapping(bytes4 selector => uint256) public timelock

Returns the timelock duration (in seconds) for a given function selector.

Parameters:

NameTypeDescription
selectorbytes4The function selector to query.

Return Values:

NameTypeDescription
durationuint256The timelock duration in seconds for the given selector.

abdicated

mapping(bytes4 selector => bool) public abdicated

Returns whether the curator has permanently abdicated the ability to execute a specific action.

Parameters:

NameTypeDescription
selectorbytes4The function selector to query.

Return Values:

NameTypeDescription
isAbdicatedbooltrue if the curator has abdicated the given selector, false otherwise.

executableAt

function executableAt(bytes memory data) external view returns (uint256)

Returns the Unix timestamp (seconds) at which a submitted timelocked action becomes executable.

Parameters:

NameTypeDescription
databytesThe ABI-encoded function call data of the pending action.

Return Values:

ValueMeaning
0No pending action (never submitted, already executed, or revoked)
<= block.timestampAction is currently executable (timelock has elapsed)
> block.timestampNot yet executable — equals submissionTimestamp + timelock[selector]

supplyShares

mapping(bytes32 marketId => uint256) public supplyShares

Returns the adapter's tracked supply shares for a given market.

Parameters:

NameTypeDescription
marketIdbytes32The market ID to query.

Return Values:

NameTypeDescription
sharesuint256The adapter's tracked supply shares for the given market.

skimRecipient

address public skimRecipient

Returns the address that receives skimmed token balances.