Liquidation

A lender's position depends on borrowers repaying their debt. Two situations can put that at risk:

  • A position becomes undercollateralized. If a borrower's collateral loses enough value, it may no longer cover their debt. Left unaddressed, this can lead to bad debt - a shortfall that lenders ultimately bear.
  • Debt remains unpaid at maturity. A market matures on a fixed date, at which point lenders expect to redeem. A borrower who has not repaid - even one whose position is otherwise healthy - leaves lenders unable to withdraw the loan tokens they are owed.

Liquidation is the mechanism that addresses both. A liquidator repays borrower's debt and receives collateral in return; the repaid loan tokens become withdrawable liquidity for lenders in that market. Midnight has two liquidation paths, one for each situation:

  • Health-based liquidation applies when a position is no longer safely backed by its collateral. It can be triggered at any time, before or after maturity, and protects lenders against solvency deterioration.
  • Post-maturity liquidation applies when debt is still outstanding after the market's maturity, regardless of the position's health. It lets lenders redeem even when a borrower fails to repay on time.

Borrower health and maximum debt

A Midnight market can accept multiple collateral assets. Each collateral asset has its own oracle and LLTV (liquidation loan-to-value). LLTV is the percentage of a collateral's oracle value that contributes to a borrower's maximum debt (maxDebt).

Any borrower in a market can back their single debt with any mix of those listed collaterals. A borrower's maximum debt, called maxDebt, is the sum of these contributions across all collateral assets used by the borrower:

maxDebt=i(collateral valuei×LLTVi)\text{maxDebt} = \sum_i \left( \text{collateral value}_i \times \text{LLTV}_i \right)

Example

Suppose a USDC market accepts WETH and cbBTC as collateral.

A borrower deposits:

  • 2 WETH worth 3,000 USDC each, with 86% LLTV
  • 0.1 cbBTC worth 90,000 USDC, with 77% LLTV

Their maxDebt is:

  • WETH contribution: 2 × 3,000 × 86% = 5,160 USDC
  • cbBTC contribution: 0.1 × 90,000 × 77% = 6,930 USDC

Total maxDebt = 12,090 USDC.

A borrower is healthy as long as their debt is less than or equal to maxDebt.

Healthy and liquidatable are not the same thing. Before maturity, liquidation is based on borrower health. After maturity, a borrower with outstanding debt can also be liquidated through the post-maturity liquidation path, even if the position is still healthy.

Liquidation incentive

The LIF (liquidation incentive factor) determines how much collateral a liquidator receives for repaying debt.

A LIF of 1.05 means the liquidator receives collateral worth 1.05 loan tokens for each 1 loan token repaid. A LIF of 1.0 means there is no liquidation bonus.

Each collateral listed in a Midnight market has a maximum LIF, called maxLif.

The LIF used in a liquidation depends on the liquidation path:

  • in health-based liquidation, the LIF is maxLif;
  • in post-maturity liquidation, the LIF starts at 1.0 after maturity and ramps to maxLif over 60 minutes.

Health-based liquidation

Health-based liquidation is available when a borrower is unhealthy, meaning debt > maxDebt.

In this path:

  1. The liquidator repays part of the borrower's debt.
  2. The liquidator receives collateral using the collateral's maxLif.
  3. The repaid loan tokens become withdrawable liquidity for lenders.

Health-based liquidation is usually limited by the RCF (Recovery Close Factor). It prevents liquidating entire positions as soon as they become unhealthy - protecting borrowers from being over-liquidated for a small health breach - whilst still incentivizing liquidators to restore the position to health.

The RCF has two exceptions:

  • When LLTV = 1, repaying can never restore health, so the RCF is inactive and there is no cap on the liquidation amount.
  • When the collateral remaining after a partial liquidation would be too small to liquidate efficiently, the RCF is deactivated to avoid leaving dust positions.

Post-maturity liquidation

Post-maturity liquidation is available strictly after maturity when a borrower still has outstanding debt.

In this path:

  1. The liquidator repays outstanding debt.
  2. The liquidator receives collateral.
  3. The LIF starts at 1.0 and ramps to maxLif over 60 minutes.
  4. No RCF applies.

If a borrower is both post-maturity and unhealthy, the liquidator can choose either path:

  • health-based liquidation: immediate maxLif, but RCF may apply;
  • post-maturity liquidation: ramping LIF, with no RCF.

Summary by case

CaseLiquidatable?Liquidation modeLIFRCF
Pre-maturity and at exact maturity
HealthyNo---
UnhealthyYesHealth-basedmaxLifRCF if LLTV < 1
Post-maturity - within 60 min ramp
HealthyYesPost-maturity1.0 → maxLifNo RCF
UnhealthyYesHealth-based or post-maturityHealth-based: maxLif
Post-maturity: 1.0 → maxLif
Only on health-based mode
Post-maturity - after 60 min ramp
HealthyYesPost-maturitymaxLifNo RCF
UnhealthyYesHealth-based or post-maturitymaxLifOnly on health-based mode

Liquidator gates

A market can use a liquidator gate to restrict who may liquidate.

Restricting liquidators can change how quickly bad debt is realized and how quickly lenders receive recovered liquidity.

More on liquidator gates in the Gates section.

Bad debt

Bad debt arises during liquidation when, even after seizing all the borrower's collateral at the maximum liquidation incentive, some debt still cannot be repaid. The protocol immediately records the excess as a loss.

This bad debt is distributed proportionally across lenders: each lender's credit is reduced by the share of total market credit that could not be recovered. The corresponding loan tokens are gone - they will never become withdrawable. Bad debt in one market does not affect lenders in other markets.

On this page