Y2k Finance contest - lukris02's results

A suite of structured products for assessing pegged asset risk.

General Information

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

Y2k Finance

Findings Distribution

Researcher Performance

Rank: 53/110

Findings: 2

Award: $89.45

🌟 Selected for report: 0

🚀 Solo Findings: 0

QA Report for Y2K Finance contest

Overview

During the audit, 7 non-critical issues were found.

â„–TitleRisk RatingInstance Count
NC-1Scientific notation may be usedNon-Critical4
NC-2Constants may be usedNon-Critical7
NC-3Missing NatSpecNon-Critical16
NC-4Open TODONon-Critical1
NC-5Inconsistent use of named return variablesNon-Critical
NC-6Public functions can be externalNon-Critical5
NC-7Commented codeNon-Critical6

Non-Critical Risk Findings (7)

NC-1. Scientific notation may be used

Description

For readability, it is better to use scientific notation.

Instances
Recommendation

Replace 10000 with 10e4.

NC-2. Constants may be used

Description

Constants may be used instead of literal values.

Instances
Recommendation

Define constant variables, especially, for repeated values.

NC-3. Missing NatSpec

Description

NatSpec is missing for 16 functions in 3 contracts.

Instances
Recommendation

Add NatSpec for all functions.

NC-4. Open TODO

Instances
Recommendation

Resolve issues.

NC-5. Inconsistent use of named return variables

Description

Some functions return named variables, others return explicit values.

Instances

For example:

NC-6. Public functions can be external

Description

If functions are not called by the contract where they are defined, they can be declared external.

Instances
Recommendation

Make public functions external, where possible.

NC-7. Commented code

Instances
Recommendation

Delete commented code.

#0 - HickupHH3

2022-11-05T15:31:21Z

while main QA reports contains only NCs, the 1 low issue is valid and is described non-generically, hence the satisfactory rating.

Gas Optimizations Report for Y2k Finance contest

Overview

During the audit, 7 gas issues were found.

Gas Optimizations Findings (7)

G-1. Postfix increment

Description

Prefix increment costs less gas than postfix.

Instances
Recommendation

Consider using prefix increment where it is relevant.

G-2. <>.length in loops

Description

Reading the length of an array at each iteration of the loop consumes extra gas.

Instances
Recommendation

Store the length of an array in a variable before the loop, and use it.

G-3. Initializing variables with default value

Description

It costs gas to initialize integer variables with 0 or bool variables with false but it is not necessary.

Instances
Recommendation

Remove initialization for default values.
For example: for (uint256 i; i < array.length; ++i) {

G-4. > 0 is more expensive than =! 0

Instances
Recommendation

Use =! 0 instead of > 0, where possible.

G-5. x += y is more expensive than x = x + y

Instances
Recommendation

Use x = x + y instead of x += y. Use x = x - y instead of x -= y.

G-6. Using unchecked blocks saves gas

Description

In Solidity 0.8+, there’s a default overflow and underflow check on unsigned integers. When an overflow or underflow isn’t possible, some gas can be saved by using unchecked blocks.

Instances
Recommendation

Change:

for (uint256 i; i < n; ++i) { // ... }

to:

for (uint256 i; i < n;) { // ... unchecked { ++i; } }

G-7. Some variables can be immutable

Description

Using immutables is cheaper than storage-writing operations.

Instances
Recommendation

Use immutables where possible.

#0 - HickupHH3

2022-11-08T15:11:59Z

immutables save quite a good chunk. Capped to 10k gas.

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