Added interface for LendingPoolLiquidationManager

This commit is contained in:
The3D 2020-11-23 19:17:19 +01:00
parent eecb0b4fef
commit 10e9f17446
3 changed files with 56 additions and 30 deletions

View File

@ -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);
}

View File

@ -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';

View File

@ -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];