Closed code423n4 closed 2 years ago
ye0lde
A struct is being assigned its default value which is unnecessary. Removing the assignment will save gas when deploying.
struct
https://github.com/code-423n4/2022-01-elasticswap/blob/d107a198c0d10fbe254d69ffe5be3e40894ff078/elasticswap/src/contracts/Exchange.sol#L27-L28
Visual Studio Code, Remix
Remove the assignment.
Or if you feel it is important to show the default assignment will occur then replace the assignments with a comment.
I suggest the following:
Change this:
MathLib.InternalBalances public internalBalances = MathLib.InternalBalances(0, 0, 0);
to something like:
MathLib.InternalBalances public internalBalances; // Tracking x*y=k with x=0, y=0, k=0 initially
dupe of #158
Handle
ye0lde
Vulnerability details
Impact
A
struct
is being assigned its default value which is unnecessary. Removing the assignment will save gas when deploying.Proof of Concept
https://github.com/code-423n4/2022-01-elasticswap/blob/d107a198c0d10fbe254d69ffe5be3e40894ff078/elasticswap/src/contracts/Exchange.sol#L27-L28
Tools Used
Visual Studio Code, Remix
Recommended Mitigation Steps
Remove the assignment.
Or if you feel it is important to show the default assignment will occur then replace the assignments with a comment.
I suggest the following:
Change this:
to something like: