aave-protocol-v2/tasks/full/1_address_provider.ts

48 lines
1.8 KiB
TypeScript
Raw Normal View History

2020-11-26 15:11:40 +00:00
import { task } from 'hardhat/config';
import { deployLendingPoolAddressesProvider } from '../../helpers/contracts-deployments';
import { notFalsyOrZeroAddress, waitForTx } from '../../helpers/misc-utils';
2020-11-05 11:35:50 +00:00
import {
ConfigNames,
loadPoolConfig,
getGenesisPoolAdmin,
getEmergencyAdmin,
} from '../../helpers/configuration';
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
import { eNetwork } from '../../helpers/types';
2020-08-26 10:38:52 +00:00
task(
'full:deploy-address-provider',
'Deploy address provider, registry and fee provider for dev enviroment'
)
2020-09-24 15:48:29 +00:00
.addFlag('verify', 'Verify contracts at Etherscan')
2020-08-26 10:38:52 +00:00
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
.addFlag('skipRegistry')
.setAction(async ({ verify, pool, skipRegistry }, DRE) => {
await DRE.run('set-DRE');
2020-08-26 10:38:52 +00:00
const poolConfig = loadPoolConfig(pool);
const { MarketId } = poolConfig;
// 1. Deploy address provider and set genesis manager
const addressesProvider = await deployLendingPoolAddressesProvider(MarketId, verify);
// 2. Add to registry or setup a new one
if (!skipRegistry) {
const providerRegistryAddress = getParamPerNetwork(
poolConfig.ProviderRegistry,
<eNetwork>DRE.network.name
);
await DRE.run('add-market-to-registry', {
pool,
addressesProvider: addressesProvider.address,
deployRegistry: !notFalsyOrZeroAddress(providerRegistryAddress),
});
}
// 3. Set pool admins
await waitForTx(await addressesProvider.setPoolAdmin(await getGenesisPoolAdmin(poolConfig)));
await waitForTx(await addressesProvider.setEmergencyAdmin(await getEmergencyAdmin(poolConfig)));
console.log('Pool Admin', await addressesProvider.getPoolAdmin());
console.log('Emergency Admin', await addressesProvider.getEmergencyAdmin());
2020-08-26 10:38:52 +00:00
});