2

At the end of June 2024, Pyth push oracles will be discontinued, so all programs that currently use them must migrate to pull oracles.

The drop-in replacement is to consume Price Feed Accounts. To use these on-chain, Pyth provides an sdk: https://crates.io/crates/pyth-solana-receiver-sdk

However, the SDK uses a relatively new version of many dependencies (for example Anchor >=28), while many projects that have been consuming Pyth oracles for some time are locked to older dependencies. For example, we have a project on:

[dependencies]
anchor-lang = "0.24.2"
anchor-spl = { version = "0.24.2", features = ["dex"] }
solana-program = "1.7"
pyth-sdk-solana = "0.7.0"

In many cases, the project has nested dependencies outside of our control.

How can we update to the new pyth oracle without updating dependencies?

1 Answer 1

1

Use the pyth-min crate instead: https://crates.io/crates/pyth-min/0.1.1

This crate uses zero dependencies, and relies on reading the Pyth account from raw bytes as an UncheckedAccount:

let data = &ctx.accounts.price_acc.try_borrow_data()?[..][8..];
let price_v2 = PriceUpdateV2::get_price_update_v2_from_bytes(data);

let price = price_v2.get_price_no_older_than(
    &Clock::get()?.unix_timestamp,
    MAXIMUM_AGE, // in seconds
    None, // Pass the feed ID in bytes if you want to validate it
)?;

Fork, view source, or contribute at: https://github.com/mithraiclabs/pyth-min

See reference implementation of usage at: https://github.com/mithraiclabs/pyth-min-ref

Not the answer you're looking for? Browse other questions tagged or ask your own question.