Open code423n4 opened 2 years ago
Dravee
SLOADs are expensive
Here, _fee[_target] can be loaded twice from storage:
_fee[_target]
271: function getFeeRate(address _target) 272: external 273: view 274: override 275: returns (uint256) 276: { 277: if (_fee[_target] == 0) { 278: return _fee[address(0)]; 279: } else { 280: return _fee[_target]; 281: } 282: }
VS Code
Cache the storage reading in a memory variable
I've confirmed that this implementation
most of the cases, this tends to return the default value, so we want to keep the current implementation
we confirm this issue to reduce gas cost in the future
https://github.com/InsureDAO/pool-contracts/pull/49
Handle
Dravee
Vulnerability details
Impact
SLOADs are expensive
Proof of Concept
Here,
_fee[_target]
can be loaded twice from storage:Tools Used
VS Code
Recommended Mitigation Steps
Cache the storage reading in a memory variable