Nibbl contest - Waze's results

NFT fractionalization protocol with guaranteed liquidity and price based buyout.

General Information

Platform: Code4rena

Start Date: 21/06/2022

Pot Size: $30,000 USDC

Total HM: 12

Participants: 96

Period: 3 days

Judge: HardlyDifficult

Total Solo HM: 5

Id: 140

League: ETH

Nibbl

Findings Distribution

Researcher Performance

Rank: 55/96

Findings: 2

Award: $45.51

🌟 Selected for report: 0

🚀 Solo Findings: 0

#1 unmatch between comment and function (should be implementer_role) Impact Causing confuse to user and developer.

Proof of Concept https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVaultFactory.sol#L156

Tool Used Manual review

Recommendation Mitigation Steps change from FEE_ROLE to IMPLEMENTER_ROLE

#2 Missing param natspec _totalSupply Impact _buyPrimaryCurve, _buySecondaryCurve, _sellPrimaryCurve and _sellSecondaryCurve function have natspec comment which is missing the _totalSupply function parameter. Issues with comments are low risk based on Code4rena risk categories.

Proof of Concept https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVault.sol#L275

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVault.sol#L287

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVault.sol#L335

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVault.sol#L347

Tool Used Manual review

Recommendation Mitigation Steps Add natspec comments include _totalSupply parameter in function that mantion.

#3 Use call instead transfer Impact usage of send() or transfer() would cause an out of gas error.

Proof of Concept https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/Basket.sol#L80

Tool Used Manual review

Recommendation Mitigation Steps use .call() because .transfer() fowards 2300 gas whereas .call() forwards all / set gas.

#4 Missing state admin Impact the constructor initialize _admin but the state admin was missing, and caused of it made constructor doesn't work properly.

Proof of Concept https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/Utilities/AccessControlMechanism.sol#L19

Tool Used Manual review

Recommendation Mitigation Steps i suggest to add state admin, so that the constructor can work to initialize param admin. and make it immutable

#5 constructor cant initialize the state Impact the constructor initialize _vaultImplementation, _feeTo, and _basketImplementation but the states was missing, and caused of it made constructor doesn't work properly.

Proof of Concept https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVaultFactory.sol#L23

Tool Used Manual review

Recommendation Mitigation Steps i suggest to add state _vaultImplementation, _feeTo, and _basketImplementation, so that the constructor can work to initialize _vaultImplementation, _feeTo, and _basketImplementation. and make it immutable

#1 Reduce string

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVaultFactory.sol#L48

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVaultFactory.sol#L107

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVaultFactory.sol#L131

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVaultFactory.sol#L140

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVaultFactory.sol#L166

reduce string size of error message to bytes32 can reduce the gas fee. reduce these if possible.

#2 Use calldata instead memory

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/Basket.sol#L68

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVaultFactory.sol#L76

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.

#3 Use !=0 instead of >0

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVault.sol#L227

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVault.sol#L243

for unsigned integer, >0 is less efficient then !=0, so use !=0 instead of >0. apply to others.

#4 Looping (aritmathic)

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/Basket.sol#L43

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/Basket.sol#L70

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/Basket.sol#L94

default uint is 0 so remove unnecassary explicit can reduce gas. caching the array length (_tokens.length) can reduce gas it caused access to a local variable is more cheap than query storage / calldata / memory in solidity. pre increment e.g ++i more cheaper gas than post increment e.g i++. i suggest to use pre increment.

#5 Use storage instead memory

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/Twav/Twav.sol#L38-L39

Use storage instead of memory to reduce the gas fee. I suggest change from

TwavObservation memory _twavObservationCurrent = twavObservations[(_index)]; TwavObservation memory _twavObservationPrev = twavObservations[(_index + 1) % TWAV_BLOCK_NUMBERS];

to

TwavObservation storage _twavObservationCurrent = twavObservations[(_index)]; TwavObservation storage _twavObservationPrev = twavObservations[(_index + 1) % TWAV_BLOCK_NUMBERS];

#6 Change visibility to private or internal

https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/Utilities/AccessControlMechanism.sol#L12-L14

change visibility from public to private or internal can save gas. so i recommend to change it.

#0 - mundhrakeshav

2022-06-26T07:32:45Z

#3 , #8, #9, #15

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