mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Added tracking of the usage as collateral to the liquidationCall
This commit is contained in:
parent
c8e59ca950
commit
a3ee5d2ce6
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user