Blur Exchange contest - lukris02's results

An NFT exchange.

General Information

Platform: Code4rena

Start Date: 11/11/2022

Pot Size: $36,500 USDC

Total HM: 5

Participants: 62

Period: 3 days

Judge: berndartmueller

Id: 181

League: ETH

Blur Exchange

Findings Distribution

Researcher Performance

Rank: 51/62

Findings: 1

Award: $22.22

Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

22.2155 USDC - $22.22

Labels

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

External Links

Gas Optimizations Report for Non Fungible Trading contest

Overview

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

â„–TitleInstance CountSaved
G-1Optimization for isOpen120,000
G-2Use unchecked blocks for incrementing i3105
G-3Use unchecked blocks for subtractions where underflow is impossible4140

Gas Optimizations Findings(3)

G-1. Optimization for isOpen

Description

For state variable isOpen, it is better to use uint256(1) and uint256(2) to avoid spending 20,000 gas when changing from '0' to '1' (when opening after closing).

Link:

function open() external onlyOwner { isOpen = 1; emit Opened(); } function close() external onlyOwner { isOpen = 0; emit Closed(); }
Saved

This saves ~20,000.

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*3 = 105

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*4 = 140

#0 - c4-judge

2022-11-17T12:55:41Z

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