Omniscia Euler Finance Audit
YieldAggregatorVault Code Style Findings
YieldAggregatorVault Code Style Findings
YAV-01C: Ineffectual Usage of Safe Arithmetics
Type | Severity | Location |
---|---|---|
Language Specific | ![]() | YieldAggregatorVault.sol:L824 |
Description:
The linked mathematical operation is guaranteed to be performed safely by logical inference, such as surrounding conditionals evaluated in require
checks or if-else
constructs.
Example:
823if (lossAmount > totalNotDistributed) {824 lossAmount -= totalNotDistributed;
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:
The referenced arithmetic operation has been wrapped in an unchecked
code block as advised, optimizing its gas cost.
YAV-02C: Inefficient Re-Invocation of Function
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | YieldAggregatorVault.sol:L290, L297 |
Description:
The YieldAggregatorVaultModule::_balanceOf
function is invoked twice within the read-only YieldAggregatorVaultModule::maxRedeem
function inefficiently.
Example:
290uint256 ownerShares = _balanceOf(_owner);291uint256 assetsBeforeHarvest = _convertToAssets(ownerShares, Math.Rounding.Floor);292bool isOnlyCashReserveWithdraw = IERC20(_asset()).balanceOf(address(this)) >= assetsBeforeHarvest;293
294(uint256 totalAssetsExpected, uint256 totalSupplyExpected) =295 _previewHarvestBeforeWithdraw(isOnlyCashReserveWithdraw);296
297uint256 maxAssets = _balanceOf(_owner).mulDiv(298 totalAssetsExpected + 1, totalSupplyExpected + 10 ** _decimalsOffset(), Math.Rounding.Floor299);
Recommendation:
We advise the result to be cached to a local variable that is consequently reused similarly to the YieldAggregatorVaultModule::maxWithdraw
function.
Alleviation:
The second invocation of the function has been replaced by the ownerShares
variable itself, optimizing the code's gas cost.
YAV-03C: Redundant Parenthesis Statements
Type | Severity | Location |
---|---|---|
Code Style | ![]() | YieldAggregatorVault.sol:L504, L550, L554, L589, L733, L790, L865 |
Description:
The referenced statements are redundantly wrapped in parenthesis' (()
).
Example:
504uint256 withdrawAmount = (underlyingBalance >= desiredAssets) ? desiredAssets : underlyingBalance;
Recommendation:
We advise them to be safely omitted, increasing the legibility of the codebase.
Alleviation:
The Euler Finance team evaluated this exhibit but opted to acknowledge it in the current iteration of the codebase.