Skip to main content
DerivaDEX applies margin at the strategy level. Each strategy is cross-margined in USDC, risk is measured from the current mark price, and two thresholds govern risk: one for opening or increasing exposure, and one for liquidation.

Core margin quantities

These quantities appear throughout the platform’s risk checks.
QuantityDefinitionUsed for
Strategy valueAvailable collateral plus unrealized PnL, marked at current mark pricesBase account value for margin monitoring
Total position notionalSum of abs(position_size) × mark_price across open positionsDenominator for margin fraction and leverage
Total open position notionalSum of worst-case exposure notional across positions and resting orders that could increase exposureDenominator for open margin fraction and weighted IMF
Margin fraction (MF)strategy_value / total_position_notionalLiquidation monitoring
Open margin fraction (OMF)min(strategy_value, available_collateral) / total_open_position_notionalPre-trade admission for exposure-increasing orders
Initial margin fraction (IMF)Weighted required initial-margin fraction across total open position notionalThreshold that OMF must meet or exceed
Maintenance margin ratio (MMR)MMR_FRACTION / max_leverageLiquidation threshold
The mark price (not the last trade price) is the risk input for notional, PnL, and liquidation checks. See Price Feeds and Mark Price Inputs.

Strategy leverage and shared constants

The baseline margin requirements come from the strategy’s leverage setting and two shared protocol constants.
ParameterValueNotes
Default strategy max leverage3xDerivaDEX strategies default to 3x leverage
Base initial margin fraction1 / max_leverageAt 3x, the base IMF is 0.3333... (33.33%)
IMF_FACTOR0.0004Adds a size-scaling term for very large open positions
MMR_FRACTION0.15Shared maintenance constant used with max_leverage
Maintenance margin ratio at 3x0.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 resulting OMF is at least the resulting IMF.
position_imf = max(1 / max_leverage, IMF_FACTOR × sqrt(open_position_size))
portfolio_imf = sum(position_imf_i × open_position_notional_i) / sum(open_position_notional_i)
omf = min(strategy_value, available_collateral) / total_open_position_notional
admission rule: omf >= portfolio_imf
InputDefinitionNotes
Open position sizeThe 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 directionIncludes posted bids and asks, not just filled positions
Open position notionalopen_position_size × mark_priceUsed to weight each market’s IMF contribution
Position IMFmax(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 IMFNotional-weighted average of the position-level IMFsOne strategy can hold multiple products, so the requirement is aggregated
min(strategy_value, available_collateral) in OMFThe numerator is capped at available collateral when unrealized PnL is positiveUnrealized gains do not increase opening power; unrealized losses still reduce it

Maintenance margin and liquidation trigger

Once a strategy has open exposure, liquidation monitoring uses MF rather than OMF.
strategy_value = available_collateral + unrealized_pnl
total_position_notional = sum(abs(position_size_i) × mark_price_i)
mf = strategy_value / total_position_notional
mmr = MMR_FRACTION / max_leverage
liquidation trigger: mf < mmr
QuantityMeaning
strategy_valueCollateral plus unrealized PnL across all open positions in the strategy
MFCurrent solvency ratio of the strategy against its marked notional exposure
MMRMinimum MF required to keep the strategy out of liquidation
Liquidation threshold at 3x5% (0.05)

When each rule applies

The platform applies the same margin model differently depending on whether an order increases or reduces risk.
CaseMargin rule
Opening a new positionPost-execution OMF >= IMF must hold
Increasing an existing positionPost-execution OMF >= IMF must hold
Posting resting liquidity that could increase exposure if filledIncluded in open-position sizing for OMF and IMF checks
Reducing or closing an existing position without crossing through flat into the opposite sideThe order can bypass the OMF >= IMF admission check because it improves exposure; solvency and execution guards still apply
Existing open position after entryMF 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.
CaseCalculationOutcome
New short order with 1,000 USDC collateral, 1 contract of open exposure, and mark price 1,100OMF = 1,000 / (1 × 1,100) = 0.9091; IMF = max(1 / 3, 0.0004 × sqrt(1)) = 1 / 3Accepted 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 valueOMF = min(1,250, 1,000) / (2 × 1,100) = 1,000 / 2,200 = 0.4545; IMF remains 1 / 3Still 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 contractWorst-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 / 3Rejected 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,500strategy_value = 5,000 - 4,500 = 500; MF = 500 / (100 × 145) = 0.03448; MMR = 0.15 / 3 = 0.05Liquidatable because 0.03448 < 0.05

Size-scaling threshold

The square-root IMF_FACTOR term matters only once a position is large enough to exceed the base leverage floor.
QuantityValue
Crossover conditionIMF_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 sizeIMF = 1 / max_leverage
Above the crossover sizeIMF = 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 codeMeaning
Strategy metrics marginFractionCurrent MF for the strategy
Strategy metrics mmrCurrent maintenance margin ratio; the strategy can be liquidated when marginFraction < mmr
Safety failure OMFLessThanIMFThe post-execution strategy state would leave OMF below IMF, so the order is rejected
The strategy’s leverage setting and other trading parameters can change through product or governance updates.
Last modified on April 24, 2026