Closed code423n4 closed 2 years ago
pants
These lines in Swap.sweepFees() perfom SLOADs operations for the same feeRecipient value:
Swap.sweepFees()
SLOAD
feeRecipient
require( feeRecipient != address(0), "Swap::withdrawAccruedFees: feeRecipient is not initialized" ); IERC20(tokens[i]).safeTransfer(feeRecipient, balance); emit FeesSwept(tokens[i], balance, feeRecipient); feeRecipient.transfer(address(this).balance); emit FeesSwept(address(0), address(this).balance, feeRecipient);
Storage reads are much more expensive than reading local variables.
Manual code review.
Load feeRecipient from storage once, cache it in a local variable and them use this local variable instead of loading this value from storage again.
Duplicate of #18.
Handle
pants
Vulnerability details
These lines in
Swap.sweepFees()
perfomSLOAD
s operations for the samefeeRecipient
value:Impact
Storage reads are much more expensive than reading local variables.
Tool Used
Manual code review.
Recommended Mitigation Steps
Load
feeRecipient
from storage once, cache it in a local variable and them use this local variable instead of loading this value from storage again.