Skip to content

Commit

Permalink
Merge pull request #394 from idexio/feat/add-conditional-order-props-…
Browse files Browse the repository at this point in the history
…to-ws-api-types

feat(conditional TP/SL orders): add order `subType` prop to WS API msgs
  • Loading branch information
fubar authored Nov 14, 2024
2 parents 404d549 + 571d999 commit 7180e59
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
"bignumber.js": "^9.1.2",
"ethers": "6.9.0",
"isomorphic-ws": "^5.0.0",
"tslib": "^2.6.2",
"tslib": "^2.7.0",
"uuid": "^9.0.1",
"ws": "8.17.0"
},
Expand Down
3 changes: 2 additions & 1 deletion src/client/webSocket/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ function transformOrdersMessage(
errorCode: short.ec,
errorMessage: short.em,
type: short.o,
subType: short.O,
side: short.s,
originalQuantity: short.q,
executedQuantity: short.z,
Expand All @@ -178,7 +179,7 @@ function transformOrdersMessage(
triggerPrice: short.P,
triggerType: short.tt,
// callbackRate: short.cr,
// conditionalOrderId: short.ci,
conditionalOrderId: short.ci,
reduceOnly: short.r,
timeInForce: short.f,
selfTradePrevention: short.V,
Expand Down
22 changes: 12 additions & 10 deletions src/types/enums/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,20 +464,22 @@ export const OrderType = Object.freeze({
* to provide inline IDE completion and documentation.
*/
trailingStopMarket: 'trailingStopMarket',

/**
* @internal
*/
conditionalStopLossMarket: 'conditionalStopLossMarket',

/**
* @internal
*/
conditionalTakeProfitMarket: 'conditionalTakeProfitMarket',
} as const);

export type OrderType = (typeof OrderType)[keyof typeof OrderType];

/**
* @internal
*/
export const OrderSubType = Object.freeze({
conditional: 'conditional',
});

/**
* @internal
*/
export type OrderSubType = (typeof OrderSubType)[keyof typeof OrderSubType];

/**
* @see request {@link _types.RestRequestOrderBase.side RestRequestOrder.side}
* @see related {@link _types.IDEXOrder IDEXOrder Interface}
Expand Down
1 change: 1 addition & 0 deletions src/types/rest/endpoints/GetOrders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export interface IDEXOrder {
* - Only applicable to stop {@link OrderType order types}:
* - {@link OrderType.stopLossMarket stopLossMarket}
* - {@link OrderType.stopLossLimit stopLossLimit}
* - {@link OrderType.takeProfitMarket takeProfitMarket}
* - {@link OrderType.trailingStopMarket trailingStopMarket}
* - Indicates an {@link orderId} of an open {@link OrderType.limit limit} order
* by the same wallet in the same market that must be filled before the stop becomes active.
Expand Down
17 changes: 14 additions & 3 deletions src/types/webSocket/response/orders.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import type * as idex from '#index';
import type { MessageEventType, OrderType } from '#types/enums/index';
import type {
MessageEventType,
OrderSubType,
OrderType,
} from '#types/enums/index';
import type { OrderStateChange } from '#types/enums/response';
import type { IDEXOrder } from '#types/rest/endpoints/GetOrders';
import type { IDEXSubscriptionEventBase } from '#types/webSocket/base';
Expand Down Expand Up @@ -101,6 +105,10 @@ export interface IDEXOrderEventDataGeneral
* @inheritDoc
*/
readonly type: OrderType;
/**
* @internal
*/
readonly subType?: OrderSubType;
/**
* Type of order update
*
Expand Down Expand Up @@ -181,7 +189,6 @@ export interface WebSocketResponseOrderShortBase {
* @see inflated {@link IDEXOrderEventDataGeneral.wallet}
*/
w: IDEXOrderEventDataBase['wallet'];
// t: IDEXOrder['execut'];
/**
* @see inflated {@link IDEXOrderEventDataGeneral.executionTime}
*/
Expand Down Expand Up @@ -229,6 +236,10 @@ export interface WebSocketResponseOrderShortGeneral
* @inheritDoc
*/
o: IDEXOrderEventDataGeneral['type'];
/**
* @internal
*/
O?: IDEXOrderEventDataGeneral['subType'];
/**
* @see related {@link IDEXOrder.orderId}
* @see inflated {@link IDEXOrderEventDataGeneral.orderId}
Expand Down Expand Up @@ -314,7 +325,7 @@ export interface WebSocketResponseOrderShortGeneral
/**
* @see inflated {@link IDEXOrderEventDataGeneral.conditionalOrderId}
*/
ci?: string;
ci?: IDEXOrderEventDataGeneral['conditionalOrderId'];
/**
* @see related {@link IDEXOrder.reduceOnly}
* @see inflated {@link IDEXOrderEventDataGeneral.reduceOnly}
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ __metadata:
semantic-release: "npm:^23.1.1"
semantic-release-slack-bot: "npm:^4.0.2"
slackify-markdown: "npm:^4.4.0"
tslib: "npm:^2.6.2"
tslib: "npm:^2.7.0"
tsx: "npm:^4.10.2"
typedoc: "npm:0.25.13"
typedoc-plugin-extras: "npm:^3.0.0"
Expand Down Expand Up @@ -11194,6 +11194,13 @@ __metadata:
languageName: node
linkType: hard

"tslib@npm:^2.7.0":
version: 2.8.1
resolution: "tslib@npm:2.8.1"
checksum: 10c0/9c4759110a19c53f992d9aae23aac5ced636e99887b51b9e61def52611732872ff7668757d4e4c61f19691e36f4da981cd9485e869b4a7408d689f6bf1f14e62
languageName: node
linkType: hard

"tsx@npm:^4.10.2":
version: 4.10.2
resolution: "tsx@npm:4.10.2"
Expand Down

0 comments on commit 7180e59

Please sign in to comment.