2020-08-20 15:35:05 +00:00
|
|
|
import {task} from '@nomiclabs/buidler/config';
|
|
|
|
import {
|
2020-08-21 11:07:32 +00:00
|
|
|
getLendingPoolAddressesProvider,
|
|
|
|
initReserves,
|
2020-09-24 15:48:29 +00:00
|
|
|
deployLendingPoolCollateralManager,
|
2020-08-21 11:07:32 +00:00
|
|
|
insertContractAddressInDb,
|
|
|
|
deployWalletBalancerProvider,
|
|
|
|
deployAaveProtocolTestHelpers,
|
|
|
|
getLendingPool,
|
|
|
|
getLendingPoolConfiguratorProxy,
|
2020-08-31 10:10:40 +00:00
|
|
|
getParamPerNetwork,
|
2020-08-20 15:35:05 +00:00
|
|
|
} from '../../helpers/contracts-helpers';
|
2020-08-31 10:10:40 +00:00
|
|
|
import {loadPoolConfig, ConfigNames} from '../../helpers/configuration';
|
2020-08-20 15:35:05 +00:00
|
|
|
|
2020-08-31 10:10:40 +00:00
|
|
|
import {AavePools, eContractid, eEthereumNetwork, ICommonConfiguration} from '../../helpers/types';
|
|
|
|
import {waitForTx} from '../../helpers/misc-utils';
|
2020-08-21 11:07:32 +00:00
|
|
|
import {enableReservesToBorrow, enableReservesAsCollateral} from '../../helpers/init-helpers';
|
2020-09-24 15:48:29 +00:00
|
|
|
import {ZERO_ADDRESS} from '../../helpers/constants';
|
|
|
|
import {exit} from 'process';
|
2020-08-20 15:35:05 +00:00
|
|
|
|
2020-08-31 10:10:40 +00:00
|
|
|
task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
2020-09-24 15:48:29 +00:00
|
|
|
.addFlag('verify', 'Verify contracts at Etherscan')
|
2020-08-31 10:10:40 +00:00
|
|
|
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
|
|
|
.setAction(async ({verify, pool}, localBRE) => {
|
2020-09-24 15:48:29 +00:00
|
|
|
try {
|
|
|
|
await localBRE.run('set-bre');
|
|
|
|
console.log('init');
|
|
|
|
const network = <eEthereumNetwork>localBRE.network.name;
|
|
|
|
const poolConfig = loadPoolConfig(pool);
|
|
|
|
const {ReserveAssets, ReservesConfig} = poolConfig as ICommonConfiguration;
|
2020-08-20 15:35:05 +00:00
|
|
|
|
2020-09-24 15:48:29 +00:00
|
|
|
const reserveAssets = await getParamPerNetwork(ReserveAssets, network);
|
|
|
|
const lendingPoolProxy = await getLendingPool();
|
|
|
|
const lendingPoolConfiguratorProxy = await getLendingPoolConfiguratorProxy();
|
2020-08-21 11:07:32 +00:00
|
|
|
|
2020-09-24 15:48:29 +00:00
|
|
|
const addressesProvider = await getLendingPoolAddressesProvider();
|
2020-08-20 15:35:05 +00:00
|
|
|
|
2020-10-13 11:41:57 +00:00
|
|
|
const testHelpers = await deployAaveProtocolTestHelpers(addressesProvider.address, verify);
|
|
|
|
|
2020-09-24 15:48:29 +00:00
|
|
|
console.log('init reserves');
|
|
|
|
await initReserves(
|
|
|
|
ReservesConfig,
|
|
|
|
reserveAssets,
|
|
|
|
addressesProvider,
|
|
|
|
lendingPoolProxy,
|
2020-10-13 11:41:57 +00:00
|
|
|
testHelpers,
|
2020-09-24 15:48:29 +00:00
|
|
|
lendingPoolConfiguratorProxy,
|
|
|
|
AavePools.proto,
|
|
|
|
ZERO_ADDRESS,
|
|
|
|
verify
|
|
|
|
);
|
|
|
|
console.log('enable reserves');
|
|
|
|
await enableReservesToBorrow(
|
|
|
|
ReservesConfig,
|
|
|
|
reserveAssets,
|
2020-10-13 11:41:57 +00:00
|
|
|
testHelpers,
|
2020-09-24 15:48:29 +00:00
|
|
|
lendingPoolConfiguratorProxy
|
|
|
|
);
|
|
|
|
console.log('enable reserves as collateral');
|
|
|
|
await enableReservesAsCollateral(
|
|
|
|
ReservesConfig,
|
|
|
|
reserveAssets,
|
2020-10-13 11:41:57 +00:00
|
|
|
testHelpers,
|
2020-09-24 15:48:29 +00:00
|
|
|
lendingPoolConfiguratorProxy
|
|
|
|
);
|
2020-08-20 15:35:05 +00:00
|
|
|
|
2020-09-24 15:48:29 +00:00
|
|
|
console.log('deploy coll manager');
|
|
|
|
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
|
|
|
await waitForTx(
|
|
|
|
await addressesProvider.setLendingPoolCollateralManager(collateralManager.address)
|
|
|
|
);
|
2020-08-20 15:35:05 +00:00
|
|
|
|
2020-09-24 15:48:29 +00:00
|
|
|
console.log('deploy bal provicer');
|
|
|
|
await deployWalletBalancerProvider(addressesProvider.address, verify);
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
exit(1);
|
|
|
|
}
|
2020-08-21 11:07:32 +00:00
|
|
|
});
|