Updated to reuse LendingPool & Configurator if possible

This commit is contained in:
Zer0dot 2021-02-22 22:25:48 -05:00 committed by Hadrien Charlanes
parent 32a0aef1a9
commit 50e2828008
7 changed files with 73 additions and 19 deletions

View File

@ -464,6 +464,8 @@ export interface ICommonConfiguration {
ProviderRegistry: iParamsPerNetwork<tEthereumAddress | undefined>; ProviderRegistry: iParamsPerNetwork<tEthereumAddress | undefined>;
ProviderRegistryOwner: iParamsPerNetwork<tEthereumAddress | undefined>; ProviderRegistryOwner: iParamsPerNetwork<tEthereumAddress | undefined>;
LendingPoolCollateralManager: iParamsPerNetwork<tEthereumAddress>; LendingPoolCollateralManager: iParamsPerNetwork<tEthereumAddress>;
LendingPoolConfigurator: iParamsPerNetwork<tEthereumAddress>;
LendingPool: iParamsPerNetwork<tEthereumAddress>;
LendingRateOracleRatesCommon: iMultiPoolsAssets<IMarketRates>; LendingRateOracleRatesCommon: iMultiPoolsAssets<IMarketRates>;
LendingRateOracle: iParamsPerNetwork<tEthereumAddress>; LendingRateOracle: iParamsPerNetwork<tEthereumAddress>;
TokenDistributor: iParamsPerNetwork<tEthereumAddress>; TokenDistributor: iParamsPerNetwork<tEthereumAddress>;

View File

@ -153,6 +153,24 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.main]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C', [eEthereumNetwork.main]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
[eEthereumNetwork.tenderlyMain]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C', [eEthereumNetwork.tenderlyMain]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
}, },
LendingPoolConfigurator: {
[eEthereumNetwork.coverage]: '',
[eEthereumNetwork.hardhat]: '',
[eEthereumNetwork.buidlerevm]: '',
[eEthereumNetwork.kovan]: '',
[eEthereumNetwork.ropsten]: '',
[eEthereumNetwork.main]: '',
[eEthereumNetwork.tenderlyMain]: '',
},
LendingPool: {
[eEthereumNetwork.coverage]: '',
[eEthereumNetwork.hardhat]: '',
[eEthereumNetwork.buidlerevm]: '',
[eEthereumNetwork.kovan]: '',
[eEthereumNetwork.ropsten]: '',
[eEthereumNetwork.main]: '',
[eEthereumNetwork.tenderlyMain]: '',
},
WethGateway: { WethGateway: {
[eEthereumNetwork.coverage]: '', [eEthereumNetwork.coverage]: '',
[eEthereumNetwork.hardhat]: '', [eEthereumNetwork.hardhat]: '',

View File

@ -156,6 +156,24 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.main]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C', [eEthereumNetwork.main]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
[eEthereumNetwork.tenderlyMain]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C', [eEthereumNetwork.tenderlyMain]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
}, },
LendingPoolConfigurator: {
[eEthereumNetwork.coverage]: '',
[eEthereumNetwork.hardhat]: '',
[eEthereumNetwork.buidlerevm]: '',
[eEthereumNetwork.kovan]: '0x36eB31800aa67a9c50df1d56EE01981A6E14Cce5',
[eEthereumNetwork.ropsten]: '',
[eEthereumNetwork.main]: '',
[eEthereumNetwork.tenderlyMain]: '',
},
LendingPool: {
[eEthereumNetwork.coverage]: '',
[eEthereumNetwork.hardhat]: '',
[eEthereumNetwork.buidlerevm]: '',
[eEthereumNetwork.kovan]: '0x78142De7a1930412E9e50dEB3b80dB284c2dFa3A',
[eEthereumNetwork.ropsten]: '',
[eEthereumNetwork.main]: '',
[eEthereumNetwork.tenderlyMain]: '',
},
WethGateway: { WethGateway: {
[eEthereumNetwork.coverage]: '', [eEthereumNetwork.coverage]: '',
[eEthereumNetwork.hardhat]: '', [eEthereumNetwork.hardhat]: '',

View File

@ -1,45 +1,60 @@
import { task } from 'hardhat/config'; import { task } from 'hardhat/config';
import { insertContractAddressInDb } from '../../helpers/contracts-helpers'; import { getParamPerNetwork, insertContractAddressInDb } from '../../helpers/contracts-helpers';
import { import {
deployATokensAndRatesHelper, deployATokensAndRatesHelper,
deployLendingPool, deployLendingPool,
deployLendingPoolConfigurator, deployLendingPoolConfigurator,
deployStableAndVariableTokensHelper, deployStableAndVariableTokensHelper,
} from '../../helpers/contracts-deployments'; } from '../../helpers/contracts-deployments';
import { eContractid } from '../../helpers/types'; import { eContractid, eEthereumNetwork } from '../../helpers/types';
import { waitForTx } from '../../helpers/misc-utils'; import { notFalsyOrZeroAddress, waitForTx } from '../../helpers/misc-utils';
import { import {
getLendingPoolAddressesProvider, getLendingPoolAddressesProvider,
getLendingPool, getLendingPool,
getLendingPoolConfiguratorProxy, getLendingPoolConfiguratorProxy,
} from '../../helpers/contracts-getters'; } from '../../helpers/contracts-getters';
import { HardhatRuntimeEnvironment } from 'hardhat/types'; import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { loadPoolConfig, ConfigNames } from '../../helpers/configuration';
task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment') task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
.addFlag('verify', 'Verify contracts at Etherscan') .addFlag('verify', 'Verify contracts at Etherscan')
.setAction(async ({ verify }, DRE: HardhatRuntimeEnvironment) => { .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
.setAction(async ({ verify, pool }, DRE: HardhatRuntimeEnvironment) => {
try { try {
await DRE.run('set-DRE'); await DRE.run('set-DRE');
const network = <eEthereumNetwork>DRE.network.name;
const poolConfig = loadPoolConfig(pool)
const addressesProvider = await getLendingPoolAddressesProvider(); const addressesProvider = await getLendingPoolAddressesProvider();
const { LendingPool, LendingPoolConfigurator } = poolConfig;
// Deploy lending pool // Reuse/deploy lending pool implementation
const lendingPoolImpl = await deployLendingPool(verify); let lendingPoolImplAddress = getParamPerNetwork(LendingPool, network)
if (!notFalsyOrZeroAddress(lendingPoolImplAddress)) {
// Set lending pool impl to address provider console.log("\tDeploying new lending pool implementation & libraries...");
await waitForTx(await addressesProvider.setLendingPoolImpl(lendingPoolImpl.address)); const lendingPoolImpl = await deployLendingPool(verify);
lendingPoolImplAddress = lendingPoolImpl.address;
}
console.log("\tSetting lending pool implementation with address:" , lendingPoolImplAddress);
// Set lending pool impl to Address provider
await waitForTx(await addressesProvider.setLendingPoolImpl(lendingPoolImplAddress));
const address = await addressesProvider.getLendingPool(); const address = await addressesProvider.getLendingPool();
const lendingPoolProxy = await getLendingPool(address); const lendingPoolProxy = await getLendingPool(address);
await insertContractAddressInDb(eContractid.LendingPool, lendingPoolProxy.address); await insertContractAddressInDb(eContractid.LendingPool, lendingPoolProxy.address);
// Deploy lending pool configurator // Reuse/deploy lending pool configurator
const lendingPoolConfiguratorImpl = await deployLendingPoolConfigurator(verify); let lendingPoolConfiguratorImplAddress = getParamPerNetwork(LendingPoolConfigurator, network); //await deployLendingPoolConfigurator(verify);
if (!notFalsyOrZeroAddress(lendingPoolConfiguratorImplAddress)) {
console.log("\tDeploying new configurator implementation...");
const lendingPoolConfiguratorImpl = await deployLendingPoolConfigurator(verify);
lendingPoolConfiguratorImplAddress = lendingPoolConfiguratorImpl.address;
}
console.log("\tSetting lending pool configurator implementation with address:" , lendingPoolConfiguratorImplAddress);
// Set lending pool conf impl to Address Provider // Set lending pool conf impl to Address Provider
await waitForTx( await waitForTx(
await addressesProvider.setLendingPoolConfiguratorImpl(lendingPoolConfiguratorImpl.address) await addressesProvider.setLendingPoolConfiguratorImpl(lendingPoolConfiguratorImplAddress)
); );
const lendingPoolConfiguratorProxy = await getLendingPoolConfiguratorProxy( const lendingPoolConfiguratorProxy = await getLendingPoolConfiguratorProxy(

View File

@ -14,7 +14,7 @@ import {
} from '../../helpers/configuration'; } from '../../helpers/configuration';
import { getWETHGateway } from '../../helpers/contracts-getters'; import { getWETHGateway } from '../../helpers/contracts-getters';
import { eEthereumNetwork, ICommonConfiguration } from '../../helpers/types'; import { eEthereumNetwork, ICommonConfiguration } from '../../helpers/types';
import { waitForTx } from '../../helpers/misc-utils'; import { notFalsyOrZeroAddress, waitForTx } from '../../helpers/misc-utils';
import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers'; import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers';
import { exit } from 'process'; import { exit } from 'process';
import { import {
@ -73,12 +73,13 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
LendingPoolCollateralManager, LendingPoolCollateralManager,
network network
); );
if (!collateralManagerAddress) { if (!notFalsyOrZeroAddress(collateralManagerAddress)) {
const collateralManager = await deployLendingPoolCollateralManager(verify); const collateralManager = await deployLendingPoolCollateralManager(verify);
collateralManagerAddress = collateralManager.address; collateralManagerAddress = collateralManager.address;
} }
// Seems unnecessary to register the collateral manager in the JSON db // Seems unnecessary to register the collateral manager in the JSON db
console.log("\tSetting lending pool collateral manager implementation with address", collateralManagerAddress);
await waitForTx( await waitForTx(
await addressesProvider.setLendingPoolCollateralManager(collateralManagerAddress) await addressesProvider.setLendingPoolCollateralManager(collateralManagerAddress)
); );
@ -88,7 +89,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
const lendingPoolAddress = await addressesProvider.getLendingPool(); const lendingPoolAddress = await addressesProvider.getLendingPool();
let gateWay = getParamPerNetwork(WethGateway, network); let gateWay = getParamPerNetwork(WethGateway, network);
if (gateWay == '') { if (!notFalsyOrZeroAddress(gateWay)) {
gateWay = (await getWETHGateway()).address; gateWay = (await getWETHGateway()).address;
} }
await authorizeWETHGateway(gateWay, lendingPoolAddress); await authorizeWETHGateway(gateWay, lendingPoolAddress);

View File

@ -21,7 +21,7 @@ task('aave:mainnet', 'Deploy development enviroment')
await DRE.run('full:deploy-address-provider', { pool: POOL_NAME }); await DRE.run('full:deploy-address-provider', { pool: POOL_NAME });
console.log('2. Deploy lending pool'); console.log('2. Deploy lending pool');
await DRE.run('full:deploy-lending-pool'); await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME });
console.log('3. Deploy oracles'); console.log('3. Deploy oracles');
await DRE.run('full:deploy-oracles', { pool: POOL_NAME }); await DRE.run('full:deploy-oracles', { pool: POOL_NAME });

View File

@ -21,7 +21,7 @@ task('lp:mainnet', 'Deploy development enviroment')
await DRE.run('full:deploy-address-provider', { pool: POOL_NAME }); await DRE.run('full:deploy-address-provider', { pool: POOL_NAME });
console.log('2. Deploy lending pool'); console.log('2. Deploy lending pool');
await DRE.run('full:deploy-lending-pool'); await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME });
console.log('3. Deploy oracles'); console.log('3. Deploy oracles');
await DRE.run('full:deploy-oracles', { pool: POOL_NAME }); await DRE.run('full:deploy-oracles', { pool: POOL_NAME });