QA Report #91
Labels
bug
Something isn't working
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
resolved
Finding has been patched by sponsor (sponsor pls link to PR containing fix)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
> 0 is less efficient than != 0 for unsigned integers (with proof)
!= 0
costs less gas compared to> 0
for unsigned integers inrequire
statements with the optimizer enabled (6 gas)Proof: While it may seem that
> 0
is cheaper than!=
,this is only true without the optimizer enabled and outside a require
statement. If you enable the optimizer at 10k AND you’re in a
require
statement, this will save gas. You can see this tweet for more proofs: https://twitter.com/gzeon/status/1485428085885640706I suggest changing
> 0
with!= 0
here:Instances:
contracts/BkdLocker.sol:91: require(amount > 0, Error.INVALID_AMOUNT);
contracts/BkdLocker.sol:92: require(totalLockedBoosted > 0, Error.NOT_ENOUGH_FUNDS);
contracts/BkdLocker.sol:137: require(length > 0, "No entries");
contracts/pool/LiquidityPool.sol:469: require(underlyingAmount > 0, Error.INVALID_AMOUNT);
contracts/pool/LiquidityPool.sol:471: require(lpToken_.balanceOf(account) > 0, Error.INSUFFICIENT_BALANCE);
contracts/pool/LiquidityPool.sol:514: require(mintedLp >= minTokenAmount && mintedLp > 0, Error.INVALID_AMOUNT);
contracts/pool/LiquidityPool.sol:538: require(redeemLpTokens > 0, Error.INVALID_AMOUNT);
contracts/testing/MockVotingEscrow.sol:35: require(_balances[msg.sender] > 0, "a lock needs to first be created");
contracts/testing/MockErc20Strategy.sol:64: require(currentBalance > 0, "Invalid amount to withdraw");
contracts/testing/MockErc20Strategy.sol:74: require(amount > 0, "Invalid amount to transfer");
contracts/testing/MockEthStrategy.sol:65: require(currentBalance > 0, "Invalid amount to withdraw");
contracts/tokenomics/VestedEscrow.sol:84: require(unallocatedSupply > 0, "No reward tokens in contract");
contracts/tokenomics/KeeperGauge.sol:140: require(totalClaimable > 0, Error.ZERO_TRANSFER_NOT_ALLOWED);
contracts/tokenomics/AmmGauge.sol:104: require(amount > 0, Error.INVALID_AMOUNT);
contracts/tokenomics/AmmGauge.sol:125: require(amount > 0, Error.INVALID_AMOUNT);
contracts/tokenomics/AmmConvexGauge.sol:158: require(amount > 0, Error.INVALID_AMOUNT);
contracts/tokenomics/AmmConvexGauge.sol:171: require(amount > 0, Error.INVALID_AMOUNT);
contracts/vault/Vault.sol:163: require(amount > 0, Error.INVALID_AMOUNT);
contracts/actions/topup/TopUpActionFeeHandler.sol:123: require(totalClaimable > 0, Error.NOTHING_TO_CLAIM);
contracts/actions/topup/TopUpAction.sol:214: require(record.singleTopUpAmount > 0, Error.INVALID_AMOUNT);
contracts/actions/topup/TopUpAction.sol:535: require(position.totalTopUpAmount > 0, Error.INSUFFICIENT_BALANCE);
Also, please enable the Optimizer.
The text was updated successfully, but these errors were encountered: