There are certain ERC20 tokens that do not support an approval amount type(uint256).max (e.g. USDT). If this is changed to accommodate these tokens, additional steps are needed for other tokens that require setting allowance to zero before changing it=.
The ERC20 tokens that don't accept type(uint256).max will cause a revert in CapitalPool:approve.
If type(uint256).max is replaced, some tokens (e.g., USDT) require setting the allowance to zero before changing it to a non-zero value.
Not being able to approve certain tokens with type(uint256).max leads to not being able to approve those tokens to be able to be withdrawn from TokenManager::withdraw.
If type(uint256).max is replaced without considering tokens requiring zero-setting, it could lead to failed approvals for these tokens.
Foundry
Import IERC20 Interface and change approve:
If incorporating resetting allowance to zero:
Thanks for flagging, indeed since uint(-1) is representative of max uint256 value, when entering the `if` statement, it will be converted to uint96 max amout, so it will not revert as described. In issue #361, the mockToken utilized does not correctly reflect the below approval behavior. ```Solidity function approve(address spender, uint rawAmount) external returns (bool) { uint96 amount; if (rawAmount == uint(-1)) { amount = uint96(-1); } else { amount = safe96(rawAmount, "Comp::approve: amount exceeds 96 bits"); } ```
Thanks for flagging, indeed since uint(-1) is representative of max uint256 value, when entering the `if` statement, it will be converted to uint96 max amout, so it will not revert as described. In issue #361, the mockToken utilized does not correctly reflect the below approval behavior. ```Solidity function approve(address spender, uint rawAmount) external returns (bool) { uint96 amount; if (rawAmount == uint(-1)) { amount = uint96(-1); } else { amount = safe96(rawAmount, "Comp::approve: amount exceeds 96 bits"); } ```
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.