Skip to content

Commit

Permalink
Script to deploy Controller & Calculator (#387)
Browse files Browse the repository at this point in the history
* add deployController script

* Change marginvault to be one of the inputs

* Add script to deploy Calculator
  • Loading branch information
antoncoding committed Apr 27, 2021
1 parent 2a011e3 commit ff02efe
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scripts/deployCalculator.js
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)
}
}
33 changes: 33 additions & 0 deletions scripts/deployController.js
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)
}
}

0 comments on commit ff02efe

Please sign in to comment.