bunker.finance contest - rfa's results

The easiest way to borrow against your NFTs.

General Information

Platform: Code4rena

Start Date: 03/05/2022

Pot Size: $50,000 USDC

Total HM: 4

Participants: 46

Period: 5 days

Judge: gzeon

Total Solo HM: 2

Id: 117

League: ETH

bunker.finance

Findings Distribution

Researcher Performance

Rank: 39/46

Findings: 1

Award: $52.48

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

52.4836 USDC - $52.48

Labels

bug
G (Gas Optimization)

External Links

##GAS

Title: Initializing var with default value

Occurrences: https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/CNft.sol#L49 https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/CNft.sol#L97

By declaring var by not set its default value (0 for uint) can save gas cost Change to:

uint256 totalAmount;

Title: Using unchecked for i in a for() loop

Occurence: https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/CNft.sol#L50 https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/CNft.sol#L72 https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/CNft.sol#L122 https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/ERC1155Enumerable.sol#L51

Using unchecked for i can save execution gas fee:

for (uint256 i; i < length;) { if (!is1155) { require(amounts[i] == 1, "CNFT: Amounts must be all 1s for non-ERC1155s."); unchecked{++i;} }

Title: Using && is not effective

Occurrences: https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/CNft.sol#L66

Instead of using && which cost 15 execution gas fee per call. Using multiple require() is more effective RECOMMENDED MITIGATION STEP

require(checkSuccess, "Not the NFT owner"); require(nftOwner == msg.sender, "Not the NFT owner");
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