Caviar contest - tnevler's results

A fully on-chain NFT AMM that allows you to trade every NFT in a collection.

General Information

Platform: Code4rena

Start Date: 12/12/2022

Pot Size: $36,500 USDC

Total HM: 8

Participants: 103

Period: 7 days

Judge: berndartmueller

Id: 193

League: ETH

Caviar

Findings Distribution

Researcher Performance

Rank: 88/103

Findings: 1

Award: $14.83

Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

14.833 USDC - $14.83

Labels

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

External Links

Report

Gas Optimizations

[G-1]: The increment in for loop post condition can be made unchecked

Context:

  1. for (uint256 i = 0; i < tokenIds.length; i++) { L238
  2. for (uint256 i = 0; i < tokenIds.length; i++) { L258
  3. for (uint256 i = 0; i < tokenIds.length; i++) { L468
  4. for (uint256 j = 0; j < 32; j++) { L13
  5. for (uint256 j = 0; j < charCount; j++) { L22
  6. for (uint256 i = 32; i < 64; i++) { L33
  7. for (uint256 i = 0; i < charCount; i++) { L39

Description:

This can save 30-40 gas per loop iteration.

Recommendation:

Example how to fix. Change:

for (uint256 i = 0; i < orders.length; ++i) { // Do the thing }

To:

for (uint256 i = 0; i < orders.length;) { // Do the thing unchecked { ++i; } }

[G-2]: Place subtractions where the operands can't underflow in unchecked {} block

Context:

  1. uint256 refundAmount = maxInputAmount - inputAmount; L168

Description:

Some gas can be saved by using an unchecked {} block if an underflow isn't possible because of a previous require() or if-statement.

#0 - c4-judge

2023-01-14T17:15:52Z

berndartmueller 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