What is 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
Midnight is built around isolated and immutable markets that can be created permissionlessly. Each market specifies:
- a loan token, the asset lent, borrowed, and repaid
- a maturity date, when outstanding debt is due
- one or more collateral assets, each with its own risk parameters and oracle
- optional gates, which can restrict who may increase credit, increase debt, or liquidate
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.
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
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
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 but with the same loan token, collateral set, and maturity belong to the same market: within it, any credit unit is interchangeable with any other, as is any debt unit.
Early exits
Users can reduce an existing position at any time by trading in the opposite direction, since a trade 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
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.
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.
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.
Fees
Midnight has two protocol-level fee systems, both bounded by permanent caps.
The settlement fee applies when an offer is taken. 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. 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.