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
- Multi-source aggregation — No single exchange can manipulate the oracle price
- Weighted median — Outlier prices are naturally excluded without complex filtering
- Validator consensus — Oracle prices are submitted by validators and agreed upon through BFT consensus
- EMA smoothing — Mark prices use an exponential moving average to prevent spike manipulation
Price Sources
The oracle aggregates price data from eight centralized exchanges:
| Source | Weight | Feed Type |
|---|---|---|
| Binance | High | WebSocket real-time |
| Coinbase | High | WebSocket real-time |
| OKX | Medium | WebSocket real-time |
| Bybit | Medium | WebSocket real-time |
| Kraken | Medium | WebSocket real-time |
| Bitfinex | Low | WebSocket real-time |
| KuCoin | Low | WebSocket real-time |
| Gate.io | Low | WebSocket real-time |
| CoinGecko | Medium | REST API real-time |
| Chainlink | High | Decentralized oracle network |
| Pyth | High | Decentralized 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:
- Collect price submissions from all available sources
- Sort prices in ascending order
- Accumulate weights from lowest to highest
- 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,405The $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:
- Every validator maintains WebSocket connections to all eight CEX feeds
- At each block, the validator computes its weighted median
- The block proposal includes the proposer’s oracle price
- Other validators verify the price is within acceptable deviation (configurable tolerance)
- 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)| Parameter | Value |
|---|---|
| EMA span | Configurable per market (default: 30 seconds) |
| Update frequency | Every block (sub-second) |
| Purpose | Smooths 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:
| Condition | Action |
|---|---|
| Source stale > 30 seconds | Source excluded from median, weight redistributed |
| Fewer than 3 sources available | Oracle enters “degraded mode” — wider liquidation buffer applied |
| All sources stale | Trading 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
| Parameter | Default | Governance-Adjustable |
|---|---|---|
| Source count | 8 | Yes |
| Weight distribution | Volume-based | Yes |
| Staleness threshold | 30 seconds | Yes |
| EMA span | 30 seconds | Yes |
| Deviation tolerance | 1% (validator-to-validator) | Yes |
| Minimum active sources | 3 | Yes |