> For the complete documentation index, see [llms.txt](https://docs.perennial.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.perennial.finance/protocol/markets/margin-and-liquidations.md).

# Margin & Liquidations

## Margin

Makers and Takers have the ability to trade in a more capital-efficient manner by using leverage. Because trading with leverage means that a participant's notional exposure may far exceed the amount of collateral provided, a risk mitigation mechanism is required via margin and liquidation to prevent insolvency.

In Perennial, the Market Operator sets the parameters `maintenance`, `margin`, `minMaintenance`, and `minMargin`.

* `margin` and `minMargin` define the ratio and minimum dollar amount (respectively) of collateral required to open or change a leveraged position (i.e., initial margin).
* `maintenance` and `minMaintenance` define the ratio and minimum dollar amount (respectively) of collateral that is required to maintain a leveraged position and prevent it from being liquidated (i.e., maintenance margin).

These parameters set how much notional exposure a Maker can provide and how much leverage a Taker can obtain. Based on these parameters, Makers' and Takers' initial margin and maintenance requirements are defined by:

`marginRequirement = max(position * price * margin, minMargin)`\
`maintenanceRequirement = max(position * price * maintenance, minMaintenance)`<br>

For example, if the `maintenance` (ratio) is set at 20%, then the maximum leverage a Taker could obtain would be 5.0x (1 / 20% = 5). Assuming the price of ETH is $1000, the table below shows the maintenance margin required according to the notional positions for a Long-ETH product:

<table><thead><tr><th width="150">Side</th><th width="140.03515625">Position</th><th width="184.6153846153846">Notional</th><th>Maintenance</th><th>Leverage</th></tr></thead><tbody><tr><td>Maker</td><td>10</td><td>$10,000</td><td>$2,000</td><td>5x</td></tr><tr><td>Taker</td><td>5</td><td>$5,000</td><td>$1,000</td><td>5x</td></tr></tbody></table>

## Liquidations

An account can be liquidated whenever its collateral drops below the `maintenanceRequirement` for their position.

As is the case with other position changes, a liquidation must sit in a pending state until the next oracle update. However, a special lock is placed on the account during this period of pending liquidation so that the liquidation process cannot 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.

A minimum level of `margin`, `minMaintenance`, is set such that all non-zero positions must have enough collateral to incentivize a liquidation—even in cases where a position becomes undercollateralized. The `maintenanceRequirement` is always no less than the `minMaintenance`. For risk management purposes, the maintenance requirement for Makers is calculated by assuming 100% utilization of their exposure.

When a position is successfully liquidated, the liquidator can withdraw a fee from the collateral account. The liquidation fee is a parameter that is calculated as a multiple of the settlement fee. The liquidation fee is optional as self-liquidations are permitted. Perennial does not take a protocol or product owner cut of the liquidation fee.

The table below provides an example of the liquidation reward (fee) that can be collected (Assuming a 20% liquidation reward:

| Collateral ($) | Maintenance Requirement ($) | Liquidation Reward ($) |                          |
| -------------- | --------------------------- | ---------------------- | ------------------------ |
| 10,000         | 15,000                      | 3,000                  | Eligible for liquidation |
| 30,000         | 32,000                      | 6,400                  | Eligible for liquidation |
| 25,000         | 20,000                      | N/A                    | Safe (above requirement) |
