Uniswap – How to Determine Reserves Using getReserves Method on Uniswap Pair

uniswapweb3js

I have a bunch of incoming WETH pairs that I am calling:

const reserves = await uPair.methods.getReserves().call()

My understanding is that getReserves() will output the reserves based on the order the tokens of the pair are input to the function. However, I am wondering how that works when calling getReserves() on a pair like I am doing above.

If I am getting token0 and token1 from the pair. Does that mean that token0 would match reserves0. Then the same thing for token1 and reserves1?

Lastly, I am getting outputs like the following:

Token0: 0x8E84f5B87F29c512c25026bF3169d134351c3Ba5
Token1: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Pair: 0x8230F1f18FCB1Ca08BE63CFfe543F710a737f53A
Reserves 0: 399999999999999999999999
Reserves 1: 1000000000000000000

If my understanding is correct. Reserves1 would match token1 and that would mean that there is 1 ETH for the WETH side of the pairing and it looks like reserves are being returned in WEI. What I do not understand is why are the decimals different between the two tokens? I am pretty new to this, but I would have thought that if it is a WETH pairing they would be the same?

Best Answer

Token0: 0x8E84f5B87F29c512c25026bF3169d134351c3Ba5
Token1: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Pair: 0x8230F1f18FCB1Ca08BE63CFfe543F710a737f53A
Reserves 0: 399999999999999999999999
Reserves 1: 1000000000000000000

Token0 has 9 decimals Token1 has 18 decimals

since there is no float on EVM, decimals is just an indicator to see where you should put your ., in this case token0 is 9th position from the end, and token1 18th position from the end.

  • Token0: 399999999999999.999999999 POISON
  • Token1: 1.000000000000000000 Ether
Related Topic