Nested Finance contest - TerrierLover'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: 15/36

Findings: 2

Award: $116.54

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

81.8216 USDC - $81.82

Labels

bug
QA (Quality Assurance)
sponsor confirmed
valid

External Links

[QA-1] Naming inconsistency - some arguments have _ at their prefixes but others do not at NestedFactory.sol

Throughout the file NestedFactory.sol, arguments of functions have _ at their prefixes like function setFeeSplitter(FeeSplitter _feeSplitter). However, following 2 arguments do not have _ at their prefixes which are not consistent.

https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L121

https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L133


[QA-2] Use either _msgSender() or msg.sender

Throughout the file NestedFactory.sol, _msgSender() is used to get the sender. However, following 2 places use msg.sender which seem not consistent.

https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L89

https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L177

#0 - Yashiru

2022-06-22T15:33:29Z

[QA-1] Naming inconsistency (Confirmed)

Quality assurance confirmed

#1 - Yashiru

2022-06-22T15:39:13Z

[QA-2] Use either _msgSender() or msg.sender (Confirmed)

Awards

34.7201 USDC - $34.72

Labels

bug
G (Gas Optimization)
valid

External Links

[Gas-1] Potential usage of unchecked

Following variables or operations can be wrapped by unchecked to reduce gas cost.

  • The increment of i in the for loop

Following codebase which contains for loop can wrap i++ by unchecked since the end condition of the for loop uses uint256 variable.

Here is an example.

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

operatorsLength is uint256, and i++ will not overflow in the for loop since it has the end condition i < operatorsLength. The above part can be written like this by using unchecked which reduces the gas cost.

for (uint256 i = 0; i < operatorsLength; ) { // .... omitted unchecked { i++ } }

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/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/operators/Beefy/BeefyVaultOperator.sol#L18

  • operators[operatorsLength - 1] can be wrapped by unchecked

https://github.com/code-423n4/2022-06-nested/blob/main/contracts/NestedFactory.sol#L138

uint256 operatorsLength = operatorsCache.length; for (uint256 i = 0; i < operatorsLength; i++) { if (operatorsCache[i] == operator) { operatorsCache[i] = operators[operatorsLength - 1];

Since operatorsLength is uint256, operatorsLength - 1 will not be underflown. Therefore, this part can be written like this:

uint256 operatorsLength = operatorsCache.length; for (uint256 i = 0; i < operatorsLength; i++) { if (operatorsCache[i] == operator) { unchecked { operatorsCache[i] = operators[operatorsLength - 1]; }

[Gas-2] No need to set 0 on uint variables

The default value of uint varibles are 0. Therefore, there is no need to set 0 on uint variables. Not setting 0 on uint variables can reduce the deployment gas cost.

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#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

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/abstracts/MixinOperatorResolver.sol#L37

https://github.com/code-423n4/2022-06-nested/blob/main/contracts/abstracts/MixinOperatorResolver.sol#L56

#0 - Yashiru

2022-06-24T15:37:13Z

[Gas-1] Potential usage of unchecked (Duplicated)

Duplicated of #2 at For loop optimizaion

[Gas-2] No need to set 0 on uint variables (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