# Liquidation Model

## Liquidation Trigger

A position is liquidated when collateral equity falls below the **Maintenance Margin** (determined by `minCollateralFactor`).

| minCollateralFactor | Equivalent Max Leverage |
| :-----------------: | :---------------------: |
|          1%         |           100x          |
|         0.5%        |           200x          |

*On MegaEth Testnet, all markets use **1% minCollateralFactor** (i.e., 100x max leverage).*

## Liquidation Fee Structure

The liquidation fee is calculated as a percentage of your **total position size** (not just your collateral). This fee incentivizes keeper bots to maintain the protocol's solvency.

```
Liquidation Fee = Position Size × Liquidation Fee Factor
```

### Fee Factors by Market Type

| Market Type                       | Liquidation Fee Factor |
| --------------------------------- | :--------------------: |
| **Crypto Markets (ETH, BNB)**     |    **0.20% - 0.30%**   |
| **Synthetic Markets (XAU, CSPX)** |    **0.30% - 0.45%**   |

*The exact fee per market is configured by governance in the DataStore.*

## Fee Distribution

When liquidation occurs, the fee is split between:

| Recipient                        |  Share  |
| -------------------------------- | :-----: |
| Fee Receiver (Protocol Treasury) | **37%** |
| Liquidity Pool                   | **63%** |

The pool portion helps compensate for potential losses from the liquidated position.

## Example Calculations

### Example 1: ETH Long Position

```
Position Size:  $100,000
Leverage:       10x
Collateral:     $10,000
Fee Factor:     0.30%

Liquidation Fee = $100,000 × 0.30% = $300
```

If liquidated, **$300** is deducted from your remaining collateral, plus any unrealized losses.

### Example 2: BTC Long Position

```
Position Size:  $500,000
Leverage:       50x
Collateral:     $10,000
Fee Factor:     0.45%

Liquidation Fee = $500,000 × 0.45% = $2,250
```

If liquidated, **$2,250** is deducted from your remaining collateral.

## Important Notes

* **Fee is taken from remaining collateral**: You cannot lose more than your initial margin in cross-margin mode; your entire USDC balance backs all positions.
* **Fee is fixed per market**: It does not change based on leverage level, though higher leverage makes the fee larger relative to your margin.
* **Oracle-driven liquidation**: Liquidations occur at fair market prices, protecting traders from unfair liquidation prices.


---

# 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://megabanx.gitbook.io/megabanx/concepts/liquidation-model.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.
