Olympus DAO contest - tnevler's results

Version 3 of Olympus protocol, a decentralized floating currency.

General Information

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

Olympus DAO

Findings Distribution

Researcher Performance

Rank: 79/147

Findings: 2

Award: $86.91

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Low Risk and Non-Critical Issues

Low Risk

[L-01]: Missing check

Context:

https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/modules/PRICE.sol#L79

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)

Non-Critical Issues

[N-01]: Constants instead of unknown variables

Context:

Description:

Use constant variables to make the code easier to understand and maintain.

Recommendation:

Define constants instead of unknown variables.

[N-02]: Public function can be external

Context:

Description:

Public functions can be declared external if they are not called by the contract.

Recommendation:

Declare these functions as external instead of public.

Report

Gas Optimizations

[G-01]: Use new variable instead of reading array length in every loop of a for-loop

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.

[G-02]: variable can be immutable

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.

[G-03]: X += Y costs more gas than X = X + Y

**Context: **

Recommendation:

Change X += Y (X -= Y) to X = X + Y (X = X - Y).

[G-04]: i++ costs more gas than ++i

Context:

Recommendation:

Change i++ (i--) to ++i (--i).

[G-05]: Don't initialize variable with its default value

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;

[G-06]: >0 costs more gas than !=0

Context:

https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Governance.sol#L247

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) {
AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax Β© 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter