Solana - Mint account to Pyth oracle price

:link: Chain Solana

:receipt: I am building an application where I need to get the price of token with oracle that we can derive the feed accounts based on the base asset (USD) and the other side of the pair Sol, or tokens (mint). So basically users can pay with any token for their USD.

Currently, I am having a list of token/USD pair pyth sponsored accounts. In the frontend, I have to manually check the token spent and send that particular pyth sponsored feed account.

I am looking for a way to better handle this. Like I need to pass in the mint account and it just gives me feed_id or better gives the price directly instead of me having to maintain a list of the price accounts. Everything must happen on chain though.

gm!

Hermes has a list of all price feeds that you could use to programmatically map symbols to feed_id’s. It is available here https://hermes.pyth.network/v2/price_feeds/

I don’t think there’s an equivalent of this mapping that can be used on-chain, unfortunately.

1 Like

I came with the same question. As final result i want to get FX rate for SOL/USD pair. Solana programs are using mint addresses (PubKeys) and not XXX string currency code. So you need to follow this steps to do the mapping.

  • Mint AddressToken SymbolPyth Price Feed ID
  1. One issue here that token symbols are not unique (PYUSD) (USDC) (USDG) (USDT).
  2. Off chain json price feeds do not contain mint information.
  3. What about sponsored feeds on solana? no mint information in pyth-sdk-solana.

So in most of scenarios you should maintain this type of mapping.

Symbol Mint Address
USD Coin USDC EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
Tether USDT Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB
Bonk BONK DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263

Ah yes this is true. Unfortunately we do not maintain mint information ourselves, although we’ve received some requests about it. At this time you’d need to maintain your own mapping.