-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.js
56 lines (43 loc) · 2.46 KB
/
deploy.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
require('dotenv').config();
const process = require('process');
const ethers = require('ethers');
const RocketArbitrumPriceMessenger = require('./out/RocketArbitrumPriceMessenger.sol/RocketArbitrumPriceMessenger.json');
const RocketArbitrumPriceOracle = require('./out/RocketArbitrumPriceOracle.sol/RocketArbitrumPriceOracle.json');
const RocketBalancerRateProvider = require('./out/RocketBalancerRateProvider.sol/RocketBalancerRateProvider.json');
const arbitrumProvider = new ethers.providers.JsonRpcProvider(process.env.ARBITRUM_RPC);
const arbitrumWallet = ethers.Wallet.fromMnemonic(process.env.ARBITRUM_MNEMONIC).connect(arbitrumProvider);
const ethereumProvider = new ethers.providers.JsonRpcProvider(process.env.ETHEREUM_RPC);
const ethereumWallet = ethers.Wallet.fromMnemonic(process.env.ETHEREUM_MNEMONIC).connect(ethereumProvider);
const ethTxOverrides = {
maxFeePerGas: ethers.utils.parseUnits('35', 'gwei'),
maxPriorityFeePerGas: ethers.utils.parseUnits('1.5', 'gwei'),
}
async function deploy() {
console.log(`Ethereum deployer address: ${ethereumWallet.address}`);
console.log(`Arbitrum deployer address: ${arbitrumWallet.address}`);
// Create factories
const messengerFactory = new ethers.ContractFactory(RocketArbitrumPriceMessenger.abi,
RocketArbitrumPriceMessenger.bytecode.object).connect(ethereumWallet);
const oracleFactory = new ethers.ContractFactory(RocketArbitrumPriceOracle.abi,
RocketArbitrumPriceOracle.bytecode.object).connect(arbitrumWallet);
const balancerProviderFactory = new ethers.ContractFactory(RocketBalancerRateProvider.abi,
RocketBalancerRateProvider.bytecode.object).connect(arbitrumWallet);
// Deploy
console.log('Deploying messenger');
const messenger = await messengerFactory.deploy(process.env.ROCKET_STORAGE, process.env.ARBITRUM_INBOX, ethTxOverrides)
console.log(`Messenger address: ${messenger.address}`);
console.log('Deploying oracle');
const oracle = await oracleFactory.deploy();
console.log(`Oracle address: ${oracle.address}`);
// Setup tunnel
console.log('Setting up permission');
await messenger.updateL2Target(oracle.address, ethTxOverrides);
await oracle.setOwner(messenger.address);
console.log('Permissions set.');
// Deploy balancer rate provider wrapper
console.log('Deploying balancer wrapper')
const balancerWrapper = await balancerProviderFactory.deploy(oracle.address);
console.log(`Balancer wrapper address: ${balancerWrapper.address}`);
process.exit(0);
}
deploy();