Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chainlink Two Step Pricer & Defender Cli Update #455

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions autotask/pricers-bot/build-script.js
Original file line number Diff line number Diff line change
@@ -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);
20 changes: 10 additions & 10 deletions autotask/pricers-bot/codebuild/base-asset/index.js

Large diffs are not rendered by default.

Loading