From 2c001cc8190adeec4c830f9c9b3e377bb93882d7 Mon Sep 17 00:00:00 2001 From: shivani Date: Mon, 7 Jun 2021 09:58:28 +0530 Subject: [PATCH 1/7] =?UTF-8?q?=F0=9F=90=9B=20pass=20pool=20argument=20to?= =?UTF-8?q?=20task?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/deployments/add-market-to-registry.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/deployments/add-market-to-registry.ts b/tasks/deployments/add-market-to-registry.ts index 0e1d4b68..c21c7280 100644 --- a/tasks/deployments/add-market-to-registry.ts +++ b/tasks/deployments/add-market-to-registry.ts @@ -40,7 +40,7 @@ task('add-market-to-registry', 'Adds address provider to registry') ) { console.log('- Deploying a new Address Providers Registry:'); - await DRE.run('full:deploy-address-provider-registry', { verify }); + await DRE.run('full:deploy-address-provider-registry', { pool, verify }); providerRegistryAddress = (await getLendingPoolAddressesProviderRegistry()).address; providerRegistryOwner = await (await getFirstSigner()).getAddress(); From c4d1c697b4768a9c8b6529f1dd7396ef2c6bf48f Mon Sep 17 00:00:00 2001 From: shivani Date: Mon, 7 Jun 2021 11:20:01 +0530 Subject: [PATCH 2/7] =?UTF-8?q?=F0=9F=90=9B=20check=20verify=20flag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/permissioned/deploy-permission-manager.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tasks/permissioned/deploy-permission-manager.ts b/tasks/permissioned/deploy-permission-manager.ts index d00138cd..eb667673 100644 --- a/tasks/permissioned/deploy-permission-manager.ts +++ b/tasks/permissioned/deploy-permission-manager.ts @@ -27,13 +27,19 @@ task(`deploy-permission-manager`, `Deploys the PermissionManager contract`) await permissionManagerInstance.deployTransaction.wait(); console.log('Permission manager address', permissionManagerInstance.address); - await verifyContract(eContractid.PermissionManager, permissionManagerInstance, []); + if (verify) { + await verifyContract(eContractid.PermissionManager, permissionManagerInstance, []); + } // register the permission manager in the addresses provider const addressesProvider = await getLendingPoolAddressesProvider(); - const permissionManagerHash = ethers.utils.keccak256(ethers.utils.toUtf8Bytes("PERMISSION_MANAGER")); + const permissionManagerHash = ethers.utils.keccak256( + ethers.utils.toUtf8Bytes('PERMISSION_MANAGER') + ); - await waitForTx(await addressesProvider.setAddress(permissionManagerHash, permissionManagerInstance.address)); + await waitForTx( + await addressesProvider.setAddress(permissionManagerHash, permissionManagerInstance.address) + ); // store the permission manager contract in the DB await insertContractAddressInDb( From 5ba3cc8b94c034ed96d669f7676e39a9dcc39a1c Mon Sep 17 00:00:00 2001 From: shivani Date: Mon, 7 Jun 2021 11:26:57 +0530 Subject: [PATCH 3/7] =?UTF-8?q?=E2=9C=A8=20add=20pro=20kovan=20fork=20depl?= =?UTF-8?q?oy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 7c677356..f1a087c4 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "aave:main:full:migration": "npm run compile && npm run hardhat:main -- aave:mainnet --verify", "aave:main:full:initialize": "npm run compile && FORK=main full:initialize-tokens --pool Aave", "amm:main:full:migration": "npm run compile && npm run hardhat:main -- amm:mainnet --verify", + "pro:fork:kovan": "npm run compile && FORK=kovan hardhat pro:mainnet", "pro:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- pro:mainnet --verify", "prettier:check": "npx prettier -c 'tasks/**/*.ts' 'contracts/**/*.sol' 'helpers/**/*.ts' 'test-suites/test-aave/**/*.ts'", "prettier:write": "prettier --write 'tasks/**/*.ts' 'contracts/**/*.sol' 'helpers/**/*.ts' 'test-suites/test-aave/**/*.ts'", From 66916dd5cd1ff87542efc9dd62ae5c3efb18e8d3 Mon Sep 17 00:00:00 2001 From: shivani Date: Mon, 7 Jun 2021 12:00:16 +0530 Subject: [PATCH 4/7] =?UTF-8?q?=F0=9F=90=9B=20check=20pool=20while=20initi?= =?UTF-8?q?alizing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helpers/contracts-getters.ts | 138 +++++++++++++++++++++++------------ tasks/full/6-initialize.ts | 8 +- 2 files changed, 99 insertions(+), 47 deletions(-) diff --git a/helpers/contracts-getters.ts b/helpers/contracts-getters.ts index b6ec5de1..630068b4 100644 --- a/helpers/contracts-getters.ts +++ b/helpers/contracts-getters.ts @@ -42,16 +42,18 @@ export const getFirstSigner = async () => (await getEthersSigners())[0]; export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress) => { return await LendingPoolAddressesProviderFactory.connect( address || - (await getDb().get(`${eContractid.LendingPoolAddressesProvider}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.LendingPoolAddressesProvider}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); }; export const getLendingPoolConfiguratorProxy = async (address?: tEthereumAddress) => { return await LendingPoolConfiguratorFactory.connect( address || - (await getDb().get(`${eContractid.LendingPoolConfigurator}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.LendingPoolConfigurator}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); }; @@ -59,14 +61,18 @@ export const getLendingPoolConfiguratorProxy = async (address?: tEthereumAddress export const getLendingPool = async (address?: tEthereumAddress) => await LendingPoolFactory.connect( address || - (await getDb().get(`${eContractid.LendingPool}.${DRE.network.name}`).value()).address, + ( + await getDb().get(`${eContractid.LendingPool}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getPriceOracle = async (address?: tEthereumAddress) => await PriceOracleFactory.connect( address || - (await getDb().get(`${eContractid.PriceOracle}.${DRE.network.name}`).value()).address, + ( + await getDb().get(`${eContractid.PriceOracle}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); @@ -79,36 +85,45 @@ export const getAToken = async (address?: tEthereumAddress) => export const getStableDebtToken = async (address?: tEthereumAddress) => await StableDebtTokenFactory.connect( address || - (await getDb().get(`${eContractid.StableDebtToken}.${DRE.network.name}`).value()).address, + ( + await getDb().get(`${eContractid.StableDebtToken}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getVariableDebtToken = async (address?: tEthereumAddress) => await VariableDebtTokenFactory.connect( address || - (await getDb().get(`${eContractid.VariableDebtToken}.${DRE.network.name}`).value()).address, + ( + await getDb().get(`${eContractid.VariableDebtToken}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getMintableERC20 = async (address: tEthereumAddress) => await MintableERC20Factory.connect( address || - (await getDb().get(`${eContractid.MintableERC20}.${DRE.network.name}`).value()).address, + ( + await getDb().get(`${eContractid.MintableERC20}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getIErc20Detailed = async (address: tEthereumAddress) => await IERC20DetailedFactory.connect( address || - (await getDb().get(`${eContractid.IERC20Detailed}.${DRE.network.name}`).value()).address, + ( + await getDb().get(`${eContractid.IERC20Detailed}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getAaveProtocolDataProvider = async (address?: tEthereumAddress) => await AaveProtocolDataProviderFactory.connect( address || - (await getDb().get(`${eContractid.AaveProtocolDataProvider}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.AaveProtocolDataProvider}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); @@ -126,15 +141,18 @@ export const getInterestRateStrategy = async (address?: tEthereumAddress) => export const getMockFlashLoanReceiver = async (address?: tEthereumAddress) => await MockFlashLoanReceiverFactory.connect( address || - (await getDb().get(`${eContractid.MockFlashLoanReceiver}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.MockFlashLoanReceiver}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getLendingRateOracle = async (address?: tEthereumAddress) => await LendingRateOracleFactory.connect( address || - (await getDb().get(`${eContractid.LendingRateOracle}.${DRE.network.name}`).value()).address, + ( + await getDb().get(`${eContractid.LendingRateOracle}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); @@ -180,10 +198,9 @@ export const getPairsTokenAggregator = ( const aggregatorAddressIndex = Object.keys(aggregatorsAddresses).findIndex( (value) => value === tokenSymbol ); - const [, aggregatorAddress] = (Object.entries(aggregatorsAddresses) as [ - string, - tEthereumAddress - ][])[aggregatorAddressIndex]; + const [, aggregatorAddress] = ( + Object.entries(aggregatorsAddresses) as [string, tEthereumAddress][] + )[aggregatorAddressIndex]; return [tokenAddress, aggregatorAddress]; //} }) as [string, string][]; @@ -209,14 +226,18 @@ export const getLendingPoolAddressesProviderRegistry = async (address?: tEthereu export const getReserveLogic = async (address?: tEthereumAddress) => await ReserveLogicFactory.connect( address || - (await getDb().get(`${eContractid.ReserveLogic}.${DRE.network.name}`).value()).address, + ( + await getDb().get(`${eContractid.ReserveLogic}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getGenericLogic = async (address?: tEthereumAddress) => await GenericLogicFactory.connect( address || - (await getDb().get(`${eContractid.GenericLogic}.${DRE.network.name}`).value()).address, + ( + await getDb().get(`${eContractid.GenericLogic}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); @@ -234,15 +255,27 @@ export const getStableAndVariableTokensHelper = async (address?: tEthereumAddres export const getATokensAndRatesHelper = async (address?: tEthereumAddress) => await ATokensAndRatesHelperFactory.connect( address || - (await getDb().get(`${eContractid.ATokensAndRatesHelper}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.ATokensAndRatesHelper}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getWETHGateway = async (address?: tEthereumAddress) => await WETHGatewayFactory.connect( address || - (await getDb().get(`${eContractid.WETHGateway}.${DRE.network.name}`).value()).address, + ( + await getDb().get(`${eContractid.WETHGateway}.${DRE.network.name}`).value() + ).address, + await getFirstSigner() + ); + +export const getPermissionedWETHGateway = async (address?: tEthereumAddress) => + await WETHGatewayFactory.connect( + address || + ( + await getDb().get(`${eContractid.PermissionedWETHGateway}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); @@ -261,23 +294,27 @@ export const getMockAToken = async (address?: tEthereumAddress) => export const getMockVariableDebtToken = async (address?: tEthereumAddress) => await MockVariableDebtTokenFactory.connect( address || - (await getDb().get(`${eContractid.MockVariableDebtToken}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.MockVariableDebtToken}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getMockStableDebtToken = async (address?: tEthereumAddress) => await MockStableDebtTokenFactory.connect( address || - (await getDb().get(`${eContractid.MockStableDebtToken}.${DRE.network.name}`).value()).address, + ( + await getDb().get(`${eContractid.MockStableDebtToken}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getSelfdestructTransferMock = async (address?: tEthereumAddress) => await SelfdestructTransferFactory.connect( address || - (await getDb().get(`${eContractid.SelfdestructTransferMock}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.SelfdestructTransferMock}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); @@ -287,15 +324,18 @@ export const getProxy = async (address: tEthereumAddress) => export const getLendingPoolImpl = async (address?: tEthereumAddress) => await LendingPoolFactory.connect( address || - (await getDb().get(`${eContractid.LendingPoolImpl}.${DRE.network.name}`).value()).address, + ( + await getDb().get(`${eContractid.LendingPoolImpl}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getLendingPoolConfiguratorImpl = async (address?: tEthereumAddress) => await LendingPoolConfiguratorFactory.connect( address || - (await getDb().get(`${eContractid.LendingPoolConfiguratorImpl}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.LendingPoolConfiguratorImpl}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); @@ -313,16 +353,18 @@ export const getLendingPoolCollateralManagerImpl = async (address?: tEthereumAdd export const getWalletProvider = async (address?: tEthereumAddress) => await WalletBalanceProviderFactory.connect( address || - (await getDb().get(`${eContractid.WalletBalanceProvider}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.WalletBalanceProvider}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getLendingPoolCollateralManager = async (address?: tEthereumAddress) => await LendingPoolCollateralManagerFactory.connect( address || - (await getDb().get(`${eContractid.LendingPoolCollateralManager}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.LendingPoolCollateralManager}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); @@ -338,38 +380,44 @@ export const getAaveOracle = async (address?: tEthereumAddress) => export const getMockUniswapRouter = async (address?: tEthereumAddress) => await MockUniswapV2Router02Factory.connect( address || - (await getDb().get(`${eContractid.MockUniswapV2Router02}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.MockUniswapV2Router02}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getUniswapLiquiditySwapAdapter = async (address?: tEthereumAddress) => await UniswapLiquiditySwapAdapterFactory.connect( address || - (await getDb().get(`${eContractid.UniswapLiquiditySwapAdapter}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.UniswapLiquiditySwapAdapter}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getUniswapRepayAdapter = async (address?: tEthereumAddress) => await UniswapRepayAdapterFactory.connect( address || - (await getDb().get(`${eContractid.UniswapRepayAdapter}.${DRE.network.name}`).value()).address, + ( + await getDb().get(`${eContractid.UniswapRepayAdapter}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getFlashLiquidationAdapter = async (address?: tEthereumAddress) => await FlashLiquidationAdapterFactory.connect( address || - (await getDb().get(`${eContractid.FlashLiquidationAdapter}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.FlashLiquidationAdapter}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getPermissionManager = async (address?: tEthereumAddress) => await PermissionManagerFactory.connect( address || - (await getDb().get(`${eContractid.PermissionManager}.${DRE.network.name}`).value()).address, + ( + await getDb().get(`${eContractid.PermissionManager}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); - diff --git a/tasks/full/6-initialize.ts b/tasks/full/6-initialize.ts index bfe2925e..fdc6df00 100644 --- a/tasks/full/6-initialize.ts +++ b/tasks/full/6-initialize.ts @@ -12,7 +12,7 @@ import { getWethAddress, getTreasuryAddress, } from '../../helpers/configuration'; -import { getWETHGateway } from '../../helpers/contracts-getters'; +import { getPermissionedWETHGateway, getWETHGateway } from '../../helpers/contracts-getters'; import { eNetwork, ICommonConfiguration } from '../../helpers/types'; import { notFalsyOrZeroAddress, waitForTx } from '../../helpers/misc-utils'; import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers'; @@ -106,7 +106,11 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.') let gateWay = getParamPerNetwork(WethGateway, network); if (!notFalsyOrZeroAddress(gateWay)) { - gateWay = (await getWETHGateway()).address; + if (pool === ConfigNames.AavePro) { + gateWay = (await getPermissionedWETHGateway()).address; + } else { + gateWay = (await getWETHGateway()).address; + } } console.log('GATEWAY', gateWay); await authorizeWETHGateway(gateWay, lendingPoolAddress); From 7c93870ac40b02ca68b42de06053282b458a6c5d Mon Sep 17 00:00:00 2001 From: shivani Date: Mon, 7 Jun 2021 13:23:07 +0530 Subject: [PATCH 5/7] add permissioned wethgateway getter --- helpers/contracts-getters.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/helpers/contracts-getters.ts b/helpers/contracts-getters.ts index 630068b4..e72c6754 100644 --- a/helpers/contracts-getters.ts +++ b/helpers/contracts-getters.ts @@ -29,6 +29,7 @@ import { WalletBalanceProviderFactory, WETH9MockedFactory, WETHGatewayFactory, + PermissionedWETHGatewayFactory, FlashLiquidationAdapterFactory, PermissionManagerFactory, } from '../types'; @@ -271,7 +272,7 @@ export const getWETHGateway = async (address?: tEthereumAddress) => ); export const getPermissionedWETHGateway = async (address?: tEthereumAddress) => - await WETHGatewayFactory.connect( + await PermissionedWETHGatewayFactory.connect( address || ( await getDb().get(`${eContractid.PermissionedWETHGateway}.${DRE.network.name}`).value() From 639e2c3a46ae2202a5b21b2a3223efd176df9086 Mon Sep 17 00:00:00 2001 From: shivani Date: Mon, 7 Jun 2021 15:18:26 +0530 Subject: [PATCH 6/7] =?UTF-8?q?=20=E2=9C=A8=20update=20readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/README.md b/README.md index d59473e7..b4c0e6e4 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,70 @@ docker-compose exec contracts-env bash npm run aave:kovan:full:migration ``` +### Kovan Aave Pro Deployment + +You can deploy aave-pro with default configuration on kovan. + +In `markets/aave-pro/commons.ts` make following changes: + +- Configure `ProviderRegistryOwner` + + Set owner to your deployer address with kovan funds. + + **Notet:** Script uses first address generated, from `MNEMONIC` provided in `.env` file, as the deployer. + + ``` + ProviderRegistryOwner: { + [eEthereumNetwork.kovan]: '0xyourDeployerAddress', + // Other network settings. You can leave them empty or same + }, + ``` + +- Configure to deploy new `ProviderRegistry` + + Set registry address to empty string to deploy new registry. + + ``` + ProviderRegistry: { + [eEthereumNetwork.kovan]: '', + // Other network settings. You can leave them empty or same + }, + ``` + +- Configure to deploy/initialize `PermissionedWethGateWay` + + Set gateway address to empty string to deploy new. + + ``` + WethGateway: { + [eEthereumNetwork.kovan]: '', + // Other network settings. You can leave them empty or same + }, + ``` + +**Note:** To configure aave pro market you can update `markets/aave-pro/` + +#### Deploy Market + +**Using Docker** + +``` +# In one terminal +docker-compose up + +# Open another tab or terminal +docker-compose exec contracts-env bash + +# A new Bash terminal is prompted, connected to the container +npm run pro:kovan:full:migration +``` + +**Without Docker** + +``` +npm run pro:kovan:full:migration +``` + ### Mainnet fork deployment You can deploy Aave Protocol v2 in a forked Mainnet chain using Hardhat built-in fork feature: From b6eacf5a3a116fc7fd8b0f234c11941d3424cfd8 Mon Sep 17 00:00:00 2001 From: shivani Date: Mon, 7 Jun 2021 16:31:21 +0530 Subject: [PATCH 7/7] =?UTF-8?q?=E2=9C=A8=20update=20readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b4c0e6e4..fd702b9d 100644 --- a/README.md +++ b/README.md @@ -144,28 +144,38 @@ You can deploy aave-pro with default configuration on kovan. In `markets/aave-pro/commons.ts` make following changes: -- Configure `ProviderRegistryOwner` +- Configure `ProviderRegistryOwner` and `ReserveFactorTreasuryAddress` Set owner to your deployer address with kovan funds. + Set `ReserveFactorTreasuryAddress` to your team's wallet + **Notet:** Script uses first address generated, from `MNEMONIC` provided in `.env` file, as the deployer. ``` ProviderRegistryOwner: { - [eEthereumNetwork.kovan]: '0xyourDeployerAddress', + [eEthereumNetwork.kovan]: '0xYourDeployerAddress', + // Other network settings. You can leave them empty or same + }, + + ReserveFactorTreasuryAddress: { + [eEthereumNetwork.kovan]: '0xYourDeployerAddress, // Other network settings. You can leave them empty or same }, ``` -- Configure to deploy new `ProviderRegistry` +- Configure to deploy new `ProviderRegistry` and `LendingPoolCollateralManager` - Set registry address to empty string to deploy new registry. + Set registry and collateral manager address to empty string to deploy new registry. ``` ProviderRegistry: { [eEthereumNetwork.kovan]: '', // Other network settings. You can leave them empty or same }, + LendingPoolCollateralManager: { + [eEthereumNetwork.kovan]: '', + } ``` - Configure to deploy/initialize `PermissionedWethGateWay`