2021-11-28 17:53:16 +00:00
|
|
|
import "@nomiclabs/hardhat-waffle";
|
|
|
|
import "@nomiclabs/hardhat-ethers";
|
2023-08-18 13:01:28 +00:00
|
|
|
// import "@tenderly/hardhat-tenderly";
|
2021-11-28 17:53:16 +00:00
|
|
|
import "@nomiclabs/hardhat-etherscan";
|
|
|
|
import "@nomiclabs/hardhat-web3";
|
|
|
|
import "hardhat-deploy";
|
|
|
|
import "hardhat-deploy-ethers";
|
|
|
|
import "@typechain/hardhat";
|
|
|
|
import { resolve } from "path";
|
|
|
|
import { config as dotenvConfig } from "dotenv";
|
|
|
|
import { HardhatUserConfig } from "hardhat/config";
|
|
|
|
import { NetworkUserConfig } from "hardhat/types";
|
|
|
|
import { utils } from "ethers";
|
|
|
|
import Web3 from "web3";
|
2022-02-27 13:43:35 +00:00
|
|
|
import { network } from "hardhat";
|
2022-03-19 14:54:43 +00:00
|
|
|
import bigNumber from "bignumber.js";
|
2022-03-23 16:24:56 +00:00
|
|
|
import "./scripts/tests/run_test_through_cmd";
|
2021-11-28 17:53:16 +00:00
|
|
|
|
|
|
|
dotenvConfig({ path: resolve(__dirname, "./.env") });
|
|
|
|
|
|
|
|
const chainIds = {
|
|
|
|
ganache: 1337,
|
|
|
|
hardhat: 31337,
|
|
|
|
mainnet: 1,
|
|
|
|
avalanche: 43114,
|
|
|
|
polygon: 137,
|
2021-12-05 17:21:55 +00:00
|
|
|
arbitrum: 42161,
|
2022-02-14 02:58:00 +00:00
|
|
|
optimism: 10,
|
2023-08-16 21:37:50 +00:00
|
|
|
fantom: 250,
|
|
|
|
base: 8453,
|
2021-11-28 17:53:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const alchemyApiKey = process.env.ALCHEMY_API_KEY;
|
|
|
|
if (!alchemyApiKey) {
|
2021-12-05 17:19:39 +00:00
|
|
|
throw new Error("Please set your ALCHEMY_API_KEY in a .env file");
|
2021-11-28 17:53:16 +00:00
|
|
|
}
|
|
|
|
|
2021-12-10 22:46:46 +00:00
|
|
|
const PRIVATE_KEY = process.env.PRIVATE_KEY;
|
2022-03-12 16:54:50 +00:00
|
|
|
const mnemonic = process.env.MNEMONIC ?? "test test test test test test test test test test test junk";
|
2021-12-10 22:12:05 +00:00
|
|
|
|
2022-03-19 07:49:50 +00:00
|
|
|
const networkGasPriceConfig: Record<string, number> = {
|
|
|
|
mainnet: 100,
|
|
|
|
polygon: 50,
|
2022-04-28 22:35:53 +00:00
|
|
|
avalanche: 40,
|
2022-03-19 07:49:50 +00:00
|
|
|
arbitrum: 1,
|
|
|
|
optimism: 0.001,
|
2023-08-16 19:06:00 +00:00
|
|
|
fantom: 210,
|
2023-08-19 14:29:55 +00:00
|
|
|
base: 0.0005
|
2022-03-12 16:54:50 +00:00
|
|
|
};
|
2021-12-21 12:35:49 +00:00
|
|
|
|
2021-12-10 22:59:04 +00:00
|
|
|
function createConfig(network: string) {
|
2021-12-10 22:55:13 +00:00
|
|
|
return {
|
|
|
|
url: getNetworkUrl(network),
|
2022-03-19 07:49:50 +00:00
|
|
|
accounts: !!PRIVATE_KEY ? [`0x${PRIVATE_KEY}`] : { mnemonic },
|
2022-03-19 14:54:43 +00:00
|
|
|
gasPrice: new bigNumber(networkGasPriceConfig[network]).multipliedBy(1e9).toNumber() // Update the mapping above
|
2021-12-10 22:55:13 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-11-28 17:53:16 +00:00
|
|
|
function getNetworkUrl(networkType: string) {
|
2022-03-12 16:54:50 +00:00
|
|
|
if (networkType === "avalanche") return "https://api.avax.network/ext/bc/C/rpc";
|
|
|
|
else if (networkType === "polygon") return `https://polygon-mainnet.g.alchemy.com/v2/${alchemyApiKey}`;
|
|
|
|
else if (networkType === "arbitrum") return `https://arb-mainnet.g.alchemy.com/v2/${alchemyApiKey}`;
|
|
|
|
else if (networkType === "optimism") return `https://opt-mainnet.g.alchemy.com/v2/${alchemyApiKey}`;
|
|
|
|
else if (networkType === "fantom") return `https://rpc.ftm.tools/`;
|
2023-08-16 19:06:00 +00:00
|
|
|
else if (networkType === "base") return `https://1rpc.io/base`;
|
2021-11-28 17:53:16 +00:00
|
|
|
else return `https://eth-mainnet.alchemyapi.io/v2/${alchemyApiKey}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type import('hardhat/config').HardhatUserConfig
|
|
|
|
*/
|
2023-08-18 13:01:28 +00:00
|
|
|
const config: any = {
|
2021-11-28 17:53:16 +00:00
|
|
|
solidity: {
|
|
|
|
compilers: [
|
|
|
|
{
|
|
|
|
version: "0.7.6",
|
|
|
|
settings: {
|
|
|
|
optimizer: {
|
|
|
|
enabled: true,
|
2022-03-12 16:54:50 +00:00
|
|
|
runs: 200
|
|
|
|
}
|
|
|
|
}
|
2021-11-28 17:53:16 +00:00
|
|
|
},
|
|
|
|
{
|
2022-03-12 16:54:50 +00:00
|
|
|
version: "0.6.0"
|
2021-11-28 17:53:16 +00:00
|
|
|
},
|
|
|
|
{
|
2022-03-12 16:54:50 +00:00
|
|
|
version: "0.6.2"
|
2021-11-28 17:53:16 +00:00
|
|
|
},
|
|
|
|
{
|
2022-03-12 16:54:50 +00:00
|
|
|
version: "0.6.5"
|
|
|
|
}
|
|
|
|
]
|
2021-11-28 17:53:16 +00:00
|
|
|
},
|
|
|
|
networks: {
|
|
|
|
hardhat: {
|
|
|
|
accounts: {
|
2022-03-12 16:54:50 +00:00
|
|
|
mnemonic
|
2021-11-28 17:53:16 +00:00
|
|
|
},
|
|
|
|
chainId: chainIds.hardhat,
|
|
|
|
forking: {
|
2022-03-12 16:54:50 +00:00
|
|
|
url: String(getNetworkUrl(String(process.env.networkType)))
|
|
|
|
}
|
2021-11-28 17:53:16 +00:00
|
|
|
},
|
2021-12-10 22:59:04 +00:00
|
|
|
mainnet: createConfig("mainnet"),
|
|
|
|
polygon: createConfig("polygon"),
|
|
|
|
avalanche: createConfig("avalanche"),
|
|
|
|
arbitrum: createConfig("arbitrum"),
|
2022-01-14 18:34:47 +00:00
|
|
|
optimism: createConfig("optimism"),
|
2023-08-16 19:06:00 +00:00
|
|
|
fantom: createConfig("fantom"),
|
|
|
|
base: createConfig("base")
|
2021-11-28 17:53:16 +00:00
|
|
|
},
|
|
|
|
paths: {
|
|
|
|
artifacts: "./artifacts",
|
|
|
|
cache: "./cache",
|
|
|
|
sources: "./contracts",
|
2022-03-12 16:54:50 +00:00
|
|
|
tests: "./test"
|
2021-11-28 17:53:16 +00:00
|
|
|
},
|
2022-02-27 13:43:35 +00:00
|
|
|
etherscan: {
|
2022-03-19 07:49:50 +00:00
|
|
|
apiKey: {
|
|
|
|
mainnet: String(process.env.MAIN_ETHSCAN_KEY),
|
|
|
|
optimisticEthereum: String(process.env.OPT_ETHSCAN_KEY),
|
|
|
|
polygon: String(process.env.POLY_ETHSCAN_KEY),
|
|
|
|
arbitrumOne: String(process.env.ARB_ETHSCAN_KEY),
|
|
|
|
avalanche: String(process.env.AVAX_ETHSCAN_KEY),
|
2023-08-16 19:06:00 +00:00
|
|
|
opera: String(process.env.FTM_ETHSCAN_KEY),
|
2023-08-18 13:01:28 +00:00
|
|
|
base: String(process.env.BASE_ETHSCAN_KEY),
|
2023-08-16 21:37:50 +00:00
|
|
|
},
|
|
|
|
customChains: [
|
|
|
|
{
|
|
|
|
network: "base",
|
|
|
|
chainId: 8453,
|
|
|
|
urls: {
|
|
|
|
apiURL: "https://api.basescan.org/api",
|
2023-08-18 13:01:28 +00:00
|
|
|
browserURL: "https://basescan.org"
|
2023-08-16 21:37:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2021-11-28 17:53:16 +00:00
|
|
|
},
|
|
|
|
typechain: {
|
|
|
|
outDir: "typechain",
|
2022-03-12 16:54:50 +00:00
|
|
|
target: "ethers-v5"
|
2021-11-28 17:53:16 +00:00
|
|
|
},
|
|
|
|
mocha: {
|
2022-03-12 16:54:50 +00:00
|
|
|
timeout: 10000 * 1000 // 10,000 seconds
|
|
|
|
}
|
2021-12-05 17:19:39 +00:00
|
|
|
// tenderly: {
|
|
|
|
// project: process.env.TENDERLY_PROJECT,
|
|
|
|
// username: process.env.TENDERLY_USERNAME,
|
|
|
|
// },
|
2021-11-28 17:53:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default config;
|