Skip to content

Commit

Permalink
feat: add Icpswap
Browse files Browse the repository at this point in the history
  • Loading branch information
wouthoekstra committed Mar 26, 2024
1 parent a0a2443 commit e0a9c6d
Show file tree
Hide file tree
Showing 3 changed files with 11,617 additions and 0 deletions.
40 changes: 40 additions & 0 deletions drivers/icpswap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const Driver = require('../models/driver');
const request = require('../lib/request');
const Ticker = require('../models/ticker');
const { parseToFloat } = require('../lib/utils');

/**
* @memberof Driver
* @augments Driver
*/
class Icpswap extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
const markets = await request('https://uvevg-iyaaa-aaaak-ac27q-cai.raw.ic0.app/tickers');

return Object.keys(markets).flatMap((market) => {
const ticker = markets[market];
const close = parseToFloat(ticker.last_price);
const baseVolume = parseToFloat(ticker.base_volume_24H);
const quoteVolume = parseToFloat(ticker.target_volume_24H);

if (!close) return [];
if (!baseVolume && !quoteVolume) return [];

return new Ticker({
base: ticker.base_currency,
quote: ticker.target_currency,
baseReference: ticker.base_id,
quoteReference: ticker.target_id,
close,
baseVolume: parseToFloat(ticker.base_volume_24H),
quoteVolume: parseToFloat(ticker.target_volume_24H),
});
});
}
}

module.exports = Icpswap;
1 change: 1 addition & 0 deletions drivers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ exports.Graviex = require('./graviex');
exports.Hitbtc = require('./hitbtc');
exports.Honeyswap = require('./honeyswap');
exports.Huobiglobal = require('./huobiglobal');
exports.Icpswap = require('./icpswap');
exports.Idax = require('./idax');
exports.Idex = require('./idex');
exports.Independentreserve = require('./independentreserve');
Expand Down
Loading

0 comments on commit e0a9c6d

Please sign in to comment.