Getting error when attempting to remove liquidity via removeLiquidityETH (ds-math-sub-underflow)

Hi all,

Im trying to understand Uniswap better to learn more about DeFi so I’ve created a test token, created an LP for it, and added liq. However, when I try to remove the liq I get the following error: ‘ds-math-sub-underflow’. An underflow is obviously happening during a math operation but Im not sure whats causing it (dont worry, im not trying to rugpull, this is purely for personal learning purposes… I find defi fascinating and want to figure out how it works from top to bottom)

I created my LP by calling the router (on testnet) function addLiquidityETH with the following parameters:

  • token: My test token address

  • amountTokenDesired: 1000

  • amountETHDesired: 1

  • amountTokenMin: 0

  • amountETHMin: 0

  • to: My external test account

And heres how I try to withdraw the LP by calling removeLiquidityETH:

  • token: My test token address

  • liquidity: number of LP tokens that were created in the addLiquidityETH call

  • amountTokenMin: 0

  • amountETHMin: 0

  • to: My external test account

Any assistance would be appreciated, thanks!

2 Likes

Have you answered this question yet? I am having the exact same problem on a UniswapLP pool. Did you try varying amounts of the UniLP token? Were the decimals correct?

Try approving the LP tokens first for the contract that is spending it. This might be the issue actually but being masked by the overflow error