Skip to main content

IMidnightAdapter

Git Source - Generated with forge doc

Inherits: IFlashLoanCallback

Functions

MORPHO_MIDNIGHT

function MORPHO_MIDNIGHT() external view returns (IMidnight);

midnightRepay

Repays debt on Morpho Midnight on behalf of the initiator.

Strictly uses tokens already on the adapter (does not pull from initiator).

assets and debt are mutually exclusive: passing both non-zero reverts InconsistentInput. If the resolved repay amount is zero (e.g. a max sentinel on a zero-balance adapter or a zero-debt position), the call returns silently rather than reverting, so a best-effort residual or sweep repay can sit unconditionally in a bundle even when an earlier leg already cleared the debt.

function midnightRepay(
Market calldata market,
uint256 assets,
uint256 debt,
address callbackAddr,
bytes calldata callbackData
) external;

Parameters

NameTypeDescription
marketMarketThe market to repay.
assetsuint256The amount of assets to repay. Pass type(uint256).max to use the adapter's full balance.
debtuint256The amount to repay. Pass type(uint256).max to repay the initiator's entire debt.
callbackAddraddressThe Midnight.repay callback target, forwarded as-is. Pass address(0) for no callback. MidnightAdapterBase does not implement an onRepay handler.
callbackDatabytesArbitrary data forwarded to callbackAddr.onRepay. Unused when callbackAddr == address(0).

midnightSupplyCollateral

Supplies collateral to Morpho Midnight on behalf of the initiator.

Strictly uses tokens already on the adapter (does not pull from initiator).

function midnightSupplyCollateral(Market calldata market, uint256 collateralIndex, uint256 assets) external;

Parameters

NameTypeDescription
marketMarketThe market to supply collateral to.
collateralIndexuint256The index of the collateral in market.collateralParams.
assetsuint256The amount of collateral to supply. Pass type(uint256).max to use the adapter's full balance.

midnightWithdrawCollateral

Withdraws collateral from Morpho Midnight on behalf of the initiator.

function midnightWithdrawCollateral(
Market calldata market,
uint256 collateralIndex,
uint256 assets,
address receiver
) external;

Parameters

NameTypeDescription
marketMarketThe market to withdraw collateral from.
collateralIndexuint256The index of the collateral in market.collateralParams.
assetsuint256The amount of collateral to withdraw. Pass type(uint256).max to withdraw the initiator's full collateral balance.
receiveraddressThe account receiving the withdrawn collateral.

midnightWithdraw

Withdraws from a market on Morpho Midnight on behalf of the initiator.

function midnightWithdraw(Market calldata market, uint256 units, address receiver) external;

Parameters

NameTypeDescription
marketMarketThe market to withdraw from.
unitsuint256The amount of market units to withdraw. Pass type(uint256).max to withdraw all the initiator's credit after position update (slashing + fee accrual).
receiveraddressThe account receiving the withdrawn assets.

midnightSetConsumed

Sets the consumed amount for an offer group on Morpho Midnight on behalf of the initiator.

Used for atomic cancel operations (cancel + withdraw, cancel + disable auto-renewal). Passing type(uint256).max cancels all offers in the group.

function midnightSetConsumed(bytes32 group, uint256 amount) external;

Parameters

NameTypeDescription
groupbytes32The offer group to set consumed amount for.
amountuint256The new consumed amount (must be >= current consumed amount).

midnightFlashLoan

Triggers a flash loan on Morpho Midnight.

The flash-loaned tokens land on this adapter; the reenter actions in data must consume (and repay) them within the loan, as any balance left on the adapter is skimmable by a later bundle.

function midnightFlashLoan(address[] calldata tokens, uint256[] calldata assets, bytes calldata data) external;

Parameters

NameTypeDescription
tokensaddress[]The addresses of the tokens to flash loan.
assetsuint256[]The amounts of assets to flash loan, paired with tokens by index.
databytesArbitrary data forwarded to onFlashLoan (bundler3 reenter payload).

Errors

InconsistentInput

error InconsistentInput();