From ae8f7aa21f4962c1d6c28101b31010a896b51122 Mon Sep 17 00:00:00 2001 From: David Racero Date: Wed, 31 Mar 2021 14:13:44 +0200 Subject: [PATCH] Fixed config. Fixed WETHGateway initialiation with WrappedNativeToken. Added AaveProtocolDataProvider init at addresses provider registry. --- helpers/configuration.ts | 15 ++++++++++++++- helpers/types.ts | 1 + markets/aave/commons.ts | 9 +++++++++ markets/amm/commons.ts | 9 +++++++++ markets/matic/commons.ts | 22 +++++++++++++--------- markets/xdai/commons.ts | 3 +++ package.json | 4 ++-- tasks/full/5-deploy-wethGateWay.ts | 14 ++++++-------- tasks/full/6-initialize.ts | 12 ++++++++++++ 9 files changed, 69 insertions(+), 20 deletions(-) diff --git a/helpers/configuration.ts b/helpers/configuration.ts index 618eec82..f3423eb3 100644 --- a/helpers/configuration.ts +++ b/helpers/configuration.ts @@ -30,7 +30,7 @@ export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => { case ConfigNames.Matic: return MaticConfig; case ConfigNames.Amm: - return AmmConfig; + return AmmConfig; case ConfigNames.Commons: return CommonsConfig; default: @@ -113,6 +113,19 @@ export const getWethAddress = async (config: ICommonConfiguration) => { return weth.address; }; +export const getWrappedNativeTokenddress = async (config: ICommonConfiguration) => { + const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; + const wethAddress = getParamPerNetwork(config.WrappedNativeToken, currentNetwork); + if (wethAddress) { + return wethAddress; + } + if (currentNetwork.includes('main')) { + throw new Error('WETH not set at mainnet configuration.'); + } + const weth = await deployWETHMocked(); + return weth.address; +}; + export const getLendingRateOracles = (poolConfig: ICommonConfiguration) => { const { ProtocolGlobalParams: { UsdAddress }, diff --git a/helpers/types.ts b/helpers/types.ts index 2608016e..267b5abb 100644 --- a/helpers/types.ts +++ b/helpers/types.ts @@ -490,6 +490,7 @@ export interface ICommonConfiguration { ReservesConfig: iMultiPoolsAssets; ATokenDomainSeparator: iParamsPerNetwork; WETH: iParamsPerNetwork; + WrappedNativeToken: iParamsPerNetwork; WethGateway: iParamsPerNetwork; ReserveFactorTreasuryAddress: iParamsPerNetwork; IncentivesController: iParamsPerNetwork; diff --git a/markets/aave/commons.ts b/markets/aave/commons.ts index 8953a326..7921d992 100644 --- a/markets/aave/commons.ts +++ b/markets/aave/commons.ts @@ -337,6 +337,15 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', [eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', }, + WrappedNativeToken: { + [eEthereumNetwork.coverage]: '', // deployed in local evm + [eEthereumNetwork.hardhat]: '', // deployed in local evm + [eEthereumNetwork.buidlerevm]: '', // deployed in local evm + [eEthereumNetwork.kovan]: '0xd0a1e359811322d97991e03f863a0c30c2cf029c', + [eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab', + [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + [eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + }, ReserveFactorTreasuryAddress: { [eEthereumNetwork.coverage]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', [eEthereumNetwork.hardhat]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', diff --git a/markets/amm/commons.ts b/markets/amm/commons.ts index 3e5864f9..743ded7f 100644 --- a/markets/amm/commons.ts +++ b/markets/amm/commons.ts @@ -326,6 +326,15 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', [eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', }, + WrappedNativeToken: { + [eEthereumNetwork.coverage]: '', // deployed in local evm + [eEthereumNetwork.hardhat]: '', // deployed in local evm + [eEthereumNetwork.buidlerevm]: '', // deployed in local evm + [eEthereumNetwork.kovan]: '0xd0a1e359811322d97991e03f863a0c30c2cf029c', + [eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab', + [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + [eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + }, ReserveFactorTreasuryAddress: { [eEthereumNetwork.coverage]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', [eEthereumNetwork.hardhat]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', diff --git a/markets/matic/commons.ts b/markets/matic/commons.ts index 6203daac..8a0274a0 100644 --- a/markets/matic/commons.ts +++ b/markets/matic/commons.ts @@ -55,7 +55,7 @@ export const CommonsConfig: ICommonConfiguration = { borrowRate: oneRay.multipliedBy(0.03).toFixed(), }, WMATIC: { - borrowRate: oneRay.multipliedBy(0.05).toFixed(), // TEMP + borrowRate: oneRay.multipliedBy(0.05).toFixed(), }, AAVE: { borrowRate: oneRay.multipliedBy(0.03).toFixed(), @@ -85,16 +85,16 @@ export const CommonsConfig: ICommonConfiguration = { [ePolygonNetwork.matic]: '', }, ProviderRegistry: { - [ePolygonNetwork.mumbai]: '0x27453A916e91Fb922d309D92e637C0b6625846dF', // TEMP - [ePolygonNetwork.matic]: '', + [ePolygonNetwork.mumbai]: ZERO_ADDRESS, + [ePolygonNetwork.matic]: '0x3ac4e9aa29940770aeC38fe853a4bbabb2dA9C19', }, ProviderRegistryOwner: { - [ePolygonNetwork.mumbai]: '0xa6842C2C7fece4Cdc6a4aaaD331eb1c7910e419A', // TEMP - [ePolygonNetwork.matic]: '0x88505CB63c1679145053c758ebb7b37ac241Bd2C', + [ePolygonNetwork.mumbai]: '', + [ePolygonNetwork.matic]: '0xD7D86236d6c463521920fCC50A9CB56f8C8Bf008', }, LendingRateOracle: { [ePolygonNetwork.mumbai]: '', - [ePolygonNetwork.matic]: '', + [ePolygonNetwork.matic]: '0x17F73aEaD876CC4059089ff815EDA37052960dFB', }, LendingPoolCollateralManager: { [ePolygonNetwork.mumbai]: '', @@ -110,7 +110,7 @@ export const CommonsConfig: ICommonConfiguration = { }, AaveOracle: { [ePolygonNetwork.mumbai]: '', - [ePolygonNetwork.matic]: '', + [ePolygonNetwork.matic]: '0x0229F777B0fAb107F9591a41d5F02E4e98dB6f2d', }, FallbackOracle: { [ePolygonNetwork.mumbai]: ZERO_ADDRESS, @@ -144,11 +144,15 @@ export const CommonsConfig: ICommonConfiguration = { [ePolygonNetwork.matic]: '', }, WETH: { - [ePolygonNetwork.mumbai]: '0x53CDb16B8C031B779e996406546614E5F05BC4Bf', + [ePolygonNetwork.mumbai]: ZERO_ADDRESS, [ePolygonNetwork.matic]: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', }, + WrappedNativeToken: { + [ePolygonNetwork.mumbai]: ZERO_ADDRESS, + [ePolygonNetwork.matic]: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', + }, ReserveFactorTreasuryAddress: { - [ePolygonNetwork.mumbai]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', // TEMP + [ePolygonNetwork.mumbai]: ZERO_ADDRESS, [ePolygonNetwork.matic]: '0x7734280A4337F37Fbf4651073Db7c28C80B339e9', }, IncentivesController: { diff --git a/markets/xdai/commons.ts b/markets/xdai/commons.ts index f8377f09..ee9f1f9f 100644 --- a/markets/xdai/commons.ts +++ b/markets/xdai/commons.ts @@ -120,6 +120,9 @@ export const CommonsConfig: ICommonConfiguration = { WETH: { [eXDaiNetwork.xdai]: '', // DAI: xDAI is the base token, DAI is also there, We need WXDAI }, + WrappedNativeToken: { + [eXDaiNetwork.xdai]: '', // DAI: xDAI is the base token, DAI is also there, We need WXDAI + }, ReserveFactorTreasuryAddress: { [eXDaiNetwork.xdai]: '', // TEMP }, diff --git a/package.json b/package.json index 6777103c..6011f6f5 100644 --- a/package.json +++ b/package.json @@ -42,8 +42,8 @@ "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 --verify", - "matic:mumbai:full:migration": "npm run compile && npm run hardhat:mumbai sidechain:mainnet --pool Matic", - "matic:matic:full:migration": "npm run compile && npm run hardhat:matic sidechain:mainnet --pool Matic", + "matic:mumbai:full:migration": "npm run compile && npm run hardhat:mumbai sidechain:mainnet -- --pool Matic", + "matic:matic:full:migration": "npm run compile && npm run hardhat:matic sidechain:mainnet -- --pool Matic", "amm:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- amm:mainnet --verify", "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", diff --git a/tasks/full/5-deploy-wethGateWay.ts b/tasks/full/5-deploy-wethGateWay.ts index 2d767b59..bac606ac 100644 --- a/tasks/full/5-deploy-wethGateWay.ts +++ b/tasks/full/5-deploy-wethGateWay.ts @@ -1,10 +1,10 @@ import { task } from 'hardhat/config'; -import { AaveConfig } from '../../markets/aave/index'; -import { getParamPerNetwork } from '../../helpers/contracts-helpers'; -import { loadPoolConfig, ConfigNames, getWethAddress } from '../../helpers/configuration'; +import { + loadPoolConfig, + ConfigNames, + getWrappedNativeTokenddress, +} from '../../helpers/configuration'; import { deployWETHGateway } from '../../helpers/contracts-deployments'; -import { DRE } from '../../helpers/misc-utils'; -import { eNetwork } from '../../helpers/types'; const CONTRACT_NAME = 'WETHGateway'; @@ -13,10 +13,8 @@ task(`full-deploy-weth-gateway`, `Deploys the ${CONTRACT_NAME} contract`) .addFlag('verify', `Verify ${CONTRACT_NAME} contract via Etherscan API.`) .setAction(async ({ verify, pool }, localBRE) => { await localBRE.run('set-DRE'); - const network = localBRE.network.name; const poolConfig = loadPoolConfig(pool); - const Weth = await getWethAddress(poolConfig); - const { WethGateway } = poolConfig; + const Weth = await getWrappedNativeTokenddress(poolConfig); if (!localBRE.network.config.chainId) { throw new Error('INVALID_CHAIN_ID'); diff --git a/tasks/full/6-initialize.ts b/tasks/full/6-initialize.ts index f365f56f..bfe2925e 100644 --- a/tasks/full/6-initialize.ts +++ b/tasks/full/6-initialize.ts @@ -88,6 +88,18 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.') await addressesProvider.setLendingPoolCollateralManager(collateralManagerAddress) ); + console.log( + '\tSetting AaveProtocolDataProvider at AddressesProvider at id: 0x01', + collateralManagerAddress + ); + const aaveProtocolDataProvider = await getAaveProtocolDataProvider(); + await waitForTx( + await addressesProvider.setAddress( + '0x0100000000000000000000000000000000000000000000000000000000000000', + aaveProtocolDataProvider.address + ) + ); + await deployWalletBalancerProvider(verify); const lendingPoolAddress = await addressesProvider.getLendingPool();