Juicebox contest - sakman's results

The decentralized fundraising and treasury protocol.

General Information

Platform: Code4rena

Start Date: 18/10/2022

Pot Size: $50,000 USDC

Total HM: 13

Participants: 67

Period: 5 days

Judge: Picodes

Total Solo HM: 7

Id: 172

League: ETH

Juicebox

Findings Distribution

Researcher Performance

Rank: 63/67

Findings: 1

Award: $25.96

Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

25.9629 USDC - $25.96

Labels

bug
G (Gas Optimization)
grade-b
G-25

External Links

1. Explicitly assingning default values to variables is a waste of gas

Use uint256 i; instead of uint256 i = 0;

contracts/libraries/JBIpfsDecoder.sol: L49 L68 L76 L84

2. Cache storage variables in function call stack to save gas

contracts/JBTiered721Delegate.sol: L143-L152

3. Prefix incrementing and decrementing costs around 6 gas less than the postfix ones

e.g. ++var is cheaper than var++

contracts/libraries/JBIpfsDecoder.sol: L68 L76 L84

contracts/JBTiered721DelegateStore.sol: L1108

4. use x = x + y instead of x+= y

contracts/JBTiered721DelegateStore.sol: L827

5. Calldata is cheaper than memory for function input

contracts/abstract/JB721Delegate.sol: L206 L311 L323

contracts/libraries/JBIpfsDecoder.sol: L22 L44 L74 L82

contracts/libraries/JBBitmap.sol: L29 L59

contracts/JBTiered721DelegateDeployer.sol: L71

contracts/JBTiered721DelegateStore.sol: L628 L1091 L1227

contracts/JBTiered721Delegate.sol: L205 L208 L210 L211 L264 L290 L480 L598 L652 L789

contracts/JB721TieredGovernance.sol: L147 L313

contracts/JB721GlobalGovernance.sol: L55

contracts/JBTiered721DelegateProjectDeployer.sol: L72 L73 L109 L110 L152 L191 L218

6. Use x < y + 1 in stead of x <= y

contracts/JB721TieredGovernance.sol: L133

contracts/JBTiered721DelegateStore.sol: L903

7. When comparing variables of type uint, use require(x != 0) instead of require(x > 0)

contracts/libraries/JBIpfsDecoder.sol: L57

contracts/JBTiered721DelegateStore.sol: L1254

8. Use constant and immutable for constants

contracts/JBTiered721Delegate.sol: L48

9. Consider marking functions as payable if there is no risk of sending value through them

This change will save gas each time a function is called

contracts/JBTiered721Delegate.sol: L370 L402 L418

10. Place i++ in an unchecked blocks in for-loops

contracts/libraries/JBIpfsDecoder.sol: L49 L51 L68 L76

contracts/JBTiered721Delegate.sol: L341 L355

#0 - c4-judge

2022-11-05T12:26:54Z

Picodes marked the issue as grade-b

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