code-423n4 / 2022-10-inverse-findings

0 stars 0 forks source link

Gas Optimizations #582

Closed code423n4 closed 1 year ago

code423n4 commented 1 year ago

Issue 1: Events missing indexed fields

Instances: 5

Github Links:

S/N Link
1 DBR.sol
2 DBR.sol
3 Fed.sol
4 Market.sol
5 Oracle.sol

Issue 2: Size of string variables set are larger than needed, costing more gas than fixed size with bytes36

Instances: 2

Github Links:

S/N Link
1 DBR.sol
2 DBR.sol

Issue 3: Use Custom Errors instead of rever()/require() strings to save gas

Instances: 76

Github Links:

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Oracle.sol#L143

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/escrows/SimpleERC20Escrow.sol#L26

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/escrows/SimpleERC20Escrow.sol#L37

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/escrows/INVEscrow.sol#L45

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/escrows/INVEscrow.sol#L60

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/escrows/INVEscrow.sol#L91

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/escrows/GovTokenEscrow.sol#L44

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/escrows/GovTokenEscrow.sol#L31

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/escrows/GovTokenEscrow.sol#L67

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Oracle.sol#L36

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Oracle.sol#L67

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Oracle.sol#L83

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Oracle.sol#L117

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Market.sol#L74-L76

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Market.sol#L93

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Market.sol#L74-L76

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Market.sol#L93

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Market.sol#L150

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Market.sol#L162

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Market.sol#L173

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Market.sol#L184

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Market.sol#L195

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Market.sol#L204

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Market.sol#L214

https://github.com/code-423n4/2022-10-inverse/blob/3e81f0f5908ea99b36e6ab72f13488bbfe622183/src/Market.sol#L216

S/N Link
1 Fed.sol
2 Fed.sol
3 Fed.sol
4 Fed.sol
5 Fed.sol
6 Fed.sol
7 Fed.sol
8 Fed.sol
9 Fed.sol
10 Fed.sol
11 DBR.sol
12 DBR.sol
13 DBR.sol
14 DBR.sol
15 DBR.sol
16 DBR.sol
17 DBR.sol
18 DBR.sol
19 DBR.sol
20 DBR.sol
21 DBR.sol
22 DBR.sol
23 DBR.sol
24 DBR.sol
25 DBR.sol
26 DBR.sol
27 DBR.sol
28 DBR.sol
29 DBR.sol
30 BorrowController.sol
31 Market.sol
32 Market.sol
33 Market.sol
34 Market.sol
35 Market.sol
36 Market.sol
37 Market.sol
38 Market.sol
39 Market.sol
40 Market.sol
41 Market.sol
42 Market.sol
43 Market.sol
44 Market.sol
44 Market.sol
45 Market.sol
46 Market.sol
47 Market.sol
48 Market.sol

Issue 4: Modifiers cost more gas than normal functions

Instances: 4

Github Links:

S/N Link
1 BorrowController.sol
2 DBR.sol
3 Market.sol
4 Oracle.sol
c4-judge commented 1 year ago

0xean marked the issue as grade-c