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
| Name | Type | Description |
|---|---|---|
market | Market | The target market. |
collateralIndex | uint256 | The index in market.collateralParams whose token is the ERC-4626 vault deposited into. |
assets | uint256 | The deposit amount in vault assets. Set to 0 if supplying shares. |
shares | uint256 | The target share output. Set to 0 if supplying assets. |
onBehalf | address | The account credited with the collateral on Midnight. |
Returns
| Name | Type | Description |
|---|---|---|
depositedShares | uint256 | The vault shares supplied as collateral. |
usedAssets | uint256 | The 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
| Name | Type | Description |
|---|---|---|
market | Market | The source market. |
collateralIndex | uint256 | The index in market.collateralParams whose token is the ERC-4626 vault redeemed from. |
shares | uint256 | The vault shares to withdraw and redeem. |
onBehalf | address | The account whose collateral is withdrawn. |
receiver | address | The address that receives the redeemed assets. |
Returns
| Name | Type | Description |
|---|---|---|
assets | uint256 | The vault assets transferred to receiver. |
Errors
Unauthorized
error Unauthorized();
InvalidInput
error InvalidInput();
LiquidationReceiverMismatch
error LiquidationReceiverMismatch();
RepayExceedsRedeemed
error RepayExceedsRedeemed();