Nicolas REY
Nicolas REY

Reputation: 467

How to compute a token price with the reserves

I have a pool on pancakeswap: 0x6bbc40579ad1BBD243895cA0ACB086BB6300d636 It's the BTCB - WBNB pool.

That I got using this:

factory_contract.functions.getPool("0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", "0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c", 500).call()

When I call the reserve of each token like this:

reserve0 = token0_contract.functions.balanceOf(pool).call()
reserve1 = token1_contract.functions.balanceOf(pool).call()

And divide by 10**18, I get:

reserve0 = 2591.57
reserve1 = 49.20

Which is indeed what I get on bscscan: enter image description here

But if I do price = reserve0 / reserve1 = 52.66, far from the price displayed on pancakeswap: enter image description here

So what am I missing here ?

Upvotes: 0

Views: 72

Answers (0)

Related Questions