Platform: Code4rena
Start Date: 08/12/2021
Pot Size: $30,000 ETH
Total HM: 12
Participants: 26
Period: 3 days
Judge: leastwood
Total Solo HM: 9
Id: 65
League: ETH
Rank: 20/26
Findings: 1
Award: $11.49
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0x0x0x
Also found by: Jujic, pmerkleplant, ye0lde
pmerkleplant
When dealing with unsigned integer types, comparisons with != 0
are cheaper
then with > 0
.
Therefore, the following comparisons could be refactored:
Factory.sol:53: require(newBondPercentDiv > 0); Basket.sol:68: require(_tokens.length > 0); Basket.sol:77: require(_weights[i] > 0); Basket.sol:93: require(amount > 0); Basket.sol:110: require(amount > 0); Basket.sol:291: require(tokenAmount > 0);
grep
#0 - 0xleastwood
2022-03-27T10:26:50Z
Duplicate of #139
🌟 Selected for report: 0x0x0x
Also found by: Jujic, Meta0xNull, WatchPug, pmerkleplant, rishabh
pmerkleplant
Caching the array length outside of a loop in a variable saves reading it on each iteration, as long as the array's length is not changed during the loop.
Therefore, the following loops could be refactored:
Basket.sol:79: for (uint256 x = 0; x < tokenList.length; x++) Basket.sol:275: for (uint256 i = 0; i < weights.length; i++) Basket.sol:282: for (uint256 i = 0; i < weights.length; i++) Basket.sol:289: for (uint256 i = 0; i < weights.length; i++) Auction.sol:88: for (uint256 i = 0; i < inputTokens.length; i++) Auction.sol:92: for (uint256 i = 0; i < outputTokens.length; i++) Auction.sol:105: for (uint256 i = 0; i < pendingWeights.length; i++) Auction.sol:152: for (uint256 i = 0; i < bountyIds.length; i++) Factory.sol:109: for (uint256 i = 0; i < bProposal.weights.length; i++)
Use the following pattern for refactoring:
uint length = arr.length; for (uint i = 0; i < length; i++) { // ... }
grep
#0 - 0xleastwood
2022-03-27T10:32:06Z
Duplicate of #140