Skip to main content

Margin & Leverage

Leverage Bounds

Every position must satisfy the maximum leverage constraint.

Maximum Leverage

notional×margincol×SCALAR_7\text{notional} \times \text{margin} \leq \text{col} \times \text{SCALAR\_7}

Equivalently: leverage <= 1 / margin.

marginMax Leverage
1_000_000 (10%)10x
500_000 (5%)20x
200_000 (2%)50x
100_000 (1%)100x
50_000 (0.5%)200x

Initial Margin vs Liquidation Threshold

PropertyInitial MarginLiquidation Threshold
RateConfigurable per marketConfigurable per market
SourceMarketConfig.marginMarketConfig.liq_fee
Enforced atOpen, modify collateralLiquidation check
Max value50% (MAX_MARGIN)25% (MAX_LIQ_FEE)
PurposeBuffer between opening and liquidationEquity below this triggers liquidation

The validation rule margin > liq_fee ensures there is always a gap between the opening margin requirement and the liquidation threshold. This gap is the safety buffer that absorbs PnL and fee accrual before liquidation triggers.

Collateral Modification

When withdrawing collateral from a filled position, an additional margin check is applied:

equity=new_col+pnltotal_fee\text{equity} = \text{new\_col} + \text{pnl} - \text{total\_fee} equitynotional×marginSCALAR_7\text{equity} \geq \text{notional} \times \frac{\text{margin}}{\text{SCALAR\_7}}

Where total_fee includes accrued funding and borrowing at current indices. If this check fails, the withdrawal is rejected with WithdrawalBreaksMargin. This prevents users from extracting collateral to the point where their position becomes immediately liquidatable.

Collateral withdrawal uses the initial margin requirement (margin), not the liquidation threshold (liq_fee). This provides an extra buffer. A user cannot withdraw collateral down to the liquidation threshold level.