mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	Merge branch 'feat/2.5-pause-one-reserve' into feat/2.5-flashloan-whitelist
This commit is contained in:
		
						commit
						ad6f2d2ede
					
				| 
						 | 
				
			
			@ -203,21 +203,199 @@ interface ILendingPoolConfigurator {
 | 
			
		|||
    address indexed implementation
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  event RiskAdminRegistered(address indexed admin);
 | 
			
		||||
 | 
			
		||||
  event RiskAdminUnregistered(address indexed admin);
 | 
			
		||||
 | 
			
		||||
   /**
 | 
			
		||||
   * @dev Emitted when a new borrower is authorized (fees = 0)
 | 
			
		||||
   * @param flashBorrower The address of the authorized borrower
 | 
			
		||||
   **/
 | 
			
		||||
  event FlashBorrowerAuthorized(address indexed flashBorrower);
 | 
			
		||||
 | 
			
		||||
   /**
 | 
			
		||||
   * @dev Emitted when a borrower is unauthorized
 | 
			
		||||
   * @param flashBorrower The address of the unauthorized borrower
 | 
			
		||||
   **/
 | 
			
		||||
  event FlashBorrowerUnauthorized(address indexed flashBorrower);
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Emitted when a new risk admin is registered
 | 
			
		||||
   * @param admin the newly registered admin
 | 
			
		||||
   **/
 | 
			
		||||
  event RiskAdminRegistered(address indexed admin);
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Emitted when a risk admin is unregistered
 | 
			
		||||
   * @param admin the unregistered admin
 | 
			
		||||
   **/
 | 
			
		||||
  event RiskAdminUnregistered(address indexed admin);
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Initializes reserves in batch
 | 
			
		||||
   * @param input The array of reserves initialization parameters
 | 
			
		||||
   **/
 | 
			
		||||
  function batchInitReserve(InitReserveInput[] calldata input) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Updates the aToken implementation for the reserve
 | 
			
		||||
   * @param input The aToken update paramenters
 | 
			
		||||
   **/
 | 
			
		||||
  function updateAToken(UpdateATokenInput calldata input) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Updates the stable debt token implementation for the reserve
 | 
			
		||||
   * @param input The stableDebtToken update parameters
 | 
			
		||||
   **/
 | 
			
		||||
  function updateStableDebtToken(UpdateDebtTokenInput calldata input) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Updates the variable debt token implementation for the asset
 | 
			
		||||
   * @param input The variableDebtToken update parameters
 | 
			
		||||
   **/
 | 
			
		||||
  function updateVariableDebtToken(UpdateDebtTokenInput calldata input) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Enables borrowing on a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   * @param borrowCap The borrow cap for this specific asset, in absolute units of tokens
 | 
			
		||||
   * @param stableBorrowRateEnabled True if stable borrow rate needs to be enabled by default on this reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function enableBorrowingOnReserve(
 | 
			
		||||
    address asset,
 | 
			
		||||
    uint256 borrowCap,
 | 
			
		||||
    bool stableBorrowRateEnabled
 | 
			
		||||
  ) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Disables borrowing on a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function disableBorrowingOnReserve(address asset) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Configures the reserve collateralization parameters
 | 
			
		||||
   * all the values are expressed in percentages with two decimals of precision. A valid value is 10000, which means 100.00%
 | 
			
		||||
   * @param asset The address of the underlying asset 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. The values is always above 100%. A value of 105%
 | 
			
		||||
   * means the liquidator will receive a 5% bonus
 | 
			
		||||
   **/
 | 
			
		||||
  function configureReserveAsCollateral(
 | 
			
		||||
    address asset,
 | 
			
		||||
    uint256 ltv,
 | 
			
		||||
    uint256 liquidationThreshold,
 | 
			
		||||
    uint256 liquidationBonus
 | 
			
		||||
  ) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Enable stable rate borrowing on a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function enableReserveStableRate(address asset) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Disable stable rate borrowing on a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function disableReserveStableRate(address asset) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Activates a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function activateReserve(address asset) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Deactivates a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function deactivateReserve(address asset) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Freezes a reserve. A frozen reserve doesn't allow any new deposit, borrow or rate swap
 | 
			
		||||
   *  but allows repayments, liquidations, rate rebalances and withdrawals
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function freezeReserve(address asset) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Unfreezes a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function unfreezeReserve(address asset) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Pauses a reserve. A paused reserve allow now user moves such as deposit, borrow, repay, swap interestrate, liquidate
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function pauseReserve(address asset) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Unpauses a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function unpauseReserve(address asset) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Updates the reserve factor of a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   * @param reserveFactor The new reserve factor of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function setReserveFactor(address asset, uint256 reserveFactor) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Sets the interest rate strategy of a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   * @param rateStrategyAddress The new address of the interest strategy contract
 | 
			
		||||
   **/
 | 
			
		||||
  function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress)
 | 
			
		||||
    external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev pauses or unpauses all the actions of the protocol, including aToken transfers
 | 
			
		||||
   * @param val true if protocol needs to be paused, false otherwise
 | 
			
		||||
   **/
 | 
			
		||||
  function setPoolPause(bool val) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Updates the borrow cap of a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   * @param borrowCap The new borrow of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function setBorrowCap(address asset, uint256 borrowCap) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Updates the supply cap of a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   * @param supplyCap The new supply of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function setSupplyCap(address asset, uint256 supplyCap) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Registers a new admin with rights on risk related configurations
 | 
			
		||||
   * @param admin The address of the admin to register
 | 
			
		||||
   **/
 | 
			
		||||
  function registerRiskAdmin(address admin) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Unegisters a risk admin
 | 
			
		||||
   * @param admin The address of the admin to unregister
 | 
			
		||||
   **/
 | 
			
		||||
  function unregisterRiskAdmin(address admin) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Returns wether an address in a risk admin or not
 | 
			
		||||
   * @param admin The address of the potential admin
 | 
			
		||||
   **/
 | 
			
		||||
  function isRiskAdmin(address admin) external view returns (bool);
 | 
			
		||||
  
 | 
			
		||||
   /**
 | 
			
		||||
   * @dev Authorize a new borrower (fees are 0 for the authorized borrower)
 | 
			
		||||
   * @param flashBorrower The address of the authorized borrower
 | 
			
		||||
   **/
 | 
			
		||||
  function authorizeFlashBorrower(address flashBorrower) external;
 | 
			
		||||
 | 
			
		||||
   /**
 | 
			
		||||
   * @dev Unauthorize a borrower
 | 
			
		||||
   * @param flashBorrower The address of the unauthorized borrower
 | 
			
		||||
   **/
 | 
			
		||||
  function unauthorizeFlashBorrower(address flashBorrower) external;
 | 
			
		||||
 | 
			
		||||
  function isRiskAdmin(address admin) external view returns (bool);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,19 +30,21 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
 | 
			
		|||
  using PercentageMath for uint256;
 | 
			
		||||
  using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
 | 
			
		||||
 | 
			
		||||
  ILendingPoolAddressesProvider internal addressesProvider;
 | 
			
		||||
  ILendingPool internal pool;
 | 
			
		||||
  ILendingPoolAddressesProvider internal _addressesProvider;
 | 
			
		||||
  ILendingPool internal _pool;
 | 
			
		||||
 | 
			
		||||
  mapping(address => bool) private _riskAdmins;
 | 
			
		||||
 | 
			
		||||
  mapping(address => bool) private _riskAdmins;
 | 
			
		||||
 | 
			
		||||
  modifier onlyPoolAdmin {
 | 
			
		||||
    require(addressesProvider.getPoolAdmin() == msg.sender, Errors.CALLER_NOT_POOL_ADMIN);
 | 
			
		||||
    require(_addressesProvider.getPoolAdmin() == msg.sender, Errors.CALLER_NOT_POOL_ADMIN);
 | 
			
		||||
    _;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  modifier onlyEmergencyAdmin {
 | 
			
		||||
    require(
 | 
			
		||||
      addressesProvider.getEmergencyAdmin() == msg.sender,
 | 
			
		||||
      _addressesProvider.getEmergencyAdmin() == msg.sender,
 | 
			
		||||
      Errors.LPC_CALLER_NOT_EMERGENCY_ADMIN
 | 
			
		||||
    );
 | 
			
		||||
    _;
 | 
			
		||||
| 
						 | 
				
			
			@ -50,8 +52,8 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
 | 
			
		|||
 | 
			
		||||
  modifier onlyEmergencyOrPoolAdmin {
 | 
			
		||||
    require(
 | 
			
		||||
      addressesProvider.getEmergencyAdmin() == msg.sender ||
 | 
			
		||||
        addressesProvider.getPoolAdmin() == msg.sender,
 | 
			
		||||
      _addressesProvider.getEmergencyAdmin() == msg.sender ||
 | 
			
		||||
        _addressesProvider.getPoolAdmin() == msg.sender,
 | 
			
		||||
      Errors.LPC_CALLER_NOT_EMERGENCY_OR_POOL_ADMIN
 | 
			
		||||
    );
 | 
			
		||||
    _;
 | 
			
		||||
| 
						 | 
				
			
			@ -59,7 +61,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
 | 
			
		|||
 | 
			
		||||
  modifier onlyRiskOrPoolAdmins {
 | 
			
		||||
    require(
 | 
			
		||||
      _riskAdmins[msg.sender] || addressesProvider.getPoolAdmin() == msg.sender,
 | 
			
		||||
      _riskAdmins[msg.sender] || _addressesProvider.getPoolAdmin() == msg.sender,
 | 
			
		||||
      Errors.LPC_CALLER_NOT_RISK_OR_POOL_ADMIN
 | 
			
		||||
    );
 | 
			
		||||
    _;
 | 
			
		||||
| 
						 | 
				
			
			@ -72,15 +74,13 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  function initialize(ILendingPoolAddressesProvider provider) public initializer {
 | 
			
		||||
    addressesProvider = provider;
 | 
			
		||||
    pool = ILendingPool(addressesProvider.getLendingPool());
 | 
			
		||||
    _addressesProvider = provider;
 | 
			
		||||
    _pool = ILendingPool(_addressesProvider.getLendingPool());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Initializes reserves in batch
 | 
			
		||||
   **/
 | 
			
		||||
  function batchInitReserve(InitReserveInput[] calldata input) external onlyPoolAdmin {
 | 
			
		||||
    ILendingPool cachedPool = pool;
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function batchInitReserve(InitReserveInput[] calldata input) external override onlyPoolAdmin {
 | 
			
		||||
    ILendingPool cachedPool = _pool;
 | 
			
		||||
    for (uint256 i = 0; i < input.length; i++) {
 | 
			
		||||
      _initReserve(cachedPool, input[i]);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -161,11 +161,9 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
 | 
			
		|||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Updates the aToken implementation for the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function updateAToken(UpdateATokenInput calldata input) external onlyPoolAdmin {
 | 
			
		||||
    ILendingPool cachedPool = pool;
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function updateAToken(UpdateATokenInput calldata input) external override onlyPoolAdmin {
 | 
			
		||||
    ILendingPool cachedPool = _pool;
 | 
			
		||||
 | 
			
		||||
    DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -189,11 +187,13 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
 | 
			
		|||
    emit ATokenUpgraded(input.asset, reserveData.aTokenAddress, input.implementation);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Updates the stable debt token implementation for the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function updateStableDebtToken(UpdateDebtTokenInput calldata input) external onlyPoolAdmin {
 | 
			
		||||
    ILendingPool cachedPool = pool;
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function updateStableDebtToken(UpdateDebtTokenInput calldata input)
 | 
			
		||||
    external
 | 
			
		||||
    override
 | 
			
		||||
    onlyPoolAdmin
 | 
			
		||||
  {
 | 
			
		||||
    ILendingPool cachedPool = _pool;
 | 
			
		||||
 | 
			
		||||
    DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -224,12 +224,13 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
 | 
			
		|||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Updates the variable debt token implementation for the asset
 | 
			
		||||
   **/
 | 
			
		||||
  function updateVariableDebtToken(UpdateDebtTokenInput calldata input) external onlyPoolAdmin {
 | 
			
		||||
    ILendingPool cachedPool = pool;
 | 
			
		||||
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function updateVariableDebtToken(UpdateDebtTokenInput calldata input)
 | 
			
		||||
    external
 | 
			
		||||
    override
 | 
			
		||||
    onlyPoolAdmin
 | 
			
		||||
  {
 | 
			
		||||
    ILendingPool cachedPool = _pool;
 | 
			
		||||
    DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset);
 | 
			
		||||
 | 
			
		||||
    (, , , uint256 decimals, ) = cachedPool.getConfiguration(input.asset).getParamsMemory();
 | 
			
		||||
| 
						 | 
				
			
			@ -259,56 +260,42 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
 | 
			
		|||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Enables borrowing on a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   * @param stableBorrowRateEnabled True if stable borrow rate needs to be enabled by default on this reserve
 | 
			
		||||
   **/
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function enableBorrowingOnReserve(
 | 
			
		||||
    address asset,
 | 
			
		||||
    uint256 borrowCap,
 | 
			
		||||
    bool stableBorrowRateEnabled
 | 
			
		||||
  ) external onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
 | 
			
		||||
  ) external override onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);$
 | 
			
		||||
 | 
			
		||||
    currentConfig.setBorrowingEnabled(true);
 | 
			
		||||
    currentConfig.setBorrowCap(borrowCap);
 | 
			
		||||
    currentConfig.setStableRateBorrowingEnabled(stableBorrowRateEnabled);
 | 
			
		||||
 | 
			
		||||
    pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
    _pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
 | 
			
		||||
    emit BorrowCapChanged(asset, borrowCap);
 | 
			
		||||
    emit BorrowingEnabledOnReserve(asset, stableBorrowRateEnabled);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Disables borrowing on a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function disableBorrowingOnReserve(address asset) external onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function disableBorrowingOnReserve(address asset) external override onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
 | 
			
		||||
 | 
			
		||||
    currentConfig.setBorrowingEnabled(false);
 | 
			
		||||
 | 
			
		||||
    pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
    _pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
    emit BorrowingDisabledOnReserve(asset);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Configures the reserve collateralization parameters
 | 
			
		||||
   * all the values are expressed in percentages with two decimals of precision. A valid value is 10000, which means 100.00%
 | 
			
		||||
   * @param asset The address of the underlying asset 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. The values is always above 100%. A value of 105%
 | 
			
		||||
   * means the liquidator will receive a 5% bonus
 | 
			
		||||
   **/
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function configureReserveAsCollateral(
 | 
			
		||||
    address asset,
 | 
			
		||||
    uint256 ltv,
 | 
			
		||||
    uint256 liquidationThreshold,
 | 
			
		||||
    uint256 liquidationBonus
 | 
			
		||||
  ) external onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
 | 
			
		||||
  ) external override onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
 | 
			
		||||
 | 
			
		||||
    //validation of the parameters: the LTV can
 | 
			
		||||
    //only be lower or equal than the liquidation threshold
 | 
			
		||||
| 
						 | 
				
			
			@ -341,212 +328,195 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
 | 
			
		|||
    currentConfig.setLiquidationThreshold(liquidationThreshold);
 | 
			
		||||
    currentConfig.setLiquidationBonus(liquidationBonus);
 | 
			
		||||
 | 
			
		||||
    pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
    _pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
 | 
			
		||||
    emit CollateralConfigurationChanged(asset, ltv, liquidationThreshold, liquidationBonus);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Enable stable rate borrowing on a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function enableReserveStableRate(address asset) external onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function enableReserveStableRate(address asset) external override onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
 | 
			
		||||
 | 
			
		||||
    currentConfig.setStableRateBorrowingEnabled(true);
 | 
			
		||||
 | 
			
		||||
    pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
    _pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
 | 
			
		||||
    emit StableRateEnabledOnReserve(asset);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Disable stable rate borrowing on a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function disableReserveStableRate(address asset) external onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function disableReserveStableRate(address asset) external override onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
 | 
			
		||||
 | 
			
		||||
    currentConfig.setStableRateBorrowingEnabled(false);
 | 
			
		||||
 | 
			
		||||
    pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
    _pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
 | 
			
		||||
    emit StableRateDisabledOnReserve(asset);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Activates a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function activateReserve(address asset) external onlyPoolAdmin {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function activateReserve(address asset) external override onlyPoolAdmin {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
 | 
			
		||||
 | 
			
		||||
    currentConfig.setActive(true);
 | 
			
		||||
 | 
			
		||||
    pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
    _pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
 | 
			
		||||
    emit ReserveActivated(asset);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Deactivates a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function deactivateReserve(address asset) external onlyPoolAdmin {
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function deactivateReserve(address asset) external override onlyPoolAdmin {
 | 
			
		||||
    _checkNoLiquidity(asset);
 | 
			
		||||
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
 | 
			
		||||
 | 
			
		||||
    currentConfig.setActive(false);
 | 
			
		||||
 | 
			
		||||
    pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
    _pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
 | 
			
		||||
    emit ReserveDeactivated(asset);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Freezes a reserve. A frozen reserve doesn't allow any new deposit, borrow or rate swap
 | 
			
		||||
   *  but allows repayments, liquidations, rate rebalances and withdrawals
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function freezeReserve(address asset) external onlyPoolAdmin {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function freezeReserve(address asset) external override onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
 | 
			
		||||
 | 
			
		||||
    currentConfig.setFrozen(true);
 | 
			
		||||
 | 
			
		||||
    pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
    _pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
 | 
			
		||||
    emit ReserveFrozen(asset);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Unfreezes a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function unfreezeReserve(address asset) external onlyPoolAdmin {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function unfreezeReserve(address asset) external override onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
 | 
			
		||||
 | 
			
		||||
    currentConfig.setFrozen(false);
 | 
			
		||||
 | 
			
		||||
    pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
    _pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
 | 
			
		||||
    emit ReserveUnfrozen(asset);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Pauses a reserve. A paused reserve allow now user moves such as deposit, borrow, repay, swap interestrate, liquidate
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function pauseReserve(address asset) external onlyEmergencyOrPoolAdmin {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function pauseReserve(address asset) external override onlyEmergencyOrPoolAdmin {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
 | 
			
		||||
 | 
			
		||||
    currentConfig.setPaused(true);
 | 
			
		||||
 | 
			
		||||
    pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
    _pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
 | 
			
		||||
    emit ReservePaused(asset);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Unpauses a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function unpauseReserve(address asset) external onlyEmergencyOrPoolAdmin {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function unpauseReserve(address asset) external override onlyEmergencyOrPoolAdmin {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
 | 
			
		||||
 | 
			
		||||
    currentConfig.setPaused(false);
 | 
			
		||||
 | 
			
		||||
    pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
    _pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
 | 
			
		||||
    emit ReserveUnpaused(asset);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Updates the reserve factor of a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   * @param reserveFactor The new reserve factor of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function setReserveFactor(address asset, uint256 reserveFactor) external onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function setReserveFactor(address asset, uint256 reserveFactor)
 | 
			
		||||
    external
 | 
			
		||||
    override
 | 
			
		||||
    onlyRiskOrPoolAdmins
 | 
			
		||||
  {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
 | 
			
		||||
 | 
			
		||||
    currentConfig.setReserveFactor(reserveFactor);
 | 
			
		||||
 | 
			
		||||
    pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
    _pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
 | 
			
		||||
    emit ReserveFactorChanged(asset, reserveFactor);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Updates the borrow cap of a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   * @param borrowCap The new borrow of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function setBorrowCap(address asset, uint256 borrowCap) external onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
 | 
			
		||||
  ///@inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function setBorrowCap(address asset, uint256 borrowCap) external override onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
 | 
			
		||||
 | 
			
		||||
    currentConfig.setBorrowCap(borrowCap);
 | 
			
		||||
 | 
			
		||||
    pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
    _pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
 | 
			
		||||
    emit BorrowCapChanged(asset, borrowCap);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Updates the supply cap of a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   * @param supplyCap The new supply of the reserve
 | 
			
		||||
   **/
 | 
			
		||||
  function setSupplyCap(address asset, uint256 supplyCap) external onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
 | 
			
		||||
  ///@inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function setSupplyCap(address asset, uint256 supplyCap) external override onlyRiskOrPoolAdmins {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
 | 
			
		||||
 | 
			
		||||
    currentConfig.setSupplyCap(supplyCap);
 | 
			
		||||
 | 
			
		||||
    pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
    _pool.setConfiguration(asset, currentConfig.data);
 | 
			
		||||
 | 
			
		||||
    emit SupplyCapChanged(asset, supplyCap);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Sets the interest rate strategy of a reserve
 | 
			
		||||
   * @param asset The address of the underlying asset of the reserve
 | 
			
		||||
   * @param rateStrategyAddress The new address of the interest strategy contract
 | 
			
		||||
   **/
 | 
			
		||||
  ///@inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress)
 | 
			
		||||
    external
 | 
			
		||||
    override
 | 
			
		||||
    onlyRiskOrPoolAdmins
 | 
			
		||||
  {
 | 
			
		||||
    pool.setReserveInterestRateStrategyAddress(asset, rateStrategyAddress);
 | 
			
		||||
    _pool.setReserveInterestRateStrategyAddress(asset, rateStrategyAddress);
 | 
			
		||||
    emit ReserveInterestRateStrategyChanged(asset, rateStrategyAddress);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev pauses or unpauses all the actions of the protocol, including aToken transfers
 | 
			
		||||
   * @param val true if protocol needs to be paused, false otherwise
 | 
			
		||||
   **/
 | 
			
		||||
  function setPoolPause(bool val) external onlyEmergencyAdmin {
 | 
			
		||||
    pool.setPause(val);
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function setPoolPause(bool val) external override onlyEmergencyAdmin {
 | 
			
		||||
    _pool.setPause(val);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function registerRiskAdmin(address admin) external override onlyPoolAdmin {
 | 
			
		||||
    _riskAdmins[admin] = true;
 | 
			
		||||
    emit RiskAdminRegistered(admin);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function unregisterRiskAdmin(address admin) external override onlyPoolAdmin {
 | 
			
		||||
    _riskAdmins[admin] = false;
 | 
			
		||||
    emit RiskAdminUnregistered(admin);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function isRiskAdmin(address admin) external view override onlyPoolAdmin returns (bool) {
 | 
			
		||||
    return _riskAdmins[admin];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function registerRiskAdmin(address admin) external override onlyPoolAdmin {
 | 
			
		||||
    _riskAdmins[admin] = true;
 | 
			
		||||
    emit RiskAdminRegistered(admin);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function unregisterRiskAdmin(address admin) external override onlyPoolAdmin {
 | 
			
		||||
    _riskAdmins[admin] = false;
 | 
			
		||||
    emit RiskAdminUnregistered(admin);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function authorizeFlashBorrower(address flashBorrower) external override onlyPoolAdmin {
 | 
			
		||||
    pool.authorizeFlashBorrower(flashBorrower);
 | 
			
		||||
    emit FlashBorrowerAuthorized(flashBorrower);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function unauthorizeFlashBorrower(address flashBorrower) external override onlyPoolAdmin {
 | 
			
		||||
    pool.unauthorizeFlashBorrower(flashBorrower);
 | 
			
		||||
    emit FlashBorrowerUnauthorized(flashBorrower);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// @inheritdoc ILendingPoolConfigurator
 | 
			
		||||
  function isRiskAdmin(address admin) external view override onlyPoolAdmin returns (bool) {
 | 
			
		||||
    return _riskAdmins[admin];
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -575,7 +545,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  function _checkNoLiquidity(address asset) internal view {
 | 
			
		||||
    DataTypes.ReserveData memory reserveData = pool.getReserveData(asset);
 | 
			
		||||
    DataTypes.ReserveData memory reserveData = _pool.getReserveData(asset);
 | 
			
		||||
 | 
			
		||||
    uint256 availableLiquidity = IERC20Detailed(asset).balanceOf(reserveData.aTokenAddress);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,8 +20,8 @@ library ReserveConfiguration {
 | 
			
		|||
  uint256 constant STABLE_BORROWING_MASK =      0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFFFFF; // prettier-ignore
 | 
			
		||||
  uint256 constant PAUSED_MASK =                0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFF; // prettier-ignore
 | 
			
		||||
  uint256 constant RESERVE_FACTOR_MASK =        0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF; // prettier-ignore
 | 
			
		||||
  uint256 constant BORROW_CAP_MASK =            0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000FFFFFFFFFFFFFFFFFFFF; // prettier-ignore
 | 
			
		||||
  uint256 constant SUPPLY_CAP_MASK =            0xFFFFFFFFFFFFFFFFFFFF000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore
 | 
			
		||||
  uint256 constant BORROW_CAP_MASK =            0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFF; // prettier-ignore
 | 
			
		||||
  uint256 constant SUPPLY_CAP_MASK =            0xFFFFFFFFFFFFFFFFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore
 | 
			
		||||
 | 
			
		||||
  /// @dev For the LTV, the start bit is 0 (up to 15), hence no bitshifting is needed
 | 
			
		||||
  uint256 constant LIQUIDATION_THRESHOLD_START_BIT_POSITION = 16;
 | 
			
		||||
| 
						 | 
				
			
			@ -35,15 +35,15 @@ library ReserveConfiguration {
 | 
			
		|||
  // bits 61 62 63 unused yet
 | 
			
		||||
  uint256 constant RESERVE_FACTOR_START_BIT_POSITION = 64;
 | 
			
		||||
  uint256 constant BORROW_CAP_START_BIT_POSITION = 80;
 | 
			
		||||
  uint256 constant SUPPLY_CAP_START_BIT_POSITION = 128;
 | 
			
		||||
  uint256 constant SUPPLY_CAP_START_BIT_POSITION = 116;
 | 
			
		||||
 | 
			
		||||
  uint256 constant MAX_VALID_LTV = 65535;
 | 
			
		||||
  uint256 constant MAX_VALID_LIQUIDATION_THRESHOLD = 65535;
 | 
			
		||||
  uint256 constant MAX_VALID_LIQUIDATION_BONUS = 65535;
 | 
			
		||||
  uint256 constant MAX_VALID_DECIMALS = 255;
 | 
			
		||||
  uint256 constant MAX_VALID_RESERVE_FACTOR = 65535;
 | 
			
		||||
  uint256 constant MAX_VALID_BORROW_CAP = 281474976710655;
 | 
			
		||||
  uint256 constant MAX_VALID_SUPPLY_CAP = 281474976710655;
 | 
			
		||||
  uint256 constant MAX_VALID_BORROW_CAP = 68719476735;
 | 
			
		||||
  uint256 constant MAX_VALID_SUPPLY_CAP = 68719476735;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Sets the Loan to Value of the reserve
 | 
			
		||||
| 
						 | 
				
			
			@ -304,9 +304,7 @@ library ReserveConfiguration {
 | 
			
		|||
  {
 | 
			
		||||
    require(borrowCap <= MAX_VALID_BORROW_CAP, Errors.RC_INVALID_BORROW_CAP);
 | 
			
		||||
 | 
			
		||||
    self.data =
 | 
			
		||||
      (self.data & BORROW_CAP_MASK) |
 | 
			
		||||
      (borrowCap << BORROW_CAP_START_BIT_POSITION);
 | 
			
		||||
    self.data = (self.data & BORROW_CAP_MASK) | (borrowCap << BORROW_CAP_START_BIT_POSITION);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
| 
						 | 
				
			
			@ -333,9 +331,7 @@ library ReserveConfiguration {
 | 
			
		|||
  {
 | 
			
		||||
    require(supplyCap <= MAX_VALID_SUPPLY_CAP, Errors.RC_INVALID_SUPPLY_CAP);
 | 
			
		||||
 | 
			
		||||
    self.data =
 | 
			
		||||
      (self.data & SUPPLY_CAP_MASK) |
 | 
			
		||||
      (supplyCap << SUPPLY_CAP_START_BIT_POSITION);
 | 
			
		||||
    self.data = (self.data & SUPPLY_CAP_MASK) | (supplyCap << SUPPLY_CAP_START_BIT_POSITION);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
| 
						 | 
				
			
			@ -413,16 +409,13 @@ library ReserveConfiguration {
 | 
			
		|||
  function getCaps(DataTypes.ReserveConfigurationMap storage self)
 | 
			
		||||
    internal
 | 
			
		||||
    view
 | 
			
		||||
    returns (
 | 
			
		||||
      uint256,
 | 
			
		||||
      uint256
 | 
			
		||||
    )
 | 
			
		||||
    returns (uint256, uint256)
 | 
			
		||||
  {
 | 
			
		||||
    uint256 dataLocal = self.data;
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
      (self.data & ~BORROW_CAP_MASK) >> BORROW_CAP_START_BIT_POSITION,
 | 
			
		||||
      (self.data & ~SUPPLY_CAP_MASK) >> SUPPLY_CAP_START_BIT_POSITION
 | 
			
		||||
      (dataLocal & ~BORROW_CAP_MASK) >> BORROW_CAP_START_BIT_POSITION,
 | 
			
		||||
      (dataLocal & ~SUPPLY_CAP_MASK) >> SUPPLY_CAP_START_BIT_POSITION
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -459,10 +452,7 @@ library ReserveConfiguration {
 | 
			
		|||
  function getCapsMemory(DataTypes.ReserveConfigurationMap memory self)
 | 
			
		||||
    internal
 | 
			
		||||
    pure
 | 
			
		||||
    returns (
 | 
			
		||||
      uint256,
 | 
			
		||||
      uint256
 | 
			
		||||
    )
 | 
			
		||||
    returns (uint256, uint256)
 | 
			
		||||
  {
 | 
			
		||||
    return (
 | 
			
		||||
      (self.data & ~BORROW_CAP_MASK) >> BORROW_CAP_START_BIT_POSITION,
 | 
			
		||||
| 
						 | 
				
			
			@ -494,4 +484,30 @@ library ReserveConfiguration {
 | 
			
		|||
      (self.data & ~PAUSED_MASK) != 0
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Gets the supply cap of the reserve from a memory objet
 | 
			
		||||
   * @param self The reserve configuration
 | 
			
		||||
   * @return The supply cap
 | 
			
		||||
   **/
 | 
			
		||||
  function getSupplyCapMemory(DataTypes.ReserveConfigurationMap memory self)
 | 
			
		||||
    internal
 | 
			
		||||
    pure
 | 
			
		||||
    returns (uint256)
 | 
			
		||||
  {
 | 
			
		||||
    return (self.data & ~SUPPLY_CAP_MASK) >> SUPPLY_CAP_START_BIT_POSITION;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Gets the borrow cap of the reserve from a memory object
 | 
			
		||||
   * @param self The reserve configuration
 | 
			
		||||
   * @return The borrow cap
 | 
			
		||||
   **/
 | 
			
		||||
  function getBorrowCapMemory(DataTypes.ReserveConfigurationMap memory self)
 | 
			
		||||
    internal
 | 
			
		||||
    pure
 | 
			
		||||
    returns (uint256)
 | 
			
		||||
  {
 | 
			
		||||
    return (self.data & ~BORROW_CAP_MASK) >> BORROW_CAP_START_BIT_POSITION;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,17 +40,20 @@ library ValidationLogic {
 | 
			
		|||
   * @param reserve The reserve object on which the user is depositing
 | 
			
		||||
   * @param amount The amount to be deposited
 | 
			
		||||
   */
 | 
			
		||||
  function validateDeposit(DataTypes.ReserveData storage reserve, uint256 amount) external view {
 | 
			
		||||
    (bool isActive, bool isFrozen, , , bool isPaused) = reserve.configuration.getFlags();
 | 
			
		||||
  function validateDeposit(DataTypes.ReserveData storage reserve, uint256 amount) internal view {
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory reserveConfiguration = reserve.configuration;
 | 
			
		||||
    (bool isActive, bool isFrozen, , , bool isPaused) = reserveConfiguration.getFlagsMemory();
 | 
			
		||||
    (, , , uint256 reserveDecimals, ) = reserveConfiguration.getParamsMemory();
 | 
			
		||||
    uint256 supplyCap = reserveConfiguration.getSupplyCapMemory();
 | 
			
		||||
 | 
			
		||||
    require(amount != 0, Errors.VL_INVALID_AMOUNT);
 | 
			
		||||
    require(isActive, Errors.VL_NO_ACTIVE_RESERVE);
 | 
			
		||||
    require(!isPaused, Errors.VL_RESERVE_PAUSED);
 | 
			
		||||
    require(!isFrozen, Errors.VL_RESERVE_FROZEN);
 | 
			
		||||
    require(
 | 
			
		||||
      IERC20(reserve.aTokenAddress).totalSupply().add(amount).div(
 | 
			
		||||
        10**reserve.configuration.getDecimals()
 | 
			
		||||
      ) < reserve.configuration.getSupplyCap(),
 | 
			
		||||
      supplyCap == 0 ||
 | 
			
		||||
        IERC20(reserve.aTokenAddress).totalSupply().add(amount).div(10**reserveDecimals) <
 | 
			
		||||
        supplyCap,
 | 
			
		||||
      Errors.VL_SUPPLY_CAP_EXCEEDED
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -84,6 +87,8 @@ library ValidationLogic {
 | 
			
		|||
    uint256 healthFactor;
 | 
			
		||||
    uint256 totalSupplyStableDebt;
 | 
			
		||||
    uint256 totalSupplyVariableDebt;
 | 
			
		||||
    uint256 reserveDecimals;
 | 
			
		||||
    uint256 borrowCap;
 | 
			
		||||
    bool isActive;
 | 
			
		||||
    bool isFrozen;
 | 
			
		||||
    bool isPaused;
 | 
			
		||||
| 
						 | 
				
			
			@ -119,16 +124,19 @@ library ValidationLogic {
 | 
			
		|||
    mapping(uint256 => address) storage reserves,
 | 
			
		||||
    uint256 reservesCount,
 | 
			
		||||
    address oracle
 | 
			
		||||
  ) internal view {
 | 
			
		||||
  ) external view {
 | 
			
		||||
    ValidateBorrowLocalVars memory vars;
 | 
			
		||||
 | 
			
		||||
    DataTypes.ReserveConfigurationMap memory reserveConfiguration = reserve.configuration;
 | 
			
		||||
    (, , , vars.reserveDecimals, ) = reserveConfiguration.getParamsMemory();
 | 
			
		||||
 | 
			
		||||
    (
 | 
			
		||||
      vars.isActive,
 | 
			
		||||
      vars.isFrozen,
 | 
			
		||||
      vars.borrowingEnabled,
 | 
			
		||||
      vars.stableRateBorrowingEnabled,
 | 
			
		||||
      vars.isPaused
 | 
			
		||||
    ) = reserve.configuration.getFlags();
 | 
			
		||||
    ) = reserveConfiguration.getFlagsMemory();
 | 
			
		||||
 | 
			
		||||
    require(vars.isActive, Errors.VL_NO_ACTIVE_RESERVE);
 | 
			
		||||
    require(!vars.isPaused, Errors.VL_RESERVE_PAUSED);
 | 
			
		||||
| 
						 | 
				
			
			@ -144,17 +152,16 @@ library ValidationLogic {
 | 
			
		|||
      Errors.VL_INVALID_INTEREST_RATE_MODE_SELECTED
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    (vars.totalSupplyStableDebt, ) = IStableDebtToken(reserve.stableDebtTokenAddress)
 | 
			
		||||
      .getTotalSupplyAndAvgRate();
 | 
			
		||||
 | 
			
		||||
    vars.totalSupplyVariableDebt = IVariableDebtToken(reserve.variableDebtTokenAddress)
 | 
			
		||||
      .scaledTotalSupply()
 | 
			
		||||
      .rayMul(reserve.variableBorrowIndex);
 | 
			
		||||
    vars.totalSupplyStableDebt = IERC20(reserve.stableDebtTokenAddress).totalSupply();
 | 
			
		||||
    vars.borrowCap = reserveConfiguration.getBorrowCapMemory();
 | 
			
		||||
    vars.totalSupplyVariableDebt = IERC20(reserve.variableDebtTokenAddress).totalSupply();
 | 
			
		||||
 | 
			
		||||
    require(
 | 
			
		||||
      vars.totalSupplyStableDebt.add(vars.totalSupplyVariableDebt).add(amount).div(
 | 
			
		||||
        10**reserve.configuration.getDecimals()
 | 
			
		||||
      ) < reserve.configuration.getBorrowCap(),
 | 
			
		||||
      vars.borrowCap == 0 ||
 | 
			
		||||
        vars.totalSupplyStableDebt.add(vars.totalSupplyVariableDebt).add(amount).div(
 | 
			
		||||
          10**vars.reserveDecimals
 | 
			
		||||
        ) <
 | 
			
		||||
        vars.borrowCap,
 | 
			
		||||
      Errors.VL_BORROW_CAP_EXCEEDED
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,8 +39,8 @@ library DataTypes {
 | 
			
		|||
    //bit 60: asset is paused
 | 
			
		||||
    //bit 61-63: reserved
 | 
			
		||||
    //bit 64-79: reserve factor
 | 
			
		||||
    //bit 80-127 borrow cap
 | 
			
		||||
    //bit 128-175 borrow cap
 | 
			
		||||
    //bit 80-115 borrow cap, borrowCap == 0 => disabled
 | 
			
		||||
    //bit 116-152 supply cap, supplyCap == 0 => disabled
 | 
			
		||||
    uint256 data;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,3 +21,5 @@ services:
 | 
			
		|||
      ALCHEMY_KEY: ${ALCHEMY_KEY}
 | 
			
		||||
      TENDERLY_FORK_ID: ${TENDERLY_FORK_ID}
 | 
			
		||||
      TENDERLY_HEAD_ID: ${TENDERLY_HEAD_ID}
 | 
			
		||||
      DEFENDER_API_KEY: ${DEFENDER_API_KEY}
 | 
			
		||||
      DEFENDER_SECRET_KEY: ${DEFENDER_SECRET_KEY}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ import {
 | 
			
		|||
  ICommonConfiguration,
 | 
			
		||||
  eNetwork,
 | 
			
		||||
} from './types';
 | 
			
		||||
import { getParamPerPool } from './contracts-helpers';
 | 
			
		||||
import { getEthersSignersAddresses, getParamPerPool } from './contracts-helpers';
 | 
			
		||||
import AaveConfig from '../markets/aave';
 | 
			
		||||
import MaticConfig from '../markets/matic';
 | 
			
		||||
import AmmConfig from '../markets/amm';
 | 
			
		||||
| 
						 | 
				
			
			@ -66,9 +66,7 @@ export const getGenesisPoolAdmin = async (
 | 
			
		|||
  if (targetAddress) {
 | 
			
		||||
    return targetAddress;
 | 
			
		||||
  }
 | 
			
		||||
  const addressList = await Promise.all(
 | 
			
		||||
    (await DRE.ethers.getSigners()).map((signer) => signer.getAddress())
 | 
			
		||||
  );
 | 
			
		||||
  const addressList = await getEthersSignersAddresses();
 | 
			
		||||
  const addressIndex = config.PoolAdminIndex;
 | 
			
		||||
  return addressList[addressIndex];
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -81,9 +79,7 @@ export const getEmergencyAdmin = async (
 | 
			
		|||
  if (targetAddress) {
 | 
			
		||||
    return targetAddress;
 | 
			
		||||
  }
 | 
			
		||||
  const addressList = await Promise.all(
 | 
			
		||||
    (await DRE.ethers.getSigners()).map((signer) => signer.getAddress())
 | 
			
		||||
  );
 | 
			
		||||
  const addressList = await getEthersSignersAddresses();
 | 
			
		||||
  const addressIndex = config.EmergencyAdminIndex;
 | 
			
		||||
  return addressList[addressIndex];
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,8 +15,8 @@ export const oneEther = new BigNumber(Math.pow(10, 18));
 | 
			
		|||
export const oneRay = new BigNumber(Math.pow(10, 27));
 | 
			
		||||
export const MAX_UINT_AMOUNT =
 | 
			
		||||
  '115792089237316195423570985008687907853269984665640564039457584007913129639935';
 | 
			
		||||
export const MAX_BORROW_CAP = '281474976710655';
 | 
			
		||||
export const MAX_SUPPLY_CAP = '281474976710655';
 | 
			
		||||
export const MAX_BORROW_CAP = '68719476735';
 | 
			
		||||
export const MAX_SUPPLY_CAP = '68719476735';
 | 
			
		||||
export const ONE_YEAR = '31536000';
 | 
			
		||||
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
 | 
			
		||||
export const ONE_ADDRESS = '0x0000000000000000000000000000000000000001';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -137,7 +137,9 @@ export const deployGenericLogic = async (reserveLogic: Contract, verify?: boolea
 | 
			
		|||
    linkedGenericLogicByteCode
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  const genericLogic = await (await genericLogicFactory.deploy()).deployed();
 | 
			
		||||
  const genericLogic = await (
 | 
			
		||||
    await genericLogicFactory.connect(await getFirstSigner()).deploy()
 | 
			
		||||
  ).deployed();
 | 
			
		||||
  return withSaveAndVerify(genericLogic, eContractid.GenericLogic, [], verify);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -158,7 +160,9 @@ export const deployValidationLogic = async (
 | 
			
		|||
    linkedValidationLogicByteCode
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  const validationLogic = await (await validationLogicFactory.deploy()).deployed();
 | 
			
		||||
  const validationLogic = await (
 | 
			
		||||
    await validationLogicFactory.connect(await getFirstSigner()).deploy()
 | 
			
		||||
  ).deployed();
 | 
			
		||||
 | 
			
		||||
  return withSaveAndVerify(validationLogic, eContractid.ValidationLogic, [], verify);
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,11 +32,11 @@ import {
 | 
			
		|||
  FlashLiquidationAdapterFactory,
 | 
			
		||||
} from '../types';
 | 
			
		||||
import { IERC20DetailedFactory } from '../types/IERC20DetailedFactory';
 | 
			
		||||
import { MockTokenMap } from './contracts-helpers';
 | 
			
		||||
import { getEthersSigners, MockTokenMap } from './contracts-helpers';
 | 
			
		||||
import { DRE, getDb, notFalsyOrZeroAddress } from './misc-utils';
 | 
			
		||||
import { eContractid, PoolConfiguration, tEthereumAddress, TokenContractId } from './types';
 | 
			
		||||
 | 
			
		||||
export const getFirstSigner = async () => (await DRE.ethers.getSigners())[0];
 | 
			
		||||
export const getFirstSigner = async () => (await getEthersSigners())[0];
 | 
			
		||||
 | 
			
		||||
export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await LendingPoolAddressesProviderFactory.connect(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,9 +23,10 @@ import { MintableERC20 } from '../types/MintableERC20';
 | 
			
		|||
import { Artifact } from 'hardhat/types';
 | 
			
		||||
import { Artifact as BuidlerArtifact } from '@nomiclabs/buidler/types';
 | 
			
		||||
import { verifyEtherscanContract } from './etherscan-verification';
 | 
			
		||||
import { getIErc20Detailed } from './contracts-getters';
 | 
			
		||||
import { getFirstSigner, getIErc20Detailed } from './contracts-getters';
 | 
			
		||||
import { usingTenderly, verifyAtTenderly } from './tenderly-utils';
 | 
			
		||||
import { usingPolygon, verifyAtPolygon } from './polygon-utils';
 | 
			
		||||
import { getDefenderRelaySigner, usingDefender } from './defender-utils';
 | 
			
		||||
 | 
			
		||||
export type MockTokenMap = { [symbol: string]: MintableERC20 };
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -66,11 +67,18 @@ export const rawInsertContractAddressInDb = async (id: string, address: tEthereu
 | 
			
		|||
    })
 | 
			
		||||
    .write();
 | 
			
		||||
 | 
			
		||||
export const getEthersSigners = async (): Promise<Signer[]> =>
 | 
			
		||||
  await Promise.all(await DRE.ethers.getSigners());
 | 
			
		||||
export const getEthersSigners = async (): Promise<Signer[]> => {
 | 
			
		||||
  const ethersSigners = await Promise.all(await DRE.ethers.getSigners());
 | 
			
		||||
 | 
			
		||||
  if (usingDefender()) {
 | 
			
		||||
    const [, ...users] = ethersSigners;
 | 
			
		||||
    return [await getDefenderRelaySigner(), ...users];
 | 
			
		||||
  }
 | 
			
		||||
  return ethersSigners;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getEthersSignersAddresses = async (): Promise<tEthereumAddress[]> =>
 | 
			
		||||
  await Promise.all((await DRE.ethers.getSigners()).map((signer) => signer.getAddress()));
 | 
			
		||||
  await Promise.all((await getEthersSigners()).map((signer) => signer.getAddress()));
 | 
			
		||||
 | 
			
		||||
export const getCurrentBlock = async () => {
 | 
			
		||||
  return DRE.ethers.provider.getBlockNumber();
 | 
			
		||||
| 
						 | 
				
			
			@ -83,9 +91,9 @@ export const deployContract = async <ContractType extends Contract>(
 | 
			
		|||
  contractName: string,
 | 
			
		||||
  args: any[]
 | 
			
		||||
): Promise<ContractType> => {
 | 
			
		||||
  const contract = (await (await DRE.ethers.getContractFactory(contractName)).deploy(
 | 
			
		||||
    ...args
 | 
			
		||||
  )) as ContractType;
 | 
			
		||||
  const contract = (await (await DRE.ethers.getContractFactory(contractName))
 | 
			
		||||
    .connect(await getFirstSigner())
 | 
			
		||||
    .deploy(...args)) as ContractType;
 | 
			
		||||
  await waitForTx(contract.deployTransaction);
 | 
			
		||||
  await registerContractInJsonDb(<eContractid>contractName, contract);
 | 
			
		||||
  return contract;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										41
									
								
								helpers/defender-utils.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								helpers/defender-utils.ts
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,41 @@
 | 
			
		|||
import { formatEther } from '@ethersproject/units';
 | 
			
		||||
import { DefenderRelaySigner, DefenderRelayProvider } from 'defender-relay-client/lib/ethers';
 | 
			
		||||
import { Signer } from 'ethers';
 | 
			
		||||
import { HardhatRuntimeEnvironment } from 'hardhat/types';
 | 
			
		||||
import { DRE, impersonateAccountsHardhat } from './misc-utils';
 | 
			
		||||
import { usingTenderly } from './tenderly-utils';
 | 
			
		||||
 | 
			
		||||
export const usingDefender = () => process.env.DEFENDER === 'true';
 | 
			
		||||
 | 
			
		||||
export const getDefenderRelaySigner = async () => {
 | 
			
		||||
  const { DEFENDER_API_KEY, DEFENDER_SECRET_KEY } = process.env;
 | 
			
		||||
  let defenderSigner: Signer;
 | 
			
		||||
 | 
			
		||||
  if (!DEFENDER_API_KEY || !DEFENDER_SECRET_KEY) {
 | 
			
		||||
    throw new Error('Defender secrets required');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const credentials = { apiKey: DEFENDER_API_KEY, apiSecret: DEFENDER_SECRET_KEY };
 | 
			
		||||
 | 
			
		||||
  defenderSigner = new DefenderRelaySigner(credentials, new DefenderRelayProvider(credentials), {
 | 
			
		||||
    speed: 'fast',
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  const defenderAddress = await defenderSigner.getAddress();
 | 
			
		||||
  console.log('  - Using Defender Relay: ', defenderAddress);
 | 
			
		||||
 | 
			
		||||
  // Replace signer if FORK=main is active
 | 
			
		||||
  if (process.env.FORK === 'main') {
 | 
			
		||||
    console.log('  - Impersonating Defender Relay');
 | 
			
		||||
    await impersonateAccountsHardhat([defenderAddress]);
 | 
			
		||||
    defenderSigner = await (DRE as HardhatRuntimeEnvironment).ethers.getSigner(defenderAddress);
 | 
			
		||||
  }
 | 
			
		||||
  // Replace signer if Tenderly network is active
 | 
			
		||||
  if (usingTenderly()) {
 | 
			
		||||
    console.log('  - Impersonating Defender Relay via Tenderly');
 | 
			
		||||
    defenderSigner = await (DRE as HardhatRuntimeEnvironment).ethers.getSigner(defenderAddress);
 | 
			
		||||
  }
 | 
			
		||||
  console.log('  - Balance: ', formatEther(await defenderSigner.getBalance()));
 | 
			
		||||
 | 
			
		||||
  return defenderSigner;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -115,3 +115,17 @@ export const notFalsyOrZeroAddress = (address: tEthereumAddress | null | undefin
 | 
			
		|||
  }
 | 
			
		||||
  return isAddress(address) && !isZeroAddress(address);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const impersonateAccountsHardhat = async (accounts: string[]) => {
 | 
			
		||||
  if (process.env.TENDERLY === 'true') {
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  // eslint-disable-next-line no-restricted-syntax
 | 
			
		||||
  for (const account of accounts) {
 | 
			
		||||
    // eslint-disable-next-line no-await-in-loop
 | 
			
		||||
    await (DRE as HardhatRuntimeEnvironment).network.provider.request({
 | 
			
		||||
      method: 'hardhat_impersonateAccount',
 | 
			
		||||
      params: [account],
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,7 @@ export const usingTenderly = () =>
 | 
			
		|||
 | 
			
		||||
export const verifyAtTenderly = async (id: string, instance: Contract) => {
 | 
			
		||||
  console.log('\n- Doing Tenderly contract verification of', id);
 | 
			
		||||
  await (DRE as any).tenderlyRPC.verify({
 | 
			
		||||
  await (DRE as any).tenderlyNetwork.verify({
 | 
			
		||||
    name: id,
 | 
			
		||||
    address: instance.address,
 | 
			
		||||
  });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,3 @@
 | 
			
		|||
import { MAX_BORROW_CAP, MAX_SUPPLY_CAP } from '../../helpers/constants';
 | 
			
		||||
import { eContractid, IReserveParams } from '../../helpers/types';
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
| 
						 | 
				
			
			@ -23,8 +22,8 @@ export const strategyBUSD: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyDAI: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -37,8 +36,8 @@ export const strategyDAI: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategySUSD: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -51,8 +50,8 @@ export const strategySUSD: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyTUSD: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -65,8 +64,8 @@ export const strategyTUSD: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyUSDC: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -79,8 +78,8 @@ export const strategyUSDC: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '6',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyUSDT: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -93,8 +92,8 @@ export const strategyUSDT: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '6',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyAAVE: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -107,8 +106,8 @@ export const strategyAAVE: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '0',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyBAT: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -121,8 +120,8 @@ export const strategyBAT: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyENJ: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -135,8 +134,8 @@ export const strategyENJ: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -149,8 +148,8 @@ export const strategyWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyKNC: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -163,8 +162,8 @@ export const strategyKNC: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyLINK: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -177,8 +176,8 @@ export const strategyLINK: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyMANA: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -191,8 +190,8 @@ export const strategyMANA: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '3500',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyMKR: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -205,8 +204,8 @@ export const strategyMKR: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyREN: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -219,8 +218,8 @@ export const strategyREN: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategySNX: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -233,8 +232,8 @@ export const strategySNX: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '3500',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Invalid borrow rates in params currently, replaced with snx params
 | 
			
		||||
| 
						 | 
				
			
			@ -248,8 +247,8 @@ export const strategyUNI: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.DelegationAwareAToken,
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyWBTC: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -262,8 +261,8 @@ export const strategyWBTC: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '8',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyYFI: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -276,8 +275,8 @@ export const strategyYFI: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyZRX: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -290,8 +289,8 @@ export const strategyZRX: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyXSUSHI: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -304,6 +303,6 @@ export const strategyXSUSHI: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '3500',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,5 @@
 | 
			
		|||
import { MAX_BORROW_CAP, MAX_SUPPLY_CAP } from '../../helpers/constants';
 | 
			
		||||
import { eContractid, IReserveParams} from '../../helpers/types';
 | 
			
		||||
import {
 | 
			
		||||
  rateStrategyAmmBase,
 | 
			
		||||
  rateStrategyStable,
 | 
			
		||||
  rateStrategyBaseOne,
 | 
			
		||||
} from './rateStrategies';
 | 
			
		||||
 | 
			
		||||
import { eContractid, IReserveParams } from '../../helpers/types';
 | 
			
		||||
import { rateStrategyAmmBase, rateStrategyStable, rateStrategyBaseOne } from './rateStrategies';
 | 
			
		||||
 | 
			
		||||
export const strategyWETH: IReserveParams = {
 | 
			
		||||
  strategy: rateStrategyBaseOne,
 | 
			
		||||
| 
						 | 
				
			
			@ -17,8 +11,8 @@ export const strategyWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyWBTC: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -31,8 +25,8 @@ export const strategyWBTC: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '8',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyDAI: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -45,8 +39,8 @@ export const strategyDAI: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyUSDC: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -59,8 +53,8 @@ export const strategyUSDC: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '6',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyUSDT: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -73,8 +67,8 @@ export const strategyUSDT: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '6',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyDAIWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -87,8 +81,8 @@ export const strategyDAIWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyWBTCWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -101,8 +95,8 @@ export const strategyWBTCWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1500',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyAAVEWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -115,8 +109,8 @@ export const strategyAAVEWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '500',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyBATWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -129,8 +123,8 @@ export const strategyBATWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1500',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyDAIUSDC: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -143,8 +137,8 @@ export const strategyDAIUSDC: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyCRVWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -157,8 +151,8 @@ export const strategyCRVWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1500',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyLINKWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -171,8 +165,8 @@ export const strategyLINKWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1500',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyMKRWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -185,8 +179,8 @@ export const strategyMKRWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1500',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyRENWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -199,8 +193,8 @@ export const strategyRENWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1500',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategySNXWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -213,8 +207,8 @@ export const strategySNXWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyUNIWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -227,8 +221,8 @@ export const strategyUNIWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1500',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyUSDCWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -241,8 +235,8 @@ export const strategyUSDCWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyWBTCUSDC: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -255,8 +249,8 @@ export const strategyWBTCUSDC: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1500',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyYFIWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -269,8 +263,8 @@ export const strategyYFIWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1500',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyBALWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -283,6 +277,6 @@ export const strategyBALWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1500',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
}
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,5 @@
 | 
			
		|||
// import BigNumber from 'bignumber.js';
 | 
			
		||||
// import { oneRay } from '../../helpers/constants';
 | 
			
		||||
import { MAX_BORROW_CAP, MAX_SUPPLY_CAP } from '../../helpers/constants';
 | 
			
		||||
import { eContractid, IReserveParams } from '../../helpers/types';
 | 
			
		||||
import {
 | 
			
		||||
  rateStrategyStableTwo,
 | 
			
		||||
| 
						 | 
				
			
			@ -21,8 +20,8 @@ export const strategyDAI: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyUSDC: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -35,8 +34,8 @@ export const strategyUSDC: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '6',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyUSDT: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -49,8 +48,8 @@ export const strategyUSDT: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '6',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -63,8 +62,8 @@ export const strategyWETH: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyWBTC: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -77,8 +76,8 @@ export const strategyWBTC: IReserveParams = {
 | 
			
		|||
  reserveDecimals: '8',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyMATIC: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -90,6 +89,8 @@ export const strategyMATIC: IReserveParams = {
 | 
			
		|||
  stableBorrowRateEnabled: false,
 | 
			
		||||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
| 
						 | 
				
			
			@ -104,7 +105,7 @@ export const strategyAAVE: IReserveParams = {
 | 
			
		|||
  stableBorrowRateEnabled: false,
 | 
			
		||||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  borrowCap: MAX_BORROW_CAP,
 | 
			
		||||
  supplyCap: MAX_SUPPLY_CAP,
 | 
			
		||||
  borrowCap: '0',
 | 
			
		||||
  supplyCap: '0',
 | 
			
		||||
  reserveFactor: '0',
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1309
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1309
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -100,7 +100,7 @@
 | 
			
		|||
    "@nomiclabs/hardhat-ethers": "^2.0.0",
 | 
			
		||||
    "@nomiclabs/hardhat-waffle": "^2.0.0",
 | 
			
		||||
    "@openzeppelin/contracts": "3.1.0",
 | 
			
		||||
    "@tenderly/hardhat-tenderly": "^1.1.0-beta.4",
 | 
			
		||||
    "@tenderly/hardhat-tenderly": "1.1.0-beta.5",
 | 
			
		||||
    "@typechain/ethers-v4": "1.0.0",
 | 
			
		||||
    "@typechain/ethers-v5": "^2.0.0",
 | 
			
		||||
    "@typechain/truffle-v4": "2.0.2",
 | 
			
		||||
| 
						 | 
				
			
			@ -115,6 +115,7 @@
 | 
			
		|||
    "chai": "4.2.0",
 | 
			
		||||
    "chai-bignumber": "3.0.0",
 | 
			
		||||
    "chai-bn": "^0.2.1",
 | 
			
		||||
    "defender-relay-client": "^1.7.0",
 | 
			
		||||
    "dotenv": "^8.2.0",
 | 
			
		||||
    "eth-sig-util": "2.5.3",
 | 
			
		||||
    "ethereum-waffle": "3.0.2",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,7 @@ import {
 | 
			
		|||
  deployLendingPoolAddressesProvider,
 | 
			
		||||
  deployLendingPoolAddressesProviderRegistry,
 | 
			
		||||
} from '../../helpers/contracts-deployments';
 | 
			
		||||
import { getEthersSigners } from '../../helpers/contracts-helpers';
 | 
			
		||||
import { waitForTx } from '../../helpers/misc-utils';
 | 
			
		||||
import { AaveConfig } from '../../markets/aave';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -14,7 +15,7 @@ task(
 | 
			
		|||
  .setAction(async ({ verify }, localBRE) => {
 | 
			
		||||
    await localBRE.run('set-DRE');
 | 
			
		||||
 | 
			
		||||
    const admin = await (await localBRE.ethers.getSigners())[0].getAddress();
 | 
			
		||||
    const admin = await (await getEthersSigners())[0].getAddress();
 | 
			
		||||
 | 
			
		||||
    const addressesProvider = await deployLendingPoolAddressesProvider(AaveConfig.MarketId, verify);
 | 
			
		||||
    await waitForTx(await addressesProvider.setPoolAdmin(admin));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -82,7 +82,7 @@ task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
 | 
			
		|||
      if (DRE.network.name.includes('tenderly')) {
 | 
			
		||||
        const transactionLink = `https://dashboard.tenderly.co/${DRE.config.tenderly.username}/${
 | 
			
		||||
          DRE.config.tenderly.project
 | 
			
		||||
        }/fork/${DRE.tenderlyRPC.getFork()}/simulation/${DRE.tenderlyRPC.getHead()}`;
 | 
			
		||||
        }/fork/${DRE.tenderlyNetwork.getFork()}/simulation/${DRE.tenderlyNetwork.getHead()}`;
 | 
			
		||||
        console.error('Check tx error:', transactionLink);
 | 
			
		||||
      }
 | 
			
		||||
      throw error;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -84,7 +84,7 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
 | 
			
		|||
      if (DRE.network.name.includes('tenderly')) {
 | 
			
		||||
        const transactionLink = `https://dashboard.tenderly.co/${DRE.config.tenderly.username}/${
 | 
			
		||||
          DRE.config.tenderly.project
 | 
			
		||||
        }/fork/${DRE.tenderlyRPC.getFork()}/simulation/${DRE.tenderlyRPC.getHead()}`;
 | 
			
		||||
        }/fork/${DRE.tenderlyNetwork.getFork()}/simulation/${DRE.tenderlyNetwork.getHead()}`;
 | 
			
		||||
        console.error('Check tx error:', transactionLink);
 | 
			
		||||
      }
 | 
			
		||||
      throw error;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,8 +46,8 @@ task('aave:mainnet', 'Deploy development enviroment')
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    if (usingTenderly()) {
 | 
			
		||||
      const postDeployHead = DRE.tenderlyRPC.getHead();
 | 
			
		||||
      const postDeployFork = DRE.tenderlyRPC.getFork();
 | 
			
		||||
      const postDeployHead = DRE.tenderlyNetwork.getHead();
 | 
			
		||||
      const postDeployFork = DRE.tenderlyNetwork.getFork();
 | 
			
		||||
      console.log('Tenderly Info');
 | 
			
		||||
      console.log('- Head', postDeployHead);
 | 
			
		||||
      console.log('- Fork', postDeployFork);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,8 +46,8 @@ task('amm:mainnet', 'Deploy development enviroment')
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    if (usingTenderly()) {
 | 
			
		||||
      const postDeployHead = DRE.tenderlyRPC.getHead();
 | 
			
		||||
      const postDeployFork = DRE.tenderlyRPC.getFork();
 | 
			
		||||
      const postDeployHead = DRE.tenderlyNetwork.getHead();
 | 
			
		||||
      const postDeployFork = DRE.tenderlyNetwork.getFork();
 | 
			
		||||
      console.log('Tenderly Info');
 | 
			
		||||
      console.log('- Head', postDeployHead);
 | 
			
		||||
      console.log('- Fork', postDeployFork);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,8 +49,8 @@ task('sidechain:mainnet', 'Deploy market at sidechain')
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    if (usingTenderly()) {
 | 
			
		||||
      const postDeployHead = DRE.tenderlyRPC.getHead();
 | 
			
		||||
      const postDeployFork = DRE.tenderlyRPC.getFork();
 | 
			
		||||
      const postDeployHead = DRE.tenderlyNetwork.getHead();
 | 
			
		||||
      const postDeployFork = DRE.tenderlyNetwork.getFork();
 | 
			
		||||
      console.log('Tenderly Info');
 | 
			
		||||
      console.log('- Head', postDeployHead);
 | 
			
		||||
      console.log('- Fork', postDeployFork);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,12 +1,6 @@
 | 
			
		|||
import { task } from 'hardhat/config';
 | 
			
		||||
import { DRE, setDRE } from '../../helpers/misc-utils';
 | 
			
		||||
import { EthereumNetworkNames } from '../../helpers/types';
 | 
			
		||||
import { usingTenderly } from '../../helpers/tenderly-utils';
 | 
			
		||||
import { HardhatRuntimeEnvironment } from 'hardhat/types';
 | 
			
		||||
import { getFirstSigner } from '../../helpers/contracts-getters';
 | 
			
		||||
import { formatEther } from 'ethers/lib/utils';
 | 
			
		||||
import { fork } from 'child_process';
 | 
			
		||||
import { env } from 'process';
 | 
			
		||||
 | 
			
		||||
task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).setAction(
 | 
			
		||||
  async (_, _DRE) => {
 | 
			
		||||
| 
						 | 
				
			
			@ -18,24 +12,21 @@ task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).set
 | 
			
		|||
      process.env.TENDERLY === 'true'
 | 
			
		||||
    ) {
 | 
			
		||||
      console.log('- Setting up Tenderly provider');
 | 
			
		||||
      const net = _DRE.tenderly.network();
 | 
			
		||||
 | 
			
		||||
      if (process.env.TENDERLY_FORK_ID && process.env.TENDERLY_HEAD_ID) {
 | 
			
		||||
        console.log('- Connecting to a Tenderly Fork');
 | 
			
		||||
        _DRE.tenderlyRPC.setFork(process.env.TENDERLY_FORK_ID);
 | 
			
		||||
        _DRE.tenderlyRPC.setHead(process.env.TENDERLY_HEAD_ID);
 | 
			
		||||
        await net.setFork(process.env.TENDERLY_FORK_ID);
 | 
			
		||||
        await net.setHead(process.env.TENDERLY_HEAD_ID);
 | 
			
		||||
      } else {
 | 
			
		||||
        console.log('- Creating a new Tenderly Fork');
 | 
			
		||||
        await _DRE.tenderlyRPC.initializeFork();
 | 
			
		||||
        await net.initializeFork();
 | 
			
		||||
      }
 | 
			
		||||
      const provider = new _DRE.ethers.providers.Web3Provider(_DRE.tenderlyRPC as any);
 | 
			
		||||
      const provider = new _DRE.ethers.providers.Web3Provider(net);
 | 
			
		||||
      _DRE.ethers.provider = provider;
 | 
			
		||||
      console.log('- Initialized Tenderly fork:');
 | 
			
		||||
      console.log('  - Fork: ', _DRE.tenderlyRPC.getFork());
 | 
			
		||||
      console.log('  - Head: ', _DRE.tenderlyRPC.getHead());
 | 
			
		||||
      console.log('  - First account:', await (await _DRE.ethers.getSigners())[0].getAddress());
 | 
			
		||||
      console.log(
 | 
			
		||||
        '  - Balance:',
 | 
			
		||||
        formatEther(await (await _DRE.ethers.getSigners())[0].getBalance())
 | 
			
		||||
      );
 | 
			
		||||
      console.log('  - Fork: ', net.getFork());
 | 
			
		||||
      console.log('  - Head: ', net.getHead());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    console.log('- Enviroment');
 | 
			
		||||
| 
						 | 
				
			
			@ -50,6 +41,7 @@ task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).set
 | 
			
		|||
      }
 | 
			
		||||
    }
 | 
			
		||||
    console.log('  - Network :', _DRE.network.name);
 | 
			
		||||
 | 
			
		||||
    setDRE(_DRE);
 | 
			
		||||
    return _DRE;
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,6 +4,7 @@ import {
 | 
			
		|||
  insertContractAddressInDb,
 | 
			
		||||
  getEthersSigners,
 | 
			
		||||
  registerContractInJsonDb,
 | 
			
		||||
  getEthersSignersAddresses,
 | 
			
		||||
} from '../../helpers/contracts-helpers';
 | 
			
		||||
import {
 | 
			
		||||
  deployLendingPoolAddressesProvider,
 | 
			
		||||
| 
						 | 
				
			
			@ -102,10 +103,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
 | 
			
		|||
  await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
 | 
			
		||||
 | 
			
		||||
  //setting users[1] as emergency admin, which is in position 2 in the DRE addresses list
 | 
			
		||||
  //     .. users[2] as risk admin ..                position 3
 | 
			
		||||
  const addressList: string[] = await Promise.all(
 | 
			
		||||
    (await DRE.ethers.getSigners()).map((signer) => signer.getAddress())
 | 
			
		||||
  );
 | 
			
		||||
  const addressList = await getEthersSignersAddresses();
 | 
			
		||||
 | 
			
		||||
  await waitForTx(await addressesProvider.setEmergencyAdmin(addressList[2]));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,10 +16,9 @@ const { expect } = require('chai');
 | 
			
		|||
makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		||||
  const { VL_BORROW_CAP_EXCEEDED, RC_INVALID_BORROW_CAP } = ProtocolErrors;
 | 
			
		||||
 | 
			
		||||
  const miliUnitToPrecision = async (token: WETH9Mocked | MintableERC20, nb: string) =>
 | 
			
		||||
  const unitParse = async (token: WETH9Mocked | MintableERC20, nb: string) =>
 | 
			
		||||
    BigNumber.from(nb).mul(BigNumber.from('10').pow((await token.decimals()) - 3));
 | 
			
		||||
 | 
			
		||||
  it('Sets the borrow cap for Weth and DAI to 0 Units, deposits weth', async () => {
 | 
			
		||||
  it('Reserves should initially have borrow cap disabled (borrowCap = 0)', async () => {
 | 
			
		||||
    const {
 | 
			
		||||
      configurator,
 | 
			
		||||
      weth,
 | 
			
		||||
| 
						 | 
				
			
			@ -30,61 +29,111 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
      helpersContract,
 | 
			
		||||
      users: [user1],
 | 
			
		||||
    } = testEnv;
 | 
			
		||||
    const mintedMiliAmount = '1000000000000';
 | 
			
		||||
    const daiMinted = await miliUnitToPrecision(dai, mintedMiliAmount);
 | 
			
		||||
    const wethMinted = await miliUnitToPrecision(weth, mintedMiliAmount);
 | 
			
		||||
    const usdcMinted = await miliUnitToPrecision(usdc, mintedMiliAmount);
 | 
			
		||||
    await dai.mint(daiMinted);
 | 
			
		||||
    await weth.mint(wethMinted);
 | 
			
		||||
    await usdc.mint(usdcMinted);
 | 
			
		||||
    await dai.connect(user1.signer).mint(daiMinted);
 | 
			
		||||
    await weth.connect(user1.signer).mint(wethMinted);
 | 
			
		||||
    await usdc.connect(user1.signer).mint(usdcMinted);
 | 
			
		||||
 | 
			
		||||
    const mintedAmount = parseEther('1000000000');
 | 
			
		||||
    // minting for main user
 | 
			
		||||
    await dai.mint(mintedAmount);
 | 
			
		||||
    await weth.mint(mintedAmount);
 | 
			
		||||
    await usdc.mint(mintedAmount);
 | 
			
		||||
    // minting for lp user
 | 
			
		||||
    await dai.connect(user1.signer).mint(mintedAmount);
 | 
			
		||||
    await weth.connect(user1.signer).mint(mintedAmount);
 | 
			
		||||
    await usdc.connect(user1.signer).mint(mintedAmount);
 | 
			
		||||
 | 
			
		||||
    await dai.approve(pool.address, MAX_UINT_AMOUNT);
 | 
			
		||||
    await weth.approve(pool.address, MAX_UINT_AMOUNT);
 | 
			
		||||
    await usdc.approve(pool.address, MAX_UINT_AMOUNT);
 | 
			
		||||
    await dai.connect(user1.signer).approve(pool.address, MAX_UINT_AMOUNT);
 | 
			
		||||
    await weth.connect(user1.signer).approve(pool.address, MAX_UINT_AMOUNT);
 | 
			
		||||
    await usdc.connect(user1.signer).approve(pool.address, MAX_UINT_AMOUNT);
 | 
			
		||||
 | 
			
		||||
    let usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap;
 | 
			
		||||
    let daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap;
 | 
			
		||||
    expect(usdcBorrowCap).to.be.equal(MAX_BORROW_CAP);
 | 
			
		||||
    expect(daiBorrowCap).to.be.equal(MAX_BORROW_CAP);
 | 
			
		||||
    let wethBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap;
 | 
			
		||||
    let wethSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
    expect(wethBorrowCap).to.be.equal(MAX_BORROW_CAP);
 | 
			
		||||
    expect(wethSupplyCap).to.be.equal(MAX_SUPPLY_CAP);
 | 
			
		||||
 | 
			
		||||
    const depositedMiliAmount = (1e9).toString();
 | 
			
		||||
    expect(usdcBorrowCap).to.be.equal('0');
 | 
			
		||||
    expect(daiBorrowCap).to.be.equal('0');
 | 
			
		||||
  });
 | 
			
		||||
  it('Should be able to borrow 10 Dai stable, 10 USDC variable', async () => {
 | 
			
		||||
    const {
 | 
			
		||||
      configurator,
 | 
			
		||||
      weth,
 | 
			
		||||
      pool,
 | 
			
		||||
      dai,
 | 
			
		||||
      usdc,
 | 
			
		||||
      deployer,
 | 
			
		||||
      helpersContract,
 | 
			
		||||
      users: [user1],
 | 
			
		||||
    } = testEnv;
 | 
			
		||||
 | 
			
		||||
    await configurator.setBorrowCap(usdc.address, 0);
 | 
			
		||||
    await configurator.setBorrowCap(dai.address, 0);
 | 
			
		||||
    const suppliedAmount = 1000;
 | 
			
		||||
    const precisionSuppliedAmount = (suppliedAmount * 1000).toString();
 | 
			
		||||
 | 
			
		||||
    usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap;
 | 
			
		||||
    daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap;
 | 
			
		||||
 | 
			
		||||
    expect(usdcBorrowCap).to.be.equal(0);
 | 
			
		||||
    expect(daiBorrowCap).to.be.equal(0);
 | 
			
		||||
    const borrowedAmount = 10;
 | 
			
		||||
    const precisionBorrowedAmount = (borrowedAmount * 1000).toString();
 | 
			
		||||
 | 
			
		||||
    // deposit collateral
 | 
			
		||||
    await pool.deposit(
 | 
			
		||||
      weth.address,
 | 
			
		||||
      await miliUnitToPrecision(weth, depositedMiliAmount),
 | 
			
		||||
      await unitParse(weth, precisionSuppliedAmount),
 | 
			
		||||
      deployer.address,
 | 
			
		||||
      0
 | 
			
		||||
    );
 | 
			
		||||
    await pool.connect(user1.signer).deposit(weth.address, wethMinted, user1.address, 0);
 | 
			
		||||
    await pool.connect(user1.signer).deposit(dai.address, daiMinted, user1.address, 0);
 | 
			
		||||
    await pool.connect(user1.signer).deposit(usdc.address, usdcMinted, user1.address, 0);
 | 
			
		||||
    // user 1 deposit more dai and usdc to be able to borrow
 | 
			
		||||
    await pool
 | 
			
		||||
      .connect(user1.signer)
 | 
			
		||||
      .deposit(dai.address, await unitParse(dai, precisionSuppliedAmount), user1.address, 0);
 | 
			
		||||
 | 
			
		||||
    await pool
 | 
			
		||||
      .connect(user1.signer)
 | 
			
		||||
      .deposit(usdc.address, await unitParse(usdc, precisionSuppliedAmount), user1.address, 0);
 | 
			
		||||
 | 
			
		||||
    // borrow
 | 
			
		||||
    await pool.borrow(
 | 
			
		||||
      usdc.address,
 | 
			
		||||
      await unitParse(usdc, precisionBorrowedAmount),
 | 
			
		||||
      2,
 | 
			
		||||
      0,
 | 
			
		||||
      deployer.address
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    await pool.borrow(
 | 
			
		||||
      dai.address,
 | 
			
		||||
      await unitParse(dai, precisionBorrowedAmount),
 | 
			
		||||
      1,
 | 
			
		||||
      0,
 | 
			
		||||
      deployer.address
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
  it('Sets the borrow cap for Weth and DAI to 10 Units', async () => {
 | 
			
		||||
    const {
 | 
			
		||||
      configurator,
 | 
			
		||||
      weth,
 | 
			
		||||
      pool,
 | 
			
		||||
      dai,
 | 
			
		||||
      usdc,
 | 
			
		||||
      deployer,
 | 
			
		||||
      helpersContract,
 | 
			
		||||
      users: [user1],
 | 
			
		||||
    } = testEnv;
 | 
			
		||||
 | 
			
		||||
    await configurator.setBorrowCap(usdc.address, 10);
 | 
			
		||||
    await configurator.setBorrowCap(dai.address, 10);
 | 
			
		||||
 | 
			
		||||
    const usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap;
 | 
			
		||||
    const daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap;
 | 
			
		||||
 | 
			
		||||
    expect(usdcBorrowCap).to.be.equal(10);
 | 
			
		||||
    expect(daiBorrowCap).to.be.equal(10);
 | 
			
		||||
  });
 | 
			
		||||
  it('should fail to borrow any dai or usdc, stable or variable', async () => {
 | 
			
		||||
    const { usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const borrowedAmount = 10;
 | 
			
		||||
    const borrowedMilimount = (borrowedAmount * 1000).toString();
 | 
			
		||||
    const precisionBorrowedAmount = (borrowedAmount * 1000).toString();
 | 
			
		||||
 | 
			
		||||
    await expect(
 | 
			
		||||
      pool.borrow(
 | 
			
		||||
        usdc.address,
 | 
			
		||||
        await miliUnitToPrecision(usdc, borrowedMilimount),
 | 
			
		||||
        await unitParse(usdc, precisionBorrowedAmount),
 | 
			
		||||
        2,
 | 
			
		||||
        0,
 | 
			
		||||
        deployer.address
 | 
			
		||||
| 
						 | 
				
			
			@ -94,7 +143,7 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
    await expect(
 | 
			
		||||
      pool.borrow(
 | 
			
		||||
        dai.address,
 | 
			
		||||
        await miliUnitToPrecision(dai, borrowedMilimount),
 | 
			
		||||
        await unitParse(dai, precisionBorrowedAmount),
 | 
			
		||||
        2,
 | 
			
		||||
        0,
 | 
			
		||||
        deployer.address
 | 
			
		||||
| 
						 | 
				
			
			@ -104,11 +153,6 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
  it('Should fail to set the borrow cap for usdc and DAI to max cap + 1 Units', async () => {
 | 
			
		||||
    const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const newCap = Number(MAX_BORROW_CAP) + 1;
 | 
			
		||||
    let usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap;
 | 
			
		||||
    let daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap;
 | 
			
		||||
 | 
			
		||||
    expect(usdcBorrowCap).to.be.equal(0);
 | 
			
		||||
    expect(daiBorrowCap).to.be.equal(0);
 | 
			
		||||
 | 
			
		||||
    await expect(configurator.setBorrowCap(usdc.address, newCap)).to.be.revertedWith(
 | 
			
		||||
      RC_INVALID_BORROW_CAP
 | 
			
		||||
| 
						 | 
				
			
			@ -116,24 +160,16 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
    await expect(configurator.setBorrowCap(dai.address, newCap)).to.be.revertedWith(
 | 
			
		||||
      RC_INVALID_BORROW_CAP
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap;
 | 
			
		||||
    daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap;
 | 
			
		||||
  });
 | 
			
		||||
  it('Sets the borrow cap for usdc and DAI to 110 Units', async () => {
 | 
			
		||||
  it('Sets the borrow cap for usdc and DAI to 120 Units', async () => {
 | 
			
		||||
    const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const newCap = '110';
 | 
			
		||||
    let usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap;
 | 
			
		||||
    let daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap;
 | 
			
		||||
 | 
			
		||||
    expect(usdcBorrowCap).to.be.equal(0);
 | 
			
		||||
    expect(daiBorrowCap).to.be.equal(0);
 | 
			
		||||
    const newCap = '120';
 | 
			
		||||
 | 
			
		||||
    await configurator.setBorrowCap(usdc.address, newCap);
 | 
			
		||||
    await configurator.setBorrowCap(dai.address, newCap);
 | 
			
		||||
 | 
			
		||||
    usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap;
 | 
			
		||||
    daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap;
 | 
			
		||||
    const usdcBorrowCap = (await helpersContract.getReserveCaps(usdc.address)).borrowCap;
 | 
			
		||||
    const daiBorrowCap = (await helpersContract.getReserveCaps(dai.address)).borrowCap;
 | 
			
		||||
 | 
			
		||||
    expect(usdcBorrowCap).to.be.equal(newCap);
 | 
			
		||||
    expect(daiBorrowCap).to.be.equal(newCap);
 | 
			
		||||
| 
						 | 
				
			
			@ -141,10 +177,10 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
  it('Should succeed to borrow 10 stable dai and 10 variable usdc', async () => {
 | 
			
		||||
    const { usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const borrowedAmount = 10;
 | 
			
		||||
    const borrowedMilimount = (borrowedAmount * 1000).toString();
 | 
			
		||||
    const precisionBorrowedAmount = (borrowedAmount * 1000).toString();
 | 
			
		||||
    await pool.borrow(
 | 
			
		||||
      usdc.address,
 | 
			
		||||
      await miliUnitToPrecision(usdc, borrowedMilimount),
 | 
			
		||||
      await unitParse(usdc, precisionBorrowedAmount),
 | 
			
		||||
      2,
 | 
			
		||||
      0,
 | 
			
		||||
      deployer.address
 | 
			
		||||
| 
						 | 
				
			
			@ -152,7 +188,7 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
 | 
			
		||||
    await pool.borrow(
 | 
			
		||||
      dai.address,
 | 
			
		||||
      await miliUnitToPrecision(dai, borrowedMilimount),
 | 
			
		||||
      await unitParse(dai, precisionBorrowedAmount),
 | 
			
		||||
      1,
 | 
			
		||||
      0,
 | 
			
		||||
      deployer.address
 | 
			
		||||
| 
						 | 
				
			
			@ -161,12 +197,12 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
  it('should fail to borrow 100 variable dai and 100 stable usdc', async () => {
 | 
			
		||||
    const { usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const borrowedAmount = 100;
 | 
			
		||||
    const borrowedMilimount = (borrowedAmount * 1000).toString();
 | 
			
		||||
    const precisionBorrowedAmount = (borrowedAmount * 1000).toString();
 | 
			
		||||
 | 
			
		||||
    await expect(
 | 
			
		||||
      pool.borrow(
 | 
			
		||||
        usdc.address,
 | 
			
		||||
        await miliUnitToPrecision(usdc, borrowedMilimount),
 | 
			
		||||
        await unitParse(usdc, precisionBorrowedAmount),
 | 
			
		||||
        1,
 | 
			
		||||
        0,
 | 
			
		||||
        deployer.address
 | 
			
		||||
| 
						 | 
				
			
			@ -176,7 +212,7 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
    await expect(
 | 
			
		||||
      pool.borrow(
 | 
			
		||||
        dai.address,
 | 
			
		||||
        await miliUnitToPrecision(dai, borrowedMilimount),
 | 
			
		||||
        await unitParse(dai, precisionBorrowedAmount),
 | 
			
		||||
        2,
 | 
			
		||||
        0,
 | 
			
		||||
        deployer.address
 | 
			
		||||
| 
						 | 
				
			
			@ -186,10 +222,10 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
  it('Should succeed to borrow 99 variable dai and 99 stable usdc', async () => {
 | 
			
		||||
    const { usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const borrowedAmount = 99;
 | 
			
		||||
    const borrowedMilimount = (borrowedAmount * 1000).toString();
 | 
			
		||||
    const precisionBorrowedAmount = (borrowedAmount * 1000).toString();
 | 
			
		||||
    await pool.borrow(
 | 
			
		||||
      usdc.address,
 | 
			
		||||
      await miliUnitToPrecision(usdc, borrowedMilimount),
 | 
			
		||||
      await unitParse(usdc, precisionBorrowedAmount),
 | 
			
		||||
      2,
 | 
			
		||||
      0,
 | 
			
		||||
      deployer.address
 | 
			
		||||
| 
						 | 
				
			
			@ -197,7 +233,7 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
 | 
			
		||||
    await pool.borrow(
 | 
			
		||||
      dai.address,
 | 
			
		||||
      await miliUnitToPrecision(dai, borrowedMilimount),
 | 
			
		||||
      await unitParse(dai, precisionBorrowedAmount),
 | 
			
		||||
      1,
 | 
			
		||||
      0,
 | 
			
		||||
      deployer.address
 | 
			
		||||
| 
						 | 
				
			
			@ -221,11 +257,11 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
  it('should succeed to borrow 100 variable dai and 100 stable usdc', async () => {
 | 
			
		||||
    const { usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const borrowedAmount = 100;
 | 
			
		||||
    const borrowedMilimount = (borrowedAmount * 1000).toString();
 | 
			
		||||
    const precisionBorrowedAmount = (borrowedAmount * 1000).toString();
 | 
			
		||||
 | 
			
		||||
    await pool.borrow(
 | 
			
		||||
      usdc.address,
 | 
			
		||||
      await miliUnitToPrecision(usdc, borrowedMilimount),
 | 
			
		||||
      await unitParse(usdc, precisionBorrowedAmount),
 | 
			
		||||
      1,
 | 
			
		||||
      0,
 | 
			
		||||
      deployer.address
 | 
			
		||||
| 
						 | 
				
			
			@ -233,7 +269,7 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
 | 
			
		||||
    await pool.borrow(
 | 
			
		||||
      dai.address,
 | 
			
		||||
      await miliUnitToPrecision(dai, borrowedMilimount),
 | 
			
		||||
      await unitParse(dai, precisionBorrowedAmount),
 | 
			
		||||
      2,
 | 
			
		||||
      0,
 | 
			
		||||
      deployer.address
 | 
			
		||||
| 
						 | 
				
			
			@ -257,12 +293,12 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
  it('should fail to borrow 100 variable dai and 100 stable usdc', async () => {
 | 
			
		||||
    const { usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const borrowedAmount = 100;
 | 
			
		||||
    const borrowedMilimount = (borrowedAmount * 1000).toString();
 | 
			
		||||
    const precisionBorrowedAmount = (borrowedAmount * 1000).toString();
 | 
			
		||||
 | 
			
		||||
    await expect(
 | 
			
		||||
      pool.borrow(
 | 
			
		||||
        usdc.address,
 | 
			
		||||
        await miliUnitToPrecision(usdc, borrowedMilimount),
 | 
			
		||||
        await unitParse(usdc, precisionBorrowedAmount),
 | 
			
		||||
        1,
 | 
			
		||||
        0,
 | 
			
		||||
        deployer.address
 | 
			
		||||
| 
						 | 
				
			
			@ -272,7 +308,7 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
    await expect(
 | 
			
		||||
      pool.borrow(
 | 
			
		||||
        dai.address,
 | 
			
		||||
        await miliUnitToPrecision(dai, borrowedMilimount),
 | 
			
		||||
        await unitParse(dai, precisionBorrowedAmount),
 | 
			
		||||
        2,
 | 
			
		||||
        0,
 | 
			
		||||
        deployer.address
 | 
			
		||||
| 
						 | 
				
			
			@ -297,11 +333,11 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
  it('should succeed to borrow 100 variable dai and 100 stable usdc', async () => {
 | 
			
		||||
    const { usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const borrowedAmount = 100;
 | 
			
		||||
    const borrowedMilimount = (borrowedAmount * 1000).toString();
 | 
			
		||||
    const precisionBorrowedAmount = (borrowedAmount * 1000).toString();
 | 
			
		||||
 | 
			
		||||
    await pool.borrow(
 | 
			
		||||
      usdc.address,
 | 
			
		||||
      await miliUnitToPrecision(usdc, borrowedMilimount),
 | 
			
		||||
      await unitParse(usdc, precisionBorrowedAmount),
 | 
			
		||||
      1,
 | 
			
		||||
      0,
 | 
			
		||||
      deployer.address
 | 
			
		||||
| 
						 | 
				
			
			@ -309,7 +345,7 @@ makeSuite('Borrow Cap', (testEnv: TestEnv) => {
 | 
			
		|||
 | 
			
		||||
    await pool.borrow(
 | 
			
		||||
      dai.address,
 | 
			
		||||
      await miliUnitToPrecision(dai, borrowedMilimount),
 | 
			
		||||
      await unitParse(dai, precisionBorrowedAmount),
 | 
			
		||||
      2,
 | 
			
		||||
      0,
 | 
			
		||||
      deployer.address
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -73,7 +73,6 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
 | 
			
		|||
    expect(await configurator.signer.getAddress()).to.be.equal(
 | 
			
		||||
      await addressesProvider.getPoolAdmin()
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    await configurator.pauseReserve(weth.address);
 | 
			
		||||
    const {
 | 
			
		||||
      decimals,
 | 
			
		||||
| 
						 | 
				
			
			@ -220,7 +219,147 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
 | 
			
		|||
    ).to.be.revertedWith(LPC_CALLER_NOT_EMERGENCY_OR_POOL_ADMIN);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('Freezes the ETH reserve', async () => {
 | 
			
		||||
    await configurator.pauseReserve(weth.address);
 | 
			
		||||
    const {
 | 
			
		||||
      decimals,
 | 
			
		||||
      ltv,
 | 
			
		||||
      liquidationBonus,
 | 
			
		||||
      liquidationThreshold,
 | 
			
		||||
      reserveFactor,
 | 
			
		||||
      stableBorrowRateEnabled,
 | 
			
		||||
      borrowingEnabled,
 | 
			
		||||
      isActive,
 | 
			
		||||
      isFrozen,
 | 
			
		||||
    } = await helpersContract.getReserveConfigurationData(weth.address);
 | 
			
		||||
    const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
 | 
			
		||||
    const isPaused = await helpersContract.getPaused(weth.address);
 | 
			
		||||
 | 
			
		||||
    expect(borrowingEnabled).to.be.equal(true);
 | 
			
		||||
    expect(isActive).to.be.equal(true);
 | 
			
		||||
    expect(isPaused).to.be.equal(true);
 | 
			
		||||
    expect(isFrozen).to.be.equal(false);
 | 
			
		||||
    expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
 | 
			
		||||
    expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
 | 
			
		||||
    expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
 | 
			
		||||
    expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
 | 
			
		||||
    expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled);
 | 
			
		||||
    expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor);
 | 
			
		||||
    expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
 | 
			
		||||
    expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('Unpauses the ETH reserve by pool admin ', async () => {
 | 
			
		||||
    const { configurator, helpersContract, weth } = testEnv;
 | 
			
		||||
    await configurator.unpauseReserve(weth.address);
 | 
			
		||||
 | 
			
		||||
    const {
 | 
			
		||||
      decimals,
 | 
			
		||||
      ltv,
 | 
			
		||||
      liquidationBonus,
 | 
			
		||||
      liquidationThreshold,
 | 
			
		||||
      reserveFactor,
 | 
			
		||||
      stableBorrowRateEnabled,
 | 
			
		||||
      borrowingEnabled,
 | 
			
		||||
      isActive,
 | 
			
		||||
      isFrozen,
 | 
			
		||||
    } = await helpersContract.getReserveConfigurationData(weth.address);
 | 
			
		||||
    const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
 | 
			
		||||
    const isPaused = await helpersContract.getPaused(weth.address);
 | 
			
		||||
 | 
			
		||||
    expect(borrowingEnabled).to.be.equal(true);
 | 
			
		||||
    expect(isActive).to.be.equal(true);
 | 
			
		||||
    expect(isPaused).to.be.equal(false);
 | 
			
		||||
    expect(isFrozen).to.be.equal(false);
 | 
			
		||||
    expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
 | 
			
		||||
    expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
 | 
			
		||||
    expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
 | 
			
		||||
    expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
 | 
			
		||||
    expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled);
 | 
			
		||||
    expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor);
 | 
			
		||||
    expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
 | 
			
		||||
    expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
 | 
			
		||||
  });
 | 
			
		||||
  it('Pauses the ETH reserve by emergency admin', async () => {
 | 
			
		||||
    const { configurator, weth, helpersContract, addressesProvider, users, emergencyAdmin } =
 | 
			
		||||
      testEnv;
 | 
			
		||||
    await configurator.connect(emergencyAdmin.signer).pauseReserve(weth.address);
 | 
			
		||||
    const {
 | 
			
		||||
      decimals,
 | 
			
		||||
      ltv,
 | 
			
		||||
      liquidationBonus,
 | 
			
		||||
      liquidationThreshold,
 | 
			
		||||
      reserveFactor,
 | 
			
		||||
      stableBorrowRateEnabled,
 | 
			
		||||
      borrowingEnabled,
 | 
			
		||||
      isActive,
 | 
			
		||||
      isFrozen,
 | 
			
		||||
    } = await helpersContract.getReserveConfigurationData(weth.address);
 | 
			
		||||
    const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
 | 
			
		||||
    const isPaused = await helpersContract.getPaused(weth.address);
 | 
			
		||||
 | 
			
		||||
    expect(borrowingEnabled).to.be.equal(true);
 | 
			
		||||
    expect(isActive).to.be.equal(true);
 | 
			
		||||
    expect(isPaused).to.be.equal(true);
 | 
			
		||||
    expect(isFrozen).to.be.equal(false);
 | 
			
		||||
    expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
 | 
			
		||||
    expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
 | 
			
		||||
    expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
 | 
			
		||||
    expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
 | 
			
		||||
    expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled);
 | 
			
		||||
    expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor);
 | 
			
		||||
    expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
 | 
			
		||||
    expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('Unpauses the ETH reserve by emergency admin ', async () => {
 | 
			
		||||
    const { configurator, helpersContract, weth, users, emergencyAdmin } = testEnv;
 | 
			
		||||
    await configurator.connect(emergencyAdmin.signer).unpauseReserve(weth.address);
 | 
			
		||||
 | 
			
		||||
    const {
 | 
			
		||||
      decimals,
 | 
			
		||||
      ltv,
 | 
			
		||||
      liquidationBonus,
 | 
			
		||||
      liquidationThreshold,
 | 
			
		||||
      reserveFactor,
 | 
			
		||||
      stableBorrowRateEnabled,
 | 
			
		||||
      borrowingEnabled,
 | 
			
		||||
      isActive,
 | 
			
		||||
      isFrozen,
 | 
			
		||||
    } = await helpersContract.getReserveConfigurationData(weth.address);
 | 
			
		||||
    const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
 | 
			
		||||
    const isPaused = await helpersContract.getPaused(weth.address);
 | 
			
		||||
 | 
			
		||||
    expect(borrowingEnabled).to.be.equal(true);
 | 
			
		||||
    expect(isActive).to.be.equal(true);
 | 
			
		||||
    expect(isPaused).to.be.equal(false);
 | 
			
		||||
    expect(isFrozen).to.be.equal(false);
 | 
			
		||||
    expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
 | 
			
		||||
    expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
 | 
			
		||||
    expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
 | 
			
		||||
    expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
 | 
			
		||||
    expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled);
 | 
			
		||||
    expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor);
 | 
			
		||||
    expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
 | 
			
		||||
    expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('Check the only admin or emergency admin can pauseReserve ', async () => {
 | 
			
		||||
    const { configurator, users, weth, riskAdmin } = testEnv;
 | 
			
		||||
    await expect(
 | 
			
		||||
      configurator.connect(riskAdmin.signer).pauseReserve(weth.address),
 | 
			
		||||
      CALLER_NOT_POOL_ADMIN
 | 
			
		||||
    ).to.be.revertedWith(LPC_CALLER_NOT_EMERGENCY_OR_POOL_ADMIN);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('Check the only admin or emergency admin can unpauseReserve ', async () => {
 | 
			
		||||
    const { configurator, users, weth, riskAdmin } = testEnv;
 | 
			
		||||
    await expect(
 | 
			
		||||
      configurator.connect(riskAdmin.signer).unpauseReserve(weth.address),
 | 
			
		||||
      CALLER_NOT_POOL_ADMIN
 | 
			
		||||
    ).to.be.revertedWith(LPC_CALLER_NOT_EMERGENCY_OR_POOL_ADMIN);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('Freezes the ETH reserve by pool Admin', async () => {
 | 
			
		||||
    const { configurator, weth, helpersContract } = testEnv;
 | 
			
		||||
 | 
			
		||||
    await configurator.freezeReserve(weth.address);
 | 
			
		||||
| 
						 | 
				
			
			@ -252,7 +391,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
 | 
			
		|||
    expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('Unfreezes the ETH reserve', async () => {
 | 
			
		||||
  it('Unfreezes the ETH reserve by Pool admin', async () => {
 | 
			
		||||
    const { configurator, helpersContract, weth } = testEnv;
 | 
			
		||||
    await configurator.unfreezeReserve(weth.address);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -283,21 +422,83 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
 | 
			
		|||
    expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
 | 
			
		||||
    expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
 | 
			
		||||
  });
 | 
			
		||||
  it('Freezes the ETH reserve by Risk Admin', async () => {
 | 
			
		||||
    const { configurator, weth, helpersContract, riskAdmin } = testEnv;
 | 
			
		||||
    await configurator.connect(riskAdmin.signer).freezeReserve(weth.address);
 | 
			
		||||
    const {
 | 
			
		||||
      decimals,
 | 
			
		||||
      ltv,
 | 
			
		||||
      liquidationBonus,
 | 
			
		||||
      liquidationThreshold,
 | 
			
		||||
      reserveFactor,
 | 
			
		||||
      stableBorrowRateEnabled,
 | 
			
		||||
      borrowingEnabled,
 | 
			
		||||
      isActive,
 | 
			
		||||
      isFrozen,
 | 
			
		||||
    } = await helpersContract.getReserveConfigurationData(weth.address);
 | 
			
		||||
    const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
 | 
			
		||||
    const isPaused = await helpersContract.getPaused(weth.address);
 | 
			
		||||
 | 
			
		||||
  it('Check the onlyAaveAdmin on freezeReserve ', async () => {
 | 
			
		||||
    const { configurator, users, weth, riskAdmin } = testEnv;
 | 
			
		||||
    await expect(
 | 
			
		||||
      configurator.connect(riskAdmin.signer).freezeReserve(weth.address),
 | 
			
		||||
      CALLER_NOT_POOL_ADMIN
 | 
			
		||||
    ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
 | 
			
		||||
    expect(borrowingEnabled).to.be.equal(true);
 | 
			
		||||
    expect(isActive).to.be.equal(true);
 | 
			
		||||
    expect(isPaused).to.be.equal(false);
 | 
			
		||||
    expect(isFrozen).to.be.equal(true);
 | 
			
		||||
    expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
 | 
			
		||||
    expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
 | 
			
		||||
    expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
 | 
			
		||||
    expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
 | 
			
		||||
    expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled);
 | 
			
		||||
    expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor);
 | 
			
		||||
    expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
 | 
			
		||||
    expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('Check the onlyAaveAdmin on unfreezeReserve ', async () => {
 | 
			
		||||
    const { configurator, users, weth, riskAdmin } = testEnv;
 | 
			
		||||
  it('Unfreezes the ETH reserve by Risk admin', async () => {
 | 
			
		||||
    const { configurator, helpersContract, weth, riskAdmin } = testEnv;
 | 
			
		||||
    await configurator.connect(riskAdmin.signer).unfreezeReserve(weth.address);
 | 
			
		||||
 | 
			
		||||
    const {
 | 
			
		||||
      decimals,
 | 
			
		||||
      ltv,
 | 
			
		||||
      liquidationBonus,
 | 
			
		||||
      liquidationThreshold,
 | 
			
		||||
      reserveFactor,
 | 
			
		||||
      stableBorrowRateEnabled,
 | 
			
		||||
      borrowingEnabled,
 | 
			
		||||
      isActive,
 | 
			
		||||
      isFrozen,
 | 
			
		||||
    } = await helpersContract.getReserveConfigurationData(weth.address);
 | 
			
		||||
    const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
 | 
			
		||||
    const isPaused = await helpersContract.getPaused(weth.address);
 | 
			
		||||
 | 
			
		||||
    expect(borrowingEnabled).to.be.equal(true);
 | 
			
		||||
    expect(isActive).to.be.equal(true);
 | 
			
		||||
    expect(isPaused).to.be.equal(false);
 | 
			
		||||
    expect(isFrozen).to.be.equal(false);
 | 
			
		||||
    expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
 | 
			
		||||
    expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
 | 
			
		||||
    expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
 | 
			
		||||
    expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
 | 
			
		||||
    expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled);
 | 
			
		||||
    expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor);
 | 
			
		||||
    expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
 | 
			
		||||
    expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('Check the onlyRiskOrPoolAdmins on freezeReserve ', async () => {
 | 
			
		||||
    const { configurator, users, weth, emergencyAdmin } = testEnv;
 | 
			
		||||
    await expect(
 | 
			
		||||
      configurator.connect(riskAdmin.signer).unfreezeReserve(weth.address),
 | 
			
		||||
      CALLER_NOT_POOL_ADMIN
 | 
			
		||||
    ).to.be.revertedWith(CALLER_NOT_POOL_ADMIN);
 | 
			
		||||
      configurator.connect(emergencyAdmin.signer).freezeReserve(weth.address),
 | 
			
		||||
      LPC_CALLER_NOT_RISK_OR_POOL_ADMIN
 | 
			
		||||
    ).to.be.revertedWith(LPC_CALLER_NOT_RISK_OR_POOL_ADMIN);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('Check the onlyRiskOrPoolAdmins on unfreezeReserve ', async () => {
 | 
			
		||||
    const { configurator, users, weth, emergencyAdmin } = testEnv;
 | 
			
		||||
    await expect(
 | 
			
		||||
      configurator.connect(emergencyAdmin.signer).unfreezeReserve(weth.address),
 | 
			
		||||
      LPC_CALLER_NOT_RISK_OR_POOL_ADMIN
 | 
			
		||||
    ).to.be.revertedWith(LPC_CALLER_NOT_RISK_OR_POOL_ADMIN);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('Deactivates the ETH reserve for borrowing via pool admin', async () => {
 | 
			
		||||
| 
						 | 
				
			
			@ -333,7 +534,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
 | 
			
		|||
 | 
			
		||||
  it('Activates the ETH reserve for borrowing via pool admin', async () => {
 | 
			
		||||
    const { configurator, weth, helpersContract } = testEnv;
 | 
			
		||||
    await configurator.enableBorrowingOnReserve(weth.address, MAX_BORROW_CAP, true);
 | 
			
		||||
    await configurator.enableBorrowingOnReserve(weth.address, '0', true);
 | 
			
		||||
    const { variableBorrowIndex } = await helpersContract.getReserveData(weth.address);
 | 
			
		||||
 | 
			
		||||
    const {
 | 
			
		||||
| 
						 | 
				
			
			@ -399,9 +600,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
 | 
			
		|||
 | 
			
		||||
  it('Activates the ETH reserve for borrowing via risk admin', async () => {
 | 
			
		||||
    const { configurator, weth, helpersContract, riskAdmin } = testEnv;
 | 
			
		||||
    await configurator
 | 
			
		||||
      .connect(riskAdmin.signer)
 | 
			
		||||
      .enableBorrowingOnReserve(weth.address, MAX_BORROW_CAP, true);
 | 
			
		||||
    await configurator.connect(riskAdmin.signer).enableBorrowingOnReserve(weth.address, '0', true);
 | 
			
		||||
    const { variableBorrowIndex } = await helpersContract.getReserveData(weth.address);
 | 
			
		||||
 | 
			
		||||
    const {
 | 
			
		||||
| 
						 | 
				
			
			@ -816,15 +1015,45 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
 | 
			
		|||
    expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
 | 
			
		||||
    expect(reserveFactor).to.be.equal(1000);
 | 
			
		||||
  });
 | 
			
		||||
  it('Changes the reserve factor of WETH risk admin', async () => {
 | 
			
		||||
    const { configurator, helpersContract, weth, riskAdmin } = testEnv;
 | 
			
		||||
    await configurator.connect(riskAdmin.signer).setReserveFactor(weth.address, '1000');
 | 
			
		||||
    const {
 | 
			
		||||
      decimals,
 | 
			
		||||
      ltv,
 | 
			
		||||
      liquidationBonus,
 | 
			
		||||
      liquidationThreshold,
 | 
			
		||||
      reserveFactor,
 | 
			
		||||
      stableBorrowRateEnabled,
 | 
			
		||||
      borrowingEnabled,
 | 
			
		||||
      isActive,
 | 
			
		||||
      isFrozen,
 | 
			
		||||
    } = await helpersContract.getReserveConfigurationData(weth.address);
 | 
			
		||||
    const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
 | 
			
		||||
    const isPaused = await helpersContract.getPaused(weth.address);
 | 
			
		||||
 | 
			
		||||
  it('Fails to change to too high borrowCap', async () => {
 | 
			
		||||
    expect(borrowingEnabled).to.be.equal(true);
 | 
			
		||||
    expect(isActive).to.be.equal(true);
 | 
			
		||||
    expect(isPaused).to.be.equal(false);
 | 
			
		||||
    expect(isFrozen).to.be.equal(false);
 | 
			
		||||
    expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
 | 
			
		||||
    expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
 | 
			
		||||
    expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
 | 
			
		||||
    expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
 | 
			
		||||
    expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled);
 | 
			
		||||
    expect(borrowCap).to.be.equal(strategyWETH.borrowCap);
 | 
			
		||||
    expect(supplyCap).to.be.equal(strategyWETH.supplyCap);
 | 
			
		||||
    expect(reserveFactor).to.be.equal(1000);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('Check that borrowCap cannot be set to value that exceeds the MAX_BORROW_CAP', async () => {
 | 
			
		||||
    const { configurator, users, weth } = testEnv;
 | 
			
		||||
    await expect(
 | 
			
		||||
      configurator.setBorrowCap(weth.address, BigNumber.from(MAX_BORROW_CAP).add(1)),
 | 
			
		||||
      CALLER_NOT_POOL_ADMIN
 | 
			
		||||
    ).to.be.revertedWith(RC_INVALID_BORROW_CAP);
 | 
			
		||||
  });
 | 
			
		||||
  it('Fails to change to too high supplyCap', async () => {
 | 
			
		||||
  it('Check that supplyCap cannot be set to value that exceeds the MAX_SUPPLY_CAP', async () => {
 | 
			
		||||
    const { configurator, users, weth } = testEnv;
 | 
			
		||||
    await expect(
 | 
			
		||||
      configurator.setSupplyCap(weth.address, BigNumber.from(MAX_BORROW_CAP).add(1)),
 | 
			
		||||
| 
						 | 
				
			
			@ -953,6 +1182,36 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
 | 
			
		|||
    expect(borrowCap).to.be.equal('3000000');
 | 
			
		||||
    expect(supplyCap).to.be.equal('3000000');
 | 
			
		||||
  });
 | 
			
		||||
  it('Changes the supply Cap of WETH via risk admin', async () => {
 | 
			
		||||
    const { configurator, helpersContract, weth, riskAdmin } = testEnv;
 | 
			
		||||
    await configurator.connect(riskAdmin.signer).setSupplyCap(weth.address, '3000000');
 | 
			
		||||
    const {
 | 
			
		||||
      decimals,
 | 
			
		||||
      ltv,
 | 
			
		||||
      liquidationBonus,
 | 
			
		||||
      liquidationThreshold,
 | 
			
		||||
      reserveFactor,
 | 
			
		||||
      stableBorrowRateEnabled,
 | 
			
		||||
      borrowingEnabled,
 | 
			
		||||
      isActive,
 | 
			
		||||
      isFrozen,
 | 
			
		||||
    } = await helpersContract.getReserveConfigurationData(weth.address);
 | 
			
		||||
    const { borrowCap, supplyCap } = await helpersContract.getReserveCaps(weth.address);
 | 
			
		||||
    const isPaused = await helpersContract.getPaused(weth.address);
 | 
			
		||||
 | 
			
		||||
    expect(borrowingEnabled).to.be.equal(true);
 | 
			
		||||
    expect(isActive).to.be.equal(true);
 | 
			
		||||
    expect(isPaused).to.be.equal(false);
 | 
			
		||||
    expect(isFrozen).to.be.equal(false);
 | 
			
		||||
    expect(decimals).to.be.equal(strategyWETH.reserveDecimals);
 | 
			
		||||
    expect(ltv).to.be.equal(strategyWETH.baseLTVAsCollateral);
 | 
			
		||||
    expect(liquidationThreshold).to.be.equal(strategyWETH.liquidationThreshold);
 | 
			
		||||
    expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
 | 
			
		||||
    expect(stableBorrowRateEnabled).to.be.equal(strategyWETH.stableBorrowRateEnabled);
 | 
			
		||||
    expect(reserveFactor).to.be.equal(1000);
 | 
			
		||||
    expect(borrowCap).to.be.equal('3000000');
 | 
			
		||||
    expect(supplyCap).to.be.equal('3000000');
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('Reverts when trying to disable the DAI reserve with liquidity on it', async () => {
 | 
			
		||||
    const { dai, pool, configurator } = testEnv;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -172,7 +172,7 @@ export async function initializeMakeSuite() {
 | 
			
		|||
const setSnapshot = async () => {
 | 
			
		||||
  const hre = DRE as HardhatRuntimeEnvironment;
 | 
			
		||||
  if (usingTenderly()) {
 | 
			
		||||
    setBuidlerevmSnapshotId((await hre.tenderlyRPC.getHead()) || '0x1');
 | 
			
		||||
    setBuidlerevmSnapshotId((await hre.tenderlyNetwork.getHead()) || '0x1');
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  setBuidlerevmSnapshotId(await evmSnapshot());
 | 
			
		||||
| 
						 | 
				
			
			@ -181,7 +181,7 @@ const setSnapshot = async () => {
 | 
			
		|||
const revertHead = async () => {
 | 
			
		||||
  const hre = DRE as HardhatRuntimeEnvironment;
 | 
			
		||||
  if (usingTenderly()) {
 | 
			
		||||
    await hre.tenderlyRPC.setHead(buidlerevmSnapshotId);
 | 
			
		||||
    await hre.tenderlyNetwork.setHead(buidlerevmSnapshotId);
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  await evmRevert(buidlerevmSnapshotId);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,17 +12,14 @@ const { expect } = require('chai');
 | 
			
		|||
makeSuite('Pausable Pool', (testEnv: TestEnv) => {
 | 
			
		||||
  let _mockFlashLoanReceiver = {} as MockFlashLoanReceiver;
 | 
			
		||||
 | 
			
		||||
  const {
 | 
			
		||||
    LP_IS_PAUSED,
 | 
			
		||||
    INVALID_FROM_BALANCE_AFTER_TRANSFER,
 | 
			
		||||
    INVALID_TO_BALANCE_AFTER_TRANSFER,
 | 
			
		||||
  } = ProtocolErrors;
 | 
			
		||||
  const { LP_IS_PAUSED, INVALID_FROM_BALANCE_AFTER_TRANSFER, INVALID_TO_BALANCE_AFTER_TRANSFER } =
 | 
			
		||||
    ProtocolErrors;
 | 
			
		||||
 | 
			
		||||
  before(async () => {
 | 
			
		||||
    _mockFlashLoanReceiver = await getMockFlashLoanReceiver();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('User 0 deposits 1000 DAI. Configurator pauses pool. Transfers to user 1 reverts. Configurator unpauses the network and next transfer succees', async () => {
 | 
			
		||||
  it('User 0 deposits 1000 DAI. Configurator pauses pool. Transfers to user 1 reverts. Configurator unpauses the network and next transfer succeeds', async () => {
 | 
			
		||||
    const { users, pool, dai, aDai, configurator } = testEnv;
 | 
			
		||||
 | 
			
		||||
    const amountDAItoDeposit = await convertToCurrencyDecimals(dai.address, '1000');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,8 @@ makeSuite('Pause Reserve', (testEnv: TestEnv) => {
 | 
			
		|||
    _mockFlashLoanReceiver = await getMockFlashLoanReceiver();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('User 0 deposits 1000 DAI. Configurator pauses pool. Transfers to user 1 reverts. Configurator unpauses the network and next transfer succees', async () => {
 | 
			
		||||
 | 
			
		||||
  it('User 0 deposits 1000 DAI. Configurator pauses pool. Transfers to user 1 reverts. Configurator unpauses the network and next transfer succeeds', async () => {
 | 
			
		||||
    const { users, pool, dai, aDai, configurator } = testEnv;
 | 
			
		||||
 | 
			
		||||
    const amountDAItoDeposit = await convertToCurrencyDecimals(dai.address, '1000');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,10 +15,10 @@ const { expect } = require('chai');
 | 
			
		|||
makeSuite('supply Cap', (testEnv: TestEnv) => {
 | 
			
		||||
  const { VL_SUPPLY_CAP_EXCEEDED, RC_INVALID_SUPPLY_CAP } = ProtocolErrors;
 | 
			
		||||
 | 
			
		||||
  const miliUnitToPrecision = async (token: WETH9Mocked | MintableERC20, nb: string) =>
 | 
			
		||||
  const unitParse = async (token: WETH9Mocked | MintableERC20, nb: string) =>
 | 
			
		||||
    BigNumber.from(nb).mul(BigNumber.from('10').pow((await token.decimals()) - 3));
 | 
			
		||||
 | 
			
		||||
  it('Sets the supply cap for Weth and DAI to 0 Units, deposits weth', async () => {
 | 
			
		||||
  it('Reserves should initially have supply cap disabled (supplyCap = 0)', async () => {
 | 
			
		||||
    const {
 | 
			
		||||
      configurator,
 | 
			
		||||
      weth,
 | 
			
		||||
| 
						 | 
				
			
			@ -29,61 +29,101 @@ makeSuite('supply Cap', (testEnv: TestEnv) => {
 | 
			
		|||
      helpersContract,
 | 
			
		||||
      users: [user1],
 | 
			
		||||
    } = testEnv;
 | 
			
		||||
 | 
			
		||||
    const mintedAmount = parseEther('1000000000');
 | 
			
		||||
    await dai.mint(mintedAmount);
 | 
			
		||||
    await weth.mint(mintedAmount);
 | 
			
		||||
    await usdc.mint(mintedAmount);
 | 
			
		||||
 | 
			
		||||
    await dai.approve(pool.address, MAX_UINT_AMOUNT);
 | 
			
		||||
    await weth.approve(pool.address, MAX_UINT_AMOUNT);
 | 
			
		||||
    await usdc.approve(pool.address, MAX_UINT_AMOUNT);
 | 
			
		||||
    let usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    let daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
 | 
			
		||||
    expect(usdcsupplyCap).to.be.equal(MAX_SUPPLY_CAP);
 | 
			
		||||
    expect(daisupplyCap).to.be.equal(MAX_SUPPLY_CAP);
 | 
			
		||||
    let usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    let daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
 | 
			
		||||
    const depositedMiliAmount = (1e9).toString();
 | 
			
		||||
    expect(usdcSupplyCap).to.be.equal('0');
 | 
			
		||||
    expect(daiSupplyCap).to.be.equal('0');
 | 
			
		||||
  });
 | 
			
		||||
  it('Should be able to deposit 1000 Dai, 1000 USDC and 1000 Weth', async () => {
 | 
			
		||||
    const {
 | 
			
		||||
      configurator,
 | 
			
		||||
      weth,
 | 
			
		||||
      pool,
 | 
			
		||||
      dai,
 | 
			
		||||
      usdc,
 | 
			
		||||
      deployer,
 | 
			
		||||
      helpersContract,
 | 
			
		||||
      users: [user1],
 | 
			
		||||
    } = testEnv;
 | 
			
		||||
 | 
			
		||||
    await configurator.setSupplyCap(usdc.address, 0);
 | 
			
		||||
    await configurator.setSupplyCap(dai.address, 0);
 | 
			
		||||
    const suppliedAmount = 1000;
 | 
			
		||||
    const precisionSuppliedAmount = (suppliedAmount * 1000).toString();
 | 
			
		||||
 | 
			
		||||
    usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
    await pool.deposit(
 | 
			
		||||
      usdc.address,
 | 
			
		||||
      await unitParse(usdc, precisionSuppliedAmount),
 | 
			
		||||
      deployer.address,
 | 
			
		||||
      0
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    expect(usdcsupplyCap).to.be.equal(0);
 | 
			
		||||
    expect(daisupplyCap).to.be.equal(0);
 | 
			
		||||
    await pool.deposit(
 | 
			
		||||
      dai.address,
 | 
			
		||||
      await unitParse(dai, precisionSuppliedAmount),
 | 
			
		||||
      deployer.address,
 | 
			
		||||
      0
 | 
			
		||||
    );
 | 
			
		||||
    await pool.deposit(
 | 
			
		||||
      weth.address,
 | 
			
		||||
      await unitParse(weth, precisionSuppliedAmount),
 | 
			
		||||
      deployer.address,
 | 
			
		||||
      0
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
  it('Sets the supply cap for Weth and DAI to 1000 Unit', async () => {
 | 
			
		||||
    const {
 | 
			
		||||
      configurator,
 | 
			
		||||
      weth,
 | 
			
		||||
      pool,
 | 
			
		||||
      dai,
 | 
			
		||||
      usdc,
 | 
			
		||||
      deployer,
 | 
			
		||||
      helpersContract,
 | 
			
		||||
      users: [user1],
 | 
			
		||||
    } = testEnv;
 | 
			
		||||
 | 
			
		||||
    const newCap = '1000';
 | 
			
		||||
 | 
			
		||||
    await configurator.setSupplyCap(usdc.address, newCap);
 | 
			
		||||
    await configurator.setSupplyCap(dai.address, newCap);
 | 
			
		||||
 | 
			
		||||
    const usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    const daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
 | 
			
		||||
    expect(usdcSupplyCap).to.be.equal(newCap);
 | 
			
		||||
    expect(daiSupplyCap).to.be.equal(newCap);
 | 
			
		||||
  });
 | 
			
		||||
  it('should fail to supply any dai or usdc', async () => {
 | 
			
		||||
    const { usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const suppliedAmount = 10;
 | 
			
		||||
    const suppliedMilimount = (suppliedAmount * 1000).toString();
 | 
			
		||||
    const precisionSuppliedAmount = (suppliedAmount * 1000).toString();
 | 
			
		||||
 | 
			
		||||
    await expect(
 | 
			
		||||
      pool.deposit(
 | 
			
		||||
        usdc.address,
 | 
			
		||||
        await miliUnitToPrecision(usdc, suppliedMilimount),
 | 
			
		||||
        await unitParse(usdc, precisionSuppliedAmount),
 | 
			
		||||
        deployer.address,
 | 
			
		||||
        0
 | 
			
		||||
      )
 | 
			
		||||
    ).to.be.revertedWith(VL_SUPPLY_CAP_EXCEEDED);
 | 
			
		||||
 | 
			
		||||
    await expect(
 | 
			
		||||
      pool.deposit(
 | 
			
		||||
        dai.address,
 | 
			
		||||
        await miliUnitToPrecision(dai, suppliedMilimount),
 | 
			
		||||
        deployer.address,
 | 
			
		||||
        0
 | 
			
		||||
      )
 | 
			
		||||
      pool.deposit(dai.address, await unitParse(dai, precisionSuppliedAmount), deployer.address, 0)
 | 
			
		||||
    ).to.be.revertedWith(VL_SUPPLY_CAP_EXCEEDED);
 | 
			
		||||
  });
 | 
			
		||||
  it('Should fail to set the supply cap for usdc and DAI to max cap + 1 Units', async () => {
 | 
			
		||||
    const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const newCap = Number(MAX_SUPPLY_CAP) + 1;
 | 
			
		||||
    let usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    let daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
 | 
			
		||||
    expect(usdcsupplyCap).to.be.equal(0);
 | 
			
		||||
    expect(daisupplyCap).to.be.equal(0);
 | 
			
		||||
 | 
			
		||||
    await expect(configurator.setSupplyCap(usdc.address, newCap)).to.be.revertedWith(
 | 
			
		||||
      RC_INVALID_SUPPLY_CAP
 | 
			
		||||
| 
						 | 
				
			
			@ -92,38 +132,33 @@ makeSuite('supply Cap', (testEnv: TestEnv) => {
 | 
			
		|||
      RC_INVALID_SUPPLY_CAP
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
  it('Sets the supply cap for usdc and DAI to 110 Units', async () => {
 | 
			
		||||
  it('Sets the supply cap for usdc and DAI to 1110 Units', async () => {
 | 
			
		||||
    const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const newCap = '110';
 | 
			
		||||
    let usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    let daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
 | 
			
		||||
    expect(usdcsupplyCap).to.be.equal(0);
 | 
			
		||||
    expect(daisupplyCap).to.be.equal(0);
 | 
			
		||||
    const newCap = '1110';
 | 
			
		||||
 | 
			
		||||
    await configurator.setSupplyCap(usdc.address, newCap);
 | 
			
		||||
    await configurator.setSupplyCap(dai.address, newCap);
 | 
			
		||||
 | 
			
		||||
    usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
    const usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    const daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
 | 
			
		||||
    expect(usdcsupplyCap).to.be.equal(newCap);
 | 
			
		||||
    expect(daisupplyCap).to.be.equal(newCap);
 | 
			
		||||
    expect(usdcSupplyCap).to.be.equal(newCap);
 | 
			
		||||
    expect(daiSupplyCap).to.be.equal(newCap);
 | 
			
		||||
  });
 | 
			
		||||
  it('Should succeed to supply 10  dai and 10  usdc', async () => {
 | 
			
		||||
    const { usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const suppliedAmount = 10;
 | 
			
		||||
    const suppliedMilimount = (suppliedAmount * 1000).toString();
 | 
			
		||||
    const precisionSuppliedAmount = (suppliedAmount * 1000).toString();
 | 
			
		||||
    await pool.deposit(
 | 
			
		||||
      usdc.address,
 | 
			
		||||
      await miliUnitToPrecision(usdc, suppliedMilimount),
 | 
			
		||||
      await unitParse(usdc, precisionSuppliedAmount),
 | 
			
		||||
      deployer.address,
 | 
			
		||||
      0
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    await pool.deposit(
 | 
			
		||||
      dai.address,
 | 
			
		||||
      await miliUnitToPrecision(dai, suppliedMilimount),
 | 
			
		||||
      await unitParse(dai, precisionSuppliedAmount),
 | 
			
		||||
      deployer.address,
 | 
			
		||||
      0
 | 
			
		||||
    );
 | 
			
		||||
| 
						 | 
				
			
			@ -131,144 +166,132 @@ makeSuite('supply Cap', (testEnv: TestEnv) => {
 | 
			
		|||
  it('should fail to supply 100 dai and 100 usdc', async () => {
 | 
			
		||||
    const { usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const suppliedAmount = 100;
 | 
			
		||||
    const suppliedMilimount = (suppliedAmount * 1000).toString();
 | 
			
		||||
    const precisionSuppliedAmount = (suppliedAmount * 1000).toString();
 | 
			
		||||
 | 
			
		||||
    await expect(
 | 
			
		||||
      pool.deposit(
 | 
			
		||||
        usdc.address,
 | 
			
		||||
        await miliUnitToPrecision(usdc, suppliedMilimount),
 | 
			
		||||
        await unitParse(usdc, precisionSuppliedAmount),
 | 
			
		||||
        deployer.address,
 | 
			
		||||
        0
 | 
			
		||||
      )
 | 
			
		||||
    ).to.be.revertedWith(VL_SUPPLY_CAP_EXCEEDED);
 | 
			
		||||
 | 
			
		||||
    await expect(
 | 
			
		||||
      pool.deposit(
 | 
			
		||||
        dai.address,
 | 
			
		||||
        await miliUnitToPrecision(dai, suppliedMilimount),
 | 
			
		||||
        deployer.address,
 | 
			
		||||
        0
 | 
			
		||||
      )
 | 
			
		||||
      pool.deposit(dai.address, await unitParse(dai, precisionSuppliedAmount), deployer.address, 0)
 | 
			
		||||
    ).to.be.revertedWith(VL_SUPPLY_CAP_EXCEEDED);
 | 
			
		||||
  });
 | 
			
		||||
  it('Should succeed to supply 99 dai and 99 usdc', async () => {
 | 
			
		||||
    const { usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const suppliedAmount = 99;
 | 
			
		||||
    const suppliedMilimount = (suppliedAmount * 1000).toString();
 | 
			
		||||
    const precisionSuppliedAmount = (suppliedAmount * 1000).toString();
 | 
			
		||||
    await pool.deposit(
 | 
			
		||||
      usdc.address,
 | 
			
		||||
      await miliUnitToPrecision(usdc, suppliedMilimount),
 | 
			
		||||
      await unitParse(usdc, precisionSuppliedAmount),
 | 
			
		||||
      deployer.address,
 | 
			
		||||
      0
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    await pool.deposit(
 | 
			
		||||
      dai.address,
 | 
			
		||||
      await miliUnitToPrecision(dai, suppliedMilimount),
 | 
			
		||||
      await unitParse(dai, precisionSuppliedAmount),
 | 
			
		||||
      deployer.address,
 | 
			
		||||
      0
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
  it('Raises the supply cap for usdc and DAI to 1000 Units', async () => {
 | 
			
		||||
  it('Raises the supply cap for usdc and DAI to 2000 Units', async () => {
 | 
			
		||||
    const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const newCap = '1000';
 | 
			
		||||
    let usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    let daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
    const newCap = '2000';
 | 
			
		||||
 | 
			
		||||
    await configurator.setSupplyCap(usdc.address, newCap);
 | 
			
		||||
    await configurator.setSupplyCap(dai.address, newCap);
 | 
			
		||||
 | 
			
		||||
    usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
    const usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    const daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
 | 
			
		||||
    expect(usdcsupplyCap).to.be.equal(newCap);
 | 
			
		||||
    expect(daisupplyCap).to.be.equal(newCap);
 | 
			
		||||
    expect(usdcSupplyCap).to.be.equal(newCap);
 | 
			
		||||
    expect(daiSupplyCap).to.be.equal(newCap);
 | 
			
		||||
  });
 | 
			
		||||
  it('should succeed to supply 100 dai and 100 usdc', async () => {
 | 
			
		||||
    const { usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const suppliedAmount = 100;
 | 
			
		||||
    const suppliedMilimount = (suppliedAmount * 1000).toString();
 | 
			
		||||
    const precisionSuppliedAmount = (suppliedAmount * 1000).toString();
 | 
			
		||||
    await pool.deposit(
 | 
			
		||||
      usdc.address,
 | 
			
		||||
      await miliUnitToPrecision(usdc, suppliedMilimount),
 | 
			
		||||
      await unitParse(usdc, precisionSuppliedAmount),
 | 
			
		||||
      deployer.address,
 | 
			
		||||
      0
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    await pool.deposit(
 | 
			
		||||
      dai.address,
 | 
			
		||||
      await miliUnitToPrecision(dai, suppliedMilimount),
 | 
			
		||||
      await unitParse(dai, precisionSuppliedAmount),
 | 
			
		||||
      deployer.address,
 | 
			
		||||
      0
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
  it('Lowers the supply cap for usdc and DAI to 200 Units', async () => {
 | 
			
		||||
  it('Lowers the supply cap for usdc and DAI to 1200 Units', async () => {
 | 
			
		||||
    const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const newCap = '200';
 | 
			
		||||
    let usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    let daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
    const newCap = '1200';
 | 
			
		||||
    let usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    let daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
 | 
			
		||||
    await configurator.setSupplyCap(usdc.address, newCap);
 | 
			
		||||
    await configurator.setSupplyCap(dai.address, newCap);
 | 
			
		||||
 | 
			
		||||
    usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
    usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
 | 
			
		||||
    expect(usdcsupplyCap).to.be.equal(newCap);
 | 
			
		||||
    expect(daisupplyCap).to.be.equal(newCap);
 | 
			
		||||
    expect(usdcSupplyCap).to.be.equal(newCap);
 | 
			
		||||
    expect(daiSupplyCap).to.be.equal(newCap);
 | 
			
		||||
  });
 | 
			
		||||
  it('should fail to supply 100 dai and 100 usdc', async () => {
 | 
			
		||||
    const { usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const suppliedAmount = 100;
 | 
			
		||||
    const suppliedMilimount = (suppliedAmount * 1000).toString();
 | 
			
		||||
    const precisionSuppliedAmount = (suppliedAmount * 1000).toString();
 | 
			
		||||
 | 
			
		||||
    await expect(
 | 
			
		||||
      pool.deposit(
 | 
			
		||||
        usdc.address,
 | 
			
		||||
        await miliUnitToPrecision(usdc, suppliedMilimount),
 | 
			
		||||
        await unitParse(usdc, precisionSuppliedAmount),
 | 
			
		||||
        deployer.address,
 | 
			
		||||
        0
 | 
			
		||||
      )
 | 
			
		||||
    ).to.be.revertedWith(VL_SUPPLY_CAP_EXCEEDED);
 | 
			
		||||
 | 
			
		||||
    await expect(
 | 
			
		||||
      pool.deposit(
 | 
			
		||||
        dai.address,
 | 
			
		||||
        await miliUnitToPrecision(dai, suppliedMilimount),
 | 
			
		||||
        deployer.address,
 | 
			
		||||
        0
 | 
			
		||||
      )
 | 
			
		||||
      pool.deposit(dai.address, await unitParse(dai, precisionSuppliedAmount), deployer.address, 0)
 | 
			
		||||
    ).to.be.revertedWith(VL_SUPPLY_CAP_EXCEEDED);
 | 
			
		||||
  });
 | 
			
		||||
  it('Raises the supply cap for usdc and DAI to max cap Units', async () => {
 | 
			
		||||
    const { configurator, usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const newCap = MAX_SUPPLY_CAP;
 | 
			
		||||
    let usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    let daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
    let usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    let daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
 | 
			
		||||
    await configurator.setSupplyCap(usdc.address, newCap);
 | 
			
		||||
    await configurator.setSupplyCap(dai.address, newCap);
 | 
			
		||||
 | 
			
		||||
    usdcsupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    daisupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
    usdcSupplyCap = (await helpersContract.getReserveCaps(usdc.address)).supplyCap;
 | 
			
		||||
    daiSupplyCap = (await helpersContract.getReserveCaps(dai.address)).supplyCap;
 | 
			
		||||
 | 
			
		||||
    expect(usdcsupplyCap).to.be.equal(newCap);
 | 
			
		||||
    expect(daisupplyCap).to.be.equal(newCap);
 | 
			
		||||
    expect(usdcSupplyCap).to.be.equal(newCap);
 | 
			
		||||
    expect(daiSupplyCap).to.be.equal(newCap);
 | 
			
		||||
  });
 | 
			
		||||
  it('should succeed to supply 100 dai and 100 usdc', async () => {
 | 
			
		||||
    const { usdc, pool, dai, deployer, helpersContract } = testEnv;
 | 
			
		||||
    const suppliedAmount = 100;
 | 
			
		||||
    const suppliedMilimount = (suppliedAmount * 1000).toString();
 | 
			
		||||
    const precisionSuppliedAmount = (suppliedAmount * 1000).toString();
 | 
			
		||||
    await pool.deposit(
 | 
			
		||||
      usdc.address,
 | 
			
		||||
      await miliUnitToPrecision(usdc, suppliedMilimount),
 | 
			
		||||
      await unitParse(usdc, precisionSuppliedAmount),
 | 
			
		||||
      deployer.address,
 | 
			
		||||
      0
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    await pool.deposit(
 | 
			
		||||
      dai.address,
 | 
			
		||||
      await miliUnitToPrecision(dai, suppliedMilimount),
 | 
			
		||||
      await unitParse(dai, precisionSuppliedAmount),
 | 
			
		||||
      deployer.address,
 | 
			
		||||
      0
 | 
			
		||||
    );
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,6 +4,7 @@ import {
 | 
			
		|||
  insertContractAddressInDb,
 | 
			
		||||
  getEthersSigners,
 | 
			
		||||
  registerContractInJsonDb,
 | 
			
		||||
  getEthersSignersAddresses,
 | 
			
		||||
} from '../../helpers/contracts-helpers';
 | 
			
		||||
import {
 | 
			
		||||
  deployLendingPoolAddressesProvider,
 | 
			
		||||
| 
						 | 
				
			
			@ -101,9 +102,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
 | 
			
		|||
  await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
 | 
			
		||||
 | 
			
		||||
  //setting users[1] as emergency admin, which is in position 2 in the DRE addresses list
 | 
			
		||||
  const addressList = await Promise.all(
 | 
			
		||||
    (await DRE.ethers.getSigners()).map((signer) => signer.getAddress())
 | 
			
		||||
  );
 | 
			
		||||
  const addressList = await getEthersSignersAddresses();
 | 
			
		||||
 | 
			
		||||
  await waitForTx(await addressesProvider.setEmergencyAdmin(addressList[2]));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -156,7 +156,7 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
 | 
			
		|||
 | 
			
		||||
  it('Activates the ETH reserve for borrowing', async () => {
 | 
			
		||||
    const { configurator, weth, helpersContract } = testEnv;
 | 
			
		||||
    await configurator.enableBorrowingOnReserve(weth.address, MAX_BORROW_CAP, true);
 | 
			
		||||
    await configurator.enableBorrowingOnReserve(weth.address, '0', true);
 | 
			
		||||
    const { variableBorrowIndex } = await helpersContract.getReserveData(weth.address);
 | 
			
		||||
 | 
			
		||||
    const {
 | 
			
		||||
| 
						 | 
				
			
			@ -180,7 +180,6 @@ makeSuite('LendingPoolConfigurator', (testEnv: TestEnv) => {
 | 
			
		|||
    expect(liquidationBonus).to.be.equal(strategyWETH.liquidationBonus);
 | 
			
		||||
    expect(stableBorrowRateEnabled).to.be.equal(true /*strategyWETH.stableBorrowRateEnabled*/);
 | 
			
		||||
    expect(reserveFactor).to.be.equal(strategyWETH.reserveFactor);
 | 
			
		||||
 | 
			
		||||
    expect(variableBorrowIndex.toString()).to.be.equal(RAY);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -163,7 +163,7 @@ export async function initializeMakeSuite() {
 | 
			
		|||
const setSnapshot = async () => {
 | 
			
		||||
  const hre = DRE as HardhatRuntimeEnvironment;
 | 
			
		||||
  if (usingTenderly()) {
 | 
			
		||||
    setBuidlerevmSnapshotId((await hre.tenderlyRPC.getHead()) || '0x1');
 | 
			
		||||
    setBuidlerevmSnapshotId((await hre.tenderlyNetwork.getHead()) || '0x1');
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  setBuidlerevmSnapshotId(await evmSnapshot());
 | 
			
		||||
| 
						 | 
				
			
			@ -172,7 +172,7 @@ const setSnapshot = async () => {
 | 
			
		|||
const revertHead = async () => {
 | 
			
		||||
  const hre = DRE as HardhatRuntimeEnvironment;
 | 
			
		||||
  if (usingTenderly()) {
 | 
			
		||||
    await hre.tenderlyRPC.setHead(buidlerevmSnapshotId);
 | 
			
		||||
    await hre.tenderlyNetwork.setHead(buidlerevmSnapshotId);
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  await evmRevert(buidlerevmSnapshotId);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,7 +22,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => {
 | 
			
		|||
    _mockFlashLoanReceiver = await getMockFlashLoanReceiver();
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('User 0 deposits 1000 DAI. Configurator pauses pool. Transfers to user 1 reverts. Configurator unpauses the network and next transfer succees', async () => {
 | 
			
		||||
  it('User 0 deposits 1000 DAI. Configurator pauses pool. Transfers to user 1 reverts. Configurator unpauses the network and next transfer succeeds', async () => {
 | 
			
		||||
    const { users, pool, dai, aDai, configurator } = testEnv;
 | 
			
		||||
 | 
			
		||||
    const amountDAItoDeposit = await convertToCurrencyDecimals(dai.address, '1000');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,7 @@
 | 
			
		|||
    "noImplicitAny": false,
 | 
			
		||||
    "resolveJsonModule": true
 | 
			
		||||
  },
 | 
			
		||||
  "include": ["./scripts", "./test", "./tasks", "test-suites/test-aave/uniswapAdapters.repay.spec.ts", "test-suites/test-aave/upgradeability.spec.ts", "test-suites/test-aave/variable-debt-token.spec.ts", "test-suites/test-aave/weth-gateway.spec.ts"],
 | 
			
		||||
  "include": ["./scripts", "./test", "./tasks", "./helpers", "test-suites/test-aave/uniswapAdapters.repay.spec.ts", "test-suites/test-aave/upgradeability.spec.ts", "test-suites/test-aave/variable-debt-token.spec.ts", "test-suites/test-aave/weth-gateway.spec.ts"],
 | 
			
		||||
  "files": [
 | 
			
		||||
    "./hardhat.config.ts",
 | 
			
		||||
    "./modules/tenderly/tenderly.d.ts",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user