-
Notifications
You must be signed in to change notification settings - Fork 2
/
hardhat.config.ts
163 lines (156 loc) Β· 4.73 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
import "hardhat-diamond-abi";
import "@nomiclabs/hardhat-waffle";
import * as dotenv from "dotenv";
import "hardhat-deploy";
import "hardhat-deploy-ethers";
import { HardhatUserConfig } from "hardhat/config";
import "@typechain/hardhat";
import "@nomiclabs/hardhat-ethers";
import "hardhat-gas-reporter";
import "solidity-coverage";
import "./tasks/index";
import "@nomiclabs/hardhat-etherscan";
import "hardhat-abi-exporter";
dotenv.config();
const {
INFURA_KEY,
ALCHEMY_API_KEY,
PRIVATE_KEY,
MNEMONIC,
ETHERSCAN_API_KEY,
COINMARKETCAP_API_KEY,
REPORT_GAS,
REPORT_GAS_PRICE,
} = process.env;
const mnemonic = `${
MNEMONIC || "test test test test test test test test test test test junk"
}`;
// if using infura, you can add new networks by adding the name as it is seen in the infura url
const INFURA_NETWORKS = [
"mainnet",
"rinkeby",
"kovan",
"goerli",
"arbitrum-mainnet",
"arbitrum-rinkeby",
];
const accounts = PRIVATE_KEY
? // Private key overrides mnemonic - leave pkey empty in .env if using mnemonic
[`0x${PRIVATE_KEY}`]
: {
mnemonic,
path: "m/44'/60'/0'/0",
initialIndex: 0,
count: 10,
};
const networks = ["mainnet", "kovan", "goerli"];
/**
* Given the name of a network build a Hardhat Network object
* @param {string} _network - the string name of the network
* @return {INetwork} - the Hardhat Network object
*/
const makeNetwork = (_network: string) => {
if (INFURA_NETWORKS.includes(_network))
return {
url: `https://${_network}.infura.io/v3/${INFURA_KEY}`,
accounts,
};
return {};
};
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.9",
settings: {
optimizer: {
enabled: true,
runs: 800,
},
metadata: {
// do not include the metadata hash, since this is machine dependent
// and we want all generated code to be deterministic
// https://docs.soliditylang.org/en/v0.7.6/metadata.html
bytecodeHash: "none",
},
},
},
],
},
diamondAbi: {
name: "MeTokensDiamond",
include: ["facets/"],
},
mocha: {
delay: true,
timeout: 120000, // Here is 2min but can be whatever timeout is suitable for you.
},
namedAccounts: {
SwapRouter: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
Quoter: "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6",
UNIV3Factory: "0x1F98431c8aD98523631AE4a59f267346ea31F984",
DAI: {
default: "0x6B175474E89094C44Da98b954EedeAC495271d0F", // here this will by default take the first account as deployer
1: "0x6B175474E89094C44Da98b954EedeAC495271d0F", // 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
4: "0xc7ad46e0b8a400bb3c915120d284aafba8fc4735", // but for rinkeby it will be a specific address
goerli: "0x0C4f55df47B20c8Fbb134494B45A7a01097849ff", //it can also specify a specific netwotk name (specified in hardhat.config.js)
},
DAIWhale: "0x47ac0Fb4F2D84898e4D9E7b4DaB3C24507a6D503",
WETH: {
default: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
1: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
},
WETHWhale: "0x57757E3D981446D585Af0D9Ae4d7DF6D64647806",
USDC: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
USDCWhale: "0x6262998Ced04146fA42253a5C0AF90CA02dfd2A3",
USDT: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
YDAIWhale: "0x863e730904cb7dcdd5205de6b502f42c3f6d9372",
YDAI: "0xdA816459F1AB5631232FE5e97a05BBBb94970c95",
WBTC: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
WBTCWhale: "0x2faf487a4414fe77e2327f0bf4ae2a264a776ad2",
},
networks: {
hardhat: {
forking: {
url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_API_KEY}`,
accounts,
blockNumber: 14800000,
},
gas: "auto",
timeout: 1800000,
chainId: 1,
},
...networks.reduce((obj: any, entry) => {
obj[entry] = makeNetwork(entry);
return obj;
}, {}),
},
typechain: {
outDir: "artifacts/types",
target: "ethers-v5",
},
gasReporter: {
enabled: REPORT_GAS === "true",
currency: "USD",
gasPrice: Number.parseInt(REPORT_GAS_PRICE ?? "50"),
onlyCalledMethods: true,
coinmarketcap: `${COINMARKETCAP_API_KEY || ""}`,
},
etherscan: {
// Your API key for Etherscan
// Obtain one at https://etherscan.io/
apiKey: `${ETHERSCAN_API_KEY || ""}`,
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts",
},
abiExporter: {
path: "./test/abi",
clear: true,
flat: true,
},
};
export default config;