Y2k Finance contest - tnevler'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: 100/110

Findings: 1

Award: $16.18

๐ŸŒŸ Selected for report: 0

๐Ÿš€ Solo Findings: 0

Report

Gas Optimizations

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

Context:

https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/VaultFactory.sol#L195

Recommendation:

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

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

Context:

https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Vault.sol#L443

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-03]: >0 costs more gas than !=0

Context:

Description:

uint type and msg.value are always non-negative.

Recommendation:

Change >0 to !=0.

[G-04]: Use new variable instead of calling function and reading array length in every loop of a for-loop

Context:

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

https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Vault.sol#L443

Description:

If you call function and 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-05]: i++ costs more gas than ++i

Context:

https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Vault.sol#L443

Recommendation:

Change i++ to ++i.

[G-06]: variable can be immutable

Context:

Description:

Variable is set in the constructor and never modified after that.

Recommendation:

It is more gas efficient to mark it as immutable.

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