Platform: Code4rena
Start Date: 21/06/2022
Pot Size: $50,000 USDC
Total HM: 31
Participants: 99
Period: 5 days
Judges: moose-code, JasoonS, denhampreen
Total Solo HM: 17
Id: 139
League: ETH
Rank: 94/99
Findings: 1
Award: $26.57
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: BowTiedWardens
Also found by: 0v3rf10w, 0x1f8b, 0x29A, 0xKitsune, 0xNazgul, 0xf15ers, 0xkatana, 0xmint, 8olidity, ACai, Bnke0x0, Chom, ElKu, Fabble, Fitraldys, FudgyDRS, Funen, GalloDaSballo, GimelSec, IllIllI, JC, Kaiziron, Lambda, Limbooo, MiloTruck, Noah3o6, Nyamcil, Picodes, PwnedNoMore, Randyyy, RedOneN, Sm4rty, StErMi, TomJ, Tomio, TrungOre, UnusualTurtle, Waze, _Adam, aga7hokakological, ajtra, antonttc, asutorufos, bardamu, c3phas, defsec, delfin454000, exd0tpy, fatherOfBlocks, hansfriese, ignacio, joestakey, kenta, ladboy233, m_Rassska, mics, minhquanym, oyc_109, pashov, reassor, robee, s3cunda, sach1r0, saian, sashik_eth, scaraven, sikorico, simon135, slywaters
26.5706 USDC - $26.57
Using ++i
costs less gas than using i++
. In the context of a for-loop, gas is saved on each iteration.
The following line of code is affected:
2022-06-yieldy/src/contracts/Staking.sol:708: epoch.number++;
When compiled, Solidity code using the >=
or <=
comparison operators in fact executes two separate checks: one for 'is-equal-to' and a second for 'is-greater-than/is-less-than'. By contrast, using >
or <
performs only one check. Therefore code that is written to use strict comparison operators is more gas-efficient.
If this change is applied, be sure to update the relevant variables being evaluated. For clarity, it is also advised to rename the variables to make this change explicit, e.g. renaming a variable from MINIMUM
to MINIMUM_PLUS_ONE
.
The following lines are affected:
2022-06-yieldy/src/contracts/LiquidityReserve.sol:163: require(_amount <= balanceOf(msg.sender), "Not enough lr tokens"); 2022-06-yieldy/src/contracts/LiquidityReserve.sol:171: IERC20Upgradeable(stakingToken).balanceOf(address(this)) >= 2022-06-yieldy/src/contracts/LiquidityReserve.sol:69: stakingTokenBalance >= MINIMUM_LIQUIDITY, 2022-06-yieldy/src/contracts/LiquidityReserve.sol:94: require(_fee <= BASIS_POINTS, "Out of range"); 2022-06-yieldy/src/contracts/Staking.sol:265: return epoch.number >= info.expiry && info.expiry != 0; 2022-06-yieldy/src/contracts/Staking.sol:285: epoch.number >= info.expiry && 2022-06-yieldy/src/contracts/Staking.sol:288: ((requestedWithdrawals.minCycle <= currentCycleIndex && 2022-06-yieldy/src/contracts/Staking.sol:289: requestedWithdrawals.amount + withdrawalAmount >= 2022-06-yieldy/src/contracts/Staking.sol:290: info.amount) || withdrawalAmount >= info.amount); 2022-06-yieldy/src/contracts/Staking.sol:306: requestedWithdrawals.minCycle <= currentCycleIndex 2022-06-yieldy/src/contracts/Staking.sol:361: block.timestamp + timeLeftToRequestWithdrawal >= nextCycleStart && 2022-06-yieldy/src/contracts/Staking.sol:528: _amount <= walletBalance + warmUpBalance, 2022-06-yieldy/src/contracts/Staking.sol:535: if (_amount >= warmUpBalance) { 2022-06-yieldy/src/contracts/Staking.sol:586: require(reserveBalance >= _amount, "Not enough funds in reserve"); 2022-06-yieldy/src/contracts/Staking.sol:703: if (epoch.endTime <= block.timestamp) { 2022-06-yieldy/src/contracts/Staking.sol:713: if (balance <= staked) { 2022-06-yieldy/src/contracts/Yieldy.sol:190: require(creditAmount <= creditBalances[msg.sender], "Not enough funds"); 2022-06-yieldy/src/contracts/Yieldy.sol:210: require(_allowances[_from][msg.sender] >= _value, "Allowance too low"); 2022-06-yieldy/src/contracts/Yieldy.sol:286: require(currentCredits >= creditAmount, "Not enough balance");