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:

Asset
Discount Factor
Rationale

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

Health Factor
Status
Action

> 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:

  1. Transfer tokens from user to CollateralEngine

  2. Update account balance

  3. No margin check needed (deposits only help)

Withdraw

Flow:

  1. Update position growth (mark to market)

  2. Check margin requirement

  3. If insufficient → revert

  4. 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

Use Case
Margin Ratio
Leverage

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

  1. Discount factors reduce volatile collateral value

  2. Worst case VY determines margin requirement

  3. Health Factor = Collateral / Requirement

  4. Keep Health > 1.5 to avoid liquidation risk

  5. 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