@nadohq/engine-client 0.1.0-alpha.20 → 0.1.0-alpha.21

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 (53) hide show
  1. package/dist/EngineExecuteBuilder.cjs +9 -6
  2. package/dist/EngineExecuteBuilder.cjs.map +1 -1
  3. package/dist/EngineExecuteBuilder.js +9 -6
  4. package/dist/EngineExecuteBuilder.js.map +1 -1
  5. package/dist/EngineExecuteClient.cjs +6 -6
  6. package/dist/EngineExecuteClient.cjs.map +1 -1
  7. package/dist/EngineExecuteClient.d.cts +1 -1
  8. package/dist/EngineExecuteClient.d.ts +1 -1
  9. package/dist/EngineExecuteClient.js +6 -6
  10. package/dist/EngineExecuteClient.js.map +1 -1
  11. package/dist/EngineQueryClient.cjs +8 -1
  12. package/dist/EngineQueryClient.cjs.map +1 -1
  13. package/dist/EngineQueryClient.d.cts +6 -2
  14. package/dist/EngineQueryClient.d.ts +6 -2
  15. package/dist/EngineQueryClient.js +9 -1
  16. package/dist/EngineQueryClient.js.map +1 -1
  17. package/dist/index.d.cts +4 -4
  18. package/dist/index.d.ts +4 -4
  19. package/dist/types/clientExecuteTypes.cjs.map +1 -1
  20. package/dist/types/clientExecuteTypes.d.cts +8 -1
  21. package/dist/types/clientExecuteTypes.d.ts +8 -1
  22. package/dist/types/clientQueryTypes.cjs.map +1 -1
  23. package/dist/types/clientQueryTypes.d.cts +13 -3
  24. package/dist/types/clientQueryTypes.d.ts +13 -3
  25. package/dist/types/index.d.cts +3 -3
  26. package/dist/types/index.d.ts +3 -3
  27. package/dist/types/serverExecuteTypes.cjs.map +1 -1
  28. package/dist/types/serverExecuteTypes.d.cts +8 -1
  29. package/dist/types/serverExecuteTypes.d.ts +8 -1
  30. package/dist/types/serverQueryModelTypes.cjs.map +1 -1
  31. package/dist/types/serverQueryModelTypes.d.cts +24 -1
  32. package/dist/types/serverQueryModelTypes.d.ts +24 -1
  33. package/dist/types/serverQueryTypes.cjs.map +1 -1
  34. package/dist/types/serverQueryTypes.d.cts +15 -24
  35. package/dist/types/serverQueryTypes.d.ts +15 -24
  36. package/dist/utils/index.d.cts +1 -1
  37. package/dist/utils/index.d.ts +1 -1
  38. package/dist/utils/queryDataMappers.cjs +18 -2
  39. package/dist/utils/queryDataMappers.cjs.map +1 -1
  40. package/dist/utils/queryDataMappers.d.cts +4 -3
  41. package/dist/utils/queryDataMappers.d.ts +4 -3
  42. package/dist/utils/queryDataMappers.js +17 -2
  43. package/dist/utils/queryDataMappers.js.map +1 -1
  44. package/package.json +3 -3
  45. package/src/EngineExecuteBuilder.ts +9 -6
  46. package/src/EngineExecuteClient.ts +7 -7
  47. package/src/EngineQueryClient.ts +11 -1
  48. package/src/types/clientExecuteTypes.ts +9 -2
  49. package/src/types/clientQueryTypes.ts +14 -2
  50. package/src/types/serverExecuteTypes.ts +9 -2
  51. package/src/types/serverQueryModelTypes.ts +25 -0
  52. package/src/types/serverQueryTypes.ts +18 -25
  53. package/src/utils/queryDataMappers.ts +21 -2
@@ -40,6 +40,7 @@ import {
40
40
  GetEngineMaxWithdrawableResponse,
41
41
  GetEngineNlpLockedBalancesParams,
42
42
  GetEngineNlpLockedBalancesResponse,
43
+ GetEngineNlpPoolInfoResponse,
43
44
  GetEngineOrderParams,
44
45
  GetEngineOrderResponse,
45
46
  GetEngineSubaccountFeeRatesParams,
@@ -61,6 +62,7 @@ import {
61
62
  mapEngineMarketPrice,
62
63
  mapEngineServerIsolatedPositions,
63
64
  mapEngineServerNlpLockedBalances,
65
+ mapEngineServerNlpPoolInfo,
64
66
  mapEngineServerOrder,
65
67
  mapEngineServerPerpProduct,
66
68
  mapEngineServerSpotProduct,
@@ -544,7 +546,7 @@ export class EngineQueryClient extends EngineBaseClient {
544
546
  }
545
547
 
546
548
  /**
547
- * Gets the insurance funds in USDC.
549
+ * Gets the insurance funds in USDT.
548
550
  * @returns
549
551
  */
550
552
  public async getInsurance(): Promise<GetEngineInsuranceResponse> {
@@ -570,4 +572,12 @@ export class EngineQueryClient extends EngineBaseClient {
570
572
 
571
573
  return mapEngineServerNlpLockedBalances(baseResponse);
572
574
  }
575
+
576
+ /**
577
+ * Retrieves information about all NLP sub-pools
578
+ */
579
+ async getNlpPoolInfo(): Promise<GetEngineNlpPoolInfoResponse> {
580
+ const baseResponse = await this.query('nlp_pool_info', {});
581
+ return mapEngineServerNlpPoolInfo(baseResponse);
582
+ }
573
583
  }
@@ -49,7 +49,7 @@ export type EnginePlaceOrderParams = WithBaseEngineExecuteParams<{
49
49
  order: EngineOrderParams;
50
50
  // If not given, engine defaults to true (leverage/borrow enabled)
51
51
  spotLeverage?: boolean;
52
- // For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative USDC balance)
52
+ // For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative USDT balance)
53
53
  borrowMargin?: boolean;
54
54
  }>;
55
55
 
@@ -84,7 +84,14 @@ export type EngineMintNlpParams = WithBaseEngineExecuteParams<
84
84
  export type EngineBurnNlpParams =
85
85
  WithBaseEngineExecuteParams<EIP712BurnNlpParams>;
86
86
 
87
- export type EnginePlaceOrdersParams = EnginePlaceOrderParams[];
87
+ export type EnginePlaceOrdersParams = {
88
+ orders: EnginePlaceOrderParams[];
89
+ /**
90
+ * If `true`, aborts the batch after the first failed order; if `false`, remaining orders continue to execute.
91
+ * If not provided, the default value is `false`.
92
+ */
93
+ cancelOnFailure?: boolean;
94
+ };
88
95
 
89
96
  export interface EngineExecuteRequestParamsByType {
90
97
  burn_nlp: EngineBurnNlpParams;
@@ -19,11 +19,11 @@ import {
19
19
  EngineServerTimeResponse,
20
20
  } from './serverQueryTypes';
21
21
 
22
- export type GetEngineSubaccountSummaryResponse = {
22
+ export interface GetEngineSubaccountSummaryResponse {
23
23
  exists: boolean;
24
24
  balances: BalanceWithProduct[];
25
25
  health: HealthStatusByType;
26
- };
26
+ }
27
27
 
28
28
  export type GetEngineSubaccountSummaryParams = Subaccount;
29
29
 
@@ -277,3 +277,15 @@ export interface GetEngineNlpLockedBalancesResponse {
277
277
  balanceLocked: EngineNlpBalance;
278
278
  balanceUnlocked: EngineNlpBalance;
279
279
  }
280
+
281
+ export interface NlpPool {
282
+ poolId: number;
283
+ subaccount: Subaccount;
284
+ balanceWeight: BigDecimal;
285
+ subaccountInfo: GetEngineSubaccountSummaryResponse;
286
+ openOrders: EngineOrder[];
287
+ }
288
+
289
+ export interface GetEngineNlpPoolInfoResponse {
290
+ nlpPools: NlpPool[];
291
+ }
@@ -73,7 +73,7 @@ export interface EngineServerPlaceOrderParams {
73
73
  signature: string;
74
74
  // Engine defaults this to true
75
75
  spot_leverage: boolean | null;
76
- // For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative USDC balance)
76
+ // For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative USDT balance)
77
77
  borrow_margin: boolean | null;
78
78
  }
79
79
 
@@ -111,7 +111,14 @@ export interface EngineServerExecuteRequestByType {
111
111
  liquidate_subaccount: SignedTx<EIP712LiquidateSubaccountValues>;
112
112
  mint_nlp: WithSpotLeverage<SignedTx<EIP712MintNlpValues>>;
113
113
  place_order: EngineServerPlaceOrderParams;
114
- place_orders: EngineServerPlaceOrderParams[];
114
+ place_orders: {
115
+ orders: EngineServerPlaceOrderParams[];
116
+ /**
117
+ * If `true`, aborts the batch after the first failed order; if `false`, remaining orders continue to execute.
118
+ * If `null`, the default value is `false`.
119
+ */
120
+ cancel_on_failure: boolean | null;
121
+ };
115
122
  transfer_quote: SignedTx<EIP712TransferQuoteValues>;
116
123
  withdraw_collateral: WithSpotLeverage<
117
124
  SignedTx<EIP712WithdrawCollateralValues>
@@ -81,3 +81,28 @@ export interface EngineServerPerpBalance {
81
81
  }
82
82
 
83
83
  export type EngineServerProductType = 'perp' | 'spot';
84
+
85
+ export interface EngineServerOrder {
86
+ product_id: number;
87
+ sender: string;
88
+ price_x18: string;
89
+ amount: string;
90
+ expiration: string;
91
+ nonce: string;
92
+ unfilled_amount: string;
93
+ digest: string;
94
+ placed_at: number;
95
+ order_type: string;
96
+ appendix: string;
97
+ }
98
+
99
+ export interface EngineServerNlpBalance {
100
+ product_id: number;
101
+ balance: {
102
+ amount: string;
103
+ };
104
+ }
105
+ export interface EngineServerNlpLockedBalance {
106
+ unlocked_at: number;
107
+ balance: EngineServerNlpBalance;
108
+ }
@@ -1,6 +1,9 @@
1
1
  import { HealthStatus } from '@nadohq/shared';
2
2
  import {
3
3
  EngineServerHealthBreakdown,
4
+ EngineServerNlpBalance,
5
+ EngineServerNlpLockedBalance,
6
+ EngineServerOrder,
4
7
  EngineServerPerpBalance,
5
8
  EngineServerPerpProduct,
6
9
  EngineServerProductType,
@@ -129,6 +132,7 @@ export interface EngineServerQueryRequestByType {
129
132
  max_nlp_mintable: EngineServerMaxMintNlpQueryParams;
130
133
  max_order_size: EngineServerMaxOrderSizeQueryParams;
131
134
  nlp_locked_balances: EngineServerNlpLockedBalancesQueryParams;
135
+ nlp_pool_info: Record<string, never>;
132
136
  max_withdrawable: EngineServerMaxWithdrawableQueryParams;
133
137
  nonces: EngineServerNoncesParams;
134
138
  order: EngineServerGetOrderQueryParams;
@@ -282,20 +286,6 @@ export interface EngineServerMarketPricesResponse {
282
286
  market_prices: EngineServerMarketPrice[];
283
287
  }
284
288
 
285
- export interface EngineServerOrder {
286
- product_id: number;
287
- sender: string;
288
- price_x18: string;
289
- amount: string;
290
- expiration: string;
291
- nonce: string;
292
- unfilled_amount: string;
293
- digest: string;
294
- placed_at: number;
295
- order_type: string;
296
- appendix: string;
297
- }
298
-
299
289
  export type EngineServerOrderResponse = EngineServerOrder;
300
290
 
301
291
  export interface EngineServerValidateOrderResponse {
@@ -340,23 +330,25 @@ export interface EngineServerMaxMintNlpResponse {
340
330
  max_quote_amount: string;
341
331
  }
342
332
 
343
- export interface EngineServerNlpBalance {
344
- product_id: number;
345
- balance: {
346
- amount: string;
347
- };
348
- }
349
-
350
- export interface EngineServerNlpLockedBalance extends EngineServerNlpBalance {
351
- unlocked_at: number;
352
- }
353
-
354
333
  export interface EngineServerNlpLockedBalancesResponse {
355
334
  balance_locked: EngineServerNlpBalance;
356
335
  balance_unlocked: EngineServerNlpBalance;
357
336
  locked_balances: EngineServerNlpLockedBalance[];
358
337
  }
359
338
 
339
+ export interface EngineServerNlpPool {
340
+ pool_id: number;
341
+ subaccount: string;
342
+ owner: string;
343
+ balance_weight_x18: string;
344
+ subaccount_info: EngineServerSubaccountInfoResponse;
345
+ open_orders: EngineServerOrder[];
346
+ }
347
+
348
+ export interface EngineServerNlpPoolInfoResponse {
349
+ nlp_pools: EngineServerNlpPool[];
350
+ }
351
+
360
352
  export interface EngineServerQueryResponseByType {
361
353
  all_products: EngineServerAllProductsResponse;
362
354
  contracts: EngineServerContractsResponse;
@@ -373,6 +365,7 @@ export interface EngineServerQueryResponseByType {
373
365
  max_nlp_mintable: EngineServerMaxMintNlpResponse;
374
366
  max_order_size: EngineServerMaxOrderSizeResponse;
375
367
  nlp_locked_balances: EngineServerNlpLockedBalancesResponse;
368
+ nlp_pool_info: EngineServerNlpPoolInfoResponse;
376
369
  max_withdrawable: EngineServerMaxWithdrawableResponse;
377
370
  nonces: EngineServerNoncesResponse;
378
371
  order: EngineServerOrderResponse;
@@ -19,6 +19,7 @@ import {
19
19
  EngineServerIsolatedPositionsResponse,
20
20
  EngineServerMarketPrice,
21
21
  EngineServerNlpLockedBalancesResponse,
22
+ EngineServerNlpPoolInfoResponse,
22
23
  EngineServerOrderResponse,
23
24
  EngineServerPerpProduct,
24
25
  EngineServerPriceTickLiquidity,
@@ -30,6 +31,7 @@ import {
30
31
  EngineSymbolsResponse,
31
32
  GetEngineIsolatedPositionsResponse,
32
33
  GetEngineNlpLockedBalancesResponse,
34
+ GetEngineNlpPoolInfoResponse,
33
35
  GetEngineSubaccountSummaryResponse,
34
36
  } from '../types';
35
37
  import { mapEngineServerProductType } from './productEngineTypeMappers';
@@ -297,8 +299,8 @@ export function mapEngineServerNlpLockedBalances(
297
299
  ): GetEngineNlpLockedBalancesResponse {
298
300
  const lockedBalances: EngineNlpLockedBalance[] =
299
301
  baseResponse.locked_balances.map((lockedBalance) => ({
300
- productId: lockedBalance.product_id,
301
- balance: toBigDecimal(lockedBalance.balance.amount),
302
+ productId: lockedBalance.balance.product_id,
303
+ balance: toBigDecimal(lockedBalance.balance.balance.amount),
302
304
  unlockedAt: lockedBalance.unlocked_at,
303
305
  }));
304
306
 
@@ -314,3 +316,20 @@ export function mapEngineServerNlpLockedBalances(
314
316
  },
315
317
  };
316
318
  }
319
+
320
+ export function mapEngineServerNlpPoolInfo(
321
+ baseResponse: EngineServerNlpPoolInfoResponse,
322
+ ): GetEngineNlpPoolInfoResponse {
323
+ return {
324
+ nlpPools: baseResponse.nlp_pools.map((pool) => ({
325
+ poolId: pool.pool_id,
326
+ subaccount: {
327
+ subaccountOwner: pool.owner,
328
+ subaccountName: pool.subaccount,
329
+ },
330
+ balanceWeight: removeDecimals(pool.balance_weight_x18),
331
+ subaccountInfo: mapSubaccountSummary(pool.subaccount_info),
332
+ openOrders: pool.open_orders.map(mapEngineServerOrder),
333
+ })),
334
+ };
335
+ }