Position Equity
| Parameter | Type | Description |
|---|---|---|
| lockedMargin | Onchain: stored in Position struct | USDC collateral locked for this position (mutable via margin adjustments) |
| unrealizedPnL | Computed: derived from current forward price | Mark-to-market profit or loss (signed) |
| Condition | Status |
|---|---|
equity >= lockedMargin | Healthy — profitable or breakeven |
MM <= equity < lockedMargin | Underwater — losses but not liquidatable |
equity < MM | Liquidatable — anyone can close the position |
equity <= 0 | Bad debt — losses exceed margin, pool absorbs the rest |
Two Margin Levels
Every position has two thresholds that create a buffer zone between opening and liquidation.| Parameter | Default | Description |
|---|---|---|
| imFactorBps | 200 bps (2%) | Minimum collateral to open. Onchain: stored in Config |
| mmFactorBps | 100 bps (1%) | Liquidation threshold. Onchain: stored in Config |
| BPS_DENOMINATOR | 10,000 | Fixed constant |
imFactorBps > mmFactorBps — any attempt to violate this reverts. This gap creates the buffer: equity starts above IM and must erode through the buffer before liquidation.
Variable Leverage
Traders choose their own margin within[minIM, notional]. More margin means lower leverage and a larger liquidation buffer.
| Margin | Leverage | Buffer Before Liquidation | Best For |
|---|---|---|---|
| 2% (minimum) | 50x | ~1% adverse move | High-conviction short-term trades |
| 5% | 20x | ~4% adverse move | Active trading with moderate risk |
| 10% | 10x | ~9% adverse move | Balanced risk/reward |
| 20% | 5x | ~19% adverse move | Conservative positions, longer tenors |
| 100% | 1x | Cannot be liquidated | Full hedging, maximum safety |
Isolated Margin
Each position’s margin is completely independent:- A loss on Position A does not affect Position B
- Maximum loss per position is capped at that position’s locked margin
- Free collateral in your account is never at risk from open positions
- Liquidation of one position does not affect others
Isolated vs cross margin
Isolated vs cross margin
In a cross-margin system, all positions share a common margin pool. A loss on one position can drain margin from others, and the entire account balance is at risk.The protocol defines a
MarginMode enum with ISOLATED (0) and CROSS (1) values, but only isolated margin is implemented in M2. The isolated model provides clearer risk boundaries and prevents cascading failures.Margin Operations
Add Margin
Increases locked margin, reducing leverage and increasing the liquidation buffer.
- Allowed at any time, even when liquidatable (rescue mechanism)
- Total locked margin cannot exceed notional
- Amount transfers from free collateral
Remove Margin
Decreases locked margin, increasing leverage and freeing collateral.
- Not allowed when liquidatable
- Remaining margin must stay above minIM
- Equity after removal must stay above MM threshold
Snapshotted Rates
When a position is opened, margin configuration parameters are snapshotted and stored with the position:| Snapshotted Field | Description |
|---|---|
| snapshotImBps | Initial margin factor at time of open |
| snapshotMmBps | Maintenance margin factor at time of open |
| snapshotTradingFeeBps | Trading fee rate at time of open |
| snapshotLiquidationPenaltyBps | Liquidation penalty at time of open |
| snapshotOracleFee | Oracle fee at time of open |
Worked Example
Full margin lifecycle
Full margin lifecycle
Setup:Add 25 USDC margin:Price recovers, PnL now +15 USDC:Remove 30 USDC margin:
- Notional: 1,000 USDC
- Margin deposited: 50 USDC (5%, 20x leverage)
- Minimum IM: 20 USDC (2%)
- MM threshold: 10 USDC (1%)
What happens if PnL loss exceeds locked margin?
What happens if PnL loss exceeds locked margin?
When a position’s market PnL loss exceeds its locked margin (
|marketPnl| > imLocked), the excess becomes bad debt. The trader’s realized loss is capped at imLocked, and the remaining loss is absorbed by pool equity. A BadDebt event is emitted for monitoring. The pool equity floor is clamped to zero — it cannot go negative.Account Equity
Beyond individual positions, the protocol tracks aggregate account equity:aggregateUnrealizedPnL sums unrealized PnL across all open positions. Available via the subgraph for informational purposes.