Price feed

Composite index weighting

Perpetual swaps track an underlying composite index, which is a weighted average price of spot prices across a selection of exchange offerings. Exactly which exchanges to use is a parameter that can be be modified from an initial setting via governance.

While it is fairly trivial to add more exchanges with custom weightings (which can become necessary as the exchange supports numerous assets), at the moment, the DerivaDEX composite index price is currently constructed in the following manner:

Price feed input sources

Update criterion

The DerivaDEX price feed updates every second, if and only if the price has changed by more than 1 bps (0.01%). This is similar to the standards of highly performany centralized exchanges.

Price feed attributes

The price feed emits "Price checkpoint" events that are stored in the system's verifiable state, that contain the following information:

Index price

The index price is the weighted average composite price as per the details above.

EMA

The EMA (exponential moving average) tracks the spread between the DerivaDEX perpetual swap's price and the underlying index price it is tracking. It is derived in the following manner:

  1. Compute the fair_price of the DerivaDEX order book, which is the midpoint of the best available bid and ask. fair_price = avg(best_bid, best_ask).

  2. Compute the premium, which is the difference between the fair_price and the composite index price. premium = fair_price - index_price.

  3. Compute the latest ema value of this premium using a 30-period EMA multiplier and the last computed ema. ema = (premium - previous_ema) * (2/31) + previous_ema.

In the case where the DerivaDEX order book is consistently trading above the composite index price, this ema will be positive, and if it is trading below the index price, it will be negative. This ema field has special significance for computing and distributing funding rate-related payments.

if there is an empty order book, the fair price is set equal to the index price.

Mark price

The mark price is used to assess liquidations and depict unrealized PNLs for positions. It can be calculated using the index_price and ema described above: mark_price = index_price + delta where delta is the ema bounded to 0.5% of the index price.

Last updated