Platform: Code4rena
Start Date: 20/05/2022
Pot Size: $1,000,000 USDC
Total HM: 4
Participants: 59
Period: 14 days
Judge: leastwood
Id: 128
League: ETH
Rank: 59/59
Findings: 1
Award: $434.35
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Dravee
Also found by: 0x1f8b, 0x29A, 0xalpharush, Chom, Czar102, Hawkeye, IllIllI, MaratCerby, MiloTruck, NoamYakov, OriDabush, RoiEvenHaim, Spearbit, Tadashi, TerrierLover, TomJ, asutorufos, cccz, cmichel, csanuragjain, defsec, delfin454000, djxploit, ellahi, foobar, gzeon, hake, hickuphh3, ignacio, ilan, joestakey, kaden, mayo, ming, oyc_109, peritoflores, rfa, sach1r0, sashik_eth, shung, sirhashalot, twojoy, zer0dot, zkhorse
434.3522 USDC - $434.35
Issue: Variables should not be initialized to their default values
Explanation: Initializing uint
variables to their default value of zero is unnecessary and costs gas
extraCeiling
is initialized to zero in both lines below:
uint256 extraCeiling = 0;
Change to uint256 extraCeiling;
in both cases
i
(or j
) is initialized to zero in all 37 lines below:
Example:
for (uint256 i = 0; i < totalStandardTransfers; ) {
Change uint256 i = 0;
to uint256 i;
totalFilteredExecutions
is initialized to zero in all four lines below:
uint256 totalFilteredExecutions = 0;
Change to uint256 totalFilteredExecutions;
uint256 recipientCount = 0;
Change to 'uint256 recipientCount;'
uint256 nextComponentIndex = 0;
Change to uint256 nextComponentIndex;
Issue: Use ++i
instead of i++
in for
loops and do not initialize i
to zero
Explanation: Using i++
is more costly than ++i
. Initialization of uint
variables to their default value of zero is unnecessary and also costs gas
for (uint256 i = 0; i < totalStandardTransfers; i++) {
Recommendation:
for (uint256 i; i < totalStandardTransfers; ++i) {
Similarly for the three for
loops referenced below:
Issue: Array length should not be looked up in every iteration of a for
loop
Explanation: Calculating the array length costs gas
Recommendation: Read the length of the array from memory before executing the loop. In addition, do not initialize i
(or j
) to zero (its default value)
for (uint256 j = 0; j < offer.length; ++j) {
Recommendation:
uint256 totalOfferLength = offer.length; for (uint256 j; j < totalOfferLength; ++j) {
Similarly for the 14 for
loops referenced below: