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

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 (83) hide show
  1. package/dist/EngineBaseClient.d.cts +2 -1
  2. package/dist/EngineBaseClient.d.ts +2 -1
  3. package/dist/EngineClient.d.cts +1 -0
  4. package/dist/EngineClient.d.ts +1 -0
  5. package/dist/EngineExecuteBuilder.cjs +9 -6
  6. package/dist/EngineExecuteBuilder.cjs.map +1 -1
  7. package/dist/EngineExecuteBuilder.d.cts +1 -0
  8. package/dist/EngineExecuteBuilder.d.ts +1 -0
  9. package/dist/EngineExecuteBuilder.js +9 -6
  10. package/dist/EngineExecuteBuilder.js.map +1 -1
  11. package/dist/EngineExecuteClient.cjs +6 -6
  12. package/dist/EngineExecuteClient.cjs.map +1 -1
  13. package/dist/EngineExecuteClient.d.cts +2 -1
  14. package/dist/EngineExecuteClient.d.ts +2 -1
  15. package/dist/EngineExecuteClient.js +6 -6
  16. package/dist/EngineExecuteClient.js.map +1 -1
  17. package/dist/EngineQueryClient.cjs +54 -11
  18. package/dist/EngineQueryClient.cjs.map +1 -1
  19. package/dist/EngineQueryClient.d.cts +19 -2
  20. package/dist/EngineQueryClient.d.ts +19 -2
  21. package/dist/EngineQueryClient.js +57 -12
  22. package/dist/EngineQueryClient.js.map +1 -1
  23. package/dist/EngineWebClient.d.cts +1 -0
  24. package/dist/EngineWebClient.d.ts +1 -0
  25. package/dist/endpoints.cjs +6 -6
  26. package/dist/endpoints.cjs.map +1 -1
  27. package/dist/endpoints.js +6 -6
  28. package/dist/endpoints.js.map +1 -1
  29. package/dist/index.cjs +4 -4
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +9 -8
  32. package/dist/index.d.ts +9 -8
  33. package/dist/index.js +2 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/types/clientExecuteTypes.cjs.map +1 -1
  36. package/dist/types/clientExecuteTypes.d.cts +8 -1
  37. package/dist/types/clientExecuteTypes.d.ts +8 -1
  38. package/dist/types/clientQueryTypes.cjs.map +1 -1
  39. package/dist/types/clientQueryTypes.d.cts +66 -33
  40. package/dist/types/clientQueryTypes.d.ts +66 -33
  41. package/dist/types/index.cjs +10 -10
  42. package/dist/types/index.cjs.map +1 -1
  43. package/dist/types/index.d.cts +6 -5
  44. package/dist/types/index.d.ts +6 -5
  45. package/dist/types/index.js +5 -5
  46. package/dist/types/index.js.map +1 -1
  47. package/dist/types/serverExecuteTypes.cjs.map +1 -1
  48. package/dist/types/serverExecuteTypes.d.cts +8 -1
  49. package/dist/types/serverExecuteTypes.d.ts +8 -1
  50. package/dist/types/serverQueryModelTypes.cjs.map +1 -1
  51. package/dist/types/serverQueryModelTypes.d.cts +24 -1
  52. package/dist/types/serverQueryModelTypes.d.ts +24 -1
  53. package/dist/types/serverQueryTypes.cjs +19 -0
  54. package/dist/types/serverQueryTypes.cjs.map +1 -1
  55. package/dist/types/serverQueryTypes.d.cts +49 -23
  56. package/dist/types/serverQueryTypes.d.ts +49 -23
  57. package/dist/types/serverQueryTypes.js +12 -0
  58. package/dist/types/serverQueryTypes.js.map +1 -1
  59. package/dist/types/serverSubscriptionEventTypes.cjs.map +1 -1
  60. package/dist/types/serverSubscriptionEventTypes.d.cts +7 -2
  61. package/dist/types/serverSubscriptionEventTypes.d.ts +7 -2
  62. package/dist/utils/index.d.cts +3 -2
  63. package/dist/utils/index.d.ts +3 -2
  64. package/dist/utils/queryDataMappers.cjs +95 -47
  65. package/dist/utils/queryDataMappers.cjs.map +1 -1
  66. package/dist/utils/queryDataMappers.d.cts +8 -5
  67. package/dist/utils/queryDataMappers.d.ts +8 -5
  68. package/dist/utils/queryDataMappers.js +94 -48
  69. package/dist/utils/queryDataMappers.js.map +1 -1
  70. package/package.json +13 -7
  71. package/src/EngineExecuteBuilder.ts +9 -6
  72. package/src/EngineExecuteClient.ts +7 -7
  73. package/src/EngineQueryClient.ts +73 -12
  74. package/src/endpoints.ts +6 -6
  75. package/src/index.ts +2 -2
  76. package/src/types/clientExecuteTypes.ts +9 -2
  77. package/src/types/clientQueryTypes.ts +76 -32
  78. package/src/types/index.ts +5 -5
  79. package/src/types/serverExecuteTypes.ts +9 -2
  80. package/src/types/serverQueryModelTypes.ts +25 -0
  81. package/src/types/serverQueryTypes.ts +74 -31
  82. package/src/types/serverSubscriptionEventTypes.ts +18 -25
  83. package/src/utils/queryDataMappers.ts +115 -49
@@ -1,5 +1,5 @@
1
1
  import { HealthStatus } from '@nadohq/shared';
2
- import { EngineServerProductType, EngineServerSpotProduct, EngineServerPerpProduct, EngineServerSpotBalance, EngineServerPerpBalance, EngineServerHealthBreakdown } from './serverQueryModelTypes.js';
2
+ import { EngineServerProductType, EngineServerSpotProduct, EngineServerPerpProduct, EngineServerSpotBalance, EngineServerPerpBalance, EngineServerNlpBalance, EngineServerNlpLockedBalance, EngineServerHealthBreakdown, EngineServerOrder } from './serverQueryModelTypes.js';
3
3
 
4
4
  interface EngineServerNoncesParams {
5
5
  address: string;
@@ -14,6 +14,7 @@ interface EngineServerSubaccountInfoQueryParams {
14
14
  v_quote_delta: string;
15
15
  };
16
16
  }>;
17
+ pre_state?: string;
17
18
  }
18
19
  interface EngineServerIsolatedPositionsQueryParams {
19
20
  subaccount: string;
@@ -63,6 +64,8 @@ interface EngineServerMaxOrderSizeQueryParams {
63
64
  direction: 'long' | 'short';
64
65
  spot_leverage: string | null;
65
66
  reduce_only: string | null;
67
+ isolated: string | null;
68
+ borrow_margin: string | null;
66
69
  }
67
70
  interface EngineServerLinkedSignerParams {
68
71
  subaccount: string;
@@ -71,6 +74,12 @@ interface EngineServerMaxMintNlpQueryParams {
71
74
  sender: string;
72
75
  spot_leverage: string | null;
73
76
  }
77
+ interface EngineServerMaxBurnNlpQueryParams {
78
+ sender: string;
79
+ }
80
+ interface EngineServerNlpLockedBalancesQueryParams {
81
+ subaccount: string;
82
+ }
74
83
  interface EngineServerQueryRequestByType {
75
84
  all_products: Record<string, never>;
76
85
  contracts: Record<string, never>;
@@ -83,8 +92,11 @@ interface EngineServerQueryRequestByType {
83
92
  market_liquidity: EngineServerMarketLiquidityQueryParams;
84
93
  market_price: EngineServerMarketPriceQueryParams;
85
94
  market_prices: EngineServerMarketPricesQueryParams;
95
+ max_nlp_burnable: EngineServerMaxBurnNlpQueryParams;
86
96
  max_nlp_mintable: EngineServerMaxMintNlpQueryParams;
87
97
  max_order_size: EngineServerMaxOrderSizeQueryParams;
98
+ nlp_locked_balances: EngineServerNlpLockedBalancesQueryParams;
99
+ nlp_pool_info: Record<string, never>;
88
100
  max_withdrawable: EngineServerMaxWithdrawableQueryParams;
89
101
  nonces: EngineServerNoncesParams;
90
102
  order: EngineServerGetOrderQueryParams;
@@ -105,26 +117,31 @@ interface EngineServerContractsResponse {
105
117
  chain_id: string;
106
118
  endpoint_addr: string;
107
119
  }
108
- type EngineServerStatusResponse = 'started' | 'active' | 'stopping' | 'syncing' | 'live_syncing' | 'failed';
120
+ declare const ENGINE_SERVER_STATUS_VALUES: readonly ["started", "active", "stopping", "syncing", "live_syncing", "failed"];
121
+ type EngineServerStatusResponse = (typeof ENGINE_SERVER_STATUS_VALUES)[number];
109
122
  interface EngineServerNoncesResponse {
110
123
  order_nonce: string;
111
124
  tx_nonce: string;
112
125
  }
113
- interface EngineServerSubaccountInfoResponse {
126
+ interface EngineServerSubaccountInfoResponse extends EngineServerSubaccountInfoState {
114
127
  exists: boolean;
115
128
  subaccount: string;
129
+ spot_count: number;
130
+ perp_count: number;
131
+ spot_products: EngineServerSpotProduct[];
132
+ perp_products: EngineServerPerpProduct[];
133
+ /** This is set if request has `pre_state` flag set to 'true' */
134
+ pre_state: EngineServerSubaccountInfoState | undefined;
135
+ }
136
+ interface EngineServerSubaccountInfoState {
116
137
  healths: [
117
138
  initial: EngineServerHealthBreakdown,
118
139
  maintenance: EngineServerHealthBreakdown,
119
140
  unweighted: EngineServerHealthBreakdown
120
141
  ];
121
142
  health_contributions: string[][];
122
- spot_count: number;
123
- perp_count: number;
124
143
  spot_balances: EngineServerSpotBalance[];
125
144
  perp_balances: EngineServerPerpBalance[];
126
- spot_products: EngineServerSpotProduct[];
127
- perp_products: EngineServerPerpProduct[];
128
145
  }
129
146
  interface EngineServerIsolatedPosition {
130
147
  subaccount: string;
@@ -150,12 +167,12 @@ interface EngineServerSymbol {
150
167
  price_increment_x18: string;
151
168
  size_increment: string;
152
169
  min_size: string;
153
- min_depth_x18: string;
154
- max_spread_rate_x18: string;
155
170
  maker_fee_rate_x18: string;
156
171
  taker_fee_rate_x18: string;
157
172
  long_weight_initial_x18: string;
158
173
  long_weight_maintenance_x18: string;
174
+ max_open_interest_x18: string | undefined;
175
+ isolated_only: boolean;
159
176
  }
160
177
  interface EngineServerSymbolsResponse {
161
178
  symbols: Record<string, EngineServerSymbol>;
@@ -203,19 +220,6 @@ type EngineServerMarketPriceResponse = EngineServerMarketPrice;
203
220
  interface EngineServerMarketPricesResponse {
204
221
  market_prices: EngineServerMarketPrice[];
205
222
  }
206
- interface EngineServerOrder {
207
- product_id: number;
208
- sender: string;
209
- price_x18: string;
210
- amount: string;
211
- expiration: string;
212
- nonce: string;
213
- unfilled_amount: string;
214
- digest: string;
215
- placed_at: number;
216
- order_type: string;
217
- appendix: string;
218
- }
219
223
  type EngineServerOrderResponse = EngineServerOrder;
220
224
  interface EngineServerValidateOrderResponse {
221
225
  product_id: number;
@@ -242,9 +246,28 @@ interface EngineInsuranceResponse {
242
246
  interface EngineServerEdgeAllProductsResponse {
243
247
  edge_all_products: Record<number, EngineServerAllProductsResponse>;
244
248
  }
249
+ interface EngineServerMaxBurnNlpResponse {
250
+ max_nlp_amount: string;
251
+ }
245
252
  interface EngineServerMaxMintNlpResponse {
246
253
  max_quote_amount: string;
247
254
  }
255
+ interface EngineServerNlpLockedBalancesResponse {
256
+ balance_locked: EngineServerNlpBalance;
257
+ balance_unlocked: EngineServerNlpBalance;
258
+ locked_balances: EngineServerNlpLockedBalance[];
259
+ }
260
+ interface EngineServerNlpPool {
261
+ pool_id: number;
262
+ subaccount: string;
263
+ owner: string;
264
+ balance_weight_x18: string;
265
+ subaccount_info: EngineServerSubaccountInfoResponse;
266
+ open_orders: EngineServerOrder[];
267
+ }
268
+ interface EngineServerNlpPoolInfoResponse {
269
+ nlp_pools: EngineServerNlpPool[];
270
+ }
248
271
  interface EngineServerQueryResponseByType {
249
272
  all_products: EngineServerAllProductsResponse;
250
273
  contracts: EngineServerContractsResponse;
@@ -257,8 +280,11 @@ interface EngineServerQueryResponseByType {
257
280
  market_liquidity: EngineServerMarketLiquidityResponse;
258
281
  market_price: EngineServerMarketPriceResponse;
259
282
  market_prices: EngineServerMarketPricesResponse;
283
+ max_nlp_burnable: EngineServerMaxBurnNlpResponse;
260
284
  max_nlp_mintable: EngineServerMaxMintNlpResponse;
261
285
  max_order_size: EngineServerMaxOrderSizeResponse;
286
+ nlp_locked_balances: EngineServerNlpLockedBalancesResponse;
287
+ nlp_pool_info: EngineServerNlpPoolInfoResponse;
262
288
  max_withdrawable: EngineServerMaxWithdrawableResponse;
263
289
  nonces: EngineServerNoncesResponse;
264
290
  order: EngineServerOrderResponse;
@@ -280,4 +306,4 @@ interface EngineServerQueryFailureResponse {
280
306
  }
281
307
  type EngineServerQueryResponse<TQueryType extends keyof EngineServerQueryResponseByType = EngineServerQueryRequestType> = EngineServerQuerySuccessResponse<TQueryType> | EngineServerQueryFailureResponse;
282
308
 
283
- export type { EngineInsuranceResponse, EngineServerAllProductsResponse, EngineServerContractsResponse, EngineServerEdgeAllProductsResponse, EngineServerFeeRatesResponse, EngineServerGetOrderQueryParams, EngineServerHealthGroupsResponse, EngineServerIpBlockResponse, EngineServerIsolatedPosition, EngineServerIsolatedPositionsQueryParams, EngineServerIsolatedPositionsResponse, EngineServerLinkedSignerParams, EngineServerLinkedSignerResponse, EngineServerMarketLiquidityQueryParams, EngineServerMarketLiquidityResponse, EngineServerMarketPrice, EngineServerMarketPriceQueryParams, EngineServerMarketPriceResponse, EngineServerMarketPricesQueryParams, EngineServerMarketPricesResponse, EngineServerMaxMintNlpQueryParams, EngineServerMaxMintNlpResponse, EngineServerMaxOrderSizeQueryParams, EngineServerMaxOrderSizeResponse, EngineServerMaxWithdrawableQueryParams, EngineServerMaxWithdrawableResponse, EngineServerNoncesParams, EngineServerNoncesResponse, EngineServerOrder, EngineServerOrderResponse, EngineServerOrdersQueryParams, EngineServerPriceTickLiquidity, EngineServerProductOrdersResponse, EngineServerQueryFailureResponse, EngineServerQueryRequest, EngineServerQueryRequestByType, EngineServerQueryRequestType, EngineServerQueryResponse, EngineServerQueryResponseByType, EngineServerQuerySuccessResponse, EngineServerStatusResponse, EngineServerSubaccountFeeRatesParams, EngineServerSubaccountInfoQueryParams, EngineServerSubaccountInfoResponse, EngineServerSubaccountOrders, EngineServerSubaccountOrdersQueryParams, EngineServerSubaccountOrdersResponse, EngineServerSymbol, EngineServerSymbolsQueryParams, EngineServerSymbolsResponse, EngineServerTimeResponse, EngineServerValidateOrderQueryParams, EngineServerValidateOrderResponse };
309
+ export { ENGINE_SERVER_STATUS_VALUES, type EngineInsuranceResponse, type EngineServerAllProductsResponse, type EngineServerContractsResponse, type EngineServerEdgeAllProductsResponse, type EngineServerFeeRatesResponse, type EngineServerGetOrderQueryParams, type EngineServerHealthGroupsResponse, type EngineServerIpBlockResponse, type EngineServerIsolatedPosition, type EngineServerIsolatedPositionsQueryParams, type EngineServerIsolatedPositionsResponse, type EngineServerLinkedSignerParams, type EngineServerLinkedSignerResponse, type EngineServerMarketLiquidityQueryParams, type EngineServerMarketLiquidityResponse, type EngineServerMarketPrice, type EngineServerMarketPriceQueryParams, type EngineServerMarketPriceResponse, type EngineServerMarketPricesQueryParams, type EngineServerMarketPricesResponse, type EngineServerMaxBurnNlpQueryParams, type EngineServerMaxBurnNlpResponse, type EngineServerMaxMintNlpQueryParams, type EngineServerMaxMintNlpResponse, type EngineServerMaxOrderSizeQueryParams, type EngineServerMaxOrderSizeResponse, type EngineServerMaxWithdrawableQueryParams, type EngineServerMaxWithdrawableResponse, type EngineServerNlpLockedBalancesQueryParams, type EngineServerNlpLockedBalancesResponse, type EngineServerNlpPool, type EngineServerNlpPoolInfoResponse, type EngineServerNoncesParams, type EngineServerNoncesResponse, type EngineServerOrderResponse, type EngineServerOrdersQueryParams, type EngineServerPriceTickLiquidity, type EngineServerProductOrdersResponse, type EngineServerQueryFailureResponse, type EngineServerQueryRequest, type EngineServerQueryRequestByType, type EngineServerQueryRequestType, type EngineServerQueryResponse, type EngineServerQueryResponseByType, type EngineServerQuerySuccessResponse, type EngineServerStatusResponse, type EngineServerSubaccountFeeRatesParams, type EngineServerSubaccountInfoQueryParams, type EngineServerSubaccountInfoResponse, type EngineServerSubaccountInfoState, type EngineServerSubaccountOrders, type EngineServerSubaccountOrdersQueryParams, type EngineServerSubaccountOrdersResponse, type EngineServerSymbol, type EngineServerSymbolsQueryParams, type EngineServerSymbolsResponse, type EngineServerTimeResponse, type EngineServerValidateOrderQueryParams, type EngineServerValidateOrderResponse };
@@ -1 +1,13 @@
1
+ // src/types/serverQueryTypes.ts
2
+ var ENGINE_SERVER_STATUS_VALUES = [
3
+ "started",
4
+ "active",
5
+ "stopping",
6
+ "syncing",
7
+ "live_syncing",
8
+ "failed"
9
+ ];
10
+ export {
11
+ ENGINE_SERVER_STATUS_VALUES
12
+ };
1
13
  //# sourceMappingURL=serverQueryTypes.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../src/types/serverQueryTypes.ts"],"sourcesContent":["import { HealthStatus } from '@nadohq/shared';\nimport {\n EngineServerHealthBreakdown,\n EngineServerNlpBalance,\n EngineServerNlpLockedBalance,\n EngineServerOrder,\n EngineServerPerpBalance,\n EngineServerPerpProduct,\n EngineServerProductType,\n EngineServerSpotBalance,\n EngineServerSpotProduct,\n} from './serverQueryModelTypes';\n\nexport interface EngineServerNoncesParams {\n address: string;\n}\n\nexport interface EngineServerSubaccountInfoQueryParams {\n subaccount: string;\n txns?: Array<{\n apply_delta: {\n product_id: number;\n subaccount: string;\n amount_delta: string;\n v_quote_delta: string;\n };\n }>;\n // If not given, engine defaults to 'false'\n pre_state?: string;\n}\n\nexport interface EngineServerIsolatedPositionsQueryParams {\n subaccount: string;\n}\n\nexport interface EngineServerSymbolsQueryParams {\n product_type?: EngineServerProductType;\n product_ids?: number[];\n}\n\nexport interface EngineServerMarketPriceQueryParams {\n product_id: number;\n}\n\nexport interface EngineServerMarketPricesQueryParams {\n product_ids: number[];\n}\n\nexport interface EngineServerGetOrderQueryParams {\n product_id: number;\n digest: string;\n}\n\nexport interface EngineServerValidateOrderQueryParams {\n product_id: number;\n // Bytes for order, does not need to be signed\n order: string;\n}\n\nexport interface EngineServerOrdersQueryParams {\n sender: string;\n product_ids: number[];\n}\n\nexport interface EngineServerSubaccountOrdersQueryParams {\n sender: string;\n product_id: number;\n}\n\nexport interface EngineServerSubaccountFeeRatesParams {\n sender: string;\n}\n\nexport interface EngineServerMarketLiquidityQueryParams {\n product_id: number;\n depth: number;\n}\n\nexport interface EngineServerMaxWithdrawableQueryParams {\n sender: string;\n product_id: number;\n // If not given, engine defaults to true (leverage/borrow enabled)\n spot_leverage: string | null;\n}\n\nexport interface EngineServerMaxOrderSizeQueryParams {\n sender: string;\n product_id: number;\n price_x18: string;\n // Note: When `reduce_only` is true, `direction` must be opposite of the current position, otherwise it returns 0.\n direction: 'long' | 'short';\n // If not given, engine defaults to true (leverage/borrow enabled)\n spot_leverage: string | null;\n // If not given, engine defaults to false. If true, the max order size will be capped to the subaccount's current position size;\n // If no position exists, it will return 0.\n reduce_only: string | null;\n isolated: string | null;\n // For isolated, max order size includes available collateral to transfer from parent cross subaccount\n // If not given, engine defaults to true (borrow enabled)\n borrow_margin: string | null;\n}\n\nexport interface EngineServerLinkedSignerParams {\n subaccount: string;\n}\n\nexport interface EngineServerMaxMintNlpQueryParams {\n sender: string;\n // If not given, engine defaults to true (leverage/borrow enabled)\n spot_leverage: string | null;\n}\n\nexport interface EngineServerMaxBurnNlpQueryParams {\n sender: string;\n}\n\nexport interface EngineServerNlpLockedBalancesQueryParams {\n subaccount: string;\n}\n\nexport interface EngineServerQueryRequestByType {\n all_products: Record<string, never>;\n contracts: Record<string, never>;\n edge_all_products: Record<string, never>;\n fee_rates: EngineServerSubaccountFeeRatesParams;\n health_groups: Record<string, never>;\n insurance: Record<string, never>;\n isolated_positions: EngineServerIsolatedPositionsQueryParams;\n linked_signer: EngineServerLinkedSignerParams;\n market_liquidity: EngineServerMarketLiquidityQueryParams;\n market_price: EngineServerMarketPriceQueryParams;\n market_prices: EngineServerMarketPricesQueryParams;\n max_nlp_burnable: EngineServerMaxBurnNlpQueryParams;\n max_nlp_mintable: EngineServerMaxMintNlpQueryParams;\n max_order_size: EngineServerMaxOrderSizeQueryParams;\n nlp_locked_balances: EngineServerNlpLockedBalancesQueryParams;\n nlp_pool_info: Record<string, never>;\n max_withdrawable: EngineServerMaxWithdrawableQueryParams;\n nonces: EngineServerNoncesParams;\n order: EngineServerGetOrderQueryParams;\n orders: EngineServerOrdersQueryParams;\n status: Record<string, never>;\n subaccount_info: Omit<EngineServerSubaccountInfoQueryParams, 'txns'> & {\n // JSON serialized txns\n txns?: string;\n };\n subaccount_orders: EngineServerSubaccountOrdersQueryParams;\n symbols: EngineServerSymbolsQueryParams;\n validate_order: EngineServerValidateOrderQueryParams;\n}\n\nexport type EngineServerQueryRequestType = keyof EngineServerQueryRequestByType;\n\nexport type EngineServerQueryRequest<\n TRequestType extends EngineServerQueryRequestType,\n> = {\n type: TRequestType;\n} & EngineServerQueryRequestByType[TRequestType];\n\nexport interface EngineServerContractsResponse {\n chain_id: string;\n endpoint_addr: string;\n}\n\n// Unless in active state, engine is not fully operational\nexport const ENGINE_SERVER_STATUS_VALUES = [\n 'started',\n 'active',\n 'stopping',\n 'syncing',\n 'live_syncing',\n 'failed',\n] as const;\n\nexport type EngineServerStatusResponse =\n (typeof ENGINE_SERVER_STATUS_VALUES)[number];\n\nexport interface EngineServerNoncesResponse {\n order_nonce: string;\n tx_nonce: string;\n}\n\nexport interface EngineServerSubaccountInfoResponse extends EngineServerSubaccountInfoState {\n exists: boolean;\n subaccount: string;\n spot_count: number;\n perp_count: number;\n spot_products: EngineServerSpotProduct[];\n perp_products: EngineServerPerpProduct[];\n\n /** This is set if request has `pre_state` flag set to 'true' */\n pre_state: EngineServerSubaccountInfoState | undefined;\n}\n\nexport interface EngineServerSubaccountInfoState {\n healths: [\n initial: EngineServerHealthBreakdown,\n maintenance: EngineServerHealthBreakdown,\n unweighted: EngineServerHealthBreakdown,\n ];\n // First index is product ID, each subarray is of length 3 [initial, maintenance, unweighted]\n health_contributions: string[][];\n spot_balances: EngineServerSpotBalance[];\n perp_balances: EngineServerPerpBalance[];\n}\n\nexport interface EngineServerIsolatedPosition {\n subaccount: string;\n healths: [\n initial: HealthStatus,\n maintenance: HealthStatus,\n unweighted: HealthStatus,\n ];\n quote_healths: [initial: string, maintenance: string, unweighted: string];\n base_healths: [initial: string, maintenance: string, unweighted: string];\n quote_balance: EngineServerSpotBalance;\n base_balance: EngineServerPerpBalance;\n quote_product: EngineServerSpotProduct;\n base_product: EngineServerPerpProduct;\n}\n\nexport type EngineServerIsolatedPositionsResponse = {\n isolated_positions: EngineServerIsolatedPosition[];\n};\n\nexport interface EngineServerSymbol {\n type: EngineServerProductType;\n product_id: number;\n symbol: string;\n price_increment_x18: string;\n size_increment: string;\n min_size: string;\n maker_fee_rate_x18: string;\n taker_fee_rate_x18: string;\n long_weight_initial_x18: string;\n long_weight_maintenance_x18: string;\n // undefined when there is no max open interest limit (always undefined for spot products)\n max_open_interest_x18: string | undefined;\n isolated_only: boolean;\n}\n\nexport interface EngineServerSymbolsResponse {\n symbols: Record<string, EngineServerSymbol>;\n}\n\nexport interface EngineServerAllProductsResponse {\n spot_products: EngineServerSpotProduct[];\n perp_products: EngineServerPerpProduct[];\n}\n\nexport interface EngineServerHealthGroupsResponse {\n health_groups: [spotProductId: number, perpProductId: number][];\n}\n\n// Price, liquidity pairs\nexport type EngineServerPriceTickLiquidity = [\n priceX18: string,\n liquidity: string,\n];\n\nexport interface EngineServerMarketLiquidityResponse {\n bids: EngineServerPriceTickLiquidity[];\n asks: EngineServerPriceTickLiquidity[];\n}\n\nexport interface EngineServerSubaccountOrders {\n sender: string;\n product_id: number;\n orders: EngineServerOrder[];\n}\n\nexport type EngineServerSubaccountOrdersResponse = EngineServerSubaccountOrders;\n\nexport interface EngineServerProductOrdersResponse {\n sender: string;\n product_orders: EngineServerSubaccountOrders[];\n}\n\nexport interface EngineServerFeeRatesResponse {\n liquidation_sequencer_fee: string;\n health_check_sequencer_fee: string;\n taker_sequencer_fee: string;\n // Product ID is the index\n withdraw_sequencer_fees: string[];\n taker_fee_rates_x18: string[];\n maker_fee_rates_x18: string[];\n fee_tier: number;\n}\n\nexport interface EngineServerMarketPrice {\n product_id: number;\n bid_x18: string;\n ask_x18: string;\n}\n\nexport type EngineServerMarketPriceResponse = EngineServerMarketPrice;\n\nexport interface EngineServerMarketPricesResponse {\n market_prices: EngineServerMarketPrice[];\n}\n\nexport type EngineServerOrderResponse = EngineServerOrder;\n\nexport interface EngineServerValidateOrderResponse {\n product_id: number;\n order: string;\n valid: boolean;\n}\n\nexport interface EngineServerMaxOrderSizeResponse {\n max_order_size: string;\n}\n\nexport interface EngineServerMaxWithdrawableResponse {\n max_withdrawable: string;\n}\n\nexport type EngineServerTimeResponse = number;\n\nexport interface EngineServerIpBlockResponse {\n blocked: boolean;\n reason: string;\n}\n\nexport interface EngineServerLinkedSignerResponse {\n linked_signer: string;\n}\n\nexport interface EngineInsuranceResponse {\n insurance: string;\n}\n\nexport interface EngineServerEdgeAllProductsResponse {\n // chain_id -> EngineServerAllProductsResponse\n edge_all_products: Record<number, EngineServerAllProductsResponse>;\n}\n\nexport interface EngineServerMaxBurnNlpResponse {\n max_nlp_amount: string;\n}\n\nexport interface EngineServerMaxMintNlpResponse {\n max_quote_amount: string;\n}\n\nexport interface EngineServerNlpLockedBalancesResponse {\n balance_locked: EngineServerNlpBalance;\n balance_unlocked: EngineServerNlpBalance;\n locked_balances: EngineServerNlpLockedBalance[];\n}\n\nexport interface EngineServerNlpPool {\n pool_id: number;\n subaccount: string;\n owner: string;\n balance_weight_x18: string;\n subaccount_info: EngineServerSubaccountInfoResponse;\n open_orders: EngineServerOrder[];\n}\n\nexport interface EngineServerNlpPoolInfoResponse {\n nlp_pools: EngineServerNlpPool[];\n}\n\nexport interface EngineServerQueryResponseByType {\n all_products: EngineServerAllProductsResponse;\n contracts: EngineServerContractsResponse;\n edge_all_products: EngineServerEdgeAllProductsResponse;\n fee_rates: EngineServerFeeRatesResponse;\n health_groups: EngineServerHealthGroupsResponse;\n insurance: EngineInsuranceResponse;\n isolated_positions: EngineServerIsolatedPositionsResponse;\n linked_signer: EngineServerLinkedSignerResponse;\n market_liquidity: EngineServerMarketLiquidityResponse;\n market_price: EngineServerMarketPriceResponse;\n market_prices: EngineServerMarketPricesResponse;\n max_nlp_burnable: EngineServerMaxBurnNlpResponse;\n max_nlp_mintable: EngineServerMaxMintNlpResponse;\n max_order_size: EngineServerMaxOrderSizeResponse;\n nlp_locked_balances: EngineServerNlpLockedBalancesResponse;\n nlp_pool_info: EngineServerNlpPoolInfoResponse;\n max_withdrawable: EngineServerMaxWithdrawableResponse;\n nonces: EngineServerNoncesResponse;\n order: EngineServerOrderResponse;\n orders: EngineServerProductOrdersResponse;\n status: EngineServerStatusResponse;\n subaccount_info: EngineServerSubaccountInfoResponse;\n subaccount_orders: EngineServerSubaccountOrdersResponse;\n symbols: EngineServerSymbolsResponse;\n validate_order: EngineServerValidateOrderResponse;\n}\n\nexport interface EngineServerQuerySuccessResponse<\n TQueryType extends keyof EngineServerQueryResponseByType =\n EngineServerQueryRequestType,\n> {\n status: 'success';\n data: EngineServerQueryResponseByType[TQueryType];\n}\n\nexport interface EngineServerQueryFailureResponse {\n status: 'failure';\n error: string;\n error_code: number;\n}\n\nexport type EngineServerQueryResponse<\n TQueryType extends keyof EngineServerQueryResponseByType =\n EngineServerQueryRequestType,\n> =\n | EngineServerQuerySuccessResponse<TQueryType>\n | EngineServerQueryFailureResponse;\n"],"mappings":";AAqKO,IAAM,8BAA8B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
@@ -1 +1 @@
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
+ {"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 EngineServerSubscriptionEventType =\n EngineServerSubscriptionEventType,\n> {\n type: T;\n product_id: number;\n}\n\n/**\n * Event from subscribing to a `trade` stream.\n */\nexport interface EngineServerSubscriptionTradeEvent 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 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 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 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 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 * True if the position change was for an isolated position\n */\n isolated: boolean;\n}\n\n/**\n * Event from subscribing to an `order_update` stream.\n */\nexport interface EngineServerSubscriptionOrderUpdateEvent 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 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 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 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, EngineServerOrder } from './serverQueryTypes.cjs';
1
+ import { EngineServerPriceTickLiquidity } from './serverQueryTypes.cjs';
2
2
  import '@nadohq/shared';
3
3
  import './serverQueryModelTypes.cjs';
4
4
 
@@ -72,13 +72,18 @@ interface EngineServerSubscriptionPositionChangeEvent extends EngineServerSubscr
72
72
  /** Zero for everything except perps */
73
73
  v_quote_amount: string;
74
74
  reason: PositionChangeReason;
75
+ /**
76
+ * True if the position change was for an isolated position
77
+ */
78
+ isolated: boolean;
75
79
  }
76
80
  /**
77
81
  * Event from subscribing to an `order_update` stream.
78
82
  */
79
83
  interface EngineServerSubscriptionOrderUpdateEvent extends EngineServerSubscriptionBaseEvent<'order_update'> {
80
84
  timestamp: string;
81
- order: EngineServerOrder;
85
+ digest: string;
86
+ amount: string;
82
87
  reason: OrderUpdateReason;
83
88
  }
84
89
  /**
@@ -1,4 +1,4 @@
1
- import { EngineServerPriceTickLiquidity, EngineServerOrder } from './serverQueryTypes.js';
1
+ import { EngineServerPriceTickLiquidity } from './serverQueryTypes.js';
2
2
  import '@nadohq/shared';
3
3
  import './serverQueryModelTypes.js';
4
4
 
@@ -72,13 +72,18 @@ interface EngineServerSubscriptionPositionChangeEvent extends EngineServerSubscr
72
72
  /** Zero for everything except perps */
73
73
  v_quote_amount: string;
74
74
  reason: PositionChangeReason;
75
+ /**
76
+ * True if the position change was for an isolated position
77
+ */
78
+ isolated: boolean;
75
79
  }
76
80
  /**
77
81
  * Event from subscribing to an `order_update` stream.
78
82
  */
79
83
  interface EngineServerSubscriptionOrderUpdateEvent extends EngineServerSubscriptionBaseEvent<'order_update'> {
80
84
  timestamp: string;
81
- order: EngineServerOrder;
85
+ digest: string;
86
+ amount: string;
82
87
  reason: OrderUpdateReason;
83
88
  }
84
89
  /**
@@ -1,5 +1,6 @@
1
- export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './queryDataMappers.cjs';
1
+ export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerNlpLockedBalances, mapEngineServerNlpPoolInfo, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './queryDataMappers.cjs';
2
2
  import '@nadohq/shared';
3
- import '../types/clientQueryTypes.cjs';
4
3
  import '../types/serverQueryTypes.cjs';
5
4
  import '../types/serverQueryModelTypes.cjs';
5
+ import '../types/clientQueryTypes.cjs';
6
+ import 'bignumber.js';
@@ -1,5 +1,6 @@
1
- export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './queryDataMappers.js';
1
+ export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerNlpLockedBalances, mapEngineServerNlpPoolInfo, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './queryDataMappers.js';
2
2
  import '@nadohq/shared';
3
- import '../types/clientQueryTypes.js';
4
3
  import '../types/serverQueryTypes.js';
5
4
  import '../types/serverQueryModelTypes.js';
5
+ import '../types/clientQueryTypes.js';
6
+ import 'bignumber.js';
@@ -23,6 +23,8 @@ __export(queryDataMappers_exports, {
23
23
  mapEngineMarketPrice: () => mapEngineMarketPrice,
24
24
  mapEngineServerBalanceHealthContributions: () => mapEngineServerBalanceHealthContributions,
25
25
  mapEngineServerIsolatedPositions: () => mapEngineServerIsolatedPositions,
26
+ mapEngineServerNlpLockedBalances: () => mapEngineServerNlpLockedBalances,
27
+ mapEngineServerNlpPoolInfo: () => mapEngineServerNlpPoolInfo,
26
28
  mapEngineServerOrder: () => mapEngineServerOrder,
27
29
  mapEngineServerPerpProduct: () => mapEngineServerPerpProduct,
28
30
  mapEngineServerSpotProduct: () => mapEngineServerSpotProduct,
@@ -37,7 +39,7 @@ var import_productEngineTypeMappers = require("./productEngineTypeMappers.cjs");
37
39
  function mapEngineServerTickLiquidity(tick) {
38
40
  return {
39
41
  price: (0, import_shared.removeDecimals)(tick[0]),
40
- liquidity: (0, import_shared.toBigDecimal)(tick[1])
42
+ liquidity: (0, import_shared.toBigNumber)(tick[1])
41
43
  };
42
44
  }
43
45
  function mapEngineServerOrder(order) {
@@ -50,8 +52,8 @@ function mapEngineServerOrder(order) {
50
52
  productId: order.product_id,
51
53
  subaccountOwner: subaccount.subaccountOwner,
52
54
  subaccountName: subaccount.subaccountName,
53
- totalAmount: (0, import_shared.toBigDecimal)(order.amount),
54
- unfilledAmount: (0, import_shared.toBigDecimal)(order.unfilled_amount),
55
+ totalAmount: (0, import_shared.toBigNumber)(order.amount),
56
+ unfilledAmount: (0, import_shared.toBigNumber)(order.unfilled_amount),
55
57
  placementTime: order.placed_at,
56
58
  appendix: (0, import_shared.unpackOrderAppendix)(order.appendix)
57
59
  };
@@ -60,9 +62,9 @@ function mapEngineServerSpotProduct(product) {
60
62
  return {
61
63
  type: import_shared.ProductEngineType.SPOT,
62
64
  productId: product.product_id,
63
- minSize: (0, import_shared.toBigDecimal)(product.book_info.min_size),
65
+ minSize: (0, import_shared.toBigNumber)(product.book_info.min_size),
64
66
  priceIncrement: (0, import_shared.removeDecimals)(product.book_info.price_increment_x18),
65
- sizeIncrement: (0, import_shared.toBigDecimal)(product.book_info.size_increment),
67
+ sizeIncrement: (0, import_shared.toBigNumber)(product.book_info.size_increment),
66
68
  product: {
67
69
  productId: product.product_id,
68
70
  type: import_shared.ProductEngineType.SPOT,
@@ -98,9 +100,9 @@ function mapEngineServerPerpProduct(product) {
98
100
  return {
99
101
  type: import_shared.ProductEngineType.PERP,
100
102
  productId: product.product_id,
101
- minSize: (0, import_shared.toBigDecimal)(product.book_info.min_size),
103
+ minSize: (0, import_shared.toBigNumber)(product.book_info.min_size),
102
104
  priceIncrement: (0, import_shared.removeDecimals)(product.book_info.price_increment_x18),
103
- sizeIncrement: (0, import_shared.toBigDecimal)(product.book_info.size_increment),
105
+ sizeIncrement: (0, import_shared.toBigNumber)(product.book_info.size_increment),
104
106
  product: {
105
107
  productId: product.product_id,
106
108
  type: import_shared.ProductEngineType.PERP,
@@ -113,7 +115,7 @@ function mapEngineServerPerpProduct(product) {
113
115
  shortWeightMaintenance: (0, import_shared.removeDecimals)(
114
116
  product.risk.short_weight_maintenance_x18
115
117
  ),
116
- openInterest: (0, import_shared.toBigDecimal)(product.state.open_interest),
118
+ openInterest: (0, import_shared.toBigNumber)(product.state.open_interest),
117
119
  cumulativeFundingLong: (0, import_shared.removeDecimals)(
118
120
  product.state.cumulative_funding_long_x18
119
121
  ),
@@ -125,62 +127,76 @@ function mapEngineServerPerpProduct(product) {
125
127
  }
126
128
  function mapEngineServerBalanceHealthContributions(healthContributionsForBalance) {
127
129
  return {
128
- initial: (0, import_shared.toBigDecimal)(healthContributionsForBalance[0]),
129
- maintenance: (0, import_shared.toBigDecimal)(healthContributionsForBalance[1]),
130
- unweighted: (0, import_shared.toBigDecimal)(healthContributionsForBalance[2])
130
+ initial: (0, import_shared.toBigNumber)(healthContributionsForBalance[0]),
131
+ maintenance: (0, import_shared.toBigNumber)(healthContributionsForBalance[1]),
132
+ unweighted: (0, import_shared.toBigNumber)(healthContributionsForBalance[2])
131
133
  };
132
134
  }
133
135
  function mapSubaccountSummary(baseResponse) {
136
+ return {
137
+ exists: baseResponse.exists,
138
+ ...mapSubaccountSummaryState(
139
+ baseResponse,
140
+ baseResponse.spot_products,
141
+ baseResponse.perp_products
142
+ ),
143
+ preState: baseResponse.pre_state ? mapSubaccountSummaryState(
144
+ baseResponse.pre_state,
145
+ baseResponse.spot_products,
146
+ baseResponse.perp_products
147
+ ) : void 0
148
+ };
149
+ }
150
+ function mapSubaccountSummaryState(state, spotProducts, perpProducts) {
134
151
  const balances = [];
135
- baseResponse.spot_balances.forEach((spotBalance) => {
136
- const product = baseResponse.spot_products.find(
152
+ state.spot_balances.forEach((spotBalance) => {
153
+ const product = spotProducts.find(
137
154
  (product2) => product2.product_id === spotBalance.product_id
138
155
  );
139
156
  if (!product) {
140
157
  throw Error(`Could not find product ${spotBalance.product_id}`);
141
158
  }
142
159
  balances.push({
143
- amount: (0, import_shared.toBigDecimal)(spotBalance.balance.amount),
160
+ amount: (0, import_shared.toBigNumber)(spotBalance.balance.amount),
144
161
  healthContributions: mapEngineServerBalanceHealthContributions(
145
- baseResponse.health_contributions[spotBalance.product_id]
162
+ state.health_contributions[spotBalance.product_id]
146
163
  ),
147
164
  ...mapEngineServerSpotProduct(product).product
148
165
  });
149
166
  });
150
- baseResponse.perp_balances.forEach((perpBalance) => {
151
- const product = baseResponse.perp_products.find(
167
+ state.perp_balances.forEach((perpBalance) => {
168
+ const product = perpProducts.find(
152
169
  (product2) => product2.product_id === perpBalance.product_id
153
170
  );
154
171
  if (!product) {
155
172
  throw Error(`Could not find product ${perpBalance.product_id}`);
156
173
  }
157
174
  balances.push({
158
- amount: (0, import_shared.toBigDecimal)(perpBalance.balance.amount),
159
- vQuoteBalance: (0, import_shared.toBigDecimal)(perpBalance.balance.v_quote_balance),
175
+ amount: (0, import_shared.toBigNumber)(perpBalance.balance.amount),
176
+ vQuoteBalance: (0, import_shared.toBigNumber)(perpBalance.balance.v_quote_balance),
160
177
  healthContributions: mapEngineServerBalanceHealthContributions(
161
- baseResponse.health_contributions[perpBalance.product_id]
178
+ state.health_contributions[perpBalance.product_id]
162
179
  ),
163
180
  ...mapEngineServerPerpProduct(product).product
164
181
  });
165
182
  });
166
183
  return {
167
184
  balances,
168
- exists: baseResponse.exists,
169
185
  health: {
170
186
  initial: {
171
- health: (0, import_shared.toBigDecimal)(baseResponse.healths[0].health),
172
- assets: (0, import_shared.toBigDecimal)(baseResponse.healths[0].assets),
173
- liabilities: (0, import_shared.toBigDecimal)(baseResponse.healths[0].liabilities)
187
+ health: (0, import_shared.toBigNumber)(state.healths[0].health),
188
+ assets: (0, import_shared.toBigNumber)(state.healths[0].assets),
189
+ liabilities: (0, import_shared.toBigNumber)(state.healths[0].liabilities)
174
190
  },
175
191
  maintenance: {
176
- health: (0, import_shared.toBigDecimal)(baseResponse.healths[1].health),
177
- assets: (0, import_shared.toBigDecimal)(baseResponse.healths[1].assets),
178
- liabilities: (0, import_shared.toBigDecimal)(baseResponse.healths[1].liabilities)
192
+ health: (0, import_shared.toBigNumber)(state.healths[1].health),
193
+ assets: (0, import_shared.toBigNumber)(state.healths[1].assets),
194
+ liabilities: (0, import_shared.toBigNumber)(state.healths[1].liabilities)
179
195
  },
180
196
  unweighted: {
181
- health: (0, import_shared.toBigDecimal)(baseResponse.healths[2].health),
182
- assets: (0, import_shared.toBigDecimal)(baseResponse.healths[2].assets),
183
- liabilities: (0, import_shared.toBigDecimal)(baseResponse.healths[2].liabilities)
197
+ health: (0, import_shared.toBigNumber)(state.healths[2].health),
198
+ assets: (0, import_shared.toBigNumber)(state.healths[2].assets),
199
+ liabilities: (0, import_shared.toBigNumber)(state.healths[2].liabilities)
184
200
  }
185
201
  }
186
202
  };
@@ -192,27 +208,27 @@ function mapEngineServerIsolatedPositions(baseResponse) {
192
208
  return {
193
209
  subaccount: (0, import_shared.subaccountFromHex)(position.subaccount),
194
210
  healths: {
195
- initial: (0, import_shared.toBigDecimal)(position.healths[0].health),
196
- maintenance: (0, import_shared.toBigDecimal)(position.healths[1].health),
197
- unweighted: (0, import_shared.toBigDecimal)(position.healths[2].health)
211
+ initial: (0, import_shared.toBigNumber)(position.healths[0].health),
212
+ maintenance: (0, import_shared.toBigNumber)(position.healths[1].health),
213
+ unweighted: (0, import_shared.toBigNumber)(position.healths[2].health)
198
214
  },
199
215
  baseBalance: {
200
- amount: (0, import_shared.toBigDecimal)(perpBalance.balance.amount),
201
- vQuoteBalance: (0, import_shared.toBigDecimal)(perpBalance.balance.v_quote_balance),
216
+ amount: (0, import_shared.toBigNumber)(perpBalance.balance.amount),
217
+ vQuoteBalance: (0, import_shared.toBigNumber)(perpBalance.balance.v_quote_balance),
202
218
  // Health contributions === healths for an isolated position
203
219
  healthContributions: {
204
- initial: (0, import_shared.toBigDecimal)(position.base_healths[0]),
205
- maintenance: (0, import_shared.toBigDecimal)(position.base_healths[1]),
206
- unweighted: (0, import_shared.toBigDecimal)(position.base_healths[2])
220
+ initial: (0, import_shared.toBigNumber)(position.base_healths[0]),
221
+ maintenance: (0, import_shared.toBigNumber)(position.base_healths[1]),
222
+ unweighted: (0, import_shared.toBigNumber)(position.base_healths[2])
207
223
  },
208
224
  ...mapEngineServerPerpProduct(position.base_product).product
209
225
  },
210
226
  quoteBalance: {
211
- amount: (0, import_shared.toBigDecimal)(quoteBalance.balance.amount),
227
+ amount: (0, import_shared.toBigNumber)(quoteBalance.balance.amount),
212
228
  healthContributions: {
213
- initial: (0, import_shared.toBigDecimal)(position.quote_healths[0]),
214
- maintenance: (0, import_shared.toBigDecimal)(position.quote_healths[1]),
215
- unweighted: (0, import_shared.toBigDecimal)(position.quote_healths[2])
229
+ initial: (0, import_shared.toBigNumber)(position.quote_healths[0]),
230
+ maintenance: (0, import_shared.toBigNumber)(position.quote_healths[1]),
231
+ unweighted: (0, import_shared.toBigNumber)(position.quote_healths[2])
216
232
  },
217
233
  ...mapEngineServerSpotProduct(position.quote_product).product
218
234
  }
@@ -234,10 +250,8 @@ function mapEngineServerSymbol(engineServerSymbol) {
234
250
  productId: engineServerSymbol.product_id,
235
251
  symbol: engineServerSymbol.symbol,
236
252
  priceIncrement: (0, import_shared.removeDecimals)(engineServerSymbol.price_increment_x18),
237
- sizeIncrement: (0, import_shared.toBigDecimal)(engineServerSymbol.size_increment),
238
- minSize: (0, import_shared.toBigDecimal)(engineServerSymbol.min_size),
239
- minDepth: (0, import_shared.removeDecimals)(engineServerSymbol.min_depth_x18),
240
- maxSpreadRate: (0, import_shared.removeDecimals)(engineServerSymbol.max_spread_rate_x18),
253
+ sizeIncrement: (0, import_shared.toBigNumber)(engineServerSymbol.size_increment),
254
+ minSize: (0, import_shared.toBigNumber)(engineServerSymbol.min_size),
241
255
  makerFeeRate: (0, import_shared.removeDecimals)(engineServerSymbol.maker_fee_rate_x18),
242
256
  takerFeeRate: (0, import_shared.removeDecimals)(engineServerSymbol.taker_fee_rate_x18),
243
257
  longWeightInitial: (0, import_shared.removeDecimals)(
@@ -245,7 +259,9 @@ function mapEngineServerSymbol(engineServerSymbol) {
245
259
  ),
246
260
  longWeightMaintenance: (0, import_shared.removeDecimals)(
247
261
  engineServerSymbol.long_weight_maintenance_x18
248
- )
262
+ ),
263
+ maxOpenInterest: (0, import_shared.removeDecimals)(engineServerSymbol.max_open_interest_x18),
264
+ isolatedOnly: engineServerSymbol.isolated_only
249
265
  };
250
266
  }
251
267
  function mapEngineMarketPrice(baseResponse) {
@@ -255,11 +271,43 @@ function mapEngineMarketPrice(baseResponse) {
255
271
  productId: baseResponse.product_id
256
272
  };
257
273
  }
274
+ function mapEngineServerNlpLockedBalances(baseResponse) {
275
+ const lockedBalances = baseResponse.locked_balances.map((lockedBalance) => ({
276
+ productId: lockedBalance.balance.product_id,
277
+ balance: (0, import_shared.toBigNumber)(lockedBalance.balance.balance.amount),
278
+ unlockedAt: lockedBalance.unlocked_at
279
+ }));
280
+ return {
281
+ lockedBalances,
282
+ balanceLocked: {
283
+ productId: baseResponse.balance_locked.product_id,
284
+ balance: (0, import_shared.toBigNumber)(baseResponse.balance_locked.balance.amount)
285
+ },
286
+ balanceUnlocked: {
287
+ productId: baseResponse.balance_unlocked.product_id,
288
+ balance: (0, import_shared.toBigNumber)(baseResponse.balance_unlocked.balance.amount)
289
+ }
290
+ };
291
+ }
292
+ function mapEngineServerNlpPoolInfo(baseResponse) {
293
+ return {
294
+ nlpPools: baseResponse.nlp_pools.map((pool) => ({
295
+ poolId: pool.pool_id,
296
+ subaccountHex: pool.subaccount,
297
+ ownerAddress: pool.owner,
298
+ balanceWeight: (0, import_shared.removeDecimals)(pool.balance_weight_x18),
299
+ subaccountInfo: mapSubaccountSummary(pool.subaccount_info),
300
+ openOrders: pool.open_orders.map(mapEngineServerOrder)
301
+ }))
302
+ };
303
+ }
258
304
  // Annotate the CommonJS export names for ESM import in node:
259
305
  0 && (module.exports = {
260
306
  mapEngineMarketPrice,
261
307
  mapEngineServerBalanceHealthContributions,
262
308
  mapEngineServerIsolatedPositions,
309
+ mapEngineServerNlpLockedBalances,
310
+ mapEngineServerNlpPoolInfo,
263
311
  mapEngineServerOrder,
264
312
  mapEngineServerPerpProduct,
265
313
  mapEngineServerSpotProduct,