We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SLOAD
sendToSplitter()
https://github.com/code-423n4/2022-03-joyn/blob/main/royalty-vault/contracts/RoyaltyVault.sol#L31 cache splitterProxy, royaltyAsset, platformFeeRecipient in sendToSplitter(). each direct read of state vars cost 100 gas.
splitterProxy
royaltyAsset
platformFeeRecipient
calldata
memory
createProject()
https://github.com/code-423n4/2022-03-joyn/blob/main/core-contracts/contracts/CoreFactory.sol#L72
For external function's dynamic params, calldata is the cheapest location to use.
Change params memory to calldata
Custom errors from Solidity 0.8.4 are cheaper than require messages. https://blog.soliditylang.org/2021/04/21/custom-errors/
require
++i
i++
https://github.com/code-423n4/2022-03-joyn/blob/main/core-contracts/contracts/CoreCollection.sol#L279 https://github.com/code-423n4/2022-03-joyn/blob/main/core-contracts/contracts/CoreFactory.sol#L79 https://github.com/code-423n4/2022-03-joyn/blob/main/splits/contracts/Splitter.sol#L50 https://github.com/code-423n4/2022-03-joyn/blob/main/splits/contracts/Splitter.sol#L274
== true
transfer return boolean and require expect a boolean. so removing these == true can save some gas: https://github.com/code-423n4/2022-03-joyn/blob/main/royalty-vault/contracts/RoyaltyVault.sol#L44 https://github.com/code-423n4/2022-03-joyn/blob/main/royalty-vault/contracts/RoyaltyVault.sol#L48 https://github.com/code-423n4/2022-03-joyn/blob/main/royalty-vault/contracts/RoyaltyVault.sol#L55
transfer
The text was updated successfully, but these errors were encountered:
z3s issue #70
a5eed8f
No branches or pull requests
Gas Optimizations
Saving some
SLOAD
s insendToSplitter()
:https://github.com/code-423n4/2022-03-joyn/blob/main/royalty-vault/contracts/RoyaltyVault.sol#L31
cache
splitterProxy
,royaltyAsset
,platformFeeRecipient
insendToSplitter()
.each direct read of state vars cost 100 gas.
Use
calldata
instead ofmemory
increateProject()
:https://github.com/code-423n4/2022-03-joyn/blob/main/core-contracts/contracts/CoreFactory.sol#L72
For external function's dynamic params, calldata is the cheapest location to use.
Recommended Mitigation Steps:
Change params
memory
tocalldata
Use Custom Errors to save Gas:
Custom errors from Solidity 0.8.4 are cheaper than
require
messages.https://blog.soliditylang.org/2021/04/21/custom-errors/
++i
use less gas thani++
:https://github.com/code-423n4/2022-03-joyn/blob/main/core-contracts/contracts/CoreCollection.sol#L279
https://github.com/code-423n4/2022-03-joyn/blob/main/core-contracts/contracts/CoreFactory.sol#L79
https://github.com/code-423n4/2022-03-joyn/blob/main/splits/contracts/Splitter.sol#L50
https://github.com/code-423n4/2022-03-joyn/blob/main/splits/contracts/Splitter.sol#L274
Redundant
== true
in require:transfer
return boolean andrequire
expect a boolean. so removing these== true
can save some gas:https://github.com/code-423n4/2022-03-joyn/blob/main/royalty-vault/contracts/RoyaltyVault.sol#L44
https://github.com/code-423n4/2022-03-joyn/blob/main/royalty-vault/contracts/RoyaltyVault.sol#L48
https://github.com/code-423n4/2022-03-joyn/blob/main/royalty-vault/contracts/RoyaltyVault.sol#L55
The text was updated successfully, but these errors were encountered: