mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
tasks: Full migration scripts now deploys independent markets. Added new task to attach a new market to the LendingPoolAddressesProviderRegistry.
This commit is contained in:
parent
57cc6579e1
commit
607d3c9a24
27
package.json
27
package.json
|
@ -40,16 +40,23 @@
|
|||
"test:main:check-list": "MAINNET_FORK=true TS_NODE_TRANSPILE_ONLY=1 hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/mainnet/check-list.spec.ts",
|
||||
"dev:coverage": "buidler compile --force && buidler coverage --network coverage",
|
||||
"aave:evm:dev:migration": "npm run compile && hardhat aave:dev",
|
||||
"aave:docker:full:migration": "npm run compile && npm run hardhat:docker -- aave:mainnet --deploy-registry",
|
||||
"aave:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- aave:mainnet --verify --deploy-registry",
|
||||
"matic:mumbai:full:migration": "npm run compile && npm run hardhat:mumbai matic:mainnet --deploy-registry",
|
||||
"matic:matic:full:migration": "npm run compile && npm run hardhat:matic matic:mainnet --deploy-registry",
|
||||
"amm:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- amm:mainnet --verify --deploy-registry",
|
||||
"aave:docker:full:migration:skip-registry": "npm run compile && npm run hardhat:docker -- aave:mainnet",
|
||||
"aave:kovan:full:migration:skip-registry": "npm run compile && npm run hardhat:kovan -- aave:mainnet --verify",
|
||||
"matic:mumbai:full:migration:skip-registry": "npm run compile && npm run hardhat:mumbai matic:mainnet",
|
||||
"matic:matic:full:migration:skip-registry": "npm run compile && npm run hardhat:matic matic:mainnet",
|
||||
"amm:kovan:full:migration:skip-registry": "npm run compile && npm run hardhat:kovan -- amm:mainnet --verify",
|
||||
"aave:docker:full:migration": "npm run compile && npm run hardhat:docker -- aave:mainnet",
|
||||
"aave:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- aave:mainnet",
|
||||
"matic:mumbai:full:migration": "npm run compile && npm run hardhat:mumbai matic:mainnet",
|
||||
"matic:matic:full:migration": "npm run compile && npm run hardhat:matic matic:mainnet",
|
||||
"amm:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- amm:mainnet",
|
||||
"aave:docker:add-market-to-registry-from-config": "npm run compile && npm run hardhat:docker -- add-market-to-registry --pool Aave",
|
||||
"aave:kovan:add-market-to-registry-from-config": "npm run compile && npm run hardhat:kovan -- add-market-to-registry --pool Aave",
|
||||
"matic:mumbai:add-market-to-registry-from-config": "npm run compile && npm run hardhat:mumbai add-market-to-registry --pool Matic",
|
||||
"amm:kovan:add-market-to-registry-from-config": "npm run compile && npm run hardhat:kovan -- add-market-to-registry --pool Amm",
|
||||
"matic:matic:add-market-to-registry-from-config": "npm run compile && npm run hardhat:matic add-market-to-registry --pool Matic",
|
||||
"aave:main:add-market-to-registry-from-config": "npm run compile && npm run hardhat:main -- add-market-to-registry --pool Aave",
|
||||
"aave:docker:add-market-to-new-registry": "npm run compile && npm run hardhat:docker -- add-market-to-registry --pool Aave --deploy-registry",
|
||||
"aave:kovan:add-market-to-new-registry": "npm run compile && npm run hardhat:kovan -- add-market-to-registry --pool Aave --verify --deploy-registry",
|
||||
"matic:mumbai:add-market-to-new-registry": "npm run compile && npm run hardhat:mumbai add-market-to-registry --pool Matic --verify --deploy-registry",
|
||||
"amm:kovan:add-market-to-new-registry": "npm run compile && npm run hardhat:kovan -- add-market-to-registry --pool Amm --verify --deploy-registry",
|
||||
"matic:matic:add-market-to-new-registry": "npm run compile && npm run hardhat:matic -- add-market-to-registry --pool Matic --verify --deploy-registry",
|
||||
"aave:main:add-market-to-new-registry": "npm run compile && npm run hardhat:matic -- add-market-to-registry --pool Matic --verify --deploy-registry",
|
||||
"aave:kovan:full:initialize": "npm run hardhat:kovan -- full:initialize-lending-pool --verify --pool Aave",
|
||||
"aave:ropsten:full:migration": "npm run compile && npm run hardhat:ropsten -- aave:mainnet --verify",
|
||||
"aave:fork:main:tenderly": "npm run compile && npm run hardhat:tenderly-main -- aave:mainnet",
|
||||
|
|
|
@ -1,25 +1,12 @@
|
|||
import { task } from 'hardhat/config';
|
||||
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
|
||||
import {
|
||||
deployLendingPoolAddressesProvider,
|
||||
deployLendingPoolAddressesProviderRegistry,
|
||||
} from '../../helpers/contracts-deployments';
|
||||
import { notFalsyOrZeroAddress, waitForTx } from '../../helpers/misc-utils';
|
||||
import { deployLendingPoolAddressesProvider } from '../../helpers/contracts-deployments';
|
||||
import { waitForTx } from '../../helpers/misc-utils';
|
||||
import {
|
||||
ConfigNames,
|
||||
loadPoolConfig,
|
||||
getGenesisPoolAdmin,
|
||||
getEmergencyAdmin,
|
||||
} from '../../helpers/configuration';
|
||||
import { eNetwork } from '../../helpers/types';
|
||||
import {
|
||||
getFirstSigner,
|
||||
getLendingPoolAddressesProviderRegistry,
|
||||
} from '../../helpers/contracts-getters';
|
||||
import { formatEther, isAddress, parseEther } from 'ethers/lib/utils';
|
||||
import { isZeroAddress } from 'ethereumjs-util';
|
||||
import { Signer, BigNumber } from 'ethers';
|
||||
import { parse } from 'path';
|
||||
//import BigNumber from 'bignumber.js';
|
||||
|
||||
task(
|
||||
|
@ -28,71 +15,15 @@ task(
|
|||
)
|
||||
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
||||
.addFlag('deployRegistry', 'Deploy a new address provider registry')
|
||||
.setAction(async ({ verify, pool, deployRegistry }, DRE) => {
|
||||
.setAction(async ({ verify, pool }, DRE) => {
|
||||
await DRE.run('set-DRE');
|
||||
let signer: Signer;
|
||||
const network = <eNetwork>DRE.network.name;
|
||||
const poolConfig = loadPoolConfig(pool);
|
||||
const { ProviderId, MarketId } = poolConfig;
|
||||
const { MarketId } = poolConfig;
|
||||
|
||||
let providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network);
|
||||
let providerRegistryOwner = getParamPerNetwork(poolConfig.ProviderRegistryOwner, network);
|
||||
|
||||
if (
|
||||
deployRegistry ||
|
||||
!providerRegistryAddress ||
|
||||
!isAddress(providerRegistryAddress) ||
|
||||
isZeroAddress(providerRegistryAddress)
|
||||
) {
|
||||
console.log('- Deploying a new Address Providers Registry:');
|
||||
|
||||
await DRE.run('full:deploy-address-provider-registry');
|
||||
|
||||
providerRegistryAddress = (await getLendingPoolAddressesProviderRegistry()).address;
|
||||
providerRegistryOwner = await (await getFirstSigner()).getAddress();
|
||||
}
|
||||
|
||||
if (
|
||||
!providerRegistryOwner ||
|
||||
!isAddress(providerRegistryOwner) ||
|
||||
isZeroAddress(providerRegistryOwner)
|
||||
) {
|
||||
throw Error('config.ProviderRegistryOwner is missing or is not an address.');
|
||||
}
|
||||
|
||||
// Checks if deployer address is registry owner
|
||||
if (process.env.MAINNET_FORK === 'true') {
|
||||
await DRE.network.provider.request({
|
||||
method: 'hardhat_impersonateAccount',
|
||||
params: [providerRegistryOwner],
|
||||
});
|
||||
signer = DRE.ethers.provider.getSigner(providerRegistryOwner);
|
||||
const firstAccount = await getFirstSigner();
|
||||
await firstAccount.sendTransaction({ value: parseEther('10'), to: providerRegistryOwner });
|
||||
} else {
|
||||
signer = DRE.ethers.provider.getSigner(providerRegistryOwner);
|
||||
}
|
||||
// 1. Address Provider Registry instance
|
||||
const addressesProviderRegistry = (
|
||||
await getLendingPoolAddressesProviderRegistry(providerRegistryAddress)
|
||||
).connect(signer);
|
||||
|
||||
console.log('Registry Address', addressesProviderRegistry.address);
|
||||
|
||||
// 2. Deploy address provider and set genesis manager
|
||||
// 1. Deploy address provider and set genesis manager
|
||||
const addressesProvider = await deployLendingPoolAddressesProvider(MarketId, verify);
|
||||
|
||||
// DISABLE SEC. 3 FOR GOVERNANCE USE!
|
||||
// 3. Set the provider at the Registry
|
||||
await waitForTx(
|
||||
await addressesProviderRegistry.registerAddressesProvider(
|
||||
addressesProvider.address,
|
||||
ProviderId
|
||||
)
|
||||
);
|
||||
|
||||
// 4. Set pool admins
|
||||
// 2. Set pool admins
|
||||
|
||||
await waitForTx(await addressesProvider.setPoolAdmin(await getGenesisPoolAdmin(poolConfig)));
|
||||
await waitForTx(await addressesProvider.setEmergencyAdmin(await getEmergencyAdmin(poolConfig)));
|
||||
|
|
82
tasks/full/8-add-market-to-registry.ts
Normal file
82
tasks/full/8-add-market-to-registry.ts
Normal file
|
@ -0,0 +1,82 @@
|
|||
import { task } from 'hardhat/config';
|
||||
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
|
||||
import { waitForTx } from '../../helpers/misc-utils';
|
||||
import { ConfigNames, loadPoolConfig } from '../../helpers/configuration';
|
||||
import { eNetwork } from '../../helpers/types';
|
||||
import {
|
||||
getFirstSigner,
|
||||
getLendingPoolAddressesProvider,
|
||||
getLendingPoolAddressesProviderRegistry,
|
||||
} from '../../helpers/contracts-getters';
|
||||
import { isAddress, parseEther } from 'ethers/lib/utils';
|
||||
import { isZeroAddress } from 'ethereumjs-util';
|
||||
import { Signer } from 'ethers';
|
||||
|
||||
task('add-market-to-registry', 'Adds address provider to registry')
|
||||
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
||||
.addOptionalParam('addressesProvider', `Address of LendingPoolAddressProvider`)
|
||||
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||
.addFlag('deployRegistry', 'Deploy a new address provider registry')
|
||||
.setAction(async ({ verify, addressesProvider, pool, deployRegistry }, DRE) => {
|
||||
await DRE.run('set-DRE');
|
||||
let signer: Signer;
|
||||
const network = <eNetwork>DRE.network.name;
|
||||
const poolConfig = loadPoolConfig(pool);
|
||||
const { ProviderId } = poolConfig;
|
||||
|
||||
let providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network);
|
||||
let providerRegistryOwner = getParamPerNetwork(poolConfig.ProviderRegistryOwner, network);
|
||||
|
||||
if (
|
||||
deployRegistry ||
|
||||
!providerRegistryAddress ||
|
||||
!isAddress(providerRegistryAddress) ||
|
||||
isZeroAddress(providerRegistryAddress)
|
||||
) {
|
||||
console.log('- Deploying a new Address Providers Registry:');
|
||||
|
||||
await DRE.run('full:deploy-address-provider-registry', { verify });
|
||||
|
||||
providerRegistryAddress = (await getLendingPoolAddressesProviderRegistry()).address;
|
||||
providerRegistryOwner = await (await getFirstSigner()).getAddress();
|
||||
}
|
||||
|
||||
if (
|
||||
!providerRegistryOwner ||
|
||||
!isAddress(providerRegistryOwner) ||
|
||||
isZeroAddress(providerRegistryOwner)
|
||||
) {
|
||||
throw Error('config.ProviderRegistryOwner is missing or is not an address.');
|
||||
}
|
||||
|
||||
// Checks if deployer address is registry owner
|
||||
if (process.env.MAINNET_FORK === 'true') {
|
||||
await DRE.network.provider.request({
|
||||
method: 'hardhat_impersonateAccount',
|
||||
params: [providerRegistryOwner],
|
||||
});
|
||||
signer = DRE.ethers.provider.getSigner(providerRegistryOwner);
|
||||
const firstAccount = await getFirstSigner();
|
||||
await firstAccount.sendTransaction({ value: parseEther('10'), to: providerRegistryOwner });
|
||||
} else {
|
||||
signer = DRE.ethers.provider.getSigner(providerRegistryOwner);
|
||||
}
|
||||
|
||||
// 1. Address Provider Registry instance
|
||||
const addressesProviderRegistry = (
|
||||
await getLendingPoolAddressesProviderRegistry(providerRegistryAddress)
|
||||
).connect(signer);
|
||||
|
||||
const addressesProviderInstance = await getLendingPoolAddressesProvider(addressesProvider);
|
||||
|
||||
// 2. Set the provider at the Registry
|
||||
await waitForTx(
|
||||
await addressesProviderRegistry.registerAddressesProvider(
|
||||
addressesProviderInstance.address,
|
||||
ProviderId
|
||||
)
|
||||
);
|
||||
console.log(
|
||||
`Added LendingPoolAddressesProvider with address "${addressesProviderInstance.address}" to registry located at ${addressesProviderRegistry.address}`
|
||||
);
|
||||
});
|
|
@ -6,8 +6,7 @@ import { usingTenderly } from '../../helpers/tenderly-utils';
|
|||
|
||||
task('aave:mainnet', 'Deploy development enviroment')
|
||||
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||
.addFlag('deployRegistry')
|
||||
.setAction(async ({ verify, deployRegistry }, DRE) => {
|
||||
.setAction(async ({ verify }, DRE) => {
|
||||
const POOL_NAME = ConfigNames.Aave;
|
||||
await DRE.run('set-DRE');
|
||||
|
||||
|
@ -19,10 +18,7 @@ task('aave:mainnet', 'Deploy development enviroment')
|
|||
console.log('Migration started\n');
|
||||
|
||||
console.log('1. Deploy address provider');
|
||||
await DRE.run('full:deploy-address-provider', {
|
||||
pool: POOL_NAME,
|
||||
deployRegistry,
|
||||
});
|
||||
await DRE.run('full:deploy-address-provider', { pool: POOL_NAME });
|
||||
|
||||
console.log('2. Deploy lending pool');
|
||||
await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME });
|
||||
|
|
|
@ -6,8 +6,7 @@ import { usingTenderly } from '../../helpers/tenderly-utils';
|
|||
|
||||
task('amm:mainnet', 'Deploy development enviroment')
|
||||
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||
.addFlag('deployRegistry')
|
||||
.setAction(async ({ verify, deployRegistry }, DRE) => {
|
||||
.setAction(async ({ verify }, DRE) => {
|
||||
const POOL_NAME = ConfigNames.Amm;
|
||||
await DRE.run('set-DRE');
|
||||
|
||||
|
@ -19,10 +18,7 @@ task('amm:mainnet', 'Deploy development enviroment')
|
|||
console.log('Migration started\n');
|
||||
|
||||
console.log('1. Deploy address provider');
|
||||
await DRE.run('full:deploy-address-provider', {
|
||||
pool: POOL_NAME,
|
||||
deployRegistry,
|
||||
});
|
||||
await DRE.run('full:deploy-address-provider', { pool: POOL_NAME });
|
||||
|
||||
console.log('2. Deploy lending pool');
|
||||
await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME });
|
||||
|
|
|
@ -6,8 +6,7 @@ import { usingTenderly } from '../../helpers/tenderly-utils';
|
|||
|
||||
task('matic:mainnet', 'Deploy development enviroment')
|
||||
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||
.addFlag('deployRegistry')
|
||||
.setAction(async ({ verify, deployRegistry }, DRE) => {
|
||||
.setAction(async ({ verify }, DRE) => {
|
||||
const POOL_NAME = ConfigNames.Matic;
|
||||
await DRE.run('set-DRE');
|
||||
|
||||
|
@ -19,10 +18,7 @@ task('matic:mainnet', 'Deploy development enviroment')
|
|||
console.log('Migration started\n');
|
||||
|
||||
console.log('1. Deploy address provider');
|
||||
await DRE.run('full:deploy-address-provider', {
|
||||
pool: POOL_NAME,
|
||||
deployRegistry,
|
||||
});
|
||||
await DRE.run('full:deploy-address-provider', { pool: POOL_NAME });
|
||||
|
||||
console.log('2. Deploy lending pool');
|
||||
await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME });
|
||||
|
|
Loading…
Reference in New Issue
Block a user