Nested Finance contest - SooYa's results

The one-stop Defi app to build, manage and monetize your portfolio.

General Information

Platform: Code4rena

Start Date: 15/06/2022

Pot Size: $35,000 USDC

Total HM: 1

Participants: 36

Period: 3 days

Judge: Jack the Pug

Total Solo HM: 1

Id: 137

League: ETH

Nested Finance

Findings Distribution

Researcher Performance

Rank: 35/36

Findings: 1

Award: $34.72

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

34.7201 USDC - $34.72

Labels

bug
G (Gas Optimization)
valid

External Links

To optimize the for loop and make it consume less gas, i suggest to:

  1. If a variable is not set/initialized, it is assumed to have the default value (0 for uint, false for bool, address(0) for address…). Explicitly initializing it with its default value is an anti-pattern and wastes gas.

  2. Use ++i instead of i++, which is a cheaper operation (in this case there is no difference between i++ and ++i because we dont use the return value of this expression, which is the only difference between these two expression).

As an example:

for (uint256 i = 0; i < numIterations; ++i) {

should be replaced with

for (uint256 i; i < numIterations; ++i) {

i suggest to change the code below: https://github.com/code-423n4/2022-06-nested/blob/main/contracts/abstracts/MixinOperatorResolver.sol#L37 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/abstracts/MixinOperatorResolver.sol#L56 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/OperatorResolver.sol#L40 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/OperatorResolver.sol#L60 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/OperatorResolver.sol#L75 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L124 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L136 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L196 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L256 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L315 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L333 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L369 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L412 https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L651

#0 - Yashiru

2022-06-24T15:49:14Z

1. If a variable is not set/initialized, it is assumed to have the default value (Duplicated)

Duplicated of #2 at For loop optimizaion

2. Use ++i instead of i++ (Duplicated)

Duplicated of #2 at For loop optimizaion

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