Derive the Pyth Lazer price feed account and decode its bytes
PriCems5tHihc6UDXDjzjeawomAwBduWMGAi8ZUjppd
// seeds: ["price_feed", "pyth-lazer", feed_id_as_string] function deriveFeedAddress (feedId: string) { const [addr] = web3.PublicKey.findProgramAddressSync( [Buffer.from('price_feed'), Buffer.from('pyth-lazer'), Buffer.from(feedId)], PROGRAM ID ); return addr }
i64
const addr = deriveFeedAddress(feed.id); const PRICE_OFFSET = 73; const dv = new DataView(ai.data.buffer, ai.data.byteOffset, ai.data.byteLength); const raw = dv.getBigUint64(PRICE_OFFSET, true); const price = Number(raw) * Math.pow(10, feed.exponent);
Was this page helpful?