-
Notifications
You must be signed in to change notification settings - Fork 3
/
helper-hardhat-config.ts
146 lines (137 loc) · 5.77 KB
/
helper-hardhat-config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import { HardhatNetworkForkingUserConfig } from "hardhat/types";
import { resolve } from "path";
import { config as dotenvConfig } from "dotenv";
import {
eEthereumNetwork,
ePolygonNetwork,
eXDaiNetwork,
eAvalancheNetwork,
eArbitrumNetwork,
eFantomNetwork,
eBinanceSmartChainNetwork,
eOptimisticEthereumNetwork,
iParamsPerNetwork,
} from "./helpers/types";
dotenvConfig({ path: resolve(__dirname, "./.env") });
const KOVAN_RPC_URL = process.env.KOVAN_RPC_URL || "";
const ROPSTEN_RPC_URL = process.env.ROPSTEN_RPC_URL || "";
const MAIN_RPC_URL = process.env.MAIN_RPC_URL || "";
const RINKEBY_RPC_URL = process.env.RINKEBY_RPC_URL || "";
const GOERLI_RPC_URL = process.env.GOERLI_RPC_URL || "";
const MUMBAI_RPC_URL = process.env.MUMBAI_RPC_URL || "";
const MATIC_RPC_URL = process.env.MATIC_RPC_URL || "";
const XDAI_RPC_URL = process.env.XDAI_RPC_URL || "";
const AVALANCHE_RPC_URL = process.env.AVALANCHE_RPC_URL || "";
const FUJI_RPC_URL = process.env.FUJI_RPC_URL || "";
const ARBITRUM1_RPC_URL = process.env.ARBITRUM1_RPC_URL || "";
const RINKEBY_ARBITRUM1_RPC_URL = process.env.RINKEBY_ARBITRUM1_RPC_URL || "";
const FANTOM_RPC_URL = process.env.FANTOM_RPC_URL || "";
const FANTOM_TEST_RPC_URL = process.env.FANTOM_TEST_RPC_URL || "";
const BSC_RPC_URL = process.env.BSC_RPC_URL || "";
const BSC_TEST_RPC_URL = process.env.BSC_TEST_RPC_URL || "";
const OETHEREUM_RPC_URL = process.env.OETHEREUM_RPC_URL || "";
const KOVAN_OETHEREUM_RPC_URL = process.env.KOVAN_OETHEREUM_RPC_URL || "";
const GOERLI_OETHEREUM_RPC_URL = process.env.GOERLI_OETHEREUM_RPC_URL || "";
const FORK = process.env.FORK || "";
const FORK_BLOCK_NUMBER = process.env.FORK_BLOCK_NUMBER ? parseInt(process.env.FORK_BLOCK_NUMBER) : 0;
const GWEI = 1000 * 1000 * 1000;
export const NETWORKS_RPC_URL: iParamsPerNetwork<string> = {
[eEthereumNetwork.kovan]: KOVAN_RPC_URL,
[eEthereumNetwork.ropsten]: ROPSTEN_RPC_URL,
[eEthereumNetwork.main]: MAIN_RPC_URL,
[eEthereumNetwork.rinkeby]: RINKEBY_RPC_URL,
[eEthereumNetwork.goerli]: GOERLI_RPC_URL,
[eEthereumNetwork.hardhat]: "http://localhost:8545",
[ePolygonNetwork.mumbai]: MUMBAI_RPC_URL,
[ePolygonNetwork.matic]: MATIC_RPC_URL,
[eXDaiNetwork.xdai]: XDAI_RPC_URL,
[eAvalancheNetwork.avalanche]: AVALANCHE_RPC_URL,
[eAvalancheNetwork.fuji]: FUJI_RPC_URL,
[eArbitrumNetwork.arbitrum1]: ARBITRUM1_RPC_URL,
[eArbitrumNetwork.rinkeby_arbitrum1]: RINKEBY_ARBITRUM1_RPC_URL,
[eFantomNetwork.fantom]: FANTOM_RPC_URL,
[eFantomNetwork.fantom_test]: FANTOM_TEST_RPC_URL,
[eBinanceSmartChainNetwork.bsc]: BSC_RPC_URL,
[eBinanceSmartChainNetwork.bsc_test]: BSC_TEST_RPC_URL,
[eOptimisticEthereumNetwork.oethereum]: OETHEREUM_RPC_URL,
[eOptimisticEthereumNetwork.kovan_oethereum]: KOVAN_OETHEREUM_RPC_URL,
[eOptimisticEthereumNetwork.goerli_oethereum]: GOERLI_OETHEREUM_RPC_URL,
};
export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number | "auto"> = {
[eEthereumNetwork.kovan]: 1 * GWEI,
[eEthereumNetwork.ropsten]: 65 * GWEI,
[eEthereumNetwork.main]: "auto",
[eEthereumNetwork.hardhat]: 65 * GWEI,
[eEthereumNetwork.rinkeby]: 65 * GWEI,
[eEthereumNetwork.goerli]: 65 * GWEI,
[ePolygonNetwork.mumbai]: 1 * GWEI,
[ePolygonNetwork.matic]: "auto",
[eXDaiNetwork.xdai]: 1 * GWEI,
[eAvalancheNetwork.avalanche]: 225 * GWEI,
[eAvalancheNetwork.fuji]: 85 * GWEI,
[eArbitrumNetwork.arbitrum1]: 1 * GWEI,
[eArbitrumNetwork.rinkeby_arbitrum1]: 1 * GWEI,
[eFantomNetwork.fantom]: 1 * GWEI,
[eFantomNetwork.fantom_test]: 1 * GWEI,
[eBinanceSmartChainNetwork.bsc]: 1 * GWEI,
[eBinanceSmartChainNetwork.bsc_test]: 1 * GWEI,
[eOptimisticEthereumNetwork.oethereum]: 1 * GWEI,
[eOptimisticEthereumNetwork.kovan_oethereum]: 1 * GWEI,
[eOptimisticEthereumNetwork.goerli_oethereum]: 1 * GWEI,
};
export const NETWORKS_CHAIN_ID: iParamsPerNetwork<number | "auto"> = {
[eEthereumNetwork.kovan]: 42,
[eEthereumNetwork.ropsten]: 3,
[eEthereumNetwork.main]: 1,
[eEthereumNetwork.rinkeby]: 4,
[eEthereumNetwork.goerli]: 5,
[eEthereumNetwork.hardhat]: 31337,
[ePolygonNetwork.mumbai]: 80001,
[ePolygonNetwork.matic]: 137,
[eXDaiNetwork.xdai]: 100,
[eAvalancheNetwork.avalanche]: 43114,
[eAvalancheNetwork.fuji]: 43113,
[eArbitrumNetwork.arbitrum1]: 42161,
[eArbitrumNetwork.rinkeby_arbitrum1]: 421611,
[eFantomNetwork.fantom]: 250,
[eFantomNetwork.fantom_test]: 4002,
[eBinanceSmartChainNetwork.bsc]: 56,
[eBinanceSmartChainNetwork.bsc_test]: 97,
[eOptimisticEthereumNetwork.oethereum]: 10,
[eOptimisticEthereumNetwork.kovan_oethereum]: 69,
[eOptimisticEthereumNetwork.goerli_oethereum]: 420,
};
export const BLOCK_TO_FORK = {
[eEthereumNetwork.main]: 13856680,
[eEthereumNetwork.kovan]: undefined,
[eEthereumNetwork.ropsten]: undefined,
[eEthereumNetwork.rinkeby]: undefined,
[eEthereumNetwork.goerli]: undefined,
[eEthereumNetwork.hardhat]: undefined,
[ePolygonNetwork.mumbai]: undefined,
[ePolygonNetwork.matic]: 21435710,
[eXDaiNetwork.xdai]: undefined,
[eAvalancheNetwork.avalanche]: undefined,
[eAvalancheNetwork.fuji]: undefined,
[eArbitrumNetwork.arbitrum1]: undefined,
[eArbitrumNetwork.rinkeby_arbitrum1]: undefined,
[eFantomNetwork.fantom]: undefined,
[eFantomNetwork.fantom_test]: undefined,
[eBinanceSmartChainNetwork.bsc]: undefined,
[eBinanceSmartChainNetwork.bsc_test]: undefined,
[eOptimisticEthereumNetwork.oethereum]: undefined,
[eOptimisticEthereumNetwork.kovan_oethereum]: undefined,
[eOptimisticEthereumNetwork.goerli_oethereum]: undefined,
};
export const buildForkConfig = (): HardhatNetworkForkingUserConfig | undefined => {
if (FORK) {
const forkMode: HardhatNetworkForkingUserConfig = {
url: NETWORKS_RPC_URL[FORK],
};
if (FORK_BLOCK_NUMBER || BLOCK_TO_FORK[FORK]) {
forkMode.blockNumber = FORK_BLOCK_NUMBER || BLOCK_TO_FORK[FORK];
}
return forkMode;
}
return undefined;
};