Open code423n4 opened 2 years ago
C4-001: Revert String Size Optimization
It already fits in 32 bytes.
C4-002 : Non-strict inequalities are cheaper than strict ones
Irrelevant, the amount shouldn't be equal to 0.
C4-003 : Check if amount > 0 before token transfer can save gas
If shares are greater than 0, it means that the deposit amount will also be greater than 0.
C4-004: > 0 can be replaced with != 0 for gas optimization
Duplicate of https://github.com/code-423n4/2022-04-pooltogether-findings/issues/11
C4-001: Revert String Size Optimization
Impact
Shortening revert strings to fit in 32 bytes will decrease deploy time gas and will decrease runtime gas when the revert condition has been met.
Revert strings that are longer than 32 bytes require at least one additional mstore, along with additional overhead for computing memory offset, etc.
Proof of Concept
Revert strings > 32 bytes are here:
Tools Used
Manual Review
Recommended Mitigation Steps
Shorten the revert strings to fit in 32 bytes. That will affect gas optimization.
C4-002 : Non-strict inequalities are cheaper than strict ones
Impact
Strict inequalities add a check of non equality which costs around 3 gas.
Proof of Concept
Tools Used
Code Review
Recommended Mitigation Steps
Use >= or <= instead of > and < when possible.
C4-003 : Check if amount > 0 before token transfer can save gas
Impact
Since _amount can be 0. Checking if (_amount != 0) before the transfer can potentially save an external call and the unnecessary gas cost of a 0 token transfer.
Proof of Concept
All Contracts
Tools Used
None
Recommended Mitigation Steps
Consider checking amount != 0.
C4-004:
> 0 can be replaced with != 0 for gas optimization
Impact
!= 0
is a cheaper operation compared to> 0
, when dealing with uint.Proof of Concept
Tools Used
Code Review
Recommended Mitigation Steps
Use "!=0" instead of ">0" for the gas optimization.