This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
hardhat.config.ts
230 lines (220 loc) · 4.82 KB
/
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
import { HardhatUserConfig } from 'hardhat/types'
import { NetworkUserConfig } from 'hardhat/types'
import { NetworksUserConfig } from 'hardhat/types'
import dotenv from 'dotenv'
import '@nomiclabs/hardhat-waffle'
import '@nomiclabs/hardhat-ethers'
import 'solidity-coverage'
import './tasks/accounts'
import './tasks/clean'
import './tasks/addOwnerFunds'
import './tasks/addContractsToDefenderAdmin'
import './tasks/migrateStrategy'
dotenv.config()
const chainIds = {
ganache: 1337,
goerli: 5,
hardhat: 31337,
kovan: 42,
mainnet: 1,
ensonet: 1,
rinkeby: 4,
ropsten: 3,
}
// Ensure that we have all the environment variables we need.
let mnemonic: string | undefined = process.env.MNEMONIC
let infuraApiKey: string | undefined = process.env.INFURA_API_KEY
let archiveNode: string | undefined = process.env.ARCHIVE_NODE
let networkIndex: number = process.argv.findIndex((arg) => arg === '--network')
if (networkIndex > 0) {
if (process.argv[networkIndex + 1] !== 'hardhat') {
if (!mnemonic) {
throw new Error('Please set your MNEMONIC in a .env file')
}
/*if (!infuraApiKey) {
throw new Error('Please set your INFURA_API_KEY in a .env file')
}*/
} else {
if (process.argv[2] == 'test' && !archiveNode) {
throw new Error('Please set your ARCHIVE_NODE in a .env file')
}
}
} else {
if (process.argv[2] == 'test' && !archiveNode) {
throw new Error('Please set your ARCHIVE_NODE in a .env file')
}
}
function getNetworks(): NetworksUserConfig {
let networks: NetworksUserConfig = {
hardhat: {
chainId: chainIds.mainnet,
accounts: {
accountsBalance: "100000000000000000000000" //10,000 ETH
}
},
localhost: {
url: 'http://127.0.0.1:8545',
timeout: 900000,
gasPrice: 100000000000, // 100 gwei
},
}
if (networks.hardhat) {
if (mnemonic)
networks.hardhat.accounts = {
...networks.hardhat.accounts,
mnemonic,
}
if (archiveNode)
networks.hardhat.forking = {
url: archiveNode,
blockNumber: 15394205,
}
}
if (mnemonic && infuraApiKey) {
networks.goerli = createTestnetConfig('goerli')
networks.kovan = createTestnetConfig('kovan')
networks.rinkeby = createTestnetConfig('rinkeby')
networks.ropsten = createTestnetConfig('ropsten')
networks.ensonet = createTestnetConfig('ensonet')
networks.mainnet = createTestnetConfig('mainnet')
}
return networks
}
function createTestnetConfig(network: keyof typeof chainIds): NetworkUserConfig {
// Ensure that we have all the environment variables we need.
let url: string
if (network === 'ensonet') {
url = 'http://testnet.enso.finance'
} else {
url = 'https://' + network + '.infura.io/v3/' + infuraApiKey
}
return {
accounts: {
count: 10,
initialIndex: 0,
mnemonic,
path: "m/44'/60'/0'/0",
},
chainId: chainIds[network],
url,
}
}
let config: HardhatUserConfig = {
defaultNetwork: 'hardhat',
networks: getNetworks(),
paths: {
artifacts: './artifacts',
cache: './cache',
sources: './contracts',
tests: './test',
},
solidity: {
compilers: [
{
version: '0.8.11',
settings: {
optimizer: {
enabled: true,
runs: 420,
},
},
},
{
version: '0.7.6',
settings: {
optimizer: {
enabled: true,
runs: 420,
},
},
},
{
version: '0.6.12',
settings: {
optimizer: {
enabled: true,
runs: 420,
},
},
},
{
version: '0.6.6',
settings: {
optimizer: {
enabled: true,
runs: 420,
},
},
},
{
version: '0.5.16',
settings: {
optimizer: {
enabled: true,
runs: 420,
},
},
},
{
version: '0.5.12',
settings: {
optimizer: {
enabled: true,
runs: 420,
},
},
},
{
version: '0.5.5',
settings: {
optimizer: {
enabled: true,
runs: 420,
},
},
},
],
overrides: {
"@uniswap/v3-periphery/contracts/libraries/ChainId.sol": {
version: '0.7.0',
settings: {}
},
"@uniswap/lib/contracts/libraries/SafeERC20Namer.sol": {
version: '0.5.0',
settings: {}
},
"@uniswap/lib/contracts/libraries/AddressStringUtil.sol": {
version: '0.5.0',
settings: {}
},
"@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol": {
version: '0.5.0',
settings: {}
},
"@uniswap/v2-periphery/contracts/interfaces/IWETH.sol": {
version: '0.5.0',
settings: {}
},
"@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol": {
version: '0.5.0',
settings: {}
},
"@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol": {
version: '0.5.0',
settings: {}
},
"@uniswap/v2-core/contracts/interfaces/IUniswapV2ERC20.sol": {
version: '0.5.0',
settings: {}
},
"@uniswap/v2-core/contracts/interfaces/IUniswapV2Callee.sol": {
version: '0.5.0',
settings: {}
},
}
},
mocha: {
timeout: 100000,
},
}
export default config