Platform: Code4rena
Start Date: 14/09/2022
Pot Size: $50,000 USDC
Total HM: 25
Participants: 110
Period: 5 days
Judge: hickuphh3
Total Solo HM: 9
Id: 162
League: ETH
Rank: 100/110
Findings: 1
Award: $16.18
๐ Selected for report: 0
๐ Solo Findings: 0
๐ Selected for report: pfapostol
Also found by: 0x040, 0x1f8b, 0x4non, 0xNazgul, 0xSmartContract, 0xc0ffEE, 0xkatana, Aymen0909, Bnke0x0, Deivitto, Diana, JAGADESH, KIntern_NA, Lambda, MiloTruck, R2, RaymondFam, Respx, ReyAdmirado, Rohan16, RoiEvenHaim, Rolezn, Ruhum, Saintcode_, Samatak, Sm4rty, SnowMan, Tomio, Tomo, WilliamAmbrozic, _Adam, __141345__, ajtra, ak1, async, c3phas, ch0bu, cryptostellar5, d3e4, delfin454000, dharma09, djxploit, durianSausage, eierina, erictee, fatherOfBlocks, gianganhnguyen, gogo, ignacio, imare, jag, jonatascm, leosathya, lukris02, malinariy, oyc_109, pashov, pauliax, peanuts, peiw, prasantgupta52, robee, rokinot, rotcivegaf, rvierdiiev, seyni, simon135, slowmoses, sryysryy, tnevler, zishansami
16.1756 USDC - $16.18
Context:
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/VaultFactory.sol#L195
Recommendation:
Change X += Y (X -= Y) to X = X + Y (X = X - Y).
Context:
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Vault.sol#L443
Description:
Default value of uint is 0. It's unnecessary and costs more gas to initialize uint variavles to 0.
Recommendation:
Change uint256 i = 0; to uint256 i;
Context:
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/rewards/StakingRewards.sol#L119 uint256
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/rewards/StakingRewards.sol#L134 uint256
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Vault.sol#L187
Description:
uint type and msg.value are always non-negative.
Recommendation:
Change >0 to !=0.
Context:
for (uint256 i = 0; i < epochsLength(); i++) {
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Vault.sol#L443
Description:
If you call function and read the length of the array at each iteration of the loop, this consumes a lot of gas.
Recommendation:
Store the arrayโs length in a variable before the for-loop, and use this new variable in the loop.
Context:
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Vault.sol#L443
Recommendation:
Change i++ to ++i.
Context:
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/rewards/RewardsFactory.sol#L9
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/rewards/RewardsFactory.sol#L10
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/rewards/RewardsFactory.sol#L11
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/rewards/StakingRewards.sol#L41
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/SemiFungibleVault.sol#L21
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/oracles/PegOracle.sol#L10
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/oracles/PegOracle.sol#L11
https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/oracles/PegOracle.sol#L13
Description:
Variable is set in the constructor and never modified after that.
Recommendation:
It is more gas efficient to mark it as immutable.