Nibbl contest - kenta'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: 47/96

Findings: 2

Award: $45.67

🌟 Selected for report: 0

🚀 Solo Findings: 0

2022-06-nibbl

1 missing validations for the length of arrays.

The following parameters are array and the length of them must be checked before executing a function if the length is the same or not.

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

https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L504 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L545

require(a.length == b.length, “error message”);

2 use safeTransfer instead of transfer or check the return value of the transfer

transfer is used to send ERC20 tokens. The return value must be checked if the transfer is successful or not. Otherwise, safeTrasfer must be used as an alternative.

https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L517 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L526 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/Basket.sol#L87 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/Basket.sol#L94

Consider using safeTransfer or check the return value of the transfer.

3 use receivingAddress.call{value: amount}(""); instead of transfer

https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/Basket.sol#L80

(bool success, )= receivingAddress.call{value:amount}(""); require(success, “Error message”);

4 missing event for updateCurator.

Curator is a state variable. Event could be emitted in updateCurator with the arguments previousCurator and newCurator.

https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L485-L488

Event CuratorUpdated(address oldCurator, address newCurator);

address oldCurator = curator; curator = _newCurator;

emit CuratorUpdated(oldCurator, _newCurator);

#0 - HardlyDifficult

2022-07-01T00:31:27Z

#1 - HardlyDifficult

2022-07-04T17:47:41Z

Good best practices to follow.

2022-06-nibbl gas optimization

1 use calldata instead of memory

https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/Basket.sol#L41 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/Basket.sol#L68 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/Basket.sol#L91 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/Basket.sol#L109

https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVaultFactory.sol#L80 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVaultFactory.sol#L88

https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L174 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L175 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L504 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L523 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L545

For example,

function withdrawMultipleERC721(address[] calldata _tokens, uint256[] calldata _tokenId, address _to) external override {}

2 use unchecked for the following calculation.

_totalSupply > _initialTokenSupply is already checked in the if sentence. With unchecked, you can save gas costs.

https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L378

uint256 _tokensPrimaryCurve; unchecked { _tokensPrimaryCurve = _totalSupply - _initialTokenSupply;
}

3 use initial value for uint256, unchecked and prefix in the loop

https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/Basket.sol#L43 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/Basket.sol#L70 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/Basket.sol#L93

https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L547 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L525 https://github.com/code-423n4/2022-06-nibbl/blob/main/contracts/NibblVault.sol#L506

for (uint256 i; i < length;) { // some executions unchecked { ++i; } }

#0 - mundhrakeshav

2022-06-26T11:19:15Z

#8

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