Oracle Parameters:
- Source set (which exchanges and venues to query)
- Staleness bounds (maximum age of acceptable price data)
- Deviation thresholds (maximum allowed price variance)
- Circuit breakers (when to pause trading)
Price Aggregation Methodology
The protocol employs a multi-source, multi-method approach to price discovery:Data Sources
Centralized Exchanges:- Binance
- Coinbase
- Kraken
- Regional exchanges (based on fiat currency)
- Other P2P protocol instances
- OTC desk quotes
- Local exchange averages
- DEX prices (Uniswap, Curve)
- Oracle feeds (Chainlink, Pyth)
Aggregation Methods
Median Calculation
Median Calculation
The primary method uses the median of all valid sources:
- Collect prices from all sources
- Filter out stale or outlier data
- Calculate median value
- Apply as reference price
- Robust against single-source manipulation
- Resistant to outliers
- Simple and transparent
Time-Weighted Average Price (TWAP)
Time-Weighted Average Price (TWAP)
For added stability, especially during volatile periods:
- Calculate median at regular intervals (e.g., every 30 seconds)
- Average these medians over a time window (e.g., 5 minutes)
- Use TWAP as reference price
- Smooths short-term volatility
- Harder to manipulate through brief price spikes
- More stable for users
Fallback Hierarchy
Fallback Hierarchy
If primary methods fail:
- Primary: Median of all sources
- Secondary: TWAP if real-time median unavailable
- Tertiary: Last known good price (with staleness limits)
- Emergency: Circuit breaker triggers, trading pauses
- Insufficient valid sources (fewer than 3)
- Extreme deviation (greater than 5% from recent average)
- Stale data (>60 seconds old)
- Oracle downtime
Price Parameters (Governance-Controlled)
Staleness Bounds
Deviation Thresholds
Quote Expiry
All price quotes include an expiry timestamp:
- Standard expiry: 60 seconds from quote generation
- Volatile market expiry: 30 seconds during high volatility
- Stable market expiry: 120 seconds during stable periods
Circuit Breakers
The protocol includes multiple layers of circuit breakers to protect users during abnormal conditions:Level 1: Warning
Trigger Conditions:- Price deviation >3% from TWAP
- Single source failure
- Increased latency in price updates
- Continue trading with enhanced monitoring
- Reduce quote expiry times
- Log events for governance review
Level 2: Caution
Trigger Conditions:- Price deviation >4.5% from TWAP
- Multiple source failures
- Significant latency issues
- Reduce maximum order sizes by 50%
- Increase bond requirements
- Extend settlement windows
- Alert users to abnormal conditions
Level 3: Circuit Breaker
Trigger Conditions:- Price deviation >5% from TWAP
- Majority of sources unavailable
- Suspected oracle manipulation
- Flash crash or extreme volatility
- Immediate trading pause for all new orders
- Existing orders continue through settlement
- Governance notified automatically
- Manual review required to resume trading
Quote Flow Example
Regional Price Variations
The protocol accounts for regional price variations:Currency-Specific Oracles
Each fiat currency has dedicated oracle sources: USD/USDC:- US-based exchanges weighted higher
- Includes international USD pairs
- Indian exchanges (WazirX, CoinDCX)
- P2P local rates
- Official forex rates
- Brazilian exchanges (Mercado Bitcoin)
- PIX-based P2P rates
- Regional forex feeds
Local Spread Adjustments
The protocol applies market-adjusted spreads based on:
- Local liquidity conditions
- Payment rail characteristics
- Regional volatility
- Merchant availability
Oracle Security
Attack Vectors and Mitigations
Price Manipulation
Price Manipulation
Attack: Manipulate a single source to influence the median.Mitigation:
- Use multiple diverse sources (10+)
- Median calculation resistant to outliers
- Outlier detection and filtering
- Source diversity requirements
Flash Crash Exploitation
Flash Crash Exploitation
Attack: Execute trades during brief extreme price movements.Mitigation:
- TWAP smoothing over 5-minute windows
- Circuit breakers trigger on rapid changes
- Quote expiry limits exposure window
- Increased bonds during volatility
Oracle Downtime
Oracle Downtime
Attack: DDoS oracles to halt trading or force fallbacks.Mitigation:
- Multiple independent oracle providers
- Fallback hierarchy with graceful degradation
- Cached last-known-good prices
- Automatic circuit breaker on extended downtime
Front-Running
Front-Running
Attack: Monitor oracle updates and front-run price changes.Mitigation:
- Frequent price updates (every 30s)
- Short quote expiry windows
- Randomized update timing
- On-chain commit-reveal for large orders (planned)
Governance and Upgradability
Oracle parameters are governance-controlled:- Source management: Add/remove price sources
- Weight adjustments: Change source weights in aggregation
- Threshold tuning: Adjust deviation and staleness limits
- Circuit breaker rules: Modify trigger conditions
- Spread parameters: Update regional spread adjustments
Emergency parameter updates (e.g., removing a compromised source) can be executed by the multisig with expedited process, subject to later governance ratification.