fix: update behavior of finalizeTransfer() to proper emit the ReserveUsedAsCollateralDisabled event

This commit is contained in:
The3D 2021-05-14 20:00:37 +02:00
parent 9d12200b8c
commit 49db36726b

View File

@ -725,20 +725,21 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
if (from != to) {
DataTypes.UserConfigurationMap storage fromConfig = _usersConfig[from];
if (fromConfig.isUsingAsCollateral(reserveId) && fromConfig.isBorrowingAny()) {
ValidationLogic.validateHealthFactor(
from,
_reserves,
_usersConfig[from],
_reservesList,
_reservesCount,
_addressesProvider.getPriceOracle()
);
}
if (balanceFromBefore.sub(amount) == 0) {
fromConfig.setUsingAsCollateral(reserveId, false);
emit ReserveUsedAsCollateralDisabled(asset, from);
if (fromConfig.isUsingAsCollateral(reserveId)) {
if (fromConfig.isBorrowingAny()) {
ValidationLogic.validateHealthFactor(
from,
_reserves,
_usersConfig[from],
_reservesList,
_reservesCount,
_addressesProvider.getPriceOracle()
);
}
if (balanceFromBefore.sub(amount) == 0) {
fromConfig.setUsingAsCollateral(reserveId, false);
emit ReserveUsedAsCollateralDisabled(asset, from);
}
}
if (balanceToBefore == 0 && amount != 0) {