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
Rank: 92/99
Findings: 1
Award: $32.13
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: IllIllI
Also found by: 0v3rf10w, 0x1f8b, 0x29A, 0xAsm0d3us, 0xDjango, 0xKitsune, 0xNazgul, 0xf15ers, 0xkatana, 0xkowloon, BowTiedWardens, Chom, ElKu, FSchmoede, Funen, GimelSec, Kaiziron, Kenshin, Lambda, MadWookie, MiloTruck, PPrieditis, Picodes, PwnedNoMore, StErMi, Tadashi, TerrierLover, TomJ, Tomio, Wayne, Waze, _Adam, antonttc, apostle0x01, asutorufos, c3phas, codexploder, defsec, delfin454000, fatherOfBlocks, hake, hansfriese, hyh, joestakey, k, kenta, oyc_109, peritoflores, reassor, rfa, robee, sach1r0, simon135, slywaters, zer0dot
32.1296 USDC - $32.13
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).
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; }
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.
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