Tenor Midnight callbacks
Callbacks are stateless, non-upgradeable 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 Ratifier and run as part of the migration flow, and standalone callbacks, which are used directly through MORPHO_MIDNIGHT.take() without involving the ratifier.
Renewal and migration
| Callback | Direction | Side | Page |
|---|---|---|---|
BorrowMidnightRenewalCallback | Midnight → Midnight | Borrower | Borrow Midnight Renewal |
LendMidnightRenewalCallback | Midnight → Midnight | Lender | Lend Midnight Renewal |
BorrowBlueToMidnightCallback | Blue → Midnight | Borrower | Blue to Midnight |
LendVaultToMidnightCallback | Vault → Midnight | Lender | Vault to Midnight |
BorrowMidnightToBlueCallback | Midnight → Blue | Borrower | Midnight to Blue |
LendMidnightToVaultCallback | Midnight → Vault | Lender | Midnight to Vault |
Standalone
| Callback | Purpose | Page |
|---|---|---|
MidnightSupplyCollateralCallback | Pull and supply collateral atomically on a take | Supply collateral |
MidnightSupplyVaultSharesCallback | Wrap loan tokens into ERC-4626 vault shares and supply as collateral on a take | Supply vault shares as collateral |
MidnightWithdrawVaultSharesCallback | Withdraw vault shares from collateral and redeem to loan tokens on an early exit | Withdraw vault shares as collateral |
MidnightWithdrawableCallback | Standing par buy (lend) offer funded from a market's withdrawable: lenders exit at par, borrowers borrow at 0% interest, each minus Midnight's settlement fee | Withdrawable |
Common properties
msg.sendercheck: Every callback rejects any caller other than Morpho Midnight (OnlyMidnight).- Immutability: All callbacks pin their integration addresses (Morpho Midnight, Morpho Blue) as constructor immutables. The contract code cannot be upgraded. Tenor can pause certain optional functions and holds fee parameters that are switched off; see Pausable functions.
- No stored state: Callbacks hold assets only transiently, within the take, and keep 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.
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).
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. Tenor charges no fees today. Some Tenor contracts contain fee parameters; they are switched off. Two fee models are used:
- Effective-price fee on interest (Midnight renewals, Blue → Midnight, Vault → Midnight). Derived from the offer's tick and applied to the interest portion of the offer.
- Flat percentage fee on total assets (Midnight → Blue and Midnight → Vault). Percentage of the value moved to the variable-rate market or vault.
Standalone callbacks (MidnightSupplyCollateralCallback, vault-shares callbacks, MidnightWithdrawableCallback) have no ability to set fees. Fills through the withdrawable callback still pay Midnight's settlement fee.