### Liquidations

Accounts whose total value falls below the maintenance margin requirement may have their positions automatically closed by the liquidation engine. Positions are closed at the liquidation price described below. Profits or losses from liquidations are taken on by the insurance fund.

During a liquidation, the liquidator is allowed to take on up to the entire account balance of the liquidated account, potentially leaving it with zero margin and position. Partial liquidation is also permitted, in which case the liquidator will take on proportional amounts of the account’s margin and position.

**Liquidation Penalty**

When an account is liquidated, up to the entire value of the account may be taken as penalty and transferred to the **Insurance Fund**. The liquidation engine will attempt to leave funds in accounts of positive value where possible after they have paid the **Minimum Liquidation Penalty** of 1%.

### Liquidation Price

The liquidation price of a position is calculated as follows, depending on whether it is a short or long position:

`Liquidation Price (short) = P × (1 + M × V) `

Liquidation Price (long) = P × (1 − M × V)

Where:

`P`

is the oracle price for the market`M`

is the maintenance margin fraction for the market`V`

is the total account value, as defined above

This formula is chosen such that the ratio `Total Account Value / Total Maintenance Margin Requirement`

is unchanged as individual positions are liquidated.

### Liquidation Examples

Assume an initial margin requirement of 10% and a maintenance margin requirement of 7.5%.

### Example 1

Trader A deposits 1000 USDC, then opens a short perpetual position of 1 XYZ (hypothetical asset) at a price of 2000 USDC. Their account balance is +3000 USDC, -1 XYZ. The index price is 2000 USDC/XYZ, making their margin percentage 50%.

Over time, the price of XYZ increases, and the index price hits 2791 USDC, at which point Trader A’s position is below the maintenance margin requirement and becomes liquidatable. The liquidator, which has a balance of +100 USDC, 0 XYZ, liquidates A’s position successfully, leaving A with zero balance, and bringing the liquidator's balance to +3100 USDC, -1 XYZ. The liquidator then closes the short position on the market at a price of 2800 USDC, bringing its final balance to +300 USDC, 0 XYZ.

At the time of liquidation, using the index price of 2791 USDC, Trader A’s account had a nominal value of 209 USDC, therefore we may say that A’s liquidation penalty was 209 USDC. The liquidator's profit, after closing the short position, and ignoring any trade fees, is 200 USDC.

### Example 2 - Partial Liquidation

Suppose Trader A has an account balance of +3000 USDC, -1 XYZ, but due to a rapidly increasing price in the underlying spot market, the index is now 2900 USDC, giving A a margin percentage of only 3.45%.

The liquidator, which has a balance of +100 USDC, 0 XYZ, would liquidate Trader A’s account. However, at the current index price, a full liquidation is not possible since it would leave the liquidator with a margin percentage of 6.90%. The liquidator executes a partial liquidation, taking on 60% of Trader A’s balances. This leaves A with 1200 USDC, -0.4 XYZ, and the liquidator with 1900 USDC, -0.6 XYZ.

At an index price of 2900 USDC, the liquidator’s account has a nominal value of 160 USDC, giving it a hypothetical profit of 60 USDC.

Trader A’s remaining position still has a margin percentage of 3.45%, and their remaining balance may be liquidated if they don’t make a deposit or trade out of their position.

### What price is used to determine liquidations?

The **Index Price **is used to determine liquidations.