Margin Management
TL;DR: The margin system ensures all positions are adequately collateralized. It uses discount factors for collateral, worst-case VY for requirements, and health factors to monitor risk.
Overview
┌─────────────────────────────────────────────────────────────┐
│ MARGIN SYSTEM │
├─────────────────────────────────────────────────────────────┤
│ │
│ Collateral Value vs Margin Requirement │
│ ───────────────── ────────────────── │
│ │
│ Σ(Balance × Price × DF) ≥ Σ(Position Obligation) │
│ │
│ If Collateral < Requirement → Liquidation Risk │
│ │
└─────────────────────────────────────────────────────────────┘Collateral Valuation
Formula
Total Collateral Value = Σ (Balance × Price × Discount Factor)Discount Factors
Different assets have different risk profiles:
USDC
1.00 (100%)
Stable, liquid
USDT
0.98 (98%)
Minor depeg risk
DAI
0.97 (97%)
Algorithmic stable
ETH
0.90 (90%)
Volatile but liquid
WBTC
0.85 (85%)
Volatile, wrapped asset
Example Calculation
Isolated Margin Mode
In isolated margin mode, only the specified token is used:
The isolated token gets 100% discount factor (no haircut).
Margin Requirements
Position Obligation
Each position has a margin requirement based on potential loss:
Worst Case Variable Factor
The protocol uses conservative VY assumptions:
Example Calculation
Health Factor
Definition
Interpretation
> 1.5
Safe
No action needed
1.2 - 1.5
Caution
Consider adding margin
1.0 - 1.2
Warning
Add margin urgently
< 1.0
Danger
Liquidation possible
Visual
LP Position Margin
Liquidity providers have additional margin considerations:
Scenario Analysis
LP positions must cover the worst-case tick movement:
Extra Balances Calculation
Margin Operations
Deposit
Flow:
Transfer tokens from user to CollateralEngine
Update account balance
No margin check needed (deposits only help)
Withdraw
Flow:
Update position growth (mark to market)
Check margin requirement
If insufficient → revert
Transfer tokens to user
After Trade
Multi-Position Aggregation
Cross-Margin
With cross-margin, all positions share collateral:
Isolated Margin
With isolated margin, each sub-account is separate:
Margin Efficiency
Effective Leverage
Typical Margin Ratios
Conservative
10%
10x
Standard
5%
20x
Aggressive
2.5%
40x
Note: Higher leverage = higher liquidation risk
Best Practices
1. Maintain Buffer
2. Monitor Regularly
3. Use Isolated Margin for Risky Trades
4. Understand Worst Case
Key Takeaways
Discount factors reduce volatile collateral value
Worst case VY determines margin requirement
Health Factor = Collateral / Requirement
Keep Health > 1.5 to avoid liquidation risk
Isolated margin protects other positions
Next Steps
Liquidations — What happens when margin fails
Risk Management — Managing your risk
Getting Started — Start with proper margin
Last updated

