0

Given a Uniswap v3 pool: how can I find (using the Uniswap v3 pool contract) the amount of WETH and other coins that are in the pool?

I know in Uniswap v2, you can just call the getReserves function.

For example: for this pool, I want to get "347,132 ZuZu and 0.5189 WETH in pool".

enter image description here

1 Answer 1

1

As per my knowledge, there is no straight-forward approach to get the reserve pool in UniswapV3. However, you can play around using balanceOf function of token contract to get these number as long as you know the pair address. Piece of code the play around is

pairAddress = '0xF5a7AE8D465b476e306c8EF764A91b8f119144B4'

wethContract = web3.eth.contract(address=wethAddress, abi=poolAbi)
zuzuContract = web3.eth.contract(address=zuzuAddress, abi=poolAbi)

wethAmount = wethContract.functions.balanceOf(pairAddress).call()
zuzuAmount = zuzuContract.functions.balanceOf(pairAddress).call()

print(wethAmount)
print(zuzuAmount)

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.