1

https://uniswap.org/docs/v2/smart-contracts/router01/#removeliquidityeth

How do i safely/correctly calculate the amountETHMin and amountTokenMin when calling this function from a contract? I could just use 0's but my tx will probably get frontrun/sandwiched.

Thanks!

2 Answers 2

0

Calculated through slippage setting. It should not be set to 0, but should be set to a value calculated with some acceptable range you think. The attacker has no motivation to do frontrun/sandwiched. In order for an attacker to perform such an attack, a large amount of tokens must be swapped, but the attack is not useful due to the slippage setting.

1
  • Hi thanks for the reply. Could you help me figure out exactly what math needs to be performed to calculate these inputs? Thanks!
    – D3l_Gato
    Commented Feb 21, 2021 at 1:24
0

amountTokenMin = liquidity*reserveToken/totalSupply

amountETHMin = liquidity*reserveETH/totalSupply

However, only use this function when WETH is involved in pool, as per docs

Link is dead; so re-posted from UniswapV2Router02.sol; also see screen shot below: enter image description here

Your Answer

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

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