Open code423n4 opened 2 years ago
WatchPug
https://github.com/code-423n4/2021-12-perennial/blob/fd7c38823833a51ae0c6ae3856a3d93a7309c0e4/protocol/contracts/oracle/ChainlinkOracle.sol#L20-L20
IChainlinkFeed public feed;
https://github.com/code-423n4/2021-12-perennial/blob/fd7c38823833a51ae0c6ae3856a3d93a7309c0e4/protocol/contracts/oracle/ChainlinkOracle.sol#L29-L29
uint256 private _decimalOffset;
In ChainlinkOracle.sol, feed and _decimalOffset will never change, use immutable variables instead of storage variables can save gas.
ChainlinkOracle.sol
feed
_decimalOffset
https://github.com/code-423n4/2021-12-perennial/blob/fd7c38823833a51ae0c6ae3856a3d93a7309c0e4/protocol/contracts/product/ProductProviderBase.sol#L13-L13
IOracle public oracle;
In ProductProviderBase.sol, oracle will never change, use immutable variables instead of storage variables can save gas.
ProductProviderBase.sol
oracle
Finding is valid, for any variable that is only set once, either use a constant or immutable to save gas
Handle
WatchPug
Vulnerability details
https://github.com/code-423n4/2021-12-perennial/blob/fd7c38823833a51ae0c6ae3856a3d93a7309c0e4/protocol/contracts/oracle/ChainlinkOracle.sol#L20-L20
https://github.com/code-423n4/2021-12-perennial/blob/fd7c38823833a51ae0c6ae3856a3d93a7309c0e4/protocol/contracts/oracle/ChainlinkOracle.sol#L29-L29
In
ChainlinkOracle.sol
,feed
and_decimalOffset
will never change, use immutable variables instead of storage variables can save gas.https://github.com/code-423n4/2021-12-perennial/blob/fd7c38823833a51ae0c6ae3856a3d93a7309c0e4/protocol/contracts/product/ProductProviderBase.sol#L13-L13
In
ProductProviderBase.sol
,oracle
will never change, use immutable variables instead of storage variables can save gas.