# What is Midnight?

Understand Midnight fixed-rate lending, market units, offers, early exits, collateral, liquidations, gates, and fees for lenders and borrowers.

Source: https://docs.morpho.org/learn/concepts/midnight



Midnight is a noncustodial fixed rate lending protocol. No intermediary holds user assets, and users retain direct ownership of their positions.

Users lend or borrow by buying or selling market units that mature on a fixed date. The unit price determines the implied fixed rate for the remaining term.

## Markets [#markets]

Midnight is built around isolated markets that can be created permissionlessly. Each market's configuration is fixed at creation:

| Parameter                       | Description                                                                                                                          |
| :------------------------------ | :----------------------------------------------------------------------------------------------------------------------------------- |
| Loan token                      | The asset lent, borrowed, and repaid.                                                                                                |
| Maturity date                   | When outstanding debt is due.                                                                                                        |
| Collateral configurations       | From 1 to 128 collateral assets, each with its own token, oracle, liquidation loan-to-value (LLTV), and liquidation cursor.          |
| Recovery close factor threshold | A loan-token amount used to relax liquidation limits for small remaining collateral balances.                                        |
| Optional gates                  | Two contract addresses controlling who may increase credit or debt, and who may liquidate. A zero address means unrestricted access. |

Each market has a unique 32-byte ID derived from its full configuration, including the chain ID and Midnight contract address. Changing any parameter produces a different market ID.

### Governance-approved parameters [#governance-approved-parameters]

Each collateral's LLTV and liquidation cursor used at market creation must be values enabled by Morpho governance. Values can be enabled but never disabled.

#### LLTV \[!toc] [#lltv]

LLTV determines how much of a collateral's oracle value contributes to the borrower's maximum debt. The enabled LLTVs are:

| LLTV  | Contract value (scaled by 1e18) |
| :---- | :------------------------------ |
| 38.5% | 385000000000000000              |
| 62.5% | 625000000000000000              |
| 77%   | 770000000000000000              |
| 86%   | 860000000000000000              |
| 91.5% | 915000000000000000              |
| 94.5% | 945000000000000000              |
| 96.5% | 965000000000000000              |
| 98%   | 980000000000000000              |
| 100%  | 1000000000000000000             |

#### Liquidation cursor \[!toc] [#liquidation-cursor]

The enabled liquidation cursor is **0.3** (`300000000000000000`), which controls the maximum liquidation incentive. See [liquidation incentive](/learn/concepts/midnight/liquidation/#liquidation-incentive) for how these parameters affect positions.

These values are enabled on Ethereum, Base, Tempo, Robinhood, and Arc. Governance can add more values; check [`isLltvEnabled`](/developers/contracts/midnight/#islltvenabled) and [`isLiquidationCursorEnabled`](/developers/contracts/midnight/#isliquidationcursorenabled) on the relevant Midnight contract for the current status.

## Units, credit, and debt [#units-credit-and-debt]

Within a market, positions are tracked with **units**.

* A borrower has **debt** units: an obligation to repay one loan token per unit before maturity.
* A lender has **credit** units: each unit is a claim on one loan token repaid by borrowers.

Midnight contracts don't store a rate. They record trades at a unit price, and the unit price determines the implied fixed rate. For a unit price `P > 0`, the simple rate over the remaining term is:

`r = 1 / P - 1`

<Callout type="info">
  For example, if a lender buys 1 unit for 0.95 loan tokens, the implied rate over the remaining term is 1 / 0.95 - 1 = 5.26%, before fees and losses.

  To compare across maturities, this return can be annualized using the time remaining:

  * If maturity is in 1 month: 5.26% / (1/12) = 63.16% APR
  * If maturity is in 6 months: 5.26% / 0.5 = 10.53% APR
  * If maturity is in 1 year: 5.26% / 1 = 5.26% APR
</Callout>

## Rates are quoted as APR [#rates-are-quoted-as-apr]

Morpho quotes the annualized rate from the example above as APR: the simple return to maturity, scaled to one year without compounding. With `T` years left to maturity:

`APR = r / T`

Since October 9, 2026, the Morpho app and the Midnight endpoints of the Morpho API both use this convention. Before that date they quoted Midnight rates as APY, so rates recorded earlier won't match the ones shown now. The convention only affects how the rate is displayed: offers still settle at their unit price.

Morpho Blue markets and Morpho Vaults still quote their variable rates as APY, which includes compounding. Don't compare the two as if they were the same measure: the same return gives a different APR and APY. For example, a 9% APR over six months is about 9.20% APY.

## Fungibility [#fungibility]

Every settlement has a buyer and a seller, but it does not create a lasting bilateral loan between them.

After settlement, positions are accounted at the market level. A lender holds credit in the market, not a claim against one specific borrower. A borrower owes debt to the market, not to one specific lender.

Positions created at different times in the same market share its full configuration. Within that market, any credit unit is interchangeable with any other, as is any debt unit.

## Early exits [#early-exits]

Users can reduce an existing position at any time by taking offers in the opposite direction, since taking an offer first offsets the current position before building the opposite one:

* A lender can sell units to reduce credit.
* A borrower can buy units to reduce debt.
* A borrower can also repay directly: repaying one loan token removes one debt unit.

Buying and selling can continue after maturity, except that debt can no longer be increased. This still allows positions to be unwound, which is useful when liquidations are unprofitable.

## Offers [#offers]

Makers publish offers, specifying the price and size at which they are willing to buy or sell units. Midnight does not broadcast offers itself - they circulate through external channels, and routers help takers find executable offers across them. A taker executes an offer by submitting it to the Midnight contract, which settles atomically against the referenced market - creating, transferring, or burning the corresponding credit and debt units.

More on offers, routing, callbacks, and settlement paths [here](/learn/concepts/midnight/offers/).

## Collateral and liquidations [#collateral-and-liquidations]

Each market defines which collateral assets it accepts. A market can accept one collateral asset or several.

Borrowers can supply and withdraw collateral as long as withdrawals do not make the position unhealthy. In multi-collateral markets, a borrower may change their collateral mix over time.

A borrower's collateral determines their `maxDebt`: the maximum debt the position can support. The position is healthy when its debt is less than or equal to `maxDebt`.

A position can be liquidated if it becomes unhealthy, or if debt remains unpaid after maturity. In a liquidation, a liquidator repays part or all of the debt and receives collateral according to the market's liquidation rules.

More on liquidation mechanics [here](/learn/concepts/midnight/liquidation/).

## Gates [#gates]

Midnight is designed to support flexible access-control policies. Markets may specify up to two optional gate contracts at creation, fixed thereafter, that let each market embed conditions specific to its intended use. Those gates are designed in a noncustodial way and cannot lock or take control of user assets.

More on gates [here](/learn/concepts/midnight/gates/).

## Fees [#fees]

Midnight has two protocol-level fee systems, both bounded by permanent caps.

The **settlement fee** applies when an offer is taken and is paid entirely by the taker. It creates a small spread between what the buyer pays and what the seller receives, and varies with time to maturity. The annualized fee remains capped regardless of duration.

The **continuous fee** accrues over time on outstanding lender credit and is borne by lenders. When a lender opens a credit position, their continuous fee rate is fixed for that credit - later changes to the market rate do not affect it. The continuous fee is capped at 1% annualized.

## Further reading [#further-reading]

* [Midnight Whitepaper](https://morpho.org/whitepapers/midnight-whitepaper.pdf)
* [Midnight code](https://github.com/morpho-org/midnight)
* [Fixed rates are how DeFi moves beyond crypto](https://morpho.org/blog/fixed-rates-are-how-defi-moves-beyond-crypto/)

<Callout type="info" title="For developers">
  Want to integrate Midnight? See the [developer integration overview](/developers/midnight/get-started/).
</Callout>