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!

1 Like