code-423n4 / 2021-10-tally-findings

0 stars 0 forks source link

Unnecessary `SLOAD`s in `Swap`'s constructor #58

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

pants

Vulnerability details

These lines in Swap's constructor perfom two SLOADs operations for values that are already stored in local variables:

emit NewFeeRecipient(feeRecipient);
emit NewSwapFee(swapFee);

Impact

Storage reads are much more expensive than reading local variables.

Tool Used

Manual code review.

Recommended Mitigation Steps

Use the already existing local variables instead of loading these values from storage:

emit NewFeeRecipient(feeRecipient_);
emit NewSwapFee(swapFee_);
0xean commented 2 years ago

dupe of #19