@nadohq/engine-client 0.1.0-alpha.1 → 0.1.0-alpha.11

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.
Files changed (100) hide show
  1. package/dist/EngineBaseClient.cjs +8 -7
  2. package/dist/EngineBaseClient.cjs.map +1 -1
  3. package/dist/EngineBaseClient.d.cts +1 -2
  4. package/dist/EngineBaseClient.d.ts +1 -2
  5. package/dist/EngineBaseClient.js +7 -5
  6. package/dist/EngineBaseClient.js.map +1 -1
  7. package/dist/EngineClient.d.cts +1 -2
  8. package/dist/EngineClient.d.ts +1 -2
  9. package/dist/EngineExecuteBuilder.cjs +33 -61
  10. package/dist/EngineExecuteBuilder.cjs.map +1 -1
  11. package/dist/EngineExecuteBuilder.d.cts +14 -25
  12. package/dist/EngineExecuteBuilder.d.ts +14 -25
  13. package/dist/EngineExecuteBuilder.js +25 -53
  14. package/dist/EngineExecuteBuilder.js.map +1 -1
  15. package/dist/EngineExecuteClient.cjs +12 -16
  16. package/dist/EngineExecuteClient.cjs.map +1 -1
  17. package/dist/EngineExecuteClient.d.cts +5 -6
  18. package/dist/EngineExecuteClient.d.ts +5 -6
  19. package/dist/EngineExecuteClient.js +12 -16
  20. package/dist/EngineExecuteClient.js.map +1 -1
  21. package/dist/EngineQueryClient.cjs +33 -57
  22. package/dist/EngineQueryClient.cjs.map +1 -1
  23. package/dist/EngineQueryClient.d.cts +4 -15
  24. package/dist/EngineQueryClient.d.ts +4 -15
  25. package/dist/EngineQueryClient.js +11 -35
  26. package/dist/EngineQueryClient.js.map +1 -1
  27. package/dist/EngineWebClient.cjs +0 -2
  28. package/dist/EngineWebClient.cjs.map +1 -1
  29. package/dist/EngineWebClient.d.cts +1 -2
  30. package/dist/EngineWebClient.d.ts +1 -2
  31. package/dist/EngineWebClient.js +0 -2
  32. package/dist/EngineWebClient.js.map +1 -1
  33. package/dist/endpoints.cjs +6 -6
  34. package/dist/endpoints.cjs.map +1 -1
  35. package/dist/endpoints.d.cts +1 -1
  36. package/dist/endpoints.d.ts +1 -1
  37. package/dist/endpoints.js +6 -6
  38. package/dist/endpoints.js.map +1 -1
  39. package/dist/index.d.cts +7 -8
  40. package/dist/index.d.ts +7 -8
  41. package/dist/types/EngineServerFailureError.cjs +1 -1
  42. package/dist/types/EngineServerFailureError.cjs.map +1 -1
  43. package/dist/types/EngineServerFailureError.d.cts +2 -2
  44. package/dist/types/EngineServerFailureError.d.ts +2 -2
  45. package/dist/types/EngineServerFailureError.js +1 -1
  46. package/dist/types/EngineServerFailureError.js.map +1 -1
  47. package/dist/types/clientExecuteTypes.cjs.map +1 -1
  48. package/dist/types/clientExecuteTypes.d.cts +8 -16
  49. package/dist/types/clientExecuteTypes.d.ts +8 -16
  50. package/dist/types/clientQueryTypes.cjs.map +1 -1
  51. package/dist/types/clientQueryTypes.d.cts +15 -25
  52. package/dist/types/clientQueryTypes.d.ts +15 -25
  53. package/dist/types/index.d.cts +7 -8
  54. package/dist/types/index.d.ts +7 -8
  55. package/dist/types/serverExecuteTypes.cjs.map +1 -1
  56. package/dist/types/serverExecuteTypes.d.cts +10 -18
  57. package/dist/types/serverExecuteTypes.d.ts +10 -18
  58. package/dist/types/serverQueryModelTypes.cjs.map +1 -1
  59. package/dist/types/serverQueryModelTypes.d.cts +1 -1
  60. package/dist/types/serverQueryModelTypes.d.ts +1 -1
  61. package/dist/types/serverQueryTypes.cjs.map +1 -1
  62. package/dist/types/serverQueryTypes.d.cts +8 -17
  63. package/dist/types/serverQueryTypes.d.ts +8 -17
  64. package/dist/types/serverSubscriptionEventTypes.cjs.map +1 -1
  65. package/dist/types/serverSubscriptionEventTypes.d.cts +83 -24
  66. package/dist/types/serverSubscriptionEventTypes.d.ts +83 -24
  67. package/dist/types/serverSubscriptionTypes.cjs.map +1 -1
  68. package/dist/types/serverSubscriptionTypes.d.cts +21 -4
  69. package/dist/types/serverSubscriptionTypes.d.ts +21 -4
  70. package/dist/utils/index.d.cts +1 -2
  71. package/dist/utils/index.d.ts +1 -2
  72. package/dist/utils/productEngineTypeMappers.cjs +5 -5
  73. package/dist/utils/productEngineTypeMappers.cjs.map +1 -1
  74. package/dist/utils/productEngineTypeMappers.d.cts +1 -1
  75. package/dist/utils/productEngineTypeMappers.d.ts +1 -1
  76. package/dist/utils/productEngineTypeMappers.js +1 -1
  77. package/dist/utils/productEngineTypeMappers.js.map +1 -1
  78. package/dist/utils/queryDataMappers.cjs +79 -90
  79. package/dist/utils/queryDataMappers.cjs.map +1 -1
  80. package/dist/utils/queryDataMappers.d.cts +1 -2
  81. package/dist/utils/queryDataMappers.d.ts +1 -2
  82. package/dist/utils/queryDataMappers.js +7 -19
  83. package/dist/utils/queryDataMappers.js.map +1 -1
  84. package/package.json +3 -4
  85. package/src/EngineBaseClient.ts +5 -3
  86. package/src/EngineExecuteBuilder.ts +30 -70
  87. package/src/EngineExecuteClient.ts +13 -21
  88. package/src/EngineQueryClient.ts +14 -42
  89. package/src/EngineWebClient.ts +0 -2
  90. package/src/endpoints.ts +4 -5
  91. package/src/types/EngineServerFailureError.ts +2 -2
  92. package/src/types/clientExecuteTypes.ts +13 -25
  93. package/src/types/clientQueryTypes.ts +21 -34
  94. package/src/types/serverExecuteTypes.ts +13 -24
  95. package/src/types/serverQueryModelTypes.ts +1 -1
  96. package/src/types/serverQueryTypes.ts +7 -20
  97. package/src/types/serverSubscriptionEventTypes.ts +130 -22
  98. package/src/types/serverSubscriptionTypes.ts +23 -3
  99. package/src/utils/productEngineTypeMappers.ts +1 -1
  100. package/src/utils/queryDataMappers.ts +7 -20
@@ -1,9 +1,8 @@
1
1
  import {
2
- EIP712BurnVlpValues,
3
- EIP712IsolatedOrderParams,
2
+ EIP712BurnNlpValues,
4
3
  EIP712LinkSignerValues,
5
4
  EIP712LiquidateSubaccountValues,
6
- EIP712MintVlpValues,
5
+ EIP712MintNlpValues,
7
6
  EIP712OrderCancellationValues,
8
7
  EIP712OrderParams,
9
8
  EIP712OrderValues,
@@ -11,27 +10,30 @@ import {
11
10
  EIP712TransferQuoteValues,
12
11
  EIP712WithdrawCollateralValues,
13
12
  SignedTx,
14
- } from '@nadohq/contracts';
13
+ } from '@nadohq/shared';
15
14
  import { EngineServerOrderResponse } from './serverQueryTypes';
16
15
 
17
16
  export interface EngineServerPlaceOrderResponse {
18
17
  digest: string;
18
+ error: string | null;
19
19
  }
20
20
 
21
+ export type EngineServerPlaceOrdersResponse = EngineServerPlaceOrderResponse[];
22
+
21
23
  export interface EngineServerCancelOrdersResponse {
22
24
  cancelled_orders: EngineServerOrderResponse[];
23
25
  }
24
26
 
25
27
  export interface EngineServerExecuteResponseDataByType {
26
- burn_vlp: null;
28
+ burn_nlp: null;
27
29
  cancel_and_place: EngineServerPlaceOrderResponse;
28
30
  cancel_orders: EngineServerCancelOrdersResponse;
29
31
  cancel_product_orders: EngineServerCancelOrdersResponse;
30
32
  link_signer: null;
31
33
  liquidate_subaccount: null;
32
- mint_vlp: null;
33
- place_isolated_order: EngineServerPlaceOrderResponse;
34
+ mint_nlp: null;
34
35
  place_order: EngineServerPlaceOrderResponse;
36
+ place_orders: EngineServerPlaceOrdersResponse;
35
37
  transfer_quote: null;
36
38
  withdraw_collateral: null;
37
39
  }
@@ -71,15 +73,7 @@ export interface EngineServerPlaceOrderParams {
71
73
  signature: string;
72
74
  // Engine defaults this to true
73
75
  spot_leverage: boolean | null;
74
- }
75
-
76
- export interface EngineServerPlaceIsolatedOrderParams {
77
- id: number | null;
78
- product_id: number;
79
- isolated_order: EIP712OrderValues;
80
- // Bytes
81
- signature: string;
82
- // Engine defaults this to false
76
+ // For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative USDC balance)
83
77
  borrow_margin: boolean | null;
84
78
  }
85
79
 
@@ -104,7 +98,7 @@ type WithSpotLeverage<T> = T & {
104
98
  };
105
99
 
106
100
  export interface EngineServerExecuteRequestByType {
107
- burn_vlp: SignedTx<EIP712BurnVlpValues>;
101
+ burn_nlp: SignedTx<EIP712BurnNlpValues>;
108
102
  cancel_and_place: EngineServiceCancelAndPlaceParams;
109
103
  cancel_orders: EngineServerCancelOrdersParams;
110
104
  cancel_product_orders: SignedTx<
@@ -115,9 +109,9 @@ export interface EngineServerExecuteRequestByType {
115
109
  >;
116
110
  link_signer: SignedTx<EIP712LinkSignerValues>;
117
111
  liquidate_subaccount: SignedTx<EIP712LiquidateSubaccountValues>;
118
- mint_vlp: WithSpotLeverage<SignedTx<EIP712MintVlpValues>>;
119
- place_isolated_order: EngineServerPlaceIsolatedOrderParams;
112
+ mint_nlp: WithSpotLeverage<SignedTx<EIP712MintNlpValues>>;
120
113
  place_order: EngineServerPlaceOrderParams;
114
+ place_orders: EngineServerPlaceOrderParams[];
121
115
  transfer_quote: SignedTx<EIP712TransferQuoteValues>;
122
116
  withdraw_collateral: WithSpotLeverage<
123
117
  SignedTx<EIP712WithdrawCollateralValues>
@@ -131,8 +125,3 @@ export interface EngineServerExecutePlaceOrderPayload {
131
125
  payload: EngineServerExecuteRequestByType['place_order'];
132
126
  orderParams: EIP712OrderParams;
133
127
  }
134
-
135
- export interface EngineServerExecutePlaceIsolatedOrderPayload {
136
- payload: EngineServerExecuteRequestByType['place_isolated_order'];
137
- orderParams: EIP712IsolatedOrderParams;
138
- }
@@ -6,7 +6,6 @@ export interface EngineServerHealthBreakdown {
6
6
 
7
7
  export interface EngineServerSpotBalanceData {
8
8
  amount: string;
9
- last_cumulative_multiplier_x18: string;
10
9
  }
11
10
 
12
11
  export interface EngineServerPerpBalanceData {
@@ -36,6 +35,7 @@ export interface EngineServerSpotConfig {
36
35
  interest_floor_x18: string;
37
36
  interest_small_cap_x18: string;
38
37
  interest_large_cap_x18: string;
38
+ min_deposit_rate_x18: string;
39
39
  }
40
40
 
41
41
  export interface EngineServerSpotState {
@@ -1,4 +1,4 @@
1
- import { HealthStatus } from '@nadohq/contracts';
1
+ import { HealthStatus } from '@nadohq/shared';
2
2
  import {
3
3
  EngineServerHealthBreakdown,
4
4
  EngineServerPerpBalance,
@@ -95,7 +95,7 @@ export interface EngineServerLinkedSignerParams {
95
95
  subaccount: string;
96
96
  }
97
97
 
98
- export interface EngineServerMaxMintVlpQueryParams {
98
+ export interface EngineServerMaxMintNlpQueryParams {
99
99
  sender: string;
100
100
  // If not given, engine defaults to true (leverage/borrow enabled)
101
101
  spot_leverage: string | null;
@@ -113,10 +113,9 @@ export interface EngineServerQueryRequestByType {
113
113
  market_liquidity: EngineServerMarketLiquidityQueryParams;
114
114
  market_price: EngineServerMarketPriceQueryParams;
115
115
  market_prices: EngineServerMarketPricesQueryParams;
116
- max_vlp_mintable: EngineServerMaxMintVlpQueryParams;
116
+ max_nlp_mintable: EngineServerMaxMintNlpQueryParams;
117
117
  max_order_size: EngineServerMaxOrderSizeQueryParams;
118
118
  max_withdrawable: EngineServerMaxWithdrawableQueryParams;
119
- min_deposit_rates: Record<string, never>;
120
119
  nonces: EngineServerNoncesParams;
121
120
  order: EngineServerGetOrderQueryParams;
122
121
  orders: EngineServerOrdersQueryParams;
@@ -141,8 +140,6 @@ export type EngineServerQueryRequest<
141
140
  export interface EngineServerContractsResponse {
142
141
  chain_id: string;
143
142
  endpoint_addr: string;
144
- // Index is product ID
145
- book_addrs: string[];
146
143
  }
147
144
 
148
145
  // Unless in active state, engine is not fully operational
@@ -256,6 +253,7 @@ export interface EngineServerFeeRatesResponse {
256
253
  withdraw_sequencer_fees: string[];
257
254
  taker_fee_rates_x18: string[];
258
255
  maker_fee_rates_x18: string[];
256
+ fee_tier: number;
259
257
  }
260
258
 
261
259
  export interface EngineServerMarketPrice {
@@ -281,7 +279,7 @@ export interface EngineServerOrder {
281
279
  digest: string;
282
280
  placed_at: number;
283
281
  order_type: string;
284
- margin: string | null;
282
+ appendix: string;
285
283
  }
286
284
 
287
285
  export type EngineServerOrderResponse = EngineServerOrder;
@@ -315,22 +313,12 @@ export interface EngineInsuranceResponse {
315
313
  insurance: string;
316
314
  }
317
315
 
318
- export interface EngineServerMinDepositRate {
319
- product_id: number;
320
- min_deposit_rate_x18: string;
321
- }
322
-
323
- export interface EngineServerMinDepositRatesResponse {
324
- // product_id -> EngineServerMinDepositRate
325
- min_deposit_rates: Record<number, EngineServerMinDepositRate>;
326
- }
327
-
328
316
  export interface EngineServerEdgeAllProductsResponse {
329
317
  // chain_id -> EngineServerAllProductsResponse
330
318
  edge_all_products: Record<number, EngineServerAllProductsResponse>;
331
319
  }
332
320
 
333
- export interface EngineServerMaxMintVlpResponse {
321
+ export interface EngineServerMaxMintNlpResponse {
334
322
  max_quote_amount: string;
335
323
  }
336
324
 
@@ -346,10 +334,9 @@ export interface EngineServerQueryResponseByType {
346
334
  market_liquidity: EngineServerMarketLiquidityResponse;
347
335
  market_price: EngineServerMarketPriceResponse;
348
336
  market_prices: EngineServerMarketPricesResponse;
349
- max_vlp_mintable: EngineServerMaxMintVlpResponse;
337
+ max_nlp_mintable: EngineServerMaxMintNlpResponse;
350
338
  max_order_size: EngineServerMaxOrderSizeResponse;
351
339
  max_withdrawable: EngineServerMaxWithdrawableResponse;
352
- min_deposit_rates: EngineServerMinDepositRatesResponse;
353
340
  nonces: EngineServerNoncesResponse;
354
341
  order: EngineServerOrderResponse;
355
342
  orders: EngineServerProductOrdersResponse;
@@ -1,22 +1,51 @@
1
- import { EngineServerPriceTickLiquidity } from './serverQueryTypes';
1
+ import {
2
+ EngineServerOrder,
3
+ EngineServerPriceTickLiquidity,
4
+ } from './serverQueryTypes';
2
5
 
3
6
  /**
4
- * Event from subscribing to a `order_update` stream.
7
+ * Reasons that can trigger position change events.
5
8
  */
6
- export interface EngineServerSubscriptionOrderUpdateEvent {
7
- timestamp: string;
9
+ export type PositionChangeReason =
10
+ | 'deposit_collateral'
11
+ | 'match_orders'
12
+ | 'withdraw_collateral'
13
+ | 'transfer_quote'
14
+ | 'settle_pnl'
15
+ | 'mint_nlp'
16
+ | 'burn_nlp'
17
+ | 'liquidate_subaccount';
18
+
19
+ /**
20
+ * Possible reasons for order updates.
21
+ */
22
+ export type OrderUpdateReason = 'cancelled' | 'filled' | 'placed';
23
+
24
+ export type EngineServerSubscriptionEventType =
25
+ | 'trade'
26
+ | 'best_bid_offer'
27
+ | 'book_depth'
28
+ | 'fill'
29
+ | 'position_change'
30
+ | 'order_update'
31
+ | 'liquidation'
32
+ | 'latest_candlestick'
33
+ | 'funding_payment';
34
+
35
+ export interface EngineServerSubscriptionBaseEvent<
36
+ T extends
37
+ EngineServerSubscriptionEventType = EngineServerSubscriptionEventType,
38
+ > {
39
+ type: T;
8
40
  product_id: number;
9
- digest: string;
10
- amount: string;
11
- reason: string;
12
41
  }
13
42
 
14
43
  /**
15
44
  * Event from subscribing to a `trade` stream.
16
45
  */
17
- export interface EngineServerSubscriptionTradeEvent {
46
+ export interface EngineServerSubscriptionTradeEvent
47
+ extends EngineServerSubscriptionBaseEvent<'trade'> {
18
48
  timestamp: string;
19
- product_id: number;
20
49
  price: string;
21
50
  taker_qty: string;
22
51
  maker_qty: string;
@@ -26,49 +55,128 @@ export interface EngineServerSubscriptionTradeEvent {
26
55
  /**
27
56
  * Event from subscribing to a `best_bid_offer` stream.
28
57
  */
29
- export interface EngineServerSubscriptionBestBidOfferEvent {
58
+ export interface EngineServerSubscriptionBestBidOfferEvent
59
+ extends EngineServerSubscriptionBaseEvent<'best_bid_offer'> {
30
60
  timestamp: string;
31
- product_id: number;
32
61
  bid_price: string;
33
62
  bid_qty: string;
34
63
  ask_price: string;
35
64
  ask_qty: string;
36
65
  }
37
66
 
67
+ /**
68
+ * Event from subscribing to a `book_depth` stream.
69
+ */
70
+ export interface EngineServerSubscriptionBookDepthEvent
71
+ extends EngineServerSubscriptionBaseEvent<'book_depth'> {
72
+ last_max_timestamp: string;
73
+ min_timestamp: string;
74
+ max_timestamp: string;
75
+ bids: EngineServerPriceTickLiquidity[];
76
+ asks: EngineServerPriceTickLiquidity[];
77
+ }
78
+
38
79
  /**
39
80
  * Event from subscribing to a `fill` stream.
40
81
  */
41
- export interface EngineServerSubscriptionFillEvent {
82
+ export interface EngineServerSubscriptionFillEvent
83
+ extends EngineServerSubscriptionBaseEvent<'fill'> {
42
84
  // NOTE: `id` is excluded from the response to avoid parsing issues.
43
85
  // type of `id` on the backend is `u64` which can overflow until we introduce proper parsing on the SDK.
44
86
  timestamp: string;
45
- product_id: number;
46
87
  subaccount: string;
47
88
  order_digest: string;
48
89
  filled_qty: string;
49
90
  remaining_qty: string;
91
+ original_qty: string;
50
92
  price: string;
51
93
  is_taker: boolean;
94
+ is_bid: boolean;
95
+ fee: string;
96
+ submission_idx: string;
97
+ appendix: string;
52
98
  }
53
99
 
54
100
  /**
55
101
  * Event from subscribing to a `position_change` stream.
56
102
  */
57
- export interface EngineServerSubscriptionPositionChangeEvent {
103
+ export interface EngineServerSubscriptionPositionChangeEvent
104
+ extends EngineServerSubscriptionBaseEvent<'position_change'> {
58
105
  timestamp: string;
59
- product_id: number;
60
106
  subaccount: string;
61
107
  amount: string;
108
+ /** Zero for everything except perps */
62
109
  v_quote_amount: string;
110
+ reason: PositionChangeReason;
63
111
  }
64
112
 
65
113
  /**
66
- * Event from subscribing to a `book_depth` stream.
114
+ * Event from subscribing to an `order_update` stream.
67
115
  */
68
- export interface EngineServerSubscriptionBookDepthEvent {
69
- min_timestamp: string;
70
- max_timestamp: string;
71
- product_id: number;
72
- bids: EngineServerPriceTickLiquidity[];
73
- asks: EngineServerPriceTickLiquidity[];
116
+ export interface EngineServerSubscriptionOrderUpdateEvent
117
+ extends EngineServerSubscriptionBaseEvent<'order_update'> {
118
+ timestamp: string;
119
+ order: EngineServerOrder;
120
+ reason: OrderUpdateReason;
121
+ }
122
+
123
+ /**
124
+ * Event from subscribing to a `liquidation` stream.
125
+ */
126
+ export interface EngineServerSubscriptionLiquidationEvent
127
+ extends EngineServerSubscriptionBaseEvent<'liquidation'> {
128
+ timestamp: string;
129
+ /** Single element for regular liquidations, two elements for spread liquidations [spotId, perpId] */
130
+ product_ids: number[];
131
+ liquidator: string;
132
+ liquidatee: string;
133
+ /** Amount liquidated (positive for long, negative for short) */
134
+ amount: string;
135
+ /** Price at which liquidation occurred */
136
+ price: string;
74
137
  }
138
+
139
+ /**
140
+ * Event from subscribing to a `latest_candlestick` stream.
141
+ */
142
+ export interface EngineServerSubscriptionLatestCandlestickEvent
143
+ extends EngineServerSubscriptionBaseEvent<'latest_candlestick'> {
144
+ timestamp: string;
145
+ granularity: number;
146
+ open_x18: string;
147
+ high_x18: string;
148
+ low_x18: string;
149
+ close_x18: string;
150
+ volume: string;
151
+ }
152
+
153
+ /**
154
+ * Event from subscribing to a `funding_payment` stream.
155
+ */
156
+ export interface EngineServerSubscriptionFundingPaymentEvent
157
+ extends EngineServerSubscriptionBaseEvent<'funding_payment'> {
158
+ timestamp: string;
159
+ /** Funding payment amount (positive = receive, negative = pay) */
160
+ payment_amount: string;
161
+ /** Open interest at time of funding */
162
+ open_interest: string;
163
+ /** Current cumulative funding values */
164
+ cumulative_funding_long_x18: string;
165
+ cumulative_funding_short_x18: string;
166
+ /** Time delta over which the funding payment was calculated */
167
+ dt: string;
168
+ }
169
+
170
+ /**
171
+ * Union type for all engine server subscription events.
172
+ */
173
+ export type EngineServerSubscriptionEvent =
174
+ | EngineServerSubscriptionTradeEvent
175
+ | EngineServerSubscriptionBestBidOfferEvent
176
+ | EngineServerSubscriptionBookDepthEvent
177
+ | EngineServerSubscriptionFillEvent
178
+ | EngineServerSubscriptionPositionChangeEvent
179
+ | EngineServerSubscriptionOrderUpdateEvent
180
+ | EngineServerSubscriptionLiquidationEvent
181
+ | EngineServerSubscriptionLatestCandlestickEvent
182
+ | EngineServerSubscriptionFundingPaymentEvent;
@@ -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,12 +13,14 @@ 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
 
19
21
  export interface EngineServerPositionChangeStreamParams {
20
- product_id: number;
22
+ /** when not provided, subscribes to all products */
23
+ product_id?: number;
21
24
  subaccount: string;
22
25
  }
23
26
 
@@ -25,6 +28,20 @@ export interface EngineServerBookDepthStreamParams {
25
28
  product_id: number;
26
29
  }
27
30
 
31
+ export interface EngineServerLatestCandlestickStreamParams {
32
+ product_id: number;
33
+ granularity: number;
34
+ }
35
+
36
+ export interface EngineServerLiquidationStreamParams {
37
+ /** when not provided, subscribes to all products */
38
+ product_id?: number;
39
+ }
40
+
41
+ export interface EngineServerFundingPaymentStreamParams {
42
+ product_id: number;
43
+ }
44
+
28
45
  /**
29
46
  * Available subscription streams
30
47
  */
@@ -35,6 +52,9 @@ export interface EngineServerSubscriptionStreamParamsByType {
35
52
  fill: EngineServerFillStreamParams;
36
53
  position_change: EngineServerPositionChangeStreamParams;
37
54
  book_depth: EngineServerBookDepthStreamParams;
55
+ liquidation: EngineServerLiquidationStreamParams;
56
+ latest_candlestick: EngineServerLatestCandlestickStreamParams;
57
+ funding_payment: EngineServerFundingPaymentStreamParams;
38
58
  }
39
59
 
40
60
  export type EngineServerSubscriptionStreamParamsType =
@@ -1,4 +1,4 @@
1
- import { ProductEngineType } from '@nadohq/contracts';
1
+ import { ProductEngineType } from '@nadohq/shared';
2
2
  import { EngineServerProductType } from '../types';
3
3
 
4
4
  export function mapProductEngineType(
@@ -2,18 +2,15 @@ import {
2
2
  BalanceHealthContributions,
3
3
  calcTotalBorrowed,
4
4
  calcTotalDeposited,
5
- OrderExpirationType,
5
+ mapValues,
6
6
  PerpMarket,
7
7
  ProductEngineType,
8
+ removeDecimals,
8
9
  SpotMarket,
9
10
  subaccountFromHex,
10
- } from '@nadohq/contracts';
11
- import {
12
- mapValues,
13
- removeDecimals,
14
11
  toBigDecimal,
15
- toIntegerString,
16
- } from '@nadohq/utils';
12
+ unpackOrderAppendix,
13
+ } from '@nadohq/shared';
17
14
  import {
18
15
  EngineMarketPrice,
19
16
  EngineOrder,
@@ -49,7 +46,7 @@ export function mapEngineServerOrder(
49
46
  const subaccount = subaccountFromHex(order.sender);
50
47
  return {
51
48
  digest: order.digest,
52
- expiration: toBigDecimal(order.expiration),
49
+ expiration: Number(order.expiration),
53
50
  nonce: order.nonce,
54
51
  price: removeDecimals(order.price_x18),
55
52
  productId: order.product_id,
@@ -57,19 +54,8 @@ export function mapEngineServerOrder(
57
54
  subaccountName: subaccount.subaccountName,
58
55
  totalAmount: toBigDecimal(order.amount),
59
56
  unfilledAmount: toBigDecimal(order.unfilled_amount),
60
- margin: order.margin ? toBigDecimal(order.margin) : null,
61
- // Standardizes from hex
62
- // toFixed is required as toString gives values with `e`
63
- orderParams: {
64
- amount: toIntegerString(order.amount),
65
- expiration: toIntegerString(order.expiration),
66
- nonce: order.nonce,
67
- price: toIntegerString(removeDecimals(order.price_x18)),
68
- subaccountOwner: subaccount.subaccountOwner,
69
- subaccountName: subaccount.subaccountName,
70
- },
71
57
  placementTime: order.placed_at,
72
- orderType: order.order_type as OrderExpirationType,
58
+ appendix: unpackOrderAppendix(order.appendix),
73
59
  };
74
60
  }
75
61
 
@@ -100,6 +86,7 @@ export function mapEngineServerSpotProduct(
100
86
  ),
101
87
  interestLargeCap: removeDecimals(product.config.interest_large_cap_x18),
102
88
  interestSmallCap: removeDecimals(product.config.interest_small_cap_x18),
89
+ minDepositRate: removeDecimals(product.config.min_deposit_rate_x18),
103
90
  longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),
104
91
  longWeightMaintenance: removeDecimals(
105
92
  product.risk.long_weight_maintenance_x18,