Omniscia Astrolab DAO Audit
ChainlinkUtils Code Style Findings
ChainlinkUtils Code Style Findings
CUS-01C: Ineffectual Usage of Safe Arithmetics
Type | Severity | Location |
---|---|---|
Language Specific | ![]() | ChainlinkUtils.sol:L29, L30 |
Description:
The linked mathematical operation is guaranteed to be performed safely by surrounding conditionals evaluated in either require
checks or if-else
constructs.
Example:
27// debase pyth feed decimals to target decimals28return _targetDecimals >= feedDecimals ?29 uint256(basePrice) * 10 ** uint32(_targetDecimals - feedDecimals) :30 uint256(basePrice) / 10 ** uint32(feedDecimals - _targetDecimals);
Recommendation:
Given that safe arithmetics are toggled on by default in pragma
versions of 0.8.X
, we advise the linked statement to be wrapped in an unchecked
code block thereby optimizing its execution cost.
Alleviation (59b75fbee1):
The relevant statement has been significantly refactored and now lives under the ChainlinkProvider::_toUsdBp
, wrapped in an unchecked
code block.
We do not consider the present unchecked
code block introduced to be safe, as it relies on an _invert
flag instead of the actual relation between the variables subtracted thus rendering this exhibit not validated to highlight the fact of this insecurity.
Alleviation (efbeab6478):
The Astrolab DAO team opted to revert the unchecked
code block's introduction, ensuring that the statements are performed safely yet inefficiently per their original implementation.
As such, we consider this exhibit acknowledged as the Astrolab DAO team does not intend to apply the optimization properly.
CUS-02C: Repetitive Value Literal
Type | Severity | Location |
---|---|---|
Code Style | ![]() | ChainlinkUtils.sol:L49, L50 |
Description:
The linked value literal is repeated across the codebase multiple times.
Example:
49return getPriceUsd(_feeds[0], _validities[0], 18)
Recommendation:
We advise it to be set to a constant
variable instead optimizing the legibility of the codebase.
Alleviation (59b75fbee1d8f3dee807c928f18be41c58b904e1):
The referenced value literal now lives under the PriceProvider
implementation and specifically the USD_DECIMALS
constant variable, addressing this exhibit.