code-423n4 / 2022-01-elasticswap-findings

1 stars 0 forks source link

Initialize to default state is redundant #158

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

WatchPug

Vulnerability details

https://github.com/code-423n4/2022-01-elasticswap/blob/d107a198c0d10fbe254d69ffe5be3e40894ff078/elasticswap/src/contracts/Exchange.sol#L27-L28

MathLib.InternalBalances public internalBalances =
    MathLib.InternalBalances(0, 0, 0);

Initialize internalBalances to the default state is redundant.

Change to MathLib.InternalBalances public internalBalances; can make the code simpler and save some gas.

GalloDaSballo commented 2 years ago

Agree with the finding, for the sake of visibility the sponsor may decide to keep the assignment as a comment, but this is effectually paying for assigning the same value to a storage slot (should be 3 due to int types) which should cost 800 per assignment (2.4k gas in total)