Platform: Code4rena
Start Date: 20/01/2022
Pot Size: $50,000 USDC
Total HM: 3
Participants: 35
Period: 7 days
Judge: GalloDaSballo
Total Solo HM: 2
Id: 77
League: ETH
Rank: 31/35
Findings: 1
Award: $2.31
🌟 Selected for report: 0
🚀 Solo Findings: 0
2.3145 USDC - $2.31
bobi
When dealing with unsigned integer types, comparisons with != 0
are a cheaper operation than with > 0
; since uint
is >= 0
by nature, this change will not alter the program's behavior.
Such comparisons are found in:
MathLib.sol MathLib.sol::125 => require(_tokenAQty > 0, "MathLib: INSUFFICIENT_QTY"); MathLib.sol::127 => _tokenAReserveQty > 0 && _tokenBReserveQty > 0, MathLib.sol::266 => baseTokenQtyDecayChange > 0, MathLib.sol::336 => quoteTokenQtyDecayChange > 0, MathLib.sol::347 => require(quoteTokenDecay > 0, "MathLib: NO_QUOTE_DECAY"); MathLib.sol::388 => if (_totalSupplyOfLiquidityTokens > 0) { MathLib.sol::496 => _baseTokenQtyDesired > 0, MathLib.soll::500 => _quoteTokenQtyDesired > 0, MathLib.sol::606 => _baseTokenReserveQty > 0 && MathLib.sol::607 => _internalBalances.baseTokenReserveQty > 0, MathLib.sol::664 => _baseTokenQty > 0 && _quoteTokenQtyMin > 0, Exchange.sol Exchange.sol::113 => if (tokenQtys.liquidityTokenFeeQty > 0) { Exchange.sol::178 => require(this.totalSupply() > 0, "Exchange: INSUFFICIENT_LIQUIDITY"); Exchange.sol::180 => _baseTokenQtyMin > 0 && _quoteTokenQtyMin > 0, Exchange.sol::238 => if (liquidityTokenFeeQty > 0) { Exchange.sol::277 => _baseTokenQty > 0 && _minQuoteTokenQty > 0, Exchange.sol::314 => _quoteTokenQty > 0 && _minBaseTokenQty > 0,
change the comparison statement with != 0
; for eg:
From:
MathLib.sol::125 => require(_tokenAQty > 0, "MathLib: INSUFFICIENT_QTY");
To:
MathLib.sol::125 => require(_tokenAQty != 0, "MathLib: INSUFFICIENT_QTY");
#0 - 0xean
2022-01-31T14:03:07Z
dupe of #161