feat(OP-4112): remove futures

This commit is contained in:
Dmitriy Pavlov
2023-07-10 17:57:05 +03:00
parent 0c02ff821a
commit 9de02596a7
9 changed files with 12 additions and 73 deletions

View File

@@ -134,7 +134,7 @@ const assets = await orion.getAssets(); // Optional: tradableOnly: boolean (defa
### Get pairs
```ts
const pairs = await orion.getPairs("spot"); // 'spot' | 'futures'
const pairs = await orion.getPairs("spot"); // 'spot'
// Response example:
// {

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@orionprotocol/sdk",
"version": "0.19.33-rc1",
"version": "0.19.33-rc2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@orionprotocol/sdk",
"version": "0.19.33-rc1",
"version": "0.19.33-rc2",
"license": "ISC",
"dependencies": {
"@babel/runtime": "^7.21.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.19.33-rc1",
"version": "0.19.33-rc2",
"description": "Orion Protocol SDK",
"main": "./lib/index.cjs",
"module": "./lib/index.js",

View File

@@ -9,10 +9,10 @@ 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 { pairConfigSchema } from './schemas/index.js';
import {
aggregatedOrderbookSchema, exchangeOrderbookSchema, poolReservesSchema,
} from './schemas/aggregatedOrderbookSchema.js';
pairConfigSchema, aggregatedOrderbookSchema,
exchangeOrderbookSchema, poolReservesSchema,
} from './schemas/index.js';
import type networkCodes from '../../constants/networkCodes.js';
import toUpperCase from '../../utils/toUpperCase.js';
import httpToWS from '../../utils/httpToWS.js';
@@ -93,7 +93,7 @@ class Aggregator {
);
}
getPairsList = (market: 'spot' | 'futures') => {
getPairsList = (market: 'spot') => {
const url = new URL(`${this.apiUrl}/api/v1/pairs/list`);
url.searchParams.append('market', toUpperCase(market));
@@ -141,7 +141,7 @@ class Aggregator {
);
};
getPairConfigs = (market: 'spot' | 'futures') => {
getPairConfigs = (market: 'spot') => {
const url = new URL(`${this.apiUrl}/api/v1/pairs/exchangeInfo`);
url.searchParams.append('market', toUpperCase(market));

View File

@@ -7,7 +7,6 @@ const MessageType = {
ASSET_PAIRS_CONFIG_UPDATE: 'apcu',
ASSET_PAIR_CONFIG_UPDATE: 'apiu',
ADDRESS_UPDATE: 'au',
FUTURES_TRADE_INFO_UPDATE: 'fti',
BROKER_TRADABLE_ATOMIC_SWAP_ASSETS_BALANCE_UPDATE: 'btasabu',
UNSUBSCRIPTION_DONE: 'ud',
} as const;

View File

@@ -5,7 +5,6 @@ const SubscriptionType = {
ADDRESS_UPDATES_SUBSCRIBE: 'aus',
BROKER_TRADABLE_ATOMIC_SWAP_ASSETS_BALANCE_UPDATES_SUBSCRIBE: 'btasabus',
SWAP_SUBSCRIBE: 'ss',
FUTURES_TRADE_INFO_SUBSCRIBE: 'fts',
} as const;
export default SubscriptionType;

View File

@@ -11,12 +11,11 @@ import {
import UnsubscriptionType from './UnsubscriptionType.js';
import type {
SwapInfoBase, AssetPairUpdate, OrderbookItem,
Balance, Exchange, FuturesTradeInfo, SwapInfo, Json, BasicAuthCredentials,
Balance, Exchange, SwapInfo, Json, BasicAuthCredentials,
} from '../../../types.js';
import unsubscriptionDoneSchema from './schemas/unsubscriptionDoneSchema.js';
import assetPairConfigSchema from './schemas/assetPairConfigSchema.js';
import type { fullOrderSchema, orderUpdateSchema } from './schemas/addressUpdateSchema.js';
import futuresTradeInfoSchema from './schemas/futuresTradeInfoSchema.js';
import { objectKeys } from '../../../utils/objectKeys.js';
// import assertError from '../../../utils/assertError.js';
// import errorSchema from './schemas/errorSchema';
@@ -34,7 +33,6 @@ const messageSchema = z.union([
brokerMessageSchema,
orderBookSchema,
swapInfoSchema,
futuresTradeInfoSchema,
errorSchema,
unsubscriptionDoneSchema,
]);
@@ -49,13 +47,6 @@ type SwapInfoSubscriptionPayload = {
is?: boolean // instant settlement
}
type FuturesTradeInfoPayload = {
s: string // wallet address
i: string // pair
a: number // amount
p?: number // price
}
type BrokerTradableAtomicSwapBalanceSubscription = {
callback: (balances: Partial<Record<string, number>>) => void
}
@@ -90,12 +81,6 @@ type SwapInfoSubscription = {
callback: (swapInfo: SwapInfo) => void
}
type FuturesTradeInfoSubscription = {
payload: FuturesTradeInfoPayload
callback: (futuresTradeInfo: FuturesTradeInfo) => void
errorCb?: (message: string) => void
}
type AddressUpdateUpdate = {
kind: 'update'
balances: Partial<
@@ -131,7 +116,6 @@ type Subscription = {
[SubscriptionType.ASSET_PAIR_CONFIG_UPDATES_SUBSCRIBE]: PairConfigSubscription
[SubscriptionType.BROKER_TRADABLE_ATOMIC_SWAP_ASSETS_BALANCE_UPDATES_SUBSCRIBE]: BrokerTradableAtomicSwapBalanceSubscription
[SubscriptionType.SWAP_SUBSCRIBE]: SwapInfoSubscription
[SubscriptionType.FUTURES_TRADE_INFO_SUBSCRIBE]: FuturesTradeInfoSubscription
}
const exclusiveSubscriptions = [
@@ -171,8 +155,6 @@ type Subscriptions = Partial<{
[K in keyof Subscription]: Partial<Record<string, Subscription[K]>>
}>;
const FUTURES_SUFFIX = 'USDF';
class AggregatorWS {
private ws?: WebSocket | undefined;
@@ -368,8 +350,7 @@ class AggregatorWS {
const isOrderBooksSubscription = (subId: string) => {
const isSpotPairName = subId.includes('-') && subId.split('-').length === 2;
const isFuturesPairName = subId.endsWith(FUTURES_SUFFIX);
return isSpotPairName || isFuturesPairName;
return isSpotPairName;
}
if (newestSubId.includes('0x')) { // is wallet address (ADDRESS_UPDATE)
@@ -385,7 +366,6 @@ class AggregatorWS {
// is swap info subscription (contains hyphen)
delete this.subscriptions[SubscriptionType.SWAP_SUBSCRIBE]?.[newestSubId];
delete this.subscriptions[SubscriptionType.ASSET_PAIR_CONFIG_UPDATES_SUBSCRIBE]?.[newestSubId];
delete this.subscriptions[SubscriptionType.FUTURES_TRADE_INFO_SUBSCRIBE]?.[newestSubId];
// !!! swap info subscription is uuid that contains hyphen
} else if (isOrderBooksSubscription(newestSubId)) { // is pair name(AGGREGATED_ORDER_BOOK_UPDATE)
const aobSubscriptions = this.subscriptions[SubscriptionType.AGGREGATED_ORDER_BOOK_UPDATES_SUBSCRIBE];
@@ -564,18 +544,6 @@ class AggregatorWS {
}
}
break;
case MessageType.FUTURES_TRADE_INFO_UPDATE:
this.subscriptions[SubscriptionType.FUTURES_TRADE_INFO_SUBSCRIBE]?.[json.id]?.callback({
futuresTradeRequestId: json.id,
sender: json.S,
instrument: json.i,
buyPrice: json.bp,
sellPrice: json.sp,
buyPower: json.bpw,
sellPower: json.spw,
minAmount: json.ma,
});
break;
case MessageType.INITIALIZATION:
this.onInit?.();
break;

View File

@@ -1,16 +0,0 @@
import { z } from 'zod';
import MessageType from '../MessageType.js';
const futuresTradeInfoSchema = z.object({
T: z.literal(MessageType.FUTURES_TRADE_INFO_UPDATE),
id: z.string(), // trade info request UUID, set by client side
S: z.string(), // sender
i: z.string(), // instrument
bp: z.number().optional(), // buy price
sp: z.number().optional(), // sell price
bpw: z.number(), // buy power
spw: z.number(), // sell power
ma: z.number(), // min amount
});
export default futuresTradeInfoSchema;

View File

@@ -203,17 +203,6 @@ export type SwapInfoByAmountOut = SwapInfoBase & {
export type SwapInfo = SwapInfoByAmountIn | SwapInfoByAmountOut;
export type FuturesTradeInfo = {
futuresTradeRequestId: string
sender: string
instrument: string
buyPrice: number | undefined
sellPrice: number | undefined
buyPower: number
sellPower: number
minAmount: number
}
export enum HistoryTransactionStatus {
PENDING = 'Pending',
DONE = 'Done',
@@ -255,7 +244,7 @@ export type VerboseUnitConfig = {
// https://price-feed:3003/
}
}
basicAuth?: BasicAuthCredentials,
basicAuth?: BasicAuthCredentials
}
export type KnownEnv = typeof knownEnvs[number];