Token Price Feeds
How to fetch and use real-time price feeds for Solayer tokens using Pyth Network
Solayer Token Price Feeds Guide
This guide explains how to fetch real-time price feeds for sUSD
, sSOL
, and Layer
using Pyth Network.
It is intended for developers integrating on-chain or off-chain price functionality into applications or smart contracts.
Price Feed Sources
Solayer tokens are supported on Pyth Network with live, decentralized price feeds:
Token | Feed Symbol | Pyth Price Feed URL |
---|---|---|
Layer | Crypto.LAYER/USD | https://www.pyth.network/price-feeds/crypto-layer-usd |
sSOL | Crypto.sSOL/SOL::RR | https://www.pyth.network/price-feeds/crypto-ssol-sol-rr |
sUSD | Crypto.sUSD/USD::RR | https://www.pyth.network/price-feeds/crypto-susd-usd-rr |
How to Use Pyth Price Feeds
You can consume these feeds in two ways: on-chain (Solana programs) and off-chain (apps, bots, bridges, etc).
1. On-Chain: Using Real-Time Data in Solana Programs
Solana programs can directly use Pyth’s price data via CPI.
Steps:
- Locate the Pyth price account from the links above
- Pass the price account as an input to your smart contract
- In the contract, deserialize and access:
price
confidence_interval
expo
- Always validate:
status == Trading
- the publish time is recent enough (i.e. not stale)
Reference: Using Real-Time Data in Solana Programs
2. Off-Chain: Using Real-Time Price Data
Pyth recommends using hermes-client
or calling the get_price_updates
API for secure off-chain usage.
get_price_updates API (Signed & Verifiable)
To fetch signed, binary-encoded price updates:
This method is suitable for:
- Secure data ingestion
- Cross-chain bridging
- Price verification in backend systems
Reference: Fetch Price Updates
Deprecated / Not Recommended
price-service-sdk
is deprecated and should not be used.- The
api/latest_price
HTTP endpoint is still functional but not recommended for production use:- It is not cryptographically verified
- It may be deprecated in the future
- Use only for internal dashboards or quick prototyping
Additional Resources
- Pyth Developer Docs
- Feeds available on testnets via
pythnet
anddevnet