BorrowBlueToMidnightCallback
Git Source - Generated with forge doc
Inherits: IBorrowBlueToMidnightCallback
Title: BorrowBlueToMidnightCallback
Callback that migrates a borrower position from Morpho Blue to the target Midnight market when that market's SELL offer is taken.
The offer's receiverIfMakerIsSeller (or receiverIfTakerIsSeller when the taker sells) must be this contract so that sellerAssets are transferred here before onSell is called; onSell reverts with InvalidReceiver otherwise.
Repays the Morpho Blue debt with the sale proceeds (minus fee) and migrates collateral to Midnight pro-rata to the repaid debt (all of it on the final fill).
The borrower must authorize this contract on Morpho Blue (collateral withdrawal) and Morpho Midnight (collateral supply).
Pre-existing Midnight positions are netted: the borrower can end up with collateral but no debt on Midnight.
Partial fills migrate collateral pro-rata to the repaid debt, rounded down, so a small fill can migrate less collateral than the repaid debt implies — down to zero on tiny fills — temporarily increasing the target position's LTV until the final fill migrates all remaining collateral.
Constants
MORPHO_MIDNIGHT
IMidnight public immutable MORPHO_MIDNIGHT
MORPHO_BLUE
IMorpho public immutable MORPHO_BLUE
Functions
constructor
constructor(address morphoMidnight, address morphoBlue) ;
onSell
function onSell(
bytes32 marketId,
Market memory market,
uint256 sellerAssets,
uint256 units,
uint256, /* pendingFeeDecrease */
address seller,
address receiver,
bytes memory data
) external override returns (bytes32);