@melonproject/exchange-aggregator
TypeScript icon, indicating that this package has built-in type declarations

0.1.20 • Public • Published

Exchange aggregator

Installation

# With yarn
yarn add @melonproject/exchange-aggregator

# With npm
npm install @melonproject/exchange-aggregator

Usage example

Please note, that not all asset pairs are available on all exchanges.

import { createToken } from '@melonproject/token-math';
import { Network, exchanges, aggregateOrders, createOrderbook } from '@melonproject/exchange-aggregator';

const options = {
  network: Network.MAINNET,
  pair: {
    // The token pair is used for constructing the proper
    // requests (e.g. endpoint urls) and calculations in
    // token-math.
    base: createToken('ZRX', undefined, 18),
    quote: createToken('WETH', undefined, 18),
  },
};

const environment = constructEnvironment({
  endpoint: 'ws://localhost:8545',
});

const promises = await Promise.all([
  exchanges.radarrelay.fetch(options),
  // Some exchanges require extra configuration.
  exchanges.oasisdex.fetch({
    ...options,
    environment,
  }),
]);

// Concatenate the api responses into a single array.
const orders = [].concat(...promises);
// Aggregate all orders into a sorted orderbook with
// cummulative volume information.
const orderbook = createOrderbook(options, orders);

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.200latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.200
0.1.190
2.0.0-alpha20
2.0.0-alpha10
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00
0.1.180
0.1.170
0.1.160
0.1.150
0.1.140
0.1.130
0.1.120
0.1.110
0.1.101
0.1.90
0.1.80
0.1.70
0.1.60
0.1.50
0.1.40
0.1.30
0.1.20
0.1.10
0.1.00
0.0.120
0.0.110
0.0.100
0.0.90
0.0.80
0.0.70
0.0.60
0.0.50
0.0.40
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i @melonproject/exchange-aggregator

Weekly Downloads

1

Version

0.1.20

License

GPL-3.0

Unpacked Size

66.2 kB

Total Files

81

Last publish

Collaborators

  • yogivan
  • fubhy