2021-03-15 10:52:57 +00:00
|
|
|
import { formatEther } from 'ethers/lib/utils';
|
2020-11-30 18:25:06 +00:00
|
|
|
import { task } from 'hardhat/config';
|
2021-03-26 14:20:24 +00:00
|
|
|
import { ConfigNames, loadPoolConfig } from '../../helpers/configuration';
|
2020-11-30 18:25:06 +00:00
|
|
|
import { deployLendingPoolAddressesProviderRegistry } from '../../helpers/contracts-deployments';
|
2021-03-15 10:52:57 +00:00
|
|
|
import { getFirstSigner } from '../../helpers/contracts-getters';
|
2021-03-26 14:20:24 +00:00
|
|
|
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
|
|
|
|
import { notFalsyOrZeroAddress } from '../../helpers/misc-utils';
|
|
|
|
import { eNetwork } from '../../helpers/types';
|
2020-11-30 18:25:06 +00:00
|
|
|
|
|
|
|
task('full:deploy-address-provider-registry', 'Deploy address provider registry')
|
|
|
|
.addFlag('verify', 'Verify contracts at Etherscan')
|
2021-03-26 14:20:24 +00:00
|
|
|
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
|
|
|
.setAction(async ({ verify, pool }, DRE) => {
|
2020-11-30 18:25:06 +00:00
|
|
|
await DRE.run('set-DRE');
|
2021-03-26 14:20:24 +00:00
|
|
|
const poolConfig = loadPoolConfig(pool);
|
|
|
|
const network = <eNetwork>DRE.network.name;
|
2021-03-15 10:52:57 +00:00
|
|
|
const signer = await getFirstSigner();
|
2021-03-26 14:20:24 +00:00
|
|
|
|
|
|
|
const providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network);
|
|
|
|
|
2021-03-15 10:52:57 +00:00
|
|
|
console.log('Signer', await signer.getAddress());
|
|
|
|
console.log('Balance', formatEther(await signer.getBalance()));
|
2020-11-30 18:25:06 +00:00
|
|
|
|
2021-03-26 14:20:24 +00:00
|
|
|
if (notFalsyOrZeroAddress(providerRegistryAddress)) {
|
2021-05-12 07:46:05 +00:00
|
|
|
console.log('Already deployed Provider Registry Address at', providerRegistryAddress);
|
2021-03-26 14:20:24 +00:00
|
|
|
} else {
|
|
|
|
const contract = await deployLendingPoolAddressesProviderRegistry(verify);
|
|
|
|
console.log('Deployed Registry Address:', contract.address);
|
|
|
|
}
|
2020-11-30 18:25:06 +00:00
|
|
|
});
|