Closed code423n4 closed 2 years ago
Duplicate to #137
This warden has made a large number of submissions pointing to basically the same area in different parts of the code. Because of how similar issues are, I don't think its fair to other wardens to have these treated as separate. While I understand gas reports should fix this, I've decided for this contest I'll mark similar duplicates as invalid
.
Handle
Dravee
Vulnerability details
Impact
SLOADs are expensive (~100 gas) compared to MLOADs/MSTOREs (~3 gas). Minimizing them can save gas.
Proof of Concept
The code is as such:
Here, these variables are read multiple times from storage:
wETH, baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink, admin, lpoolImplementation
By caching these in memory variable and using the newly created memory variables, it's possible to save 7 SLOADs (~700 gas)
Tools Used
VS Code
Recommended Mitigation Steps
Cache the storage values in a memory variable and use them instead of repeatedly reading them from storage.