SIZE contest - halden's results

An on-chain sealed bid auction protocol.

General Information

Platform: Code4rena

Start Date: 04/11/2022

Pot Size: $42,500 USDC

Total HM: 9

Participants: 88

Period: 4 days

Judge: 0xean

Total Solo HM: 2

Id: 180

League: ETH

SIZE

Findings Distribution

Researcher Performance

Rank: 71/88

Findings: 1

Award: $21.13

Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

21.132 USDC - $21.13

Labels

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

External Links

[G-01] Cache storage values in memory to minimize SLOADs

cache a.timings in memory File SizeSealed.sol: 29-37

if (block.timestamp < a.timings.startTimestamp) { // 1 SLOAD if (_state != States.Created) revert InvalidState(); } else if (block.timestamp < a.timings.endTimestamp) { // 2 SLOAD if (_state != States.AcceptingBids) revert InvalidState(); } else if (a.data.lowestQuote != type(uint128).max) { if (_state != States.Finalized) revert InvalidState(); } else if (block.timestamp <= a.timings.endTimestamp + 24 hours) { // 3 SLOAD if (_state != States.RevealPeriod) revert InvalidState(); } else if (block.timestamp > a.timings.endTimestamp + 24 hours) { // 4 SLOAD

[G-02] Use memory instaed of storage

idToAuction[auctionId] can be stored first in memory and after getting/setting of all variables can be stored in storage

File SizeSealed.sol: 86-92, 131, 181, 221, 246, 337-338, 359-360, 392, 418-419, 456

[G-03] Using unchecked blocks to save gas - Increments in for loop can be unchecked

The majority of Solidity for loops increment a uint256 variable that starts at 0. These increment operations never need to be checked for over/underflow because the variable will never reach the max number of uint256 (will run out of gas long before that happens). The default over/underflow check wastes gas in every iteration of virtually every for loop . eg.

File SizeSealed.sol: 244, 302

[G-04] Add unchecked {} where the operands can not underflow/overflow because of a previous check

uint128 unsoldBase = data.totalBaseAmount - data.filledBase; File SizeSealed.sol: 319 is checked in 313 line

currentTime - vestingStart and vestingEnd - vestingStart can be unchecked File CommonTokenMath.sol: 65

[G-05] X += Y costs more gas than X = X + Y for state variables

File SizeSealed.sol: 373

#0 - c4-judge

2022-11-10T02:08:46Z

0xean 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