Pyth Price Feeds

Fetch real-time price data from Pyth Network oracles

Fetch real-time price data from Pyth Network’s decentralized oracle network. Access price feeds for various crypto assets with support for symbol lookup and price formatting.

  1. Price Feed Management

    • Symbol-based feed lookup

    • Price feed ID resolution

    • Real-time price fetching

    • Decimal adjustment

  2. Price Operations

    • Multi-symbol support

    • Price scaling

    • Error handling

    • Format conversion

Copy

// Get feed ID by token symbol
const feedId = await agent.methods.getPythPriceFeedID("SOL");
console.log("SOL Price Feed ID:", feedId);

Copy

Copy

Copy

Copy

Copy

Copy

Copy

Copy

Copy

  1. Feed ID Management

    • Cache common feeds

    • Validate symbols

    • Handle multiple matches

    • Monitor updates

  2. Price Fetching

    • Handle decimals properly

    • Validate responses

    • Consider staleness

    • Format consistently

  3. Error Handling

    • Implement retries

    • Validate inputs

    • Check feed status

    • Log errors

  4. Performance

    • Cache feed IDs

    • Batch requests

    • Monitor latency

    • Handle timeouts

  1. Feed Lookup

    • Invalid symbols

    • Multiple matches

    • Missing feeds

    • Network errors

  2. Price Fetching

    • Stale prices

    • Decimal errors

    • Format issues

    • Connection problems

  3. Data Quality

    • Price accuracy

    • Update frequency

    • Feed reliability

    • Data consistency

Symbol
Feed ID (Mainnet)

SOL/USD

H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG

BTC/USD

GVXRSBjFk6e6J3NbVPXohDJetcTjaeeuykUpbQF8UoMU

ETH/USD

JBu1AL4obBcCMqKBBxhpWCNUt136ijcuMZLFvTP7iWdB

USDC/USD

Gnt27xtC473ZT2Mw5u8wZ68Z3gULkSTb5DuxJy7eJotD

  • Most feeds update every 400ms

  • Updates depend on market conditions

  • Consider confidence intervals

  • Monitor update timestamps

  1. Price Monitoring

    Copy

  2. Error Recovery

    Copy

  • getTokenData: Get token information

  • trade: Execute trades

  • fetchMarketData: Get market info

  • calculatePositionValue: Value positions

Last updated