forked from IndexZoo/Zoo-Habitat-Index-Protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
121 lines (108 loc) · 3.43 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
require("dotenv").config();
import 'hardhat-gas-reporter';
import chalk from "chalk";
import { HardhatUserConfig } from "hardhat/config";
import { privateKeys } from "./utils/wallets";
import "@nomiclabs/hardhat-waffle";
import "@typechain/hardhat";
import "solidity-coverage";
import "./tasks";
const UNISWAPROUTER_ADDRESS = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"; // mainnet, rinkbey, kovan
const forkingConfig = {
url: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_TOKEN}`,
blockNumber: 12198000,
};
const mochaConfig = {
grep: "@forked-mainnet",
invert: (process.env.FORK ) ? false : true,
timeout: (process.env.FORK || process.env.FORKED) ? 200000 : 40000, // 100000:40000
} as Mocha.MochaOptions;
checkForkedProviderEnvironment();
const config: HardhatUserConfig = {
solidity: {
version: "0.6.10",
settings: {
optimizer: { enabled: true, runs: 200 },
},
},
networks: {
hardhat: {
forking: (process.env.FORK) ? forkingConfig : undefined,
accounts: getHardhatPrivateKeys(),
},
localhost: {
url: "http://127.0.0.1:8545",
timeout: 200000,
gas: 12000000,
blockGasLimit: 12000000,
},
kovan: {
url: "https://eth-kovan.alchemyapi.io/v2/" + process.env.KOVAN_ALCHEMY_TOKEN,
gas: 12000000,
// @ts-ignore
accounts: [`0x${process.env.TEST_PRIVATE_KEY}`],
// @ts-ignore
uniswapRouterAddress: UNISWAPROUTER_ADDRESS
},
rinkeby: {
url: "https://eth-rinkeby.alchemyapi.io/v2/" + process.env.ALCHEMY_TOKEN,
gas: 12000000,
// url: "https://rinkeby.infura.io/v3/" + process.env.INFURA_TOKEN,
// @ts-ignore
accounts: [`0x${process.env.TEST_PRIVATE_KEY}`],
// @ts-ignore
uniswapRouterAddress: UNISWAPROUTER_ADDRESS,
weth: "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"
},
polygon: {
url: "https://polygon-mainnet.g.alchemy.com/v2/" + process.env.POLYGON_ALCHEMY_TOKEN,
gas: 12000000,
// @ts-ignore
accounts: [`0x${process.env.PRODUCTION_LOWFEE_DEPLOY_PRIVATE_KEY}`],
// @ts-ignore
uniswapRouterAddress: "0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F", // Sushiswap
weth: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
},
// To update coverage network configuration got o .solcover.js and update param in providerOptions field
coverage: {
url: "http://127.0.0.1:8555", // Coverage launches its own ganache-cli client
timeout: 200000,
},
},
// @ts-ignore
typechain: {
outDir: "typechain",
target: "ethers-v5",
externalArtifacts: ["external/**/*.json"],
},
mocha: mochaConfig,
// These are external artifacts we don't compile but would like to improve
// test performance for by hardcoding the gas into the abi at runtime
// @ts-ignore
externalGasMods: [
],
gasReporter: {
enabled: true
}
};
function getHardhatPrivateKeys() {
return privateKeys.map(key => {
const ONE_MILLION_ETH = "1000000000000000000000000";
return {
privateKey: key,
balance: ONE_MILLION_ETH,
};
});
}
function checkForkedProviderEnvironment() {
if (process.env.FORK &&
(!process.env.ALCHEMY_TOKEN || process.env.ALCHEMY_TOKEN === "fake_alchemy_token")
) {
console.log(chalk.red(
"You are running forked provider tests with invalid Alchemy credentials.\n" +
"Update your ALCHEMY_TOKEN settings in the `.env` file."
));
process.exit(1);
}
}
export default config;