Skip to content

Commit

Permalink
feat: add support for Asteroid protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
nickpater committed Feb 5, 2024
1 parent a91ca12 commit 2c22709
Show file tree
Hide file tree
Showing 3 changed files with 488 additions and 0 deletions.
47 changes: 47 additions & 0 deletions drivers/asteroidprotocol.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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 Asteroidprotocol extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
const result = await request({
method: 'POST',
url: 'https://api.asteroidprotocol.io/v1/graphql',
json: {
query: `
query {
token(offset: 0, limit: 100, order_by: [{ volume_24_base: desc }], where: { volume_24_base: { _gt: 1000000 }}) {
transaction {
hash
}
name
ticker
last_price_base
volume_24_base
}
}
`,
},
});

return result.data.token.map((ticker) => new Ticker(({
base: ticker.ticker,
baseName: ticker.name,
baseReference: ticker.transaction.hash,
quote: 'ATOM',
quoteVolume: parseToFloat(ticker.volume_24_base) / 1000000,
close: parseToFloat(ticker.last_price_base) / 1000000,
})));
}
}

module.exports = Asteroidprotocol;
1 change: 1 addition & 0 deletions drivers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ exports.Aex = require('./aex');
exports.Altcointrader = require('./altcointrader');
exports.Apeswappolygon = require('./apeswappolygon');
exports.Ascendex = require('./ascendex');
exports.Asteroidprotocol = require('./asteroidprotocol');
exports.Balancer = require('./balancer');
exports.Balancerpolygon = require('./balancerpolygon');
exports.Bamboo = require('./bamboo');
Expand Down
Loading

0 comments on commit 2c22709

Please sign in to comment.