@nadohq/engine-client 0.1.0-alpha.8 → 0.1.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/serverSubscriptionEventTypes.ts"],"sourcesContent":["import { EngineServerPriceTickLiquidity } from './serverQueryTypes';\n\n/**\n * Reasons that can trigger position change events.\n */\nexport type PositionChangeReason =\n | 'deposit_collateral'\n | 'match_orders'\n | 'withdraw_collateral'\n | 'transfer_quote'\n | 'settle_pnl'\n | 'mint_nlp'\n | 'burn_nlp'\n | 'liquidate_subaccount';\n\n/**\n * Possible reasons for order updates.\n */\nexport type OrderUpdateReason = 'cancelled' | 'filled' | 'placed';\n\nexport type EngineServerSubscriptionEventType =\n | 'trade'\n | 'best_bid_offer'\n | 'book_depth'\n | 'fill'\n | 'position_change'\n | 'order_update'\n | 'liquidation'\n | 'latest_candlestick'\n | 'funding_payment';\n\nexport interface EngineServerSubscriptionBaseEvent<\n T extends\n EngineServerSubscriptionEventType = EngineServerSubscriptionEventType,\n> {\n type: T;\n product_id: number;\n}\n\n/**\n * Event from subscribing to a `trade` stream.\n */\nexport interface EngineServerSubscriptionTradeEvent\n extends EngineServerSubscriptionBaseEvent<'trade'> {\n timestamp: string;\n price: string;\n taker_qty: string;\n maker_qty: string;\n is_taker_buyer: boolean;\n}\n\n/**\n * Event from subscribing to a `best_bid_offer` stream.\n */\nexport interface EngineServerSubscriptionBestBidOfferEvent\n extends EngineServerSubscriptionBaseEvent<'best_bid_offer'> {\n timestamp: string;\n bid_price: string;\n bid_qty: string;\n ask_price: string;\n ask_qty: string;\n}\n\n/**\n * Event from subscribing to a `book_depth` stream.\n */\nexport interface EngineServerSubscriptionBookDepthEvent\n extends EngineServerSubscriptionBaseEvent<'book_depth'> {\n last_max_timestamp: string;\n min_timestamp: string;\n max_timestamp: string;\n bids: EngineServerPriceTickLiquidity[];\n asks: EngineServerPriceTickLiquidity[];\n}\n\n/**\n * Event from subscribing to a `fill` stream.\n */\nexport interface EngineServerSubscriptionFillEvent\n extends EngineServerSubscriptionBaseEvent<'fill'> {\n // NOTE: `id` is excluded from the response to avoid parsing issues.\n // type of `id` on the backend is `u64` which can overflow until we introduce proper parsing on the SDK.\n timestamp: string;\n subaccount: string;\n order_digest: string;\n filled_qty: string;\n remaining_qty: string;\n original_qty: string;\n price: string;\n is_taker: boolean;\n is_bid: boolean;\n fee: string;\n submission_idx: string;\n}\n\n/**\n * Event from subscribing to a `position_change` stream.\n */\nexport interface EngineServerSubscriptionPositionChangeEvent\n extends EngineServerSubscriptionBaseEvent<'position_change'> {\n timestamp: string;\n subaccount: string;\n amount: string;\n /** Zero for everything except perps */\n v_quote_amount: string;\n reason: PositionChangeReason;\n}\n\n/**\n * Event from subscribing to an `order_update` stream.\n */\nexport interface EngineServerSubscriptionOrderUpdateEvent\n extends EngineServerSubscriptionBaseEvent<'order_update'> {\n timestamp: string;\n digest: string;\n amount: string;\n reason: OrderUpdateReason;\n}\n\n/**\n * Event from subscribing to a `liquidation` stream.\n */\nexport interface EngineServerSubscriptionLiquidationEvent\n extends EngineServerSubscriptionBaseEvent<'liquidation'> {\n timestamp: string;\n /** Single element for regular liquidations, two elements for spread liquidations [spotId, perpId] */\n product_ids: number[];\n liquidator: string;\n liquidatee: string;\n /** Amount liquidated (positive for long, negative for short) */\n amount: string;\n /** Price at which liquidation occurred */\n price: string;\n}\n\n/**\n * Event from subscribing to a `latest_candlestick` stream.\n */\nexport interface EngineServerSubscriptionLatestCandlestickEvent\n extends EngineServerSubscriptionBaseEvent<'latest_candlestick'> {\n timestamp: string;\n granularity: number;\n open_x18: string;\n high_x18: string;\n low_x18: string;\n close_x18: string;\n volume: string;\n}\n\n/**\n * Event from subscribing to a `funding_payment` stream.\n */\nexport interface EngineServerSubscriptionFundingPaymentEvent\n extends EngineServerSubscriptionBaseEvent<'funding_payment'> {\n timestamp: string;\n /** Funding payment amount (positive = receive, negative = pay) */\n payment_amount: string;\n /** Open interest at time of funding */\n open_interest: string;\n /** Current cumulative funding values */\n cumulative_funding_long_x18: string;\n cumulative_funding_short_x18: string;\n /** Time delta over which the funding payment was calculated */\n dt: string;\n}\n\n/**\n * Union type for all engine server subscription events.\n */\nexport type EngineServerSubscriptionEvent =\n | EngineServerSubscriptionTradeEvent\n | EngineServerSubscriptionBestBidOfferEvent\n | EngineServerSubscriptionBookDepthEvent\n | EngineServerSubscriptionFillEvent\n | EngineServerSubscriptionPositionChangeEvent\n | EngineServerSubscriptionOrderUpdateEvent\n | EngineServerSubscriptionLiquidationEvent\n | EngineServerSubscriptionLatestCandlestickEvent\n | EngineServerSubscriptionFundingPaymentEvent;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/serverSubscriptionEventTypes.ts"],"sourcesContent":["import {\n EngineServerOrder,\n EngineServerPriceTickLiquidity,\n} from './serverQueryTypes';\n\n/**\n * Reasons that can trigger position change events.\n */\nexport type PositionChangeReason =\n | 'deposit_collateral'\n | 'match_orders'\n | 'withdraw_collateral'\n | 'transfer_quote'\n | 'settle_pnl'\n | 'mint_nlp'\n | 'burn_nlp'\n | 'liquidate_subaccount';\n\n/**\n * Possible reasons for order updates.\n */\nexport type OrderUpdateReason = 'cancelled' | 'filled' | 'placed';\n\nexport type EngineServerSubscriptionEventType =\n | 'trade'\n | 'best_bid_offer'\n | 'book_depth'\n | 'fill'\n | 'position_change'\n | 'order_update'\n | 'liquidation'\n | 'latest_candlestick'\n | 'funding_payment';\n\nexport interface EngineServerSubscriptionBaseEvent<\n T extends\n EngineServerSubscriptionEventType = EngineServerSubscriptionEventType,\n> {\n type: T;\n product_id: number;\n}\n\n/**\n * Event from subscribing to a `trade` stream.\n */\nexport interface EngineServerSubscriptionTradeEvent\n extends EngineServerSubscriptionBaseEvent<'trade'> {\n timestamp: string;\n price: string;\n taker_qty: string;\n maker_qty: string;\n is_taker_buyer: boolean;\n}\n\n/**\n * Event from subscribing to a `best_bid_offer` stream.\n */\nexport interface EngineServerSubscriptionBestBidOfferEvent\n extends EngineServerSubscriptionBaseEvent<'best_bid_offer'> {\n timestamp: string;\n bid_price: string;\n bid_qty: string;\n ask_price: string;\n ask_qty: string;\n}\n\n/**\n * Event from subscribing to a `book_depth` stream.\n */\nexport interface EngineServerSubscriptionBookDepthEvent\n extends EngineServerSubscriptionBaseEvent<'book_depth'> {\n last_max_timestamp: string;\n min_timestamp: string;\n max_timestamp: string;\n bids: EngineServerPriceTickLiquidity[];\n asks: EngineServerPriceTickLiquidity[];\n}\n\n/**\n * Event from subscribing to a `fill` stream.\n */\nexport interface EngineServerSubscriptionFillEvent\n extends EngineServerSubscriptionBaseEvent<'fill'> {\n // NOTE: `id` is excluded from the response to avoid parsing issues.\n // type of `id` on the backend is `u64` which can overflow until we introduce proper parsing on the SDK.\n timestamp: string;\n subaccount: string;\n order_digest: string;\n filled_qty: string;\n remaining_qty: string;\n original_qty: string;\n price: string;\n is_taker: boolean;\n is_bid: boolean;\n fee: string;\n submission_idx: string;\n appendix: string;\n}\n\n/**\n * Event from subscribing to a `position_change` stream.\n */\nexport interface EngineServerSubscriptionPositionChangeEvent\n extends EngineServerSubscriptionBaseEvent<'position_change'> {\n timestamp: string;\n subaccount: string;\n amount: string;\n /** Zero for everything except perps */\n v_quote_amount: string;\n reason: PositionChangeReason;\n}\n\n/**\n * Event from subscribing to an `order_update` stream.\n */\nexport interface EngineServerSubscriptionOrderUpdateEvent\n extends EngineServerSubscriptionBaseEvent<'order_update'> {\n timestamp: string;\n order: EngineServerOrder;\n reason: OrderUpdateReason;\n}\n\n/**\n * Event from subscribing to a `liquidation` stream.\n */\nexport interface EngineServerSubscriptionLiquidationEvent\n extends EngineServerSubscriptionBaseEvent<'liquidation'> {\n timestamp: string;\n /** Single element for regular liquidations, two elements for spread liquidations [spotId, perpId] */\n product_ids: number[];\n liquidator: string;\n liquidatee: string;\n /** Amount liquidated (positive for long, negative for short) */\n amount: string;\n /** Price at which liquidation occurred */\n price: string;\n}\n\n/**\n * Event from subscribing to a `latest_candlestick` stream.\n */\nexport interface EngineServerSubscriptionLatestCandlestickEvent\n extends EngineServerSubscriptionBaseEvent<'latest_candlestick'> {\n timestamp: string;\n granularity: number;\n open_x18: string;\n high_x18: string;\n low_x18: string;\n close_x18: string;\n volume: string;\n}\n\n/**\n * Event from subscribing to a `funding_payment` stream.\n */\nexport interface EngineServerSubscriptionFundingPaymentEvent\n extends EngineServerSubscriptionBaseEvent<'funding_payment'> {\n timestamp: string;\n /** Funding payment amount (positive = receive, negative = pay) */\n payment_amount: string;\n /** Open interest at time of funding */\n open_interest: string;\n /** Current cumulative funding values */\n cumulative_funding_long_x18: string;\n cumulative_funding_short_x18: string;\n /** Time delta over which the funding payment was calculated */\n dt: string;\n}\n\n/**\n * Union type for all engine server subscription events.\n */\nexport type EngineServerSubscriptionEvent =\n | EngineServerSubscriptionTradeEvent\n | EngineServerSubscriptionBestBidOfferEvent\n | EngineServerSubscriptionBookDepthEvent\n | EngineServerSubscriptionFillEvent\n | EngineServerSubscriptionPositionChangeEvent\n | EngineServerSubscriptionOrderUpdateEvent\n | EngineServerSubscriptionLiquidationEvent\n | EngineServerSubscriptionLatestCandlestickEvent\n | EngineServerSubscriptionFundingPaymentEvent;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,4 +1,4 @@
1
- import { EngineServerPriceTickLiquidity } from './serverQueryTypes.cjs';
1
+ import { EngineServerPriceTickLiquidity, EngineServerOrder } from './serverQueryTypes.cjs';
2
2
  import '@nadohq/shared';
3
3
  import './serverQueryModelTypes.cjs';
4
4
 
@@ -60,6 +60,7 @@ interface EngineServerSubscriptionFillEvent extends EngineServerSubscriptionBase
60
60
  is_bid: boolean;
61
61
  fee: string;
62
62
  submission_idx: string;
63
+ appendix: string;
63
64
  }
64
65
  /**
65
66
  * Event from subscribing to a `position_change` stream.
@@ -77,8 +78,7 @@ interface EngineServerSubscriptionPositionChangeEvent extends EngineServerSubscr
77
78
  */
78
79
  interface EngineServerSubscriptionOrderUpdateEvent extends EngineServerSubscriptionBaseEvent<'order_update'> {
79
80
  timestamp: string;
80
- digest: string;
81
- amount: string;
81
+ order: EngineServerOrder;
82
82
  reason: OrderUpdateReason;
83
83
  }
84
84
  /**
@@ -1,4 +1,4 @@
1
- import { EngineServerPriceTickLiquidity } from './serverQueryTypes.js';
1
+ import { EngineServerPriceTickLiquidity, EngineServerOrder } from './serverQueryTypes.js';
2
2
  import '@nadohq/shared';
3
3
  import './serverQueryModelTypes.js';
4
4
 
@@ -60,6 +60,7 @@ interface EngineServerSubscriptionFillEvent extends EngineServerSubscriptionBase
60
60
  is_bid: boolean;
61
61
  fee: string;
62
62
  submission_idx: string;
63
+ appendix: string;
63
64
  }
64
65
  /**
65
66
  * Event from subscribing to a `position_change` stream.
@@ -77,8 +78,7 @@ interface EngineServerSubscriptionPositionChangeEvent extends EngineServerSubscr
77
78
  */
78
79
  interface EngineServerSubscriptionOrderUpdateEvent extends EngineServerSubscriptionBaseEvent<'order_update'> {
79
80
  timestamp: string;
80
- digest: string;
81
- amount: string;
81
+ order: EngineServerOrder;
82
82
  reason: OrderUpdateReason;
83
83
  }
84
84
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/serverSubscriptionTypes.ts"],"sourcesContent":["export interface EngineServerOrderUpdateStreamParams {\n product_id: number;\n subaccount: string;\n}\n\nexport interface EngineServerTradeStreamParams {\n product_id: number;\n}\n\nexport interface EngineServerBestBidOfferStreamParams {\n product_id: number;\n}\n\nexport interface EngineServerFillStreamParams {\n product_id: number;\n subaccount: string;\n}\n\nexport interface EngineServerPositionChangeStreamParams {\n /** when not provided, subscribes to all products */\n product_id?: number;\n subaccount: string;\n}\n\nexport interface EngineServerBookDepthStreamParams {\n product_id: number;\n}\n\nexport interface EngineServerLatestCandlestickStreamParams {\n product_id: number;\n granularity: number;\n}\n\nexport interface EngineServerLiquidationStreamParams {\n /** when not provided, subscribes to all products */\n product_id?: number;\n}\n\nexport interface EngineServerFundingPaymentStreamParams {\n product_id: number;\n}\n\n/**\n * Available subscription streams\n */\nexport interface EngineServerSubscriptionStreamParamsByType {\n order_update: EngineServerOrderUpdateStreamParams;\n trade: EngineServerTradeStreamParams;\n best_bid_offer: EngineServerBestBidOfferStreamParams;\n fill: EngineServerFillStreamParams;\n position_change: EngineServerPositionChangeStreamParams;\n book_depth: EngineServerBookDepthStreamParams;\n liquidation: EngineServerLiquidationStreamParams;\n latest_candlestick: EngineServerLatestCandlestickStreamParams;\n funding_payment: EngineServerFundingPaymentStreamParams;\n}\n\nexport type EngineServerSubscriptionStreamParamsType =\n keyof EngineServerSubscriptionStreamParamsByType;\n\n/**\n * Describes a stream that can be subscribed to.\n */\nexport type EngineServerSubscriptionStream<\n TStreamType extends EngineServerSubscriptionStreamParamsType,\n> = {\n type: TStreamType;\n} & EngineServerSubscriptionStreamParamsByType[TStreamType];\n\n/**\n * Params to provide to a `subscribe` / `unsubscribe` action.\n */\nexport interface EngineServerSubscriptionParams {\n stream: EngineServerSubscriptionStream<EngineServerSubscriptionStreamParamsType>;\n}\n\n/**\n * Available actions on the subscription API.\n */\nexport interface EngineServerSubscriptionRequestByType {\n subscribe: EngineServerSubscriptionParams;\n unsubscribe: EngineServerSubscriptionParams;\n list: Record<string, never>;\n}\n\nexport type EngineServerSubscriptionRequestType =\n keyof EngineServerSubscriptionRequestByType;\n\n/**\n * Top level request to send to the server.\n */\nexport type EngineServerSubscriptionRequest<\n TRequestType extends EngineServerSubscriptionRequestType,\n> = {\n id: number;\n method: TRequestType;\n} & EngineServerSubscriptionRequestByType[TRequestType];\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../src/types/serverSubscriptionTypes.ts"],"sourcesContent":["export interface EngineServerOrderUpdateStreamParams {\n /** when not provided, subscribes to all products */\n product_id?: number;\n subaccount: string;\n}\n\nexport interface EngineServerTradeStreamParams {\n product_id: number;\n}\n\nexport interface EngineServerBestBidOfferStreamParams {\n product_id: number;\n}\n\nexport interface EngineServerFillStreamParams {\n /** when not provided, subscribes to all products */\n product_id?: number;\n subaccount: string;\n}\n\nexport interface EngineServerPositionChangeStreamParams {\n /** when not provided, subscribes to all products */\n product_id?: number;\n subaccount: string;\n}\n\nexport interface EngineServerBookDepthStreamParams {\n product_id: number;\n}\n\nexport interface EngineServerLatestCandlestickStreamParams {\n product_id: number;\n granularity: number;\n}\n\nexport interface EngineServerLiquidationStreamParams {\n /** when not provided, subscribes to all products */\n product_id?: number;\n}\n\nexport interface EngineServerFundingPaymentStreamParams {\n product_id: number;\n}\n\n/**\n * Available subscription streams\n */\nexport interface EngineServerSubscriptionStreamParamsByType {\n order_update: EngineServerOrderUpdateStreamParams;\n trade: EngineServerTradeStreamParams;\n best_bid_offer: EngineServerBestBidOfferStreamParams;\n fill: EngineServerFillStreamParams;\n position_change: EngineServerPositionChangeStreamParams;\n book_depth: EngineServerBookDepthStreamParams;\n liquidation: EngineServerLiquidationStreamParams;\n latest_candlestick: EngineServerLatestCandlestickStreamParams;\n funding_payment: EngineServerFundingPaymentStreamParams;\n}\n\nexport type EngineServerSubscriptionStreamParamsType =\n keyof EngineServerSubscriptionStreamParamsByType;\n\n/**\n * Describes a stream that can be subscribed to.\n */\nexport type EngineServerSubscriptionStream<\n TStreamType extends EngineServerSubscriptionStreamParamsType,\n> = {\n type: TStreamType;\n} & EngineServerSubscriptionStreamParamsByType[TStreamType];\n\n/**\n * Params to provide to a `subscribe` / `unsubscribe` action.\n */\nexport interface EngineServerSubscriptionParams {\n stream: EngineServerSubscriptionStream<EngineServerSubscriptionStreamParamsType>;\n}\n\n/**\n * Available actions on the subscription API.\n */\nexport interface EngineServerSubscriptionRequestByType {\n subscribe: EngineServerSubscriptionParams;\n unsubscribe: EngineServerSubscriptionParams;\n list: Record<string, never>;\n}\n\nexport type EngineServerSubscriptionRequestType =\n keyof EngineServerSubscriptionRequestByType;\n\n/**\n * Top level request to send to the server.\n */\nexport type EngineServerSubscriptionRequest<\n TRequestType extends EngineServerSubscriptionRequestType,\n> = {\n id: number;\n method: TRequestType;\n} & EngineServerSubscriptionRequestByType[TRequestType];\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,5 +1,6 @@
1
1
  interface EngineServerOrderUpdateStreamParams {
2
- product_id: number;
2
+ /** when not provided, subscribes to all products */
3
+ product_id?: number;
3
4
  subaccount: string;
4
5
  }
5
6
  interface EngineServerTradeStreamParams {
@@ -9,7 +10,8 @@ interface EngineServerBestBidOfferStreamParams {
9
10
  product_id: number;
10
11
  }
11
12
  interface EngineServerFillStreamParams {
12
- product_id: number;
13
+ /** when not provided, subscribes to all products */
14
+ product_id?: number;
13
15
  subaccount: string;
14
16
  }
15
17
  interface EngineServerPositionChangeStreamParams {
@@ -1,5 +1,6 @@
1
1
  interface EngineServerOrderUpdateStreamParams {
2
- product_id: number;
2
+ /** when not provided, subscribes to all products */
3
+ product_id?: number;
3
4
  subaccount: string;
4
5
  }
5
6
  interface EngineServerTradeStreamParams {
@@ -9,7 +10,8 @@ interface EngineServerBestBidOfferStreamParams {
9
10
  product_id: number;
10
11
  }
11
12
  interface EngineServerFillStreamParams {
12
- product_id: number;
13
+ /** when not provided, subscribes to all products */
14
+ product_id?: number;
13
15
  subaccount: string;
14
16
  }
15
17
  interface EngineServerPositionChangeStreamParams {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nadohq/engine-client",
3
- "version": "0.1.0-alpha.8",
3
+ "version": "0.1.0-alpha.9",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "> TODO: description",
@@ -37,7 +37,7 @@
37
37
  }
38
38
  },
39
39
  "dependencies": {
40
- "@nadohq/shared": "^0.1.0-alpha.8",
40
+ "@nadohq/shared": "^0.1.0-alpha.9",
41
41
  "axios": "*",
42
42
  "ts-mixer": "*"
43
43
  },
@@ -47,5 +47,5 @@
47
47
  "devDependencies": {
48
48
  "viem": "*"
49
49
  },
50
- "gitHead": "3488a83313ef5c199b2fc9a3cd70f477e80e74db"
50
+ "gitHead": "aa99daac81aaf29696ecdbdb45276145823e0ac7"
51
51
  }
@@ -1,4 +1,7 @@
1
- import { EngineServerPriceTickLiquidity } from './serverQueryTypes';
1
+ import {
2
+ EngineServerOrder,
3
+ EngineServerPriceTickLiquidity,
4
+ } from './serverQueryTypes';
2
5
 
3
6
  /**
4
7
  * Reasons that can trigger position change events.
@@ -91,6 +94,7 @@ export interface EngineServerSubscriptionFillEvent
91
94
  is_bid: boolean;
92
95
  fee: string;
93
96
  submission_idx: string;
97
+ appendix: string;
94
98
  }
95
99
 
96
100
  /**
@@ -112,8 +116,7 @@ export interface EngineServerSubscriptionPositionChangeEvent
112
116
  export interface EngineServerSubscriptionOrderUpdateEvent
113
117
  extends EngineServerSubscriptionBaseEvent<'order_update'> {
114
118
  timestamp: string;
115
- digest: string;
116
- amount: string;
119
+ order: EngineServerOrder;
117
120
  reason: OrderUpdateReason;
118
121
  }
119
122
 
@@ -1,5 +1,6 @@
1
1
  export interface EngineServerOrderUpdateStreamParams {
2
- product_id: number;
2
+ /** when not provided, subscribes to all products */
3
+ product_id?: number;
3
4
  subaccount: string;
4
5
  }
5
6
 
@@ -12,7 +13,8 @@ export interface EngineServerBestBidOfferStreamParams {
12
13
  }
13
14
 
14
15
  export interface EngineServerFillStreamParams {
15
- product_id: number;
16
+ /** when not provided, subscribes to all products */
17
+ product_id?: number;
16
18
  subaccount: string;
17
19
  }
18
20