mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
OP-3279 Add /api/v1/pools/reserves endpoint (#33)
* OP-3279 Add /api/v1/pools/reserves endpoint * OP-3279 Fixup * OP-3279 Fixup * OP-3279 Update version
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.15.25",
|
||||
"version": "0.15.28-rc.0",
|
||||
"description": "Orion Protocol SDK",
|
||||
"main": "./lib/esm/index.js",
|
||||
"module": "./lib/esm/index.js",
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -38,6 +38,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 = () => fetchWithValidation(
|
||||
@@ -59,7 +60,7 @@ class OrionAggregator {
|
||||
|
||||
getExchangeOrderbook = (
|
||||
pair: string,
|
||||
exchange: string,
|
||||
exchange: Exchange,
|
||||
depth = 20,
|
||||
filterByBrokerBalances: boolean | null = null,
|
||||
) => {
|
||||
@@ -77,6 +78,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,
|
||||
);
|
||||
};
|
||||
|
||||
getPairConfigs = () => fetchWithValidation(
|
||||
`${this.apiUrl}/api/v1/pairs/exchangeInfo`,
|
||||
exchangeInfoSchema,
|
||||
|
||||
@@ -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(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user