Overview
The Oracle precompile provides access to Sei’s native oracle system, allowing you to query real-time exchange rates and time-weighted average prices (TWAP) for various assets. This precompile bridges EVM contracts with Sei’s oracle module for price data. Contract Address:0x0000000000000000000000000000000000001008
Key Features
- Real-Time Exchange Rates: Get current market prices for supported assets
- TWAP Data: Access time-weighted average prices with configurable lookback periods
- Multi-Asset Support: Query prices for various token denominations
- High Precision: Decimal-accurate price data for DeFi applications
Available Functions
View Functions
getExchangeRates() → DenomOracleExchangeRatePair[]
getExchangeRates() → DenomOracleExchangeRatePair[]
Get current exchange rates for all supported denominations.Parameters: NoneReturns: Array of denomination-price pairs with metadataReturn Structure:
getOracleTwaps(uint64) → OracleTwap[]
getOracleTwaps(uint64) → OracleTwap[]
Get time-weighted average prices with a specified lookback period.Parameters:
lookback_seconds(uint64): Lookback period in seconds
Usage Examples
- Viem
- Ethers.js
- Manual
Common Use Cases
DeFi Applications
- Price Oracles: Use real-time prices for lending/borrowing protocols
- DEX Integration: Price discovery and arbitrage detection
- Liquidation Systems: Monitor collateral values with TWAP data
- Yield Farming: Calculate APY based on token prices
Trading Applications
- Price Alerts: Monitor significant price movements
- Technical Analysis: Use TWAP data for trend analysis
- Risk Management: Compare current prices vs historical averages
- Portfolio Valuation: Calculate total portfolio value
Analytics & Monitoring
- Market Data: Track price history and volatility
- Deviation Analysis: Identify price anomalies
- Performance Metrics: Calculate returns and benchmarks
TWAP Lookback Periods
Common lookback periods for different use cases:- 1 minute (60s): High-frequency trading signals
- 5 minutes (300s): Short-term price smoothing
- 1 hour (3600s): Medium-term trend analysis
- 4 hours (14400s): Swing trading signals
- 24 hours (86400s): Daily average pricing
- 7 days (604800s): Weekly trend analysis
Error Handling
Common errors when using the Oracle precompile:- No data available: Some denominations may not have oracle data
- Stale data: Check timestamp to ensure data freshness
- Invalid lookback: Very large lookback periods may not have data
Related Precompiles
- Bank: Query token balances and metadata
- Staking: Validator and delegation information
- Governance: Proposal and voting data