Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't get latest price of SOL/USD from solana mainnet #2409

Open
hitman0290 opened this issue Feb 24, 2025 · 0 comments
Open

I can't get latest price of SOL/USD from solana mainnet #2409

hitman0290 opened this issue Feb 24, 2025 · 0 comments

Comments

@hitman0290
Copy link

Hello,
I am trying to get the latest price of SOL/USD from SOLANA mainnet-beta.
I found price account of SOL/USD is H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG

**import { getPythProgramKeyForCluster, PythHttpClient, parsePriceData, getPythClusterApiUrl } from "@pythnetwork/client";
const SOL_PRICE_FEED_ID = "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d";
export const SOL_PRICE_FEED_ACCOUNT = 'H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG'

const connection = new anchor.web3.Connection(getPythClusterApiUrl('mainnet-beta'))
const onChanAccount = await connection.getAccountInfo(new anchor.web3.PublicKey(SOL_PRICE_FEED_ACCOUNT))
console.log(parsePriceData(onChanAccount.data).aggregate.price)

const connection = new anchor.web3.Connection(getPythClusterApiUrl('pythnet'))
const accountInfo= await connection.getAccountInfo(new anchor.web3.PublicKey(SOL_PRICE_FEED_ACCOUNT))
console.log(parsePriceData(accountInfo.data).aggregate.price)**

The results are different and price from pythnet is correct but the price from mainnet-beta is wrong.
The console output
119.23378
159.55172424

Let me know what is wrong
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant