diff --git a/oracle/README.md b/oracle/README.md index 25b6ae2..1f425be 100644 --- a/oracle/README.md +++ b/oracle/README.md @@ -37,7 +37,7 @@ CRONTAB="* * * * *" # bip39 mnemonic of oracle MNEMONIC="secret words go here" -# List of markets the oracle will post prices for. See pricefeed parameters for the list of active markets. \\TODO add "all" method for next version +# List of markets the oracle will post prices for. See pricefeed parameters for the list of active markets. MARKET_IDS="bnb:usd,bnb:usd:30" # percentage deviation from previous price needed to trigger a new price - (example 0.5%) @@ -49,6 +49,9 @@ EXPIRY="14400" # how long (in seconds) before the oracle will consider a price expiring and post a new price, regardless of the value of deviation. # for example, if this is set to 600, the oracle will post a price any time the current posted price is expiring in less than 600 seconds. EXPIRY_THRESHOLD="300" + +# if the oracle should use the legacy HD path for kava (118). Setting to "true" will use 118, false will use 459 +LEGACY_HD_PATH="false" ``` Setup a `systemd` file to run the oracle process. An example with user `ubuntu` is as follows (note that the `nodejs` process is at `/usr/bin/nodejs`, this may be different depending on how you install node ): diff --git a/oracle/example-env b/oracle/example-env index ad1f2e1..8eaf0dc 100644 --- a/oracle/example-env +++ b/oracle/example-env @@ -21,4 +21,7 @@ EXPIRY="14400" # how long (in seconds) before the oracle will consider a price expiring and post a new price, regardless of the value of deviation. # for example, if this is set to 600, the oracle will post a price any time the current posted price is expiring in less than 600 seconds. -EXPIRY_THRESHOLD="300" \ No newline at end of file +EXPIRY_THRESHOLD="300" + +# if the oracle should use the legacy HD path for kava (118). Setting to "true" will use 118, false will use 459 +LEGACY_HD_PATH="false" \ No newline at end of file diff --git a/oracle/oracle.js b/oracle/oracle.js index 01b4993..2c4cb4d 100644 --- a/oracle/oracle.js +++ b/oracle/oracle.js @@ -44,9 +44,10 @@ class PriceOracle { * Initialize the Kava client * @param {String} lcdURL api endpoint for Kava's rest-server * @param {String} mnemonic Kava address mnemonic + * @param {Boolean} legacyHDPath * @return {Promise} */ - async initClient(lcdURL, mnemonic) { + async initClient(lcdURL, mnemonic, legacyHDPath=false) { if (!lcdURL) { throw new Error("chain's rest-server url is required"); } @@ -56,7 +57,7 @@ class PriceOracle { // Initiate and set Kava client this.client = new kava.KavaClient(lcdURL); - this.client.setWallet(mnemonic); + this.client.setWallet(mnemonic, '', legacyHDPath); this.client.setBroadcastMode('sync'); try { await this.client.initChain(); diff --git a/package.json b/package.json index 74c9598..47fbc52 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@kava-labs/kava-tools", "description": "Tools for interacting with the Kava blockchain", - "version": "0.1.3", + "version": "0.1.6", "license": "Apache-2.0", "main": "index.js", "author": "Kava Labs", diff --git a/scripts/config.js b/scripts/config.js index 39adc41..a807f7d 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -12,4 +12,5 @@ module.exports = { forward_bid_margin: process.env.FORWARD_BID_MARGIN, reverse_bid_margin: process.env.REVERSE_BID_MARGIN, crontab: process.env.CRONTAB, + legacy_hd_path: process.env.LEGACY_HD_PATH }; diff --git a/scripts/oracle.js b/scripts/oracle.js index ae9a98f..993e563 100644 --- a/scripts/oracle.js +++ b/scripts/oracle.js @@ -10,10 +10,14 @@ var main = async () => { const expiry = process.env.EXPIRY; const expiryThreshold = process.env.EXPIRY_THRESHOLD; const deviation = process.env.DEVIATION; + let legacyHDPath = false + if (process.env.LEGACY_HD_PATH === 'true') { + legacyHDPath = true + } // Initiate price oracle oracle = new PriceOracle(marketIDs, expiry, expiryThreshold, deviation); - await oracle.initClient(lcdURL, mnemonic); + await oracle.initClient(lcdURL, mnemonic, legacyHDPath); // Start cron job cron.schedule(process.env.CRONTAB, () => { diff --git a/yarn.lock b/yarn.lock index 2430c65..3545185 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,10 @@ # yarn lockfile v1 -"@kava-labs/javascript-sdk@^2.0.0-beta.4": - version "2.0.0-beta.4" - resolved "https://registry.yarnpkg.com/@kava-labs/javascript-sdk/-/javascript-sdk-2.0.0-beta.4.tgz#0740d46cb68c959870a1fe81030ca108183bf783" - integrity sha512-tuJvxYnlnF6G35HUNmgYZgtFsgDAqFZdZREWCkwjhSAFC2DwxEfPQw2mLiVd1qCJASkFkrt1eShxlSfKnYobCQ== +"@kava-labs/javascript-sdk@^2.0.0-beta.6": + version "2.0.0-beta.6" + resolved "https://registry.yarnpkg.com/@kava-labs/javascript-sdk/-/javascript-sdk-2.0.0-beta.6.tgz#d3677c246a70f7ed7e8af3b28b0b96cd798eff41" + integrity sha512-OvXSAuJ5inHLWJ++8mZIdBs5UNKooixPg48rFPJ9Y2r1wYQcfDQsnr5Rbs+ROKkmiC0RdYuRo4/pjEXcA8Jrug== dependencies: "@kava-labs/sig" "^0.1.0" axios "^0.19.2"