From 0be703ddd14c7ecc0ef933b6425b57277e47d1f1 Mon Sep 17 00:00:00 2001 From: Aleksandr Kraiz Date: Wed, 16 Nov 2022 15:22:11 +0400 Subject: [PATCH] Added new pairs type: futures --- package.json | 2 +- src/services/OrionAggregator/index.ts | 14 ++++++++++---- src/utils/toUpperCase.ts | 4 ++++ 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 src/utils/toUpperCase.ts diff --git a/package.json b/package.json index ee7e3cb..324220a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.15.15", + "version": "0.16.0-rc.0", "description": "Orion Protocol SDK", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", diff --git a/src/services/OrionAggregator/index.ts b/src/services/OrionAggregator/index.ts index ecf1169..07e4e73 100644 --- a/src/services/OrionAggregator/index.ts +++ b/src/services/OrionAggregator/index.ts @@ -14,6 +14,7 @@ import { pairConfigSchema } from './schemas'; import { aggregatedOrderbookSchema, exchangeOrderbookSchema, } from './schemas/aggregatedOrderbookSchema'; +import toUpperCase from '../../utils/toUpperCase'; class OrionAggregator { private readonly apiUrl: string; @@ -39,10 +40,15 @@ class OrionAggregator { this.getExchangeOrderbook = this.getExchangeOrderbook.bind(this); } - getPairsList = () => fetchWithValidation( - `${this.apiUrl}/api/v1/pairs/list`, - z.array(z.string()), - ); + getPairsList = (market: 'spot' | 'futures') => { + const url = new URL(`${this.apiUrl}/api/v1/pairs/list`); + url.searchParams.append('market', toUpperCase(market)); + + return fetchWithValidation( + url.toString(), + z.array(z.string()), + ); + }; getAggregatedOrderbook = (pair: string, depth = 20) => { const url = new URL(`${this.apiUrl}/api/v1/orderbook`); diff --git a/src/utils/toUpperCase.ts b/src/utils/toUpperCase.ts new file mode 100644 index 0000000..5615da8 --- /dev/null +++ b/src/utils/toUpperCase.ts @@ -0,0 +1,4 @@ +export default function toUpperCase(str: T): Uppercase { + // eslint-disable-next-line @typescript-eslint/consistent-type-assertions + return str.toUpperCase() as Uppercase; +}