mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
fixed: fixed issue with index validation on variable debt
This commit is contained in:
parent
83d6f9c8be
commit
c549da6f35
contracts/protocol
|
@ -894,6 +894,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
|
||||
DataTypes.InterestRateMode interestRateMode = DataTypes.InterestRateMode(rateMode);
|
||||
|
||||
reserve.updateState(reserveCache);
|
||||
ValidationLogic.validateRepay(
|
||||
reserveCache,
|
||||
asset,
|
||||
|
@ -911,8 +912,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
paybackAmount = amount;
|
||||
}
|
||||
|
||||
reserve.updateState(reserveCache);
|
||||
|
||||
if (interestRateMode == DataTypes.InterestRateMode.STABLE) {
|
||||
IStableDebtToken(reserveCache.stableDebtTokenAddress).burn(onBehalfOf, paybackAmount);
|
||||
reserveCache.refreshDebt(0, paybackAmount, 0, 0);
|
||||
|
|
|
@ -207,9 +207,10 @@ library ValidationLogic {
|
|||
vars.amountInBaseCurrency = vars.amountInBaseCurrency.mul(amount).div(10**vars.reserveDecimals);
|
||||
|
||||
//add the current already borrowed amount to the amount requested to calculate the total collateral needed.
|
||||
vars.collateralNeededInBaseCurrency = vars.userDebtInBaseCurrency.add(vars.amountInBaseCurrency).percentDiv(
|
||||
vars.currentLtv
|
||||
); //LTV is calculated in percentage
|
||||
vars.collateralNeededInBaseCurrency = vars
|
||||
.userDebtInBaseCurrency
|
||||
.add(vars.amountInBaseCurrency)
|
||||
.percentDiv(vars.currentLtv); //LTV is calculated in percentage
|
||||
|
||||
require(
|
||||
vars.collateralNeededInBaseCurrency <= vars.userCollateralInBaseCurrency,
|
||||
|
@ -280,7 +281,7 @@ library ValidationLogic {
|
|||
} else if (DataTypes.InterestRateMode(rateMode) == DataTypes.InterestRateMode.VARIABLE) {
|
||||
require(
|
||||
IVariableDebtToken(reserveCache.variableDebtTokenAddress).lastUserIndex(onBehalfOf) !=
|
||||
reserveCache.currVariableBorrowIndex,
|
||||
reserveCache.nextVariableBorrowIndex,
|
||||
Errors.VL_SAME_BLOCK_BORROW_REPAY
|
||||
);
|
||||
require(variableDebt > 0, Errors.VL_NO_DEBT_OF_SELECTED_TYPE);
|
||||
|
|
Loading…
Reference in New Issue
Block a user