-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task/deploySAvaxPricer Adding sAvax pricer deploy script
- Loading branch information
Showing
2 changed files
with
35 additions
and
2 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 |
---|---|---|
|
@@ -17,7 +17,7 @@ import {SafeMath} from "../packages/oz/SafeMath.sol"; | |
|
||
/** | ||
* @title SAvaxPricer | ||
* @author Opyn Team | ||
* @author Ben Burns ([email protected]) | ||
* @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); | ||
} | ||
|
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 SAvaxPricer = artifacts.require('SAvaxPricer.sol') | ||
|
||
module.exports = async function (callback) { | ||
try { | ||
const options = yargs | ||
.usage( | ||
'Usage: --network <network> --sAvax <sAvax> --underlying <underlying> --oracle <oracle> --gasPrice <gasPrice> --gasLimit <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) | ||
} | ||
} |