aboutsummaryrefslogtreecommitdiffstats
path: root/packages/pipeline/src/data_sources/idex/index.ts
diff options
context:
space:
mode:
authorHsuan Lee <boczeratul@gmail.com>2019-03-06 17:46:50 +0800
committerHsuan Lee <boczeratul@gmail.com>2019-03-06 17:46:50 +0800
commit35703539d0f2b4ddb3b11d0de8c9634af59ab71f (patch)
treeae3731221dbbb3a6fa40060a8d916cfd3f738289 /packages/pipeline/src/data_sources/idex/index.ts
parent92a1fde5b1ecd81b07cdb5bf0c9c1cd3544799db (diff)
downloaddexon-0x-contracts-35703539d0f2b4ddb3b11d0de8c9634af59ab71f.tar
dexon-0x-contracts-35703539d0f2b4ddb3b11d0de8c9634af59ab71f.tar.gz
dexon-0x-contracts-35703539d0f2b4ddb3b11d0de8c9634af59ab71f.tar.bz2
dexon-0x-contracts-35703539d0f2b4ddb3b11d0de8c9634af59ab71f.tar.lz
dexon-0x-contracts-35703539d0f2b4ddb3b11d0de8c9634af59ab71f.tar.xz
dexon-0x-contracts-35703539d0f2b4ddb3b11d0de8c9634af59ab71f.tar.zst
dexon-0x-contracts-35703539d0f2b4ddb3b11d0de8c9634af59ab71f.zip
Deploy @dexon-foundation/0x.jsstable
Diffstat (limited to 'packages/pipeline/src/data_sources/idex/index.ts')
-rw-r--r--packages/pipeline/src/data_sources/idex/index.ts82
1 files changed, 0 insertions, 82 deletions
diff --git a/packages/pipeline/src/data_sources/idex/index.ts b/packages/pipeline/src/data_sources/idex/index.ts
deleted file mode 100644
index c1e53c08d..000000000
--- a/packages/pipeline/src/data_sources/idex/index.ts
+++ /dev/null
@@ -1,82 +0,0 @@
-import { fetchAsync } from '@0x/utils';
-
-const IDEX_BASE_URL = 'https://api.idex.market';
-const MARKETS_URL = `${IDEX_BASE_URL}/returnTicker`;
-const ORDERBOOK_URL = `${IDEX_BASE_URL}/returnOrderBook`;
-const MAX_ORDER_COUNT = 100; // Maximum based on https://github.com/AuroraDAO/idex-api-docs#returnorderbook
-export const IDEX_SOURCE = 'idex';
-
-export interface IdexMarketsResponse {
- [marketName: string]: IdexMarket;
-}
-
-export interface IdexMarket {
- last: string;
- high: string;
- low: string;
- lowestAsk: string;
- highestBid: string;
- percentChange: string;
- baseVolume: string;
- quoteVolume: string;
-}
-
-export interface IdexOrderbook {
- asks: IdexOrder[];
- bids: IdexOrder[];
-}
-
-export interface IdexOrder {
- price: string;
- amount: string;
- total: string;
- orderHash: string;
- params: IdexOrderParam;
-}
-
-export interface IdexOrderParam {
- tokenBuy: string;
- buySymbol: string;
- buyPrecision: number;
- amountBuy: string;
- tokenSell: string;
- sellSymbol: string;
- sellPrecision: number;
- amountSell: string;
- expires: number;
- nonce: number;
- user: string;
-}
-
-// tslint:disable:prefer-function-over-method
-// ^ Keep consistency with other sources and help logical organization
-export class IdexSource {
- /**
- * Call Idex API to find out which markets they are maintaining orderbooks for.
- */
- public async getMarketsAsync(): Promise<string[]> {
- const params = { method: 'POST' };
- const resp = await fetchAsync(MARKETS_URL, params);
- const respJson: IdexMarketsResponse = await resp.json();
- const markets: string[] = Object.keys(respJson);
- return markets;
- }
-
- /**
- * Retrieve orderbook from Idex API for a given market.
- * @param marketId String identifying the market we want data for. Eg. 'REP_AUG'
- */
- public async getMarketOrderbookAsync(marketId: string): Promise<IdexOrderbook> {
- const params = {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({
- market: marketId,
- count: MAX_ORDER_COUNT,
- }),
- };
- const resp = await fetchAsync(ORDERBOOK_URL, params);
- const respJson: IdexOrderbook = await resp.json();
- return respJson;
- }
-}