Backd Tokenomics contest - Tadashi's results

Maximize the power of your assets and start earning yield

General Information

Platform: Code4rena

Start Date: 27/05/2022

Pot Size: $75,000 USDC

Total HM: 20

Participants: 58

Period: 7 days

Judge: GalloDaSballo

Total Solo HM: 15

Id: 131

League: ETH

Backd

Findings Distribution

Researcher Performance

Rank: 51/58

Findings: 1

Award: $73.63

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

73.6341 USDC - $73.63

Labels

bug
G (Gas Optimization)
resolved
sponsor confirmed

External Links

Redundant checks can be removed

Details: The checks on L575, L589 and L602 of CrvDepositor.sol can be removed since the variables totalKeeperPoolWeight, totalLpPoolWeight and totalAmmTokenWeight are uint256 and the unchecked versions of add and sub are not used before these lines.

Some if conditions can be simplified changing ≤ to ==

Details: Some variables in the contract are of the type uint256 and will never be strictly negative. Thus, to check if these variables are not strictly positive you only need to check if they are equal to 0 — this will economize gas because EVM instruction set does not have an opcode for the condition "less than or eq", only for "less than" and "equal" opcodes.

In view of this it is suggested to perform the following simplifications:

  • Since amount in L62 of AmmGauge.sol is uint256, the if condition at L63 can be simplified to

    if (amount == 0) return 0;
  • Since the variables amount, crvAmount and crxAmount in L70-72 of AmmConvexGauge.sol are uint256, the if condition at L73 can be simplified to

    if (amount == 0 && crvAmount == 0 && cvxAmount == 0) return 0;
  • Since the variable amount in L58 of LpGauge.sol is uint256, the if condition at L59 can be simplified to

    if (amount == 0) return 0;

Pre-incrementing a variable is cheaper than post-incrementing it

Details: Consider changing L59 and L98 of KeeperGauge.sol to ++epoch;. For more information, see G012 of c4-common-issues.

Unused library

Details: ScaledMath is added to uint256 in BkdToken.sol, but its functions are not used. Consider removing it.

#0 - GalloDaSballo

2022-06-18T01:39:59Z

Redundant checks can be removed

Saves 100 gas per instance -> 300

Some if conditions can be simplified changing ≤ to ==

if (amount == 0) return 0;

3

if (amount == 0 && crvAmount == 0 && cvxAmount == 0) return 0;

3 * 3 = 9

if (amount == 0) return 0;

3

Pre-incrementing a variable is cheaper than post-incrementing it

5 gas per instance = 10

Unused library

Removed by the compiler

Total Gas Saved 325

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