📈Price Feeds
Details on ZKX Appchain's internal data provisioning for derivatives trading
Price Definition
ZKX uses the following terms when referring to Price:
Market Price - the price of the latest trade that was successfully matched (executed.)
Index Price - the average market price of assets traded in the exchanges / presented by data providers, used in our DPS. Index Price is also the main contributor to the Mark Price.
Mark Price - is the price used in calculating full liquidations and deleveraging (forced buy & sell.) Also, we use Mark Price for any conditional order execution/trigger. We model Mark Price as fair and temper-resistant.
Additional details:
Unrealized PnL calculation (mark-to-market PnL calculation) is based on the Best Bid price or Best Ask price.
Slippage for Market Orders is based on the Market Price (last traded price) and is passed from one batch to another if the order is forced to be re-batched.
For the calculation of stop loss/take profit triggers, we use the Last Traded Price.
Price Calculation
Perp Index Price
ZKX Perpetual Swaps Index Price = Average Spot Liquidity Mid Price of All Active Sources in Data Provider Services (DPS) for this market.
i.e: Index Price = AVERAGE ( Spot Liquidity Mid Price of Sources )
Spot Liquidity Mid Price of Source - is a subset of all active sources.
One Source ∈ All Active Sources.
Spot Liquidity Mid Price = (Best Bid Price * Ask Size + Best Ask Price * Bid Size) / (Bid Size + Ask Size)
We strive to use up to six independent sources to keep prices fair and temper-resistant, and we use the following rules for the result processing:
The average value is calculated after removing the highest and lowest reference values.
For example - if there are six reference values, remove the highest and lowest values, then calculate the average of the remaining four values.
The reference feeds corresponding to each currency may be different.
The frequency of Perp Index Price updates should equal the time of our L3 block minting.
Perp Mark Price
ZKX Perpetual Swaps Mark Price = (Index Price * 90% + ZKX Impact Mid Price * 10%.)
The frequency of Perp Mark Price updates should equal the time of our L3 block minting.
The Impact Mid is the median of the average entry price market-selling x value of contracts and market-buying x value of contracts. ZKX Impact Mid Price = Average (Impact Bid Price, Impact Ask Price.) Impact Bid Price: The average buy price of the first 5000 highest bid units * step_size in the Order Book Impact Ask Price: The average sell price of the first 5000 lowest ask units * step_size in the Order Book
For example:
i.e. step_size for this market: 0.01
In this order book, the price will be calculated as:
Impact Bid Price = (1800.00 x 5000) / 5000 = 1800.00
Impact Ask Price = (1900 * 828.805 + 2000 * 4171.195) / 5000 = (1574729.5 + 8342390 ) / 5000 = 9917119.5 / 5000 = 1983.42
Impact Mid Price = (1800 + 1983.42) / 2 = 1891.71
Obviously, if we have in total of less than 5000 units in the calculation - we divide not by 5000, but by the total amount of units. I.e. for the following order book calculation is:
Impact Ask Price = (1898.8 * 35.249 + 1899.0 * 84.377) / 119.626 = ( 66930.8012 + 160231.923 ) / 119.626 = 227162.7242 / 119.626 = 1898.941
ZKX Perpetual Swaps Mark Price has an additional applied condition:
If the spread between the Mark Price and the Spot Liquidity Mid Price ≥ 2%, we set Mark Price = Index Price.
Data Sources
Primary sources
Binance
OKX
Kraken
Coinbase
Gate.io
Bybit
Secondary sources (used when Primary sources are unavailable), are enabled manually.
Chainlink
Kline definition
Kline Cases
No trades in time segment - if we have mid-spread, we use mid-spread. If we don't have mid-spread, we use mark price.
If we have any trades in the time segment - we use the last traded price (all trades that have been executed within the time segment.)
Details:
Time segment 60 seconds.
We use the timestamp of the trade from the block, which means if the trade happened at the last T of the segment but was processed when the segment has finished - we use that trade in the next segment.
Last updated