Rubicon contest - RoiEvenHaim's results

An order book protocol for Ethereum, built on L2s.

General Information

Platform: Code4rena

Start Date: 23/05/2022

Pot Size: $50,000 USDC

Total HM: 44

Participants: 99

Period: 5 days

Judge: hickuphh3

Total Solo HM: 11

Id: 129

League: ETH

Rubicon

Findings Distribution

Researcher Performance

Rank: 93/99

Findings: 1

Award: $30.83

🌟 Selected for report: 0

🚀 Solo Findings: 0

gas optimization

object++ cost more then ++object .

The default value of uint is 0. So there is no need to set false at index variable. uint256 index = 0 cost more then uint256 index.

The default value of bool is false. So there is no need to set false at assigned variable. bool assigned = false cost more then bool assigned.

BathPair.sol

line 310 - bool assigned = false;
fix - bool assigned;
line 311- for (uint256 index = 0; index < array.length; index++) { if (uid == array[index]) { _index = index; assigned = true; return _index; } }
fix - for (uint256 index; index < array.length; ++index) { if (uid == array[index]) { _index = index; assigned = true; return _index; } }
line 427- for (uint256 index = 0; index < quantity; index++) { placeMarketMakingTrades( tokenPair, askNumerators[index], askDenominators[index], bidNumerators[index], bidDenominators[index] ); }
fix- for (uint256 index; index < quantity; ++index) { placeMarketMakingTrades( tokenPair, askNumerators[index], askDenominators[index], bidNumerators[index], bidDenominators[index] ); }
line 480- for (uint256 index = 0; index < quantity; index++) { requote( ids[index], tokenPair, askNumerators[index], askDenominators[index], bidNumerators[index], bidDenominators[index] ); }
fix- for (uint256 index; index < quantity; ++index) { requote( ids[index], tokenPair, askNumerators[index], askDenominators[index], bidNumerators[index], bidDenominators[index] ); }
line 582 - for (uint256 index = 0; index < ids.length; index++) { uint256 _id = ids[index]; scrubStrategistTrade(_id); }
fix - for (uint256 index = 0; index < ids.length; index++) { uint256 _id = ids[index]; scrubStrategistTrade(_id); }
line 206 - last_stratTrade_id++;
fix - ++last_stratTrade_id;
line 277- current[target] = current[current.length - 1];
fix- current[target] = current[--current.length];

BathToken.sol

line 635 - for (uint256 index = 0; index < bonusTokens.length; index++) { IERC20 token = IERC20(bonusTokens[index]); // Note: Shares already burned in Bath Token _withdraw // Pair each bonus token with a lightly adapted OZ Vesting wallet. Each time a user withdraws, they // are released their relative share of this pool, of vested BathBuddy rewards // The BathBuddy pool should accrue ERC-20 rewards just like OZ VestingWallet and simply just release the withdrawer's relative share of releaseable() tokens if (rewardsVestingWallet != IBathBuddy(0)) { rewardsVestingWallet.release( (token), receiver, sharesWithdrawn, initialTotalSupply, feeBPS ); } } }
fix - for (uint256 index; index < bonusTokens.length; ++index) { IERC20 token = IERC20(bonusTokens[index]); // Note: Shares already burned in Bath Token _withdraw // Pair each bonus token with a lightly adapted OZ Vesting wallet. Each time a user withdraws, they // are released their relative share of this pool, of vested BathBuddy rewards // The BathBuddy pool should accrue ERC-20 rewards just like OZ VestingWallet and simply just release the withdrawer's relative share of releaseable() tokens if (rewardsVestingWallet != IBathBuddy(0)) { rewardsVestingWallet.release( (token), receiver, sharesWithdrawn, initialTotalSupply, feeBPS ); } } }
line 733- nonces[owner]++
fix- ++nonces[owner]

RubiconMarket.sol

line 436 - last_offer_id++;
fix - ++last_offer_id;
line 1165- _span[address(pay_gem)][address(buy_gem)]++;
fix- _span[address(pay_gem)][address(buy_gem)]++;
line 990 - uint256 old_top = 0;
fix - uint256 old_top;

RubiconRouter.sol

line 85 - for (uint256 index = 0; index < topNOrders; index++) { if (index == 0) { lastAsk = bestAskID; lastBid = bestBidID;
fix - for (uint256 index; index < topNOrders; ++index) { if (index == 0) { lastAsk = bestAskID; lastBid = bestBidID;
line 165 - for (uint256 i = 0; i < route.length - 1; i++) { (address input, address output) = (route[i], route[i + 1]); uint256 _pay = i == 0
fix - for (uint256 i; i < route.length - 1; ++i) { (address input, address output) = (route[i], route[i + 1]); uint256 _pay = i == 0
line 227 - for (uint256 i = 0; i < route.length - 1; i++) { (address input, address output) = (route[i], route[i + 1]); uint256 _pay = i == 0
fix - for (uint256 i; i < route.length - 1; ++i) { (address input, address output) = (route[i], route[i + 1]); uint256 _pay = i == 0
line 82 - uint256 lastBid = 0;
fix - uint256 lastBid;
line 83 - uint256 lastAsk = 0;
fix - uint256 lastAsk;
line 168 - uint256 currentAmount = 0;
fix - uint256 currentAmount;
line 226 - uint256 currentAmount = 0;
fix - uint256 currentAmount;
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