diff --git a/helpers/configuration.ts b/helpers/configuration.ts index ddc568d76..03c1fd3a1 100644 --- a/helpers/configuration.ts +++ b/helpers/configuration.ts @@ -1,3 +1,4 @@ +import { getMintableERC20, getMockedTokens } from './contracts-getters'; import { AavePools, iMultiPoolsAssets, @@ -14,7 +15,7 @@ import AmmConfig from '../markets/amm'; import { CommonsConfig } from '../markets/aave/commons'; import { DRE, filterMapBy } from './misc-utils'; -import { tEthereumAddress } from './types'; +import { tEthereumAddress, IAaveConfiguration } from './types'; import { getParamPerNetwork } from './contracts-helpers'; import { deployWETHMocked } from './contracts-deployments'; @@ -23,7 +24,7 @@ export enum ConfigNames { Aave = 'Aave', Matic = 'Matic', Amm = 'Amm', - Avalanche = 'Avalanche' + Avalanche = 'Avalanche', } export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => { @@ -34,8 +35,8 @@ export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => { return MaticConfig; case ConfigNames.Amm: return AmmConfig; - case ConfigNames.Avalanche: - return AvalancheConfig; + case ConfigNames.Avalanche: + return AvalancheConfig; case ConfigNames.Commons: return CommonsConfig; default: @@ -65,7 +66,7 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets { return weth.address; }; -export const getWrappedNativeTokenAddress = async (config: IBaseConfiguration) => { +export const getWrappedNativeTokenAddress = async (config: IAaveConfiguration) => { const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name; const wethAddress = getParamPerNetwork(config.WrappedNativeToken, currentNetwork); if (wethAddress) { @@ -126,6 +127,10 @@ export const getWrappedNativeTokenAddress = async (config: IBaseConfiguration) = if (currentNetwork.includes('main')) { throw new Error('WETH not set at mainnet configuration.'); } + const mockTokens = await getMockedTokens(config); + if (mockTokens['WETH']) { + return mockTokens['WETH'].address; + } const weth = await deployWETHMocked(); return weth.address; }; diff --git a/helpers/constants.ts b/helpers/constants.ts index 253435d7d..d564c439f 100644 --- a/helpers/constants.ts +++ b/helpers/constants.ts @@ -86,7 +86,7 @@ export const chainlinkAggregatorProxy = { 'arbitrum-rinkeby': '0x5f0423B1a6935dc5596e7A24d98532b67A0AeFd8', arbitrum: '0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612', rinkeby: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e', - goerli: '0x9F54B624fb17d07816C5552f8AB133c21b0322cD', + goerli: '0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e', }; export const chainlinkEthUsdAggregatorProxy = { @@ -100,5 +100,5 @@ export const chainlinkEthUsdAggregatorProxy = { 'arbitrum-rinkeby': '0x5f0423B1a6935dc5596e7A24d98532b67A0AeFd8', arbitrum: '0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612', rinkeby: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e', - goerli: '0x9F54B624fb17d07816C5552f8AB133c21b0322cD', + goerli: '0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e', }; diff --git a/helpers/contracts-deployments.ts b/helpers/contracts-deployments.ts index 7292a217f..873c66da9 100644 --- a/helpers/contracts-deployments.ts +++ b/helpers/contracts-deployments.ts @@ -1,3 +1,4 @@ +import { WETH9Mocked } from './../types/WETH9Mocked.d'; import { Contract } from 'ethers'; import { DRE, notFalsyOrZeroAddress } from './misc-utils'; import { @@ -503,7 +504,7 @@ export const deployDelegationAwareATokenImpl = async (verify: boolean) => ); export const deployAllMockTokens = async (verify?: boolean) => { - const tokens: { [symbol: string]: MockContract | MintableERC20 } = {}; + const tokens: { [symbol: string]: MockContract | MintableERC20 | WETH9Mocked } = {}; const protoConfigData = getReservesConfigByPool(AavePools.proto); @@ -512,10 +513,15 @@ export const deployAllMockTokens = async (verify?: boolean) => { let configData = (protoConfigData)[tokenSymbol]; - tokens[tokenSymbol] = await deployMintableERC20( - [tokenSymbol, tokenSymbol, configData ? configData.reserveDecimals : decimals], - verify - ); + if (tokenSymbol == 'WETH') { + tokens[tokenSymbol] = await deployWETHMocked(verify); + } else { + tokens[tokenSymbol] = await deployMintableERC20( + [tokenSymbol, tokenSymbol, configData ? configData.reserveDecimals : decimals], + verify + ); + } + await registerContractInJsonDb(tokenSymbol.toUpperCase(), tokens[tokenSymbol]); } return tokens;