Price Feeds & Oracles
Integrate Pyth, Switchboard, and custom price feeds into your Solana application.
Price oracles provide reliable, tamper-resistant price data for on-chain programs and off-chain applications. Solana has two primary oracle networks: Pyth and Switchboard.
Pyth Network is the dominant oracle on Solana, providing high-frequency price updates for 500+ assets. Pyth uses a pull-based model where prices are published to Solana accounts by data providers. On-chain programs read Pyth price accounts directly. Off-chain applications can use the Pyth SDK to subscribe to price updates.
Switchboard is a decentralized oracle network that supports custom data feeds beyond just price data. Switchboard oracles can be configured to fetch any external data and publish it on-chain. This flexibility makes it suitable for custom metrics, sports data, and other non-price data.
DEX-based Price Feeds
For tokens not covered by Pyth or Switchboard, you can derive prices from DEX pool reserves. Monitor Raydium or Orca pool accounts and calculate the current price from reserve ratios. This approach has higher latency and is subject to manipulation, but works for long-tail tokens.
TWAP (Time-Weighted Average Price)
For on-chain programs that need manipulation-resistant prices, implement a TWAP using historical price observations stored in a circular buffer. Raydium's CLMM pools provide built-in TWAP observations.