def SOL_USDC():
client = Client("https://api.mainnet-beta.solana.com")
base = "6P4tvbzRY6Bh3MiWDHuLqyHywovsRwRpfskPvyeSoHsz"
quote = "6mK4Pxs6GhwnessH7CvPivqDYauiHZmAdbEFDpXFk9zt"
base_pubkey = Pubkey.from_string(base)
quote_pubkey = Pubkey.from_string(quote)
base_balance = client.get_token_account_balance(base_pubkey).value.ui_amount
quote_balance = client.get_token_account_balance(quote_pubkey).value.ui_amount
price = quote_balance / base_balance
print(
f"WSOL: {base_balance}\n"
f"USDC: {quote_balance}\n"
f"Price: {price}"
)
I used the basevault and quotevault of the pair address of SOL / USDC (8sLbNZoA1cfnvMJLPfp98ZLAnFSYCFApfJKMbiXNLwxj), I am using the same way of calculation of price to all the tokens but the difference is not multiplying the native price of this to USD because this is the Solana itself.