GX CoreOracle

Oracle

GX Core uses a multi-source oracle system to derive fair market prices for all perpetual futures markets. The oracle aggregates price feeds from eight major centralized exchanges, CoinGecko real-time prices, and supports Chainlink/Pyth decentralized oracle feeds. A weighted median computation ensures resistance to single-source manipulation.


Design Principles

  1. Multi-source aggregation — No single exchange can manipulate the oracle price
  2. Weighted median — Outlier prices are naturally excluded without complex filtering
  3. Validator consensus — Oracle prices are submitted by validators and agreed upon through BFT consensus
  4. EMA smoothing — Mark prices use an exponential moving average to prevent spike manipulation

Price Sources

The oracle aggregates price data from eight centralized exchanges:

SourceWeightFeed Type
BinanceHighWebSocket real-time
CoinbaseHighWebSocket real-time
OKXMediumWebSocket real-time
BybitMediumWebSocket real-time
KrakenMediumWebSocket real-time
BitfinexLowWebSocket real-time
KuCoinLowWebSocket real-time
Gate.ioLowWebSocket real-time
CoinGeckoMediumREST API real-time
ChainlinkHighDecentralized oracle network
PythHighDecentralized oracle network

Weights are assigned based on exchange volume, reliability, and historical uptime. The exact weight distribution is configurable and subject to governance. CoinGecko provides real-time price data, while Chainlink and Pyth provide decentralized, tamper-resistant oracle feeds.


Weighted Median Calculation

Rather than a simple average (which is vulnerable to outlier manipulation), GX Core computes a weighted median:

  1. Collect price submissions from all available sources
  2. Sort prices in ascending order
  3. Accumulate weights from lowest to highest
  4. The oracle price is the price at which cumulative weight crosses 50%

Example:

Prices:  [$67,400, $67,410, $67,405, $67,390, $67,415, $67,408, $67,402, $67,500]
Weights: [25%,     20%,     15%,     15%,     10%,     8%,      5%,      2%     ]

Sorted:  $67,390 (15%) -> $67,400 (25%) -> $67,402 (5%) -> $67,405 (15%) -> ...

Cumulative: 15% -> 40% -> 45% -> 60% (crosses 50%)

Oracle price = $67,405

The $67,500 outlier is automatically excluded because it falls above the 50% cumulative weight threshold.


Validator Submissions

Each validator independently fetches prices from all eight sources and computes a weighted median. These per-validator oracle prices are then included in the block proposal:

  1. Every validator maintains WebSocket connections to all eight CEX feeds
  2. At each block, the validator computes its weighted median
  3. The block proposal includes the proposer’s oracle price
  4. Other validators verify the price is within acceptable deviation (configurable tolerance)
  5. The final oracle price is the median of all validator submissions

This two-layer median (source-level, then validator-level) provides double protection against manipulation.


Mark Price

The mark price is the price used for margin calculations, PnL computation, and liquidation thresholds. It is derived from the oracle price using an Exponential Moving Average (EMA):

mark_price = EMA(oracle_price, span)
ParameterValue
EMA spanConfigurable per market (default: 30 seconds)
Update frequencyEvery block (sub-second)
PurposeSmooths short-term volatility, prevents liquidation cascades from price spikes

The EMA ensures that a momentary price spike on one exchange does not instantly trigger liquidations. The mark price converges to the oracle price over time but dampens short-term noise.


Staleness Protection

If a price source becomes stale (no update within a configurable window), it is excluded from the median calculation:

ConditionAction
Source stale > 30 secondsSource excluded from median, weight redistributed
Fewer than 3 sources availableOracle enters “degraded mode” — wider liquidation buffer applied
All sources staleTrading is paused for the affected market

Funding Rate Oracle

The oracle also provides the reference price for funding rate calculations:

funding_rate = clamp((mark_price - oracle_price) / oracle_price, -0.05%, +0.05%)

The oracle price serves as the “fair value” anchor. When the perpetual mark price deviates from the oracle price, funding payments incentivize convergence.


Configuration

ParameterDefaultGovernance-Adjustable
Source count8Yes
Weight distributionVolume-basedYes
Staleness threshold30 secondsYes
EMA span30 secondsYes
Deviation tolerance1% (validator-to-validator)Yes
Minimum active sources3Yes