diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index bc4f0e709..988949c63 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -20,12 +20,6 @@ jobs: uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - - uses: actions/cache@v2 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - name: Install dependencies run: npm ci - name: Test diff --git a/hardhat.config.ts b/hardhat.config.ts index 131f328e9..c7261f1dc 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -108,6 +108,7 @@ const buidlerConfig: HardhatUserConfig = { xdai: getCommonNetworkConfig(eXDaiNetwork.xdai, 100), avalanche: getCommonNetworkConfig(eAvalancheNetwork.avalanche, 43114), fuji: getCommonNetworkConfig(eAvalancheNetwork.fuji, 43113), + goerli: getCommonNetworkConfig(eEthereumNetwork.goerli, 5), hardhat: { hardfork: 'berlin', blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT, diff --git a/helper-hardhat-config.ts b/helper-hardhat-config.ts index 88633d851..48cfc67d2 100644 --- a/helper-hardhat-config.ts +++ b/helper-hardhat-config.ts @@ -55,6 +55,7 @@ export const NETWORKS_RPC_URL: iParamsPerNetwork = { [eXDaiNetwork.xdai]: 'https://rpc.xdaichain.com/', [eAvalancheNetwork.avalanche]: 'https://api.avax.network/ext/bc/C/rpc', [eAvalancheNetwork.fuji]: 'https://api.avax-test.network/ext/bc/C/rpc', + [eEthereumNetwork.goerli]: `https://eth-goerli.g.alchemy.com/v2/${ALCHEMY_KEY}`, }; export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork = { @@ -70,6 +71,7 @@ export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork = { [eXDaiNetwork.xdai]: 1 * GWEI, [eAvalancheNetwork.avalanche]: 225 * GWEI, [eAvalancheNetwork.fuji]: 85 * GWEI, + [eEthereumNetwork.goerli]: 2 * GWEI, }; export const BLOCK_TO_FORK: iParamsPerNetwork = { @@ -85,4 +87,5 @@ export const BLOCK_TO_FORK: iParamsPerNetwork = { [eXDaiNetwork.xdai]: undefined, [eAvalancheNetwork.avalanche]: undefined, [eAvalancheNetwork.fuji]: undefined, + [eEthereumNetwork.goerli]: undefined, }; diff --git a/helpers/constants.ts b/helpers/constants.ts index 26e2c611f..253435d7d 100644 --- a/helpers/constants.ts +++ b/helpers/constants.ts @@ -1,5 +1,4 @@ import BigNumber from 'bignumber.js'; -import { eEthereumNetwork } from './types'; // ---------------- // MATH @@ -87,6 +86,7 @@ export const chainlinkAggregatorProxy = { 'arbitrum-rinkeby': '0x5f0423B1a6935dc5596e7A24d98532b67A0AeFd8', arbitrum: '0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612', rinkeby: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e', + goerli: '0x9F54B624fb17d07816C5552f8AB133c21b0322cD', }; export const chainlinkEthUsdAggregatorProxy = { @@ -100,4 +100,5 @@ export const chainlinkEthUsdAggregatorProxy = { 'arbitrum-rinkeby': '0x5f0423B1a6935dc5596e7A24d98532b67A0AeFd8', arbitrum: '0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612', rinkeby: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e', + goerli: '0x9F54B624fb17d07816C5552f8AB133c21b0322cD', }; diff --git a/helpers/contracts-getters.ts b/helpers/contracts-getters.ts index cac9fe70a..0395cdd71 100644 --- a/helpers/contracts-getters.ts +++ b/helpers/contracts-getters.ts @@ -210,17 +210,21 @@ export const getPairsTokenAggregator = ( getQuoteCurrencies(oracleQuoteCurrency) ); - const pairs = Object.entries(assetsWithoutQuoteCurrency).map(([tokenSymbol, tokenAddress]) => { - //if (true/*tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH' && tokenSymbol !== 'LpWETH'*/) { - const aggregatorAddressIndex = Object.keys(aggregatorsAddresses).findIndex( - (value) => value === tokenSymbol - ); - const [, aggregatorAddress] = ( - Object.entries(aggregatorsAddresses) as [string, tEthereumAddress][] - )[aggregatorAddressIndex]; - return [tokenAddress, aggregatorAddress]; - //} - }) as [string, string][]; + const pairs = Object.entries(assetsWithoutQuoteCurrency).reduce<[string, string][]>( + (acc, [tokenSymbol, tokenAddress]) => { + const aggregatorAddressIndex = Object.keys(aggregatorsAddresses).findIndex( + (value) => value === tokenSymbol + ); + if (aggregatorAddressIndex >= 0) { + const [, aggregatorAddress] = ( + Object.entries(aggregatorsAddresses) as [string, tEthereumAddress][] + )[aggregatorAddressIndex]; + return [...acc, [tokenAddress, aggregatorAddress]]; + } + return acc; + }, + [] + ); const mappedPairs = pairs.map(([asset]) => asset); const mappedAggregators = pairs.map(([, source]) => source); @@ -424,23 +428,26 @@ export const getFlashLiquidationAdapter = async (address?: tEthereumAddress) => export const getMockParaSwapAugustus = async (address?: tEthereumAddress) => await MockParaSwapAugustusFactory.connect( address || - (await getDb().get(`${eContractid.MockParaSwapAugustus}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.MockParaSwapAugustus}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getMockParaSwapAugustusRegistry = async (address?: tEthereumAddress) => await MockParaSwapAugustusRegistryFactory.connect( address || - (await getDb().get(`${eContractid.MockParaSwapAugustusRegistry}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.MockParaSwapAugustusRegistry}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); export const getParaSwapLiquiditySwapAdapter = async (address?: tEthereumAddress) => await ParaSwapLiquiditySwapAdapterFactory.connect( address || - (await getDb().get(`${eContractid.ParaSwapLiquiditySwapAdapter}.${DRE.network.name}`).value()) - .address, + ( + await getDb().get(`${eContractid.ParaSwapLiquiditySwapAdapter}.${DRE.network.name}`).value() + ).address, await getFirstSigner() ); diff --git a/helpers/contracts-helpers.ts b/helpers/contracts-helpers.ts index 87d39f032..98cf2236a 100644 --- a/helpers/contracts-helpers.ts +++ b/helpers/contracts-helpers.ts @@ -145,7 +145,7 @@ export const linkBytecode = (artifact: BuidlerArtifact | Artifact, libraries: an }; export const getParamPerNetwork = (param: iParamsPerNetwork, network: eNetwork) => { - const { main, ropsten, kovan, coverage, buidlerevm, tenderly } = + const { main, ropsten, kovan, coverage, buidlerevm, tenderly, goerli } = param as iEthereumParamsPerNetwork; const { matic, mumbai } = param as iPolygonParamsPerNetwork; const { xdai } = param as iXDaiParamsPerNetwork; @@ -179,6 +179,8 @@ export const getParamPerNetwork = (param: iParamsPerNetwork, network: eNet return avalanche; case eAvalancheNetwork.fuji: return fuji; + case eEthereumNetwork.goerli: + return goerli; } }; diff --git a/helpers/etherscan-verification.ts b/helpers/etherscan-verification.ts index e8f1972ea..4fd7ef71b 100644 --- a/helpers/etherscan-verification.ts +++ b/helpers/etherscan-verification.ts @@ -10,11 +10,20 @@ const fatalErrors = [ `The constructor for`, ]; -const okErrors = [`Contract source code already verified`]; +const okErrors = [`Contract source code already verified`, 'Already Verified']; const unableVerifyError = 'Fail - Unable to verify'; -export const SUPPORTED_ETHERSCAN_NETWORKS = ['main', 'ropsten', 'kovan', 'matic', 'mumbai']; +export const SUPPORTED_ETHERSCAN_NETWORKS = [ + 'main', + 'ropsten', + 'kovan', + 'matic', + 'mumbai', + 'goerli', + 'avalanche', + 'fuji', +]; function delay(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); diff --git a/helpers/init-helpers.ts b/helpers/init-helpers.ts index 01e26bd81..aacf755d7 100644 --- a/helpers/init-helpers.ts +++ b/helpers/init-helpers.ts @@ -10,6 +10,7 @@ import { chunk, getDb, waitForTx } from './misc-utils'; import { getAToken, getATokensAndRatesHelper, + getLendingPool, getLendingPoolAddressesProvider, getLendingPoolConfiguratorProxy, } from './contracts-getters'; @@ -20,9 +21,9 @@ import { import { BigNumberish } from 'ethers'; import { ConfigNames } from './configuration'; import { deployRateStrategy } from './contracts-deployments'; +import { ZERO_ADDRESS } from './constants'; export const getATokenExtraParams = async (aTokenName: string, tokenAddress: tEthereumAddress) => { - console.log(aTokenName); switch (aTokenName) { default: return '0x10'; @@ -88,6 +89,12 @@ export const initReservesByHelper = async ( console.log(`- Skipping init of ${symbol} due token address is not set at markets config`); continue; } + const pool = await getLendingPool(await addressProvider.getLendingPool()); + const poolReserve = await pool.getReserveData(tokenAddresses[symbol]); + if (poolReserve.aTokenAddress !== ZERO_ADDRESS) { + console.log(`- Skipping init of ${symbol} due is already initialized`); + continue; + } const { strategy, aTokenImpl, reserveDecimals } = params; const { optimalUtilizationRate, diff --git a/helpers/oracles-helpers.ts b/helpers/oracles-helpers.ts index 9fd2ba448..5c28e7e02 100644 --- a/helpers/oracles-helpers.ts +++ b/helpers/oracles-helpers.ts @@ -67,8 +67,8 @@ export const setInitialMarketRatesInRatesOracleByHelper = async ( }; export const setInitialAssetPricesInOracle = async ( - prices: iAssetBase, - assetsAddresses: iAssetBase, + prices: { [key: string]: string }, + assetsAddresses: { [key: string]: string }, priceOracleInstance: PriceOracle ) => { for (const [assetSymbol, price] of Object.entries(prices) as [string, string][]) { @@ -113,17 +113,17 @@ export const deployMockAggregators = async (initialPrices: SymbolMap, ve }; export const deployAllMockAggregators = async ( - initialPrices: iAssetAggregatorBase, + initialPrices: SymbolMap, verify?: boolean ) => { - const aggregators: { [tokenSymbol: string]: MockAggregator } = {}; + const aggregators: { [tokenSymbol: string]: tEthereumAddress } = {}; for (const tokenContractName of Object.keys(initialPrices)) { if (tokenContractName !== 'ETH') { const priceIndex = Object.keys(initialPrices).findIndex( (value) => value === tokenContractName ); const [, price] = (Object.entries(initialPrices) as [string, string][])[priceIndex]; - aggregators[tokenContractName] = await deployMockAggregator(price, verify); + aggregators[tokenContractName] = (await deployMockAggregator(price, verify)).address; } } return aggregators; diff --git a/helpers/types.ts b/helpers/types.ts index 71597f9c3..d4619ddf8 100644 --- a/helpers/types.ts +++ b/helpers/types.ts @@ -13,7 +13,9 @@ export enum eEthereumNetwork { main = 'main', coverage = 'coverage', hardhat = 'hardhat', + tenderly = 'tenderly', + goerli = 'goerli', } export enum ePolygonNetwork { @@ -432,6 +434,7 @@ export interface iEthereumParamsPerNetwork { [eEthereumNetwork.main]: T; [eEthereumNetwork.hardhat]: T; [eEthereumNetwork.tenderly]: T; + [eEthereumNetwork.goerli]: T; } export interface iPolygonParamsPerNetwork { @@ -480,7 +483,7 @@ export interface IProtocolGlobalConfig { } export interface IMocksConfig { - AllAssetsInitialPrices: iAssetBase; + AllAssetsInitialPrices: { [key: string]: string }; } export interface ILendingRateOracleRatesCommon { diff --git a/markets/aave/commons.ts b/markets/aave/commons.ts index d0a34bcdb..5931e3057 100644 --- a/markets/aave/commons.ts +++ b/markets/aave/commons.ts @@ -114,6 +114,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: undefined, [eEthereumNetwork.main]: undefined, [eEthereumNetwork.tenderly]: undefined, + [eEthereumNetwork.goerli]: undefined, }, PoolAdminIndex: 0, EmergencyAdmin: { @@ -124,6 +125,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: undefined, [eEthereumNetwork.main]: undefined, [eEthereumNetwork.tenderly]: undefined, + [eEthereumNetwork.goerli]: undefined, }, EmergencyAdminIndex: 1, ProviderRegistry: { @@ -134,6 +136,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.hardhat]: '', [eEthereumNetwork.buidlerevm]: '', [eEthereumNetwork.tenderly]: '0x52D306e36E3B6B02c153d0266ff0f85d18BCD413', + [eEthereumNetwork.goerli]: '', }, ProviderRegistryOwner: { [eEthereumNetwork.kovan]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F', @@ -143,6 +146,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.hardhat]: '', [eEthereumNetwork.buidlerevm]: '', [eEthereumNetwork.tenderly]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE', + [eEthereumNetwork.goerli]: '', }, LendingRateOracle: { [eEthereumNetwork.coverage]: '', @@ -152,6 +156,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '0x05dcca805a6562c1bdd0423768754acb6993241b', [eEthereumNetwork.main]: '', //'0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D', [eEthereumNetwork.tenderly]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D', + [eEthereumNetwork.goerli]: '', }, LendingPoolCollateralManager: { [eEthereumNetwork.coverage]: '', @@ -161,6 +166,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '', [eEthereumNetwork.main]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C', [eEthereumNetwork.tenderly]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C', + [eEthereumNetwork.goerli]: '', }, LendingPoolConfigurator: { [eEthereumNetwork.coverage]: '', @@ -170,6 +176,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '', [eEthereumNetwork.main]: '', [eEthereumNetwork.tenderly]: '', + [eEthereumNetwork.goerli]: '', }, LendingPool: { [eEthereumNetwork.coverage]: '', @@ -179,6 +186,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '', [eEthereumNetwork.main]: '', [eEthereumNetwork.tenderly]: '', + [eEthereumNetwork.goerli]: '', }, WethGateway: { [eEthereumNetwork.coverage]: '', @@ -188,6 +196,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '', [eEthereumNetwork.main]: '', [eEthereumNetwork.tenderly]: '', + [eEthereumNetwork.goerli]: '', }, TokenDistributor: { [eEthereumNetwork.coverage]: '', @@ -197,6 +206,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '0xeba2ea67942b8250d870b12750b594696d02fc9c', [eEthereumNetwork.main]: '0xe3d9988f676457123c5fd01297605efdd0cba1ae', [eEthereumNetwork.tenderly]: '0xe3d9988f676457123c5fd01297605efdd0cba1ae', + [eEthereumNetwork.goerli]: '', }, AaveOracle: { [eEthereumNetwork.coverage]: '', @@ -206,6 +216,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: ZERO_ADDRESS, [eEthereumNetwork.main]: '', //'0xA50ba011c48153De246E5192C8f9258A2ba79Ca9', [eEthereumNetwork.tenderly]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9', + [eEthereumNetwork.goerli]: '', }, FallbackOracle: { [eEthereumNetwork.coverage]: '', @@ -215,6 +226,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '0xAD1a978cdbb8175b2eaeC47B01404f8AEC5f4F0d', [eEthereumNetwork.main]: ZERO_ADDRESS, [eEthereumNetwork.tenderly]: ZERO_ADDRESS, + [eEthereumNetwork.goerli]: '', }, ChainlinkAggregator: { [eEthereumNetwork.coverage]: {}, @@ -310,6 +322,7 @@ export const CommonsConfig: ICommonConfiguration = { USD: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419', xSUSHI: '0x9b26214bEC078E68a394AaEbfbffF406Ce14893F', }, + [eEthereumNetwork.goerli]: {}, }, ReserveAssets: { [eEthereumNetwork.coverage]: {}, @@ -319,6 +332,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.kovan]: {}, [eEthereumNetwork.ropsten]: {}, [eEthereumNetwork.tenderly]: {}, + [eEthereumNetwork.goerli]: {}, }, ReservesConfig: {}, ATokenDomainSeparator: { @@ -332,6 +346,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '', [eEthereumNetwork.main]: '', [eEthereumNetwork.tenderly]: '', + [eEthereumNetwork.goerli]: '', }, WETH: { [eEthereumNetwork.coverage]: '', // deployed in local evm @@ -341,6 +356,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab', [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', [eEthereumNetwork.tenderly]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + [eEthereumNetwork.goerli]: '', }, WrappedNativeToken: { [eEthereumNetwork.coverage]: '', // deployed in local evm @@ -350,6 +366,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab', [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', [eEthereumNetwork.tenderly]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + [eEthereumNetwork.goerli]: '', }, ReserveFactorTreasuryAddress: { [eEthereumNetwork.coverage]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', @@ -359,6 +376,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', [eEthereumNetwork.main]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', [eEthereumNetwork.tenderly]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', + [eEthereumNetwork.goerli]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', }, IncentivesController: { [eEthereumNetwork.coverage]: ZERO_ADDRESS, @@ -368,5 +386,6 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: ZERO_ADDRESS, [eEthereumNetwork.main]: ZERO_ADDRESS, [eEthereumNetwork.tenderly]: ZERO_ADDRESS, + [eEthereumNetwork.goerli]: ZERO_ADDRESS, }, }; diff --git a/markets/aave/index.ts b/markets/aave/index.ts index 72f251526..5313ef397 100644 --- a/markets/aave/index.ts +++ b/markets/aave/index.ts @@ -58,6 +58,7 @@ export const AaveConfig: IAaveConfiguration = { xSUSHI: strategyXSUSHI, }, ReserveAssets: { + [eEthereumNetwork.goerli]: {}, [eEthereumNetwork.buidlerevm]: {}, [eEthereumNetwork.hardhat]: {}, [eEthereumNetwork.coverage]: {}, diff --git a/markets/amm/commons.ts b/markets/amm/commons.ts index 39fca1d06..43a09b30f 100644 --- a/markets/amm/commons.ts +++ b/markets/amm/commons.ts @@ -120,6 +120,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: undefined, [eEthereumNetwork.main]: undefined, [eEthereumNetwork.tenderly]: undefined, + [eEthereumNetwork.goerli]: undefined, }, PoolAdminIndex: 0, EmergencyAdmin: { @@ -130,6 +131,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: undefined, [eEthereumNetwork.main]: undefined, [eEthereumNetwork.tenderly]: undefined, + [eEthereumNetwork.goerli]: undefined, }, EmergencyAdminIndex: 1, ProviderRegistry: { @@ -140,6 +142,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.hardhat]: '', [eEthereumNetwork.buidlerevm]: '', [eEthereumNetwork.tenderly]: '0x52D306e36E3B6B02c153d0266ff0f85d18BCD413', + [eEthereumNetwork.goerli]: '', }, ProviderRegistryOwner: { [eEthereumNetwork.kovan]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F', @@ -149,6 +152,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.hardhat]: '', [eEthereumNetwork.buidlerevm]: '', [eEthereumNetwork.tenderly]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE', + [eEthereumNetwork.goerli]: '', }, LendingRateOracle: { [eEthereumNetwork.coverage]: '', @@ -158,6 +162,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '0x05dcca805a6562c1bdd0423768754acb6993241b', [eEthereumNetwork.main]: '', //'0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D', // Need to re-deploy because of onlyOwner [eEthereumNetwork.tenderly]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D', + [eEthereumNetwork.goerli]: '', }, LendingPoolCollateralManager: { [eEthereumNetwork.coverage]: '', @@ -167,6 +172,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '', [eEthereumNetwork.main]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C', [eEthereumNetwork.tenderly]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C', + [eEthereumNetwork.goerli]: '', }, LendingPoolConfigurator: { [eEthereumNetwork.coverage]: '', @@ -176,6 +182,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '', [eEthereumNetwork.main]: '', [eEthereumNetwork.tenderly]: '', + [eEthereumNetwork.goerli]: '', }, LendingPool: { [eEthereumNetwork.coverage]: '', @@ -185,6 +192,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '', [eEthereumNetwork.main]: '', [eEthereumNetwork.tenderly]: '', + [eEthereumNetwork.goerli]: '', }, WethGateway: { [eEthereumNetwork.coverage]: '', @@ -194,6 +202,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '', [eEthereumNetwork.main]: '', [eEthereumNetwork.tenderly]: '', + [eEthereumNetwork.goerli]: '', }, TokenDistributor: { [eEthereumNetwork.coverage]: '', @@ -203,6 +212,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '0xeba2ea67942b8250d870b12750b594696d02fc9c', [eEthereumNetwork.main]: '0xe3d9988f676457123c5fd01297605efdd0cba1ae', [eEthereumNetwork.tenderly]: '0xe3d9988f676457123c5fd01297605efdd0cba1ae', + [eEthereumNetwork.goerli]: '', }, AaveOracle: { [eEthereumNetwork.coverage]: '', @@ -212,6 +222,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: ZERO_ADDRESS, [eEthereumNetwork.main]: '', //'0xA50ba011c48153De246E5192C8f9258A2ba79Ca9', // Need to re-deploy because of onlyOwner [eEthereumNetwork.tenderly]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9', + [eEthereumNetwork.goerli]: '', }, FallbackOracle: { [eEthereumNetwork.coverage]: '', @@ -221,8 +232,10 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '0xAD1a978cdbb8175b2eaeC47B01404f8AEC5f4F0d', [eEthereumNetwork.main]: ZERO_ADDRESS, [eEthereumNetwork.tenderly]: ZERO_ADDRESS, + [eEthereumNetwork.goerli]: '', }, ChainlinkAggregator: { + [eEthereumNetwork.goerli]: {}, [eEthereumNetwork.coverage]: {}, [eEthereumNetwork.hardhat]: {}, [eEthereumNetwork.buidlerevm]: {}, @@ -305,6 +318,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.kovan]: {}, [eEthereumNetwork.ropsten]: {}, [eEthereumNetwork.tenderly]: {}, + [eEthereumNetwork.goerli]: {}, }, ReservesConfig: {}, ATokenDomainSeparator: { @@ -318,6 +332,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '', [eEthereumNetwork.main]: '', [eEthereumNetwork.tenderly]: '', + [eEthereumNetwork.goerli]: '', }, WETH: { [eEthereumNetwork.coverage]: '', // deployed in local evm @@ -327,6 +342,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab', [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', [eEthereumNetwork.tenderly]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + [eEthereumNetwork.goerli]: '', }, WrappedNativeToken: { [eEthereumNetwork.coverage]: '', // deployed in local evm @@ -336,6 +352,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab', [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', [eEthereumNetwork.tenderly]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + [eEthereumNetwork.goerli]: '', }, ReserveFactorTreasuryAddress: { [eEthereumNetwork.coverage]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', @@ -345,6 +362,7 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', [eEthereumNetwork.main]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', [eEthereumNetwork.tenderly]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', + [eEthereumNetwork.goerli]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c', }, IncentivesController: { [eEthereumNetwork.coverage]: ZERO_ADDRESS, @@ -354,5 +372,6 @@ export const CommonsConfig: ICommonConfiguration = { [eEthereumNetwork.ropsten]: ZERO_ADDRESS, [eEthereumNetwork.main]: ZERO_ADDRESS, [eEthereumNetwork.tenderly]: ZERO_ADDRESS, + [eEthereumNetwork.goerli]: ZERO_ADDRESS, }, }; diff --git a/markets/amm/index.ts b/markets/amm/index.ts index 37bc46b6e..f7dd1af71 100644 --- a/markets/amm/index.ts +++ b/markets/amm/index.ts @@ -57,6 +57,7 @@ export const AmmConfig: IAmmConfiguration = { BptBALWETH: strategyBALWETH, }, ReserveAssets: { + [eEthereumNetwork.goerli]: {}, [eEthereumNetwork.buidlerevm]: {}, [eEthereumNetwork.hardhat]: {}, [eEthereumNetwork.coverage]: {}, diff --git a/package.json b/package.json index 1fb3ed606..5489c7f0e 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "run-env": "npm i && tail -f /dev/null", "hardhat": "hardhat", "hardhat:kovan": "hardhat --network kovan", + "hardhat:goerli": "hardhat --network goerli", "hardhat:tenderly-main": "hardhat --network tenderlyMain", "hardhat:ropsten": "hardhat --network ropsten", "hardhat:main": "hardhat --network main", @@ -36,6 +37,7 @@ "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", + "aave:goerli:full:migration:add-registry": "npm run compile && npm run hardhat:goerli -- aave:testnet", "matic:mumbai:full:migration:add-registry": "npm run compile && npm run hardhat:mumbai sidechain:mainnet -- --pool Matic", "matic:matic:full:migration:add-registry": "npm run compile && npm run hardhat:matic sidechain:mainnet -- --pool Matic", "amm:kovan:full:migration:add-registry": "npm run compile && npm run hardhat:kovan -- amm:mainnet", diff --git a/tasks/dev/3_lending_pool.ts b/tasks/dev/3_lending_pool.ts index 5f4336c6d..bea136776 100644 --- a/tasks/dev/3_lending_pool.ts +++ b/tasks/dev/3_lending_pool.ts @@ -28,10 +28,8 @@ task('dev:deploy-lending-pool', 'Deploy lending pool for dev enviroment') // Set lending pool impl to Address Provider await waitForTx(await addressesProvider.setLendingPoolImpl(lendingPoolImpl.address)); - const address = await addressesProvider.getLendingPool(); const lendingPoolProxy = await getLendingPool(address); - await insertContractAddressInDb(eContractid.LendingPool, lendingPoolProxy.address); const lendingPoolConfiguratorImpl = await deployLendingPoolConfigurator(verify); @@ -40,7 +38,6 @@ task('dev:deploy-lending-pool', 'Deploy lending pool for dev enviroment') await waitForTx( await addressesProvider.setLendingPoolConfiguratorImpl(lendingPoolConfiguratorImpl.address) ); - const lendingPoolConfiguratorProxy = await getLendingPoolConfiguratorProxy( await addressesProvider.getLendingPoolConfigurator() ); diff --git a/tasks/dev/4_oracles.ts b/tasks/dev/4_oracles.ts index 3fa8fe964..b926e2bcb 100644 --- a/tasks/dev/4_oracles.ts +++ b/tasks/dev/4_oracles.ts @@ -1,9 +1,5 @@ import { task } from 'hardhat/config'; -import { - deployPriceOracle, - deployAaveOracle, - deployLendingRateOracle, -} from '../../helpers/contracts-deployments'; +import { deployAaveOracle, deployLendingRateOracle } from '../../helpers/contracts-deployments'; import { setInitialAssetPricesInOracle, deployAllMockAggregators, @@ -17,6 +13,7 @@ import { getAllMockedTokens, getLendingPoolAddressesProvider, getPairsTokenAggregator, + getPriceOracle, } from '../../helpers/contracts-getters'; task('dev:deploy-oracles', 'Deploy oracles for dev environment') @@ -33,34 +30,36 @@ task('dev:deploy-oracles', 'Deploy oracles for dev environment') OracleQuoteUnit, } = poolConfig as ICommonConfiguration; - const defaultTokenList = { + const defaultTokenList: { [key: string]: string } = { ...Object.fromEntries(Object.keys(TokenContractId).map((symbol) => [symbol, ''])), USD: UsdAddress, - } as iAssetBase; + }; const mockTokens = await getAllMockedTokens(); - const mockTokensAddress = Object.keys(mockTokens).reduce>((prev, curr) => { - prev[curr as keyof iAssetBase] = mockTokens[curr].address; - return prev; - }, defaultTokenList); + const mockTokensAddress = Object.keys(mockTokens).reduce<{ [key: string]: string }>( + (prev, curr) => { + prev[curr] = mockTokens[curr].address; + return prev; + }, + defaultTokenList + ); const addressesProvider = await getLendingPoolAddressesProvider(); const admin = await addressesProvider.getPoolAdmin(); - const fallbackOracle = await deployPriceOracle(verify); + const fallbackOracle = await getPriceOracle('0x0F9d5ED72f6691E47abe2f79B890C3C33e924092'); await waitForTx(await fallbackOracle.setEthUsdPrice(MockUsdPriceInWei)); await setInitialAssetPricesInOracle(AllAssetsInitialPrices, mockTokensAddress, fallbackOracle); const mockAggregators = await deployAllMockAggregators(AllAssetsInitialPrices, verify); const allTokenAddresses = getAllTokenAddresses(mockTokens); - const allAggregatorsAddresses = getAllAggregatorsAddresses(mockAggregators); const [tokens, aggregators] = getPairsTokenAggregator( allTokenAddresses, - allAggregatorsAddresses, + mockAggregators, OracleQuoteCurrency ); - await deployAaveOracle( + const aaveOracle = await deployAaveOracle( [ tokens, aggregators, @@ -85,4 +84,7 @@ task('dev:deploy-oracles', 'Deploy oracles for dev environment') lendingRateOracle, admin ); + // Register the proxy price provider on the addressesProvider + await waitForTx(await addressesProvider.setPriceOracle(aaveOracle.address)); + await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle.address)); }); diff --git a/tasks/dev/5_initialize.ts b/tasks/dev/5_initialize.ts index c791656f4..505b9e8a9 100644 --- a/tasks/dev/5_initialize.ts +++ b/tasks/dev/5_initialize.ts @@ -23,6 +23,7 @@ import { ZERO_ADDRESS } from '../../helpers/constants'; import { getAllMockedTokens, getLendingPoolAddressesProvider, + getLendingPoolConfiguratorProxy, getWETHGateway, } from '../../helpers/contracts-getters'; import { insertContractAddressInDb } from '../../helpers/contracts-helpers'; @@ -52,6 +53,7 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.') ); const testHelpers = await deployAaveProtocolDataProvider(addressesProvider.address, verify); + await insertContractAddressInDb(eContractid.AaveProtocolDataProvider, testHelpers.address); const admin = await addressesProvider.getPoolAdmin(); @@ -88,8 +90,6 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.') await deployWalletBalancerProvider(verify); - await insertContractAddressInDb(eContractid.AaveProtocolDataProvider, testHelpers.address); - const lendingPoolAddress = await addressesProvider.getLendingPool(); let gateway = getParamPerNetwork(WethGateway, network); @@ -97,4 +97,7 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.') gateway = (await getWETHGateway()).address; } await authorizeWETHGateway(gateway, lendingPoolAddress); + + const poolConfigurator = await getLendingPoolConfiguratorProxy(); + await waitForTx(await poolConfigurator.setPoolPause(false)); }); diff --git a/tasks/migrations/aave.mainnet.ts b/tasks/migrations/aave.mainnet.ts index 875b03086..6b359f583 100644 --- a/tasks/migrations/aave.mainnet.ts +++ b/tasks/migrations/aave.mainnet.ts @@ -1,8 +1,9 @@ import { task } from 'hardhat/config'; import { checkVerification } from '../../helpers/etherscan-verification'; -import { ConfigNames } from '../../helpers/configuration'; +import { ConfigNames, getEmergencyAdmin, loadPoolConfig } from '../../helpers/configuration'; import { printContracts } from '../../helpers/misc-utils'; import { usingTenderly } from '../../helpers/tenderly-utils'; +import { getLendingPoolConfiguratorProxy } from '../../helpers/contracts-getters'; task('aave:mainnet', 'Deploy development enviroment') .addFlag('verify', 'Verify contracts at Etherscan') @@ -18,6 +19,9 @@ task('aave:mainnet', 'Deploy development enviroment') console.log('Migration started\n'); + console.log('0. Deploy address provider registry'); + await DRE.run('full:deploy-address-provider-registry', { pool: POOL_NAME }); + console.log('1. Deploy address provider'); await DRE.run('full:deploy-address-provider', { pool: POOL_NAME, skipRegistry }); @@ -40,12 +44,18 @@ task('aave:mainnet', 'Deploy development enviroment') await DRE.run('deploy-UiPoolDataProviderV2V3', { verify }); await DRE.run('deploy-UiIncentiveDataProviderV2V3', { verify }); + const poolConfig = loadPoolConfig(POOL_NAME); + const emergencyAdmin = await DRE.ethers.getSigner(await getEmergencyAdmin(poolConfig)); + const poolConfigurator = await getLendingPoolConfiguratorProxy(); + await poolConfigurator.connect(emergencyAdmin).setPoolPause(false); + console.log('Finished deployment, unpaused protocol'); + if (verify) { printContracts(); - console.log('7. Veryfing contracts'); + console.log('8. Veryfing contracts'); await DRE.run('verify:general', { all: true, pool: POOL_NAME }); - console.log('8. Veryfing aTokens and debtTokens'); + console.log('9. Veryfing aTokens and debtTokens'); await DRE.run('verify:tokens', { pool: POOL_NAME }); } diff --git a/tasks/misc/balance-check.ts b/tasks/misc/balance-check.ts new file mode 100644 index 000000000..32ed30211 --- /dev/null +++ b/tasks/misc/balance-check.ts @@ -0,0 +1,30 @@ +import { formatEther, parseEther } from 'ethers/lib/utils'; +import { task } from 'hardhat/config'; +import { DRE } from '../../helpers/misc-utils'; + +task('balance-check', 'Checks deployer balance').setAction(async ({}, localBRE) => { + await localBRE.run('set-DRE'); + + const signers = await DRE.ethers.getSigners(); + const deployer = signers[0]; + const proxyAdmin = signers[1]; + + const proxyAdminBalance = await proxyAdmin.getBalance(); + + if (proxyAdminBalance.lt(parseEther('0.10'))) { + await ( + await deployer.sendTransaction({ + to: await proxyAdmin.getAddress(), + value: parseEther('0.15'), + }) + ).wait(); + console.log('- Sent 0.15 ETH to proxy admin'); + } + + console.log('\nAccounts'); + console.log('========'); + console.table({ + deployer: formatEther(await deployer.getBalance()), + proxyAdmin: formatEther(await proxyAdmin.getBalance()), + }); +}); diff --git a/test-suites/test-aave/__setup.spec.ts b/test-suites/test-aave/__setup.spec.ts index 7b3586674..38d2a88f8 100644 --- a/test-suites/test-aave/__setup.spec.ts +++ b/test-suites/test-aave/__setup.spec.ts @@ -131,6 +131,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { await waitForTx( await addressesProvider.setLendingPoolConfiguratorImpl(lendingPoolConfiguratorImpl.address) ); + const lendingPoolConfiguratorProxy = await getLendingPoolConfiguratorProxy( await addressesProvider.getLendingPoolConfigurator() ); @@ -213,7 +214,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { const allAggregatorsAddresses = Object.entries(mockAggregators).reduce( (accum: { [tokenSymbol: string]: tEthereumAddress }, [tokenSymbol, aggregator]) => ({ ...accum, - [tokenSymbol]: aggregator.address, + [tokenSymbol]: aggregator, }), {} ); diff --git a/test-suites/test-amm/__setup.spec.ts b/test-suites/test-amm/__setup.spec.ts index 448ea7fd3..b49ecfd95 100644 --- a/test-suites/test-amm/__setup.spec.ts +++ b/test-suites/test-amm/__setup.spec.ts @@ -215,7 +215,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { const allAggregatorsAddresses = Object.entries(mockAggregators).reduce( (accum: { [tokenSymbol: string]: tEthereumAddress }, [tokenSymbol, aggregator]) => ({ ...accum, - [tokenSymbol]: aggregator.address, + [tokenSymbol]: aggregator, }), {} );