# Liquidation Process

Astros utilizes **Mark Price** to minimize liquidation risks due to market manipulation or low liquidity. Liquidation occurs when the margin balance of a position reaches or falls below the **maintenance margin** threshold.

***

### Liquidation Price Calculations

The liquidation price is calculated differently based on the direction of the position:

#### For **Long Positions**:

$$
\text{Liquidation Price} = (\text{Average Entry Price}) \times (1 + \text{Maintenance Margin Fraction}) - \frac{\text{Position Margin Balance}}{\text{Contract Size}}
$$

#### For **Short Positions**:

$$
\text{Liquidation Price} = (\text{Average Entry Price}) \times (1 - \text{Maintenance Margin Fraction}) + \frac{\text{Position Margin Balance}}{\text{Contract Size}}
$$

***

### Perpetual Margin Level Calculation

To assess the current margin health of a perpetual contract position, Astros computes the margin level as follows:

$$
\text{Perpetual Margin Level (%)} = \frac{\text{Position Maintenance Margin}}{\text{Position Margin Balance}} \times 100%
$$

A margin level approaching or falling below 100% indicates an imminent liquidation risk.

Astros

### Margin Modes and Liquidation Impact

Astros provides two distinct margin modes, each with different liquidation implications:

#### **1. Isolated Margin Mode**

In isolated margin mode, liquidation risk and consequences are confined strictly to the margin and funding fees associated with the particular position being liquidated. Other positions and balances remain unaffected.

#### **2. Cross Margin Mode**

In cross margin mode, liquidation impacts are broader. When liquidation occurs, the trader risks losing:

* All collateral allocated.
* Accrued funding fees associated with open positions.
* Margins reserved for active orders (frozen margin).
* The entirety of the available account balance.

***

### Liquidation Outcomes at Bankruptcy Price

During liquidation at the **Bankruptcy Price**, two possible outcomes emerge:

* **Surplus Scenario**:\
  If liquidation occurs at a price more favorable than the bankruptcy price, excess collateral is automatically transferred into the **Insurance Fund**.
* **Deficit Scenario**:\
  If liquidation cannot be executed above the bankruptcy price, the resulting deficit is first covered by the **Insurance Fund**. However, if the Insurance Fund balance is insufficient to cover this deficit, the liquidation is further managed through the **Automatic Deleveraging (ADL)** mechanism, which systematically reduces other positions to restore financial stability.
