Platform: Code4rena
Start Date: 25/08/2022
Pot Size: $75,000 USDC
Total HM: 35
Participants: 147
Period: 7 days
Judge: 0xean
Total Solo HM: 15
Id: 156
League: ETH
Rank: 79/147
Findings: 2
Award: $86.91
π Selected for report: 0
π Solo Findings: 0
π Selected for report: zzzitron
Also found by: 0x040, 0x1f8b, 0x52, 0x85102, 0xDjango, 0xNazgul, 0xNineDec, 0xSky, 0xSmartContract, 0xkatana, 8olidity, Aymen0909, Bahurum, BipinSah, Bnke0x0, CRYP70, CertoraInc, Ch_301, Chandr, Chom, CodingNameKiki, Deivitto, DimSon, Diraco, ElKu, EthLedger, Funen, GalloDaSballo, Guardian, IllIllI, JansenC, Jeiwan, Lambda, LeoS, Margaret, MasterCookie, PPrieditis, PaludoX0, Picodes, PwnPatrol, RaymondFam, ReyAdmirado, Rohan16, Rolezn, Ruhum, Sm4rty, StevenL, The_GUILD, TomJ, Tomo, Trust, Waze, __141345__, ajtra, ak1, apostle0x01, aviggiano, bin2chen, bobirichman, brgltd, c3phas, cRat1st0s, carlitox477, cccz, ch13fd357r0y3r, cloudjunky, cryptphi, csanuragjain, d3e4, datapunk, delfin454000, devtooligan, dipp, djxploit, durianSausage, eierina, enckrish, erictee, fatherOfBlocks, gogo, grGred, hansfriese, hyh, ignacio, indijanc, itsmeSTYJ, ladboy233, lukris02, martin, medikko, mics, natzuu, ne0n, nxrblsrpr, okkothejawa, oyc_109, p_crypt0, pfapostol, prasantgupta52, rajatbeladiya, rbserver, reassor, ret2basic, robee, rokinot, rvierdiiev, shenwilly, sikorico, sorrynotsorry, tnevler, tonisives, w0Lfrum, yixxas
54.3129 DAI - $54.31
Context:
Description:
Missing check that observationFrequency_ not equal to zero.
For example, there is a check that observationFrequency_ not equal to zero here.
Constructor will not indicate Price_InvalidParams() error without that check.
Recommendation:
Change to:
if (observationFrequency_ == 0 || movingAverageDuration_ == 0 || movingAverageDuration_ % observationFrequency_ != 0)
Context:
https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/modules/RANGE.sol#L264 (10000 and 100)
https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Operator.sol#L111 (10000 and 100)
https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Operator.sol#L518 (10000 and 100)
https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Operator.sol#L550 (10000 and 100)
Description:
Use constant variables to make the code easier to understand and maintain.
Recommendation:
Define constants instead of unknown variables.
Context:
https://github.com/code-423n4/2022-08-olympus/blob/main/src/Kernel.sol#L439
https://github.com/code-423n4/2022-08-olympus/blob/main/src/Kernel.sol#L451
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L47
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L75
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/MINTR.sol#L20
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/MINTR.sol#L33
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/MINTR.sol#L37
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L110
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L215
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/PRICE.sol#L108
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/VOTES.sol#L22
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/VOTES.sol#L45
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/INSTR.sol#L28
Description:
Public functions can be declared external if they are not called by the contract.
Recommendation:
Declare these functions as external instead of public.
π Selected for report: pfapostol
Also found by: 0x040, 0x1f8b, 0x85102, 0xDjango, 0xNazgul, 0xNineDec, 0xSmartContract, 0xkatana, Amithuddar, Aymen0909, Bnke0x0, CertoraInc, Chandr, CodingNameKiki, Deivitto, Dionysus, Diraco, ElKu, Fitraldys, Funen, GalloDaSballo, Guardian, IllIllI, JC, JansenC, Jeiwan, LeoS, Metatron, Noah3o6, RaymondFam, ReyAdmirado, Rohan16, RoiEvenHaim, Rolezn, Ruhum, Saintcode_, Shishigami, Sm4rty, SooYa, StevenL, Tagir2003, The_GUILD, TomJ, Tomo, Waze, __141345__, ajtra, apostle0x01, aviggiano, bobirichman, brgltd, c3phas, cRat1st0s, carlitox477, cccz, ch0bu, chrisdior4, d3e4, delfin454000, djxploit, durianSausage, erictee, exolorkistis, fatherOfBlocks, gogo, grGred, hyh, ignacio, jag, karanctf, kris, ladboy233, lukris02, m_Rassska, martin, medikko, natzuu, ne0n, newfork01, oyc_109, peiw, rbserver, ret2basic, robee, rokinot, rvierdiiev, sikorico, simon135, tnevler, zishansami
32.597 DAI - $32.60
Context:
https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/Governance.sol#L278
Description:
If you 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-08-olympus/blob/main/src/policies/BondCallback.sol#L32
Description:
Variable is set in the constructor and never modified after that.
Recommendation:
It is more gas efficient to mark it as immutable.
**Context: **
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L96
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L97
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L131
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L115
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L116
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L132
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/PRICE.sol#L136
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/PRICE.sol#L222
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/PRICE.sol#L138
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/VOTES.sol#L58
https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/VOTES.sol#L56
https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/BondCallback.sol#L143
https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/BondCallback.sol#L144
https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/Heart.sol#L103
https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/Governance.sol#L198
https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/Governance.sol#L252
https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/Governance.sol#L254
https://github.com/code-423n4/2022-08-olympus/blob/main/src/policies/Governance.sol#L194
Recommendation:
Change X += Y (X -= Y) to X = X + Y (X = X - Y).
Context:
Recommendation:
Change i++ (i--) to ++i (--i).
Context:
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:
Description:
uint256 is a unsigned integer.
userVotesForProposal[activeProposal.proposalId][msg.sender] will never be less than 0.
Recommendation:
Change to
if (userVotesForProposal[activeProposal.proposalId][msg.sender] != 0) {