generated from Opty-Fi/defi-adapter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
132 lines (126 loc) · 4.29 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
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import "@nomiclabs/hardhat-waffle";
import "@typechain/hardhat";
import "solidity-coverage";
import { resolve, join } from "path";
import fs from "fs";
import { config as dotenvConfig } from "dotenv";
import { HardhatUserConfig, NetworkUserConfig } from "hardhat/types";
import {
eArbitrumNetwork,
eAvalancheNetwork,
eBinanceSmartChainNetwork,
eEthereumNetwork,
eFantomNetwork,
eNetwork,
eOptimisticEthereumNetwork,
ePolygonNetwork,
eXDaiNetwork,
iParamsPerNetwork,
} from "./helpers/types";
import { NETWORKS_RPC_URL, buildForkConfig, NETWORKS_CHAIN_ID, NETWORKS_DEFAULT_GAS } from "./helper-hardhat-config";
dotenvConfig({ path: resolve(__dirname, "./.env") });
const SKIP_LOAD = process.env.SKIP_LOAD === "true";
const HARDFORK = "london";
const MNEMONIC_PATH = "m/44'/60'/0'/0";
const MNEMONIC = process.env.MNEMONIC || "";
const NETWORK = process.env.NETWORK || "hardhat";
// Prevent to load scripts before compilation and typechain
if (!SKIP_LOAD) {
["1_ethereum"].forEach(folder => {
const tasksPath = join(__dirname, "tasks", folder);
fs.readdirSync(tasksPath)
.filter(pth => pth.includes(".ts"))
.forEach(task => {
require(`${tasksPath}/${task}`);
});
});
require("./tasks/accounts");
require("./tasks/clean");
}
const getCommonNetworkConfig = (networkName: eNetwork): NetworkUserConfig | undefined => ({
url: NETWORKS_RPC_URL[networkName as keyof iParamsPerNetwork<string>],
hardfork: HARDFORK,
gasPrice: "auto",
chainId: NETWORKS_CHAIN_ID[networkName as keyof iParamsPerNetwork<string>],
initialBaseFeePerGas: 1_00_000_000,
accounts: {
mnemonic: MNEMONIC,
path: MNEMONIC_PATH,
initialIndex: 0,
count: 20,
accountsBalance: "10000000000000000000000",
},
});
const config: HardhatUserConfig = {
networks: {
kovan: getCommonNetworkConfig(eEthereumNetwork.kovan),
ropsten: getCommonNetworkConfig(eEthereumNetwork.ropsten),
main: getCommonNetworkConfig(eEthereumNetwork.main),
rinkeby: getCommonNetworkConfig(eEthereumNetwork.main),
goerli: getCommonNetworkConfig(eEthereumNetwork.main),
matic: getCommonNetworkConfig(ePolygonNetwork.matic),
mumbai: getCommonNetworkConfig(ePolygonNetwork.mumbai),
xdai: getCommonNetworkConfig(eXDaiNetwork.xdai),
avalanche: getCommonNetworkConfig(eAvalancheNetwork.avalanche),
fuji: getCommonNetworkConfig(eAvalancheNetwork.fuji),
arbitrum1: getCommonNetworkConfig(eArbitrumNetwork.arbitrum1),
rinkeby_arbitrum1: getCommonNetworkConfig(eArbitrumNetwork.rinkeby_arbitrum1),
fantom: getCommonNetworkConfig(eFantomNetwork.fantom),
fantom_test: getCommonNetworkConfig(eFantomNetwork.fantom_test),
bsc: getCommonNetworkConfig(eBinanceSmartChainNetwork.bsc),
bsc_test: getCommonNetworkConfig(eBinanceSmartChainNetwork.bsc_test),
oethereum: getCommonNetworkConfig(eOptimisticEthereumNetwork.oethereum),
kovan_oethereum: getCommonNetworkConfig(eOptimisticEthereumNetwork.kovan_oethereum),
goerli_oethereum: getCommonNetworkConfig(eOptimisticEthereumNetwork.goerli_oethereum),
hardhat: {
hardfork: "london",
gasPrice: NETWORKS_DEFAULT_GAS[NETWORK as keyof iParamsPerNetwork<string>],
chainId: NETWORKS_CHAIN_ID[NETWORK as keyof iParamsPerNetwork<string>],
initialBaseFeePerGas: 1_00_000_000,
accounts: {
initialIndex: 0,
count: 20,
mnemonic: MNEMONIC,
path: MNEMONIC_PATH,
accountsBalance: "10000000000000000000000",
},
forking: buildForkConfig(),
},
},
solidity: {
compilers: [
{
version: "0.8.11",
settings: {
metadata: {
// Not including the metadata hash
// https://github.com/paulrberg/solidity-template/issues/31
bytecodeHash: "none",
},
// Disable the optimizer when debugging
// https://hardhat.org/hardhat-network/#solidity-optimizer-support
optimizer: {
enabled: true,
runs: 200,
},
},
},
],
},
paths: {
artifacts: "./artifacts",
cache: "./cache",
sources: "./contracts",
tests: "./test",
},
typechain: {
outDir: "typechain",
target: "ethers-v5",
},
mocha: {
timeout: 0,
},
};
export default config;