Skip to main content

LendMidnightToVaultCallback

Git Source - Generated with forge doc

Inherits: ILendMidnightToVaultCallback

Title: LendMidnightToVaultCallback

Callback that deposits a lender's exit proceeds into an ERC-4626 vault when a Midnight 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.

Deposits sellerAssets minus a percentage fee into the vault on behalf of the lender.

Reverts if the seller has debt on the market.

On Morpho Vault-v2, deposits can revert if a liquidity-adapter cap is reached, blocking otherwise valid fills. VAULT SAFETY REQUIREMENTS

List of assumptions on the destination vault that guarantee this callback behaves as expected:

  • Its share price must not move adversely between offer creation and fill: the deposit accepts whatever rate the vault reports at fill time, with no minimum-shares bound. The vault must be resistant to atomic share-price manipulation (e.g. sandwiched via donation).
  • 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 (takeUnits has no minimum).
  • It must not re-enter Midnight nor this callback on deposit.

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);