LendVaultToMidnightCallback
Git Source - Generated with forge doc
Inherits: ILendVaultToMidnightCallback
Title: LendVaultToMidnightCallback
Callback that redeems ERC-4626 vault shares to fund a lender's BUY offer on the target Midnight market when it is taken.
Withdraws buyerAssets + fee from the vault, transfers the fee to the recipient, and approves Morpho Midnight to pull buyerAssets.
The lender must approve this contract for vault shares. VAULT SAFETY REQUIREMENTS
List of assumptions on the source vault that guarantee this callback behaves as expected:
- Its share price must not move adversely between offer creation and fill: the withdrawal burns whatever shares the vault's rate dictates at fill time, with no maximum-shares bound. The vault must be resistant to atomic share-price manipulation (e.g. sandwiched via donation).
- It must have immediate exit liquidity for
buyerAssets + fee, otherwisewithdrawreverts and the fill fails. - Its shares should carry high decimals (e.g. 18 via a virtual-shares offset) so per-fill rounding is negligible;
shares that match a low-decimal underlying let dust-sized fills socialize per-fill rounding loss to other depositors
over many takes (
takeUnitshas no minimum). - It must not re-enter Midnight nor this callback on
withdraw.
Constants
MORPHO_MIDNIGHT
IMidnight public immutable MORPHO_MIDNIGHT
Functions
constructor
constructor(address morphoMidnight) ;
onBuy
function onBuy(
bytes32 marketId,
Market memory market,
uint256 buyerAssets,
uint256 units,
uint256, /* pendingFeeIncrease */
address buyer,
bytes memory data
) external override returns (bytes32);