code-423n4 / 2021-09-wildcredit-findings

0 stars 0 forks source link

Converting state variables to immutable will save storage slots and gas #92

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

0xRajeev

Vulnerability details

Impact

All five address-type state variables in PairFactory can be made immutable (because they are only ever initialized in the constructor) to save storage slots and gas because SLOADs are not needed anymore for their reads as their usages are replaced at construction time by their fixed values.

Proof of Concept

https://github.com/code-423n4/2021-09-wildcredit/blob/c48235289a25b2134bb16530185483e8c85507f8/contracts/PairFactory.sol#L22-L26

https://github.com/code-423n4/2021-09-wildcredit/blob/c48235289a25b2134bb16530185483e8c85507f8/contracts/PairFactory.sol#L32-L44

Tools Used

Manual Analysis

Recommended Mitigation Steps

Convert the five state variables to immutable

talegift commented 2 years ago

Duplicate of #1