Price Architecture

Pricing an asset is subtly complex. VDEX measures the price of perpetuals through robust price indices and displays cosmetic values for client-side monitoring.

Robust Price Indices

VDEX utilizes various price types to minimize the risk of market manipulation.

pOracle: the oracle price is an external data feed used in calculating the funding rate and in pMark. The data source depends on the asset class.

  • Crypto - Binance, updates every second

  • Stocks, Commodities, and Foreign Exchange - TwelveData, updates every 5 seconds

  • Prediction Markets - Seda, updates every 200ms

pMark: the mark price is designed to be a fair approximation of the perp price. It is used in calculating unrealized PnL and margin requirements, as well as for TP/SL and liquidation triggers. pMark updates every 5 seconds and is the median value of:

  • pOracle plus a 150 second exponential moving average (EMA) of the difference between pMid and pOracle

  • The median of the best bid, best ask, and pLast on VDEX

  • pOracle

pImpact: the impact price measures market depth at pMid. Bid and ask orders of size $1,000 are simulated against the order book. The median of the average execution prices is pImpact. pImpact is used exclusively in calculating the funding rate.

pMid: the mid price is the average price between the best bid price and best ask price. pMid is used in calculating pMark and is displayed on trading charts.

pLast: the last price is the most recent price at which an order was executed. pLast is used in calculating pMark and appears in the token dashboard.

Display Prices

The protocol's fundamental state is based solely on margin. The following prices are inferred from margin and displayed for convenient monitoring:

  • Entry price is updated to the average of the former entry price and successive trade prices, weighted by size

  • Exit price is the executed price of an order.

  • Expected price is the simulated execution price based on position size and the current state of the order book

  • Unrealized PnL is the difference between entry price and pMark, scaled by position size

  • Realized PnL measures the absolute change in margin from a position. It excludes funding payments and fees.

  • Liquidation price reflects the point at which account equity falls below the maintenance margin requirement

Formulas

Exponential Moving Average

The exponential moving average (EMA) is calculated using the following method. Let sample be the new data point, and let t be the time (in minutes) since the last update.

The EMA is defined as:

ema = numerator_new / denominator_new

numerator_new -> numerator_prev * exp(-t / 2.5) + sample * t

denominator_new -> denominator_prev * exp(-t / 2.5) + t

This formulation applies a decay factor over a 2.5-minute window, giving more weight to recent values while smoothing out short-term noise.

Last updated