Core margin quantities
These quantities appear throughout the platform’s risk checks.| Quantity | Definition | Used for |
|---|---|---|
| Strategy value | Available collateral plus unrealized PnL, marked at current mark prices | Base account value for margin monitoring |
| Total position notional | Sum of abs(position_size) × mark_price across open positions | Denominator for margin fraction and leverage |
| Total open position notional | Sum of worst-case exposure notional across positions and resting orders that could increase exposure | Denominator for open margin fraction and weighted IMF |
Margin fraction (MF) | strategy_value / total_position_notional | Liquidation monitoring |
Open margin fraction (OMF) | min(strategy_value, available_collateral) / total_open_position_notional | Pre-trade admission for exposure-increasing orders |
Initial margin fraction (IMF) | Weighted required initial-margin fraction across total open position notional | Threshold that OMF must meet or exceed |
Maintenance margin ratio (MMR) | MMR_FRACTION / max_leverage | Liquidation threshold |
Strategy leverage and shared constants
The baseline margin requirements come from the strategy’s leverage setting and two shared protocol constants.| Parameter | Value | Notes |
|---|---|---|
| Default strategy max leverage | 3x | DerivaDEX strategies default to 3x leverage |
| Base initial margin fraction | 1 / max_leverage | At 3x, the base IMF is 0.3333... (33.33%) |
IMF_FACTOR | 0.0004 | Adds a size-scaling term for very large open positions |
MMR_FRACTION | 0.15 | Shared maintenance constant used with max_leverage |
Maintenance margin ratio at 3x | 0.05 (5%) | 0.15 / 3 |
Initial margin admission rule
DerivaDEX checks initial margin on the post-execution strategy state. An order that opens or increases exposure is accepted only if the resultingOMF is at least the resulting IMF.
| Input | Definition | Notes |
|---|---|---|
| Open position size | The larger absolute exposure that would exist in one market if the strategy’s current position and exposure-increasing resting orders were fully filled in the riskier direction | Includes posted bids and asks, not just filled positions |
| Open position notional | open_position_size × mark_price | Used to weight each market’s IMF contribution |
| Position IMF | max(1 / max_leverage, IMF_FACTOR × sqrt(open_position_size)) | Small positions use the leverage floor; very large positions pick up the square-root term |
| Portfolio IMF | Notional-weighted average of the position-level IMFs | One strategy can hold multiple products, so the requirement is aggregated |
min(strategy_value, available_collateral) in OMF | The numerator is capped at available collateral when unrealized PnL is positive | Unrealized gains do not increase opening power; unrealized losses still reduce it |
Maintenance margin and liquidation trigger
Once a strategy has open exposure, liquidation monitoring usesMF rather than OMF.
| Quantity | Meaning |
|---|---|
strategy_value | Collateral plus unrealized PnL across all open positions in the strategy |
MF | Current solvency ratio of the strategy against its marked notional exposure |
MMR | Minimum MF required to keep the strategy out of liquidation |
Liquidation threshold at 3x | 5% (0.05) |
When each rule applies
The platform applies the same margin model differently depending on whether an order increases or reduces risk.| Case | Margin rule |
|---|---|
| Opening a new position | Post-execution OMF >= IMF must hold |
| Increasing an existing position | Post-execution OMF >= IMF must hold |
| Posting resting liquidity that could increase exposure if filled | Included in open-position sizing for OMF and IMF checks |
| Reducing or closing an existing position without crossing through flat into the opposite side | The order can bypass the OMF >= IMF admission check because it improves exposure; solvency and execution guards still apply |
| Existing open position after entry | MF is monitored against MMR for liquidation |
Worked margin cases
These examples show the two thresholds in action, including a rejection where opposite-side resting orders still leave a larger absolute exposure in one direction.| Case | Calculation | Outcome |
|---|---|---|
New short order with 1,000 USDC collateral, 1 contract of open exposure, and mark price 1,100 | OMF = 1,000 / (1 × 1,100) = 0.9091; IMF = max(1 / 3, 0.0004 × sqrt(1)) = 1 / 3 | Accepted because 0.9091 >= 0.3333... |
Second order increases the same strategy to 2 contracts of open exposure at the same 1,100 mark, while unrealized PnL contributes +250 to strategy value | OMF = min(1,250, 1,000) / (2 × 1,100) = 1,000 / 2,200 = 0.4545; IMF remains 1 / 3 | Still accepted because unrealized gains do not raise the numerator above available collateral, but 0.4545 >= 0.3333... |
Existing long 2 contracts with 1,000 USDC collateral, mark price 1,000, resting bid for 2 more contracts, and resting ask for 1 contract | Worst-case open position size is max(abs(2 + 2), abs(2 - 1)) = max(4, 1) = 4; OMF = 1,000 / (4 × 1,000) = 0.25; IMF = max(1 / 3, 0.0004 × sqrt(4)) = 1 / 3 | Rejected with OMFLessThanIMF because the risk check uses the larger reachable absolute exposure, so the opposite-side ask does not offset the bid enough to satisfy 0.25 >= 0.3333... |
Liquidation check with 5,000 USDC collateral, short 100 contracts, mark price 145, and unrealized PnL -4,500 | strategy_value = 5,000 - 4,500 = 500; MF = 500 / (100 × 145) = 0.03448; MMR = 0.15 / 3 = 0.05 | Liquidatable because 0.03448 < 0.05 |
Size-scaling threshold
The square-rootIMF_FACTOR term matters only once a position is large enough to exceed the base leverage floor.
| Quantity | Value |
|---|---|
| Crossover condition | IMF_FACTOR × sqrt(open_position_size) > 1 / max_leverage |
Crossover size at 3x leverage | ((1 / 3) / 0.0004)^2 ≈ 694,444.44 units |
| Below the crossover size | IMF = 1 / max_leverage |
| Above the crossover size | IMF = IMF_FACTOR × sqrt(open_position_size) |
API fields and rejection codes
Programmatic integrations can inspect the current maintenance state and detect failed initial-margin checks from API responses.| API field or code | Meaning |
|---|---|
Strategy metrics marginFraction | Current MF for the strategy |
Strategy metrics mmr | Current maintenance margin ratio; the strategy can be liquidated when marginFraction < mmr |
Safety failure OMFLessThanIMF | The post-execution strategy state would leave OMF below IMF, so the order is rejected |