refactor: further refactored the CachingHelper

This commit is contained in:
The3D 2021-06-04 14:47:02 +02:00
parent 360e83fd05
commit 044b492f7f
4 changed files with 8 additions and 13 deletions

View File

@ -198,7 +198,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
onBehalfOf,
amount,
interestRateMode,
reserve.aTokenAddress,
referralCode,
true
)
@ -542,7 +541,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
onBehalfOf,
vars.currentAmount,
modes[vars.i],
vars.currentATokenAddress,
referralCode,
false
)
@ -877,7 +875,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
address onBehalfOf;
uint256 amount;
uint256 interestRateMode;
address aTokenAddress;
uint16 referralCode;
bool releaseUnderlying;
}

View File

@ -166,7 +166,7 @@ contract LendingPoolCollateralManager is
debtReserve.updateState(debtReserveCachedData);
if (vars.userVariableDebt >= vars.actualDebtToLiquidate) {
IVariableDebtToken(debtReserve.variableDebtTokenAddress).burn(
IVariableDebtToken(debtReserveCachedData.variableDebtTokenAddress).burn(
user,
vars.actualDebtToLiquidate,
debtReserveCachedData.newVariableBorrowIndex

View File

@ -39,18 +39,16 @@ library CachingHelper {
{
CachedData memory cachedData;
cachedData.reserveConfiguration = reserveData.configuration;
cachedData.oldLiquidityIndex = reserveData.liquidityIndex;
cachedData.oldVariableBorrowIndex = reserveData.variableBorrowIndex;
cachedData.oldLiquidityRate = reserveData.currentLiquidityRate;
cachedData.oldVariableBorrowRate = reserveData.currentVariableBorrowRate;
cachedData.aTokenAddress = reserveData.aTokenAddress;
cachedData.stableDebtTokenAddress = reserveData.stableDebtTokenAddress;
cachedData.variableDebtTokenAddress = reserveData.variableDebtTokenAddress;
cachedData.reserveConfiguration = reserveData.configuration;
cachedData.oldLiquidityRate = reserveData.currentLiquidityRate;
cachedData.oldVariableBorrowRate = reserveData.currentVariableBorrowRate;
cachedData.reserveLastUpdateTimestamp = reserveData.lastUpdateTimestamp;
cachedData.oldScaledVariableDebt = cachedData.newScaledVariableDebt = IVariableDebtToken(

View File

@ -273,17 +273,17 @@ library ReserveLogic {
//calculate the stable debt until the last timestamp update
vars.cumulatedStableInterest = MathUtils.calculateCompoundedInterest(
vars.avgStableRate,
vars.stableSupplyUpdatedTimestamp,
cachedData.oldAvgStableBorrowRate,
cachedData.stableDebtLastUpdateTimestamp,
cachedData.reserveLastUpdateTimestamp
);
vars.previousStableDebt = vars.principalStableDebt.rayMul(vars.cumulatedStableInterest);
vars.previousStableDebt = cachedData.oldPrincipalStableDebt.rayMul(vars.cumulatedStableInterest);
//debt accrued is the sum of the current debt minus the sum of the debt at the last update
vars.totalDebtAccrued = vars
.currentVariableDebt
.add(vars.currentStableDebt)
.add(cachedData.oldTotalStableDebt)
.sub(vars.previousVariableDebt)
.sub(vars.previousStableDebt);