2020-05-29 16:45:37 +00:00
// SPDX-License-Identifier: agpl-3.0
pragma solidity ^ 0 . 6 . 8 ;
2020-07-23 15:18:06 +00:00
pragma experimental ABIEncoderV2 ;
2020-05-29 16:45:37 +00:00
2020-08-20 07:51:21 +00:00
import { SafeMath } from ' @openzeppelin/contracts/math/SafeMath.sol ' ;
import {
VersionedInitializable
} from ' ../libraries/openzeppelin-upgradeability/VersionedInitializable.sol ' ;
import {
InitializableAdminUpgradeabilityProxy
} from ' ../libraries/openzeppelin-upgradeability/InitializableAdminUpgradeabilityProxy.sol ' ;
import { ReserveConfiguration } from ' ../libraries/configuration/ReserveConfiguration.sol ' ;
2020-08-21 12:03:17 +00:00
import { ILendingPoolAddressesProvider } from ' ../interfaces/ILendingPoolAddressesProvider.sol ' ;
2020-08-20 12:32:20 +00:00
import { ILendingPool } from ' ../interfaces/ILendingPool.sol ' ;
2020-08-07 16:23:52 +00:00
import { IERC20Detailed } from ' ../interfaces/IERC20Detailed.sol ' ;
2020-09-02 15:54:34 +00:00
import { Errors } from ' ../libraries/helpers/Errors.sol ' ;
2020-05-29 16:45:37 +00:00
/**
2020-06-20 23:40:03 +00:00
* @ title LendingPoolConfigurator contract
* @ author Aave
2020-07-27 08:03:53 +00:00
* @ notice Executes configuration methods on the LendingPoolCore contract . Allows to enable / disable reserves
* and set different protocol parameters .
2020-06-20 23:40:03 +00:00
** /
2020-05-29 16:45:37 +00:00
contract LendingPoolConfigurator is VersionedInitializable {
2020-06-20 23:40:03 +00:00
using SafeMath for uint256 ;
2020-07-23 15:18:06 +00:00
using ReserveConfiguration for ReserveConfiguration . Map ;
2020-06-20 23:40:03 +00:00
/**
* @ dev emitted when a reserve is initialized .
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param aToken the address of the overlying aToken contract
* @ param stableDebtToken the address of the associated stable rate debt token
* @ param variableDebtToken the address of the associated variable rate debt token
* @ param interestRateStrategyAddress the address of the interest rate strategy for the reserve
2020-06-20 23:40:03 +00:00
** /
event ReserveInitialized (
2020-08-21 12:03:17 +00:00
address indexed asset ,
address indexed aToken ,
address stableDebtToken ,
address variableDebtToken ,
address interestRateStrategyAddress
2020-06-20 23:40:03 +00:00
) ;
2020-07-13 08:54:08 +00:00
/**
2020-06-20 23:40:03 +00:00
* @ dev emitted when borrowing is enabled on a reserve
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param stableRateEnabled true if stable rate borrowing is enabled , false otherwise
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
event BorrowingEnabledOnReserve ( address asset , bool stableRateEnabled ) ;
2020-06-20 23:40:03 +00:00
/**
* @ dev emitted when borrowing is disabled on a reserve
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
event BorrowingDisabledOnReserve ( address indexed asset ) ;
2020-06-20 23:40:03 +00:00
/**
* @ dev emitted when a reserve is enabled as collateral .
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param ltv the loan to value of the asset when used as collateral
* @ param liquidationThreshold the threshold at which loans using this asset as collateral will be considered undercollateralized
* @ param liquidationBonus the bonus liquidators receive to liquidate this asset
2020-06-20 23:40:03 +00:00
** /
event ReserveEnabledAsCollateral (
2020-08-21 12:03:17 +00:00
address indexed asset ,
uint256 ltv ,
uint256 liquidationThreshold ,
uint256 liquidationBonus
2020-06-20 23:40:03 +00:00
) ;
/**
* @ dev emitted when a reserve is disabled as collateral
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
event ReserveDisabledAsCollateral ( address indexed asset ) ;
2020-06-20 23:40:03 +00:00
/**
* @ dev emitted when stable rate borrowing is enabled on a reserve
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
event StableRateEnabledOnReserve ( address indexed asset ) ;
2020-06-20 23:40:03 +00:00
/**
* @ dev emitted when stable rate borrowing is disabled on a reserve
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
event StableRateDisabledOnReserve ( address indexed asset ) ;
2020-06-20 23:40:03 +00:00
/**
* @ dev emitted when a reserve is activated
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
event ReserveActivated ( address indexed asset ) ;
2020-06-20 23:40:03 +00:00
/**
* @ dev emitted when a reserve is deactivated
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
event ReserveDeactivated ( address indexed asset ) ;
2020-06-20 23:40:03 +00:00
/**
* @ dev emitted when a reserve is freezed
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
event ReserveFreezed ( address indexed asset ) ;
2020-06-20 23:40:03 +00:00
/**
* @ dev emitted when a reserve is unfreezed
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
event ReserveUnfreezed ( address indexed asset ) ;
2020-06-20 23:40:03 +00:00
/**
* @ dev emitted when a reserve loan to value is updated
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param ltv the new value for the loan to value
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
event ReserveBaseLtvChanged ( address asset , uint256 ltv ) ;
2020-06-20 23:40:03 +00:00
/**
* @ dev emitted when a reserve liquidation threshold is updated
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param threshold the new value for the liquidation threshold
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
event ReserveLiquidationThresholdChanged ( address asset , uint256 threshold ) ;
2020-06-20 23:40:03 +00:00
/**
* @ dev emitted when a reserve liquidation bonus is updated
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param bonus the new value for the liquidation bonus
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
event ReserveLiquidationBonusChanged ( address asset , uint256 bonus ) ;
2020-06-20 23:40:03 +00:00
/**
* @ dev emitted when the reserve decimals are updated
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param decimals the new decimals
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
event ReserveDecimalsChanged ( address asset , uint256 decimals ) ;
2020-06-20 23:40:03 +00:00
/**
* @ dev emitted when a reserve interest strategy contract is updated
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param strategy the new address of the interest strategy contract
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
event ReserveInterestRateStrategyChanged ( address asset , address strategy ) ;
2020-06-20 23:40:03 +00:00
2020-08-18 00:16:46 +00:00
/**
* @ dev emitted when an aToken implementation is upgraded
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param proxy the aToken proxy address
* @ param implementation the new aToken implementation
2020-08-18 00:16:46 +00:00
** /
2020-08-21 12:03:17 +00:00
event ATokenUpgraded ( address asset , address proxy , address implementation ) ;
2020-08-18 00:16:46 +00:00
2020-08-18 16:48:23 +00:00
/**
2020-08-18 00:16:46 +00:00
* @ dev emitted when the implementation of a stable debt token is upgraded
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param proxy the stable debt token proxy address
* @ param implementation the new aToken implementation
2020-08-18 00:16:46 +00:00
** /
2020-08-21 12:03:17 +00:00
event StableDebtTokenUpgraded ( address asset , address proxy , address implementation ) ;
2020-08-18 00:16:46 +00:00
2020-08-18 16:48:23 +00:00
/**
2020-08-18 00:16:46 +00:00
* @ dev emitted when the implementation of a variable debt token is upgraded
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-08-25 08:53:58 +00:00
* @ param proxy the variable debt token proxy address
* @ param implementation the new aToken implementation
2020-08-18 00:16:46 +00:00
** /
2020-08-25 08:53:58 +00:00
event VariableDebtTokenUpgraded ( address asset , address proxy , address implementation ) ;
2020-08-18 00:16:46 +00:00
2020-08-21 12:03:17 +00:00
ILendingPoolAddressesProvider internal addressesProvider ;
ILendingPool internal pool ;
2020-07-23 15:18:06 +00:00
2020-06-20 23:40:03 +00:00
/**
* @ dev only the lending pool manager can call functions affected by this modifier
** /
modifier onlyLendingPoolManager {
require (
2020-08-21 12:03:17 +00:00
addressesProvider . getLendingPoolManager ( ) == msg . sender ,
2020-09-02 15:54:34 +00:00
Errors . CALLER_NOT_LENDING_POOL_MANAGER
2020-05-29 16:45:37 +00:00
) ;
2020-06-20 23:40:03 +00:00
_ ;
}
uint256 public constant CONFIGURATOR_REVISION = 0x3 ;
function getRevision ( ) internal override pure returns ( uint256 ) {
return CONFIGURATOR_REVISION ;
}
2020-08-21 12:03:17 +00:00
function initialize ( ILendingPoolAddressesProvider provider ) public initializer {
addressesProvider = provider ;
pool = ILendingPool ( addressesProvider . getLendingPool ( ) ) ;
2020-06-20 23:40:03 +00:00
}
/**
* @ dev initializes a reserve
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve to be initialized
* @ param aTokenImpl the address of the aToken contract implementation
* @ param stableDebtTokenImpl the address of the stable debt token contract
* @ param variableDebtTokenImpl the address of the variable debt token contract
* @ param underlyingAssetDecimals the decimals of the reserve underlying asset
* @ param interestRateStrategyAddress the address of the interest rate strategy contract for this reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-08 17:21:23 +00:00
function initReserve (
2020-08-21 12:03:17 +00:00
address asset ,
address aTokenImpl ,
address stableDebtTokenImpl ,
address variableDebtTokenImpl ,
uint8 underlyingAssetDecimals ,
address interestRateStrategyAddress
2020-06-20 23:40:03 +00:00
) public onlyLendingPoolManager {
2020-08-25 08:53:58 +00:00
address aTokenProxyAddress = _initTokenWithProxy ( aTokenImpl , underlyingAssetDecimals ) ;
2020-06-30 12:09:28 +00:00
2020-08-18 16:48:23 +00:00
address stableDebtTokenProxyAddress = _initTokenWithProxy (
2020-08-21 12:03:17 +00:00
stableDebtTokenImpl ,
underlyingAssetDecimals
2020-08-17 19:28:50 +00:00
) ;
2020-08-18 16:48:23 +00:00
address variableDebtTokenProxyAddress = _initTokenWithProxy (
2020-08-21 12:03:17 +00:00
variableDebtTokenImpl ,
underlyingAssetDecimals
2020-08-17 19:28:50 +00:00
) ;
2020-08-07 16:23:52 +00:00
2020-07-23 15:18:06 +00:00
pool . initReserve (
2020-08-21 12:03:17 +00:00
asset ,
2020-08-17 19:28:50 +00:00
aTokenProxyAddress ,
stableDebtTokenProxyAddress ,
variableDebtTokenProxyAddress ,
2020-08-21 12:03:17 +00:00
interestRateStrategyAddress
2020-05-29 16:45:37 +00:00
) ;
2020-08-21 12:03:17 +00:00
ReserveConfiguration . Map memory currentConfig = pool . getConfiguration ( asset ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
currentConfig . setDecimals ( underlyingAssetDecimals ) ;
2020-07-23 15:18:06 +00:00
currentConfig . setActive ( true ) ;
2020-07-27 07:49:45 +00:00
currentConfig . setFrozen ( false ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
pool . setConfiguration ( asset , currentConfig . data ) ;
2020-07-23 15:18:06 +00:00
2020-08-17 19:28:50 +00:00
emit ReserveInitialized (
2020-08-21 12:03:17 +00:00
asset ,
2020-08-17 19:28:50 +00:00
aTokenProxyAddress ,
stableDebtTokenProxyAddress ,
variableDebtTokenProxyAddress ,
2020-08-21 12:03:17 +00:00
interestRateStrategyAddress
2020-08-17 19:28:50 +00:00
) ;
2020-06-20 23:40:03 +00:00
}
2020-08-10 18:20:08 +00:00
/**
2020-08-21 12:03:17 +00:00
* @ dev updates the aToken implementation for the asset
* @ param asset the address of the reserve to be updated
* @ param implementation the address of the new aToken implementation
2020-08-10 18:20:08 +00:00
** /
2020-08-21 12:03:17 +00:00
function updateAToken ( address asset , address implementation ) external onlyLendingPoolManager {
( address aTokenAddress , , ) = pool . getReserveTokensAddresses ( asset ) ;
2020-08-10 13:29:18 +00:00
2020-08-21 12:03:17 +00:00
_upgradeTokenImplementation ( asset , aTokenAddress , implementation ) ;
2020-08-10 13:29:18 +00:00
2020-08-21 12:03:17 +00:00
emit ATokenUpgraded ( asset , aTokenAddress , implementation ) ;
2020-08-18 00:16:46 +00:00
}
/**
2020-08-21 12:03:17 +00:00
* @ dev updates the stable debt token implementation for the asset
* @ param asset the address of the reserve to be updated
* @ param implementation the address of the new aToken implementation
2020-08-18 00:16:46 +00:00
** /
2020-08-21 12:03:17 +00:00
function updateStableDebtToken ( address asset , address implementation )
2020-08-18 00:16:46 +00:00
external
onlyLendingPoolManager
{
2020-08-21 12:03:17 +00:00
( , address stableDebtToken , ) = pool . getReserveTokensAddresses ( asset ) ;
2020-08-18 00:16:46 +00:00
2020-08-21 12:03:17 +00:00
_upgradeTokenImplementation ( asset , stableDebtToken , implementation ) ;
2020-08-10 13:29:18 +00:00
2020-08-21 12:03:17 +00:00
emit StableDebtTokenUpgraded ( asset , stableDebtToken , implementation ) ;
2020-08-18 00:16:46 +00:00
}
2020-08-25 08:53:58 +00:00
2020-08-18 00:16:46 +00:00
/**
2020-08-21 12:03:17 +00:00
* @ dev updates the variable debt token implementation for the asset
* @ param asset the address of the reserve to be updated
* @ param implementation the address of the new aToken implementation
2020-08-18 00:16:46 +00:00
** /
2020-08-21 12:03:17 +00:00
function updateVariableDebtToken ( address asset , address implementation )
2020-08-18 00:16:46 +00:00
external
onlyLendingPoolManager
{
2020-08-21 12:03:17 +00:00
( , , address variableDebtToken ) = pool . getReserveTokensAddresses ( asset ) ;
2020-08-18 00:16:46 +00:00
2020-08-21 12:03:17 +00:00
_upgradeTokenImplementation ( asset , variableDebtToken , implementation ) ;
2020-08-18 00:16:46 +00:00
2020-08-21 12:03:17 +00:00
emit VariableDebtTokenUpgraded ( asset , variableDebtToken , implementation ) ;
2020-08-10 13:29:18 +00:00
}
2020-06-20 23:40:03 +00:00
/**
* @ dev enables borrowing on a reserve
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param stableBorrowRateEnabled true if stable borrow rate needs to be enabled by default on this reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
function enableBorrowingOnReserve ( address asset , bool stableBorrowRateEnabled )
2020-06-20 23:40:03 +00:00
external
onlyLendingPoolManager
{
2020-08-21 12:03:17 +00:00
ReserveConfiguration . Map memory currentConfig = pool . getConfiguration ( asset ) ;
2020-07-23 15:18:06 +00:00
currentConfig . setBorrowingEnabled ( true ) ;
2020-08-21 12:03:17 +00:00
currentConfig . setStableRateBorrowingEnabled ( stableBorrowRateEnabled ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
pool . setConfiguration ( asset , currentConfig . data ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
emit BorrowingEnabledOnReserve ( asset , stableBorrowRateEnabled ) ;
2020-06-20 23:40:03 +00:00
}
/**
* @ dev disables borrowing on a reserve
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
function disableBorrowingOnReserve ( address asset ) external onlyLendingPoolManager {
ReserveConfiguration . Map memory currentConfig = pool . getConfiguration ( asset ) ;
2020-07-23 15:18:06 +00:00
currentConfig . setBorrowingEnabled ( false ) ;
2020-08-21 12:03:17 +00:00
pool . setConfiguration ( asset , currentConfig . data ) ;
emit BorrowingDisabledOnReserve ( asset ) ;
2020-06-20 23:40:03 +00:00
}
/**
* @ dev enables a reserve to be used as collateral
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param ltv the loan to value of the asset when used as collateral
* @ param liquidationThreshold the threshold at which loans using this asset as collateral will be considered undercollateralized
* @ param liquidationBonus the bonus liquidators receive to liquidate this asset
2020-06-20 23:40:03 +00:00
** /
function enableReserveAsCollateral (
2020-08-21 12:03:17 +00:00
address asset ,
uint256 ltv ,
uint256 liquidationThreshold ,
uint256 liquidationBonus
2020-06-20 23:40:03 +00:00
) external onlyLendingPoolManager {
2020-08-21 12:03:17 +00:00
ReserveConfiguration . Map memory currentConfig = pool . getConfiguration ( asset ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
currentConfig . setLtv ( ltv ) ;
currentConfig . setLiquidationThreshold ( liquidationThreshold ) ;
currentConfig . setLiquidationBonus ( liquidationBonus ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
pool . setConfiguration ( asset , currentConfig . data ) ;
2020-07-23 15:18:06 +00:00
2020-08-25 08:53:58 +00:00
emit ReserveEnabledAsCollateral ( asset , ltv , liquidationThreshold , liquidationBonus ) ;
2020-06-20 23:40:03 +00:00
}
/**
* @ dev disables a reserve as collateral
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
function disableReserveAsCollateral ( address asset ) external onlyLendingPoolManager {
ReserveConfiguration . Map memory currentConfig = pool . getConfiguration ( asset ) ;
2020-07-23 15:18:06 +00:00
currentConfig . setLtv ( 0 ) ;
2020-08-21 12:03:17 +00:00
pool . setConfiguration ( asset , currentConfig . data ) ;
2020-06-20 23:40:03 +00:00
2020-08-21 12:03:17 +00:00
emit ReserveDisabledAsCollateral ( asset ) ;
2020-06-20 23:40:03 +00:00
}
/**
* @ dev enable stable rate borrowing on a reserve
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
function enableReserveStableRate ( address asset ) external onlyLendingPoolManager {
ReserveConfiguration . Map memory currentConfig = pool . getConfiguration ( asset ) ;
2020-07-23 15:18:06 +00:00
currentConfig . setStableRateBorrowingEnabled ( true ) ;
2020-08-21 12:03:17 +00:00
pool . setConfiguration ( asset , currentConfig . data ) ;
2020-06-20 23:40:03 +00:00
2020-08-21 12:03:17 +00:00
emit StableRateEnabledOnReserve ( asset ) ;
2020-06-20 23:40:03 +00:00
}
/**
* @ dev disable stable rate borrowing on a reserve
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
function disableReserveStableRate ( address asset ) external onlyLendingPoolManager {
ReserveConfiguration . Map memory currentConfig = pool . getConfiguration ( asset ) ;
2020-07-23 15:18:06 +00:00
currentConfig . setStableRateBorrowingEnabled ( false ) ;
2020-08-21 12:03:17 +00:00
pool . setConfiguration ( asset , currentConfig . data ) ;
2020-06-20 23:40:03 +00:00
2020-08-21 12:03:17 +00:00
emit StableRateDisabledOnReserve ( asset ) ;
2020-06-20 23:40:03 +00:00
}
/**
* @ dev activates a reserve
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
function activateReserve ( address asset ) external onlyLendingPoolManager {
ReserveConfiguration . Map memory currentConfig = pool . getConfiguration ( asset ) ;
2020-07-23 15:18:06 +00:00
currentConfig . setActive ( true ) ;
2020-08-21 12:03:17 +00:00
pool . setConfiguration ( asset , currentConfig . data ) ;
2020-06-20 23:40:03 +00:00
2020-08-21 12:03:17 +00:00
emit ReserveActivated ( asset ) ;
2020-06-20 23:40:03 +00:00
}
/**
* @ dev deactivates a reserve
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
function deactivateReserve ( address asset ) external onlyLendingPoolManager {
2020-06-20 23:40:03 +00:00
(
uint256 availableLiquidity ,
uint256 totalBorrowsStable ,
uint256 totalBorrowsVariable ,
,
,
,
,
,
,
2020-08-21 12:03:17 +00:00
) = pool . getReserveData ( asset ) ;
2020-06-20 23:40:03 +00:00
require (
availableLiquidity == 0 && totalBorrowsStable == 0 && totalBorrowsVariable == 0 ,
2020-09-02 15:54:34 +00:00
Errors . RESERVE_LIQUIDITY_NOT_0
2020-06-20 23:40:03 +00:00
) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
ReserveConfiguration . Map memory currentConfig = pool . getConfiguration ( asset ) ;
2020-07-23 15:18:06 +00:00
currentConfig . setActive ( false ) ;
2020-08-21 12:03:17 +00:00
pool . setConfiguration ( asset , currentConfig . data ) ;
2020-06-20 23:40:03 +00:00
2020-08-21 12:03:17 +00:00
emit ReserveDeactivated ( asset ) ;
2020-06-20 23:40:03 +00:00
}
/**
* @ dev freezes a reserve . A freezed reserve doesn ' t accept any new deposit, borrow or rate swap, but can accept repayments, liquidations, rate rebalances and redeems
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
function freezeReserve ( address asset ) external onlyLendingPoolManager {
ReserveConfiguration . Map memory currentConfig = pool . getConfiguration ( asset ) ;
2020-07-23 15:18:06 +00:00
2020-07-27 07:49:45 +00:00
currentConfig . setFrozen ( true ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
pool . setConfiguration ( asset , currentConfig . data ) ;
2020-06-20 23:40:03 +00:00
2020-08-21 12:03:17 +00:00
emit ReserveFreezed ( asset ) ;
2020-06-20 23:40:03 +00:00
}
/**
* @ dev unfreezes a reserve
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
function unfreezeReserve ( address asset ) external onlyLendingPoolManager {
ReserveConfiguration . Map memory currentConfig = pool . getConfiguration ( asset ) ;
2020-07-23 15:18:06 +00:00
2020-07-27 07:49:45 +00:00
currentConfig . setFrozen ( false ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
pool . setConfiguration ( asset , currentConfig . data ) ;
2020-06-20 23:40:03 +00:00
2020-08-21 12:03:17 +00:00
emit ReserveUnfreezed ( asset ) ;
2020-06-20 23:40:03 +00:00
}
/**
* @ dev emitted when a reserve loan to value is updated
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param ltv the new value for the loan to value
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
function setLtv ( address asset , uint256 ltv ) external onlyLendingPoolManager {
ReserveConfiguration . Map memory currentConfig = pool . getConfiguration ( asset ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
currentConfig . setLtv ( ltv ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
pool . setConfiguration ( asset , currentConfig . data ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
emit ReserveBaseLtvChanged ( asset , ltv ) ;
2020-06-20 23:40:03 +00:00
}
/**
* @ dev updates the liquidation threshold of a reserve .
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param threshold the new value for the liquidation threshold
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
function setLiquidationThreshold ( address asset , uint256 threshold )
2020-06-20 23:40:03 +00:00
external
onlyLendingPoolManager
{
2020-08-21 12:03:17 +00:00
ReserveConfiguration . Map memory currentConfig = pool . getConfiguration ( asset ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
currentConfig . setLiquidationThreshold ( threshold ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
pool . setConfiguration ( asset , currentConfig . data ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
emit ReserveLiquidationThresholdChanged ( asset , threshold ) ;
2020-06-20 23:40:03 +00:00
}
/**
* @ dev updates the liquidation bonus of a reserve
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param bonus the new value for the liquidation bonus
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
function setLiquidationBonus ( address asset , uint256 bonus ) external onlyLendingPoolManager {
ReserveConfiguration . Map memory currentConfig = pool . getConfiguration ( asset ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
currentConfig . setLiquidationBonus ( bonus ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
pool . setConfiguration ( asset , currentConfig . data ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
emit ReserveLiquidationBonusChanged ( asset , bonus ) ;
2020-06-20 23:40:03 +00:00
}
/**
* @ dev updates the reserve decimals
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param decimals the new number of decimals
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
function setReserveDecimals ( address asset , uint256 decimals ) external onlyLendingPoolManager {
ReserveConfiguration . Map memory currentConfig = pool . getConfiguration ( asset ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
currentConfig . setDecimals ( decimals ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
pool . setConfiguration ( asset , currentConfig . data ) ;
2020-07-23 15:18:06 +00:00
2020-08-21 12:03:17 +00:00
emit ReserveDecimalsChanged ( asset , decimals ) ;
2020-06-20 23:40:03 +00:00
}
/**
* @ dev sets the interest rate strategy of a reserve
2020-08-21 12:03:17 +00:00
* @ param asset the address of the reserve
* @ param rateStrategyAddress the new address of the interest strategy contract
2020-06-20 23:40:03 +00:00
** /
2020-08-21 12:03:17 +00:00
function setReserveInterestRateStrategyAddress ( address asset , address rateStrategyAddress )
2020-06-20 23:40:03 +00:00
external
onlyLendingPoolManager
{
2020-08-21 12:03:17 +00:00
pool . setReserveInterestRateStrategyAddress ( asset , rateStrategyAddress ) ;
emit ReserveInterestRateStrategyChanged ( asset , rateStrategyAddress ) ;
2020-06-20 23:40:03 +00:00
}
2020-08-17 19:28:50 +00:00
/**
2020-08-18 16:48:23 +00:00
* @ dev initializes a token with a proxy and a specific implementation
2020-08-21 12:03:17 +00:00
* @ param implementation the address of the implementation
* @ param decimals the decimals of the token
2020-08-17 19:28:50 +00:00
** /
2020-08-25 08:53:58 +00:00
function _initTokenWithProxy ( address implementation , uint8 decimals ) internal returns ( address ) {
2020-08-17 19:28:50 +00:00
InitializableAdminUpgradeabilityProxy proxy = new InitializableAdminUpgradeabilityProxy ( ) ;
bytes memory params = abi . encodeWithSignature (
' initialize(uint8,string,string) ' ,
2020-08-21 12:03:17 +00:00
decimals ,
IERC20Detailed ( implementation ) . name ( ) ,
IERC20Detailed ( implementation ) . symbol ( )
2020-08-17 19:28:50 +00:00
) ;
2020-08-21 12:03:17 +00:00
proxy . initialize ( implementation , address ( this ) , params ) ;
2020-08-17 19:28:50 +00:00
return address ( proxy ) ;
}
2020-08-18 00:16:46 +00:00
2020-08-18 16:48:23 +00:00
function _upgradeTokenImplementation (
2020-08-21 12:03:17 +00:00
address asset ,
address proxyAddress ,
address implementation
2020-08-20 12:32:20 +00:00
) internal {
2020-08-18 00:16:46 +00:00
InitializableAdminUpgradeabilityProxy proxy = InitializableAdminUpgradeabilityProxy (
2020-08-21 12:03:17 +00:00
payable ( proxyAddress )
2020-08-18 00:16:46 +00:00
) ;
2020-08-21 12:03:17 +00:00
( uint256 decimals , , , , , , , , , ) = pool . getReserveConfigurationData ( asset ) ;
2020-08-18 16:48:23 +00:00
2020-08-18 00:16:46 +00:00
bytes memory params = abi . encodeWithSignature (
' initialize(uint8,string,string) ' ,
2020-08-18 16:48:23 +00:00
uint8 ( decimals ) ,
2020-08-21 12:03:17 +00:00
IERC20Detailed ( implementation ) . name ( ) ,
IERC20Detailed ( implementation ) . symbol ( )
2020-08-18 00:16:46 +00:00
) ;
2020-08-21 12:03:17 +00:00
proxy . upgradeToAndCall ( implementation , params ) ;
2020-08-18 00:16:46 +00:00
}
2020-05-29 16:45:37 +00:00
}