From 5b173859abbe2e17ee5fd03616aaf93566af63fc Mon Sep 17 00:00:00 2001 From: Ben Burns Date: Tue, 15 Feb 2022 17:58:31 -0500 Subject: [PATCH] task/deploySAvaxPricer Adding sAvax pricer deploy script --- contracts/pricers/SAvaxPricer.sol | 4 ++-- scripts/deploySAvaxPricer.js | 33 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 scripts/deploySAvaxPricer.js diff --git a/contracts/pricers/SAvaxPricer.sol b/contracts/pricers/SAvaxPricer.sol index ee5b4b262..6ec244f1e 100644 --- a/contracts/pricers/SAvaxPricer.sol +++ b/contracts/pricers/SAvaxPricer.sol @@ -17,7 +17,7 @@ import {SafeMath} from "../packages/oz/SafeMath.sol"; /** * @title SAvaxPricer - * @author Opyn Team + * @author Ben Burns (abwburns@gmail.com) * @notice A Pricer contract for a sAVAX token */ contract SAvaxPricer is OpynPricerInterface { @@ -80,7 +80,7 @@ contract SAvaxPricer is OpynPricerInterface { * @return price of 1 sAVAX in USD, scaled by 1e8 */ function _underlyingPriceToSAvaxPrice(uint256 _underlyingPrice) private view returns (uint256) { - // Passing 1e18 to getPooledAvaxByShares() gives us the sAVAX price per AVAX + // Passing 1e18 to getPooledAvaxByShares() gives us the number of AVAX per sAVAX. uint256 sAvaxPerAvax = sAVAX.getPooledAvaxByShares(1e18); return sAvaxPerAvax.mul(_underlyingPrice).div(1e18); } diff --git a/scripts/deploySAvaxPricer.js b/scripts/deploySAvaxPricer.js new file mode 100644 index 000000000..3e8219f56 --- /dev/null +++ b/scripts/deploySAvaxPricer.js @@ -0,0 +1,33 @@ +const yargs = require('yargs') + +const SAvaxPricer = artifacts.require('SAvaxPricer.sol') + +module.exports = async function (callback) { + try { + const options = yargs + .usage( + 'Usage: --network --sAvax --underlying --oracle --gasPrice --gasLimit ', + ) + .option('network', { describe: 'Network name', type: 'string', demandOption: true }) + .option('sAvax', { describe: 'sAvax address', type: 'string', demandOption: true }) + .option('underlying', { describe: 'Underlying address', type: 'string', demandOption: true }) + .option('oracle', { describe: 'Oracle module address', type: 'string', demandOption: true }) + .option('gasPrice', { describe: 'Gas price in WEI', type: 'string', demandOption: false }) + .option('gasLimit', { describe: 'Gas Limit in WEI', type: 'string', demandOption: false }).argv + + console.log(`Deploying sAvax pricer contract to ${options.network} 🍕`) + + const tx = await SAvaxPricer.new(options.sAvax, options.underlying, options.oracle, { + gasPrice: options.gasPrice, + gas: options.gasLimit, + }) + + console.log('sAvax pricer deployed! 🎉') + console.log(`Transaction hash: ${tx.transactionHash}`) + console.log(`Deployed contract address: ${tx.address}`) + + callback() + } catch (err) { + callback(err) + } +}