Skip to main content

BorrowMidnightRenewalCallback

Git Source - Generated with forge doc

Inherits: IBorrowMidnightRenewalCallback

Title: BorrowMidnightRenewalCallback

Callback that renews a borrower position from a source 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 source Midnight market debt with the sale proceeds (minus fee) and transfers collateral to the target Midnight market pro-rata to the repaid debt (all of it on the final fill).

The borrower must authorize this contract on Morpho Midnight (debt repayment and collateral transfer).

The source and target markets must list the same collateral token set. Only the loan token is checked onchain; collateral tokens missing from the target market are skipped and stay on the source market.

With multiple source collaterals, only those also listed on the target migrate, which can adversely affect the source or target LTV. Use a single collateral, or make the target collateral set a superset of the source's.

Pre-existing positions on the target market are netted: the borrower can end up with collateral but no debt.

On small partial fills, the pro-rata collateral transfer can round to zero even though debt is migrated, temporarily increasing the target position's LTV until the position is fully migrated.

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, /* pendingFeeDecrease */
address seller,
address receiver,
bytes memory data
) external override returns (bytes32);