Joyn contest - Funen's results

Launchpad for collaborative web3 media projects with blueprints, building blocks, and community support.

General Information

Platform: Code4rena

Start Date: 30/03/2022

Pot Size: $30,000 USDC

Total HM: 21

Participants: 38

Period: 3 days

Judge: Michael De Luca

Total Solo HM: 10

Id: 104

League: ETH

Joyn

Findings Distribution

Researcher Performance

Rank: 36/38

Findings: 1

Award: $39.65

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

Awards

39.6506 USDC - $39.65

Labels

bug
G (Gas Optimization)

External Links

  1. Using short reason string can be used for saving more gas

Every reason string takes at least 32 bytes. Use short reason strings that fits in 32 bytes or it will become more expensive.

##Tool Used Manual Review

Occurance :

CoreCollection.sol CoreFactory.sol ERC721Claimable.sol RoyaltyVault.sol
  1. Set uint i for saving gas

https://github.com/code-423n4/2022-03-joyn/blob/main/core-contracts/contracts/CoreCollection.sol#L279

##Tool Used Manual Review

#POC

it unnecessary value set. the default value of uint is zero, so that implementation below can be used for saving gas. , so it can be set uint i instead of uint i = 0

##Occurance This was another occurance

core-contracts/contracts/Splitter.sol#L50 core-contracts/contracts/Splitter.sol#L274 core-contracts/contracts/MultiSigWallet.sol#L98 core-contracts/contracts/MultiSigWallet.sol#L127 core-contracts/contracts/MultiSigWallet.sol#L147 core-contracts/contracts/MultiSigWallet.sol#L268 core-contracts/contracts/MultiSigWallet.sol#L314 core-contracts/contracts/MultiSigWallet.sol#L330
  1. Using ++i instead i++ for saving more gas

Using i++ instead ++i for all the loops, the variable i is incremented using i++. It is known that implementation by using ++i costs less gas per iteration than i++.

Tools Used

Manual Review

Occurances

core-contracts/contracts/CoreCollection.sol#L279 core-contracts/contracts/CoreFactory.sol#L79 core-contracts/contracts/MultiSigWallet.sol#L127 core-contracts/contracts/MultiSigWallet.sol#L147
  1. Using calldata instead of memory for saving gas

https://github.com/code-423n4/2022-03-joyn/blob/c9297ccd925ebb2c44dbc6eaa3effd8db5d2368a/core-contracts/contracts/CoreFactory.sol#L72 instead of caching in memory, it better to used calldata .

Deployment Core Factory 1202872 before 
 1192707 after

##Tool Used Manual Review, Visual Studio Code

##Recommendation Mitigation

Collection[] calldata _collections
  1. using if else condition for saving more gas

https://github.com/code-423n4/2022-03-joyn/blob/main/core-contracts/contracts/CoreCollection.sol#L303-L308 this implementation below can be used for saving more gas

Deploy CoreCollection 3070877 before 3070229 after

##Tool used Visual Studio Code & Manual Review

##Recommended Mitigation Steps

if (royaltyVault != address(0) && IRoyaltyVault(royaltyVault).getVaultBalance() > 0 ) { IRoyaltyVault(royaltyVault).sendToSplitter(); }

change to

if (royaltyVault != address(0)){ }else{ IRoyaltyVault(royaltyVault).getVaultBalance() > 0; } IRoyaltyVault(royaltyVault).sendToSplitter(); }
  1. Using > instead of >= for saving more gas

https://github.com/code-423n4/2022-03-joyn/blob/c9297ccd925ebb2c44dbc6eaa3effd8db5d2368a/core-contracts/contracts/CoreMultiSig.sol#L21

##Impact expensive gas

##Tool Used Visual Studio Code

##Recommendation Mitigation Steps use >

  1. Goodway to use SafeERC20 function for saving more gas

https://github.com/code-423n4/2022-03-joyn/blob/main/core-contracts/contracts/CoreMultiSig.sol

##Impact Expensive gas

##POC https://docs.openzeppelin.com/contracts/3.x/api/token/erc20#SafeERC20

##Tool Used Manual Review

##Reccomendation Mitigation Steps by do not declaring using SafeERC20 for IERC20; and used safeTransfer

  1. Value can be set as immutable for saving gas

##Impact Expensive gas

##POC https://github.com/code-423n4/2022-03-joyn/blob/c9297ccd925ebb2c44dbc6eaa3effd8db5d2368a/royalty-vault/contracts/ProxyVault.sol#L9 this value can be set as immutable for saving gas.

##Tool Used Visual Studio Code

##Recommendation Mitigation

address internal immutable royaltyVault;

  1. Value can be set as constant for saving gas

##Impact Expensive gas

##POC

https://github.com/code-423n4/2022-03-joyn/blob/c9297ccd925ebb2c44dbc6eaa3effd8db5d2368a/royalty-vault/contracts/RoyaltyVaultFactory.sol#L27-L28 since platformFee and platformFeeRecipient was set, it can be set as constant instead, for saving gas.

##Tool Used Visual Studio Code

##Recommended Mitigation platformFee and platformFeeRecipient set as constant

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