mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Updated to reuse LendingPool & Configurator if possible
This commit is contained in:
parent
32a0aef1a9
commit
50e2828008
|
@ -464,6 +464,8 @@ export interface ICommonConfiguration {
|
|||
ProviderRegistry: iParamsPerNetwork<tEthereumAddress | undefined>;
|
||||
ProviderRegistryOwner: iParamsPerNetwork<tEthereumAddress | undefined>;
|
||||
LendingPoolCollateralManager: iParamsPerNetwork<tEthereumAddress>;
|
||||
LendingPoolConfigurator: iParamsPerNetwork<tEthereumAddress>;
|
||||
LendingPool: iParamsPerNetwork<tEthereumAddress>;
|
||||
LendingRateOracleRatesCommon: iMultiPoolsAssets<IMarketRates>;
|
||||
LendingRateOracle: iParamsPerNetwork<tEthereumAddress>;
|
||||
TokenDistributor: iParamsPerNetwork<tEthereumAddress>;
|
||||
|
|
|
@ -153,6 +153,24 @@ export const CommonsConfig: ICommonConfiguration = {
|
|||
[eEthereumNetwork.main]: '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: {
|
||||
[eEthereumNetwork.coverage]: '',
|
||||
[eEthereumNetwork.hardhat]: '',
|
||||
|
|
|
@ -156,6 +156,24 @@ export const CommonsConfig: ICommonConfiguration = {
|
|||
[eEthereumNetwork.main]: '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: {
|
||||
[eEthereumNetwork.coverage]: '',
|
||||
[eEthereumNetwork.hardhat]: '',
|
||||
|
|
|
@ -1,45 +1,60 @@
|
|||
import { task } from 'hardhat/config';
|
||||
import { insertContractAddressInDb } from '../../helpers/contracts-helpers';
|
||||
import { getParamPerNetwork, insertContractAddressInDb } from '../../helpers/contracts-helpers';
|
||||
import {
|
||||
deployATokensAndRatesHelper,
|
||||
deployLendingPool,
|
||||
deployLendingPoolConfigurator,
|
||||
deployStableAndVariableTokensHelper,
|
||||
} from '../../helpers/contracts-deployments';
|
||||
import { eContractid } from '../../helpers/types';
|
||||
import { waitForTx } from '../../helpers/misc-utils';
|
||||
import { eContractid, eEthereumNetwork } from '../../helpers/types';
|
||||
import { notFalsyOrZeroAddress, waitForTx } from '../../helpers/misc-utils';
|
||||
import {
|
||||
getLendingPoolAddressesProvider,
|
||||
getLendingPool,
|
||||
getLendingPoolConfiguratorProxy,
|
||||
} from '../../helpers/contracts-getters';
|
||||
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
||||
import { loadPoolConfig, ConfigNames } from '../../helpers/configuration';
|
||||
|
||||
task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
|
||||
.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 {
|
||||
await DRE.run('set-DRE');
|
||||
|
||||
const network = <eEthereumNetwork>DRE.network.name;
|
||||
const poolConfig = loadPoolConfig(pool)
|
||||
const addressesProvider = await getLendingPoolAddressesProvider();
|
||||
|
||||
const { LendingPool, LendingPoolConfigurator } = poolConfig;
|
||||
|
||||
// Deploy lending pool
|
||||
const lendingPoolImpl = await deployLendingPool(verify);
|
||||
|
||||
// Set lending pool impl to address provider
|
||||
await waitForTx(await addressesProvider.setLendingPoolImpl(lendingPoolImpl.address));
|
||||
// Reuse/deploy lending pool implementation
|
||||
let lendingPoolImplAddress = getParamPerNetwork(LendingPool, network)
|
||||
if (!notFalsyOrZeroAddress(lendingPoolImplAddress)) {
|
||||
console.log("\tDeploying new lending pool implementation & libraries...");
|
||||
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 lendingPoolProxy = await getLendingPool(address);
|
||||
|
||||
await insertContractAddressInDb(eContractid.LendingPool, lendingPoolProxy.address);
|
||||
|
||||
// Deploy lending pool configurator
|
||||
const lendingPoolConfiguratorImpl = await deployLendingPoolConfigurator(verify);
|
||||
|
||||
// Reuse/deploy lending pool configurator
|
||||
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
|
||||
await waitForTx(
|
||||
await addressesProvider.setLendingPoolConfiguratorImpl(lendingPoolConfiguratorImpl.address)
|
||||
await addressesProvider.setLendingPoolConfiguratorImpl(lendingPoolConfiguratorImplAddress)
|
||||
);
|
||||
|
||||
const lendingPoolConfiguratorProxy = await getLendingPoolConfiguratorProxy(
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
} from '../../helpers/configuration';
|
||||
import { getWETHGateway } from '../../helpers/contracts-getters';
|
||||
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 { exit } from 'process';
|
||||
import {
|
||||
|
@ -73,12 +73,13 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
|||
LendingPoolCollateralManager,
|
||||
network
|
||||
);
|
||||
if (!collateralManagerAddress) {
|
||||
if (!notFalsyOrZeroAddress(collateralManagerAddress)) {
|
||||
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
||||
collateralManagerAddress = collateralManager.address;
|
||||
}
|
||||
// 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 addressesProvider.setLendingPoolCollateralManager(collateralManagerAddress)
|
||||
);
|
||||
|
@ -88,7 +89,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
|||
const lendingPoolAddress = await addressesProvider.getLendingPool();
|
||||
|
||||
let gateWay = getParamPerNetwork(WethGateway, network);
|
||||
if (gateWay == '') {
|
||||
if (!notFalsyOrZeroAddress(gateWay)) {
|
||||
gateWay = (await getWETHGateway()).address;
|
||||
}
|
||||
await authorizeWETHGateway(gateWay, lendingPoolAddress);
|
||||
|
|
|
@ -21,7 +21,7 @@ task('aave:mainnet', 'Deploy development enviroment')
|
|||
await DRE.run('full:deploy-address-provider', { pool: POOL_NAME });
|
||||
|
||||
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');
|
||||
await DRE.run('full:deploy-oracles', { pool: POOL_NAME });
|
||||
|
|
|
@ -21,7 +21,7 @@ task('lp:mainnet', 'Deploy development enviroment')
|
|||
await DRE.run('full:deploy-address-provider', { pool: POOL_NAME });
|
||||
|
||||
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');
|
||||
await DRE.run('full:deploy-oracles', { pool: POOL_NAME });
|
||||
|
|
Loading…
Reference in New Issue
Block a user