Infinity NFT Marketplace contest - Tadashi's results

The world's most advanced NFT marketplace.

General Information

Platform: Code4rena

Start Date: 14/06/2022

Pot Size: $50,000 USDC

Total HM: 19

Participants: 99

Period: 5 days

Judge: HardlyDifficult

Total Solo HM: 4

Id: 136

League: ETH

Infinity NFT Marketplace

Findings Distribution

Researcher Performance

Rank: 92/99

Findings: 1

Award: $32.13

🌟 Selected for report: 0

🚀 Solo Findings: 0

Operations in relational expression can be optimized

Details: By using De Morgan's laws is possible to prove that L77-79 of InfinityOrderBookComplication.sol is equivalent to:

if (!(isOrdersTimeValid && itemsIntersect)) {
	return false; // short circuit
}

The latter code saves gas since a NOT instruction is avoided. Alternatively, consider splitting the if in two to avoid usage of || (see Simplifying if-else statements can save gas below for more details).

Simplifying if-else statements can save gas

Details: The following changes produces equivalent code and avoid the usage of || operator:

  • Changing L77-79 of InfinityOrderBookComplication.sol to

    if (!isOrdersTimeValid){ 
    	return false; 
    }
    if (!itemsIntersect) {
    	return false; 
    }
  • Changing L240-242 of InfinityOrderBookComplication.sol to

    if (order1NftsLength == 0){ 
    	return true;
    }
    if (order2NftsLength == 0){ 
    	return true;
    }
  • Changing L286-288 of InfinityOrderBookComplication.sol to

    if (item1TokensLength == 0){
    	return true;
    }
    if (item2TokensLength == 0){
    	return true;
    }
  • Changing L334-336 of InfinityOrderBookComplication.sol to

    if (priceDiff == 0) {
    	return startPrice;
    }
    if (duration == 0) {
    	return startPrice;
    }

Unnecessary require can be removed

Details: The require on L193 of InfinityStaker.sol can be removed since the variable totalStaked is of type uint256.

Note: Another alternative is to replace the code of L193 to

require(totalStaked > 0, 'nothing staked to rage quit');

which seems to be the original intent of the code authors.

Remove unnecessary fallback functions

Details: The fallback function in L119 of InfinityExchange.sol can be removed, as it does not have any logic implemented inside it and the InfinityExchange contract already has a receive function in L121. The same applies to the fallback function in L55 of InfinityStaker.sol

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