Skip to main content

Tenor Midnight Callbacks

Callbacks are stateless, immutable contracts invoked by Morpho Midnight during take(). Each callback encodes a specific state transition, runs atomically within the take, and leaves no stored state between calls.

Throughout these pages, Midnight refers to Morpho Midnight (fixed-rate, fixed-term) and Blue refers to Morpho Blue (variable-rate). sellerAssets and buyerAssets always refer to the filled amounts on the offer being taken.

Callback Catalog

The callbacks divide into two groups: renewal/migration callbacks, which are referenced by the Migration Intent Ratifier and run as part of the migration intent flow, and standalone callbacks, which are used directly through MORPHO_MIDNIGHT.take() without involving the ratifier.

Renewal & Migration

CallbackDirectionSidePage
BorrowMidnightRenewalCallbackMidnight → MidnightBorrowerBorrow Midnight Renewal
LendMidnightRenewalCallbackMidnight → MidnightLenderLend Midnight Renewal
BorrowBlueToMidnightCallbackBlue → MidnightBorrowerBlue to Midnight
LendVaultToMidnightCallbackBlue → MidnightLenderVault to Midnight
BorrowMidnightToBlueCallbackMidnight → BlueBorrowerMidnight to Blue
LendMidnightToVaultCallbackMidnight → BlueLenderMidnight to Vault

Standalone

CallbackPurposePage
MidnightSupplyCollateralCallbackPull and supply collateral atomically on a takeSupply Collateral
MidnightSupplyVaultSharesCallbackWrap loan tokens into ERC-4626 vault shares and supply as collateral on a takeSupply Vault Shares as Collateral
MidnightWithdrawVaultSharesCallbackWithdraw vault shares from collateral and redeem to loan tokens on an early exitWithdraw Vault Shares as collateral

Common Guarantees

  • msg.sender check: Every callback rejects any caller other than Morpho Midnight (OnlyMidnight).
  • Immutability: All callbacks pin their integration addresses (Morpho Midnight, Morpho Blue) as constructor immutables. Behavior never changes after deployment.
  • No stored state: Callbacks hold no balances and no per-user state. Anything left on a callback is recoverable only by a subsequent take that consumes it as input.
  • Health enforcement: Morpho Midnight checks the resulting position's health after the callback returns. A callback that leaves the borrower undercollateralized causes the entire take to revert.
Do not send tokens directly to callback contracts

Tokens transferred directly to a callback contract outside an active take can be lost; the next compatible take can consume them as inputs. Always route token movement through MORPHO_MIDNIGHT.take() (or the Tenor Adapter). Never transfer directly to a callback address.

Fees

Renewal and migration callbacks accept an optional fee. The fee can be set by the user when creating an offer with the callback, or be forced by a ratifier. Two fee models are used:

  • Percentage of interest fee (Midnight → Midnight and Blue → Midnight). Derived from the offer's tick and applied to the interest portion of the offer.
  • Flat percentage fee (Midnight → Blue and Midnight → Vault). Percentage of the value moved to the variable-rate market or vault.

Standalone callbacks (MidnightSupplyCollateralCallback, vault-shares callbacks) have no ability to set fees.