Added new pairs type: futures

This commit is contained in:
Aleksandr Kraiz
2022-11-16 15:22:11 +04:00
committed by Demid
parent e4f8778b2d
commit c252e11d60
2 changed files with 11 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.15.25",
"version": "0.16.0-rc.0",
"description": "Orion Protocol SDK",
"main": "./lib/esm/index.js",
"module": "./lib/esm/index.js",

View File

@@ -15,6 +15,7 @@ import {
aggregatedOrderbookSchema, exchangeOrderbookSchema,
} from './schemas/aggregatedOrderbookSchema';
import networkCodes from '../../constants/networkCodes';
import toUpperCase from '../../utils/toUpperCase';
class OrionAggregator {
private readonly apiUrl: string;
@@ -40,10 +41,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`);