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

2 stars 0 forks source link

"> 0" is less efficient than "!= 0" for unsigned integers #140

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

ye0lde

Vulnerability details

Impact

Gas savings

Proof of Concept

"> 0" is used in the following locations: https://github.com/code-423n4/2022-01-timeswap/blob/bf50d2a8bb93a5571f35f96bd74af54d9c92a210/Timeswap/Timeswap-V1-Convenience/contracts/libraries/SquareRoot.sol#L21 https://github.com/code-423n4/2022-01-timeswap/blob/bf50d2a8bb93a5571f35f96bd74af54d9c92a210/Timeswap/Timeswap-V1-Convenience/contracts/libraries/PayMath.sol#L27

Tools Used

Visual Studio Code, Remix

Recommended Mitigation Steps

Change "> 0" to "!=0" for small gas savings.

amateur-dev commented 2 years ago

Similar issue reported over here #172; hence closing this.