2

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?

1 Answer 1

2
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
9
  • Thank you for the response. This makes sense. However, could you please explain how would I detect this programmatically? Thank you! Mar 26, 2022 at 17:00
  • Also, am I right by assuming that Token0 would match reserves0? Mar 26, 2022 at 17:01
  • 1
    Yes, token0 -> reserves0 and token1 -> reserves1
    – Adam Boudj
    Mar 26, 2022 at 17:06
  • 1
    the amount of liquidity is 399999999999999.999999999 POISON + 1 ETHER. Again I'm not sure to understand, this is actually returning the amount of liquidity
    – Adam Boudj
    Mar 26, 2022 at 17:12
  • 1
    exactly ! But you can't swap 1 ETH for 399999999999999.999999999 POISON because of the slippage and the low liquidity the price impact will be close to 99%, but if you had had enough liquidity, let's say 1000 ETH for 399999999999999999.999999000(1000x times more), it would have been possible to exchange 1eth for 399999999999999.999999999
    – Adam Boudj
    Mar 26, 2022 at 17:22

Your Answer

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

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