How can I read from sponsored SVM price feeds in my anchor program instead of sending update myself?

I have deployed my basic program for debugging pyth price feeds on Solana but because it’s initially fetching the price off-chain and sending price update it’s so much data that it’s split into 2 different txs and has a lot higher cost. Here’s current code for the reference:

const MAX_AGE_SECS: u64 = 60;
const FEED_ID_HEX: &str =
    "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d";

#[program]
pub mod pyth_debug {
    use super::*;

    pub fn debug(ctx: Context<Debug>) -> Result<()> {
        let clk = Clock::get()?;
        let feed_id = get_feed_id_from_hex(FEED_ID_HEX)
            .map_err(|_| error!(ErrorCode::BadFeedId))?;

        let pu = &ctx.accounts.price_update;
        let p = pu
            .get_price_no_older_than(&clk, MAX_AGE_SECS, &feed_id)
            .map_err(|_| error!(ErrorCode::PriceNotFresh))?;

        msg!("PYTH feed: {}", FEED_ID_HEX);
        msg!("slot={}, verif_level={:?}", pu.posted_slot, pu.verification_level);
        msg!("price_mantissa={}, conf={}, exponent={}", p.price, p.conf, p.exponent);

        Ok(())
    }
}

#[derive(Accounts)]
pub struct Debug<'info> {
    pub price_update: Account<'info, PriceUpdateV2>,
}

#[error_code]
pub enum ErrorCode {
    #[msg("Bad feed id")]
    BadFeedId,
    #[msg("Price too old or not fully verified")]
    PriceNotFresh,
}

Now, I am wondering if there is a way to just read from the sponsored feeds on Solana without including price update account with prices that I fetched myself offchain? I wasn’t able to find any examples for that in the documentation.

gm,

Your code above should work with the price_update account set to the sponsored feed account from https://docs.pyth.network/price-feeds/sponsored-feeds.

Both ephemeral price update accounts and price feed accounts (like the ones used by sponsored feeds) contain the PriceUpdateV2structure. This means the syntax for consuming any of the two is the same.

Best,

Guillermo