Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use WETH9 mocked instance in dev deployment #310

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions helpers/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getMintableERC20, getMockedTokens } from './contracts-getters';
import {
AavePools,
iMultiPoolsAssets,
Expand All @@ -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';

Expand All @@ -23,7 +24,7 @@ export enum ConfigNames {
Aave = 'Aave',
Matic = 'Matic',
Amm = 'Amm',
Avalanche = 'Avalanche'
Avalanche = 'Avalanche',
}

export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
Expand All @@ -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:
Expand Down Expand Up @@ -65,7 +66,7 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
},
[AavePools.avalanche]: {
...AvalancheConfig.ReservesConfig,
}
},
},
pool
);
Expand Down Expand Up @@ -117,7 +118,7 @@ export const getWethAddress = async (config: IBaseConfiguration) => {
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, <eNetwork>currentNetwork);
if (wethAddress) {
Expand All @@ -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;
};
Expand Down
4 changes: 2 additions & 2 deletions helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const chainlinkAggregatorProxy = {
'arbitrum-rinkeby': '0x5f0423B1a6935dc5596e7A24d98532b67A0AeFd8',
arbitrum: '0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612',
rinkeby: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e',
goerli: '0x9F54B624fb17d07816C5552f8AB133c21b0322cD',
goerli: '0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e',
};

export const chainlinkEthUsdAggregatorProxy = {
Expand All @@ -100,5 +100,5 @@ export const chainlinkEthUsdAggregatorProxy = {
'arbitrum-rinkeby': '0x5f0423B1a6935dc5596e7A24d98532b67A0AeFd8',
arbitrum: '0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612',
rinkeby: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e',
goerli: '0x9F54B624fb17d07816C5552f8AB133c21b0322cD',
goerli: '0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e',
};
16 changes: 11 additions & 5 deletions helpers/contracts-deployments.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { WETH9Mocked } from './../types/WETH9Mocked.d';
import { Contract } from 'ethers';
import { DRE, notFalsyOrZeroAddress } from './misc-utils';
import {
Expand Down Expand Up @@ -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);

Expand All @@ -512,10 +513,15 @@ export const deployAllMockTokens = async (verify?: boolean) => {

let configData = (<any>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;
Expand Down