# Liquidation

If a user's health factor drops below 1, they will become eligible for liquidation. When a user gets liquidated, the liquidator can purchase 40% or more of their collateral at a discount.

For example, consider a user who has borrowed 1,000 USDC against 1 ETH worth 2,000 USDC for an LTV of 50%. Assume the max LTV is 75% and the liquidation discount is 5%. Here's what will happen if the ETH price falls to 1,300 USDC.

// Pre-liquidation

Debt: 1,000 USDC
Collateral: 1 ETH
ETH/USDC price: 1,300 USDC
LTV = 1,000 / 1,300 = 0.769

// Liquidation

Liquidation discount: 6%
Collateral purchased: 0.4 ETH
ETH/USDC purchase price = 1,300 * (1 - 0.06) = 1,222 USDC
USDC liquidation amount = 1,222 * 0.4 = 488.8 USDC
Liquidator profit = 0.4 ETH * 1,300 USDC * 6% = 31.2 USDC

// Post-liquidation

Debt: 1,000 USDC - 488.8 USDC = 511.2 USDC
Collateral: 1 ETH - 0.4 ETH = 0.6 ETH
ETH/USDC price: 1,300 USDC
LTV = 511.2 / 780 = 0.655

In this example, the liquidated account is returned to a healthy LTV of 0.655 and the liquidator earns a profit of 31.2 USDC.

## Liquidation discount

The size of the liquidation discount is the sum of two parts:

1. The exchange rate discount. This discount depends on what currency the user is borrowing and what currency they're using as collateral. This discount is larger for volatile pairs and smaller for stable pairs.

2. The collateral asset type discount. This discount depends on whether the user is holding their collateral as prime cash, nTokens, or fCash. For prime cash, this discount is 0%. But for nTokens and fCash it will be positive and vary by currency.

$liquidation Discount = exchangeRateDiscount + collateralAssetTypeDiscount$

### Exchange rate discount

Each currency has its own liquidation discount. For example, the ETH liquidation discount is 6% and the USDC liquidation discount is 4%. The discount that will be used in liquidation is the greater of the collateral asset discount and debt asset discount.

$exchangeRateDiscount = max(collateral.discount, debt.discount)$

### Collateral asset type discount

• Prime cash: zero additional discount.

• fCash: fCash collateral asset type discounts work similarly to fCash haircuts. They are not flat percentages - they are discounts based on adjustments to the oracle rate. This means that liquidation discounts vary in size depending on the time to maturity of the fCash asset.

• nTokens: nTokens have a flat discount percentage that varies by currency. For example, nETH has a 2% collateral asset type discount.

### Example calculations

Here are some example liquidation discount calculations for users with different portfolios.

Example 1: prime ETH collateral vs. fUSDC debt

Collateral currency: ETH
Debt currency: USDC
Collateral asset type: prime cash

ETH discount: 6%
USDC discount: 4%
Prime cash discount: 0%

Liquidation discount = max(4%, 6%) + 0% = 6%

#### Example 2: fETH collateral vs. fUSDC debt

Collateral currency: ETH
Debt currency: USDC
Collateral asset type: fETH
fETH time to maturity: 0.5 years
fETH liquidation haircut: 1%
fETH discount ~= 0.5%

ETH discount: 6%
USDC discount: 4%
fETH discount: 0.5%

Liquidation discount = max(4%, 6%) + 0.5% = 6.5%

#### Example 3: nETH collateral vs. fUSDC debt

Collateral currency: ETH
Debt currency: USDC
Collateral asset type: nETH

ETH discount: 6%
USDC discount: 4%
nETH discount: 2%

Liquidation discount = max(4%, 6%) + 2% = 8%

### Single-currency liquidation discounts

Some accounts have debts that are in the same currency as their collateral. For example, a user might have a prime USDC debt against nUSDC collateral. In these scenarios, the liquidators will not receive an exchange rate discount.

This means that the only liquidation discount for single-currency liquidations is the collateral asset type discount.

#### Example: nUSDC collateral vs. Prime USDC debt

Collateral currency: USDC
Debt currency: USDC
Collateral asset type: nUSDC

nUSDC discount: 3%

Liquidation discount = 0% + 3% = 3%