OpenSea Seaport contest - TomJ's results

A marketplace contract for safely and efficiently creating and fulfilling orders for ERC721 and ERC1155 items.

General Information

Platform: Code4rena

Start Date: 20/05/2022

Pot Size: $1,000,000 USDC

Total HM: 4

Participants: 59

Period: 14 days

Judge: leastwood

Id: 128

League: ETH

OpenSea

Findings Distribution

Researcher Performance

Rank: 52/59

Findings: 1

Award: $434.95

🌟 Selected for report: 0

🚀 Solo Findings: 0

[G-01] Unnecessary variable initialization of default value

When variable is not initialized, then it will have default values. Example: 0 for uint, false for bool and address(0) for address

I suggest removing default value initialization for following variables.

OrderValidator.sol 272: for (uint256 i = 0; i < totalOrders; ) { 350: for (uint256 i = 0; i < totalOrders; ) { BasicOrderFulfiller.sol 948: for (uint256 i = 0; i < totalAdditionalRecipients; ) { 1040: for (uint256 i = 0; i < totalAdditionalRecipients; ) { AmountDeriver.sol 44: uint256 extraCeiling = 0; CriteriaResolution.sol 56: for (uint256 i = 0; i < totalCriteriaResolvers; ++i) { 166: for (uint256 i = 0; i < totalAdvancedOrders; ++i) { 184: for (uint256 j = 0; j < totalItems; ++j) { 199: for (uint256 j = 0; j < totalItems; ++j) { OrderCombiner.sol 181: for (uint256 i = 0; i < totalOrders; ++i) { 247: for (uint256 j = 0; j < offer.length; ++j) { 291: for (uint256 j = 0; j < consideration.length; ++j) { 373: for (uint256 i = 0; i < totalOrders; ++i) { 470: uint256 totalFilteredExecutions = 0; 473: for (uint256 i = 0; i < totalOfferFulfillments; ++i) { 498: for (uint256 i = 0; i < totalConsiderationFulfillments; ++i) { 577: for (uint256 i = 0; i < totalOrders; ++i) { 598: for (uint256 j = 0; j < consideration.length; ++j) { 621: for (uint256 i = 0; i < executions.length; ) { 751: uint256 totalFilteredExecutions = 0; 754: for (uint256 i = 0; i < totalFulfillments; ++i) { OrderFulfiller.sol 217: for (uint256 i = 0; i < orderParameters.offer.length; ) { 306: for (uint256 i = 0; i < orderParameters.consideration.length; ) { 471: for (uint256 i = 0; i < totalOrders; ++i) { TokenTransferrerConstants.sol 163:uint256 constant Invalid1155BatchTransferEncoding_ptr = 0x00; Conduit.sol 66: for (uint256 i = 0; i < totalStandardTransfers; ) { 130: for (uint256 i = 0; i < totalStandardTransfers; ) {

For example these can change to:

  • for (uint256 i; i < totalOrders; ) {

  • uint256 constant Invalid1155BatchTransferEncoding_ptr;

[G-02] Save Gas in For-Loops by storing array's length as a variable

3 gas per iteration can be saved by storing an array's length as a variable before the for-loop.

Issue found at:

OrderCombiner.sol 247: for (uint256 j = 0; j < offer.length; ++j) { 291: for (uint256 j = 0; j < consideration.length; ++j) { 598: for (uint256 j = 0; j < consideration.length; ++j) { 621: for (uint256 i = 0; i < executions.length; ) { OrderFulfiller.sol 217: for (uint256 i = 0; i < orderParameters.offer.length; ) { 306: for (uint256 i = 0; i < orderParameters.consideration.length; ) {

For example, I suggest changing the ones for OrderCombiner.sol to:

offerLength = offer.length for (uint256 j; j < offerLength; ++j) {

[G-03] ++i costs less gas than i++

It is better to use ++i than i++ when possible since it costs less gas. (Same for i-- as well)

Issue found at:

OrderCombiner.sol 229: maximumFulfilled--;

#0 - HardlyDifficult

2022-07-05T00:13:53Z

G-01: I tested this and got mixed results - some functions saved a tiny amount, others got a bit worse.

The other two should provide small savings.

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