0

I am new to Ethereum and Solidity and have recently faced the following issue which I cannot understand.

I am trying to use the UniswapV2 router in order to calculate the exchange rates between tokens. I am using the method getAmountsIn and notice the following behavior:

I use USDT and SHIB in the UniswapRouterV2 as follows

enter image description here

As you see I am trying to convert 10000 TETH to SHIB. The router shows a ds-math-sub-underflow error which I cannot tell why is happening. On uniswap, this calculation can be done without a problem (never executed though).

This problem also happens in the PancakeSwapRouterV2.

Questions:

  1. TETH has 6 decimals, so If I want to trade 10000TETH the value I insert in the amountOut field should be 10000 * 10^6, right?
  2. Does this error have to do with the amount of SHIB available in the network?
  3. Any way to tackle this problem?

If you could provide any useful source to read more about this issue, I would be more than grateful.

1 Answer 1

0

There's only ~5k USDT in the pool. You have one decimal off, you are trying to get 1000 USDT out, but you have written 10000 USDT out which is greater than the number of USDT in the pool leading to the underflow in the estimation.

1
  • Nice, I see what is going on now, thanks for answering
    – al96
    Mar 13 at 21:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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