-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script to deploy Controller & Calculator (#387)
* add deployController script * Change marginvault to be one of the inputs * Add script to deploy Calculator
- Loading branch information
1 parent
2a011e3
commit ff02efe
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const yargs = require('yargs') | ||
|
||
const MarginCalculator = artifacts.require('MarginCalculator.sol') | ||
|
||
module.exports = async function(callback) { | ||
try { | ||
const options = yargs | ||
.usage('Usage: --network <network> --gasPrice <gasPrice> --gas <gasLimit> --oracle <oracle>') | ||
.option('network', {describe: 'Network name', type: 'string', demandOption: true}) | ||
.option('oracle', {description: 'Oracle address', type: 'string', demandOption: true}) | ||
.option('gasPrice', {describe: 'Gas price in WEI', type: 'string', demandOption: false}) | ||
.option('gas', {describe: 'Gas Limit in WEI', type: 'string', demandOption: false}).argv | ||
|
||
console.log(`Deploying MarginCalculator contract on ${options.network} 🍕`) | ||
|
||
const tx = await MarginCalculator.new(options.oracle, {gasPrice: options.gasPrice, gas: options.gas}) | ||
|
||
console.log('MarginCalculator deployed! 🎉') | ||
console.log(`Transaction hash: ${tx.transactionHash}`) | ||
console.log(`Deployed contract address: ${tx.address}`) | ||
|
||
callback() | ||
} catch (err) { | ||
callback(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const yargs = require('yargs') | ||
|
||
const MarginVault = artifacts.require('MarginVault.sol') | ||
const Controller = artifacts.require('Controller.sol') | ||
|
||
module.exports = async function(callback) { | ||
try { | ||
const options = yargs | ||
.usage('Usage: --network <network> --gasPrice <gasPrice> --gas <gasLimit> --marginVault') | ||
.option('network', {describe: 'Network name', type: 'string', demandOption: true}) | ||
.option('marginVault', {description: 'Lib MarginVault address', type: 'string', demandOption: true}) | ||
.option('gasPrice', {describe: 'Gas price in WEI', type: 'string', demandOption: false}) | ||
.option('gas', {describe: 'Gas Limit in WEI', type: 'string', demandOption: false}).argv | ||
|
||
console.log(`Deploying Controller contract on ${options.network} 🍕`) | ||
|
||
const marginVault = await MarginVault.at(options.marginVault) | ||
await Controller.link(marginVault) | ||
console.log(`Linking MarginVault done`) | ||
|
||
// deploy controller | ||
|
||
const tx = await Controller.new({gasPrice: options.gasPrice, gas: options.gas}) | ||
|
||
console.log('Controller implementation deployed! 🎉') | ||
console.log(`Transaction hash: ${tx.transactionHash}`) | ||
console.log(`Deployed contract address: ${tx.address}`) | ||
|
||
callback() | ||
} catch (err) { | ||
callback(err) | ||
} | ||
} |