code-423n4 / 2022-04-pooltogether-findings

0 stars 0 forks source link

Gas Optimizations #20

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Gas Report

Replace strict greater-than-zero operation (> 0) with does-not-equal-zero (!= 0) operation

When checking whether a value is equal to zero, using the construction var != 0 is costs less gas than using var > 0. Note that this is true only when the comparison occurs in a conditional context and the Solidity compiler is using the Optimizer.

For more information, please consult the following resources:

Twitter discussion detailing the gas costs of != 0 vs > 0 in require() calls

Solidity Compiler: Optimizer options

The following lines of code are affected:

code4rena/pooltogether/AaveV3YieldSource.sol:179:    require(decimals_ > 0, "AaveV3YS/decimals-gt-zero");
code4rena/pooltogether/AaveV3YieldSource.sol:233:    require(_shares > 0, "AaveV3YS/shares-gt-zero");
PierrickGT commented 2 years ago

Duplicate of https://github.com/code-423n4/2022-04-pooltogether-findings/issues/11