Closed code423n4 closed 2 years ago
Dravee
SLOADs are expensive
Here, totalSupply() is loaded twice from storage:
totalSupply()
512: function rate() external view returns (uint256) { 513: if (totalSupply() > 0) { 514: return (totalLiquidity() * MAGIC_SCALE_1E6) / totalSupply(); 515: } else { 516: return 0; 517: } 518: }
VS Code
Cache totalSupply() in a variable
dupe of #301
warden is asked to submit the same optimization(s) in the same ticket.
Handle
Dravee
Vulnerability details
Impact
SLOADs are expensive
Proof of Concept
Here,
totalSupply()
is loaded twice from storage:Tools Used
VS Code
Recommended Mitigation Steps
Cache
totalSupply()
in a variable