Omniscia Gravita Protocol Audit
PriceFeed Code Style Findings
PriceFeed Code Style Findings
PFD-01C: Inexistent Error Message
Type | Severity | Location |
---|---|---|
Code Style | ![]() | PriceFeed.sol:L60 |
Description:
The linked require
check has no error message explicitly defined.
Example:
60require(!isInitialized);
Recommendation:
We advise one to be set so to increase the legibility of the codebase and aid in validating the require
check's condition.
Alleviation:
The require
check is no longer present in the codebase rendering this exhibit no longer applicable.
PFD-02C: Redundant External Self-Calls
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | PriceFeed.sol:L149, L171 |
Description:
The referenced statements perform external calls to self via the this.fetchPrice
syntax redundantly.
Example:
148function _calcEthPrice(uint256 ethAmount) internal returns (uint256) {149 uint256 ethPrice = this.fetchPrice(address(0));150 return ethPrice.mul(ethAmount).div(1 ether);151}
Recommendation:
We advise the PriceFeed::fetchPrice
function to be set as public
and the calls to be made "internally" by removing the this
call prefix.
Alleviation:
The second referenced instance is no longer present in the codebase whereas the first instance has been properly corrected to perform an "internal" call rather than an "external" self-call.
PFD-03C: Redundant Function Implementation
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | PriceFeed.sol:L183-L185 |
Description:
The referenced function yields a contract-level constant
variable.
Example:
183function _getOracleUpdateTimelock() internal view virtual returns (uint256) {184 return ORACLE_UPDATE_TIMELOCK;185}
Recommendation:
We advise it to be omitted and invocations of it to be replaced by the constant
itself.
Alleviation:
The redundant function has been safely removed from the codebase as advised.
PFD-04C: Redundant Initialization Paradigm
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | PriceFeed.sol:L33, L59-L61 |
Description:
The PriceFeed
contract inherits the OpenZeppelin OwnableUpgradeable
implementation which contains the Initializable
implementation, put in use within the PriceFeed::setAddresses
function. As such, the manual isInitialized
flag is redundant.
Example:
54function setAddresses(55 address _adminContract,56 address _rethToken,57 address _stethToken,58 address _wstethToken59) external initializer {60 require(!isInitialized);61 isInitialized = true;62 __Ownable_init();63 adminContract = _adminContract;64 rethToken = _rethToken;65 stethToken = _stethToken;66 wstethToken = _wstethToken;67}
Recommendation:
We advise it and its validations to be omitted from the codebase as it is ineffectual and duplicates the purpose of the Initializable::initializer
modifier.
Alleviation:
The manual initialization methodology has been removed from the contract as advised.
PFD-05C: Suboptimal Struct Declaration Styles
Type | Severity | Location |
---|---|---|
Code Style | ![]() | PriceFeed.sol:L80, L82 |
Description:
The linked declaration styles of the referenced structs are using index-based argument initialization.
Example:
80queuedOracles[_token] = OracleRecord(newOracle, timelockRelease, true, true, _isEthIndexed);
Recommendation:
We advise the key-value declaration format to be utilized instead in each instance, greatly increasing the legibility of the codebase.
Alleviation:
The key-value declaration style is now in use in the code that both instances have been merged to, alleviating this exhibit.