Debt DAO contest - lukris02's results

A cryptonative credit marketplace for fully anon and trustless loans to DAOs.

General Information

Platform: Code4rena

Start Date: 03/11/2022

Pot Size: $115,500 USDC

Total HM: 17

Participants: 120

Period: 7 days

Judge: LSDan

Total Solo HM: 1

Id: 174

League: ETH

Debt DAO

Findings Distribution

Researcher Performance

Rank: 29/120

Findings: 2

Award: $669.35

QA:
grade-a
Gas:
grade-b

๐ŸŒŸ Selected for report: 0

๐Ÿš€ Solo Findings: 0

QA Report for Debt DAO contest

Overview

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

โ„–TitleRisk RatingInstance Count
NC-1Order of FunctionsNon-Critical4
NC-2Order of LayoutNon-Critical2
NC-3Spaces between the control structuresNon-Critical87
NC-4Open TODOsNon-Critical2
NC-5Open questionNon-Critical3
NC-6TyposNon-Critical26
NC-7Maximum line length exceededNon-Critical50+
NC-8Missing NatSpecNon-Critical50+
NC-9No error message in requireNon-Critical23

Non-Critical Risk Findings(9)

NC-1. Order of Functions

Description

According to Style Guide, ordering helps readers identify which functions they can call and to find the constructor and fallback definitions easier.
Functions should be grouped according to their visibility and ordered:

  1. constructor
  2. receive function (if exists)
  3. fallback function (if exists)
  4. external
  5. public
  6. internal
  7. private
Instances

receive() function at the end but should be after constructor:

external functions between internal:

public functions before external:

Recommendation

Reorder functions where possible.

NC-2. Order of Layout

Description

According to Order of Layout, inside each contract, library or interface, use the following order:

  1. Type declarations
  2. State variables
  3. Events
  4. Modifiers
  5. Functions
Instances

Modifiers after constructor:

Recommendation

Place modifiers before constructor.

NC-3. No space between the control structures

Description

According to Style Guide, there should be a single space between the control structures if, while, and for and the parenthetic block representing the conditional.

Instances
Recommendation

Change:

if(...) { ... }

to:

if (...) { ... }

NC-4. Open TODOs

Instances
Recommendation

Resolve issues.

NC-5. Open question

Instances

NC-6. Typos

Instances

NC-7. Maximum line length exceeded

Description

According to Style Guide, maximum suggested line length is 120 characters.

Instances

More than 50 instances.

Recommendation

Make the lines shorter.

NC-8. Missing NatSpec

Description

NatSpec is missing for more than 50 functions.

Recommendation

Add NatSpec for all functions.

NC-9. No error message in require

Instances
Recommendation

Add error messages.

#0 - c4-judge

2022-12-07T17:25:23Z

dmvt marked the issue as grade-b

#1 - c4-judge

2022-12-07T20:41:35Z

dmvt marked the issue as grade-a

Awards

49.2315 USDC - $49.23

Labels

bug
G (Gas Optimization)
grade-b
G-33

External Links

Gas Optimizations Report for Debt DAO contest

Overview

During the audit, 3 gas issues were found.
Total savings ~800.

โ„–TitleInstance CountSaved
G-1Use calldata instead of memory for read-only arguments5300
G-2Use unchecked blocks for incrementing i6210
G-3Use unchecked blocks for subtractions where underflow is impossible9315

Gas Optimizations Findings(3)

G-1. Use calldata instead of memory for read-only arguments

Description

Since Solidity v0.6.9, memory and calldata are allowed in all functions regardless of their visibility type (See "Calldata Variables" section here).
When function arguments should not be modified, it is cheaper to use calldata.

Instances
Recommendation

Consider using calldata where possible.

Saved

This saves at least 60 gas per iteration.
So, ~60*5 = 300

G-2. Use unchecked blocks for incrementing i

Description

In Solidity 0.8+, thereโ€™s a default overflow and underflow check on unsigned integers. In the loops, "i" will not overflow because the loop will run out of gas before that.

Instances
Recommendation

Change:

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

to:

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

This saves ~30-40 gas per iteration.
So, ~35*6 = 210

G-3. Use unchecked blocks for subtractions where underflow is impossible

Description

In Solidity 0.8+, thereโ€™s a default overflow and underflow check on unsigned integers. When an overflow or underflow isnโ€™t possible (after require or if-statement), some gas can be saved by using unchecked blocks.

Instances
Saved

This saves ~35.
So, ~35*9 = 315

#0 - c4-judge

2022-11-17T23:04:51Z

dmvt marked the issue as grade-b

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