Open hats-bug-reporter[bot] opened 1 week ago
Thank you for your report on the unnecessary else-block. While this doesn't qualify as a security issue per our competition guidelines, we appreciate your attention to code optimization.
You've identified a valid gas optimization in a high-frequency code path. We'll discuss with the competition organizers and internally about how to address such valuable optimization suggestions.
We appreciate your careful examination of our code for efficiency opportunities. Thank you for your diligence and commitment to code quality.
Github username: -- Twitter username: -- Submission hash (on-chain): 0x629c958c70e31f1d657cd004841d47d952d5365345756c1559ac94514dffe875 Severity: low
Description:
Description
Inside
Demurrage.sol
, there are two functions for calculating the demurrage factor:Note that in the first function, the
else-block
is omitted. This saves gas.However, in the second function,
_calculateDemurrageFactorAndCache()
, theelse-block
is still in there. This can easily be modified such that it just returns if the firstif-statement
turns out to befalse
. Removing theelse- block
will save a fewOPCODES
from being executed every time_calculateDemurrageFactor
is called, and since these two functions are called extensively, optimizing these functions is favored.Recommendation