Skip to content

Commit

Permalink
Merge pull request #1006 from coinranking/feature/cr-2557-dex-listing…
Browse files Browse the repository at this point in the history
…-jupiter

feat: add Jupiter DEX
  • Loading branch information
wouthoekstra authored Mar 11, 2024
2 parents e96a30c + 645adc2 commit a849abf
Show file tree
Hide file tree
Showing 4 changed files with 73,477 additions and 2 deletions.
1 change: 1 addition & 0 deletions drivers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ exports.Indodax = require('./indodax');
exports.Indoex = require('./indoex');
exports.Iqfinex = require('./iqfinex');
exports.Itbit = require('./itbit');
exports.Jupiter = require('./jupiter');
exports.Kickex = require('./kickex');
exports.Kkex = require('./kkex');
exports.Korbit = require('./korbit');
Expand Down
32 changes: 32 additions & 0 deletions drivers/jupiter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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 Jupiter extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
const tickers = await request('https://stats.jup.ag/coingecko/tickers');

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

module.exports = Jupiter;
4 changes: 2 additions & 2 deletions tests/driver.int.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ driverNames.forEach((driverName) => {

test('Probably nothing is worth 10x BTC', () => {
btcTickers.forEach((ticker) => {
if (ticker.quote === 'BTC') {
if (ticker.quote === 'BTC' && !ticker.quoteReference) {
expect(ticker.close).toBeLessThan(10);
}

if (ticker.base === 'BTC') {
if (ticker.base === 'BTC' && !ticker.baseReference) {
expect(ticker.close).toBeGreaterThan(0.1);
}
});
Expand Down
Loading

0 comments on commit a849abf

Please sign in to comment.