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

Use `!= 0` instead of `> 0` for Unsigned Integer Comparison.

Summary

Changing > 0 to !=0 to save gas.

Vulnerability Details

Issue Information: G003

Impact

Changing > 0 to !=0 will save you about 10 gas each time.

Tools Used

Manual review

Recommendations

src/Staking.sol::63 => if (totalSupply > 0) {
src/Staking.sol::67 => if (_diff > 0) {
src/Staking.sol::69 => if (_ratio > 0) {
src/Staking.sol::83 => if (_supplied > 0) {
src/Staking.sol::87 => if (_delta > 0) {

should be

src/Staking.sol::63 => if (totalSupply != 0) {
src/Staking.sol::67 => if (_diff != 0) {
src/Staking.sol::69 => if (_ratio != 0) {
src/Staking.sol::83 => if (_supplied != 0) {
src/Staking.sol::87 => if (_delta != 0) {
'''

Support

FAQs

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

Give us feedback!