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

One of the `if` statement in `update` is useless

Summary

The function update in Staking.sol has an if statement which is useless, and makes now sense to have it.

Vulnerability Details

Update checks first if _balance is greater than balance
https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Staking.sol#L65
then it does the difference between those two variables
https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Staking.sol#L66
and then it checks again with another if statement if the value of the difference is greater than 0
https://github.com/Cyfrin/2023-07-beedle/blob/658e046bda8b010a5b82d2d85e824f3823602d27/src/Staking.sol#L67
but this is mostly useless, since if the first statement is true, and _balance is greater than balance it means that the difference will always be greater than 0.

Impact

Low impact, don't use that if statement since it doesn't do anything

Tools Used

Manual review

Recommendations

Delete the if statement stated

Support

FAQs

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