code-423n4 / 2021-12-sublime-findings

0 stars 0 forks source link

Don't assign default values #158

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

0x0x0x

Vulnerability details

Concept

When a variable is declared solidity assigns the default value. In case the contract assigns the value again, it costs extra gas.

Example:uint x = 0 costs more gas than uint x without having any different functionality.

Scope


./CreditLine/CreditLine.sol:812:        uint256 _principalPaid = 0;
./Pool/Pool.sol:358:        uint256 _collateralShares = 0;
./mocks/yVault/yVault.sol:281:        uint256 shares = 0;
./mocks/yVault/yVault.sol:297:        uint256 shares = 0;
ritik99 commented 2 years ago

Duplicate of #36 since both issues deal with unnecessary initializations. Hence, the issue is the same even if the instances mentioned in both places are different. Two of the instances in mocks were not part of the audit scope as mentioned in the contest readme