Platform: Code4rena
Start Date: 20/09/2022
Pot Size: $100,000 USDC
Total HM: 4
Participants: 109
Period: 7 days
Judge: GalloDaSballo
Id: 163
League: ETH
Rank: 48/109
Findings: 2
Award: $123.86
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0x4non, 0x52, 0x5rings, 0xNazgul, 0xRobocop, 0xSmartContract, 0xdeadbeef, 0xsanson, 8olidity, Amithuddar, Aymen0909, B2, B353N, CertoraInc, Ch_301, Chom, CodingNameKiki, Deivitto, ElKu, Funen, JC, JohnnyTime, Kresh, Lambda, Noah3o6, RaymondFam, ReyAdmirado, RockingMiles, Rolezn, Sm4rty, SuldaanBeegsi, Tadashi, TomJ, Tomio, V_B, Waze, __141345__, a12jmx, ak1, arcoun, asutorufos, aviggiano, berndartmueller, bharg4v, bin2chen, brgltd, bulej93, c3phas, catchup, cccz, ch0bu, cryptonue, cryptphi, csanuragjain, delfin454000, devtooligan, djxploit, durianSausage, eighty, erictee, exd0tpy, fatherOfBlocks, giovannidisiena, hansfriese, ignacio, joestakey, ladboy233, lukris02, m9800, malinariy, martin, minhtrng, obront, oyc_109, pedr02b2, pedroais, pfapostol, philogy, prasantgupta52, rbserver, ronnyx2017, rotcivegaf, rvierdiiev, sach1r0, shung, simon135, throttle, tnevler, tonisives, wagmi, yixxas, zkhorse, zzykxx, zzzitron
55.1985 USDC - $55.20
Summary: << 1
can be replaced by *2
without losing gas and increasing readability.
Details: L844 of ArtGobblers.sol contains a left shift which is equivalent to multiplication by 2. While representing a multiplication by a power of 2 by left shifts can save gas, this do not occur here. Hence, consider changing the left shift by an explicit multiplication by 2.
Impact: Code QA
Suggestion: Consider changing the left shift by a multiplication by 2.
#0 - GalloDaSballo
2022-10-06T00:33:34Z
1R
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0xNazgul, 0xSmartContract, Atarpara, CertoraInc, Deathstore, Deivitto, ElKu, MiloTruck, ReyAdmirado, SnowMan, Tadashi, V_B, __141345__, aviggiano, catchup, djxploit, gogo, pfapostol, philogy, shung
68.6605 USDC - $68.66
Summary: Pre-computing the square root of 1e18 in computeGOOBalance
saves gas.
Details: Perform this change in L38 of LibGoo.sol:
-(emissionMultiple * lastBalanceWad * 1e18).sqrt() +(emissionMultiple * lastBalanceWad).sqrt() * 1e9
⛽ Profiling: Computed using forge snapshot --diff
:
testCanMintPageFromVirtualBalance() (gas: -24 (-0.008%)) testGooAddition() (gas: -20 (-0.008%)) testGooRemoval() (gas: -24 (-0.009%)) testMintFromGooBalance() (gas: -24 (-0.009%)) testSnapshotDoesNotAffectBalance() (gas: -96 (-0.024%)) Overall gas change: -188 (-0.059%)
Notes: - The comments in the previous lines should be rewritten if this change is made - The resolution of the operation will decrease if this change is made
Summary: part of tokenURI
can be made unchecked
Details: Since there will be only 10 legendary Globbers, L707-L709 of ArtGobblers.sol can be changed to
unchecked { if (gobblerId < FIRST_LEGENDARY_GOBBLER_ID + legendaryGobblerAuctionData.numSold) return string.concat(BASE_URI, gobblerId.toString()); }
⛽ Profiling: Computed using forge snapshot --diff
:
testMintedLegendaryURI() (gas: -161 (-0.000%)) testUnmintedLegendaryUri() (gas: -402 (-1.588%)) Overall gas change: -563 (-1.589%)
Summary: Pre-incrementing a variable is cheaper than post-incrementing it. For more information, see G012 of c4-common-issues.
Details: Consider the following changes:
L37 of ArtGobblers.sol
-for (uint256 i = 0; i < ids.length; i++) { +for (uint256 i = 0; i < ids.length; ++i) {
L251 of Pages.sol
-for (uint256 i = 0; i < numPages; i++) _mint(community, ++lastMintedPageId); +for (uint256 i = 0; i < numPages; ++i) _mint(community, ++lastMintedPageId);
⛽ Profiling: Computed using forge snapshot --diff
:
testCanWithdraw() (gas: -6 (-0.001%)) testFeedingArt() (gas: -224 (-0.087%)) testPagePricingPricingBeforeSwitch() (gas: -820505 (-0.365%)) testPagePricingPricingAfterSwitch() (gas: -2685499 (-0.743%)) testCantMintTooFastCommunityOneByOne() (gas: -57520 (-0.970%)) testCantMintTooFastCommunity() (gas: -21566 (-1.835%)) testCanMintMultipleCommunity() (gas: -39536 (-3.196%)) testCanMintCommunity() (gas: -37288 (-5.721%)) testCanMintPageFromVirtualBalance() (gas: -22181 (-7.406%)) testCantFeed721As1155() (gas: -17745 (-7.541%)) testMintPage() (gas: -5081 (-8.639%)) testMintPageUsingVirtualBalance() (gas: -5081 (-8.782%)) testCantgobbleToUnownedGobbler() (gas: -17745 (-15.405%)) testRegularMint() (gas: -17745 (-16.310%)) testMintCommunityPages() (gas: -22181 (-37.596%)) Overall gas change: -3769903 (-114.598%)
#0 - GalloDaSballo
2022-10-05T00:24:33Z
Can't argue with Benchmarks
751 from first 2 findings will give 25 for the 3rd 776