Liquidation System
Overview
The liquidation system automatically closes positions when margin falls below maintenance requirements, protecting the exchange's solvency and ensuring fair risk distribution among traders.
Key Components:
Real-Time Monitoring: Continuous position health checks
Mark Price: Oracle-based fair pricing to prevent manipulation
Auto-Liquidation: Automatic position closure at market price
Emergency Fund: System stability protection
Auto-Deleveraging (ADL): Backup mechanism for extreme scenarios
Liquidation Triggers
Margin Requirements
Position liquidated when margin falls below maintenance requirement:
Liquidation Condition:
Margin + Unrealized PnL + Pending Funding < Maintenance MarginComponents:
Margin: Initial margin allocated to position
Unrealized PnL: Current profit/loss based on mark price
Pending Funding: Accrued but not yet paid funding
Maintenance Margin: Minimum required (50% of initial margin)
Example:
Monitoring System
Real-Time Checks:
Mark price updates every block (100ms)
Position health calculated continuously
Automatic liquidation detection
No manual intervention needed
Health Metrics:
Monitoring Frequency:
Every block: Mark price update
Every block: Health check
Instant trigger: When threshold breached
No grace period: Immediate liquidation
Liquidation Process
Execution Steps
1. Detection:
System identifies position below maintenance margin
Position marked for liquidation
Process initiated automatically
User notified (if possible)
2. Market Order Placement:
Position closed at market price
Takes liquidity from order book
Executed as single market order
Slippage possible in thin markets
3. Margin Settlement:
Maintenance margin transferred to emergency fund
Remaining margin (if any) returned to user
Funding payments settled
Position closed and removed
4. User Account Update:
Position removed from account
Available balance updated
Loss recorded in history
Liquidation event logged
Example Liquidation
Mark Price System
Why Mark Price
Problem:
Last price can be manipulated
Flash crashes could cause unfair liquidations
Thin order books create risk
Market manipulation possible
Solution:
Use external oracle price (mark price)
Based on multiple spot exchanges
Prevents manipulation-based liquidations
Fair and transparent pricing
Mark Price Calculation
Data Sources:
Multiple external spot exchanges
Weighted average of prices
Outlier detection and removal
Real-time price feeds
Update Frequency:
Every block (100ms on Frontier Chain)
Continuous oracle updates
Staleness checks (max 60 seconds)
Failover to backup oracles
Formula:
Oracle Integration
Price Sources (planned):
Binance spot price
Coinbase spot price
Kraken spot price
Chainlink price feeds
Additional decentralized oracles
Confidence Thresholds:
Minimum data sources: 3
Maximum price deviation: 0.5%
Staleness check: 60 seconds max
Automatic failover on issues
Manipulation Protection:
Cannot manipulate mark price via Frontier Chain trading
Requires manipulation across multiple major exchanges
Extremely difficult and expensive
System remains secure
Liquidation Pricing
Market Order Execution
When liquidation occurs:
Order Book Impact:
Takes liquidity as market order
May experience slippage in thin markets
Larger positions = more slippage
Price depends on order book depth
Example (Good Liquidity):
Example (Poor Liquidity):
Bankruptcy Price
The price at which position margin is fully depleted:
Long Position:
Short Position:
Liquidation vs Bankruptcy:
Liquidation occurs at maintenance margin breach
Bankruptcy price is full margin depletion
Gap between them protects emergency fund
Maintenance margin acts as buffer
Emergency Fund
Purpose
The emergency fund absorbs losses from liquidations:
Functions:
Capture maintenance margin from liquidations
Cover losses when position closes at bankruptcy price
Prevent socialized losses
Maintain exchange solvency
Funding Sources:
Maintenance margin from liquidated positions
Portion of trading fees (if implemented)
Initial capitalization by exchange
Grows over time from liquidations
Example Operation
Auto-Deleveraging (ADL)
When ADL Occurs
ADL is a last-resort mechanism:
Trigger Conditions:
Emergency fund insufficient for liquidations
Multiple large liquidations simultaneously
Extreme market volatility
Flash crash scenarios
Goal:
Prevent socialized losses across all users
Close out profitable positions to offset
Maintain system solvency
Rare occurrence
ADL Priority Queue
Positions selected for auto-deleveraging based on priority:
Priority Ranking:
Profit and Leverage Score: Highest scored positions first
Most profitable positions: Unrealized PnL
Highest leverage: Riskiest positions
Recently opened: Newer positions
Score Calculation:
Example Rankings:
ADL Execution
Process:
Emergency fund depleted
System identifies highest priority positions
Positions closed at bankruptcy price of liquidated position
Users notified of ADL event
Funds used to cover liquidation losses
User Impact:
Forced position closure
Closed at bankruptcy price (not market price)
Unrealized profit realized
Can immediately re-enter position
Rare occurrence
Example:
ADL Notification
Indicators:
ADL queue position shown in UI
Percentile ranking (0-100%)
Real-time updates
Warning when in high-risk zone
Risk Zones:
0-20%: Low risk of ADL
20-50%: Moderate risk
50-80%: High risk
80-100%: Very high risk (reduce leverage)
Action Items:
Monitor ADL queue position
Reduce leverage if in high-risk zone
Take profit to move down queue
Add margin to reduce leverage
Liquidation Prevention
Monitoring Position Health
Key Metrics:
Distance to Liquidation:
Proactive Risk Management
Add Margin (Isolated):
Transfer additional funds to position
Reduces effective leverage
Moves liquidation price further away
Increases safety margin
Reduce Position Size:
Close partial position with reduce-only order
Decreases risk
Frees up margin
Maintains exposure
Set Stop Losses:
Automatic exit before liquidation
Preserve capital
Avoid liquidation fees
Control exit price
Use Lower Leverage:
Wider liquidation buffer
More time to react
Lower risk
Recommended for beginners
Example: Preventing Liquidation
Liquidation Penalties
Costs of Liquidation
Loss of Position:
Position closed at market price
May experience adverse slippage
No control over exit price
May miss recovery
Maintenance Margin Lost:
50% of initial margin to emergency fund
Best case: Lose maintenance margin only
Worst case: Lose full initial margin
No return if price recovers
Opportunity Cost:
Cannot participate in recovery
Position forcibly closed
May need to re-enter at worse price
Trading fees to re-establish
Avoiding Liquidation
Best Practices:
Use conservative leverage (5-10x max for most traders)
Set stop losses below liquidation price
Monitor positions actively
Add margin when approaching warning zone
Maintain 30%+ margin buffer
Use lower leverage in volatile markets
Key Takeaways
Liquidation Fundamentals:
Triggered when margin ratio reaches 50%
Executed as market order automatically
Maintenance margin goes to emergency fund
Based on mark price to prevent manipulation
Mark Price Protection:
Uses external oracle data
Prevents manipulation-based liquidations
Updated every block (100ms)
Fair and transparent pricing
Emergency Fund and ADL:
Emergency fund absorbs liquidation losses
ADL is last-resort mechanism
Rarely triggered under normal conditions
Protects system solvency
Prevention Strategies:
Monitor margin ratio constantly
Set stop losses proactively
Add margin when in warning zone
Use conservative leverage
Maintain sufficient buffer above maintenance margin
Next Steps:
Margin & LeverageFunding RatesPosition ManagementLast updated