Merge branch 'fix/127' into 'master'

Resolve "Add setIsUsingAsCollateral(false) in liquidation if the whole user collateral is being liquidated"

Closes #127

See merge request aave-tech/protocol-v2!147
This commit is contained in:
Ernesto Boado 2020-11-10 15:25:18 +00:00
commit 084dfd1c9a

View File

@ -57,6 +57,13 @@ contract LendingPoolCollateralManager is VersionedInitializable, LendingPoolStor
bool receiveAToken
);
/**
* @dev emitted when a user disables a reserve as collateral
* @param reserve the address of the reserve
* @param user the address of the user
**/
event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user);
struct LiquidationCallLocalVars {
uint256 userCollateralBalance;
uint256 userStableDebt;
@ -120,7 +127,7 @@ contract LendingPoolCollateralManager is VersionedInitializable, LendingPoolStor
(, , , , vars.healthFactor) = GenericLogic.calculateUserAccountData(
user,
_reserves,
_usersConfig[user],
userConfig,
_reservesList,
_reservesCount,
_addressesProvider.getPriceOracle()
@ -246,6 +253,14 @@ contract LendingPoolCollateralManager is VersionedInitializable, LendingPoolStor
);
}
//if the collateral being liquidated is equal to the user balance,
//we set the currency as not being used as collateral anymore
if (vars.maxCollateralToLiquidate == vars.userCollateralBalance) {
userConfig.setUsingAsCollateral(collateralReserve.id, false);
emit ReserveUsedAsCollateralDisabled(collateral, user);
}
//transfers the principal currency to the aToken
IERC20(principal).safeTransferFrom(
msg.sender,