# Liquidation Mechanism

#### Liquidation Overview in Trading

Liquidation occurs when a trader's total position value (which includes position margin, unrealized profit and loss (PNL), minus borrowing and funding fees) falls below the required maintenance margin. In such cases, a liquidation is triggered, and the position is closed by the keeper.

**Liquidation Price Formulas**

* Long Position: pl = {po x n - M + Funding + Interest} / {(1 - mm) x n}
* Short Position: pl = {po x n + M - Funding - Interest} / {(1 + mm) x n}

Where:

* $$po$$: Entry Price
* $$M$$: Initial Margin
* $$n$$: Number of Positions
* Funding: Funding Fees
* Interest: Borrowing Fees
* $$mm$$: Maintenance Margin Rate

**Liquidation Execution**

On the Argon, Protocol liquidations are carried out by both the system and decentralized liquidation robots. The system robot handles liquidations routinely, but in high-demand scenarios, the decentralized robot, relying on ChainLink prices, assists in executing liquidations. Community liquidators using the decentralized robot receive a 5 USDC reward per executed liquidation. Remaining margins, after deductions, are refunded to the trader’s wallet.

**Liquidation Process Details**

The maximum a trader can lose is the margin of their position. During liquidation, deductions occur in this order: Borrowing Fees → Funding Fees → Unrealized PNL → Insurance Fund → Margin returned to the trader. If the margin depletes during this process, the trader receives nothing back.

The position margin is calculated as: Unrealized PNL + Insurance Fund (Initial Position Value x 0.2%) + Returned Margin + Funding Fees + Borrowing Fees.

**Example Scenario**

* Consider a trader opening a 100x leveraged long position with 100 USDC as initial margin on ETH priced at 1,000 USDC, making the position size 10 ETH.
* Ignoring borrowing and funding fees, the liquidation price is:
  * $$Pl = Entry Price x (1 - 1/L) / (1 - mm) = 994.97 USDC$$

Upon liquidation:

1. **At a price of 930 USDC**:
   * Unrealized PNL: (930 - 1000) x 10 = -70 USDC
   * Insurance Fund: 930 x 10 x 0.002 = 18.6 USDC
   * Margin Returned: 100 - 70 - 18.6 = 11.4 USDC (assuming no borrowing/funding fees)
2. **At a price of 980 USDC**:
   * Unrealized PNL: (980 - 1000) x 10 = -200 USDC
   * After deductions, all remaining margin is added to the fund pool.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://argon-protocol.gitbook.io/argon-protocol/trading/liquidation-mechanism.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
