Price types and what they are used for
The mark price (not the last trade price) determines risk checks.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
DerivaDEX pricing reference for external spot sources, index-price aggregation, mark-price calculation, clamp bounds, and mark-dependent trading checks.
| Price | Definition | Used for |
|---|---|---|
| Index price | Composite spot price from the configured external feeds | External reference input to the mark price |
| Mark price | Index price plus a smoothed premium, clamped to ±50 basis points (±0.5%) of index | Margin, liquidation, funding, and price-band checks; fills still execute at book price |
| Last trade price | Price of the most recent fill on the DerivaDEX order book | Trade reporting and chart displays |
| Bankruptcy price | Price at which a strategy’s collateral is fully consumed by position losses | Liquidation spread and auto-deleveraging (ADL) pricing |
| Market | Underlying | External spot sources |
|---|---|---|
ETHP | ETH | Coinbase ETH-USD, Binance ETHUSDC, Gemini ETHUSD |
BTCP | BTC | Coinbase BTC-USD, Binance BTCUSDC, Gemini BTCUSD |
median_source_price = median(latest_source_prices)
clamped_source_i = clamp(source_i, 0.995 × median_source_price, 1.005 × median_source_price)
clamped_composite = average(clamped_source_1 ... clamped_source_n)
index_price_next = index_price_prev + alpha × (clamped_composite - index_price_prev)
alpha = 2 / (30 + 1)
| Parameter | Value | Notes |
|---|---|---|
| Aggregation method | Median anchor, then arithmetic mean | Outliers are clamped before averaging |
| Per-source outlier clamp | ±0.5% around the median | Applied separately to each source price |
| EMA period | 30 updates | alpha = 2 / (30 + 1) |
| Default oracle polling interval | 1 second | Source feeds are polled once per second in the default configuration |
| First published index price | Current clamped composite | No time smoothing applies until there is a prior published value |
| Input | Definition | Fallback behavior |
|---|---|---|
| Index price | Current composite spot price from the external feeds | Required base input |
| Fair price | Best available book reference from DerivaDEX quotes | Midpoint if both sides exist; bid if only bid exists; ask if only ask exists; index price if the book is empty |
| Premium EMA | Exponential moving average of fair_price - index_price | Carries forward the prior premium state between updates |
fair_price = (best_bid + best_ask) / 2 if both sides exist
fair_price = best_bid if only bid exists
fair_price = best_ask if only ask exists
fair_price = index_price if the book is empty
premium = fair_price - index_price
premium_ema_next = premium_ema_prev + alpha × (premium - premium_ema_prev)
mark_price = index_price + clamp(premium_ema_next, -0.005 × index_price, +0.005 × index_price)
| Parameter | Value | Notes |
|---|---|---|
| Premium input | fair_price - index_price | Tracks the DerivaDEX book relative to the external index |
| EMA period | 30 updates | Uses the same smoothing constant as the index update |
| Mark-price clamp | ±50 bps (±0.5%) of index price | Prevents the mark from drifting arbitrarily far from the external reference |
| Realtime feed | MARK_PRICE | Carries mark-price and funding-rate updates |
| Check | What happens |
|---|---|
| Explicitly priced order validation | Sequencing rejects an explicitly priced order when its taker price breaches the product’s max_taker_price_deviation from the current mark price |
| Market-order handling | Market orders skip the sequencer deviation check because they have no explicit price |
| Matching price band | When no explicit taker limit exists, matching derives a mark-price-relative limit from the product’s max_taker_price_deviation |
| Residual beyond the band | Any unmatched remainder is canceled rather than filled outside the effective band |
| Missing mark price | Requests can fail with MarketPriceNotAvailable instead of trading without a current risk price |
| Book state | Fair-price input |
|---|---|
Best bid 2,000, best ask 2,002 | Midpoint 2,001 |
Best bid 2,000, no ask | Bid 2,000 |
No bid, best ask 2,002 | Ask 2,002 |
| No bid and no ask | Current index price |