20,000 USDC
View results
Submission Details
Severity: gas
Valid

Redundant `_diff` zero check

Summary

The _diff zero check in Staking.update(), if (_diff >0) {} is redundant.

Vulnerability Details

In Staking.update(), it is first checked that _balance is greater than balance (i.e., the WETH balance of Staking is more than the deposited token balance). Then, the difference between the two is stored in _diff = _balance - balance. Afterward, it is checked if (_diff > 0) {}. However, this zero check is redundant as if _balance is greater than balance, their difference, ipso facto, will be more than 0.

Impact

Gas

Tools Used

Manual Review

Recommendation

Remove the if (_diff > 0) {...} check from Staking.update(), the check if (_balance > balance) {...} is enough.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.