mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
fix: fixed logic of address provider registration
This commit is contained in:
parent
607d3c9a24
commit
e41a18c33a
15
package.json
15
package.json
|
@ -40,11 +40,16 @@
|
|||
"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",
|
||||
"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:full:migration": "npm run compile && npm run hardhat:docker -- aave:mainnet --skip-registry",
|
||||
"aave:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- aave:mainnet --skip-registry",
|
||||
"matic:mumbai:full:migration": "npm run compile && npm run hardhat:mumbai matic:mainnet --skip-registry",
|
||||
"matic:matic:full:migration": "npm run compile && npm run hardhat:matic matic:mainnet --skip-registry",
|
||||
"amm:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- amm:mainnet --skip-registry",
|
||||
"aave:docker:full:migration:add-registry": "npm run compile && npm run hardhat:docker -- aave:mainnet",
|
||||
"aave:kovan:full:migration:add-registry": "npm run compile && npm run hardhat:kovan -- aave:mainnet",
|
||||
"matic:mumbai:full:migration:add-registry": "npm run compile && npm run hardhat:mumbai matic:mainnet",
|
||||
"matic:matic:full:migration:add-registry": "npm run compile && npm run hardhat:matic matic:mainnet",
|
||||
"amm:kovan:full:migration:add-registry": "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",
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
import { isAddress, parseEther } from 'ethers/lib/utils';
|
||||
import { isZeroAddress } from 'ethereumjs-util';
|
||||
import { Signer } from 'ethers';
|
||||
import { exit } from 'process';
|
||||
|
||||
task('add-market-to-registry', 'Adds address provider to registry')
|
||||
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
||||
|
@ -26,6 +27,10 @@ task('add-market-to-registry', 'Adds address provider to registry')
|
|||
|
||||
let providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network);
|
||||
let providerRegistryOwner = getParamPerNetwork(poolConfig.ProviderRegistryOwner, network);
|
||||
const currentSignerAddress = await (
|
||||
await (await getFirstSigner()).getAddress()
|
||||
).toLocaleLowerCase();
|
||||
let deployed = false;
|
||||
|
||||
if (
|
||||
deployRegistry ||
|
||||
|
@ -39,6 +44,7 @@ task('add-market-to-registry', 'Adds address provider to registry')
|
|||
|
||||
providerRegistryAddress = (await getLendingPoolAddressesProviderRegistry()).address;
|
||||
providerRegistryOwner = await (await getFirstSigner()).getAddress();
|
||||
deployed = true;
|
||||
}
|
||||
|
||||
if (
|
||||
|
@ -58,6 +64,15 @@ task('add-market-to-registry', 'Adds address provider to registry')
|
|||
signer = DRE.ethers.provider.getSigner(providerRegistryOwner);
|
||||
const firstAccount = await getFirstSigner();
|
||||
await firstAccount.sendTransaction({ value: parseEther('10'), to: providerRegistryOwner });
|
||||
}
|
||||
if (
|
||||
!deployed &&
|
||||
providerRegistryOwner.toLocaleLowerCase() !== currentSignerAddress.toLocaleLowerCase()
|
||||
) {
|
||||
console.error('ProviderRegistryOwner config does not match current signer:');
|
||||
console.error('Expected:', providerRegistryOwner);
|
||||
console.error('Current:', currentSignerAddress);
|
||||
exit(2);
|
||||
} else {
|
||||
signer = DRE.ethers.provider.getSigner(providerRegistryOwner);
|
||||
}
|
|
@ -1,12 +1,15 @@
|
|||
import { task } from 'hardhat/config';
|
||||
import { deployLendingPoolAddressesProvider } from '../../helpers/contracts-deployments';
|
||||
import { waitForTx } from '../../helpers/misc-utils';
|
||||
import { notFalsyOrZeroAddress, waitForTx } from '../../helpers/misc-utils';
|
||||
import {
|
||||
ConfigNames,
|
||||
loadPoolConfig,
|
||||
getGenesisPoolAdmin,
|
||||
getEmergencyAdmin,
|
||||
} from '../../helpers/configuration';
|
||||
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
|
||||
import { eNetwork } from '../../helpers/types';
|
||||
import { isZeroAddress } from 'ethereumjs-util';
|
||||
//import BigNumber from 'bignumber.js';
|
||||
|
||||
task(
|
||||
|
@ -15,7 +18,8 @@ task(
|
|||
)
|
||||
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
||||
.setAction(async ({ verify, pool }, DRE) => {
|
||||
.addFlag('skipRegistry')
|
||||
.setAction(async ({ verify, pool, skipRegistry }, DRE) => {
|
||||
await DRE.run('set-DRE');
|
||||
const poolConfig = loadPoolConfig(pool);
|
||||
const { MarketId } = poolConfig;
|
||||
|
@ -23,8 +27,20 @@ task(
|
|||
// 1. Deploy address provider and set genesis manager
|
||||
const addressesProvider = await deployLendingPoolAddressesProvider(MarketId, verify);
|
||||
|
||||
// 2. Set pool admins
|
||||
// 2. Add to registry or setup a new one
|
||||
if (!skipRegistry) {
|
||||
const providerRegistryAddress = getParamPerNetwork(
|
||||
poolConfig.ProviderRegistry,
|
||||
<eNetwork>DRE.network.name
|
||||
);
|
||||
|
||||
await DRE.run('add-market-to-registry', {
|
||||
pool,
|
||||
addressesProvider: addressesProvider.address,
|
||||
deployRegistry: !notFalsyOrZeroAddress(providerRegistryAddress),
|
||||
});
|
||||
}
|
||||
// 3. Set pool admins
|
||||
await waitForTx(await addressesProvider.setPoolAdmin(await getGenesisPoolAdmin(poolConfig)));
|
||||
await waitForTx(await addressesProvider.setEmergencyAdmin(await getEmergencyAdmin(poolConfig)));
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@ import { usingTenderly } from '../../helpers/tenderly-utils';
|
|||
|
||||
task('aave:mainnet', 'Deploy development enviroment')
|
||||
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||
.setAction(async ({ verify }, DRE) => {
|
||||
.addFlag('skipRegistry', 'Skip addresses provider registration at Addresses Provider Registry')
|
||||
.setAction(async ({ verify, skipRegistry }, DRE) => {
|
||||
const POOL_NAME = ConfigNames.Aave;
|
||||
await DRE.run('set-DRE');
|
||||
|
||||
|
@ -18,7 +19,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 });
|
||||
await DRE.run('full:deploy-address-provider', { pool: POOL_NAME, skipRegistry });
|
||||
|
||||
console.log('2. Deploy lending pool');
|
||||
await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME });
|
||||
|
|
|
@ -6,7 +6,8 @@ import { usingTenderly } from '../../helpers/tenderly-utils';
|
|||
|
||||
task('amm:mainnet', 'Deploy development enviroment')
|
||||
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||
.setAction(async ({ verify }, DRE) => {
|
||||
.addFlag('skipRegistry', 'Skip addresses provider registration at Addresses Provider Registry')
|
||||
.setAction(async ({ verify, skipRegistry }, DRE) => {
|
||||
const POOL_NAME = ConfigNames.Amm;
|
||||
await DRE.run('set-DRE');
|
||||
|
||||
|
@ -18,7 +19,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 });
|
||||
await DRE.run('full:deploy-address-provider', { pool: POOL_NAME, skipRegistry });
|
||||
|
||||
console.log('2. Deploy lending pool');
|
||||
await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME });
|
||||
|
|
|
@ -6,7 +6,8 @@ import { usingTenderly } from '../../helpers/tenderly-utils';
|
|||
|
||||
task('matic:mainnet', 'Deploy development enviroment')
|
||||
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||
.setAction(async ({ verify }, DRE) => {
|
||||
.addFlag('skipRegistry', 'Skip addresses provider registration at Addresses Provider Registry')
|
||||
.setAction(async ({ verify, skipRegistry }, DRE) => {
|
||||
const POOL_NAME = ConfigNames.Matic;
|
||||
await DRE.run('set-DRE');
|
||||
|
||||
|
@ -18,7 +19,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 });
|
||||
await DRE.run('full:deploy-address-provider', { pool: POOL_NAME, skipRegistry });
|
||||
|
||||
console.log('2. Deploy lending pool');
|
||||
await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME });
|
||||
|
|
Loading…
Reference in New Issue
Block a user