diff --git a/package.json b/package.json index 05078bf..8b72901 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.19.42", + "version": "0.19.43", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", @@ -108,4 +108,4 @@ "overrides": { "tsconfig-paths": "^4.0.0" } -} +} \ No newline at end of file diff --git a/src/services/Aggregator/index.ts b/src/services/Aggregator/index.ts index 7ff8aa3..7a220b3 100644 --- a/src/services/Aggregator/index.ts +++ b/src/services/Aggregator/index.ts @@ -8,7 +8,7 @@ import errorSchema from './schemas/errorSchema.js'; import placeAtomicSwapSchema from './schemas/placeAtomicSwapSchema.js'; import { AggregatorWS } from './ws/index.js'; import { atomicSwapHistorySchema } from './schemas/atomicSwapHistorySchema.js'; -import type { BasicAuthCredentials, Exchange, SignedCancelOrderRequest, SignedOrder } from '../../types.js'; +import type { BasicAuthCredentials, SignedCancelOrderRequest, SignedOrder } from '../../types.js'; import { pairConfigSchema, aggregatedOrderbookSchema, exchangeOrderbookSchema, poolReservesSchema, @@ -18,7 +18,6 @@ import toUpperCase from '../../utils/toUpperCase.js'; import httpToWS from '../../utils/httpToWS.js'; import { ethers } from 'ethers'; import orderSchema from './schemas/orderSchema.js'; -import { exchanges } from '../../constants/index.js'; import { fetchWithValidation } from 'simple-typed-fetch'; class Aggregator { @@ -119,12 +118,12 @@ class Aggregator { getAvailableExchanges = () => fetchWithValidation( `${this.apiUrl}/api/v1/exchange/list`, - z.enum(exchanges).array(), + z.string().array(), ); getExchangeOrderbook = ( pair: string, - exchange: Exchange, + exchange: string, depth = 20, filterByBrokerBalances: boolean | null = null, ) => { @@ -156,7 +155,7 @@ class Aggregator { getPoolReserves = ( pair: string, - exchange: Exchange, + exchange: string, ) => { const url = new URL(`${this.apiUrl}/api/v1/pools/reserves/${exchange}/${pair}`); return fetchWithValidation( @@ -255,7 +254,7 @@ class Aggregator { assetOut: string, amount: string, instantSettlement?: boolean, - exchanges?: Exchange[] | 'cex' | 'pools', + exchanges?: string[] | 'cex' | 'pools', ) => { const url = new URL(`${this.apiUrl}/api/v1/swap`); url.searchParams.append('assetIn', assetIn); diff --git a/src/services/Aggregator/schemas/aggregatedOrderbookSchema.ts b/src/services/Aggregator/schemas/aggregatedOrderbookSchema.ts index e827d68..b1cf821 100644 --- a/src/services/Aggregator/schemas/aggregatedOrderbookSchema.ts +++ b/src/services/Aggregator/schemas/aggregatedOrderbookSchema.ts @@ -1,5 +1,4 @@ import { z } from 'zod'; -import { exchanges } from '../../../constants/index.js'; const orderbookElementSchema = z.object({ price: z.number(), @@ -12,7 +11,7 @@ const orderbookElementSchema = z.object({ const aggregatedOrderbookElementSchema = orderbookElementSchema .extend({ - exchanges: z.enum(exchanges).array(), + exchanges: z.string().array(), }); export const aggregatedOrderbookSchema = z.object({ diff --git a/src/services/Aggregator/schemas/orderSchema.ts b/src/services/Aggregator/schemas/orderSchema.ts index 5d4cfd5..14fc395 100644 --- a/src/services/Aggregator/schemas/orderSchema.ts +++ b/src/services/Aggregator/schemas/orderSchema.ts @@ -86,7 +86,7 @@ const subOrderSchema = baseOrderSchema.extend({ parentOrderId: z.string().refine(ethers.utils.isHexString, (value) => ({ message: `subOrder.parentOrderId must be a hex string, got ${value}`, })), - exchange: z.enum(exchanges), + exchange: z.string(), brokerAddress: brokerAddressSchema, tradesInfo: z.record( z.string().uuid(), diff --git a/src/services/Aggregator/schemas/swapInfoSchema.ts b/src/services/Aggregator/schemas/swapInfoSchema.ts index cc2166e..8740e0a 100644 --- a/src/services/Aggregator/schemas/swapInfoSchema.ts +++ b/src/services/Aggregator/schemas/swapInfoSchema.ts @@ -1,5 +1,4 @@ import { z } from 'zod'; -import { exchanges } from '../../../constants/index.js'; const orderInfoSchema = z.object({ assetPair: z.string().toUpperCase(), @@ -18,13 +17,13 @@ const swapInfoBase = z.object({ // isThroughPoolOptimal: z.boolean(), // deprecated executionInfo: z.string(), orderInfo: orderInfoSchema, - exchanges: z.array(z.enum(exchanges)), + exchanges: z.array(z.string()), price: z.number().nullable(), // spending asset price minAmountOut: z.number(), minAmountIn: z.number(), marketPrice: z.number().nullable(), // spending asset market price alternatives: z.object({ // execution alternatives - exchanges: z.array(z.enum(exchanges)), + exchanges: z.array(z.string()), path: z.object({ units: z.object({ assetPair: z.string().toUpperCase(), diff --git a/src/services/Aggregator/ws/index.ts b/src/services/Aggregator/ws/index.ts index 930b6f7..c014e6c 100644 --- a/src/services/Aggregator/ws/index.ts +++ b/src/services/Aggregator/ws/index.ts @@ -11,7 +11,7 @@ import { import UnsubscriptionType from './UnsubscriptionType.js'; import type { SwapInfoBase, AssetPairUpdate, OrderbookItem, - Balance, Exchange, SwapInfo, Json, BasicAuthCredentials, + Balance, SwapInfo, Json, BasicAuthCredentials, } from '../../../types.js'; import unsubscriptionDoneSchema from './schemas/unsubscriptionDoneSchema.js'; import assetPairConfigSchema from './schemas/assetPairConfigSchema.js'; @@ -42,7 +42,7 @@ type SwapInfoSubscriptionPayload = { i: string // asset in o: string // asset out a: number // amount IN/OUT - es?: Exchange[] | 'cex' | 'pools' // exchange list of all cex or all pools (ORION_POOL, UNISWAP, PANCAKESWAP etc) + es?: string[] | 'cex' | 'pools' // exchange list of all cex or all pools (ORION_POOL, UNISWAP, PANCAKESWAP etc) e?: boolean // is amount IN? Value `false` means a = amount OUT, `true` if omitted is?: boolean // instant settlement } diff --git a/src/services/Aggregator/ws/schemas/addressUpdateSchema.ts b/src/services/Aggregator/ws/schemas/addressUpdateSchema.ts index 675cafe..0310b0a 100644 --- a/src/services/Aggregator/ws/schemas/addressUpdateSchema.ts +++ b/src/services/Aggregator/ws/schemas/addressUpdateSchema.ts @@ -1,5 +1,4 @@ import { z } from 'zod'; -import { exchanges } from '../../../../constants/index.js'; import orderStatuses from '../../../../constants/orderStatuses.js'; import executionTypes from '../../../../constants/executionTypes.js'; import subOrderStatuses from '../../../../constants/subOrderStatuses.js'; @@ -23,7 +22,7 @@ const subOrderSchema = z.object({ a: z.number(), // amount A: z.number(), // settled amount p: z.number(), // avg weighed settlement price - e: z.enum(exchanges), // exchange + e: z.string(), // exchange b: z.string(), // broker address S: z.enum(subOrderStatuses), // status o: z.boolean(), // internal only diff --git a/src/services/Aggregator/ws/schemas/orderBookSchema.ts b/src/services/Aggregator/ws/schemas/orderBookSchema.ts index 4c27b87..d0b04d2 100644 --- a/src/services/Aggregator/ws/schemas/orderBookSchema.ts +++ b/src/services/Aggregator/ws/schemas/orderBookSchema.ts @@ -1,5 +1,4 @@ import { z } from 'zod'; -import exchanges from '../../../../constants/exchanges.js'; import MessageType from '../MessageType.js'; import baseMessageSchema from './baseMessageSchema.js'; @@ -7,7 +6,7 @@ export const orderBookItemSchema = z.tuple([ z.string(), // price z.string(), // size z.array( - z.enum(exchanges), + z.string(), ), // exchanges z.array(z.tuple([ z.enum(['SELL', 'BUY']), // side diff --git a/src/services/Aggregator/ws/schemas/swapInfoSchema.ts b/src/services/Aggregator/ws/schemas/swapInfoSchema.ts index 7cc8e35..ef0fc6c 100644 --- a/src/services/Aggregator/ws/schemas/swapInfoSchema.ts +++ b/src/services/Aggregator/ws/schemas/swapInfoSchema.ts @@ -1,10 +1,9 @@ import { z } from 'zod'; -import exchanges from '../../../../constants/exchanges.js'; import MessageType from '../MessageType.js'; import baseMessageSchema from './baseMessageSchema.js'; const alternativeSchema = z.object({ // execution alternatives - e: z.enum(exchanges).array(), // exchanges + e: z.string().array(), // exchanges ps: z.string().array(), // path mo: z.number().optional(), // market amount out mi: z.number().optional(), // market amount in @@ -23,7 +22,7 @@ const swapInfoSchemaBase = baseMessageSchema.extend({ mao: z.number(), // min amount out ps: z.string().array(), // path po: z.boolean(), // is swap through pool optimal - e: z.enum(exchanges).array().optional(), // Exchanges + e: z.string().array().optional(), // Exchanges p: z.number().optional(), // price mp: z.number().optional(), // market price oi: z.object({ // info about order equivalent to this swap diff --git a/src/services/PriceFeed/index.ts b/src/services/PriceFeed/index.ts index f2253c3..ff027d0 100644 --- a/src/services/PriceFeed/index.ts +++ b/src/services/PriceFeed/index.ts @@ -1,5 +1,5 @@ import { fetchWithValidation } from 'simple-typed-fetch'; -import type { BasicAuthCredentials, Exchange } from '../../types.js'; +import type { BasicAuthCredentials } from '../../types.js'; import { allTickersSchema, statisticsOverviewSchema, topPairsStatisticsSchema } from './schemas/index.js'; import candlesSchema from './schemas/candlesSchema.js'; import { PriceFeedWS } from './ws/index.js'; @@ -56,7 +56,7 @@ class PriceFeed { ); }; - getStatisticsOverview = (exchange: Exchange | 'ALL' = 'ALL') => { + getStatisticsOverview = (exchange: string | 'ALL' = 'ALL') => { const url = new URL(`${this.statisticsUrl}/overview`); url.searchParams.append('exchange', exchange); @@ -67,7 +67,7 @@ class PriceFeed { ); } - getTopPairStatistics = (exchange: Exchange | 'ALL' = 'ALL') => { + getTopPairStatistics = (exchange: string | 'ALL' = 'ALL') => { const url = new URL(`${this.statisticsUrl}/top-pairs`); url.searchParams.append('exchange', exchange); diff --git a/src/types.ts b/src/types.ts index b973dfc..b97e2f1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/consistent-type-definitions */ import type { BigNumber } from 'bignumber.js'; -import type exchanges from './constants/exchanges.js'; import type subOrderStatuses from './constants/subOrderStatuses.js'; import type positionStatuses from './constants/positionStatuses.js'; import type { knownEnvs } from './config/schemas/index.js'; @@ -143,12 +142,12 @@ export type BalanceIssue = { readonly fixes?: Fix[] } -export type Exchange = typeof exchanges[number]; +// export type Exchange = typeof exchanges[number]; export type OrderbookItem = { price: string amount: string - exchanges: Exchange[] + exchanges: string[] vob: Array<{ side: 'BUY' | 'SELL' pairName: string @@ -156,7 +155,7 @@ export type OrderbookItem = { } export type SwapInfoAlternative = { - exchanges: Exchange[] + exchanges: string[] path: string[] marketAmountOut?: number | undefined marketAmountIn?: number | undefined @@ -175,7 +174,7 @@ export type SwapInfoBase = { minAmountOut: number path: string[] - exchanges?: Exchange[] | undefined + exchanges?: string[] | undefined poolOptimal: boolean price?: number | undefined