Open code423n4 opened 2 years ago
Examples of this issue in the codebase:
File: contracts\contracts\core\connext\libraries\SwapUtils.sol (Line 205)
File: contracts\contracts\core\connext\helpers\StableSwap.sol (Line 81)
File: contracts\contracts\core\connext\facets\BridgeFacet.sol (Line 796)
File: contracts\contracts\core\connext\facets\BridgeFacet.sol (Line 1003)
Example of this issue in the codebase:
File: contracts\contracts\core\connext\helpers\ConnextPriceOracle.sol (Line 176)
File: contracts\contracts\core\connext\helpers\Multicall.sol (Line 16)
File: contracts\contracts\core\connext\helpers\ConnextPriceOracle.sol (Line 150)
File: contracts\contracts\core\connext\libraries\AmplificationUtils.sol (Line 86)
File: contracts\contracts\core\connext\libraries\SwapUtils.sol (Line 397)
File: contracts\contracts\core\connext\libraries\SwapUtils.sol (Line 493)
File: contracts\contracts\core\connext\libraries\SwapUtils.sol (Line 289)
File: contracts\contracts\core\connext\libraries\SwapUtils.sol (Line 300)
SafeMath
File: contracts\contracts\core\connext\helpers\ConnextPriceOracle.sol (Line 4)
File: contracts\core\connext\helpers\OZERC20.sol (Line 10)
See this issue for a detail description of the issue Example of this issue in the codebase:
CallData
File: contracts\contracts\core\connext\libraries\SwapUtils.sol. balances can be changed to calldata (Line 336)
balances
calldata
File: contracts\contracts\core\connext\libraries\SwapUtils.sol. xp can be changed to calldata (Line 286)
xp
REVERT()/REQUIRE()
File: contracts\contracts\core\connext\libraries\LibDiamond.sol (Line 113)
File: contracts\contracts\core\connext\libraries\LibDiamond.sol (Line 121)
string.concat()
abi.encodePacked(<str>,<str>)
1. ++I COSTS LESS GAS THAN ++I, ESPECIALLY WHEN IT’S USED IN FOR-LOOPS (--I/I-- TOO)
Examples of this issue in the codebase:
File: contracts\contracts\core\connext\libraries\SwapUtils.sol (Line 205)
File: contracts\contracts\core\connext\helpers\StableSwap.sol (Line 81)
2. X = X + Y IS CHEAPER THAN X += Y
Examples of this issue in the codebase:
File: contracts\contracts\core\connext\facets\BridgeFacet.sol (Line 796)
File: contracts\contracts\core\connext\facets\BridgeFacet.sol (Line 1003)
3. REQUIRE() OR REVERT() STATEMENTS THAT CHECK INPUT ARGUMENTS SHOULD BE AT THE TOP OF THE FUNCTION
Example of this issue in the codebase:
4. ++I/I++ SHOULD BE UNCHECKED{++I}/UNCHECKED{++I} WHEN IT IS NOT POSSIBLE FOR THEM TO OVERFLOW, AS IS THE CASE WHEN USED IN FOR- AND WHILE-LOOPS
Examples of this issue in the codebase:
File: contracts\contracts\core\connext\helpers\ConnextPriceOracle.sol (Line 176)
File: contracts\contracts\core\connext\helpers\Multicall.sol (Line 16)
5. USING > 0 COSTS MORE GAS THAN != 0 WHEN USED ON A UINT IN A REQUIRE() STATEMENT
Examples of this issue in the codebase:
File: contracts\contracts\core\connext\helpers\ConnextPriceOracle.sol (Line 150)
File: contracts\contracts\core\connext\libraries\AmplificationUtils.sol (Line 86)
6. SPLITTING REQUIRE() STATEMENTS THAT USE && SAVES GAS
Examples of this issue in the codebase:
File: contracts\contracts\core\connext\libraries\AmplificationUtils.sol (Line 86)
File: contracts\contracts\core\connext\libraries\SwapUtils.sol (Line 397)
File: contracts\contracts\core\connext\libraries\SwapUtils.sol (Line 493)
7. IT COSTS MORE GAS TO INITIALIZE VARIABLES TO ZERO THAN TO LET THE DEFAULT OF ZERO BE APPLIED
Examples of this issue in the codebase:
File: contracts\contracts\core\connext\libraries\SwapUtils.sol (Line 289)
File: contracts\contracts\core\connext\libraries\SwapUtils.sol (Line 300)
8.
SafeMath
IS NO LONGER NEEDED STARTING WITH SOLIDITY 0.8Examples of this issue in the codebase:
File: contracts\contracts\core\connext\helpers\ConnextPriceOracle.sol (Line 4)
File: contracts\core\connext\helpers\OZERC20.sol (Line 10)
9. EXPRESSIONS FOR CONSTANT VALUES SUCH AS A CALL TO KECCAK256(), SHOULD USE IMMUTABLE RATHER THAN CONSTANT
See this issue for a detail description of the issue Example of this issue in the codebase:
10. USE
CallData
INSTEAD OF MEMORYExamples of this issue in the codebase:
File: contracts\contracts\core\connext\libraries\SwapUtils.sol.
balances
can be changed tocalldata
(Line 336)File: contracts\contracts\core\connext\libraries\SwapUtils.sol.
xp
can be changed tocalldata
(Line 286)11. USE CUSTOM ERRORS RATHER THAN
REVERT()/REQUIRE()
STRINGS TO SAVE DEPLOYMENT GASExamples of this issue in the codebase:
File: contracts\contracts\core\connext\libraries\LibDiamond.sol (Line 113)
File: contracts\contracts\core\connext\libraries\LibDiamond.sol (Line 121)
12. USE
string.concat()
INSTEAD OFabi.encodePacked(<str>,<str>)
Example of this issue in the codebase:
13. STATE VARIABLES ONLY SET IN THE CONSTRUCTOR SHOULD BE DECLARED IMMUTABLE
Example of this issue in the codebase: