diff --git a/contracts/interfaces/ILendingPoolCollateralManager.sol b/contracts/interfaces/ILendingPoolCollateralManager.sol new file mode 100644 index 00000000..39244896 --- /dev/null +++ b/contracts/interfaces/ILendingPoolCollateralManager.sol @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity 0.6.12; + +/** + * @title ILendingPoolCollateralManager interface + * @author Aave + * @notice Defines the actions involving management of collateral in the protocol. + **/ +interface ILendingPoolCollateralManager { + /** + * @dev emitted when a borrower is liquidated + * @param collateral the address of the collateral being liquidated + * @param principal the address of the reserve + * @param user the address of the user being liquidated + * @param debtToCover the total amount liquidated + * @param liquidatedCollateralAmount the amount of collateral being liquidated + * @param liquidator the address of the liquidator + * @param receiveAToken true if the liquidator wants to receive aTokens, false otherwise + **/ + event LiquidationCall( + address indexed collateral, + address indexed principal, + address indexed user, + uint256 debtToCover, + uint256 liquidatedCollateralAmount, + address liquidator, + 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); + + /** + * @dev users can invoke this function to liquidate an undercollateralized position. + * @param collateral the address of the collateral to liquidated + * @param principal the address of the principal reserve + * @param user the address of the borrower + * @param debtToCover the amount of principal that the liquidator wants to repay + * @param receiveAToken true if the liquidators wants to receive the aTokens, false if + * he wants to receive the underlying asset directly + **/ + function liquidationCall( + address collateral, + address principal, + address user, + uint256 debtToCover, + bool receiveAToken + ) external virtual returns (uint256, string memory); +} diff --git a/contracts/protocol/lendingpool/LendingPool.sol b/contracts/protocol/lendingpool/LendingPool.sol index 1d8ef520..0649e011 100644 --- a/contracts/protocol/lendingpool/LendingPool.sol +++ b/contracts/protocol/lendingpool/LendingPool.sol @@ -19,7 +19,6 @@ import {UserConfiguration} from '../libraries/configuration/UserConfiguration.so import {IStableDebtToken} from '../tokenization/interfaces/IStableDebtToken.sol'; import {IVariableDebtToken} from '../tokenization/interfaces/IVariableDebtToken.sol'; import {IFlashLoanReceiver} from '../../flashloan/interfaces/IFlashLoanReceiver.sol'; -import {LendingPoolCollateralManager} from './LendingPoolCollateralManager.sol'; // TODO change to interface import {IPriceOracleGetter} from '../../interfaces/IPriceOracleGetter.sol'; import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; import {ILendingPool} from '../../interfaces/ILendingPool.sol'; diff --git a/contracts/protocol/lendingpool/LendingPoolCollateralManager.sol b/contracts/protocol/lendingpool/LendingPoolCollateralManager.sol index bc8aab09..5e9d16ba 100644 --- a/contracts/protocol/lendingpool/LendingPoolCollateralManager.sol +++ b/contracts/protocol/lendingpool/LendingPoolCollateralManager.sol @@ -8,6 +8,7 @@ import {IAToken} from '../tokenization/interfaces/IAToken.sol'; import {IStableDebtToken} from '../tokenization/interfaces/IStableDebtToken.sol'; import {IVariableDebtToken} from '../tokenization/interfaces/IVariableDebtToken.sol'; import {IPriceOracleGetter} from '../../interfaces/IPriceOracleGetter.sol'; +import {ILendingPoolCollateralManager} from '../../interfaces/ILendingPoolCollateralManager.sol'; import {GenericLogic} from '../libraries/logic/GenericLogic.sol'; import {ReserveLogic} from '../libraries/logic/ReserveLogic.sol'; import {UserConfiguration} from '../libraries/configuration/UserConfiguration.sol'; @@ -26,7 +27,7 @@ import {LendingPoolStorage} from './LendingPoolStorage.sol'; * @notice this contract will be ran always through delegatecall * @dev LendingPoolCollateralManager inherits VersionedInitializable from OpenZeppelin to have the same storage layout as LendingPool **/ -contract LendingPoolCollateralManager is VersionedInitializable, LendingPoolStorage { +contract LendingPoolCollateralManager is ILendingPoolCollateralManager, VersionedInitializable, LendingPoolStorage { using SafeERC20 for IERC20; using SafeMath for uint256; using WadRayMath for uint256; @@ -37,33 +38,6 @@ contract LendingPoolCollateralManager is VersionedInitializable, LendingPoolStor uint256 internal constant LIQUIDATION_CLOSE_FACTOR_PERCENT = 5000; - /** - * @dev emitted when a borrower is liquidated - * @param collateral the address of the collateral being liquidated - * @param principal the address of the reserve - * @param user the address of the user being liquidated - * @param debtToCover the total amount liquidated - * @param liquidatedCollateralAmount the amount of collateral being liquidated - * @param liquidator the address of the liquidator - * @param receiveAToken true if the liquidator wants to receive aTokens, false otherwise - **/ - event LiquidationCall( - address indexed collateral, - address indexed principal, - address indexed user, - uint256 debtToCover, - uint256 liquidatedCollateralAmount, - address liquidator, - 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; @@ -117,7 +91,7 @@ contract LendingPoolCollateralManager is VersionedInitializable, LendingPoolStor address user, uint256 debtToCover, bool receiveAToken - ) external returns (uint256, string memory) { + ) external override returns (uint256, string memory) { ReserveLogic.ReserveData storage collateralReserve = _reserves[collateral]; ReserveLogic.ReserveData storage principalReserve = _reserves[principal]; UserConfiguration.Map storage userConfig = _usersConfig[user];