2020-11-05 11:18:20 +00:00
|
|
|
import {task} from 'hardhat/config';
|
2020-10-16 09:27:09 +00:00
|
|
|
import {insertContractAddressInDb} from '../../helpers/contracts-helpers';
|
2020-08-20 15:35:05 +00:00
|
|
|
import {
|
2020-10-27 09:58:51 +00:00
|
|
|
deployATokensAndRatesHelper,
|
2020-08-20 15:35:05 +00:00
|
|
|
deployLendingPool,
|
|
|
|
deployLendingPoolConfigurator,
|
2020-10-27 09:58:51 +00:00
|
|
|
deployStableAndVariableTokensHelper,
|
2020-10-16 09:27:09 +00:00
|
|
|
} from '../../helpers/contracts-deployments';
|
2020-08-20 15:35:05 +00:00
|
|
|
import {eContractid} from '../../helpers/types';
|
|
|
|
import {waitForTx} from '../../helpers/misc-utils';
|
2020-10-15 11:57:03 +00:00
|
|
|
import {
|
|
|
|
getLendingPoolAddressesProvider,
|
|
|
|
getLendingPool,
|
|
|
|
getLendingPoolConfiguratorProxy,
|
|
|
|
} from '../../helpers/contracts-getters';
|
2020-08-20 15:35:05 +00:00
|
|
|
|
2020-08-31 10:10:40 +00:00
|
|
|
task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
|
2020-09-24 15:48:29 +00:00
|
|
|
.addFlag('verify', 'Verify contracts at Etherscan')
|
2020-08-25 15:15:27 +00:00
|
|
|
.setAction(async ({verify}, localBRE) => {
|
2020-11-05 12:44:20 +00:00
|
|
|
await localBRE.run('set-DRE');
|
2020-08-20 15:35:05 +00:00
|
|
|
|
|
|
|
const addressesProvider = await getLendingPoolAddressesProvider();
|
|
|
|
|
2020-08-31 10:10:40 +00:00
|
|
|
// Deploy lending pool
|
2020-08-20 15:35:05 +00:00
|
|
|
const lendingPoolImpl = await deployLendingPool(verify);
|
|
|
|
|
2020-08-31 10:10:40 +00:00
|
|
|
// Set lending pool impl to address provider
|
2020-08-20 15:35:05 +00:00
|
|
|
await waitForTx(await addressesProvider.setLendingPoolImpl(lendingPoolImpl.address));
|
|
|
|
|
|
|
|
const address = await addressesProvider.getLendingPool();
|
|
|
|
const lendingPoolProxy = await getLendingPool(address);
|
|
|
|
|
|
|
|
await insertContractAddressInDb(eContractid.LendingPool, lendingPoolProxy.address);
|
|
|
|
|
2020-08-31 10:10:40 +00:00
|
|
|
// Deploy lending pool configurator
|
2020-08-20 15:35:05 +00:00
|
|
|
const lendingPoolConfiguratorImpl = await deployLendingPoolConfigurator(verify);
|
|
|
|
|
|
|
|
// Set lending pool conf impl to Address Provider
|
|
|
|
await waitForTx(
|
|
|
|
await addressesProvider.setLendingPoolConfiguratorImpl(lendingPoolConfiguratorImpl.address)
|
|
|
|
);
|
|
|
|
|
|
|
|
const lendingPoolConfiguratorProxy = await getLendingPoolConfiguratorProxy(
|
|
|
|
await addressesProvider.getLendingPoolConfigurator()
|
|
|
|
);
|
2020-08-31 10:10:40 +00:00
|
|
|
|
2020-08-20 15:35:05 +00:00
|
|
|
await insertContractAddressInDb(
|
|
|
|
eContractid.LendingPoolConfigurator,
|
|
|
|
lendingPoolConfiguratorProxy.address
|
|
|
|
);
|
2020-10-27 09:58:51 +00:00
|
|
|
// Deploy deployment helpers
|
|
|
|
await deployStableAndVariableTokensHelper(
|
|
|
|
[lendingPoolProxy.address, addressesProvider.address],
|
|
|
|
verify
|
|
|
|
);
|
|
|
|
await deployATokensAndRatesHelper(
|
|
|
|
[lendingPoolProxy.address, addressesProvider.address, lendingPoolConfiguratorProxy.address],
|
|
|
|
verify
|
|
|
|
);
|
2020-08-20 15:35:05 +00:00
|
|
|
});
|