Codeup::claimCodeupERC20() adds liquidity to the Uniswap pool whenever the weth balance is bigger than 1. However, an amount bigger than 1 may still lead to reverts if it is low enough. If it is exactly 1, it will shift right to get the amount of weth to swap for CodeupERC20, trying to swap an amount of 0 and reverting. If it is bigger than 2, but still low, it may swap this for an even smaller amount of CodeupERC20, reverting when adding liquidity due to not providing enough liquidity to mint a single share.
A poc is available to confirm the finding.
Recommendation
Instead of setting 1, a slightly bigger dust amount could be use to ensure it does not revert.
I added a new constant
uint256 private constant MIN_AMOUNT_FOR_ADDING_LIQUIDITY = 0.0001 ether;
and now I am checking against it. Will this amount be enough?
Description
Codeup::claimCodeupERC20()
adds liquidity to theUniswap
pool whenever theweth
balance is bigger than1
. However, an amount bigger than1
may still lead to reverts if it is low enough. If it is exactly 1, it will shift right to get the amount ofweth
to swap forCodeupERC20
, trying to swap an amount of0
and reverting. If it is bigger than 2, but still low, it may swap this for an even smaller amount ofCodeupERC20
, reverting when adding liquidity due to not providing enough liquidity to mint a single share. A poc is available to confirm the finding.Recommendation
Instead of setting
1
, a slightly bigger dust amount could be use to ensure it does not revert.