The issue shows that the safeApprove function from OpenZeppelin SafeERC20 will revert if the current allowance is not zero when approving tokens. It will dos the addLiquidity and addLiquidityOnlyStETH functions of AMO.
The mitigation commit replaces all the safeApprove function by standard approve function. It's valid.
Suggestion
The OpenZeppelin SafeERC20 wrappers around ERC20 operations that throw on failure (when the token contract returns false). If you really want to avoid some erc20 with non-standard implementations, you can use safeApprove like:
Lines of code
Vulnerability details
Lines of code
Vulnerability details
Comments
The issue shows that the
safeApprove
function from OpenZeppelin SafeERC20 will revert if the current allowance is not zero when approving tokens. It will dos theaddLiquidity
andaddLiquidityOnlyStETH
functions of AMO.The mitigation commit replaces all the
safeApprove
function by standardapprove
function. It's valid.Suggestion
The OpenZeppelin SafeERC20 wrappers around ERC20 operations that throw on failure (when the token contract returns false). If you really want to avoid some erc20 with non-standard implementations, you can use safeApprove like:
But in practice, the
safeApprove
has been marked as "Deprecated". UsesafeIncreaseAllowance
andsafeDecreaseAllowance
instead.