diff --git a/autotask/pricers-bot/build-script.js b/autotask/pricers-bot/build-script.js index a60716d48..46b003652 100644 --- a/autotask/pricers-bot/build-script.js +++ b/autotask/pricers-bot/build-script.js @@ -50,12 +50,20 @@ async function removeExistingAsset (){ async function updateBotAsset (){ - // accepts 2 inputs - AssetAddress and BotKey - + // accepts 2 important inputs - AssetAddress and BotKey + // - AssetAddress + // - BotKey + // - CollateralAddress (optional) + // - StrikeAddress (optional) + // - isPut (true or false) - (optional) + // get new asset entry and the bot to be updated let assetAddress = process.env.npm_config_asset; let botKey = process.env.npm_config_bot; let forceOption = process.env.npm_config_force; + let collateralAddress = process.env.npm_config_collateral; + let strikeAddress = process.env.npm_config_strike; + let isPut = process.env.npm_config_isPut; //validate bot let botKeyExists = config.bots.hasOwnProperty(botKey); @@ -65,7 +73,7 @@ async function updateBotAsset (){ let connInfo = getConnectionInfoForBot(botKey); - await _newDerivedAsset(connInfo,assetAddress,forceOption) + await _newDerivedAsset(connInfo,assetAddress,collateralAddress, strikeAddress, isPut, forceOption) } @@ -87,7 +95,7 @@ function viewBot(){ // get existing assets var assetsInfo = _getAssetsFromFile(directoryPath); console.log("-------------------------- "+connInfo.name+" ------------------------------------"); - console.log(assetsInfo); + console.log(assetsInfo.filter(obj => { return obj.BotKey == botKey } )); console.log("-------------------------- "+connInfo.name+" ------------------------------------"); } @@ -240,6 +248,13 @@ async function _getUnderlyingInformationFromPricer(connInfo,pricerAddress){ const web3 = new Web3(connInfo.nodeUrl); const contractInstance = new web3.eth.Contract(abi, pricerAddress); + console.log(); + + if(!contractInstance.methods.hasOwnProperty('underlying')){ + console.log("Fetch underlying error: Seems the asset you are trying to add is not a Derived asset...") + return + } + await contractInstance.methods.underlying().call(function (err, res) { if (err) { console.log("An error occured while underlying address", err) @@ -405,7 +420,7 @@ async function _newBaseAsset(connInfo, assetAddress,collateralAddress){ } -async function _newDerivedAsset(connInfo,assetAddress,forceOption) { +async function _newDerivedAsset(connInfo,assetAddress, underlyingAddress, strikeAddress ,isPut ,forceOption) { //get pricer for asset var pricerAddress = await _getPricerForAsset(connInfo,assetAddress); diff --git a/autotask/pricers-bot/codebuild/base-asset/index.js b/autotask/pricers-bot/codebuild/base-asset/index.js index 5e1bfd9da..ace009a23 100644 --- a/autotask/pricers-bot/codebuild/base-asset/index.js +++ b/autotask/pricers-bot/codebuild/base-asset/index.js @@ -2,17 +2,17 @@ const { ethers } = require("ethers"); const { DefenderRelaySigner, DefenderRelayProvider } = require('defender-relay-client/lib/ethers'); -// Cli Gamma Sync Information = null performed sync using autoclient on Wed Feb 02 2022 12:37:16 GMT+0100 (West Africa Standard Time); +// Cli Gamma Sync Information = null performed sync using autoclient on Thu Mar 31 2022 14:30:53 GMT+0100 (West Africa Standard Time); -var AddressBookAbiString = '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"id","type":"bytes32"},{"indexed":false,"internalType":"address","name":"add","type":"address"}],"name":"AddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"id","type":"bytes32"},{"indexed":false,"internalType":"address","name":"proxy","type":"address"}],"name":"ProxyCreated","type":"event"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getOtokenImpl","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOtokenFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWhitelist","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMarginPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMarginCalculator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLiquidationManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_otokenImpl","type":"address"}],"name":"setOtokenImpl","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_otokenFactory","type":"address"}],"name":"setOtokenFactory","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_whitelist","type":"address"}],"name":"setWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_controller","type":"address"}],"name":"setController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_marginPool","type":"address"}],"name":"setMarginPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_marginCalculator","type":"address"}],"name":"setMarginCalculator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_liquidationManager","type":"address"}],"name":"setLiquidationManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_oracle","type":"address"}],"name":"setOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"getAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"},{"internalType":"address","name":"_address","type":"address"}],"name":"setAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"},{"internalType":"address","name":"_newAddress","type":"address"}],"name":"updateImpl","outputs":[],"stateMutability":"nonpayable","type":"function"}]'; -var OracleAbiString = '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newDisputer","type":"address"}],"name":"DisputerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"uint256","name":"expiryTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"disputedPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"disputeTimestamp","type":"uint256"}],"name":"ExpiryPriceDisputed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"uint256","name":"expirtyTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"onchainTimestamp","type":"uint256"}],"name":"ExpiryPriceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pricer","type":"address"},{"indexed":false,"internalType":"uint256","name":"disputePeriod","type":"uint256"}],"name":"PricerDisputePeriodUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pricer","type":"address"},{"indexed":false,"internalType":"uint256","name":"lockingPeriod","type":"uint256"}],"name":"PricerLockingPeriodUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"address","name":"pricer","type":"address"}],"name":"PricerUpdated","type":"event"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_expiryTimestamp","type":"uint256"}],"name":"getExpiryPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"getPricer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDisputer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_pricer","type":"address"}],"name":"getPricerLockingPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_pricer","type":"address"}],"name":"getPricerDisputePeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_expiryTimestamp","type":"uint256"}],"name":"isLockingPeriodOver","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_expiryTimestamp","type":"uint256"}],"name":"isDisputePeriodOver","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_pricer","type":"address"}],"name":"setAssetPricer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pricer","type":"address"},{"internalType":"uint256","name":"_lockingPeriod","type":"uint256"}],"name":"setLockingPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pricer","type":"address"},{"internalType":"uint256","name":"_disputePeriod","type":"uint256"}],"name":"setDisputePeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_disputer","type":"address"}],"name":"setDisputer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_expiryTimestamp","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"disputeExpiryPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_expiryTimestamp","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"setExpiryPrice","outputs":[],"stateMutability":"nonpayable","type":"function"}]'; -var ChainlinkPricerAbiString = '[{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_aggregator","type":"address"},{"internalType":"address","name":"_oracle","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"aggregator","outputs":[{"internalType":"contract AggregatorInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracle","outputs":[{"internalType":"contract OracleInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_expiryTimestamp","type":"uint256"},{"internalType":"uint80","name":"_roundId","type":"uint80"}],"name":"setExpiryPriceInOracle","outputs":[],"stateMutability":"nonpayable","type":"function"}]'; -var AggregatorInterfaceAbiString = '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"int256","name":"current","type":"int256"},{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"AnswerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":true,"internalType":"address","name":"startedBy","type":"address"},{"indexed":false,"internalType":"uint256","name":"startedAt","type":"uint256"}],"name":"NewRound","type":"event"},{"inputs":[],"name":"latestAnswer","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"roundId","type":"uint256"}],"name":"getAnswer","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"roundId","type":"uint256"}],"name":"getTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]'; +var AddressBookAbiString = '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"id","type":"bytes32"},{"indexed":true,"internalType":"address","name":"add","type":"address"}],"name":"AddressAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"id","type":"bytes32"},{"indexed":true,"internalType":"address","name":"proxy","type":"address"}],"name":"ProxyCreated","type":"event"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"getAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLiquidationManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMarginCalculator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMarginPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOtokenFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOtokenImpl","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWhitelist","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"},{"internalType":"address","name":"_address","type":"address"}],"name":"setAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_controller","type":"address"}],"name":"setController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_liquidationManager","type":"address"}],"name":"setLiquidationManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_marginCalculator","type":"address"}],"name":"setMarginCalculator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_marginPool","type":"address"}],"name":"setMarginPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_oracle","type":"address"}],"name":"setOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_otokenFactory","type":"address"}],"name":"setOtokenFactory","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_otokenImpl","type":"address"}],"name":"setOtokenImpl","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_whitelist","type":"address"}],"name":"setWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"},{"internalType":"address","name":"_newAddress","type":"address"}],"name":"updateImpl","outputs":[],"stateMutability":"nonpayable","type":"function"}]'; +var OracleAbiString = '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newDisputer","type":"address"}],"name":"DisputerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"uint256","name":"expiryTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"disputedPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"disputeTimestamp","type":"uint256"}],"name":"ExpiryPriceDisputed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"uint256","name":"expiryTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"onchainTimestamp","type":"uint256"}],"name":"ExpiryPriceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pricer","type":"address"},{"indexed":false,"internalType":"uint256","name":"disputePeriod","type":"uint256"}],"name":"PricerDisputePeriodUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pricer","type":"address"},{"indexed":false,"internalType":"uint256","name":"lockingPeriod","type":"uint256"}],"name":"PricerLockingPeriodUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"pricer","type":"address"}],"name":"PricerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"StablePriceUpdated","type":"event"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_expiryTimestamp","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"disputeExpiryPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"endMigration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint80","name":"_roundId","type":"uint80"}],"name":"getChainlinkRoundData","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDisputer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_expiryTimestamp","type":"uint256"}],"name":"getExpiryPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"getPricer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_pricer","type":"address"}],"name":"getPricerDisputePeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_pricer","type":"address"}],"name":"getPricerLockingPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_expiryTimestamp","type":"uint256"}],"name":"isDisputePeriodOver","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_expiryTimestamp","type":"uint256"}],"name":"isLockingPeriodOver","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256[]","name":"_expiries","type":"uint256[]"},{"internalType":"uint256[]","name":"_prices","type":"uint256[]"}],"name":"migrateOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_pricer","type":"address"}],"name":"setAssetPricer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pricer","type":"address"},{"internalType":"uint256","name":"_disputePeriod","type":"uint256"}],"name":"setDisputePeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_disputer","type":"address"}],"name":"setDisputer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_expiryTimestamp","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"setExpiryPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pricer","type":"address"},{"internalType":"uint256","name":"_lockingPeriod","type":"uint256"}],"name":"setLockingPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"setStablePrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]'; +var ChainlinkPricerAbiString = '[{"inputs":[{"internalType":"address","name":"_bot","type":"address"},{"internalType":"address","name":"_asset","type":"address"},{"internalType":"address","name":"_aggregator","type":"address"},{"internalType":"address","name":"_oracle","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"aggregator","outputs":[{"internalType":"contract AggregatorInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"aggregatorDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bot","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint80","name":"_roundId","type":"uint80"}],"name":"getHistoricalPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracle","outputs":[{"internalType":"contract OracleInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_expiryTimestamp","type":"uint256"},{"internalType":"uint80","name":"_roundId","type":"uint80"}],"name":"setExpiryPriceInOracle","outputs":[],"stateMutability":"nonpayable","type":"function"}]'; +var AggregatorInterfaceAbiString = '[{"inputs":[{"internalType":"address","name":"_aggregator","type":"address"},{"internalType":"address","name":"_accessController","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"int256","name":"current","type":"int256"},{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"updatedAt","type":"uint256"}],"name":"AnswerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":true,"internalType":"address","name":"startedBy","type":"address"},{"indexed":false,"internalType":"uint256","name":"startedAt","type":"uint256"}],"name":"NewRound","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"OwnershipTransferRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"accessController","outputs":[{"internalType":"contract AccessControllerInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"aggregator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_aggregator","type":"address"}],"name":"confirmAggregator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"description","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_roundId","type":"uint256"}],"name":"getAnswer","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint80","name":"_roundId","type":"uint80"}],"name":"getRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_roundId","type":"uint256"}],"name":"getTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestAnswer","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"phaseAggregators","outputs":[{"internalType":"contract AggregatorV2V3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"phaseId","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_aggregator","type":"address"}],"name":"proposeAggregator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"proposedAggregator","outputs":[{"internalType":"contract AggregatorV2V3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint80","name":"_roundId","type":"uint80"}],"name":"proposedGetRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proposedLatestRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_accessController","type":"address"}],"name":"setController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]'; -var pricerAddressString = '0xa0647D32deA8bf50bb4CC6d96A91F9F2bbE43EfD,0x908Fa5E6F8E997c32A15eBdBe7377a5a4321918C'; -var pricerAssetString = '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599,0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'; -var aggregatorAddressString = '0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c,0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419'; +var pricerAddressString = '0x17300f7e8F061B84EBd795D7A224e2875734b11B'; +var pricerAssetString = '0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB'; +var aggregatorAddressString = '0x976B3D034E162d8bD72D6b9C989d545b839003b0'; const AddressBookAbi = JSON.parse(AddressBookAbiString); @@ -23,8 +23,8 @@ const AggregatorInterfaceAbi = JSON.parse(AggregatorInterfaceAbiString); // Entrypoint for the Autotask exports.handler = async function(credentials) { // config - const relayerAddress = '0xfacb407914655562d6619b0048a612b1795df783'; // Relayer address - const addressbookAddress = '0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4'; // AddressBook module + const relayerAddress = '0x0ca7562e993341db1e435a27c9f56931306290a7'; // Relayer address + const addressbookAddress = '0xBCa124824326CF8aBc5E2E569FFf3A6f17110510'; // AddressBook module const pricerAddress = pricerAddressString.split(','); // [wbtc, weth, aave, uni, sushi, link, dpi] const pricerAsset = pricerAssetString.split(','); // [wbtc, weth, aave, uni, sushi, link, dpi ] const chainlinkAggregatorAddress = aggregatorAddressString.split(','); // [wbtc, weth, aave, uni, sushi, link, dpi] diff --git a/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/AddressBookAbi.json b/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/AddressBookAbi.json new file mode 100644 index 000000000..e646d2c2a --- /dev/null +++ b/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/AddressBookAbi.json @@ -0,0 +1,355 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "add", + "type": "address" + } + ], + "name": "AddressAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "proxy", + "type": "address" + } + ], + "name": "ProxyCreated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_key", + "type": "bytes32" + } + ], + "name": "getAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getController", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLiquidationManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMarginCalculator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMarginPool", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getOracle", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getOtokenFactory", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getOtokenImpl", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getWhitelist", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_key", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "setAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_controller", + "type": "address" + } + ], + "name": "setController", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_liquidationManager", + "type": "address" + } + ], + "name": "setLiquidationManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_marginCalculator", + "type": "address" + } + ], + "name": "setMarginCalculator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_marginPool", + "type": "address" + } + ], + "name": "setMarginPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_oracle", + "type": "address" + } + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_otokenFactory", + "type": "address" + } + ], + "name": "setOtokenFactory", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_otokenImpl", + "type": "address" + } + ], + "name": "setOtokenImpl", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_whitelist", + "type": "address" + } + ], + "name": "setWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_id", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "_newAddress", + "type": "address" + } + ], + "name": "updateImpl", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] \ No newline at end of file diff --git a/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/AggregatorInterfaceAbi.json b/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/AggregatorInterfaceAbi.json new file mode 100644 index 000000000..406cf9cbf --- /dev/null +++ b/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/AggregatorInterfaceAbi.json @@ -0,0 +1,509 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_aggregator", + "type": "address" + }, + { + "internalType": "address", + "name": "_accessController", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "int256", + "name": "current", + "type": "int256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "roundId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "updatedAt", + "type": "uint256" + } + ], + "name": "AnswerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "roundId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "startedBy", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "startedAt", + "type": "uint256" + } + ], + "name": "NewRound", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "OwnershipTransferRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessController", + "outputs": [ + { + "internalType": "contract AccessControllerInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "aggregator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_aggregator", + "type": "address" + } + ], + "name": "confirmAggregator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "description", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_roundId", + "type": "uint256" + } + ], + "name": "getAnswer", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint80", + "name": "_roundId", + "type": "uint80" + } + ], + "name": "getRoundData", + "outputs": [ + { + "internalType": "uint80", + "name": "roundId", + "type": "uint80" + }, + { + "internalType": "int256", + "name": "answer", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "startedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "updatedAt", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "answeredInRound", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_roundId", + "type": "uint256" + } + ], + "name": "getTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestAnswer", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestRound", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestRoundData", + "outputs": [ + { + "internalType": "uint80", + "name": "roundId", + "type": "uint80" + }, + { + "internalType": "int256", + "name": "answer", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "startedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "updatedAt", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "answeredInRound", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "latestTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "name": "phaseAggregators", + "outputs": [ + { + "internalType": "contract AggregatorV2V3Interface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "phaseId", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_aggregator", + "type": "address" + } + ], + "name": "proposeAggregator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "proposedAggregator", + "outputs": [ + { + "internalType": "contract AggregatorV2V3Interface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint80", + "name": "_roundId", + "type": "uint80" + } + ], + "name": "proposedGetRoundData", + "outputs": [ + { + "internalType": "uint80", + "name": "roundId", + "type": "uint80" + }, + { + "internalType": "int256", + "name": "answer", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "startedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "updatedAt", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "answeredInRound", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "proposedLatestRoundData", + "outputs": [ + { + "internalType": "uint80", + "name": "roundId", + "type": "uint80" + }, + { + "internalType": "int256", + "name": "answer", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "startedAt", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "updatedAt", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "answeredInRound", + "type": "uint80" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_accessController", + "type": "address" + } + ], + "name": "setController", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ] \ No newline at end of file diff --git a/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/Assets.json b/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/Assets.json new file mode 100644 index 000000000..841f58da8 --- /dev/null +++ b/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/Assets.json @@ -0,0 +1 @@ +[{"AssetAddress":"0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB","PricerAddress":"0x17300f7e8F061B84EBd795D7A224e2875734b11B","AggregatorAddress":"0x976B3D034E162d8bD72D6b9C989d545b839003b0","BotAddress":"0x0ca7562E993341db1e435a27c9f56931306290A7","AddressbookAddress":"0xBCa124824326CF8aBc5E2E569FFf3A6f17110510","AssetType":"Base Asset","BotKey":9}] \ No newline at end of file diff --git a/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/ChainlinkPricerAbi.json b/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/ChainlinkPricerAbi.json new file mode 100644 index 000000000..813491959 --- /dev/null +++ b/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/ChainlinkPricerAbi.json @@ -0,0 +1,148 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_bot", + "type": "address" + }, + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "address", + "name": "_aggregator", + "type": "address" + }, + { + "internalType": "address", + "name": "_oracle", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "aggregator", + "outputs": [ + { + "internalType": "contract AggregatorInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "aggregatorDecimals", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "asset", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bot", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint80", + "name": "_roundId", + "type": "uint80" + } + ], + "name": "getHistoricalPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract OracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_expiryTimestamp", + "type": "uint256" + }, + { + "internalType": "uint80", + "name": "_roundId", + "type": "uint80" + } + ], + "name": "setExpiryPriceInOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] \ No newline at end of file diff --git a/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/OracleAbi.json b/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/OracleAbi.json new file mode 100644 index 000000000..6b3ee01f3 --- /dev/null +++ b/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/OracleAbi.json @@ -0,0 +1,567 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newDisputer", + "type": "address" + } + ], + "name": "DisputerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "expiryTimestamp", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "disputedPrice", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newPrice", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "disputeTimestamp", + "type": "uint256" + } + ], + "name": "ExpiryPriceDisputed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "expiryTimestamp", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "price", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "onchainTimestamp", + "type": "uint256" + } + ], + "name": "ExpiryPriceUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pricer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "disputePeriod", + "type": "uint256" + } + ], + "name": "PricerDisputePeriodUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pricer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "lockingPeriod", + "type": "uint256" + } + ], + "name": "PricerLockingPeriodUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "pricer", + "type": "address" + } + ], + "name": "PricerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "price", + "type": "uint256" + } + ], + "name": "StablePriceUpdated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_expiryTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_price", + "type": "uint256" + } + ], + "name": "disputeExpiryPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "endMigration", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "uint80", + "name": "_roundId", + "type": "uint80" + } + ], + "name": "getChainlinkRoundData", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDisputer", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_expiryTimestamp", + "type": "uint256" + } + ], + "name": "getExpiryPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + } + ], + "name": "getPricer", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_pricer", + "type": "address" + } + ], + "name": "getPricerDisputePeriod", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_pricer", + "type": "address" + } + ], + "name": "getPricerLockingPeriod", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_expiryTimestamp", + "type": "uint256" + } + ], + "name": "isDisputePeriodOver", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_expiryTimestamp", + "type": "uint256" + } + ], + "name": "isLockingPeriodOver", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "_expiries", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "_prices", + "type": "uint256[]" + } + ], + "name": "migrateOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "address", + "name": "_pricer", + "type": "address" + } + ], + "name": "setAssetPricer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_pricer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_disputePeriod", + "type": "uint256" + } + ], + "name": "setDisputePeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_disputer", + "type": "address" + } + ], + "name": "setDisputer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_expiryTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_price", + "type": "uint256" + } + ], + "name": "setExpiryPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_pricer", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_lockingPeriod", + "type": "uint256" + } + ], + "name": "setLockingPeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_price", + "type": "uint256" + } + ], + "name": "setStablePrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] \ No newline at end of file diff --git a/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/WhitelistAbi.json b/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/WhitelistAbi.json new file mode 100644 index 000000000..d6fdbd1cc --- /dev/null +++ b/autotask/pricers-bot/codebuild/chains/avalanche_mainnet/WhitelistAbi.json @@ -0,0 +1,455 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_addressBook", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_callee", + "type": "address" + } + ], + "name": "CalleeBlacklisted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_callee", + "type": "address" + } + ], + "name": "CalleeWhitelisted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "collateral", + "type": "address" + } + ], + "name": "CollateralBlacklisted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "collateral", + "type": "address" + } + ], + "name": "CollateralWhitelisted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "otoken", + "type": "address" + } + ], + "name": "OtokenBlacklisted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "otoken", + "type": "address" + } + ], + "name": "OtokenWhitelisted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "productHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "underlying", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "strike", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isPut", + "type": "bool" + } + ], + "name": "ProductBlacklisted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "productHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "underlying", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "strike", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isPut", + "type": "bool" + } + ], + "name": "ProductWhitelisted", + "type": "event" + }, + { + "inputs": [], + "name": "addressBook", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_callee", + "type": "address" + } + ], + "name": "blacklistCallee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_collateral", + "type": "address" + } + ], + "name": "blacklistCollateral", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_otokenAddress", + "type": "address" + } + ], + "name": "blacklistOtoken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_underlying", + "type": "address" + }, + { + "internalType": "address", + "name": "_strike", + "type": "address" + }, + { + "internalType": "address", + "name": "_collateral", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isPut", + "type": "bool" + } + ], + "name": "blacklistProduct", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_callee", + "type": "address" + } + ], + "name": "isWhitelistedCallee", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_collateral", + "type": "address" + } + ], + "name": "isWhitelistedCollateral", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_otoken", + "type": "address" + } + ], + "name": "isWhitelistedOtoken", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_underlying", + "type": "address" + }, + { + "internalType": "address", + "name": "_strike", + "type": "address" + }, + { + "internalType": "address", + "name": "_collateral", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isPut", + "type": "bool" + } + ], + "name": "isWhitelistedProduct", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_callee", + "type": "address" + } + ], + "name": "whitelistCallee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_collateral", + "type": "address" + } + ], + "name": "whitelistCollateral", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_otokenAddress", + "type": "address" + } + ], + "name": "whitelistOtoken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_underlying", + "type": "address" + }, + { + "internalType": "address", + "name": "_strike", + "type": "address" + }, + { + "internalType": "address", + "name": "_collateral", + "type": "address" + }, + { + "internalType": "bool", + "name": "_isPut", + "type": "bool" + } + ], + "name": "whitelistProduct", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] \ No newline at end of file diff --git a/autotask/pricers-bot/codebuild/chains/mainnet/Assets.json b/autotask/pricers-bot/codebuild/chains/mainnet/Assets.json index 864991c2a..638c2f446 100644 --- a/autotask/pricers-bot/codebuild/chains/mainnet/Assets.json +++ b/autotask/pricers-bot/codebuild/chains/mainnet/Assets.json @@ -1 +1 @@ -[{"AssetAddress":"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599","PricerAddress":"0xa0647D32deA8bf50bb4CC6d96A91F9F2bbE43EfD","AggregatorAddress":"0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1},{"AssetAddress":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","PricerAddress":"0x908Fa5E6F8E997c32A15eBdBe7377a5a4321918C","AggregatorAddress":"0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1},{"AssetAddress":"0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9","PricerAddress":"0x3b43044cB8b0171290eB87c80b15d132b09e9E84","AggregatorAddress":"0x547a514d5e3769680Ce22B2361c10Ea13619e8a9","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1},{"AssetAddress":"0x1f9840a85d5af5bf1d1762f925bdaddc4201f984","PricerAddress":"0x0890E86F880ED85cf821A448e707D47715Dd4378","AggregatorAddress":"0x553303d460EE0afB37EdFf9bE42922D8FF63220e","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1},{"AssetAddress":"0x6b3595068778dd592e39a122f4f5a5cf09c90fe2","PricerAddress":"0xAB8724a8B7Aa145863382fE075bBC325145C1E6B","AggregatorAddress":"0xCc70F09A6CC17553b2E31954cD36E4A2d89501f7","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1},{"AssetAddress":"0x514910771af9ca656af840dff83e8264ecf986ca","PricerAddress":"0x2d483f9a49Dc31471f3bB50B8ebf097E3Ec06F8c","AggregatorAddress":"0x2c1d072e956AFFC0D435Cb7AC38EF18d24d9127c","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1},{"AssetAddress":"0x1494ca1f11d487c2bbe4543e90080aeba4ba3c2b","PricerAddress":"0x32485c33378A1a866c0Bd2085bF622Ab2784Cfef","AggregatorAddress":"0xD2A593BF7594aCE1faD597adb697b5645d5edDB2","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1},{"AssetAddress":"0x24129b935aff071c4f0554882c0d9573f4975fed","PricerAddress":"0x4c65680554C35c27DDDb2F276f95225953513401","UnderlyingAddress":"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599","BotAddress":"0xfacb407914655562d6619b0048a612b1795df783","AssetType":"Derived Asset","BotKey":2},{"AssetAddress":"0xa2761b0539374eb7af2155f76eb09864af075250","PricerAddress":"0x27a8ee0Eb39AEe580490da00ab60eCfAB2a02C40","UnderlyingAddress":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","BotAddress":"0xfacb407914655562d6619b0048a612b1795df783","AssetType":"Derived Asset","BotKey":4},{"AssetAddress":"0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0","PricerAddress":"0x4661951D252993AFa69b36bcc7Ba7da4a48813bF","UnderlyingAddress":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","BotAddress":"0xfacb407914655562d6619b0048a612b1795df783","AssetType":"Derived Asset","BotKey":5}] \ No newline at end of file +[{"AssetAddress":"0x2260fac5e5542a773aa44fbcfedf7c193bc2c599","PricerAddress":"0xa0647D32deA8bf50bb4CC6d96A91F9F2bbE43EfD","AggregatorAddress":"0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1},{"AssetAddress":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","PricerAddress":"0x908Fa5E6F8E997c32A15eBdBe7377a5a4321918C","AggregatorAddress":"0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1},{"AssetAddress":"0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9","PricerAddress":"0x3b43044cB8b0171290eB87c80b15d132b09e9E84","AggregatorAddress":"0x547a514d5e3769680Ce22B2361c10Ea13619e8a9","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1},{"AssetAddress":"0x1f9840a85d5af5bf1d1762f925bdaddc4201f984","PricerAddress":"0x0890E86F880ED85cf821A448e707D47715Dd4378","AggregatorAddress":"0x553303d460EE0afB37EdFf9bE42922D8FF63220e","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1},{"AssetAddress":"0x6b3595068778dd592e39a122f4f5a5cf09c90fe2","PricerAddress":"0xAB8724a8B7Aa145863382fE075bBC325145C1E6B","AggregatorAddress":"0xCc70F09A6CC17553b2E31954cD36E4A2d89501f7","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1},{"AssetAddress":"0x514910771af9ca656af840dff83e8264ecf986ca","PricerAddress":"0x2d483f9a49Dc31471f3bB50B8ebf097E3Ec06F8c","AggregatorAddress":"0x2c1d072e956AFFC0D435Cb7AC38EF18d24d9127c","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1},{"AssetAddress":"0x1494ca1f11d487c2bbe4543e90080aeba4ba3c2b","PricerAddress":"0x32485c33378A1a866c0Bd2085bF622Ab2784Cfef","AggregatorAddress":"0xD2A593BF7594aCE1faD597adb697b5645d5edDB2","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1},{"AssetAddress":"0x24129b935aff071c4f0554882c0d9573f4975fed","PricerAddress":"0x4c65680554C35c27DDDb2F276f95225953513401","UnderlyingAddress":"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599","BotAddress":"0xfacb407914655562d6619b0048a612b1795df783","AssetType":"Derived Asset","BotKey":2},{"AssetAddress":"0xa2761b0539374eb7af2155f76eb09864af075250","PricerAddress":"0x27a8ee0Eb39AEe580490da00ab60eCfAB2a02C40","UnderlyingAddress":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","BotAddress":"0xfacb407914655562d6619b0048a612b1795df783","AssetType":"Derived Asset","BotKey":4},{"AssetAddress":"0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0","PricerAddress":"0x4661951D252993AFa69b36bcc7Ba7da4a48813bF","UnderlyingAddress":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","BotAddress":"0xfacb407914655562d6619b0048a612b1795df783","AssetType":"Derived Asset","BotKey":5},{"AssetAddress":"0xbC396689893D065F41bc2C6EcbeE5e0085233447","PricerAddress":"0x733171b59Ed3839481cd0066076De2C3404EE66A","AggregatorAddress":"0x01cE1210Fe8153500F60f7131d63239373D7E26C","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1},{"AssetAddress":"0xaaaebe6fe48e54f431b0c390cfaf0b017d09d42d","PricerAddress":"0x1F89774f01A2786bccCFbA9AF92E53b0B43c743E","AggregatorAddress":"0x75FbD83b4bd51dEe765b2a01e8D3aa1B020F9d33","BotAddress":"0xfacb407914655562d6619b0048a612B1795dF783","AddressbookAddress":"0x1E31F2DCBad4dc572004Eae6355fB18F9615cBe4","AssetType":"Base Asset","BotKey":1}] \ No newline at end of file diff --git a/autotask/pricers-bot/defender-config.js b/autotask/pricers-bot/defender-config.js index eebe396e5..c78096745 100644 --- a/autotask/pricers-bot/defender-config.js +++ b/autotask/pricers-bot/defender-config.js @@ -24,6 +24,16 @@ module.exports = { blockchainExplorerApiKey: process.env.ETHERSCAN_API, nodeUrl:`https://mainnet.infura.io/v3/${infuraKey}` }, + avalanche_mainnet: { + oracleAddress: '0x108abfba5ad61bd61a930bfe73394558d60f0b10', + addressBookAddress: '0xBCa124824326CF8aBc5E2E569FFf3A6f17110510', + whitelistAddress: '0xe9963AFfc9a53e293c9bB547c52902071e6087c9', + strikeAddress: '0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664', + baseAssetDefaultBotAddress: '0x0ca7562e993341db1e435a27c9f56931306290a7', + blockchainExplorerApiUrl: `https://api.snowtrace.io/api?`, + blockchainExplorerApiKey: process.env.SNOWTRACE_API, + nodeUrl:`https://api.avax.network/ext/bc/C/rpc` + }, kovan: { oracleAddress: '0x32724C61e948892A906f5EB8892B1E7e6583ba1f', addressBookAddress: '0x8812f219f507e8cfe9d2f1e790164714c5e06a73', @@ -101,6 +111,15 @@ module.exports = { resourcePath: 'chains/mainnet', autoTaskId:'85bded19-a1ea-46ce-b24a-655acb495f4c', botKey: 8 + }, + 9: { + name: 'Chainlink Pricer bot : Avalanche Mainnet code', + chain: 'avalanche_mainnet', + type: enums.BaseAsset, + resourcePath: 'chains/avalanche_mainnet', + autoTaskId:'5d4312cc-6424-40cb-a1f7-67f94f36bab3', + botKey: 9 + } }, diff --git a/contracts/pricers/ChainlinkTwoStepPricer.sol b/contracts/pricers/ChainlinkTwoStepPricer.sol new file mode 100644 index 000000000..fc5e9579f --- /dev/null +++ b/contracts/pricers/ChainlinkTwoStepPricer.sol @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.6.10; +import {AggregatorInterface} from "../interfaces/AggregatorInterface.sol"; +import {OracleInterface} from "../interfaces/OracleInterface.sol"; +import {OpynPricerInterface} from "../interfaces/OpynPricerInterface.sol"; +import {SafeMath} from "../packages/oz/SafeMath.sol"; + +/** + * @notice A Pricer contract for one asset as reported by Chainlink + */ +contract ChainlinkTwoStepPricer is OpynPricerInterface { + using SafeMath for uint256; + /// @dev base decimals + uint256 internal constant BASE = 8; + /// @notice chainlink response decimals + uint256 public aggregatorDecimals; + /// @notice the opyn oracle address + OracleInterface public oracle; + /// @notice the aggregator for an asset + AggregatorInterface public aggregator; + /// @notice asset that this pricer will a get price for + address public asset; + /// @notice bot address that is allowed to call setExpiryPriceInOracle + address public bot; + /// @notice asset used to convert to USD + address public weth; + + /** + * @param _bot priveleged address that can call setExpiryPriceInOracle + * @param _asset asset that this pricer will get a price for + * @param _weth asset used to convert to USD + * @param _aggregator Chainlink aggregator contract for the asset + * @param _oracle Opyn Oracle address + */ + constructor( + address _bot, + address _asset, + address _weth, + address _aggregator, + address _oracle + ) public { + require(_bot != address(0), "ChainLinkPricer: Cannot set 0 address as bot"); + require(_oracle != address(0), "ChainLinkPricer: Cannot set 0 address as oracle"); + require(_aggregator != address(0), "ChainLinkPricer: Cannot set 0 address as aggregator"); + bot = _bot; + oracle = OracleInterface(_oracle); + aggregator = AggregatorInterface(_aggregator); + asset = _asset; + weth = _weth; + aggregatorDecimals = uint256(aggregator.decimals()); + } + + /** + * @notice set the expiry price in the oracle, can only be called by Bot address + * @dev a roundId must be provided to confirm price validity, which is the first Chainlink price provided after the expiryTimestamp + * @param _expiryTimestamp expiry to set a price for + * @param _roundId the first roundId after expiryTimestamp + */ + function setExpiryPriceInOracle(uint256 _expiryTimestamp, uint80 _roundId) external { + (, int256 priceInETH, , uint256 roundTimestamp, ) = aggregator.getRoundData(_roundId); + require(_expiryTimestamp <= roundTimestamp, "ChainLinkPricer: roundId not first after expiry"); + require(priceInETH >= 0, "ChainLinkPricer: invalid priceInETH"); + if (msg.sender != bot) { + bool isCorrectRoundId; + uint80 previousRoundId = uint80(uint256(_roundId).sub(1)); + while (!isCorrectRoundId) { + (, , , uint256 previousRoundTimestamp, ) = aggregator.getRoundData(previousRoundId); + if (previousRoundTimestamp == 0) { + require(previousRoundId > 0, "ChainLinkPricer: Invalid previousRoundId"); + previousRoundId = previousRoundId - 1; + } else if (previousRoundTimestamp > _expiryTimestamp) { + revert("ChainLinkPricer: previousRoundId not last before expiry"); + } else { + isCorrectRoundId = true; + } + } + } + (uint256 wethPriceExpiry, ) = oracle.getExpiryPrice(weth, _expiryTimestamp); + require(wethPriceExpiry > 0, "W5"); //error fix later + uint256 tokenUSDPrice = _tokenToUsdPrice(uint256(priceInETH), wethPriceExpiry); + oracle.setExpiryPrice(asset, _expiryTimestamp, tokenUSDPrice); + } + + /** + * @notice get the live price for the asset + * @dev overides the getPrice function in OpynPricerInterface + * @return price of the asset in USD, scaled by 1e8 + */ + function getPrice() external view override returns (uint256) { + (, int256 answer, , , ) = aggregator.latestRoundData(); + require(answer > 0, "ChainLinkPricer: price is lower than 0"); + // chainlink's answer is already 1e8 + uint256 wethPrice = oracle.getPrice(weth); + require(wethPrice > 0, "Underlying price is 0"); + return _tokenToUsdPrice(uint256(answer), wethPrice); + } + + function getHistoricalPrice(uint80) external view override returns (uint256, uint256) { + revert("GetHistoricalPrice has been deprecated"); + } + + /** + * @dev convert token's price in ether terms with the token to ETH exchange rate to usd terms + * @param _tokenPerEth token price in ETH, scaled to 1e18 + * @param _ethUsdPrice ETH price in USD, scaled to 1e8 + * @return price of 1 token in USD, scaled to 1e8 + */ + function _tokenToUsdPrice(uint256 _tokenPerEth, uint256 _ethUsdPrice) private pure returns (uint256) { + return _tokenPerEth.mul(_ethUsdPrice).div(1e18); + } +} diff --git a/package-lock.json b/package-lock.json index 9c27735f4..b03ea0336 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,7 +54,7 @@ "truffle": "^5.1.32", "truffle-assertions": "0.9.2", "truffle-contract-size": "^2.0.0", - "truffle-plugin-verify": "^0.5.2", + "truffle-plugin-verify": "^0.5.24", "truffle-typings": "^1.0.8", "ts-node": "8.5.4", "typechain": "^1.0.5", @@ -35423,30 +35423,31 @@ "dev": true }, "node_modules/truffle-plugin-verify": { - "version": "0.5.11", - "resolved": "https://registry.npmjs.org/truffle-plugin-verify/-/truffle-plugin-verify-0.5.11.tgz", - "integrity": "sha512-IL8DDsA3YCUQcrRXtarTEXoZJeb2Rlj8jwNjdiWWyDZ7r/EQZndJooorWo19qDpZf9s8ydpvTE/Bb/uyna6Zag==", + "version": "0.5.24", + "resolved": "https://registry.npmjs.org/truffle-plugin-verify/-/truffle-plugin-verify-0.5.24.tgz", + "integrity": "sha512-kDxZ8qv4iTr5AK6hCehW4Z9xVT+1cP0F/r1Xs1rNYQb+WcN3QQTxh1Uv+rOW92fpxcoOkIKF1zSS4lQ/pC7/XA==", "dev": true, "dependencies": { - "axios": "^0.21.1", + "axios": "^0.26.1", "cli-logger": "^0.5.40", "delay": "^5.0.0", - "querystring": "^0.2.1" + "querystring": "^0.2.1", + "tunnel": "0.0.6" } }, "node_modules/truffle-plugin-verify/node_modules/axios": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", - "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", "dev": true, "dependencies": { - "follow-redirects": "^1.10.0" + "follow-redirects": "^1.14.8" } }, "node_modules/truffle-plugin-verify/node_modules/follow-redirects": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.1.tgz", - "integrity": "sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg==", + "version": "1.14.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", + "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", "dev": true, "funding": [ { @@ -36173,6 +36174,15 @@ "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", "dev": true }, + "node_modules/tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", + "dev": true, + "engines": { + "node": ">=0.6.11 <=0.7.0 || >=0.7.3" + } + }, "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -68217,30 +68227,31 @@ } }, "truffle-plugin-verify": { - "version": "0.5.11", - "resolved": "https://registry.npmjs.org/truffle-plugin-verify/-/truffle-plugin-verify-0.5.11.tgz", - "integrity": "sha512-IL8DDsA3YCUQcrRXtarTEXoZJeb2Rlj8jwNjdiWWyDZ7r/EQZndJooorWo19qDpZf9s8ydpvTE/Bb/uyna6Zag==", + "version": "0.5.24", + "resolved": "https://registry.npmjs.org/truffle-plugin-verify/-/truffle-plugin-verify-0.5.24.tgz", + "integrity": "sha512-kDxZ8qv4iTr5AK6hCehW4Z9xVT+1cP0F/r1Xs1rNYQb+WcN3QQTxh1Uv+rOW92fpxcoOkIKF1zSS4lQ/pC7/XA==", "dev": true, "requires": { - "axios": "^0.21.1", + "axios": "^0.26.1", "cli-logger": "^0.5.40", "delay": "^5.0.0", - "querystring": "^0.2.1" + "querystring": "^0.2.1", + "tunnel": "0.0.6" }, "dependencies": { "axios": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", - "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", "dev": true, "requires": { - "follow-redirects": "^1.10.0" + "follow-redirects": "^1.14.8" } }, "follow-redirects": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.1.tgz", - "integrity": "sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg==", + "version": "1.14.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", + "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", "dev": true }, "querystring": { @@ -68751,6 +68762,12 @@ "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", "dev": true }, + "tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", + "dev": true + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", diff --git a/package.json b/package.json index a6d13ee6b..eaf826fac 100644 --- a/package.json +++ b/package.json @@ -139,7 +139,7 @@ "truffle": "^5.1.32", "truffle-assertions": "0.9.2", "truffle-contract-size": "^2.0.0", - "truffle-plugin-verify": "^0.5.2", + "truffle-plugin-verify": "^0.5.24", "truffle-typings": "^1.0.8", "ts-node": "8.5.4", "typechain": "^1.0.5", diff --git a/scripts/README.md b/scripts/README.md index 4761a1528..176bb85b0 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -38,6 +38,26 @@ Transaction hash: 0xebf12fc6603ee857bcabe1c0c6194XX82639a9888776f7ff6e83a409XXXX Deployed contract address: 0x669cC97687c792fc5369d7bdd38cXXXXXXXXXX ``` + +## ChainlinkTwoStep Pricer Deployment + +To deploy a new `ChainlinkTwoStepPricer.sol`, it is recommended to use the `deployChainlinkTwoStepPricer` truffle script inside the `scripts` folder. + +**Input** + +```sh +truffle exec scripts/deployChainlinkTwoStepPricer.js --network mainnet --bot 0xfacb407914655562d6619b0048a612B1795dF783 --asset 0xaaaebe6fe48e54f431b0c390cfaf0b017d09d42d --weth 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 --aggregator 0x75FbD83b4bd51dEe765b2a01e8D3aa1B020F9d33 --oracle 0x789cD7AB3742e23Ce0952F6Bc3Eb3A73A0E08833 --gasPrice 100000000000 +``` + +**Output** + +```sh +Deploying chainlink two step pricer contract on mainnet 🍕 +Chainlink two step pricer deployed! 🎉 +Transaction hash: 0x274331e13761c79a6afb53697637e3ffe866746ed57ca71f4ac9XXXXXXXXXX +Deployed contract address: 0x1F89774f01A2786bccCFbA9AFXXXXXXXXXX +``` + ## Permit Callee Deployment The `PermitCallee.sol` contract allow user to call `permit()` function through the Controller Call action. diff --git a/scripts/deployChainlinkTwoStepPricer.js b/scripts/deployChainlinkTwoStepPricer.js new file mode 100644 index 000000000..1d5362c83 --- /dev/null +++ b/scripts/deployChainlinkTwoStepPricer.js @@ -0,0 +1,35 @@ +const yargs = require('yargs') + +const ChainlinkTwoStepPricer = artifacts.require('ChainlinkTwoStepPricer.sol') + +module.exports = async function(callback) { + try { + const options = yargs + .usage( + 'Usage: --network --bot --asset --weth --aggregator --oracle --gasPrice --gasLimit ', + ) + .option('network', {describe: 'Network name', type: 'string', demandOption: true}) + .option('bot', {describe: 'Bot address', type: 'string', demandOption: true}) + .option('asset', {describe: 'Asset address', type: 'string', demandOption: true}) + .option('weth', {describe: 'Weth address', type: 'string', demandOption: true}) + .option('aggregator', {describe: 'Chainlink aggregator 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 chainlink two step pricer contract on ${options.network} 🍕`) + + const tx = await ChainlinkTwoStepPricer.new(options.bot, options.asset, options.weth, options.aggregator, options.oracle, { + gasPrice: options.gasPrice, + gas: options.gasLimit, + }) + + console.log('Chainlink two step pricer deployed! 🎉') + console.log(`Transaction hash: ${tx.transactionHash}`) + console.log(`Deployed contract address: ${tx.address}`) + + callback() + } catch (err) { + callback(err) + } +} diff --git a/test/unit-tests/chainlinkTwoStepPricer.test.ts b/test/unit-tests/chainlinkTwoStepPricer.test.ts new file mode 100644 index 000000000..033443f0b --- /dev/null +++ b/test/unit-tests/chainlinkTwoStepPricer.test.ts @@ -0,0 +1,183 @@ +import { + ChainLinkPricerInstance, + MockOracleInstance, + MockChainlinkAggregatorInstance, + MockERC20Instance, +} from '../../build/types/truffle-types' +import BigNumber from 'bignumber.js' + +import { createTokenAmount } from '../utils' +const { expectRevert, time } = require('@openzeppelin/test-helpers') + +const ChainlinkTwoStepPricer = artifacts.require('ChainLinkTwoStepPricer.sol') +const MockOracle = artifacts.require('MockOracle.sol') +const MockChainlinkAggregator = artifacts.require('MockChainlinkAggregator.sol') +const MockERC20 = artifacts.require('MockERC20.sol') + +// address(0) +const ZERO_ADDR = '0x0000000000000000000000000000000000000000' + +contract('ChainlinkTwoStepPricer', ([owner, bot, random]) => { + let celAggregator: MockChainlinkAggregatorInstance + let oracle: MockOracleInstance + let weth: MockERC20Instance + let cel: MockERC20Instance + // otoken + let pricer: ChainLinkPricerInstance + + before('Deployment', async () => { + // deploy mock contracts + oracle = await MockOracle.new({ from: owner }) + celAggregator = await MockChainlinkAggregator.new() + weth = await MockERC20.new('WETH', 'WETH', 18) + cel = await MockERC20.new('Celsius', 'Cel', 18) + // deploy pricer + pricer = await ChainlinkTwoStepPricer.new(bot, cel.address, weth.address, celAggregator.address, oracle.address) + }) + + describe('constructor', () => { + it('should set the config correctly', async () => { + const asset = await pricer.asset() + assert.equal(asset, cel.address) + const bot = await pricer.bot() + assert.equal(bot, bot) + const aggregator = await pricer.aggregator() + assert.equal(aggregator, celAggregator.address) + const oracleModule = await pricer.oracle() + assert.equal(oracleModule, oracle.address) + }) + it('should revert if initializing aggregator with 0 address', async () => { + await expectRevert( + ChainlinkTwoStepPricer.new(bot, cel.address, weth.address, ZERO_ADDR, celAggregator.address), + 'ChainLinkPricer: Cannot set 0 address as aggregator', + ) + }) + it('should revert if initializing oracle with 0 address', async () => { + await expectRevert( + ChainlinkTwoStepPricer.new(bot, cel.address, weth.address, oracle.address, ZERO_ADDR), + 'ChainLinkPricer: Cannot set 0 address as oracle', + ) + }) + it('should revert if initializing bot with 0 address', async () => { + await expectRevert( + ChainlinkTwoStepPricer.new(ZERO_ADDR, cel.address, weth.address, oracle.address, celAggregator.address), + 'ChainLinkPricer: Cannot set 0 address as bot', + ) + }) + }) + + describe('getPrice', () => { + // aggregator have price in 1e8 + // set asset/WETH i.e asset is Cel + const assetPrice = createTokenAmount(100, 18) + before('mock data in weth aggregator', async () => { + await celAggregator.setLatestAnswer(assetPrice) + + //set weth oracle price + const wethUSDPrice = createTokenAmount(300, 8) + await oracle.setStablePrice(weth.address, wethUSDPrice) + }) + it('should return the price in 1e8', async () => { + const price = await pricer.getPrice() + const expectedResult = createTokenAmount(30000, 8) + assert.equal(price.toString(), expectedResult.toString()) + }) + it('should return the new price after resetting answer in aggregator', async () => { + const newAssetPrice = new BigNumber(createTokenAmount(400, 18)) + await celAggregator.setLatestAnswer(newAssetPrice) + + const wethPrice = await oracle.getPrice(weth.address) + + const price = await pricer.getPrice() + const expectedResult = newAssetPrice.multipliedBy(wethPrice).div(10 ** 18) + assert.equal(price.toString(), expectedResult.toString()) + }) + it('should revert if price is lower than 0', async () => { + await celAggregator.setLatestAnswer(-1) + await expectRevert(pricer.getPrice(), 'ChainLinkPricer: price is lower than 0') + }) + }) + + describe('setExpiryPrice', () => { + // time order: t0, t1, t2, t3, t4 + let t0: number, t1: number, t2: number, t3: number, t4: number, celPriceP1: BigNumber, celPriceP2: BigNumber + + // p0 = price at t0 ... etc + const p0 = createTokenAmount(100, 18) + const p1 = createTokenAmount(150.333, 18) + const p2 = createTokenAmount(180, 18) + const p3 = createTokenAmount(200, 18) + const p4 = createTokenAmount(140, 18) + + before('setup history in aggregator', async () => { + // set t0, t1, t2, expiry, t3, t4 + t0 = (await time.latest()).toNumber() + // set round answers + await celAggregator.setRoundAnswer(0, p0) + await celAggregator.setRoundAnswer(1, p1) + await celAggregator.setRoundAnswer(2, p2) + await celAggregator.setRoundAnswer(3, p3) + await celAggregator.setRoundAnswer(4, p4) + + // set round timestamps + await celAggregator.setRoundTimestamp(0, t0) + t1 = t0 + 60 * 1 + await celAggregator.setRoundTimestamp(1, t1) + t2 = t0 + 60 * 2 + await celAggregator.setRoundTimestamp(2, t2) + t3 = t0 + 60 * 3 + await celAggregator.setRoundTimestamp(3, t3) + t4 = t0 + 60 * 4 + await celAggregator.setRoundTimestamp(4, t4) + + const wethPrice = await oracle.getPrice(weth.address) + celPriceP1 = new BigNumber(p1).multipliedBy(wethPrice).div(10 ** 18) + celPriceP2 = new BigNumber(p2).multipliedBy(wethPrice).div(10 ** 18) + }) + + it('bot should set the correct price to the oracle', async () => { + const expiryTimestamp = (t0 + t1) / 2 // between t0 and t1 + const roundId = 1 + + await pricer.setExpiryPriceInOracle(expiryTimestamp, roundId, { from: bot }) + + const priceFromOracle = await oracle.getExpiryPrice(cel.address, expiryTimestamp) + assert.equal(celPriceP1.toString(), priceFromOracle[0].toString()) + }) + + it('should revert if sender is not bot address and roundId is too old', async () => { + const expiryTimestamp = (t1 + t2) / 2 // between t1 and t2 + const roundId = 1 + await expectRevert( + pricer.setExpiryPriceInOracle(expiryTimestamp, roundId, { from: random }), + 'ChainLinkPricer: roundId not first after expiry', + ) + }) + + it('should revert if sender is not bot address and roundId is too late', async () => { + const expiryTimestamp = (t1 + t2) / 2 // between t1 and t2 + const roundId = 3 + await expectRevert( + pricer.setExpiryPriceInOracle(expiryTimestamp, roundId, { from: random }), + 'ChainLinkPricer: previousRoundId not last before expiry', + ) + }) + + it('anyone should be able to set prices', async () => { + const expiryTimestamp = (t1 + t2) / 2 // between t1 and t2 + const roundId = 2 + await pricer.setExpiryPriceInOracle(expiryTimestamp, roundId, { from: random }) + const priceFromOracle = await oracle.getExpiryPrice(cel.address, expiryTimestamp) + assert.equal(celPriceP2.toString(), priceFromOracle[0].toString()) + }) + + it('should revert if round ID is too late: price[roundId].timestamp < expiry', async () => { + const expiryTimestamp = (t1 + t2) / 2 // between t1 and t2 + const roundId = 1 + await expectRevert( + pricer.setExpiryPriceInOracle(expiryTimestamp, roundId, { from: bot }), + 'ChainLinkPricer: roundId not first after expiry', + ) + }) + }) +}) diff --git a/truffle-config.js b/truffle-config.js index eca765019..52a1878c5 100644 --- a/truffle-config.js +++ b/truffle-config.js @@ -64,7 +64,11 @@ module.exports = { }, avax: { provider: () => new HDWalletProvider(mnemonic, 'https://api.avax.network/ext/bc/C/rpc'), + chain_id: 43114, network_id: 1, + timeoutBlocks: 50, + skipDryRun: false, + gasPrice: 25000000000 }, fuji: { provider: () => new HDWalletProvider(mnemonic, 'https://api.avax-test.network/ext/bc/C/rpc'), @@ -89,7 +93,8 @@ module.exports = { plugins: ['solidity-coverage', 'truffle-contract-size', 'truffle-plugin-verify'], api_keys: { - etherscan: process.env.ETHERSCAN_API, + etherscan: process.env.ETHERSCAN_API, + snowtrace: process.env.SNOWTRACE_API, }, compilers: {