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,
|
onBehalfOf,
|
||||||
amount,
|
amount,
|
||||||
interestRateMode,
|
interestRateMode,
|
||||||
reserve.aTokenAddress,
|
|
||||||
referralCode,
|
referralCode,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
@ -542,7 +541,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
onBehalfOf,
|
onBehalfOf,
|
||||||
vars.currentAmount,
|
vars.currentAmount,
|
||||||
modes[vars.i],
|
modes[vars.i],
|
||||||
vars.currentATokenAddress,
|
|
||||||
referralCode,
|
referralCode,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
@ -877,7 +875,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
||||||
address onBehalfOf;
|
address onBehalfOf;
|
||||||
uint256 amount;
|
uint256 amount;
|
||||||
uint256 interestRateMode;
|
uint256 interestRateMode;
|
||||||
address aTokenAddress;
|
|
||||||
uint16 referralCode;
|
uint16 referralCode;
|
||||||
bool releaseUnderlying;
|
bool releaseUnderlying;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ contract LendingPoolCollateralManager is
|
||||||
debtReserve.updateState(debtReserveCachedData);
|
debtReserve.updateState(debtReserveCachedData);
|
||||||
|
|
||||||
if (vars.userVariableDebt >= vars.actualDebtToLiquidate) {
|
if (vars.userVariableDebt >= vars.actualDebtToLiquidate) {
|
||||||
IVariableDebtToken(debtReserve.variableDebtTokenAddress).burn(
|
IVariableDebtToken(debtReserveCachedData.variableDebtTokenAddress).burn(
|
||||||
user,
|
user,
|
||||||
vars.actualDebtToLiquidate,
|
vars.actualDebtToLiquidate,
|
||||||
debtReserveCachedData.newVariableBorrowIndex
|
debtReserveCachedData.newVariableBorrowIndex
|
||||||
|
|
|
@ -39,18 +39,16 @@ library CachingHelper {
|
||||||
{
|
{
|
||||||
CachedData memory cachedData;
|
CachedData memory cachedData;
|
||||||
|
|
||||||
|
cachedData.reserveConfiguration = reserveData.configuration;
|
||||||
cachedData.oldLiquidityIndex = reserveData.liquidityIndex;
|
cachedData.oldLiquidityIndex = reserveData.liquidityIndex;
|
||||||
cachedData.oldVariableBorrowIndex = reserveData.variableBorrowIndex;
|
cachedData.oldVariableBorrowIndex = reserveData.variableBorrowIndex;
|
||||||
|
cachedData.oldLiquidityRate = reserveData.currentLiquidityRate;
|
||||||
|
cachedData.oldVariableBorrowRate = reserveData.currentVariableBorrowRate;
|
||||||
|
|
||||||
cachedData.aTokenAddress = reserveData.aTokenAddress;
|
cachedData.aTokenAddress = reserveData.aTokenAddress;
|
||||||
cachedData.stableDebtTokenAddress = reserveData.stableDebtTokenAddress;
|
cachedData.stableDebtTokenAddress = reserveData.stableDebtTokenAddress;
|
||||||
cachedData.variableDebtTokenAddress = reserveData.variableDebtTokenAddress;
|
cachedData.variableDebtTokenAddress = reserveData.variableDebtTokenAddress;
|
||||||
|
|
||||||
cachedData.reserveConfiguration = reserveData.configuration;
|
|
||||||
|
|
||||||
cachedData.oldLiquidityRate = reserveData.currentLiquidityRate;
|
|
||||||
cachedData.oldVariableBorrowRate = reserveData.currentVariableBorrowRate;
|
|
||||||
|
|
||||||
cachedData.reserveLastUpdateTimestamp = reserveData.lastUpdateTimestamp;
|
cachedData.reserveLastUpdateTimestamp = reserveData.lastUpdateTimestamp;
|
||||||
|
|
||||||
cachedData.oldScaledVariableDebt = cachedData.newScaledVariableDebt = IVariableDebtToken(
|
cachedData.oldScaledVariableDebt = cachedData.newScaledVariableDebt = IVariableDebtToken(
|
||||||
|
|
|
@ -273,17 +273,17 @@ library ReserveLogic {
|
||||||
|
|
||||||
//calculate the stable debt until the last timestamp update
|
//calculate the stable debt until the last timestamp update
|
||||||
vars.cumulatedStableInterest = MathUtils.calculateCompoundedInterest(
|
vars.cumulatedStableInterest = MathUtils.calculateCompoundedInterest(
|
||||||
vars.avgStableRate,
|
cachedData.oldAvgStableBorrowRate,
|
||||||
vars.stableSupplyUpdatedTimestamp,
|
cachedData.stableDebtLastUpdateTimestamp,
|
||||||
cachedData.reserveLastUpdateTimestamp
|
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
|
//debt accrued is the sum of the current debt minus the sum of the debt at the last update
|
||||||
vars.totalDebtAccrued = vars
|
vars.totalDebtAccrued = vars
|
||||||
.currentVariableDebt
|
.currentVariableDebt
|
||||||
.add(vars.currentStableDebt)
|
.add(cachedData.oldTotalStableDebt)
|
||||||
.sub(vars.previousVariableDebt)
|
.sub(vars.previousVariableDebt)
|
||||||
.sub(vars.previousStableDebt);
|
.sub(vars.previousStableDebt);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user