Closed code423n4 closed 2 years ago
Dravee
SLOADs are expensive
Here, totalSupply() is loaded twice from storage:
totalSupply()
File: PoolTemplate.sol 744: function rate() external view returns (uint256) { 745: if (totalSupply() > 0) { 746: return (originalLiquidity() * MAGIC_SCALE_1E6) / totalSupply(); 747: } else { 748: return 0; 749: } 750: }
VS Code
Cache totalSupply() in a variable
dupe of #343 - warden is asked to group similar optimizations (cacheing) in the same findings.
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