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

For state variables, use `x = x + y` rather than `x += y`

Summary

For state variable arithmetic assignments, using syntax like x = x + y rather than x += y and x = x - y rather than x -= y will save 113 gas.

Vulnerability Details

There are 3 instances of this issue.

File: src/Staking.sol
41: balances[msg.sender] += _amount;
48: balances[msg.sender] -= _amount;
89: claimable[recipient] += _share;
File Link Instance Count Instance Links
Staking.sol 3 41,48,89

Impact

339 gas

Tools Used

baudit: a custom static code analysis tool; manual review

Recommendations

For state variables, use x = x + y rather than x += y.

Support

FAQs

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