code-423n4 / 2022-03-volt-findings

0 stars 0 forks source link

Gas Optimizations #65

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Declare private function to save gas

invert function in OracleRef.sol can be declared private.

Proof of Concept

https://github.com/code-423n4/2022-03-volt/blob/main/contracts/refs/OracleRef.sol#L84

Recommendation

Declare the function to private.

Delete public volt() function and change _volt to internal

volt() function only returns _volt value. The function can be deleted and declare _volt internal to save gas.

Proof of Concept

https://github.com/code-423n4/2022-03-volt/blob/main/contracts/refs/CoreRef.sol#L12 https://github.com/code-423n4/2022-03-volt/blob/main/contracts/refs/CoreRef.sol#L193-L195

Recommendation

Change _volt to internal to allow inheriting contracts such as NonCustodialPSM to access directly.