code-423n4 / 2022-01-sherlock-findings

0 stars 0 forks source link

Gas Optimization: Unnecessary check #238

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

gzeon

Vulnerability details

Impact

Doesn't make much sense to check against type(uint256).max here:

https://github.com/code-423n4/2022-01-sherlock/blob/c763f10c4b5fe2127677d6c25b83adcf3bcec212/contracts/managers/AaveV2Strategy.sol#L94

    if (_amount == type(uint256).max) revert InvalidArgument();
jack-the-pug commented 2 years ago

Withdraw with _amount being type(uint).max will withdraw the whole aToken balance.

If this is removed, it will still revert later anyway as the actual withdrawn amount won't be the same as the _amount.

https://github.com/code-423n4/2022-01-sherlock/blob/c763f10c4b5fe2127677d6c25b83adcf3bcec212/contracts/interfaces/aaveV2/ILendingPool.sol#L192-L193

  • Send the value type(uint256).max in order to withdraw the whole aToken balance

The comment above L94 should be updated though.