Merge branch 'main' into futures_list

This commit is contained in:
Demid
2022-12-27 11:33:01 +03:00
3 changed files with 23 additions and 3 deletions

View File

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

View File

@@ -12,7 +12,7 @@ import { atomicSwapHistorySchema } from './schemas/atomicSwapHistorySchema';
import { Exchange, SignedCancelOrderRequest, SignedOrder } from '../../types';
import { pairConfigSchema } from './schemas';
import {
aggregatedOrderbookSchema, exchangeOrderbookSchema,
aggregatedOrderbookSchema, exchangeOrderbookSchema, poolReservesSchema,
} from './schemas/aggregatedOrderbookSchema';
import networkCodes from '../../constants/networkCodes';
import toUpperCase from '../../utils/toUpperCase';
@@ -39,6 +39,7 @@ class OrionAggregator {
this.getLockedBalance = this.getLockedBalance.bind(this);
this.getAggregatedOrderbook = this.getAggregatedOrderbook.bind(this);
this.getExchangeOrderbook = this.getExchangeOrderbook.bind(this);
this.getPoolReserves = this.getPoolReserves.bind(this);
}
getPairsList = (market: 'spot' | 'futures') => {
@@ -65,7 +66,7 @@ class OrionAggregator {
getExchangeOrderbook = (
pair: string,
exchange: string,
exchange: Exchange,
depth = 20,
filterByBrokerBalances: boolean | null = null,
) => {
@@ -95,6 +96,19 @@ class OrionAggregator {
);
}
getPoolReserves = (
pair: string,
exchange: Exchange,
) => {
const url = new URL(`${this.apiUrl}/api/v1/pools/reserves/${exchange}/${pair}`);
return fetchWithValidation(
url.toString(),
poolReservesSchema,
undefined,
errorSchema,
);
};
getPairConfig = (assetPair: string) => fetchWithValidation(
`${this.apiUrl}/api/v1/pairs/exchangeInfo/${assetPair}`,
pairConfigSchema,

View File

@@ -23,3 +23,9 @@ export const exchangeOrderbookSchema = z.object({
asks: z.array(orderbookElementSchema),
bids: z.array(orderbookElementSchema),
});
export const poolReservesSchema = z.object({
a: z.number(), // amount asset
p: z.number(), // price asset
indicativePrice: z.number(),
});