Skip to content

Commit

Permalink
for some reason Cache.sol was not updated
Browse files Browse the repository at this point in the history
  • Loading branch information
teryanarmen committed May 23, 2024
1 parent 96df407 commit 1ad2946
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/EVault/shared/Cache.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,20 @@ contract Cache is Storage, Errors {
/ (uint256(CONFIG_SCALE) << INTERNAL_DEBT_PRECISION_SHIFT);

if (feeAssets != 0) {
// Fee shares are minted at a slightly worse price than user deposits (unless the exchange rate of shares to assets is < 1,
// which is only possible in an extreme case of large debt socialization).
// The discrepancy arises because, firstly, the virtual deposit is not accounted for, and secondly, all new
// interest is included in the total assets during the minting process, whereas during a regular user operation, the pre-money conversion
// is performed.
// This behavior is considered safe and reduces code complexity and gas costs, while its effect is positive for
// regular users (unless the exchange rate is abnormally < 1)
// Fee shares are minted at a slightly worse price than user deposits (unless the exchange rate of
// shares to assets is < 1, which is only possible in an extreme case of large debt socialization). The
// discrepancy arises because, firstly, the virtual deposit is not accounted for, and secondly, all new
// interest is included in the total assets during the minting process, whereas during a regular user
// operation, the pre-money conversion is performed. This behavior is considered safe and reduces code
// complexity and gas costs, while its effect is positive for regular users (unless the exchange rate is
// abnormally < 1)
uint256 newTotalAssets = vaultCache.cash.toUint() + OwedLib.toAssetsUpUint(newTotalBorrows);
newTotalShares = newTotalAssets * newTotalShares / (newTotalAssets - feeAssets);
newAccumulatedFees += newTotalShares - vaultCache.totalShares.toUint();
}

// Store new values in vaultCache, only if no overflows will occur. Fees are not larger than total shares, since they are included in them.

// Store new values in vaultCache, only if no overflows will occur. Fees are not larger than total shares,
// since they are included in them.
if (newTotalBorrows <= MAX_SANE_DEBT_AMOUNT) {
vaultCache.totalBorrows = newTotalBorrows.toOwed();
vaultCache.interestAccumulator = newInterestAccumulator;
Expand All @@ -132,4 +132,4 @@ contract Cache is Storage, Errors {
// total assets can exceed Assets max amount (MAX_SANE_AMOUNT)
return vaultCache.cash.toUint() + vaultCache.totalBorrows.toAssetsUp().toUint();
}
}
}

0 comments on commit 1ad2946

Please sign in to comment.