Skip to content

Commit d279deb

Browse files
committed
arb deployment script
1 parent b6dbfdf commit d279deb

File tree

1 file changed

+216
-0
lines changed

1 file changed

+216
-0
lines changed

tasks/deploy/arbitrum.js

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
const {
2+
txTask,
3+
loadSignerSync,
4+
etherscanVerify,
5+
} = require('../../helpers/tasks');
6+
const { getEthersProvider } = require('../../helpers/utils');
7+
const {
8+
getDeployedContractInstance,
9+
readDeploymentData,
10+
writeDeploymentData,
11+
writeBulkDeploymentData,
12+
getCompiledContractFactory,
13+
} = require('../../helpers/contracts');
14+
15+
const {
16+
deployArbitrumBaseChainGatewayContracts,
17+
deployArbitrumSatelliteChainGatewayContracts,
18+
} = require('../../helpers/deploy');
19+
20+
txTask(
21+
'deploy:arbitrum_base_chain',
22+
'Deploys the chain gateway on the base chain',
23+
).setAction(async (args, hre) => {
24+
const txParams = { gasPrice: args.gasPrice, gasLimit: args.gasLimit };
25+
if (txParams.gasPrice == 0) {
26+
txParams.gasPrice = await hre.ethers.provider.getGasPrice();
27+
}
28+
const deployer = loadSignerSync(args, hre.ethers.provider);
29+
const deployerAddress = await deployer.getAddress();
30+
const chainAddresses = await readDeploymentData(hre.network.name);
31+
32+
console.log('------------------------------------------------------------');
33+
console.log('Deploying contracts on base-chain');
34+
console.log('Deployer:', deployerAddress);
35+
console.log(txParams);
36+
37+
const ampl = await getDeployedContractInstance(
38+
hre.network.name,
39+
'ampl',
40+
hre.ethers.provider,
41+
);
42+
43+
const policy = await getDeployedContractInstance(
44+
hre.network.name,
45+
'policy',
46+
hre.ethers.provider,
47+
);
48+
49+
const tokenVault = await getDeployedContractInstance(
50+
hre.network.name,
51+
'arbitrum/tokenVault',
52+
hre.ethers.provider,
53+
);
54+
55+
const { gateway } = await deployArbitrumBaseChainGatewayContracts(
56+
{
57+
ampl,
58+
policy,
59+
tokenVault,
60+
},
61+
hre.ethers,
62+
deployer,
63+
txParams,
64+
5,
65+
);
66+
67+
console.log('------------------------------------------------------------');
68+
console.log('Writing data to file');
69+
await writeDeploymentData(
70+
hre.network.name,
71+
'arbitrum/transferGateway',
72+
gateway,
73+
);
74+
await writeDeploymentData(
75+
hre.network.name,
76+
'arbitrum/rebaseGateway',
77+
gateway,
78+
);
79+
80+
console.log('------------------------------------------------------------');
81+
console.log('Verify on etherscan');
82+
await etherscanVerify(hre, gateway.address, [
83+
ampl.address,
84+
policy.address,
85+
tokenVault.address,
86+
]);
87+
});
88+
89+
txTask(
90+
'deploy:arbitrum_satellite_chain',
91+
'Deploys the chain gateway contract and connects it with arbitrum bridge and the cross-chain ample token',
92+
).setAction(async (args, hre) => {
93+
// NOTE: gas estimation is off on arbitrum
94+
// const txParams = { gasPrice: args.gasPrice, gasLimit: args.gasLimit };
95+
// if (txParams.gasPrice == 0) {
96+
// txParams.gasPrice = await hre.ethers.provider.getGasPrice();
97+
// }
98+
const txParams = {};
99+
const deployer = loadSignerSync(args, hre.ethers.provider);
100+
const deployerAddress = await deployer.getAddress();
101+
const chainAddresses = await readDeploymentData(hre.network.name);
102+
103+
console.log('------------------------------------------------------------');
104+
console.log('Deploying contracts on satellite-chain');
105+
console.log('Deployer:', deployerAddress);
106+
console.log(txParams);
107+
108+
const xcAmple = await getDeployedContractInstance(
109+
hre.network.name,
110+
'xcAmple',
111+
hre.ethers.provider,
112+
);
113+
114+
const xcAmpleController = await getDeployedContractInstance(
115+
hre.network.name,
116+
'xcAmpleController',
117+
hre.ethers.provider,
118+
);
119+
120+
const { gateway } = await deployArbitrumSatelliteChainGatewayContracts(
121+
{ xcAmple, xcAmpleController },
122+
hre.ethers,
123+
deployer,
124+
txParams,
125+
5,
126+
);
127+
128+
console.log('------------------------------------------------------------');
129+
console.log('Writing data to file');
130+
await writeDeploymentData(
131+
hre.network.name,
132+
'arbitrum/transferGateway',
133+
gateway,
134+
);
135+
await writeDeploymentData(
136+
hre.network.name,
137+
'arbitrum/rebaseGateway',
138+
gateway,
139+
);
140+
141+
console.log('------------------------------------------------------------');
142+
console.log('Verify on etherscan');
143+
await etherscanVerify(hre, gateway.address, [
144+
xcAmple.address,
145+
xcAmpleController.address,
146+
]);
147+
});
148+
149+
txTask('deploy:arbitrum_connection', 'Connects the two gateway contracts')
150+
.addParam('baseChainNetwork', 'The network name of the base chain network')
151+
.addParam(
152+
'satChainNetwork',
153+
'The network name of the satellite chain network',
154+
)
155+
.addParam('baseInbox', 'The address of the arbitrum inbox on the base chain')
156+
.addParam(
157+
'baseRouter',
158+
'The address of the arbitrum router contract on the base chain',
159+
)
160+
.addParam(
161+
'satRouter',
162+
'The address of the arbitrum router contract on the satellite chain',
163+
)
164+
.setAction(async (args, hre) => {
165+
const txParams = { gasPrice: args.gasPrice, gasLimit: args.gasLimit };
166+
if (txParams.gasPrice == 0) {
167+
txParams.gasPrice = await hre.ethers.provider.getGasPrice();
168+
}
169+
170+
const baseChainProvider = getEthersProvider(args.baseChainNetwork);
171+
const satChainProvider = getEthersProvider(args.satChainNetwork);
172+
173+
const baseChainSigner = loadSignerSync(args, baseChainProvider);
174+
const satChainSigner = loadSignerSync(args, satChainProvider);
175+
176+
const baseGateway = await getDeployedContractInstance(
177+
args.baseChainNetwork,
178+
'arbitrum/rebaseGateway',
179+
baseChainProvider,
180+
);
181+
const ampl = await getDeployedContractInstance(
182+
args.baseChainNetwork,
183+
'ampl',
184+
baseChainProvider,
185+
);
186+
187+
const satGateway = await getDeployedContractInstance(
188+
args.satChainNetwork,
189+
'arbitrum/rebaseGateway',
190+
satChainProvider,
191+
);
192+
const xcAmple = await getDeployedContractInstance(
193+
args.satChainNetwork,
194+
'xcAmple',
195+
satChainProvider,
196+
);
197+
198+
await (
199+
await baseGateway
200+
.connect(baseChainSigner)
201+
.initialize(
202+
args.baseInbox,
203+
args.baseRouter,
204+
xcAmple.address,
205+
satGateway.address,
206+
txParams,
207+
)
208+
).wait(2);
209+
210+
// NOTE: gas estimation is off on arbitrum
211+
await (
212+
await satGateway
213+
.connect(satChainSigner)
214+
.initialize(args.satRouter, ampl.address, baseGateway.address, {})
215+
).wait(2);
216+
});

0 commit comments

Comments
 (0)