Backd Tokenomics contest - SecureZeroX'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: 20/58

Findings: 2

Award: $399.88

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Awards

337.1951 USDC - $337.20

Labels

bug
QA (Quality Assurance)
resolved
sponsor confirmed

External Links

  1. Some functions have unused return value. Most of functions have bool return value to indicate success or failure. But the following functions return always true or revert transaction, so the return value is meaning less. https://github.com/code-423n4/2022-05-backd/blob/main/protocol/contracts/tokenomics/KeeperGauge.sol#L57-L62

https://github.com/code-423n4/2022-05-backd/blob/main/protocol/contracts/tokenomics/AmmGauge.sol#L49-L54

https://github.com/code-423n4/2022-05-backd/blob/main/protocol/contracts/tokenomics/KeeperGauge.sol#L72-L90

Recommendation: Return false for special conditions, or remove return value.

  1. reportFees() function of KeeperGauge.sol needs to have zero amount check. There is no zero amount check in reportFees() function, thus beneficiary’s firstEpochSet and nextEpochToClaim will be initialized, and this lead high gas cost in claim function.

Recommendation: Check zero amount to avoid updating data and wasting gas.

#0 - GalloDaSballo

2022-06-20T00:33:46Z

Some functions have unused return value.

Agree, good find

reportFees() function of KeeperGauge.sol needs to have zero amount check.

I'm not sure about which gas savings the zero check will provide

#1 - GalloDaSballo

2022-06-20T00:34:04Z

Formatting could use titles

Awards

62.6774 USDC - $62.68

Labels

bug
G (Gas Optimization)
resolved
sponsor confirmed

External Links

  1. Unused contracts and libraries are imported. https://github.com/code-423n4/2022-05-backd/blob/main/protocol/contracts/tokenomics/KeeperGauge.sol#L4

Recommendation: Remove unused libraries.

  1. Checkpoint executed twice when kill the gauge. https://github.com/code-423n4/2022-05-backd/blob/main/protocol/contracts/tokenomics/InflationManager.sol#L427-L428

https://github.com/code-423n4/2022-05-backd/blob/main/protocol/contracts/tokenomics/InflationManager.sol#L461-L462

InflationManager call poolCheckPoint(), then call kill() function, but inside of kill() function, poolCheckPoint() will be executed again.

Recommendation: Remove poolCheckPoint() call before kill.

  1. Cache array length before loop to reduce gas cost Cache length of array and use it in the loop is a good solution to reduce gas. Other wise, it will always trying to load length from storage in every loop.

https://github.com/code-423n4/2022-05-backd/blob/main/protocol/contracts/tokenomics/InflationManager.sol#L116

https://github.com/code-423n4/2022-05-backd/blob/main/protocol/contracts/access/RoleManager.sol#L82

Recommendation Cache length of array and use it in loop.

  1. Use !=0 instead of >0 for uint non zero check. In most of places, there is something like a > 0 for non-zero check. For Uint variables, there is no negative value, so it’s enough to change to a != 0.

Ex. https://github.com/code-423n4/2022-05-backd/blob/main/protocol/contracts/tokenomics/KeeperGauge.sol#L140

Recommendation: Use non-equal operator instead of greater operator for non-zero check.

  1. lastEvent in Minter.sol can be update multiple times. https://github.com/code-423n4/2022-05-backd/blob/main/protocol/contracts/tokenomics/Minter.sol#L222

_mint function update lastEvent twice – first update in Line 222, and second update inside executeInflationRateUpdate()

Recommendation: Optimize code to avoid multiple updates.

  1. Use interface contract for external calls. https://github.com/code-423n4/2022-05-backd/blob/main/protocol/contracts/tokenomics/Minter.sol#L56

There is a IBkdToken interface, but now it is using BkdToken (implementation contract) for external calls. This increase contract size.

Recommendation: Use interface for external calls.

#0 - GalloDaSballo

2022-06-17T22:40:32Z

Unused contracts and libraries are imported.

Doesn't save gas

Checkpoint executed twice when kill the gauge.

Finding is valid, but the warden didn't specify how much gas is saved, I'll give it 200 gas, although it probably would have saved more (next time do the math yourself)

Cache array length before loop to reduce gas cost

Saves 3 gas per instance 6 gas

Use !=0 instead of >0 for uint non zero check.

Only in require, with solidity < 0.8.13, with optimizer on 3 gas

_mint function update lastEvent twice – first update in Line 222, and second update inside executeInflationRateUpdate()

Setting storage to same value costs 100 gas as per ArrowGlacier, this would save 100 gas

##Β Use interface contract for external calls. I believe the optimizer removes all unused code reducing the excessive code by a lot

Total Gas Saved 309

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