Platform: Code4rena
Start Date: 14/04/2022
Pot Size: $75,000 USDC
Total HM: 8
Participants: 72
Period: 7 days
Judge: Jack the Pug
Total Solo HM: 2
Id: 110
League: ETH
Rank: 67/72
Findings: 1
Award: $54.33
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Dravee
Also found by: 0v3rf10w, 0x1f8b, 0xAsm0d3us, 0xBug, 0xDjango, 0xNazgul, 0xkatana, CertoraInc, Cityscape, Funen, Hawkeye, IllIllI, MaratCerby, SolidityScan, TerrierLover, TomFrenchBlockchain, Tomio, TrungOre, bae11, berndartmueller, csanuragjain, defsec, delfin454000, ellahi, fatherOfBlocks, gs8nrv, gzeon, horsefacts, ilan, jah, joestakey, joshie, kebabsec, kenta, nahnah, oyc_109, rayn, rfa, robee, saian, securerodd, simon135, slywaters, sorrynotsorry, tchkvsky, teryanarmen, z3s
54.333 USDC - $54.33
!= 0
instead of > 0
for unsigned integer comparisonContext: Funding.sol#L170, Funding.sol#L209, Funding.sol#L322, Funding.sol#L340 (Same goes for other contracts in /src/*
)
Description: When dealing with unsigned integer types, comparisons with != 0
are cheaper then with > 0
.
Recommendation:
Change the code in the following way:
- require(_assetAmountIn > 0, "_assetAmountIn must not be 0"); + require(_assetAmountIn != 0, "_assetAmountIn must not be 0");
https://github.com/code-423n4/2022-04-badger-citadel/blob/main/src/CitadelMinter.sol#L266
Context: CitadelMinter.sol#L266
Description: Using nested is cheaper than using &&
multiple check combinations. There are more advantages, such as easier to read code and better coverage reports.
Recommendation: Use nested If statement.
++i
is cheaper than i++;
Context: CitadelMinter.sol#L152
Description: i++
is costlier than ++i
, it is better to replace it with ++i
Recommendation:
- for (uint256 i = 0; i < numPools; i++) + for (uint256 i = 0; i < numPools; ++i)
Context: SupplySchedule.sol#L103, SupplySchedule.sol#L192, Description: If the variable is not set/initialized, it is assumed to have a default value (0, false, 0x0, etc., depending on the data type). If you explicitly initialize it with its default value, you are just wasting gas. Recommendation: Change the code in the following way:
- uint256 mintable = 0; + uint256 mintable;