Skip to content

Commit 99f7579

Browse files
committed
tasks restructure and linter run
1 parent 4c485f7 commit 99f7579

29 files changed

+847
-108
lines changed

hardhat.config.js

Lines changed: 52 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ require('@nomiclabs/hardhat-etherscan');
1010
require('./tasks/deploy/ampleforth');
1111
require('./tasks/deploy/chain_bridge');
1212
require('./tasks/deploy/matic');
13+
require('./tasks/deploy/arbitrum');
1314
require('./tasks/deploy/rebase_reporter');
1415

1516
require('./tasks/ops/rebase');
@@ -26,94 +27,114 @@ module.exports = {
2627
solidity: {
2728
compilers: [
2829
{
29-
version: '0.4.24'
30+
version: '0.4.24',
3031
},
3132
{
32-
version: '0.7.6'
33+
version: '0.5.12',
3334
},
3435
{
35-
version: '0.6.4'
36+
version: '0.6.4',
3637
},
3738
{
38-
version: '0.6.8'
39+
version: '0.6.8',
3940
},
4041
{
41-
version: '0.5.12'
42+
version: '0.6.11',
43+
settings: {
44+
optimizer: {
45+
enabled: true,
46+
runs: 200,
47+
},
48+
},
4249
},
4350
{
4451
version: '0.7.3',
4552
settings: {
4653
optimizer: {
4754
enabled: true,
48-
runs: 200
49-
}
50-
}
51-
}
52-
]
55+
runs: 200,
56+
},
57+
},
58+
},
59+
{
60+
version: '0.7.6',
61+
settings: {
62+
optimizer: {
63+
enabled: true,
64+
runs: 200,
65+
},
66+
},
67+
},
68+
],
5369
},
5470
mocha: {
55-
timeout: 1000000
71+
timeout: 1000000,
5672
},
5773
gasReporter: {
5874
currency: 'USD',
5975
enabled: !!process.env.REPORT_GAS,
6076
excludeContracts: ['_mocks', '_external', 'uFragments'],
61-
coinmarketcap: process.env.COINMARKETCAP_API_KEY
77+
coinmarketcap: process.env.COINMARKETCAP_API_KEY,
6278
},
6379

6480
etherscan: {
65-
apiKey: process.env.ETHERSCAN_API_KEY
81+
apiKey: process.env.ETHERSCAN_API_KEY,
6682
},
6783

6884
bscscan: {
69-
apiKey: process.env.BSCSCAN_API_KEY
85+
apiKey: process.env.BSCSCAN_API_KEY,
7086
},
7187

7288
networks: {
7389
localGethBaseChain: {
74-
url: 'http://localhost:7545'
90+
url: 'http://localhost:7545',
7591
},
7692
localGethSatChain1: {
77-
url: 'http://localhost:7550'
93+
url: 'http://localhost:7550',
7894
},
7995
localGethSatChain2: {
80-
url: 'http://localhost:7555'
96+
url: 'http://localhost:7555',
8197
},
8298

8399
// meter-passport
84100
dev1RopstenBaseChain: {
85-
url: 'https://eth-ropsten.alchemyapi.io/v2/' + process.env.ALCHEMY_SECRET
101+
url: 'https://eth-ropsten.alchemyapi.io/v2/' + process.env.ALCHEMY_SECRET,
86102
},
87103
dev1BscTestnetSatChain: {
88-
url: 'https://data-seed-prebsc-1-s1.binance.org:8545'
104+
url: 'https://data-seed-prebsc-1-s1.binance.org:8545',
89105
},
90106
dev1MeterTestnetSatChain: {
91-
url: 'https://rpctest.meter.io'
107+
url: 'https://rpctest.meter.io',
92108
},
93109

94110
// matic
95111
dev2GoerliBaseChain: {
96-
url: 'https://eth-goerli.alchemyapi.io/v2/' + process.env.ALCHEMY_SECRET
112+
url: 'https://eth-goerli.alchemyapi.io/v2/' + process.env.ALCHEMY_SECRET,
97113
},
98114
dev2MumbaiSatChain: {
99-
url: 'https://polygon-mumbai.infura.io/v3/' + process.env.INFURA_SECRET
115+
url: 'https://polygon-mumbai.infura.io/v3/' + process.env.INFURA_SECRET,
116+
},
117+
118+
// arbitrum
119+
dev3RinkebyBaseChain: {
120+
url: 'https://eth-rinkeby.alchemyapi.io/v2/' + process.env.ALCHEMY_SECRET,
121+
},
122+
dev3RinkebyArbitrumSatChain: {
123+
url: 'https://rinkeby.arbitrum.io/rpc',
100124
},
101125

102126
// prod
103127
prodEthereumBaseChain: {
104-
url: 'https://mainnet.infura.io/v3/' + process.env.INFURA_SECRET
128+
url: 'https://mainnet.infura.io/v3/' + process.env.INFURA_SECRET,
105129
},
106130
prodBscSatChain: {
107-
url: 'https://bsc-dataseed.binance.org'
108-
},
109-
prodAvaxSatChain: {
110-
url: 'https://api.avax.network/ext/bc/C/rpc'
131+
url: 'https://bsc-dataseed.binance.org',
111132
},
112133
prodMeterSatChain: {
113-
url: 'https://rpc.meter.io'
134+
url: 'https://rpc.meter.io',
114135
},
115136
prodMaticSatChain: {
116-
url: 'https://polygon-mainnet.infura.io/v3/' + process.env.INFURA_SECRET
117-
}
118-
}
137+
url: 'https://polygon-mainnet.infura.io/v3/' + process.env.INFURA_SECRET,
138+
},
139+
},
119140
};

helpers/contracts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const upgradeProxyContract = async (
141141
proxy.address,
142142
Factory.connect(signer),
143143
);
144-
await sleep(180);
144+
await sleep(30);
145145
} else {
146146
console.log(`CAUTION: Skpping storage layout verification!`);
147147
const newImpl = await deployContract(

helpers/deploy/ampl.js

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
const { AMPL_BASE_RATE, AMPL_BASE_CPI } = require('../../sdk/ampleforth');
2+
3+
const {
4+
deployContract,
5+
deployProxyAdminContract,
6+
deployProxyContract,
7+
} = require('../contracts');
8+
9+
async function deployAMPLContracts(
10+
ethers,
11+
deployer,
12+
txParams = {},
13+
waitBlocks = 0,
14+
) {
15+
const deployerAddress = await deployer.getAddress();
16+
17+
const proxyAdmin = await deployProxyAdminContract(ethers, deployer, txParams);
18+
19+
const ampl = await deployProxyContract(
20+
ethers,
21+
'UFragments',
22+
proxyAdmin,
23+
deployer,
24+
[deployerAddress],
25+
{ initializer: 'initialize(address)' },
26+
txParams,
27+
waitBlocks,
28+
);
29+
30+
const rateOracle = await deployContract(
31+
ethers,
32+
'MedianOracle',
33+
deployer,
34+
[3600 * 24 * 365, 0, 1],
35+
txParams,
36+
waitBlocks,
37+
);
38+
await (
39+
await rateOracle.connect(deployer).addProvider(deployerAddress, txParams)
40+
).wait(waitBlocks);
41+
await (
42+
await rateOracle.connect(deployer).pushReport(AMPL_BASE_RATE, txParams)
43+
).wait(waitBlocks);
44+
45+
const cpiOracle = await deployContract(
46+
ethers,
47+
'MedianOracle',
48+
deployer,
49+
[3600 * 24 * 365, 0, 1],
50+
txParams,
51+
waitBlocks,
52+
);
53+
await (
54+
await cpiOracle.addProvider(deployerAddress, txParams)
55+
).wait(waitBlocks);
56+
await (
57+
await cpiOracle.connect(deployer).pushReport(AMPL_BASE_CPI, txParams)
58+
).wait(waitBlocks);
59+
60+
const policy = await deployProxyContract(
61+
ethers,
62+
'UFragmentsPolicy',
63+
proxyAdmin,
64+
deployer,
65+
[deployerAddress, ampl.address, AMPL_BASE_CPI.toString()],
66+
{
67+
initializer: 'initialize(address,address,uint256)',
68+
},
69+
txParams,
70+
waitBlocks,
71+
);
72+
await (
73+
await policy.connect(deployer).setMarketOracle(rateOracle.address, txParams)
74+
).wait(waitBlocks);
75+
await (
76+
await policy.connect(deployer).setCpiOracle(cpiOracle.address, txParams)
77+
).wait(waitBlocks);
78+
await (
79+
await policy.connect(deployer).setRebaseLag(1, txParams)
80+
).wait(waitBlocks);
81+
await (
82+
await policy
83+
.connect(deployer)
84+
.setRebaseTimingParameters(1, 0, 3600, txParams)
85+
).wait(waitBlocks);
86+
await (
87+
await ampl.connect(deployer).setMonetaryPolicy(policy.address, txParams)
88+
).wait(waitBlocks);
89+
90+
const orchestrator = await deployContract(
91+
ethers,
92+
'Orchestrator',
93+
deployer,
94+
[policy.address],
95+
txParams,
96+
waitBlocks,
97+
);
98+
await (
99+
await policy
100+
.connect(deployer)
101+
.setOrchestrator(orchestrator.address, txParams)
102+
).wait(waitBlocks);
103+
104+
return {
105+
proxyAdmin,
106+
ampl,
107+
policy,
108+
orchestrator,
109+
rateOracle,
110+
cpiOracle,
111+
};
112+
}
113+
114+
async function deployXCAmpleContracts(
115+
{ tokenSymbol, tokenName, globalAmpleforthEpoch, globalAMPLSupply },
116+
ethers,
117+
deployer,
118+
txParams = {},
119+
waitBlocks = 0,
120+
) {
121+
const proxyAdmin = await deployProxyAdminContract(ethers, deployer, txParams);
122+
123+
const xcAmple = await deployProxyContract(
124+
ethers,
125+
'XCAmple',
126+
proxyAdmin,
127+
deployer,
128+
[tokenName, tokenSymbol, globalAMPLSupply],
129+
{ initializer: 'initialize(string,string,uint256)' },
130+
txParams,
131+
waitBlocks,
132+
);
133+
134+
const xcAmpleController = await deployProxyContract(
135+
ethers,
136+
'XCAmpleController',
137+
proxyAdmin,
138+
deployer,
139+
[xcAmple.address, globalAmpleforthEpoch],
140+
{
141+
initializer: 'initialize(address,uint256)',
142+
},
143+
txParams,
144+
waitBlocks,
145+
);
146+
147+
const rebaseRelayer = await deployContract(
148+
ethers,
149+
'BatchTxExecutor',
150+
deployer,
151+
[],
152+
txParams,
153+
waitBlocks,
154+
);
155+
156+
await (
157+
await xcAmple.setController(xcAmpleController.address, txParams)
158+
).wait(waitBlocks);
159+
await (
160+
await xcAmpleController.setRebaseRelayer(rebaseRelayer.address, txParams)
161+
).wait(waitBlocks);
162+
163+
return { proxyAdmin, xcAmple, xcAmpleController, rebaseRelayer };
164+
}
165+
166+
module.exports = {
167+
deployAMPLContracts,
168+
deployXCAmpleContracts,
169+
};

0 commit comments

Comments
 (0)