Skip to content

Commit

Permalink
feat: ankerswap driver
Browse files Browse the repository at this point in the history
  • Loading branch information
sajcics authored and nickpater committed Aug 11, 2020
1 parent 4df8bb8 commit 68549ab
Show file tree
Hide file tree
Showing 3 changed files with 600 additions and 0 deletions.
31 changes: 31 additions & 0 deletions drivers/ankerswap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const Driver = require('../models/driver');
const request = require('../lib/request');
const Ticker = require('../models/ticker');
const { parseToFloat } = require('../lib/utils.js');

/**
* @memberof Driver
* @augments Driver
*/
class Ankerswap extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
// get base and quote data for tickers
const { data: tickers } = await request('https://api.ankerswap.com/api/v1/tickers');

return tickers.map((ticker) => new Ticker({
base: ticker.base_currency,
quote: ticker.target_currency,
high: parseToFloat(ticker.high),
low: parseToFloat(ticker.low),
close: parseToFloat(ticker.last_price),
baseVolume: parseToFloat(ticker.base_volume),
quoteVolume: parseToFloat(ticker.target_volume),
}));
}
}

module.exports = Ankerswap;
1 change: 1 addition & 0 deletions drivers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ exports.Allcoin = require('./allcoin');
exports.Altcointrader = require('./altcointrader');
exports.Altilly = require('./altilly');
exports.Altmarkets = require('./altmarkets');
exports.Ankerswap = require('./ankerswap');
exports.Atomars = require('./atomars');
exports.Bamboo = require('./bamboo');
exports.Bancor = require('./bancor');
Expand Down
Loading

0 comments on commit 68549ab

Please sign in to comment.