2020-12-02 09:58:44 +00:00
|
|
|
import { error } from 'console';
|
2020-12-01 09:29:30 +00:00
|
|
|
import { zeroAddress } from 'ethereumjs-util';
|
|
|
|
import { task } from 'hardhat/config';
|
2020-12-02 08:28:55 +00:00
|
|
|
import {
|
|
|
|
loadPoolConfig,
|
|
|
|
ConfigNames,
|
|
|
|
getWethAddress,
|
|
|
|
getTreasuryAddress,
|
|
|
|
} from '../../helpers/configuration';
|
2020-12-01 09:29:30 +00:00
|
|
|
import { ZERO_ADDRESS } from '../../helpers/constants';
|
2020-11-10 12:11:33 +00:00
|
|
|
import {
|
2020-11-10 14:19:47 +00:00
|
|
|
getAaveProtocolDataProvider,
|
2020-11-10 13:18:48 +00:00
|
|
|
getAddressById,
|
2020-11-10 12:11:33 +00:00
|
|
|
getLendingPool,
|
|
|
|
getLendingPoolAddressesProvider,
|
|
|
|
getLendingPoolAddressesProviderRegistry,
|
|
|
|
getLendingPoolCollateralManager,
|
|
|
|
getLendingPoolCollateralManagerImpl,
|
|
|
|
getLendingPoolConfiguratorImpl,
|
|
|
|
getLendingPoolConfiguratorProxy,
|
|
|
|
getLendingPoolImpl,
|
2021-03-11 15:55:04 +00:00
|
|
|
getProxy,
|
2020-11-10 12:11:33 +00:00
|
|
|
getWalletProvider,
|
|
|
|
getWETHGateway,
|
|
|
|
} from '../../helpers/contracts-getters';
|
2021-03-11 15:55:04 +00:00
|
|
|
import { verifyContract, getParamPerNetwork } from '../../helpers/contracts-helpers';
|
2020-12-01 09:29:30 +00:00
|
|
|
import { notFalsyOrZeroAddress } from '../../helpers/misc-utils';
|
2021-03-11 15:55:04 +00:00
|
|
|
import { eContractid, eNetwork, ICommonConfiguration } from '../../helpers/types';
|
2020-11-10 12:11:33 +00:00
|
|
|
|
2021-02-23 03:25:58 +00:00
|
|
|
task('verify:general', 'Verify contracts at Etherscan')
|
2020-11-10 12:11:33 +00:00
|
|
|
.addFlag('all', 'Verify all contracts at Etherscan')
|
|
|
|
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
2020-12-01 09:29:30 +00:00
|
|
|
.setAction(async ({ all, pool }, localDRE) => {
|
2020-11-10 12:11:33 +00:00
|
|
|
await localDRE.run('set-DRE');
|
2021-02-23 14:42:47 +00:00
|
|
|
const network = localDRE.network.name as eNetwork;
|
2020-11-10 12:11:33 +00:00
|
|
|
const poolConfig = loadPoolConfig(pool);
|
2020-12-01 09:29:30 +00:00
|
|
|
const {
|
|
|
|
ReserveAssets,
|
|
|
|
ReservesConfig,
|
|
|
|
ProviderRegistry,
|
|
|
|
MarketId,
|
2021-02-23 03:25:58 +00:00
|
|
|
LendingPoolCollateralManager,
|
|
|
|
LendingPoolConfigurator,
|
|
|
|
LendingPool,
|
|
|
|
WethGateway,
|
2020-12-01 09:29:30 +00:00
|
|
|
} = poolConfig as ICommonConfiguration;
|
2020-12-02 08:28:55 +00:00
|
|
|
const treasuryAddress = await getTreasuryAddress(poolConfig);
|
2020-11-10 12:11:33 +00:00
|
|
|
|
2020-12-01 09:29:30 +00:00
|
|
|
const registryAddress = getParamPerNetwork(ProviderRegistry, network);
|
2020-11-10 12:11:33 +00:00
|
|
|
const addressesProvider = await getLendingPoolAddressesProvider();
|
2020-12-01 09:29:30 +00:00
|
|
|
const addressesProviderRegistry = notFalsyOrZeroAddress(registryAddress)
|
|
|
|
? await getLendingPoolAddressesProviderRegistry(registryAddress)
|
|
|
|
: await getLendingPoolAddressesProviderRegistry();
|
2021-02-23 03:25:58 +00:00
|
|
|
const lendingPoolAddress = await addressesProvider.getLendingPool();
|
2021-02-23 14:42:47 +00:00
|
|
|
const lendingPoolConfiguratorAddress = await addressesProvider.getLendingPoolConfigurator(); //getLendingPoolConfiguratorProxy();
|
2021-02-23 03:25:58 +00:00
|
|
|
const lendingPoolCollateralManagerAddress = await addressesProvider.getLendingPoolCollateralManager();
|
2020-11-10 12:11:33 +00:00
|
|
|
|
2021-03-11 15:55:04 +00:00
|
|
|
const lendingPoolProxy = await getProxy(lendingPoolAddress);
|
|
|
|
const lendingPoolConfiguratorProxy = await getProxy(lendingPoolConfiguratorAddress);
|
|
|
|
const lendingPoolCollateralManagerProxy = await getProxy(lendingPoolCollateralManagerAddress);
|
|
|
|
|
2020-11-10 12:11:33 +00:00
|
|
|
if (all) {
|
2021-02-23 03:25:58 +00:00
|
|
|
const lendingPoolImplAddress = getParamPerNetwork(LendingPool, network);
|
|
|
|
const lendingPoolImpl = notFalsyOrZeroAddress(lendingPoolImplAddress)
|
|
|
|
? await getLendingPoolImpl(lendingPoolImplAddress)
|
|
|
|
: await getLendingPoolImpl();
|
|
|
|
|
2021-02-23 14:42:47 +00:00
|
|
|
const lendingPoolConfiguratorImplAddress = getParamPerNetwork(
|
|
|
|
LendingPoolConfigurator,
|
|
|
|
network
|
|
|
|
);
|
2021-02-23 03:25:58 +00:00
|
|
|
const lendingPoolConfiguratorImpl = notFalsyOrZeroAddress(lendingPoolConfiguratorImplAddress)
|
|
|
|
? await getLendingPoolConfiguratorImpl(lendingPoolConfiguratorImplAddress)
|
|
|
|
: await getLendingPoolConfiguratorImpl();
|
|
|
|
|
2021-02-23 14:42:47 +00:00
|
|
|
const lendingPoolCollateralManagerImplAddress = getParamPerNetwork(
|
|
|
|
LendingPoolCollateralManager,
|
|
|
|
network
|
|
|
|
);
|
|
|
|
const lendingPoolCollateralManagerImpl = notFalsyOrZeroAddress(
|
|
|
|
lendingPoolCollateralManagerImplAddress
|
|
|
|
)
|
2021-02-23 03:25:58 +00:00
|
|
|
? await getLendingPoolCollateralManagerImpl(lendingPoolCollateralManagerImplAddress)
|
|
|
|
: await getLendingPoolCollateralManagerImpl();
|
|
|
|
|
2020-11-10 14:19:47 +00:00
|
|
|
const dataProvider = await getAaveProtocolDataProvider();
|
2020-11-10 12:11:33 +00:00
|
|
|
const walletProvider = await getWalletProvider();
|
2021-02-23 03:25:58 +00:00
|
|
|
|
|
|
|
const wethGatewayAddress = getParamPerNetwork(WethGateway, network);
|
|
|
|
const wethGateway = notFalsyOrZeroAddress(wethGatewayAddress)
|
|
|
|
? await getWETHGateway(wethGatewayAddress)
|
|
|
|
: await getWETHGateway();
|
2020-11-10 12:11:33 +00:00
|
|
|
|
|
|
|
// Address Provider
|
|
|
|
console.log('\n- Verifying address provider...\n');
|
2021-03-11 15:55:04 +00:00
|
|
|
await verifyContract(eContractid.LendingPoolAddressesProvider, addressesProvider, [MarketId]);
|
2020-11-10 12:11:33 +00:00
|
|
|
|
|
|
|
// Address Provider Registry
|
|
|
|
console.log('\n- Verifying address provider registry...\n');
|
2021-03-11 15:55:04 +00:00
|
|
|
await verifyContract(
|
|
|
|
eContractid.LendingPoolAddressesProviderRegistry,
|
|
|
|
addressesProviderRegistry,
|
|
|
|
[]
|
|
|
|
);
|
2020-11-10 12:11:33 +00:00
|
|
|
|
|
|
|
// Lending Pool implementation
|
|
|
|
console.log('\n- Verifying LendingPool Implementation...\n');
|
2021-03-11 15:55:04 +00:00
|
|
|
await verifyContract(eContractid.LendingPool, lendingPoolImpl, []);
|
2020-11-10 12:11:33 +00:00
|
|
|
|
|
|
|
// Lending Pool Configurator implementation
|
|
|
|
console.log('\n- Verifying LendingPool Configurator Implementation...\n');
|
2021-03-11 15:55:04 +00:00
|
|
|
await verifyContract(eContractid.LendingPoolConfigurator, lendingPoolConfiguratorImpl, []);
|
2020-11-10 12:11:33 +00:00
|
|
|
|
|
|
|
// Lending Pool Collateral Manager implementation
|
|
|
|
console.log('\n- Verifying LendingPool Collateral Manager Implementation...\n');
|
2021-03-11 15:55:04 +00:00
|
|
|
await verifyContract(
|
|
|
|
eContractid.LendingPoolCollateralManager,
|
|
|
|
lendingPoolCollateralManagerImpl,
|
|
|
|
[]
|
|
|
|
);
|
2020-11-10 12:11:33 +00:00
|
|
|
|
|
|
|
// Test helpers
|
2020-11-10 14:19:47 +00:00
|
|
|
console.log('\n- Verifying Aave Provider Helpers...\n');
|
2021-03-11 15:55:04 +00:00
|
|
|
await verifyContract(eContractid.AaveProtocolDataProvider, dataProvider, [
|
|
|
|
addressesProvider.address,
|
|
|
|
]);
|
2020-11-10 12:11:33 +00:00
|
|
|
|
|
|
|
// Wallet balance provider
|
|
|
|
console.log('\n- Verifying Wallet Balance Provider...\n');
|
2021-03-11 15:55:04 +00:00
|
|
|
await verifyContract(eContractid.WalletBalanceProvider, walletProvider, []);
|
2020-11-10 12:11:33 +00:00
|
|
|
|
|
|
|
// WETHGateway
|
|
|
|
console.log('\n- Verifying WETHGateway...\n');
|
2021-03-11 15:55:04 +00:00
|
|
|
await verifyContract(eContractid.WETHGateway, wethGateway, [
|
|
|
|
await getWethAddress(poolConfig),
|
|
|
|
]);
|
2020-11-10 12:11:33 +00:00
|
|
|
}
|
|
|
|
// Lending Pool proxy
|
|
|
|
console.log('\n- Verifying Lending Pool Proxy...\n');
|
2021-03-11 15:55:04 +00:00
|
|
|
await verifyContract(eContractid.InitializableAdminUpgradeabilityProxy, lendingPoolProxy, [
|
|
|
|
addressesProvider.address,
|
|
|
|
]);
|
2020-11-10 12:11:33 +00:00
|
|
|
|
|
|
|
// LendingPool Conf proxy
|
|
|
|
console.log('\n- Verifying Lending Pool Configurator Proxy...\n');
|
2021-03-11 15:55:04 +00:00
|
|
|
await verifyContract(
|
|
|
|
eContractid.InitializableAdminUpgradeabilityProxy,
|
|
|
|
lendingPoolConfiguratorProxy,
|
|
|
|
[addressesProvider.address]
|
|
|
|
);
|
2020-11-10 12:11:33 +00:00
|
|
|
|
|
|
|
// Proxy collateral manager
|
|
|
|
console.log('\n- Verifying Lending Pool Collateral Manager Proxy...\n');
|
2021-03-11 15:55:04 +00:00
|
|
|
await verifyContract(
|
|
|
|
eContractid.InitializableAdminUpgradeabilityProxy,
|
|
|
|
lendingPoolCollateralManagerProxy,
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
|
2020-12-02 09:58:44 +00:00
|
|
|
console.log('Finished verifications.');
|
2020-11-10 12:11:33 +00:00
|
|
|
});
|