fixed: fixed issue with index validation on variable debt

This commit is contained in:
emilio 2021-07-27 18:05:30 +02:00
parent 83d6f9c8be
commit c549da6f35
2 changed files with 6 additions and 6 deletions
contracts/protocol
lendingpool
libraries/logic

View File

@ -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);

View File

@ -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);