code-423n4 / 2022-06-nibbl-findings

1 stars 0 forks source link

Gas Optimizations #315

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

[Gas - 01] Use Custom Errors

Instead of using error strings, to reduce deployment and runtime cost, you should use Custom Errors: see https://blog.soliditylang.org/2021/04/21/custom-errors/. This would save both deployment and runtime cost.

Examples: 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#L49 https://github.com/code-423n4/2022-06-nibbl/blob/8c3dbd6adf350f35c58b31723d42117765644110/contracts/NibblVaultFactory.sol#L141

[Gas - 02] UPDATE_TIME could be changed to constant UPDATE_TIME is not changeable so could be changed to a constant or an immutable variable