# Leverage & Liquidations

### Leverage <a href="#leverage" id="leverage"></a>

Both makers & takers have the ability to trade in a more capital efficient manner by using leverage. This allows a participant's notional exposure to far exceed the amount of collateral provided. Solvency of the system is ensured by a maintenance margin & liquidation system.

$$
\text{MaximumLeverage} = \frac{1}{\text{maintenance}%}
$$

*For example: if maintenance is 20%, then 1 / 20% = 5, so 5.0x max leverage.*

#### Maintenance <a href="#maintenance" id="maintenance"></a>

A maintenance margin is set by the market operator. It is the minimum ratio of collateral to notional exposure that a market will allow. This sets how much notional exposure a maker can provide and how much leverage a taker can get.

If the value of the collateral posted by a maker or taker falls below the maintenance requirement, the maker/taker position will enter liquidation to ensure solvency of the protocol.

Both makers and takers have a maintenance requirement based on the notional of their position *times* the margin percentage requirement for the product.

**Example Product: Long-ETH @ 20% maintenance (up to 5x leverage)**

We use `ETH = $1000` for this example.

| Side  | Position | Notional | Maintenance |
| ----- | -------- | -------- | ----------- |
| Maker | 10       | $10,000  | $2,000      |
| Taker | 5        | $5,000   | $1,000      |

### Liquidations <a href="#liquidations" id="liquidations"></a>

An account can be liquidated whenever its collateral drops below the maintenance requirement of their position.

Like with any other position change, a liquidation must sit in a pending state until the next oracle update. During this period however, a special lock is placed on the account so that the liquidation process may not be interfered with. The user may not open or close a new position (or be liquidated again) until the liquidation process is completely settled and the lock is cleared.

{% hint style="info" %}
*Margin and maintenance requirements are the same: a single value both for opening and keeping open a position.*
{% endhint %}

The maintenance requirement for makers is calculated assuming 100% utilization of their exposure, so for a maker position of 10, even if the net exposure was only 1, 10 is still used as the position in the above equation. Since the utilization can change instantaneously, this is to ensure that we’re taking a worst case approach to the maintenance calculation.

$$
\text{maintenanceRequirement} = \max(\text{position} \cdot \text{price} \cdot \text{maintenance}, \text{minMaintenance})
$$

`minMaintenance` is used as a floor on the collateral to ensure that any non-zero position has a sufficient incentive to liquidate in the case of under-collateralization.

Upon successful liquidation, the liquidator is allowed to withdraw up to liquidation fee collateral from the account. This fee is optional, as you may want to self-liquidate, and can be computed as follows:

$$
\begin{aligned}
&\text{maintenance} = \max(\text{maintenanceRequirement} \cdot \text{liquidationFee}, \text{minMaintenance}) \\
&\text{liquidationFee} = \min(\text{maintenance}, \text{maxMaintenance})
\end{aligned}
$$

The `liquidationFee` is a percentage of the maintenance requirement of the position at time of liquidation, capped above and below by the maxMaintenance and minMaintence respectively.

#### Reward <a href="#reward" id="reward"></a>

Liquidators are immediately granted a liquidation reward equal to the maintenance requirement of the account *times* the `liquidationFee` upon the successful initiation of a liquidation.

**Example Liquidation: Collateral @ 20% liquidationFee**

| Collateral | Maintenance | Liquidation Reward     |
| ---------- | ----------- | ---------------------- |
| $10,000    | $15,000     | $3,000                 |
| $30,000    | $32,000     | $6,400                 |
| $25,000    | $20,000     | N/A - cannot liquidate |

Perennial does not take a protocol or product owner cut of the liquidation fee.


---

# 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.kwenta.io/using-kwenta/perennial-isolated-margin/perennial-intro/leverage-and-liquidations.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.
