Omniscia Ultra Yield Audit
UltraVaultOracle Code Style Findings
UltraVaultOracle Code Style Findings
UVO-01C: Calculation Simplification
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | UltraVaultOracle.sol:L233 |
Description:
The referenced calculation can be simplified by merging exponentials into a single multiplication or division depending on the outcome.
Example:
233return inAmount * price * (10 ** quoteDecimals) / (10 ** (baseDecimals + 18));Recommendation:
We advise the powers to be summed and to perform a single multiplication or division with the relevant power of 10.
Alleviation (28f27853965de07fb79f4f2b5fed696d35120032):
The code was updated per our recommendation albeit ensuring that the denominatorDecimals are always greater than the nominatorDecimals, simplifying the calculation further.
UVO-02C: Ineffective Boolean Flag Management
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | UltraVaultOracle.sol:L195, L198, L199 |
Description:
The increase boolean is meant to indicate whether price.price <= price.targetPrice is true.
Example:
195bool increase;196uint256 diff;197
198if (price.price <= price.targetPrice) {199 increase = true;200 diff = price.targetPrice - price.price;201} else {202 diff = price.price - price.targetPrice;203}Recommendation:
We advise the increase flag to be assigned to the price.price <= price.targetPrice evaluation on its declaration and the if conditional to utilize the increase flag directly, optimizing the code's gas cost.
Alleviation (28f27853965de07fb79f4f2b5fed696d35120032):
The increase flag's assignment has been revised as advised, optimizing the code's gas cost.
UVO-03C: Ineffectual Usage of Safe Arithmetics
| Type | Severity | Location |
|---|---|---|
| Language Specific | ![]() | UltraVaultOracle.sol: • I-1: L200 • I-2: L202 |
Description:
The linked mathematical operations are guaranteed to be performed safely by surrounding conditionals evaluated in either require checks or if-else constructs.
Example:
198if (price.price <= price.targetPrice) {199 increase = true;200 diff = price.targetPrice - price.price;201} else {202 diff = price.price - price.targetPrice;203}Recommendation:
Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statements to be wrapped in unchecked code blocks thereby optimizing their execution cost.
Alleviation (28f27853965de07fb79f4f2b5fed696d35120032):
The referenced price delta calculations are now wrapped in an unchecked code block, optimizing the code's gas cost.
UVO-04C: Redundant Precision Concept
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | UltraVaultOracle.sol:L21, L207 |
Description:
The DECIMAL_PRECISION concept employed by the UltraVaultOracle::_getCurrentPrice function is ineffective as the extrapolation of the timeLeft is immediately offset after use, thereby resulting in no increase of the calculation's accuracy.
Example:
207uint256 change = diff - diff * timeLeft * DECIMAL_PRECISION / timeFull / DECIMAL_PRECISION;Recommendation:
We advise the concept to be entirely omitted, optimizing the code's gas cost.
While precision errors exist, they are detailed in a separate exhibit.
Alleviation (28f27853965de07fb79f4f2b5fed696d35120032):
The ineffective precision concept has been omitted from the code, optimizing its legibility and gas cost.
UVO-05C: Repetitive Value Literal
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | UltraVaultOracle.sol:L233, L252 |
Description:
The linked value literal is repeated across the codebase multiple times.
Example:
233return inAmount * price * (10 ** quoteDecimals) / (10 ** (baseDecimals + 18));Recommendation:
We advise it to be set to a constant variable instead, optimizing the legibility of the codebase.
In case the constant has already been declared, we advise it to be properly re-used across the code.
Alleviation (28f27853965de07fb79f4f2b5fed696d35120032):
The referenced value literal 18 has been properly relocated to a contract-level constant declaration labelled PRICE_FEED_DECIMALS, optimizing the code's legibility.
