Liquidation
How FluxPerp calculates liquidation prices and processes liquidations.
When a position's margin falls below the maintenance margin requirement, the settlement program liquidates it. This page explains how liquidation price is calculated, what happens during liquidation, and how to avoid it.
Margin types
FluxPerp uses cross-margin by default. All positions share a single collateral pool. If one position loses money, it draws from the same collateral that backs other open positions.
Isolated margin is available per-position. When enabled, the position's maximum loss is capped at the isolated margin amount. Other positions are unaffected.
Margin requirements
| Requirement | Value |
|---|---|
| Initial margin | 1 / leverage |
| Maintenance margin | 0.5 × initial margin |
| Liquidation fee | 1.0% of position notional |
| Insurance fund contribution | 0.2% of position notional |
Example — 10× leverage position:
- Initial margin requirement: 10%
- Maintenance margin requirement: 5%
- A $10,000 notional position requires $1,000 to open and reaches the maintenance threshold when margin drops to $500.
Liquidation price formula
Long position
liquidation_price = entry_price × (1 - 1/leverage + maintenance_margin_rate + liquidation_fee_rate)Short position
liquidation_price = entry_price × (1 + 1/leverage - maintenance_margin_rate - liquidation_fee_rate)Where:
initial_margin_rate=1 / leveragemaintenance_margin_rate=0.5 × initial_margin_rateliquidation_fee_rate= 0.010 (1.0%)
Worked example
Position: SOL-PERP long, 10 SOL, entry price $160, leverage 10×
liquidation_price = 160 × (1 - 1/10 + 0.05 + 0.010)
= 160 × (1 - 0.1 + 0.06)
= 160 × 0.96
= $153.60If SOL mark price falls to $153.60, the position is liquidated.
Verification:
- Position notional: 10 × $160 = $1,600
- Margin deposited (10×): $160
- Loss to liquidation: 10 × ($160 - $153.60) = $64
- Remaining margin: $160 - $64 = $96 = 6.0% of notional ✓ (maintenance 5.0% + liquidation fee 1.0%)
Partial liquidation
For positions above 50,000 USDC notional, FluxPerp uses partial liquidation to reduce market impact. The engine closes 50% of the position if doing so brings margin above the maintenance threshold. A second partial may follow if needed. Full liquidation is the fallback.
Liquidation mechanics
- Mark price crosses the liquidation price.
- The settlement program emits a
LiquidationOrderon-chain. - The matching engine cancels all open orders for the account.
- The position is closed at mark price.
- The liquidation fee (1.0% of notional) is charged to the account.
- 0.2% of notional goes to the insurance fund; 0.8% goes to liquidators.
- Any remaining collateral is returned to the user's margin account.
If your account has negative collateral after liquidation (e.g., due to extreme slippage on a very large position in thin market conditions), the deficit is covered by the insurance fund. Your liability is capped at zero — you cannot owe FluxPerp money.
How to avoid liquidation
Add margin — deposit more USDC to your margin account. In cross-margin mode this immediately increases the buffer for all positions.
Reduce position size — partially closing a position reduces the notional, which reduces the required maintenance margin.
Reduce leverage — lowering leverage on an existing position increases margin ratio. This requires closing and reopening the position at the new leverage.
Set stop-loss orders — place a stopMarket order with reduceOnly: true above your liquidation price. If mark price falls toward the stop trigger, the position closes voluntarily at a better price than liquidation.
// Long SOL-PERP at $160, liq price $153.60
// Set stop-loss at $156 to exit before liquidation
await client.placeOrder({
market: "SOL-PERP",
side: "short",
type: "stopMarket",
size: 10,
triggerPrice: 156.00,
reduceOnly: true,
});Margin ratio
Track your margin ratio in real time:
const account = await client.getAccount();
// margin_ratio = total_collateral / total_notional
const marginRatio = account.totalCollateral / account.totalPositionNotional;
const isHealthy = marginRatio > account.maintenanceMarginRate;
console.log(`Margin ratio: ${(marginRatio * 100).toFixed(2)}%`);
console.log(`Status: ${isHealthy ? "healthy" : "at risk"}`);The trading UI shows margin ratio as a colored indicator: green above 10%, amber 5–10%, red below 5%.