Offers

Makers create and sign offers offchain to specify the price and maximum size they are willing to buy or sell in a market. Offers are not broadcast by Midnight - they can be distributed through any external channel, offchain or onchain.

A taker executes an offer by submitting it to the Midnight contract. Takes may be partial: any size up to the offer's remaining capacity is permitted, and a single offer can be filled by multiple takers until exhausted. Midnight settles atomically against the referenced market, creating, transferring, or burning the corresponding credit and debt units.

Offers may specify a callback that runs at take time. This lets makers source assets or collateral only when the offer is filled, instead of provisioning their positions in advance.

Finding the best available offer across all distribution channels requires takers to account for callbacks, shared group budgets, and gas. This process, referred to as routing, takes place outside the protocol and can be performed by anyone.

Maker and taker

Maker and taker are execution roles. A maker publishes an offer: a price and size they are willing to trade at. A taker executes it, submitting the transaction that settles it against the market. Every settlement also has a buyer, who receives units, and a seller, who gives them up. This is independent of the execution role - a maker can post either a buy or a sell offer, so makers and takers alike can end up on either side.

The direction is what sets the resulting position:

  • Buying units increases credit - a lending position.
  • Selling units increases debt - a borrowing position.

These describe opening a position. A participant who already holds the opposite position reduces it first - see Settlement paths for how a trade nets against an existing position.

Same economics, different execution

Example: a borrower wants loan tokens today and is willing to repay at maturity.

One route:

  1. The borrower is the maker.
  2. The borrower publishes a sell offer.
  3. A lender takes the offer and buys units.
  4. The borrower receives loan tokens and ends with debt.
  5. The lender pays loan tokens and ends with credit.

Another route:

  1. The lender is the maker.
  2. The lender publishes a buy offer.
  3. The borrower takes the offer and sells units.
  4. The borrower receives loan tokens and ends with debt.
  5. The lender pays loan tokens and ends with credit.

The economic result is the same. Only the maker/taker roles changed.

Settlement paths

The same offer mechanism handles both entering and exiting positions. Each side's outcome depends only on their own position at settlement:

  • A buyer who already holds debt reduces it first, then adds credit.
  • A seller who already holds credit reduces it first, then adds debt.

The four combinations follow:

BuyerSellerWhat it represents
Increases creditIncreases debtA new lender meets a new borrower.
Increases creditReduces creditA lender enters while another lender exits.
Reduces debtIncreases debtA borrower exits while another borrower enters.
Reduces debtReduces creditA lender and a borrower both exit.

After maturity, debt can no longer be increased, so the two paths where the seller would take on debt are blocked. The remaining paths stay open, letting participants unwind positions.

What an offer can define

An offer can define:

  1. Market: the market the offer applies to
  2. Direction: whether the maker wants to buy or sell units
  3. Price: the unit price at which the maker is willing to trade
  4. Size: the maximum amount the offer can fill
  5. Expiry: when the offer becomes active and when it expires
  6. Ratifier: a contract that validates whether the offer can be used
  7. Callback: custom logic that runs at settlement, useful for sourcing assets just-in-time
  8. Group budget: a shared fill limit across multiple offers, capping total exposure

This list covers the main parameters an offer can express. Offers may include other fields too.

Offer discovery and routing

Midnight does not maintain a single global onchain list of available offers. Available offers can come from different distribution channels, such as:

  • an offer mempool
  • an RFQ flow
  • a direct quote from a maker
  • another offchain or onchain distribution channel

Apps and routers do not replace those distribution channels. Their role is to help users interact with them.

For makers, an app or router can help create and format offers.

For takers, an app or router can help browse available offers, compare them, and choose which one, or which combination, to submit. It may compare price, size, expiry, gas cost, callbacks, shared budgets, and whether the offer is expected to pass ratifier validation.

Discovery, routing, validation, and settlement are separate:

  • offer distribution: makes offers available to potential takers
  • routing: helps users find and select offers
  • ratifier validation: decides whether a submitted offer can be used
  • Midnight settlement: moves assets if needed and updates the market's credit, debt, and withdrawable liquidity according to the settlement path

Offer validation

When a taker submits an offer to Midnight, the contract calls the offer's ratifier — the contract that embeds the offer's validation logic — to check whether it can be used. Typically, the ratifier verifies a signature of the offer against the maker's public key. The design is modular: other ratifiers can use different signature schemes, such as passkeys or post-quantum schemes, or add custom logic — for example, ratifying a whole set of offers with a single signature.

Callbacks

A callback lets a maker source funds or collateral only when an offer is filled, instead of provisioning them in advance. The capital backing an offer can stay deployed productively elsewhere until it is needed. This enables a few patterns:

  • A lender can keep assets in a Morpho Blue market while quoting a fixed-rate offer on Midnight; if the offer is taken, the callback withdraws the funds and completes settlement in the same transaction.
  • A borrower approaching maturity can buy back or repay debt in one market and enter a later-maturity market atomically, rolling their exposure. Mechanically, an offer can specify a callback that runs during settlement. When the offer is taken, the callback executes, sourcing the required assets so that settlement can complete — all within a single transaction.

Shared offer budgets

A maker may want to publish offers across many markets but cap total exposure. Midnight supports groups that share a fill budget across related offers.

If one offer in the group is filled, the remaining budget for the other offers decreases. This prevents the maker from accidentally filling more than intended across all offers combined.

Example: a maker has a shared budget of 1,000 units.

  • Offer A can be taken in Market 1.
  • Offer B can be taken in Market 2.

If Offer A fills 600 units, the remaining shared budget is 400 units. Offer B can now fill at most 400 units.

On this page