code-423n4 / 2022-06-canto-findings

0 stars 0 forks source link

QA Report #146

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Variables: No need to explicitly initialize variables with default values

If a variable is not set/initialized, it is assumed to have the default value (0 for uint, false for bool, address(0) for address…). Explicitly initializing it with its default value is an anti-pattern and wastes gas.

We can use uint number; instead of uint number = 0;

Instance Includes:

zeroswap/contracts/SushiToken.sol:168:        uint32 lower = 0;
zeroswap/contracts/bentobox/KashiPairMediumRiskV1.sol:439:            uint8 i = 0;
zeroswap/contracts/bentobox/KashiPairMediumRiskV1.sol:902:        uint256 extraAmount = 0;
zeroswap/contracts/bentobox/KashiPairMediumRiskV1.sol:903:        uint256 feeFraction = 0;
zeroswap/contracts/MasterChef.sol:75:    uint256 public totalAllocPoint = 0;
lending-market/contracts/Governance/Comp.sol:207:        uint32 lower = 0;
lending-market/contracts/ErrorReporter.sol:75:    uint public constant NO_ERROR = 0; // support legacy return codes
lending-market/contracts/Lens/CompoundLens.sol:72:        uint compSupplySpeed = 0;
lending-market/contracts/Lens/CompoundLens.sol:84:        uint compBorrowSpeed = 0;
lending-market/contracts/Lens/CompoundLens.sol:130:        uint borrowCap = 0;
lending-market/contracts/ERC20.sol:11:    uint256 private _totalSupply = 0;
lending-market/contracts/CToken.sol:81:        uint startingAllowance = 0;
stableswap/contracts/BaseV1-periphery.sol:158:        uint _totalSupply = 0;
stableswap/contracts/BaseV1-core.sol:46:    uint public totalSupply = 0;
stableswap/contracts/BaseV1-core.sol:223:        uint nextIndex = 0;
stableswap/contracts/BaseV1-core.sol:224:        uint index = 0;
stableswap/contracts/test/calculations.sol:25:        uint256 x = 0;
stableswap/contracts/test/calculations.sol:136:        uint c1 = 0;
stableswap/contracts/test/calculations.sol:137:        uint b1 = 0;
stableswap/contracts/test/calculations.sol:138:        uint b2 = 0;
stableswap/contracts/test/Token.sol:9:    uint256 public totalSupply = 0;

Recommendation:

I suggest removing explicit initializations for default values.

JeeberC4 commented 2 years ago

Warden submitted multiple QA Reports. Will not be judged.