# Liquidations & Insurance

#### Liquidation

When accounts do not have sufficient capital they will need to be liquidated to ensure that the system at large does not become bankrupt and to ensure that risks are isolated to individual user accounts where possible.\
\
The element underpinning this process is the ***margin check***:

$$
AB + UP - IM  +min(0, IPnL) > 0
$$

*where:*&#x20;

* *AB = Account Balance*
* *UP = Unrealised PnL*
* *IM = Initial Margin*
* *IPnL = instantaneous PnL from execution*

If a user fails the margin check, the liquidation process will begin:

* Step 1:&#x20;
  * 3rd party liquidators can cancel all open orders on a person’s book. The user will not be able to send orders during this time until all orders are cancelled.
* Step 2:
  * If the user is still below maintenance margin after the above cancels, they are able to be liquidated by sending a liquidation instruction. This instruction specifies a particular margin account, the market’s position and the size to be liquidated.

Upon a successful liquidation, the liquidator will trade with the liquidatee at the current mark price stored by Zeta, as well as gain a fixed % of the liquidatee’s collateral put up for maintenance margin as a reward. This reward is currently set at ***65% of the maintenance margin***, with 30% going to the liquidator and 35% going to the insurance fund.

Liquidation is a permissionless instruction, open to anyone. Check out our naive liquidator example [here ](https://github.com/zetamarkets/sdk/tree/main/examples/liquidator-example)that shows you how to check for positions at risk and liquidate their positions.&#x20;

**Note:** Liquidation is a risky endeavour and not guaranteed to be profitable.


---

# 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://docs.zeta.markets/zeta-protocol/exchange-architecture/margin-system/liquidations-and-insurance.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.
