Backd Tokenomics contest - Waze'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: 40/58

Findings: 2

Award: $171.45

๐ŸŒŸ Selected for report: 0

๐Ÿš€ Solo Findings: 0

Awards

113.5243 USDC - $113.52

Labels

bug
QA (Quality Assurance)
resolved
sponsor confirmed

External Links

#1 Immutable

Impact the state can't be initialize by constructor.

Proof Of Concept

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/VestedEscrow.sol#L35

Tool Used Manual Review

Recommended Mitigation Steps the state must add immutable because in the constructor parameter mention fundAdmin to initialize. so i suggest to add immutable on it.

address public fundAdmin;

to

address public immutable fundAdmin;

#2 Typo

Impact missleading

Proof of Concept https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/BkdLocker.sol#L173

Tools Used manual review

Recommended Mitigation Steps fix the typo to increase readibility. fix it from

* @dev This does not invlude the gov. tokens queued for withdrawal.

to

* @dev This does not includes the gov. tokens queued for withdrawal.

#0 - GalloDaSballo

2022-06-20T15:31:33Z

the state can't be initialize by constructor.

Disagree as the variable is changed in a setter

https://github.com/code-423n4/2022-05-backd-findings/issues/2 Typo

Valid non-critical finding

Awards

57.93 USDC - $57.93

Labels

bug
G (Gas Optimization)
resolved
sponsor confirmed

External Links

#1 Memory to storage

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/RewardHandler.sol#L39

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/AddressProvider.sol#L54

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/RewardHandler.sol#L41

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/zaps/PoolMigrationZap.sol#L21

use storage instead of memory can reduce the gas. i suggest to change

address[] memory pools = addressProvider.allPools();

to

address[] storage pools = addressProvider.allPools();

apply to others

#2 Use memory instead calldata

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/FeeBurner.sol#L43

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/Controller.sol#L124

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/AddressProvider.sol#L59

In the external functions where the function argument is read-only, the function() has an inputed parameter that using memory, if this function didnt change the parameter, its cheaper to use calldata then memory. so we suggest to change it.

function burnToTarget(address[] memory tokens_, address targetLpToken_)

to

function burnToTarget(address[] calldata tokens_, address targetLpToken_)

apply to others.

#3 use != 0 instead of >0

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/BkdLocker.sol#L91

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/BkdLocker.sol#L137

for unsigned integer, >0 is less efficient then !=0, so use !=0 instead of >0. do to all line code.

#4 Caching lpgauge

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/StakerVault.sol#L161-L162

ILpGauge(lpGauge).userCheckpoint(src); ILpGauge(lpGauge).userCheckpoint(dst);

to the memory for reduce the gas fee because it use multiple times.

#5 Pre increment

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/KeeperGauge.sol#L59

using pre increment more cheaper than post increment. so, i sugget to change

epoch++;

to

++epoch;

#6 change string to bytes32

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/Minter.sol#L152

reduce size of error message can reduce the gas fee. i suggest to convert string to bytes32

#7 Caching the length

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/zaps/PoolMigrationZap.sol#L22

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/zaps/PoolMigrationZap.sol#L39

caching the array length can reduce gas it caused access to a local variable is more cheap than query storage / calldata / memory in solidity.

#0 - GalloDaSballo

2022-06-17T23:15:39Z

Memory to storage

Would love to see a detailed POC as common sense dictates that storage is more expensive

Use memory instead calldata

Same as above

use != 0 instead of >0

Only for require, <=0.8.13, using optimizer, saves 3 gas

3 * 2 = 6

Caching lpgauge

Disagree, it's already cached, the casting has no gas cost and it's a higher language construct

Pre increment

Saves 5 gas

change string to bytes32

Saves 6 gas per discussion in #17

##ย Caching the length Saves 3 gas

3 * 2 = 6

Total Gas Saved 23

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