Quantcast
Channel: Recent Questions - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 7950

How to calculate token prices from LP pairs using `getTokenAccountBalance`?

$
0
0

I want to reference this post: https://solana.stackexchange.com/a/518/7486.

I am trying to achieve the same as OP of that post. I want to fetch the price of a token. One response (the one I referenced) says that I can use getTokenAccountBalance RPC method however that doesn't work for me.

This is the token
name: Silly Dragon
mint: 7EYnhQoR9YM3N7UoaKRoA44Uy8JeaZV3qyouov87awMs
LP: DsD69qYsFvMX4cBvHbssGneB2aYwECkL3ehYjQ6NH6aq

When I execute

{"jsonrpc": "2.0","id": 1,"method": "getTokenAccountBalance","params": ["DsD69qYsFvMX4cBvHbssGneB2aYwECkL3ehYjQ6NH6aq"    ]}

I receive this error.

{"jsonrpc": "2.0","error": {"code": -32602,"message": "Invalid param: not a Token account"    },"id": 1}

(I also tried with the mint address, that did give me back the same error)

Now I am wondering if that RPC method is actually working or if I am doing something wrong.


Viewing all articles
Browse latest Browse all 7950

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>