Omniscia Euler Finance Audit

Cache Code Style Findings

Cache Code Style Findings

CEH-01C: Inconsistent Unwrapping Mechanism

TypeSeverityLocation
Code StyleCache.sol:L94, L101, L111

Description:

The Shares data type is converted to its uint256 representation either via the dedicated SharesLib::toUint function or via the native Shares::unwrap function.

Example:

src/EVault/shared/Cache.sol
94uint256 newTotalShares = vaultCache.totalShares.toUint();
95uint256 feeAssets =
96 interestFee.mulDiv(newTotalBorrows - vaultCache.totalBorrows.toUint(), 1 << INTERNAL_DEBT_PRECISION);
97
98if (feeAssets != 0) {
99 uint256 newTotalAssets = vaultCache.cash.toUint() + (newTotalBorrows >> INTERNAL_DEBT_PRECISION);
100 newTotalShares = newTotalAssets * newTotalShares / (newTotalAssets - feeAssets);
101 newAccumulatedFees += newTotalShares - vaultCache.totalShares.toUint();
102}
103
104// Store new values in vaultCache, only if no overflows will occur. Fees are not larger than total shares, since they are included in them.
105
106if (newTotalShares <= MAX_SANE_AMOUNT && newTotalBorrows <= MAX_SANE_DEBT_AMOUNT) {
107 vaultCache.totalBorrows = newTotalBorrows.toOwed();
108 vaultCache.interestAccumulator = newInterestAccumulator;
109 vaultCache.lastInterestAccumulatorUpdate = uint48(block.timestamp);
110
111 if (newTotalShares != Shares.unwrap(vaultCache.totalShares)) {

Recommendation:

We advise a uniform approach to be utilized, ensuring consistency in the codebase as the result of those functions is identical.

Alleviation (fb2dd77a6ff9b7f710edb48e7eb5437e0db4fc1a):

The Shares::unwrap type-based function has been replaced by the SharesLib::toUint function, ensuring consistency across the contract as advised.