- Purpose: Its primary role is to provide a reliable, external benchmark for the true underlying asset price. It is used as a key input for calculating the Mark Price and for determining the premium/discount component in the funding rate calculation.
- Mechanism: The Oracle Price is sourced from a reliable external oracle provider (e.g., Pyth). This decouples the core price feed from Bulk Exchange’s internal order book, making it highly resistant to local market manipulation.
- Updates: The
ClearingHousereceives Oracle Price updates via a dedicated channel, which in turn triggers a recalculation of the Mark Price.
MarkPriceCalculator is the component responsible for this vital calculation.
Component 1: Adjusted Oracle Price
- Purpose: To anchor the Mark Price to the true underlying asset price from a reliable external source.
- Mechanic: This component starts with the external Oracle Price and adjusts it using a 150-second Exponential Moving Average (EMA) of the difference between the local order book’s mid-price and the Oracle Price. This allows the Mark Price to slowly and smoothly account for any persistent premium or discount on Bulk Exchange without being swayed by temporary volatility.
- Purpose: To reflect the immediate, actionable price on the exchange itself.
- Mechanic: This component is the median of three values from the local order book: the current best bid, the best ask, and the last traded price. Using the median of these three values provides a more stable local price indicator than using the mid-price alone.
- Purpose: To provide a stabilizing factor and dampen noise from rapid, short-term price fluctuations on the local market.
- Mechanic: This component is a 30-second EMA of the Local Order Book Median (Component 2). It acts as a slightly lagging, smoothed representation of the local market price.
calculate function within the MarkPriceCalculator computes these three components, sorts them, and selects the median value. The result is a scaled Decimal that represents the final, robust Mark Price. The implementation includes sensible fallbacks, such as using the Smoothed Local Price (Component 3), to avoid using volatile data in the case of thin order books.
Whenever the MarkPriceCalculator computes a new Mark Price, it is immediately sent back to the ClearingHouse, ensuring the central risk engine always has the latest and most accurate price for all its calculations.