code-423n4 / 2023-02-kuma-findings

2 stars 1 forks source link

Gas Optimizations #24

Open code423n4 opened 1 year ago

code423n4 commented 1 year ago

See the markdown file with the details of this report here.

GalloDaSballo commented 1 year ago

| GAS-1 | Use assembly to check for address(0) | 36 | Marginal

| GAS-2 | Using bools for storage incurs overhead | 2 | Marginal as it's not used often

| GAS-3 | Cache array length outside of loop | 3 | | GAS-4 | State variables should be cached in stack variables rather than re-reading them from storage | 3 | 200 (100 from _riskCategory and 100 from _KUMAAddressProvider)

| GAS-5 | Use calldata instead of memory for function arguments that do not get mutated | 13 | Valid for cBonds let's say 150 each * 2 300

| GAS-6 | Functions guaranteed to revert when called by normal users can be marked payable | 31 | | GAS-7 | ++i costs less gas than i++, especially when it's used in for-loops (--i/i-- too) | 3 | Let's say 100

| GAS-8 | Using private rather than public for constants, saves gas | 5 | | GAS-9 | Use != 0 instead of > 0 for unsigned integer comparison | 11 | Invalid after 0.8.13

Around 600 gas, report is generic but advice is good

c4-judge commented 1 year ago

GalloDaSballo marked the issue as grade-b

GalloDaSballo commented 1 year ago

Am going to award B for submitting acceptable advice, however, long-term I believe we want to see more nuanced and high impact reports such as the winning one