The thing is that I need to calculate the price of a tokan in sol or in usd. I would use one of the publicly available APIs, such as birdeye or jupiter, but they do not display the price of tokens that have not yet launched by open_time. I have all the information about the token such as metadata and liquidity pools from raydium.
2 Answers
I had the pool address so I just streamed the recent transactions in the pool and found the swap ratio to get the price.
To get the current value per (base) token in it's respective (quote) token, you would do something like:
Get the pool baseVault and pool quoteVault, they are just ATAs so you would call getParsedAccount on each and get their amounts (use the non-ui raw amount) and then divide the quoteVault amount by the baseVault amount, which would equal the current price.