Skip to main content

BorrowMidnightToBlueCallback

Git Source - Generated with forge doc

Inherits: IBorrowMidnightToBlueCallback

Title: BorrowMidnightToBlueCallback

Callback that migrates a borrower position from Midnight to Morpho Blue when a Midnight BUY offer is taken.

Withdraws collateral from Midnight pro-rata to the repaid debt (all of it on the final fill), supplies it to Morpho Blue, and borrows buyerAssets + fee on Morpho Blue on behalf of the borrower to settle the offer.

Only the target Blue market's single collateral token migrates; other source collaterals stay on Midnight, which can adversely affect the source or target LTV. Use only the target's collateral on the source position.

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

The fee is borrowed in addition to buyerAssets so any feeRate > 0 raises the post-migration Blue LTV.

The borrower must authorize this contract on Morpho Midnight (collateral withdrawal) and Morpho Blue (borrow).

Reverts if the fill would leave the borrower with credit on the Midnight market.

Relies on available Morpho Blue liquidity for the borrow; fills revert if it is insufficient at fill time.

Constants

MORPHO_MIDNIGHT

IMidnight public immutable MORPHO_MIDNIGHT

MORPHO_BLUE

IMorpho public immutable MORPHO_BLUE

Functions

constructor

constructor(address morphoMidnight, address morphoBlue) ;

onBuy

function onBuy(
bytes32 marketId,
Market memory market,
uint256 buyerAssets,
uint256 units,
uint256,
address buyer,
bytes memory data
) external override returns (bytes32);