Omniscia Moby Audit
Vault Code Style Findings
Vault Code Style Findings
VTL-01C: Deprecated Revert Pattern
Type | Severity | Location |
---|---|---|
Standard Conformity | Vault.sol:L405 |
Description:
The referenced revert
statement will yield a textual description of the error which is an abandoned practice.
Example:
405if (poolAmounts[_tokenOut] < bufferAmounts[_tokenOut]) revert("Vault: poolAmount < buffer");
Recommendation:
We advise a custom error
declaration to be introduced to the Vault
and consequently utilized in place of the referenced message, optimizing the code's gas cost as well as legibility.
Alleviation (a8720219a6a97e10b8d9c6a70c6345747f0fdcb3):
The referenced if-revert
pattern has been updated to a require
check, addressing this exhibit.
VTL-02C: Ineffectual Usage of Safe Arithmetics
Type | Severity | Location |
---|---|---|
Language Specific | Vault.sol:L138, L142, L843, L864, L876, L888 |
Description:
The linked mathematical operation is guaranteed to be performed safely by surrounding conditionals evaluated in either require
checks or if-else
constructs.
Example:
137if (_amount > usdgAmount) {138 _increaseUsdgAmount(_token, _amount - usdgAmount);139 return;140}141
142_decreaseUsdgAmount(_token, usdgAmount - _amount);
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 (a8720219a6a97e10b8d9c6a70c6345747f0fdcb3):
All referenced arithmetic operations have been wrapped in an unchecked
code block safely, optimizing their gas cost whilst retaining their security guarantees via preceding conditionals.
VTL-03C: Repetitive Value Literal
Type | Severity | Location |
---|---|---|
Code Style | Vault.sol:L778, L805 |
Description:
The linked value literal is repeated across the codebase multiple times.
Example:
778uint256 maxFeeUsd = (_size * _executionPrice) / (10 ** tokenDecimals[_underlyingAsset]) * 5000 / BASIS_POINTS_DIVISOR; // Total Execution Priceģ 50%
Recommendation:
We advise it to be set to a constant
variable instead optimizing the legibility of the codebase.
Alleviation (b02fae335f62cc1f5f4236fb4d982ad16a32bd26):
The Moby team evaluated this exhibit but opted to acknowledge it in the current iteration of the codebase
VTL-04C: Unused Contract Member
Type | Severity | Location |
---|---|---|
Gas Optimization | Vault.sol:L28 |
Description:
The referenced member is assigned to several values, however, its value is never read.
Example:
28bool public useSwapPricing;
Recommendation:
We advise it to be removed from the codebase, optimizing the code's gas cost.
Alleviation (a8720219a6a97e10b8d9c6a70c6345747f0fdcb3):
The Moby team re-assessed this exhibit and clarified that they intend to use the variable in the future, rendering the original recommendation to remove it inapplicable.