mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
refactor: further refactored the CachingHelper
This commit is contained in:
parent
360e83fd05
commit
044b492f7f
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user