Skip to content

Commit

Permalink
Merge branch 'master' into dm-refund-bot
Browse files Browse the repository at this point in the history
  • Loading branch information
denalimarsh authored Jun 18, 2020
2 parents 2c9734a + 0d1bb34 commit 0096aa3
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
5 changes: 4 additions & 1 deletion oracle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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%)
Expand All @@ -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 ):
Expand Down
5 changes: 4 additions & 1 deletion oracle/example-env
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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"
5 changes: 3 additions & 2 deletions oracle/oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
1 change: 1 addition & 0 deletions scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
6 changes: 5 additions & 1 deletion scripts/oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, () => {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 0096aa3

Please sign in to comment.