Platform: Code4rena
Start Date: 21/04/2022
Pot Size: $75,000 USDC
Total HM: 7
Participants: 45
Period: 7 days
Judge: 0xean
Total Solo HM: 5
Id: 111
League: ETH
Rank: 34/45
Findings: 1
Award: $81.64
š Selected for report: 0
š Solo Findings: 0
š Selected for report: 0xkatana
Also found by: 0v3rf10w, 0x1f8b, 0xNazgul, 0xmint, CertoraInc, Dravee, Fitraldys, Funen, IllIllI, NoamYakov, Scocco, Tomio, catchup, csanuragjain, defsec, delfin454000, djxploit, fatima_naz, gzeon, joestakey, joshie, kebabsec, nahnah, oyc_109, rayn, robee, rotcivegaf, saian, samruna, sorrynotsorry, teryanarmen, z3s
81.6446 USDC - $81.64
In If conditionals, prefer to use !=0
than > 0
when possible to save Gas
167ā if (oldRewardBalance > 0) { 168ā rewardToken.safeTransferFrom(address(flywheelRewards), address(newFlywheelRewards), oldRewardBalance); 169ā }
218ā if (strategyRewardsAccrued > 0) {
467ā if (weight > 0) { ā®ā---------------------------------------- 487ā if (weight > 0) {
287ā if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) {
Static code analysis
Replace the > 0
to != 0
167ā if (oldRewardBalance != 0) {
218ā if (strategyRewardsAccrued != 0) {
467ā if (weight != 0) { ā®ā---------------------------------------- 487ā if (weight != 0) {
287ā if (pos != 0 && ckpts[pos - 1].fromBlock == block.number) {
There is no risk of overflow caused by increasing the iteration index in for loops (the ++i
in for (uint256 i = 0; i < numIterations; ++i)
), but increments perform overflow checks that are not needed in this case.
So, to save gas, prefer ++i
to i++
in loops.
189ā for (uint256 i = 0; i < size; i++) {
346ā for (uint256 i = 0; i < size && (userFreeVotes + totalFreed) < votes; i++) {
Static code analysis
To save gas, prefer ++i
to i++
in loops.
189ā for (uint256 i = 0; i < size; ++i) {
346ā for (uint256 i = 0; i < size && (userFreeVotes + totalFreed) < votes; ++i) {