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
| Name | Type | Description |
|---|---|---|
market | Market | The market to repay. |
assets | uint256 | The amount of assets to repay. Pass type(uint256).max to use the adapter's full balance. |
debt | uint256 | The amount to repay. Pass type(uint256).max to repay the initiator's entire debt. |
callbackAddr | address | The Midnight.repay callback target, forwarded as-is. Pass address(0) for no callback. MidnightAdapterBase does not implement an onRepay handler. |
callbackData | bytes | Arbitrary 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
| Name | Type | Description |
|---|---|---|
market | Market | The market to supply collateral to. |
collateralIndex | uint256 | The index of the collateral in market.collateralParams. |
assets | uint256 | The 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
| Name | Type | Description |
|---|---|---|
market | Market | The market to withdraw collateral from. |
collateralIndex | uint256 | The index of the collateral in market.collateralParams. |
assets | uint256 | The amount of collateral to withdraw. Pass type(uint256).max to withdraw the initiator's full collateral balance. |
receiver | address | The 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
| Name | Type | Description |
|---|---|---|
market | Market | The market to withdraw from. |
units | uint256 | The amount of market units to withdraw. Pass type(uint256).max to withdraw all the initiator's credit after position update (slashing + fee accrual). |
receiver | address | The 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
| Name | Type | Description |
|---|---|---|
group | bytes32 | The offer group to set consumed amount for. |
amount | uint256 | The 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
| Name | Type | Description |
|---|---|---|
tokens | address[] | The addresses of the tokens to flash loan. |
assets | uint256[] | The amounts of assets to flash loan, paired with tokens by index. |
data | bytes | Arbitrary data forwarded to onFlashLoan (bundler3 reenter payload). |
Errors
InconsistentInput
error InconsistentInput();