> ## Documentation Index
> Fetch the complete documentation index at: https://docs.perpetradex.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Positions & Margin

> Leverage, initial margin, and how Perpetra checks a position's health

Every market on Perpetra has its own risk parameters, enforced on-chain by the Risk Engine every time you open or increase a position. This page covers what those checks actually are.

## Leverage limits

Each market defines a `minLeverage` and `maxLeverage`. When you open or increase a position, both are enforced:

```
sizeUsd >= collateralAmount x minLeverage   (leverage floor)
sizeUsd <= collateralAmount x maxLeverage   (leverage ceiling)
```

The floor exists so a position can't be so over-collateralized that it falls below the market's minimum leverage. The ceiling is the max leverage shown on the leverage slider.

## Initial margin

Initial margin is a separate check from the leverage ceiling, not derived from it. Each market has its own `initialMarginBps`:

```
Initial Margin Required = SizeUsd x InitialMarginBps / 10,000
```

Your collateral must meet or exceed this amount to open or increase a position. In practice a market's `initialMarginBps` is usually set to correspond to its `maxLeverage` (for example, an `initialMarginBps` of 100 pairs with a `maxLeverage` of 100x), but they're enforced as two independent checks on-chain.

## Open interest caps

Beyond a single position's size, each market also caps total exposure on each side:

```
Long OI after this order  <= maxLongOpenInterest
Short OI after this order <= maxShortOpenInterest
```

A single position is also capped by `maxPositionSizeUsd`, regardless of leverage or available open interest.

## Margin ratio and maintenance margin

Once a position is open, its health is tracked continuously:

```
Effective Collateral = Collateral + Unrealized PnL   (floored at 0)
Margin Ratio (bps)   = Effective Collateral x 10,000 / SizeUsd
Maintenance Margin   = SizeUsd x MaintenanceMarginBps / 10,000
```

A position becomes eligible for liquidation when:

```
Effective Collateral < Maintenance Margin
```

<Note>
  `initialMarginBps` is always required to be greater than
  `maintenanceMarginBps` for a market. The gap between the two is your buffer:
  how far effective collateral can fall from where you opened before the
  position is liquidatable.
</Note>

## Margin mode changes what "Collateral" means

These formulas apply the same way regardless of margin mode, but the collateral figure feeding into them differs:

* In **isolated** mode, each position is checked independently against its own fixed collateral.
* In **cross** mode, positions sharing a collateral token are checked together at the account level, not one at a time. See [Margin Modes](/trading/margin-modes) for exactly how that account-level check works.

For the price level at which effective collateral actually crosses below maintenance margin, see [PnL & Liquidation](/trading/pnl-and-liquidation).
