-
Notifications
You must be signed in to change notification settings - Fork 15
/
buidler.config.js
147 lines (137 loc) · 4.58 KB
/
buidler.config.js
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
const path = require('path');
const url = require('url');
require('dotenv').config();
const { InfuraProvider } = require('@ethersproject/providers');
const { fromPrivateKey } = require('ethereumjs-wallet');
const { randomBytes } = require('crypto');
const { types, internalTask } = require("@nomiclabs/buidler/config");
const Logger = require('./lib/logger');
usePlugin("buidler-ethers-v5");
usePlugin("buidler-deploy");
usePlugin("solidity-coverage");
usePlugin("@nomiclabs/buidler-etherscan");
const keys = {
mainnet: fromPrivateKey(
process.env.MAINNET_PVT_KEY
? Buffer.from(process.env.MAINNET_PVT_KEY.slice(2), 'hex')
: randomBytes(32)
).getPrivateKeyString(),
rinkeby: fromPrivateKey(
process.env.RINKEBY_PVT_KEY
? Buffer.from(process.env.RINKEBY_PVT_KEY.slice(2), 'hex')
: randomBytes(32)).getPrivateKeyString()
};
internalTask('approve_pool_controller', 'Approves an address to deploy index pools if it is not already approved.')
.addParam('address', 'address to approve')
.addOptionalParam('gasPrice', 'Gas price to use for approval transaction.', 1000000000, types.int)
.setAction(async ({ address, gasPrice }) => {
require('@nomiclabs/buidler');
const poolFactory = await ethers.getContract('poolFactory');
const logger = Logger(await getChainId());
const isApproved = await poolFactory.isApprovedController(address);
if (isApproved) {
logger.info(`${address} is already approved`);
} else {
logger.info(`Approving ${address} as a pool controller...`);
await poolFactory.approvePoolController(address, { gasLimit: 150000, gasPrice });
logger.success(`Approved ${address} as a pool controller!`);
}
});
internalTask('approve_proxy_deployer', 'Approves an address to deploy proxies if it is not already approved.')
.addParam('address', 'address to approve')
.addOptionalParam('gasPrice', 'Gas price to use for approval transaction.', 1000000000, types.int)
.setAction(async ({ address, gasPrice }) => {
require('@nomiclabs/buidler');
const proxyManager = await ethers.getContract('proxyManager');
const logger = Logger(await getChainId());
const isApproved = await proxyManager.isApprovedDeployer(address);
if (isApproved) {
logger.info(`${address} is already approved`);
} else {
logger.info(`Approving ${address} as a proxy deployer...`);
await proxyManager.approveDeployer(address, { gasLimit: 150000, gasPrice });
logger.success(`Approved ${address} as a proxy deployer!`);
}
});
module.exports = {
etherscan: {
url: "https://api.etherscan.io/api",
apiKey: process.env.ETHERSCAN_API_KEY,
},
external: {
artifacts: [
"node_modules/@uniswap/v2-core/build",
"node_modules/@uniswap/v2-periphery/build",
"node_modules/@indexed-finance/proxies/artifacts",
"node_modules/@indexed-finance/uniswap-v2-oracle/artifacts"
],
deployments: {
mainnet: [
"node_modules/@indexed-finance/proxies/deployments/mainnet",
"node_modules/@indexed-finance/uniswap-v2-oracle/deployments/mainnet",
"node_modules/@indexed-finance/uniswap-deployments/mainnet"
],
rinkeby: [
"node_modules/@indexed-finance/proxies/deployments/rinkeby",
"node_modules/@indexed-finance/uniswap-v2-oracle/deployments/rinkeby",
"node_modules/@indexed-finance/uniswap-deployments/rinkeby"
]
}
},
gasReporter: {
currency: "USD",
showTimeSpent: true,
enabled: true,
currency: "USD",
},
namedAccounts: {
deployer: {
default: 0
},
},
networks: {
buidlerevm: {
live: false,
saveDeployment: false
},
local: {
url: url.format({
protocol: "http:",
port: 8545,
hostname: "localhost",
}),
},
mainnet: {
url: new InfuraProvider("mainnet", process.env.INFURA_PROJECT_ID).connection.url,
accounts: [keys.mainnet],
chainId: 1
},
rinkeby: {
url: new InfuraProvider("rinkeby", process.env.INFURA_PROJECT_ID).connection.url,
accounts: [keys.rinkeby],
chainId: 4
},
coverage: {
url: url.format({
protocol: "http:",
port: 8555,
hostname: "localhost",
}),
}
},
paths: {
sources: path.join(__dirname, 'contracts'),
tests: path.join(__dirname, 'test'),
cache: path.join(__dirname, 'cache'),
artifacts: path.join(__dirname, 'artifacts'),
deploy: path.join(__dirname, "deploy"),
deployments: path.join(__dirname, "deployments")
},
solc: {
version: "0.6.12",
optimizer: {
enabled: true,
runs: 200
}
},
};