diff --git a/contracts/lendingpool/LendingPool.sol b/contracts/lendingpool/LendingPool.sol index 963ef7cf..400276e4 100644 --- a/contracts/lendingpool/LendingPool.sol +++ b/contracts/lendingpool/LendingPool.sol @@ -262,15 +262,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage ReserveLogic.InterestRateMode interestRateMode = ReserveLogic.InterestRateMode(rateMode); - //default to max amount - uint256 paybackAmount = interestRateMode == ReserveLogic.InterestRateMode.STABLE - ? stableDebt - : variableDebt; - - if (amount < paybackAmount) { - paybackAmount = amount; - } - ValidationLogic.validateRepay( reserve, amount, @@ -280,6 +271,15 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage variableDebt ); + //default to max amount + uint256 paybackAmount = interestRateMode == ReserveLogic.InterestRateMode.STABLE + ? stableDebt + : variableDebt; + + if (amount < paybackAmount) { + paybackAmount = amount; + } + reserve.updateState(); //burns an equivalent amount of debt tokens