Skip to main content

IMidnightVaultExecutor

Git Source - Generated with forge doc

Title: IMidnightVaultExecutor

Interface of the executor that routes ERC-4626-vault-share collateral operations on Morpho Midnight.

No per-share-price/slippage protection is enforced: operations settle at the vault's reported share price. The caller is responsible for using a vault that protects against share price manipulation.

Repay/liquidate go through Midnight directly with callback = executor (and receiver = executor for liquidate); the onRepay/onLiquidate callbacks handle the collateral.

Repay callback data is abi.encode(collateralIndex, sharesToWithdraw); the liquidate data is unused (empty).

The caller must be authorized to act for onBehalf on Midnight.

onLiquidate reverts unless the liquidation's seized-collateral receiver is this executor; the redeem would otherwise burn the executor's own resting vault shares.

Functions

depositAndAddCollateral

Deposits into the market's vault-share collateral and supplies the resulting shares for onBehalf.

Provide either assets (and shares == 0) or shares (and assets == 0), not both.

function depositAndAddCollateral(
Market calldata market,
uint256 collateralIndex,
uint256 assets,
uint256 shares,
address onBehalf
) external returns (uint256 depositedShares, uint256 usedAssets);

Parameters

NameTypeDescription
marketMarketThe target market.
collateralIndexuint256The index in market.collateralParams whose token is the ERC-4626 vault deposited into.
assetsuint256The deposit amount in vault assets. Set to 0 if supplying shares.
sharesuint256The target share output. Set to 0 if supplying assets.
onBehalfaddressThe account credited with the collateral on Midnight.

Returns

NameTypeDescription
depositedSharesuint256The vault shares supplied as collateral.
usedAssetsuint256The vault assets consumed by the deposit.

withdrawCollateralAndRedeem

Withdraws vault-share collateral from Midnight and redeems it into vault assets for receiver.

function withdrawCollateralAndRedeem(
Market calldata market,
uint256 collateralIndex,
uint256 shares,
address onBehalf,
address receiver
) external returns (uint256 assets);

Parameters

NameTypeDescription
marketMarketThe source market.
collateralIndexuint256The index in market.collateralParams whose token is the ERC-4626 vault redeemed from.
sharesuint256The vault shares to withdraw and redeem.
onBehalfaddressThe account whose collateral is withdrawn.
receiveraddressThe address that receives the redeemed assets.

Returns

NameTypeDescription
assetsuint256The vault assets transferred to receiver.

Errors

Unauthorized

error Unauthorized();

InvalidInput

error InvalidInput();

LiquidationReceiverMismatch

error LiquidationReceiverMismatch();

RepayExceedsRedeemed

error RepayExceedsRedeemed();