code-423n4 / 2022-08-olympus-findings

5 stars 4 forks source link

Gas Optimizations #471

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Table of contents

Disclaimer

[G-01] Try ++i instead of i++

Description:

All occurances:

[G-02] Consider a = a + b instead of a += b

Description:

All occurances:

[G-03] Consider marking onlyOwner functions as payable

Description:

All occurances:

*[G-04] Use binary shifting instead of a / 2^x, x > 0 or `a 2^x, x > 0`**

Description:

All occurances:

[G-05] Cache state variables, MLOAD << SLOAD

Description:

All occurances:

[G-06] Add require() before some computations, if it makes sense

Description:

All occurances:

[G-07] Internal functions can be inlined

Description:

All occurances:

[G-08] Use private/internal for constants/immutable variables instead of public

Description:

All occurances:

[G-09] Use const values instead of type(uint256).max

Description:

All occurances:

[G-10] Mark functions as external instead of public, if there are no internal calls

Description:

All occurances:

Description:

All occurances:

Kudos for the quality of the code! It's pretty easy to explore