Skip to main content

MidnightSupplyCollateralCallback

Git Source - Generated with forge doc

Inherits: IMidnightSupplyCollateralCallback

Title: MidnightSupplyCollateralCallback

Supplies a borrower's collateral just in time when a SELL offer is taken on Midnight.

The borrower must approve this contract per collateral token and authorize it on Midnight.

Collateral is scaled to the fill and rounded down; slots that round to zero are skipped, so many small fills can supply less collateral than one full fill. maxBorrowCapacityUsage guards the resulting position health.

The offer's receiver must not be this contract; onSell reverts InvalidReceiver otherwise.

Constants

MORPHO_MIDNIGHT

IMidnight public immutable MORPHO_MIDNIGHT

Functions

constructor

constructor(address morphoMidnight) ;

onSell

function onSell(
bytes32 marketId,
Market memory market,
uint256 sellerAssets,
uint256 units,
uint256,
address seller,
address receiver,
bytes memory data
) external override returns (bytes32);

_borrowCapacityUsage

Returns borrower's debt as a fraction of borrowing capacity, rounded up; Midnight's isHealthy() ratio, where WAD is the liquidation threshold.

function _borrowCapacityUsage(Market memory market, address borrower, bytes32 marketId)
internal
view
returns (uint256);