mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
merge: adding netscap doc, rename pool to _pool, adding pause reserve function to configurator interface
This commit is contained in:
commit
a9ac7a3b2f
|
@ -202,4 +202,146 @@ interface ILendingPoolConfigurator {
|
||||||
address indexed proxy,
|
address indexed proxy,
|
||||||
address indexed implementation
|
address indexed implementation
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,17 +30,17 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
||||||
using PercentageMath for uint256;
|
using PercentageMath for uint256;
|
||||||
using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
|
using ReserveConfiguration for DataTypes.ReserveConfigurationMap;
|
||||||
|
|
||||||
ILendingPoolAddressesProvider internal addressesProvider;
|
ILendingPoolAddressesProvider internal _addressesProvider;
|
||||||
ILendingPool internal pool;
|
ILendingPool internal _pool;
|
||||||
|
|
||||||
modifier onlyPoolAdmin {
|
modifier onlyPoolAdmin {
|
||||||
require(addressesProvider.getPoolAdmin() == msg.sender, Errors.CALLER_NOT_POOL_ADMIN);
|
require(_addressesProvider.getPoolAdmin() == msg.sender, Errors.CALLER_NOT_POOL_ADMIN);
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
modifier onlyEmergencyAdmin {
|
modifier onlyEmergencyAdmin {
|
||||||
require(
|
require(
|
||||||
addressesProvider.getEmergencyAdmin() == msg.sender,
|
_addressesProvider.getEmergencyAdmin() == msg.sender,
|
||||||
Errors.LPC_CALLER_NOT_EMERGENCY_ADMIN
|
Errors.LPC_CALLER_NOT_EMERGENCY_ADMIN
|
||||||
);
|
);
|
||||||
_;
|
_;
|
||||||
|
@ -48,14 +48,13 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
||||||
|
|
||||||
modifier onlyEmergencyOrPoolAdmin {
|
modifier onlyEmergencyOrPoolAdmin {
|
||||||
require(
|
require(
|
||||||
addressesProvider.getEmergencyAdmin() == msg.sender
|
addressesProvider.getEmergencyAdmin() == msg.sender ||
|
||||||
|| addressesProvider.getPoolAdmin() == msg.sender,
|
addressesProvider.getPoolAdmin() == msg.sender,
|
||||||
Errors.LPC_CALLER_NOT_EMERGENCY_OR_POOL_ADMIN
|
Errors.LPC_CALLER_NOT_EMERGENCY_OR_POOL_ADMIN
|
||||||
);
|
);
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint256 internal constant CONFIGURATOR_REVISION = 0x1;
|
uint256 internal constant CONFIGURATOR_REVISION = 0x1;
|
||||||
|
|
||||||
function getRevision() internal pure override returns (uint256) {
|
function getRevision() internal pure override returns (uint256) {
|
||||||
|
@ -63,15 +62,13 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
||||||
}
|
}
|
||||||
|
|
||||||
function initialize(ILendingPoolAddressesProvider provider) public initializer {
|
function initialize(ILendingPoolAddressesProvider provider) public initializer {
|
||||||
addressesProvider = provider;
|
_addressesProvider = provider;
|
||||||
pool = ILendingPool(addressesProvider.getLendingPool());
|
_pool = ILendingPool(_addressesProvider.getLendingPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @dev Initializes reserves in batch
|
function batchInitReserve(InitReserveInput[] calldata input) external override onlyPoolAdmin {
|
||||||
**/
|
ILendingPool cachedPool = _pool;
|
||||||
function batchInitReserve(InitReserveInput[] calldata input) external onlyPoolAdmin {
|
|
||||||
ILendingPool cachedPool = pool;
|
|
||||||
for (uint256 i = 0; i < input.length; i++) {
|
for (uint256 i = 0; i < input.length; i++) {
|
||||||
_initReserve(cachedPool, input[i]);
|
_initReserve(cachedPool, input[i]);
|
||||||
}
|
}
|
||||||
|
@ -152,11 +149,9 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @dev Updates the aToken implementation for the reserve
|
function updateAToken(UpdateATokenInput calldata input) external override onlyPoolAdmin {
|
||||||
**/
|
ILendingPool cachedPool = _pool;
|
||||||
function updateAToken(UpdateATokenInput calldata input) external onlyPoolAdmin {
|
|
||||||
ILendingPool cachedPool = pool;
|
|
||||||
|
|
||||||
DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset);
|
DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset);
|
||||||
|
|
||||||
|
@ -180,11 +175,13 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
||||||
emit ATokenUpgraded(input.asset, reserveData.aTokenAddress, input.implementation);
|
emit ATokenUpgraded(input.asset, reserveData.aTokenAddress, input.implementation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @dev Updates the stable debt token implementation for the reserve
|
function updateStableDebtToken(UpdateDebtTokenInput calldata input)
|
||||||
**/
|
external
|
||||||
function updateStableDebtToken(UpdateDebtTokenInput calldata input) external onlyPoolAdmin {
|
override
|
||||||
ILendingPool cachedPool = pool;
|
onlyPoolAdmin
|
||||||
|
{
|
||||||
|
ILendingPool cachedPool = _pool;
|
||||||
|
|
||||||
DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset);
|
DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset);
|
||||||
|
|
||||||
|
@ -215,11 +212,13 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @dev Updates the variable debt token implementation for the asset
|
function updateVariableDebtToken(UpdateDebtTokenInput calldata input)
|
||||||
**/
|
external
|
||||||
function updateVariableDebtToken(UpdateDebtTokenInput calldata input) external onlyPoolAdmin {
|
override
|
||||||
ILendingPool cachedPool = pool;
|
onlyPoolAdmin
|
||||||
|
{
|
||||||
|
ILendingPool cachedPool = _pool;
|
||||||
|
|
||||||
DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset);
|
DataTypes.ReserveData memory reserveData = cachedPool.getReserveData(input.asset);
|
||||||
|
|
||||||
|
@ -250,57 +249,42 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @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
|
|
||||||
**/
|
|
||||||
function enableBorrowingOnReserve(
|
function enableBorrowingOnReserve(
|
||||||
address asset,
|
address asset,
|
||||||
uint256 borrowCap,
|
uint256 borrowCap,
|
||||||
bool stableBorrowRateEnabled
|
bool stableBorrowRateEnabled
|
||||||
) external onlyPoolAdmin {
|
) external override onlyPoolAdmin {
|
||||||
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
|
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setBorrowingEnabled(true);
|
currentConfig.setBorrowingEnabled(true);
|
||||||
currentConfig.setBorrowCap(borrowCap);
|
currentConfig.setBorrowCap(borrowCap);
|
||||||
currentConfig.setStableRateBorrowingEnabled(stableBorrowRateEnabled);
|
currentConfig.setStableRateBorrowingEnabled(stableBorrowRateEnabled);
|
||||||
|
|
||||||
pool.setConfiguration(asset, currentConfig.data);
|
_pool.setConfiguration(asset, currentConfig.data);
|
||||||
|
|
||||||
emit BorrowCapChanged(asset, borrowCap);
|
emit BorrowCapChanged(asset, borrowCap);
|
||||||
emit BorrowingEnabledOnReserve(asset, stableBorrowRateEnabled);
|
emit BorrowingEnabledOnReserve(asset, stableBorrowRateEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @dev Disables borrowing on a reserve
|
function disableBorrowingOnReserve(address asset) external override onlyPoolAdmin {
|
||||||
* @param asset The address of the underlying asset of the reserve
|
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||||
**/
|
|
||||||
function disableBorrowingOnReserve(address asset) external onlyPoolAdmin {
|
|
||||||
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
|
|
||||||
|
|
||||||
currentConfig.setBorrowingEnabled(false);
|
currentConfig.setBorrowingEnabled(false);
|
||||||
|
|
||||||
pool.setConfiguration(asset, currentConfig.data);
|
_pool.setConfiguration(asset, currentConfig.data);
|
||||||
emit BorrowingDisabledOnReserve(asset);
|
emit BorrowingDisabledOnReserve(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @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(
|
function configureReserveAsCollateral(
|
||||||
address asset,
|
address asset,
|
||||||
uint256 ltv,
|
uint256 ltv,
|
||||||
uint256 liquidationThreshold,
|
uint256 liquidationThreshold,
|
||||||
uint256 liquidationBonus
|
uint256 liquidationBonus
|
||||||
) external onlyPoolAdmin {
|
) external override onlyPoolAdmin {
|
||||||
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
|
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||||
|
|
||||||
//validation of the parameters: the LTV can
|
//validation of the parameters: the LTV can
|
||||||
//only be lower or equal than the liquidation threshold
|
//only be lower or equal than the liquidation threshold
|
||||||
|
@ -333,167 +317,130 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
||||||
currentConfig.setLiquidationThreshold(liquidationThreshold);
|
currentConfig.setLiquidationThreshold(liquidationThreshold);
|
||||||
currentConfig.setLiquidationBonus(liquidationBonus);
|
currentConfig.setLiquidationBonus(liquidationBonus);
|
||||||
|
|
||||||
pool.setConfiguration(asset, currentConfig.data);
|
_pool.setConfiguration(asset, currentConfig.data);
|
||||||
|
|
||||||
emit CollateralConfigurationChanged(asset, ltv, liquidationThreshold, liquidationBonus);
|
emit CollateralConfigurationChanged(asset, ltv, liquidationThreshold, liquidationBonus);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @dev Enable stable rate borrowing on a reserve
|
function enableReserveStableRate(address asset) external override onlyPoolAdmin {
|
||||||
* @param asset The address of the underlying asset of the reserve
|
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||||
**/
|
|
||||||
function enableReserveStableRate(address asset) external onlyPoolAdmin {
|
|
||||||
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
|
|
||||||
|
|
||||||
currentConfig.setStableRateBorrowingEnabled(true);
|
currentConfig.setStableRateBorrowingEnabled(true);
|
||||||
|
|
||||||
pool.setConfiguration(asset, currentConfig.data);
|
_pool.setConfiguration(asset, currentConfig.data);
|
||||||
|
|
||||||
emit StableRateEnabledOnReserve(asset);
|
emit StableRateEnabledOnReserve(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @dev Disable stable rate borrowing on a reserve
|
function disableReserveStableRate(address asset) external override onlyPoolAdmin {
|
||||||
* @param asset The address of the underlying asset of the reserve
|
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||||
**/
|
|
||||||
function disableReserveStableRate(address asset) external onlyPoolAdmin {
|
|
||||||
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
|
|
||||||
|
|
||||||
currentConfig.setStableRateBorrowingEnabled(false);
|
currentConfig.setStableRateBorrowingEnabled(false);
|
||||||
|
|
||||||
pool.setConfiguration(asset, currentConfig.data);
|
_pool.setConfiguration(asset, currentConfig.data);
|
||||||
|
|
||||||
emit StableRateDisabledOnReserve(asset);
|
emit StableRateDisabledOnReserve(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @dev Activates a reserve
|
function activateReserve(address asset) external override onlyPoolAdmin {
|
||||||
* @param asset The address of the underlying asset of the reserve
|
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||||
**/
|
|
||||||
function activateReserve(address asset) external onlyPoolAdmin {
|
|
||||||
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
|
|
||||||
|
|
||||||
currentConfig.setActive(true);
|
currentConfig.setActive(true);
|
||||||
|
|
||||||
pool.setConfiguration(asset, currentConfig.data);
|
_pool.setConfiguration(asset, currentConfig.data);
|
||||||
|
|
||||||
emit ReserveActivated(asset);
|
emit ReserveActivated(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @dev Deactivates a reserve
|
function deactivateReserve(address asset) external override onlyPoolAdmin {
|
||||||
* @param asset The address of the underlying asset of the reserve
|
|
||||||
**/
|
|
||||||
function deactivateReserve(address asset) external onlyPoolAdmin {
|
|
||||||
_checkNoLiquidity(asset);
|
_checkNoLiquidity(asset);
|
||||||
|
|
||||||
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
|
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setActive(false);
|
currentConfig.setActive(false);
|
||||||
|
|
||||||
pool.setConfiguration(asset, currentConfig.data);
|
_pool.setConfiguration(asset, currentConfig.data);
|
||||||
|
|
||||||
emit ReserveDeactivated(asset);
|
emit ReserveDeactivated(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @dev Freezes a reserve. A frozen reserve doesn't allow any new deposit, borrow or rate swap
|
function freezeReserve(address asset) external override onlyPoolAdmin {
|
||||||
* but allows repayments, liquidations, rate rebalances and withdrawals
|
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||||
* @param asset The address of the underlying asset of the reserve
|
|
||||||
**/
|
|
||||||
function freezeReserve(address asset) external onlyPoolAdmin {
|
|
||||||
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
|
|
||||||
|
|
||||||
currentConfig.setFrozen(true);
|
currentConfig.setFrozen(true);
|
||||||
|
|
||||||
pool.setConfiguration(asset, currentConfig.data);
|
_pool.setConfiguration(asset, currentConfig.data);
|
||||||
|
|
||||||
emit ReserveFrozen(asset);
|
emit ReserveFrozen(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @dev Unfreezes a reserve
|
function unfreezeReserve(address asset) external override onlyPoolAdmin {
|
||||||
* @param asset The address of the underlying asset of the reserve
|
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||||
**/
|
|
||||||
function unfreezeReserve(address asset) external onlyPoolAdmin {
|
|
||||||
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
|
|
||||||
|
|
||||||
currentConfig.setFrozen(false);
|
currentConfig.setFrozen(false);
|
||||||
|
|
||||||
pool.setConfiguration(asset, currentConfig.data);
|
_pool.setConfiguration(asset, currentConfig.data);
|
||||||
|
|
||||||
emit ReserveUnfrozen(asset);
|
emit ReserveUnfrozen(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @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 {
|
function pauseReserve(address asset) external onlyEmergencyOrPoolAdmin {
|
||||||
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
|
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setPaused(true);
|
currentConfig.setPaused(true);
|
||||||
|
|
||||||
pool.setConfiguration(asset, currentConfig.data);
|
_pool.setConfiguration(asset, currentConfig.data);
|
||||||
|
|
||||||
emit ReservePaused(asset);
|
emit ReservePaused(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @dev Unpauses a reserve
|
|
||||||
* @param asset The address of the underlying asset of the reserve
|
|
||||||
**/
|
|
||||||
function unpauseReserve(address asset) external onlyEmergencyOrPoolAdmin {
|
function unpauseReserve(address asset) external onlyEmergencyOrPoolAdmin {
|
||||||
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
|
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setPaused(false);
|
currentConfig.setPaused(false);
|
||||||
|
|
||||||
pool.setConfiguration(asset, currentConfig.data);
|
_pool.setConfiguration(asset, currentConfig.data);
|
||||||
|
|
||||||
emit ReserveUnpaused(asset);
|
emit ReserveUnpaused(asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @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 onlyPoolAdmin {
|
function setReserveFactor(address asset, uint256 reserveFactor) external onlyPoolAdmin {
|
||||||
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
|
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||||
|
|
||||||
currentConfig.setReserveFactor(reserveFactor);
|
currentConfig.setReserveFactor(reserveFactor);
|
||||||
|
|
||||||
pool.setConfiguration(asset, currentConfig.data);
|
_pool.setConfiguration(asset, currentConfig.data);
|
||||||
|
|
||||||
emit ReserveFactorChanged(asset, reserveFactor);
|
emit ReserveFactorChanged(asset, reserveFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
///@inheritdoc ILendingPoolConfigurator
|
||||||
* @dev Updates the borrow cap of a reserve
|
function setBorrowCap(address asset, uint256 borrowCap) external override onlyPoolAdmin {
|
||||||
* @param asset The address of the underlying asset of the reserve
|
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||||
* @param borrowCap The new borrow of the reserve
|
|
||||||
**/
|
|
||||||
function setBorrowCap(address asset, uint256 borrowCap) external onlyPoolAdmin {
|
|
||||||
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
|
|
||||||
|
|
||||||
currentConfig.setBorrowCap(borrowCap);
|
currentConfig.setBorrowCap(borrowCap);
|
||||||
|
|
||||||
pool.setConfiguration(asset, currentConfig.data);
|
_pool.setConfiguration(asset, currentConfig.data);
|
||||||
|
|
||||||
emit BorrowCapChanged(asset, borrowCap);
|
emit BorrowCapChanged(asset, borrowCap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
///@inheritdoc ILendingPoolConfigurator
|
||||||
* @dev Updates the supply cap of a reserve
|
function setSupplyCap(address asset, uint256 supplyCap) external override onlyPoolAdmin {
|
||||||
* @param asset The address of the underlying asset of the reserve
|
DataTypes.ReserveConfigurationMap memory currentConfig = _pool.getConfiguration(asset);
|
||||||
* @param supplyCap The new supply of the reserve
|
|
||||||
**/
|
|
||||||
function setSupplyCap(address asset, uint256 supplyCap) external onlyPoolAdmin {
|
|
||||||
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
|
|
||||||
|
|
||||||
currentConfig.setSupplyCap(supplyCap);
|
currentConfig.setSupplyCap(supplyCap);
|
||||||
|
|
||||||
pool.setConfiguration(asset, currentConfig.data);
|
_pool.setConfiguration(asset, currentConfig.data);
|
||||||
|
|
||||||
emit SupplyCapChanged(asset, supplyCap);
|
emit SupplyCapChanged(asset, supplyCap);
|
||||||
}
|
}
|
||||||
|
@ -505,18 +452,16 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
||||||
**/
|
**/
|
||||||
function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress)
|
function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress)
|
||||||
external
|
external
|
||||||
|
override
|
||||||
onlyPoolAdmin
|
onlyPoolAdmin
|
||||||
{
|
{
|
||||||
pool.setReserveInterestRateStrategyAddress(asset, rateStrategyAddress);
|
_pool.setReserveInterestRateStrategyAddress(asset, rateStrategyAddress);
|
||||||
emit ReserveInterestRateStrategyChanged(asset, rateStrategyAddress);
|
emit ReserveInterestRateStrategyChanged(asset, rateStrategyAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @inheritdoc ILendingPoolConfigurator
|
||||||
* @dev pauses or unpauses all the actions of the protocol, including aToken transfers
|
function setPoolPause(bool val) external override onlyEmergencyAdmin {
|
||||||
* @param val true if protocol needs to be paused, false otherwise
|
_pool.setPause(val);
|
||||||
**/
|
|
||||||
function setPoolPause(bool val) external onlyEmergencyAdmin {
|
|
||||||
pool.setPause(val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _initTokenWithProxy(address implementation, bytes memory initParams)
|
function _initTokenWithProxy(address implementation, bytes memory initParams)
|
||||||
|
@ -543,7 +488,7 @@ contract LendingPoolConfigurator is VersionedInitializable, ILendingPoolConfigur
|
||||||
}
|
}
|
||||||
|
|
||||||
function _checkNoLiquidity(address asset) internal view {
|
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);
|
uint256 availableLiquidity = IERC20Detailed(asset).balanceOf(reserveData.aTokenAddress);
|
||||||
|
|
||||||
|
|
|
@ -21,3 +21,5 @@ services:
|
||||||
ALCHEMY_KEY: ${ALCHEMY_KEY}
|
ALCHEMY_KEY: ${ALCHEMY_KEY}
|
||||||
TENDERLY_FORK_ID: ${TENDERLY_FORK_ID}
|
TENDERLY_FORK_ID: ${TENDERLY_FORK_ID}
|
||||||
TENDERLY_HEAD_ID: ${TENDERLY_HEAD_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,
|
ICommonConfiguration,
|
||||||
eNetwork,
|
eNetwork,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { getParamPerPool } from './contracts-helpers';
|
import { getEthersSignersAddresses, getParamPerPool } from './contracts-helpers';
|
||||||
import AaveConfig from '../markets/aave';
|
import AaveConfig from '../markets/aave';
|
||||||
import MaticConfig from '../markets/matic';
|
import MaticConfig from '../markets/matic';
|
||||||
import AmmConfig from '../markets/amm';
|
import AmmConfig from '../markets/amm';
|
||||||
|
@ -66,9 +66,7 @@ export const getGenesisPoolAdmin = async (
|
||||||
if (targetAddress) {
|
if (targetAddress) {
|
||||||
return targetAddress;
|
return targetAddress;
|
||||||
}
|
}
|
||||||
const addressList = await Promise.all(
|
const addressList = await getEthersSignersAddresses();
|
||||||
(await DRE.ethers.getSigners()).map((signer) => signer.getAddress())
|
|
||||||
);
|
|
||||||
const addressIndex = config.PoolAdminIndex;
|
const addressIndex = config.PoolAdminIndex;
|
||||||
return addressList[addressIndex];
|
return addressList[addressIndex];
|
||||||
};
|
};
|
||||||
|
@ -81,9 +79,7 @@ export const getEmergencyAdmin = async (
|
||||||
if (targetAddress) {
|
if (targetAddress) {
|
||||||
return targetAddress;
|
return targetAddress;
|
||||||
}
|
}
|
||||||
const addressList = await Promise.all(
|
const addressList = await getEthersSignersAddresses();
|
||||||
(await DRE.ethers.getSigners()).map((signer) => signer.getAddress())
|
|
||||||
);
|
|
||||||
const addressIndex = config.EmergencyAdminIndex;
|
const addressIndex = config.EmergencyAdminIndex;
|
||||||
return addressList[addressIndex];
|
return addressList[addressIndex];
|
||||||
};
|
};
|
||||||
|
|
|
@ -137,7 +137,9 @@ export const deployGenericLogic = async (reserveLogic: Contract, verify?: boolea
|
||||||
linkedGenericLogicByteCode
|
linkedGenericLogicByteCode
|
||||||
);
|
);
|
||||||
|
|
||||||
const genericLogic = await (await genericLogicFactory.deploy()).deployed();
|
const genericLogic = await (
|
||||||
|
await genericLogicFactory.connect(await getFirstSigner()).deploy()
|
||||||
|
).deployed();
|
||||||
return withSaveAndVerify(genericLogic, eContractid.GenericLogic, [], verify);
|
return withSaveAndVerify(genericLogic, eContractid.GenericLogic, [], verify);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -158,7 +160,9 @@ export const deployValidationLogic = async (
|
||||||
linkedValidationLogicByteCode
|
linkedValidationLogicByteCode
|
||||||
);
|
);
|
||||||
|
|
||||||
const validationLogic = await (await validationLogicFactory.deploy()).deployed();
|
const validationLogic = await (
|
||||||
|
await validationLogicFactory.connect(await getFirstSigner()).deploy()
|
||||||
|
).deployed();
|
||||||
|
|
||||||
return withSaveAndVerify(validationLogic, eContractid.ValidationLogic, [], verify);
|
return withSaveAndVerify(validationLogic, eContractid.ValidationLogic, [], verify);
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,11 +32,11 @@ import {
|
||||||
FlashLiquidationAdapterFactory,
|
FlashLiquidationAdapterFactory,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { IERC20DetailedFactory } from '../types/IERC20DetailedFactory';
|
import { IERC20DetailedFactory } from '../types/IERC20DetailedFactory';
|
||||||
import { MockTokenMap } from './contracts-helpers';
|
import { getEthersSigners, MockTokenMap } from './contracts-helpers';
|
||||||
import { DRE, getDb, notFalsyOrZeroAddress } from './misc-utils';
|
import { DRE, getDb, notFalsyOrZeroAddress } from './misc-utils';
|
||||||
import { eContractid, PoolConfiguration, tEthereumAddress, TokenContractId } from './types';
|
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) => {
|
export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress) => {
|
||||||
return await LendingPoolAddressesProviderFactory.connect(
|
return await LendingPoolAddressesProviderFactory.connect(
|
||||||
|
|
|
@ -23,9 +23,10 @@ import { MintableERC20 } from '../types/MintableERC20';
|
||||||
import { Artifact } from 'hardhat/types';
|
import { Artifact } from 'hardhat/types';
|
||||||
import { Artifact as BuidlerArtifact } from '@nomiclabs/buidler/types';
|
import { Artifact as BuidlerArtifact } from '@nomiclabs/buidler/types';
|
||||||
import { verifyEtherscanContract } from './etherscan-verification';
|
import { verifyEtherscanContract } from './etherscan-verification';
|
||||||
import { getIErc20Detailed } from './contracts-getters';
|
import { getFirstSigner, getIErc20Detailed } from './contracts-getters';
|
||||||
import { usingTenderly, verifyAtTenderly } from './tenderly-utils';
|
import { usingTenderly, verifyAtTenderly } from './tenderly-utils';
|
||||||
import { usingPolygon, verifyAtPolygon } from './polygon-utils';
|
import { usingPolygon, verifyAtPolygon } from './polygon-utils';
|
||||||
|
import { getDefenderRelaySigner, usingDefender } from './defender-utils';
|
||||||
|
|
||||||
export type MockTokenMap = { [symbol: string]: MintableERC20 };
|
export type MockTokenMap = { [symbol: string]: MintableERC20 };
|
||||||
|
|
||||||
|
@ -66,11 +67,18 @@ export const rawInsertContractAddressInDb = async (id: string, address: tEthereu
|
||||||
})
|
})
|
||||||
.write();
|
.write();
|
||||||
|
|
||||||
export const getEthersSigners = async (): Promise<Signer[]> =>
|
export const getEthersSigners = async (): Promise<Signer[]> => {
|
||||||
await Promise.all(await DRE.ethers.getSigners());
|
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[]> =>
|
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 () => {
|
export const getCurrentBlock = async () => {
|
||||||
return DRE.ethers.provider.getBlockNumber();
|
return DRE.ethers.provider.getBlockNumber();
|
||||||
|
@ -83,9 +91,9 @@ export const deployContract = async <ContractType extends Contract>(
|
||||||
contractName: string,
|
contractName: string,
|
||||||
args: any[]
|
args: any[]
|
||||||
): Promise<ContractType> => {
|
): Promise<ContractType> => {
|
||||||
const contract = (await (await DRE.ethers.getContractFactory(contractName)).deploy(
|
const contract = (await (await DRE.ethers.getContractFactory(contractName))
|
||||||
...args
|
.connect(await getFirstSigner())
|
||||||
)) as ContractType;
|
.deploy(...args)) as ContractType;
|
||||||
await waitForTx(contract.deployTransaction);
|
await waitForTx(contract.deployTransaction);
|
||||||
await registerContractInJsonDb(<eContractid>contractName, contract);
|
await registerContractInJsonDb(<eContractid>contractName, contract);
|
||||||
return 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);
|
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) => {
|
export const verifyAtTenderly = async (id: string, instance: Contract) => {
|
||||||
console.log('\n- Doing Tenderly contract verification of', id);
|
console.log('\n- Doing Tenderly contract verification of', id);
|
||||||
await (DRE as any).tenderlyRPC.verify({
|
await (DRE as any).tenderlyNetwork.verify({
|
||||||
name: id,
|
name: id,
|
||||||
address: instance.address,
|
address: instance.address,
|
||||||
});
|
});
|
||||||
|
|
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-ethers": "^2.0.0",
|
||||||
"@nomiclabs/hardhat-waffle": "^2.0.0",
|
"@nomiclabs/hardhat-waffle": "^2.0.0",
|
||||||
"@openzeppelin/contracts": "3.1.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-v4": "1.0.0",
|
||||||
"@typechain/ethers-v5": "^2.0.0",
|
"@typechain/ethers-v5": "^2.0.0",
|
||||||
"@typechain/truffle-v4": "2.0.2",
|
"@typechain/truffle-v4": "2.0.2",
|
||||||
|
@ -115,6 +115,7 @@
|
||||||
"chai": "4.2.0",
|
"chai": "4.2.0",
|
||||||
"chai-bignumber": "3.0.0",
|
"chai-bignumber": "3.0.0",
|
||||||
"chai-bn": "^0.2.1",
|
"chai-bn": "^0.2.1",
|
||||||
|
"defender-relay-client": "^1.7.0",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"eth-sig-util": "2.5.3",
|
"eth-sig-util": "2.5.3",
|
||||||
"ethereum-waffle": "3.0.2",
|
"ethereum-waffle": "3.0.2",
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {
|
||||||
deployLendingPoolAddressesProvider,
|
deployLendingPoolAddressesProvider,
|
||||||
deployLendingPoolAddressesProviderRegistry,
|
deployLendingPoolAddressesProviderRegistry,
|
||||||
} from '../../helpers/contracts-deployments';
|
} from '../../helpers/contracts-deployments';
|
||||||
|
import { getEthersSigners } from '../../helpers/contracts-helpers';
|
||||||
import { waitForTx } from '../../helpers/misc-utils';
|
import { waitForTx } from '../../helpers/misc-utils';
|
||||||
import { AaveConfig } from '../../markets/aave';
|
import { AaveConfig } from '../../markets/aave';
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ task(
|
||||||
.setAction(async ({ verify }, localBRE) => {
|
.setAction(async ({ verify }, localBRE) => {
|
||||||
await localBRE.run('set-DRE');
|
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);
|
const addressesProvider = await deployLendingPoolAddressesProvider(AaveConfig.MarketId, verify);
|
||||||
await waitForTx(await addressesProvider.setPoolAdmin(admin));
|
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')) {
|
if (DRE.network.name.includes('tenderly')) {
|
||||||
const transactionLink = `https://dashboard.tenderly.co/${DRE.config.tenderly.username}/${
|
const transactionLink = `https://dashboard.tenderly.co/${DRE.config.tenderly.username}/${
|
||||||
DRE.config.tenderly.project
|
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);
|
console.error('Check tx error:', transactionLink);
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
@ -84,7 +84,7 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
|
||||||
if (DRE.network.name.includes('tenderly')) {
|
if (DRE.network.name.includes('tenderly')) {
|
||||||
const transactionLink = `https://dashboard.tenderly.co/${DRE.config.tenderly.username}/${
|
const transactionLink = `https://dashboard.tenderly.co/${DRE.config.tenderly.username}/${
|
||||||
DRE.config.tenderly.project
|
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);
|
console.error('Check tx error:', transactionLink);
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
@ -46,8 +46,8 @@ task('aave:mainnet', 'Deploy development enviroment')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usingTenderly()) {
|
if (usingTenderly()) {
|
||||||
const postDeployHead = DRE.tenderlyRPC.getHead();
|
const postDeployHead = DRE.tenderlyNetwork.getHead();
|
||||||
const postDeployFork = DRE.tenderlyRPC.getFork();
|
const postDeployFork = DRE.tenderlyNetwork.getFork();
|
||||||
console.log('Tenderly Info');
|
console.log('Tenderly Info');
|
||||||
console.log('- Head', postDeployHead);
|
console.log('- Head', postDeployHead);
|
||||||
console.log('- Fork', postDeployFork);
|
console.log('- Fork', postDeployFork);
|
||||||
|
|
|
@ -46,8 +46,8 @@ task('amm:mainnet', 'Deploy development enviroment')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usingTenderly()) {
|
if (usingTenderly()) {
|
||||||
const postDeployHead = DRE.tenderlyRPC.getHead();
|
const postDeployHead = DRE.tenderlyNetwork.getHead();
|
||||||
const postDeployFork = DRE.tenderlyRPC.getFork();
|
const postDeployFork = DRE.tenderlyNetwork.getFork();
|
||||||
console.log('Tenderly Info');
|
console.log('Tenderly Info');
|
||||||
console.log('- Head', postDeployHead);
|
console.log('- Head', postDeployHead);
|
||||||
console.log('- Fork', postDeployFork);
|
console.log('- Fork', postDeployFork);
|
||||||
|
|
|
@ -49,8 +49,8 @@ task('sidechain:mainnet', 'Deploy market at sidechain')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usingTenderly()) {
|
if (usingTenderly()) {
|
||||||
const postDeployHead = DRE.tenderlyRPC.getHead();
|
const postDeployHead = DRE.tenderlyNetwork.getHead();
|
||||||
const postDeployFork = DRE.tenderlyRPC.getFork();
|
const postDeployFork = DRE.tenderlyNetwork.getFork();
|
||||||
console.log('Tenderly Info');
|
console.log('Tenderly Info');
|
||||||
console.log('- Head', postDeployHead);
|
console.log('- Head', postDeployHead);
|
||||||
console.log('- Fork', postDeployFork);
|
console.log('- Fork', postDeployFork);
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
import { task } from 'hardhat/config';
|
import { task } from 'hardhat/config';
|
||||||
import { DRE, setDRE } from '../../helpers/misc-utils';
|
import { DRE, setDRE } from '../../helpers/misc-utils';
|
||||||
import { EthereumNetworkNames } from '../../helpers/types';
|
|
||||||
import { usingTenderly } from '../../helpers/tenderly-utils';
|
|
||||||
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
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(
|
task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).setAction(
|
||||||
async (_, _DRE) => {
|
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'
|
process.env.TENDERLY === 'true'
|
||||||
) {
|
) {
|
||||||
console.log('- Setting up Tenderly provider');
|
console.log('- Setting up Tenderly provider');
|
||||||
|
const net = _DRE.tenderly.network();
|
||||||
|
|
||||||
if (process.env.TENDERLY_FORK_ID && process.env.TENDERLY_HEAD_ID) {
|
if (process.env.TENDERLY_FORK_ID && process.env.TENDERLY_HEAD_ID) {
|
||||||
console.log('- Connecting to a Tenderly Fork');
|
console.log('- Connecting to a Tenderly Fork');
|
||||||
_DRE.tenderlyRPC.setFork(process.env.TENDERLY_FORK_ID);
|
await net.setFork(process.env.TENDERLY_FORK_ID);
|
||||||
_DRE.tenderlyRPC.setHead(process.env.TENDERLY_HEAD_ID);
|
await net.setHead(process.env.TENDERLY_HEAD_ID);
|
||||||
} else {
|
} else {
|
||||||
console.log('- Creating a new Tenderly Fork');
|
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;
|
_DRE.ethers.provider = provider;
|
||||||
console.log('- Initialized Tenderly fork:');
|
console.log('- Initialized Tenderly fork:');
|
||||||
console.log(' - Fork: ', _DRE.tenderlyRPC.getFork());
|
console.log(' - Fork: ', net.getFork());
|
||||||
console.log(' - Head: ', _DRE.tenderlyRPC.getHead());
|
console.log(' - Head: ', net.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('- Enviroment');
|
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);
|
console.log(' - Network :', _DRE.network.name);
|
||||||
|
|
||||||
setDRE(_DRE);
|
setDRE(_DRE);
|
||||||
return _DRE;
|
return _DRE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {
|
||||||
insertContractAddressInDb,
|
insertContractAddressInDb,
|
||||||
getEthersSigners,
|
getEthersSigners,
|
||||||
registerContractInJsonDb,
|
registerContractInJsonDb,
|
||||||
|
getEthersSignersAddresses,
|
||||||
} from '../../helpers/contracts-helpers';
|
} from '../../helpers/contracts-helpers';
|
||||||
import {
|
import {
|
||||||
deployLendingPoolAddressesProvider,
|
deployLendingPoolAddressesProvider,
|
||||||
|
@ -102,9 +103,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
|
await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
|
||||||
|
|
||||||
//setting users[1] as emergency admin, which is in position 2 in the DRE addresses list
|
//setting users[1] as emergency admin, which is in position 2 in the DRE addresses list
|
||||||
const addressList = await Promise.all(
|
const addressList = await getEthersSignersAddresses();
|
||||||
(await DRE.ethers.getSigners()).map((signer) => signer.getAddress())
|
|
||||||
);
|
|
||||||
|
|
||||||
await waitForTx(await addressesProvider.setEmergencyAdmin(addressList[2]));
|
await waitForTx(await addressesProvider.setEmergencyAdmin(addressList[2]));
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ export async function initializeMakeSuite() {
|
||||||
const setSnapshot = async () => {
|
const setSnapshot = async () => {
|
||||||
const hre = DRE as HardhatRuntimeEnvironment;
|
const hre = DRE as HardhatRuntimeEnvironment;
|
||||||
if (usingTenderly()) {
|
if (usingTenderly()) {
|
||||||
setBuidlerevmSnapshotId((await hre.tenderlyRPC.getHead()) || '0x1');
|
setBuidlerevmSnapshotId((await hre.tenderlyNetwork.getHead()) || '0x1');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setBuidlerevmSnapshotId(await evmSnapshot());
|
setBuidlerevmSnapshotId(await evmSnapshot());
|
||||||
|
@ -172,7 +172,7 @@ const setSnapshot = async () => {
|
||||||
const revertHead = async () => {
|
const revertHead = async () => {
|
||||||
const hre = DRE as HardhatRuntimeEnvironment;
|
const hre = DRE as HardhatRuntimeEnvironment;
|
||||||
if (usingTenderly()) {
|
if (usingTenderly()) {
|
||||||
await hre.tenderlyRPC.setHead(buidlerevmSnapshotId);
|
await hre.tenderlyNetwork.setHead(buidlerevmSnapshotId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await evmRevert(buidlerevmSnapshotId);
|
await evmRevert(buidlerevmSnapshotId);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {
|
||||||
insertContractAddressInDb,
|
insertContractAddressInDb,
|
||||||
getEthersSigners,
|
getEthersSigners,
|
||||||
registerContractInJsonDb,
|
registerContractInJsonDb,
|
||||||
|
getEthersSignersAddresses,
|
||||||
} from '../../helpers/contracts-helpers';
|
} from '../../helpers/contracts-helpers';
|
||||||
import {
|
import {
|
||||||
deployLendingPoolAddressesProvider,
|
deployLendingPoolAddressesProvider,
|
||||||
|
@ -101,9 +102,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
|
await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
|
||||||
|
|
||||||
//setting users[1] as emergency admin, which is in position 2 in the DRE addresses list
|
//setting users[1] as emergency admin, which is in position 2 in the DRE addresses list
|
||||||
const addressList = await Promise.all(
|
const addressList = await getEthersSignersAddresses();
|
||||||
(await DRE.ethers.getSigners()).map((signer) => signer.getAddress())
|
|
||||||
);
|
|
||||||
|
|
||||||
await waitForTx(await addressesProvider.setEmergencyAdmin(addressList[2]));
|
await waitForTx(await addressesProvider.setEmergencyAdmin(addressList[2]));
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ export async function initializeMakeSuite() {
|
||||||
const setSnapshot = async () => {
|
const setSnapshot = async () => {
|
||||||
const hre = DRE as HardhatRuntimeEnvironment;
|
const hre = DRE as HardhatRuntimeEnvironment;
|
||||||
if (usingTenderly()) {
|
if (usingTenderly()) {
|
||||||
setBuidlerevmSnapshotId((await hre.tenderlyRPC.getHead()) || '0x1');
|
setBuidlerevmSnapshotId((await hre.tenderlyNetwork.getHead()) || '0x1');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setBuidlerevmSnapshotId(await evmSnapshot());
|
setBuidlerevmSnapshotId(await evmSnapshot());
|
||||||
|
@ -172,7 +172,7 @@ const setSnapshot = async () => {
|
||||||
const revertHead = async () => {
|
const revertHead = async () => {
|
||||||
const hre = DRE as HardhatRuntimeEnvironment;
|
const hre = DRE as HardhatRuntimeEnvironment;
|
||||||
if (usingTenderly()) {
|
if (usingTenderly()) {
|
||||||
await hre.tenderlyRPC.setHead(buidlerevmSnapshotId);
|
await hre.tenderlyNetwork.setHead(buidlerevmSnapshotId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await evmRevert(buidlerevmSnapshotId);
|
await evmRevert(buidlerevmSnapshotId);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
"resolveJsonModule": true
|
"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": [
|
"files": [
|
||||||
"./hardhat.config.ts",
|
"./hardhat.config.ts",
|
||||||
"./modules/tenderly/tenderly.d.ts",
|
"./modules/tenderly/tenderly.d.ts",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user