Omniscia Platypus Finance Audit
ChainlinkProxyPriceProvider Code Style Findings
ChainlinkProxyPriceProvider Code Style Findings
CPP-01C: Redundant Storage Read
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | ChainlinkProxyPriceProvider.sol:L62, L64 |
Description:
The getAssetPrice
function redundantly reads the _assetsSources
storage entry when the asset
is equivalent to the _ethAddress
as it remains unutilized.
Example:
contracts/oracle/ChainlinkProxyPriceProvider.sol
59/// @notice Gets an asset price by address60/// @param asset The asset address61function getAssetPrice(address asset) public view override returns (uint256) {62 IChainlinkAggregator source = _assetsSources[asset];63 if (asset == _ethAddress) {64 return 1 ether;65 } else {66 // Require the asset has registered source67 require(address(source) != address(0), 'SOURCE_IS_MISSING');68
69 int256 price = IChainlinkAggregator(source).latestAnswer();70 require(price > 0, 'INVALID_PRICE');71
72 return uint256(price);73 }74}
Recommendation:
We advise the IChainlinkAggregator source
declaration to be relocated to the else
branch of the function optimizing its gas cost.
Alleviation:
The _ethAddress
member no longer exists in the contract and as such this exhibit can be considered null.