forked from saddle-finance/saddle-contract
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
174 lines (166 loc) · 4.38 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
import "@nomiclabs/hardhat-ethers"
import "@nomiclabs/hardhat-waffle"
import "@nomiclabs/hardhat-web3"
import "@nomiclabs/hardhat-etherscan"
import "@typechain/hardhat"
import "hardhat-gas-reporter"
import "solidity-coverage"
import "hardhat-deploy"
import "hardhat-spdx-license-identifier"
import { HardhatUserConfig } from "hardhat/config"
import dotenv from "dotenv"
import { ethers } from "ethers"
dotenv.config()
if (process.env.HARDHAT_FORK) {
process.env["HARDHAT_DEPLOY_FORK"] = process.env.HARDHAT_FORK
}
let config: HardhatUserConfig = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
deploy: ["./deploy/mainnet/"],
},
matic_mumbai: {
url: process.env.ALCHEMY_API_MATIC_TESTNET,
gasPrice: ethers.utils.parseUnits("3", "gwei").toNumber(),
accounts: {
mnemonic: process.env.MNEMONIC_TEST_ACCOUNT,
},
deploy: ["./deploy/matic/"],
},
// mainnet: {
// url: process.env.ALCHEMY_API,
// deploy: ["./deploy/mainnet/"],
// },
// ropsten: {
// url: process.env.ALCHEMY_API_ROPSTEN,
// gasPrice: ethers.utils.parseUnits("1.01", "gwei").toNumber(),
// accounts: {
// mnemonic: process.env.MNEMONIC_TEST_ACCOUNT,
// },
// deploy: ["./deploy/mainnet/"],
// },
// arbitrum_testnet: {
// url: "https://rinkeby.arbitrum.io/rpc",
// accounts: {
// mnemonic: process.env.MNEMONIC_TEST_ACCOUNT,
// },
// deploy: ["./deploy/arbitrum/"],
// },
// arbitrum_mainnet: {
// url: "https://arb1.arbitrum.io/rpc",
// gasPrice: ethers.utils.parseUnits("2", "gwei").toNumber(),
// deploy: ["./deploy/arbitrum/"],
// },
// optimism_testnet: {
// url: "https://kovan.optimism.io",
// chainId: 69,
// accounts: {
// mnemonic: process.env.MNEMONIC_TEST_ACCOUNT,
// },
// deploy: ["./deploy/optimism/"],
// },
// optimism_mainnet: {
// url: "https://mainnet.optimism.io",
// chainId: 10,
// deploy: ["./deploy/optimism/"],
// },
},
paths: {
sources: "./contracts",
artifacts: "./build/artifacts",
cache: "./build/cache",
},
solidity: {
compilers: [
{
version: "0.8.6",
settings: {
optimizer: {
enabled: true,
runs: 10000,
},
},
},
{
version: "0.6.12",
settings: {
optimizer: {
enabled: true,
runs: 10000,
},
},
},
{
version: "0.5.16",
},
],
},
typechain: {
outDir: "./build/typechain/",
target: "ethers-v5",
},
gasReporter: {
currency: "USD",
gasPrice: 21,
},
mocha: {
timeout: 200000,
},
namedAccounts: {
deployer: {
default: 0, // here this will by default take the first account as deployer
1: 0, // similarly on mainnet it will take the first account as deployer. Note though that depending on how hardhat network are configured, the account 0 on one network can be different than on another
42161: 0,
10: 0,
},
libraryDeployer: {
default: 0, // use a different account for deploying libraries on the hardhat network
1: 0, // use the same address as the main deployer on mainnet
42161: 0, // use the same address on arbitrum mainnet
10: 0, // use the same address on optimism mainnet
},
},
spdxLicenseIdentifier: {
overwrite: false,
runOnCompile: true,
},
}
if (process.env.POLY_SCAN_API) {
config = { ...config, etherscan: { apiKey: process.env.POLY_SCAN_API } }
}
if (process.env.ACCOUNT_PRIVATE_KEYS) {
config.networks = {
...config.networks,
mainnet: {
...config.networks?.mainnet,
accounts: JSON.parse(process.env.ACCOUNT_PRIVATE_KEYS),
},
arbitrum_mainnet: {
...config.networks?.arbitrum_mainnet,
accounts: JSON.parse(process.env.ACCOUNT_PRIVATE_KEYS),
},
}
}
if (process.env.FORK_MAINNET === "true" && config.networks) {
console.log("FORK_MAINNET is set to true")
config = {
...config,
networks: {
...config.networks,
hardhat: {
...config.networks.hardhat,
forking: {
url: process.env.ALCHEMY_API ? process.env.ALCHEMY_API : "",
},
chainId: 1,
},
},
external: {
deployments: {
localhost: ["deployments/mainnet"],
},
},
}
}
export default config