@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nadohq/engine-client",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.11",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "> TODO: description",
@@ -37,8 +37,7 @@
37
37
  }
38
38
  },
39
39
  "dependencies": {
40
- "@nadohq/contracts": "^0.1.0-alpha.1",
41
- "@nadohq/utils": "^0.1.0-alpha.1",
40
+ "@nadohq/shared": "^0.1.0-alpha.11",
42
41
  "axios": "*",
43
42
  "ts-mixer": "*"
44
43
  },
@@ -48,5 +47,5 @@
48
47
  "devDependencies": {
49
48
  "viem": "*"
50
49
  },
51
- "gitHead": "80100d38c43806d1bb57c9139d9577329467d5db"
50
+ "gitHead": "2222bc4f697c773ce29bfde977eeb4df022f0e6c"
52
51
  }
@@ -3,8 +3,8 @@ import {
3
3
  SignableRequestType,
4
4
  SignableRequestTypeToParams,
5
5
  WalletClientWithAccount,
6
- } from '@nadohq/contracts';
7
- import { WalletNotProvidedError } from '@nadohq/utils';
6
+ WalletNotProvidedError,
7
+ } from '@nadohq/shared';
8
8
  import axios, { AxiosInstance, AxiosResponse } from 'axios';
9
9
  import {
10
10
  EngineServerExecuteRequestByType,
@@ -49,6 +49,8 @@ export class EngineBaseClient {
49
49
  this.opts = opts;
50
50
  this.axiosInstance = axios.create({
51
51
  withCredentials: true,
52
+ // We have custom logic to validate response status and create an appropriate error
53
+ validateStatus: () => true,
52
54
  });
53
55
  }
54
56
 
@@ -206,7 +208,7 @@ export class EngineBaseClient {
206
208
  private checkResponseStatus(response: AxiosResponse) {
207
209
  if (response.status !== 200 || !response.data) {
208
210
  throw Error(
209
- `Unexpected response from server: ${response.status} ${response.statusText}`,
211
+ `Unexpected response from server: ${response.status} ${response.statusText}. Data: ${response.data}`,
210
212
  );
211
213
  }
212
214
  }
@@ -1,15 +1,13 @@
1
1
  import {
2
- EIP712IsolatedOrderParams,
3
2
  EIP712OrderParams,
4
3
  getNadoEIP712Values,
5
4
  getOrderNonce,
6
5
  SignableRequestType,
7
6
  SignableRequestTypeToParams,
8
- } from '@nadohq/contracts';
7
+ } from '@nadohq/shared';
9
8
  import { EngineBaseClient } from './EngineBaseClient';
10
9
  import {
11
10
  EngineExecuteRequestParamsByType,
12
- EngineServerExecutePlaceIsolatedOrderPayload,
13
11
  EngineServerExecutePlaceOrderPayload,
14
12
  EngineServerExecuteRequestByType,
15
13
  SignatureParams,
@@ -89,7 +87,7 @@ export class EngineExecuteBuilder {
89
87
  const orderWithNonce = { ...clientParams.order, nonce };
90
88
 
91
89
  const signature = await this.getSignatureIfNeeded('place_order', {
92
- // Gets expected type
90
+ // Gets expected type (signature params from `clientParams` and order params from `orderWithNonce`)
93
91
  ...clientParams,
94
92
  ...orderWithNonce,
95
93
  });
@@ -126,64 +124,26 @@ export class EngineExecuteBuilder {
126
124
  order: orderEIP712Values,
127
125
  signature: clientParams.signature,
128
126
  spot_leverage: clientParams.spotLeverage ?? null,
127
+ borrow_margin: clientParams.borrowMargin ?? null,
129
128
  },
130
129
  orderParams: clientParams.order,
131
130
  };
132
131
  }
133
132
 
134
133
  /**
135
- * Builds server payload for the `place_isolated_order` execute action.
136
- *
137
- * @param clientParams Client PlaceIsolatedOrder params.
138
- * @returns `place_isolated_order` payload
139
- */
140
- async buildIsolatedPlaceOrderPayload(
141
- clientParams: EngineExecuteRequestParamsByType['place_isolated_order'],
142
- ): Promise<EngineServerExecutePlaceIsolatedOrderPayload> {
143
- const nonce = this.getOrderNonceIfNeeded(clientParams);
144
- const orderWithNonce = { ...clientParams.order, nonce };
145
-
146
- const signature = await this.getSignatureIfNeeded('place_isolated_order', {
147
- // Gets expected type
148
- ...clientParams,
149
- ...orderWithNonce,
150
- });
151
-
152
- return this.buildPlaceIsolatedOrderPayloadSync({
153
- ...clientParams,
154
- order: orderWithNonce,
155
- signature,
156
- });
157
- }
158
-
159
- /**
160
- * Synchronously builds server payload for the `place_isolated_order` execute action.
161
- *
162
- * @param clientParams Client PlaceIsolatedOrder params.
163
- * @returns `place_isolated_order` payload
134
+ * Builds server payload for the `place_orders` execute action.
135
+ * @param clientParams Client PlaceOrders params.
136
+ * @returns `place_orders` payload
164
137
  */
165
- buildPlaceIsolatedOrderPayloadSync(
166
- clientParams: WithSignature<
167
- EngineExecuteRequestParamsByType['place_isolated_order'] & {
168
- order: EIP712IsolatedOrderParams;
169
- }
170
- >,
171
- ): EngineServerExecutePlaceIsolatedOrderPayload {
172
- const isolatedOrderEIP712Values = getNadoEIP712Values(
173
- 'place_isolated_order',
174
- clientParams.order,
138
+ async buildPlaceOrdersPayload(
139
+ clientParams: EngineExecuteRequestParamsByType['place_orders'],
140
+ ): Promise<EngineServerExecuteRequestByType['place_orders']> {
141
+ return Promise.all(
142
+ clientParams.map(async (orderParams) => {
143
+ const payload = await this.buildPlaceOrderPayload(orderParams);
144
+ return payload.payload;
145
+ }),
175
146
  );
176
-
177
- return {
178
- payload: {
179
- id: clientParams.id ?? null,
180
- product_id: clientParams.productId,
181
- isolated_order: isolatedOrderEIP712Values,
182
- signature: clientParams.signature,
183
- borrow_margin: clientParams.borrowMargin ?? null,
184
- },
185
- orderParams: clientParams.order,
186
- };
187
147
  }
188
148
 
189
149
  /**
@@ -299,19 +259,19 @@ export class EngineExecuteBuilder {
299
259
  }
300
260
 
301
261
  /**
302
- * Builds server payload for the `mint_vlp` execute action.
303
- * @param clientParams Client MintVlp params.
304
- * @returns `mint_vlp` payload
262
+ * Builds server payload for the `mint_nlp` execute action.
263
+ * @param clientParams Client MintNlp params.
264
+ * @returns `mint_nlp` payload
305
265
  */
306
- async buildMintVlpPayload(
307
- clientParams: EngineExecuteRequestParamsByType['mint_vlp'],
308
- ): Promise<EngineServerExecuteRequestByType['mint_vlp']> {
266
+ async buildMintNlpPayload(
267
+ clientParams: EngineExecuteRequestParamsByType['mint_nlp'],
268
+ ): Promise<EngineServerExecuteRequestByType['mint_nlp']> {
309
269
  const nonce = await this.getTxNonceIfNeeded(clientParams);
310
270
  const paramsWithNonce = { ...clientParams, nonce };
311
271
 
312
- const tx = getNadoEIP712Values('mint_vlp', paramsWithNonce);
272
+ const tx = getNadoEIP712Values('mint_nlp', paramsWithNonce);
313
273
  const signature = await this.getSignatureIfNeeded(
314
- 'mint_vlp',
274
+ 'mint_nlp',
315
275
  paramsWithNonce,
316
276
  );
317
277
 
@@ -323,19 +283,19 @@ export class EngineExecuteBuilder {
323
283
  }
324
284
 
325
285
  /**
326
- * Builds server payload for the `burn_vlp` execute action.
327
- * @param clientParams Client BurnVlp params.
328
- * @returns `burn_vlp` payload
286
+ * Builds server payload for the `burn_nlp` execute action.
287
+ * @param clientParams Client BurnNlp params.
288
+ * @returns `burn_nlp` payload
329
289
  */
330
- async buildBurnVlpPayload(
331
- clientParams: EngineExecuteRequestParamsByType['burn_vlp'],
332
- ): Promise<EngineServerExecuteRequestByType['burn_vlp']> {
290
+ async buildBurnNlpPayload(
291
+ clientParams: EngineExecuteRequestParamsByType['burn_nlp'],
292
+ ): Promise<EngineServerExecuteRequestByType['burn_nlp']> {
333
293
  const nonce = await this.getTxNonceIfNeeded(clientParams);
334
294
  const paramsWithNonce = { ...clientParams, nonce };
335
295
 
336
- const tx = getNadoEIP712Values('burn_vlp', paramsWithNonce);
296
+ const tx = getNadoEIP712Values('burn_nlp', paramsWithNonce);
337
297
  const signature = await this.getSignatureIfNeeded(
338
- 'burn_vlp',
298
+ 'burn_nlp',
339
299
  paramsWithNonce,
340
300
  );
341
301
 
@@ -2,7 +2,6 @@ import { EngineBaseClient, EngineClientOpts } from './EngineBaseClient';
2
2
  import { EngineExecuteBuilder } from './EngineExecuteBuilder';
3
3
  import {
4
4
  EngineExecuteRequestParamsByType,
5
- EnginePlaceIsolatedOrderResult,
6
5
  EnginePlaceOrderResult,
7
6
  } from './types';
8
7
 
@@ -43,20 +42,6 @@ export class EngineExecuteClient extends EngineBaseClient {
43
42
  };
44
43
  }
45
44
 
46
- async placeIsolatedOrder(
47
- params: EngineExecuteRequestParamsByType['place_isolated_order'],
48
- ): Promise<EnginePlaceIsolatedOrderResult> {
49
- const placeOrderPayload =
50
- await this.payloadBuilder.buildIsolatedPlaceOrderPayload(params);
51
- return {
52
- ...(await this.execute(
53
- 'place_isolated_order',
54
- placeOrderPayload.payload,
55
- )),
56
- orderParams: placeOrderPayload.orderParams,
57
- };
58
- }
59
-
60
45
  async cancelOrders(
61
46
  params: EngineExecuteRequestParamsByType['cancel_orders'],
62
47
  ) {
@@ -106,17 +91,24 @@ export class EngineExecuteClient extends EngineBaseClient {
106
91
  );
107
92
  }
108
93
 
109
- async mintVlp(params: EngineExecuteRequestParamsByType['mint_vlp']) {
94
+ async mintNlp(params: EngineExecuteRequestParamsByType['mint_nlp']) {
95
+ return this.execute(
96
+ 'mint_nlp',
97
+ await this.payloadBuilder.buildMintNlpPayload(params),
98
+ );
99
+ }
100
+
101
+ async burnNlp(params: EngineExecuteRequestParamsByType['burn_nlp']) {
110
102
  return this.execute(
111
- 'mint_vlp',
112
- await this.payloadBuilder.buildMintVlpPayload(params),
103
+ 'burn_nlp',
104
+ await this.payloadBuilder.buildBurnNlpPayload(params),
113
105
  );
114
106
  }
115
107
 
116
- async burnVlp(params: EngineExecuteRequestParamsByType['burn_vlp']) {
108
+ async placeOrders(params: EngineExecuteRequestParamsByType['place_orders']) {
117
109
  return this.execute(
118
- 'burn_vlp',
119
- await this.payloadBuilder.buildBurnVlpPayload(params),
110
+ 'place_orders',
111
+ await this.payloadBuilder.buildPlaceOrdersPayload(params),
120
112
  );
121
113
  }
122
114
  }
@@ -1,16 +1,15 @@
1
- import {
2
- encodeSignedOrder,
3
- MarketWithProduct,
4
- subaccountToHex,
5
- } from '@nadohq/contracts';
6
1
  import {
7
2
  addDecimals,
8
3
  BigDecimal,
4
+ encodeSignedOrder,
5
+ getOrderVerifyingAddress,
9
6
  mapValues,
7
+ MarketWithProduct,
10
8
  removeDecimals,
9
+ subaccountToHex,
11
10
  toBigDecimal,
12
11
  toIntegerString,
13
- } from '@nadohq/utils';
12
+ } from '@nadohq/shared';
14
13
  import { EngineBaseClient } from './EngineBaseClient';
15
14
  import {
16
15
  EngineServerStatusResponse,
@@ -31,13 +30,12 @@ import {
31
30
  GetEngineMarketPriceResponse,
32
31
  GetEngineMarketPricesParams,
33
32
  GetEngineMarketPricesResponse,
34
- GetEngineMaxMintVlpAmountParams,
35
- GetEngineMaxMintVlpAmountResponse,
33
+ GetEngineMaxMintNlpAmountParams,
34
+ GetEngineMaxMintNlpAmountResponse,
36
35
  GetEngineMaxOrderSizeParams,
37
36
  GetEngineMaxOrderSizeResponse,
38
37
  GetEngineMaxWithdrawableParams,
39
38
  GetEngineMaxWithdrawableResponse,
40
- GetEngineMinDepositRatesResponse,
41
39
  GetEngineOrderParams,
42
40
  GetEngineOrderResponse,
43
41
  GetEngineSubaccountFeeRatesParams,
@@ -75,7 +73,6 @@ export class EngineQueryClient extends EngineBaseClient {
75
73
  return {
76
74
  chainId: Number(baseResponse.chain_id),
77
75
  endpointAddr: baseResponse.endpoint_addr,
78
- orderbookAddrs: baseResponse.book_addrs,
79
76
  };
80
77
  }
81
78
 
@@ -241,22 +238,6 @@ export class EngineQueryClient extends EngineBaseClient {
241
238
  };
242
239
  }
243
240
 
244
- /**
245
- * Retrieves min deposit rates for all spot products from the engine
246
- */
247
- async getMinDepositRates(): Promise<GetEngineMinDepositRatesResponse> {
248
- const baseResponse = await this.query('min_deposit_rates', {});
249
-
250
- return {
251
- minDepositRates: mapValues(baseResponse.min_deposit_rates, (m) => {
252
- return {
253
- productId: m.product_id,
254
- minDepositRate: removeDecimals(m.min_deposit_rate_x18),
255
- };
256
- }),
257
- };
258
- }
259
-
260
241
  /**
261
242
  * Retrieves an order from the offchain engine
262
243
  *
@@ -285,7 +266,7 @@ export class EngineQueryClient extends EngineBaseClient {
285
266
  order: params.order,
286
267
  signature: await this.sign(
287
268
  'place_order',
288
- params.orderbookAddr,
269
+ getOrderVerifyingAddress(params.productId),
289
270
  params.chainId,
290
271
  params.order,
291
272
  ),
@@ -400,6 +381,7 @@ export class EngineQueryClient extends EngineBaseClient {
400
381
  },
401
382
  {} as Record<number, BigDecimal>,
402
383
  ),
384
+ feeTier: baseResponse.fee_tier,
403
385
  };
404
386
  }
405
387
 
@@ -492,14 +474,14 @@ export class EngineQueryClient extends EngineBaseClient {
492
474
  }
493
475
 
494
476
  /**
495
- * Retrieves the estimated max quote amount for minting VLP.
477
+ * Retrieves the estimated max quote amount for minting NLP.
496
478
  *
497
479
  * @param params
498
480
  */
499
- async getMaxMintVlpAmount(
500
- params: GetEngineMaxMintVlpAmountParams,
501
- ): Promise<GetEngineMaxMintVlpAmountResponse> {
502
- const baseResponse = await this.query('max_vlp_mintable', {
481
+ async getMaxMintNlpAmount(
482
+ params: GetEngineMaxMintNlpAmountParams,
483
+ ): Promise<GetEngineMaxMintNlpAmountResponse> {
484
+ const baseResponse = await this.query('max_nlp_mintable', {
503
485
  sender: subaccountToHex({
504
486
  subaccountOwner: params.subaccountOwner,
505
487
  subaccountName: params.subaccountName,
@@ -540,14 +522,4 @@ export class EngineQueryClient extends EngineBaseClient {
540
522
 
541
523
  return toBigDecimal(baseResponse.insurance);
542
524
  }
543
-
544
- /**
545
- * Gets the orderbook contract address for a given product
546
- * @param productId
547
- * @returns
548
- */
549
- public async getOrderbookAddress(productId: number): Promise<string> {
550
- const contracts = await this.getContracts();
551
- return contracts.orderbookAddrs[productId];
552
- }
553
525
  }
@@ -18,8 +18,6 @@ export class EngineWebClient extends EngineBaseClient {
18
18
  this.axiosInstance
19
19
  // Use the /time endpoint and listen to 403 responses
20
20
  .get(`${this.opts.url}/ip`, {
21
- // Allow all statuses
22
- validateStatus: () => true,
23
21
  // IP checks go through Cloudflare, which uses allow-origin as *, so withCredentials needs to be false
24
22
  withCredentials: false,
25
23
  })
package/src/endpoints.ts CHANGED
@@ -1,21 +1,20 @@
1
- import { ChainEnv } from '@nadohq/contracts';
1
+ import { ChainEnv } from '@nadohq/shared';
2
2
 
3
3
  export const ENGINE_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {
4
4
  local: 'http://localhost:80',
5
- arbitrumTestnet: 'https://gateway.sepolia-test.vertexprotocol.com/v1',
6
5
  arbitrum: 'https://gateway.prod.vertexprotocol.com/v1',
6
+ inkTestnet: 'https://gateway.test.nado-backend.xyz/v1',
7
7
  };
8
8
 
9
9
  export const ENGINE_WS_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {
10
10
  local: 'ws://localhost:80',
11
- arbitrumTestnet: 'wss://gateway.sepolia-test.vertexprotocol.com/v1/ws',
12
11
  arbitrum: 'wss://gateway.prod.vertexprotocol.com/v1/ws',
12
+ inkTestnet: 'wss://gateway.test.nado-backend.xyz/v1/ws',
13
13
  };
14
14
 
15
15
  export const ENGINE_WS_SUBSCRIPTION_CLIENT_ENDPOINTS: Record<ChainEnv, string> =
16
16
  {
17
17
  local: 'ws://localhost:80',
18
- arbitrumTestnet:
19
- 'wss://gateway.sepolia-test.vertexprotocol.com/v1/subscribe',
20
18
  arbitrum: 'wss://gateway.prod.vertexprotocol.com/v1/subscribe',
19
+ inkTestnet: 'wss://gateway.test.nado-backend.xyz/v1/subscribe',
21
20
  };
@@ -1,5 +1,5 @@
1
- import { EngineServerQueryFailureResponse } from './serverQueryTypes';
2
1
  import { EngineServerExecuteFailureResult } from './serverExecuteTypes';
2
+ import { EngineServerQueryFailureResponse } from './serverQueryTypes';
3
3
 
4
4
  export class EngineServerFailureError extends Error {
5
5
  constructor(
@@ -7,6 +7,6 @@ export class EngineServerFailureError extends Error {
7
7
  | EngineServerQueryFailureResponse
8
8
  | EngineServerExecuteFailureResult,
9
9
  ) {
10
- super();
10
+ super(`${responseData.error_code}: ${responseData.error}`);
11
11
  }
12
12
  }
@@ -1,15 +1,14 @@
1
1
  import {
2
- EIP712BurnVlpParams,
2
+ EIP712BurnNlpParams,
3
3
  EIP712CancelOrdersParams,
4
4
  EIP712CancelProductOrdersParams,
5
- EIP712IsolatedOrderParams,
6
5
  EIP712LinkSignerParams,
7
6
  EIP712LiquidateSubaccountParams,
8
- EIP712MintVlpParams,
7
+ EIP712MintNlpParams,
9
8
  EIP712OrderParams,
10
9
  EIP712TransferQuoteParams,
11
10
  EIP712WithdrawCollateralParams,
12
- } from '@nadohq/contracts';
11
+ } from '@nadohq/shared';
13
12
  import { EngineServerExecuteSuccessResult } from './serverExecuteTypes';
14
13
 
15
14
  /**
@@ -50,15 +49,7 @@ export type EnginePlaceOrderParams = WithBaseEngineExecuteParams<{
50
49
  order: EngineOrderParams;
51
50
  // If not given, engine defaults to true (leverage/borrow enabled)
52
51
  spotLeverage?: boolean;
53
- }>;
54
-
55
- export type EngineIsolatedOrderParams = WithoutNonce<EIP712IsolatedOrderParams>;
56
-
57
- export type EnginePlaceIsolatedOrderParams = WithBaseEngineExecuteParams<{
58
- id?: number;
59
- productId: number;
60
- order: EngineIsolatedOrderParams;
61
- // Whether the cross subaccount can borrow quote for the margin transfer into the isolated subaccount. If not given, engine defaults to true.
52
+ // For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative USDC balance)
62
53
  borrowMargin?: boolean;
63
54
  }>;
64
55
 
@@ -86,23 +77,25 @@ export type EngineLinkSignerParams =
86
77
  export type EngineTransferQuoteParams =
87
78
  WithBaseEngineExecuteParams<EIP712TransferQuoteParams>;
88
79
 
89
- export type EngineMintVlpParams = WithBaseEngineExecuteParams<
90
- WithSpotLeverage<EIP712MintVlpParams>
80
+ export type EngineMintNlpParams = WithBaseEngineExecuteParams<
81
+ WithSpotLeverage<EIP712MintNlpParams>
91
82
  >;
92
83
 
93
- export type EngineBurnVlpParams =
94
- WithBaseEngineExecuteParams<EIP712BurnVlpParams>;
84
+ export type EngineBurnNlpParams =
85
+ WithBaseEngineExecuteParams<EIP712BurnNlpParams>;
86
+
87
+ export type EnginePlaceOrdersParams = EnginePlaceOrderParams[];
95
88
 
96
89
  export interface EngineExecuteRequestParamsByType {
97
- burn_vlp: EngineBurnVlpParams;
90
+ burn_nlp: EngineBurnNlpParams;
98
91
  cancel_and_place: EngineCancelAndPlaceParams;
99
92
  cancel_orders: EngineCancelOrdersParams;
100
93
  cancel_product_orders: EngineCancelProductOrdersParams;
101
94
  link_signer: EngineLinkSignerParams;
102
95
  liquidate_subaccount: EngineLiquidateSubaccountParams;
103
- mint_vlp: EngineMintVlpParams;
104
- place_isolated_order: EnginePlaceIsolatedOrderParams;
96
+ mint_nlp: EngineMintNlpParams;
105
97
  place_order: EnginePlaceOrderParams;
98
+ place_orders: EnginePlaceOrdersParams;
106
99
  transfer_quote: EngineTransferQuoteParams;
107
100
  withdraw_collateral: EngineWithdrawCollateralParams;
108
101
  }
@@ -111,8 +104,3 @@ export type EnginePlaceOrderResult =
111
104
  EngineServerExecuteSuccessResult<'place_order'> & {
112
105
  orderParams: EIP712OrderParams;
113
106
  };
114
-
115
- export type EnginePlaceIsolatedOrderResult =
116
- EngineServerExecuteSuccessResult<'place_isolated_order'> & {
117
- orderParams: EIP712IsolatedOrderParams;
118
- };
@@ -1,27 +1,31 @@
1
1
  import {
2
2
  BalanceHealthContributions,
3
3
  BalanceSide,
4
+ BalanceWithProduct,
5
+ BigDecimal,
4
6
  EIP712OrderParams,
5
- GetAllMarketsResponse,
6
- GetSubaccountSummaryParams,
7
7
  HealthGroup,
8
- OrderExpirationType,
8
+ HealthStatusByType,
9
+ MarketWithProduct,
10
+ OrderAppendix,
9
11
  PerpBalanceWithProduct,
10
12
  ProductEngineType,
11
13
  SignedEIP712OrderParams,
12
14
  SpotBalanceWithProduct,
13
15
  Subaccount,
14
- SubaccountSummaryResponse,
15
- } from '@nadohq/contracts';
16
- import { BigDecimal } from '@nadohq/utils';
16
+ } from '@nadohq/shared';
17
17
  import {
18
18
  EngineServerNoncesParams,
19
19
  EngineServerTimeResponse,
20
20
  } from './serverQueryTypes';
21
21
 
22
- export type GetEngineSubaccountSummaryResponse = SubaccountSummaryResponse;
22
+ export type GetEngineSubaccountSummaryResponse = {
23
+ exists: boolean;
24
+ balances: BalanceWithProduct[];
25
+ health: HealthStatusByType;
26
+ };
23
27
 
24
- export type GetEngineSubaccountSummaryParams = GetSubaccountSummaryParams;
28
+ export type GetEngineSubaccountSummaryParams = Subaccount;
25
29
 
26
30
  export type GetEngineIsolatedPositionsParams = Subaccount;
27
31
 
@@ -48,16 +52,11 @@ export interface SubaccountProductDeltaTx {
48
52
  export interface GetEngineContractsResponse {
49
53
  chainId: number;
50
54
  endpointAddr: string;
51
- /**
52
- * Address for the orderbook contract, with the product ID being the index
53
- */
54
- orderbookAddrs: string[];
55
55
  }
56
56
 
57
- export type GetEngineEstimatedSubaccountSummaryParams =
58
- GetSubaccountSummaryParams & {
59
- txs: SubaccountTx[];
60
- };
57
+ export type GetEngineEstimatedSubaccountSummaryParams = Subaccount & {
58
+ txs: SubaccountTx[];
59
+ };
61
60
 
62
61
  export type GetEngineNoncesParams = EngineServerNoncesParams;
63
62
 
@@ -91,7 +90,7 @@ export interface EngineSymbol {
91
90
  longWeightMaintenance: BigDecimal;
92
91
  }
93
92
 
94
- export type GetEngineAllMarketsResponse = GetAllMarketsResponse;
93
+ export type GetEngineAllMarketsResponse = MarketWithProduct[];
95
94
 
96
95
  export interface GetEngineHealthGroupsResponse {
97
96
  healthGroups: HealthGroup[];
@@ -109,14 +108,11 @@ export interface EngineOrder extends Subaccount {
109
108
  totalAmount: BigDecimal;
110
109
  // Amount still unfilled
111
110
  unfilledAmount: BigDecimal;
112
- expiration: BigDecimal;
113
- // Margin being transferred for the order, will be null if not an iso order
114
- margin: BigDecimal | null;
111
+ expiration: number;
115
112
  nonce: string;
116
113
  digest: string;
117
- orderParams: EIP712OrderParams;
118
114
  placementTime: number;
119
- orderType: OrderExpirationType;
115
+ appendix: OrderAppendix;
120
116
  }
121
117
 
122
118
  export type GetEngineOrderResponse = EngineOrder;
@@ -128,7 +124,6 @@ export interface ValidateSignedEngineOrderParams {
128
124
 
129
125
  export interface ValidateEngineOrderParams {
130
126
  productId: number;
131
- orderbookAddr: string;
132
127
  chainId: number;
133
128
  order: EIP712OrderParams;
134
129
  }
@@ -171,6 +166,7 @@ export interface GetEngineSubaccountFeeRatesResponse {
171
166
  liquidationSequencerFee: BigDecimal;
172
167
  healthCheckSequencerFee: BigDecimal;
173
168
  takerSequencerFee: BigDecimal;
169
+ feeTier: number;
174
170
  }
175
171
 
176
172
  export interface EnginePriceTickLiquidity {
@@ -242,15 +238,6 @@ export interface GetEngineLinkedSignerResponse {
242
238
 
243
239
  export type GetEngineInsuranceResponse = BigDecimal;
244
240
 
245
- export interface EngineMinDepositRate {
246
- productId: number;
247
- minDepositRate: BigDecimal;
248
- }
249
-
250
- export interface GetEngineMinDepositRatesResponse {
251
- minDepositRates: Record<number, EngineMinDepositRate>;
252
- }
253
-
254
241
  /**
255
242
  * Given an IP, backend will either:
256
243
  * - Allow queries only through archive / engine (query_only)
@@ -259,9 +246,9 @@ export interface GetEngineMinDepositRatesResponse {
259
246
  */
260
247
  export type GetEngineIpBlockStatusResponse = 'query_only' | 'blocked' | null;
261
248
 
262
- export interface GetEngineMaxMintVlpAmountParams extends Subaccount {
249
+ export interface GetEngineMaxMintNlpAmountParams extends Subaccount {
263
250
  // If not given, engine defaults to true (leverage/borrow enabled)
264
251
  spotLeverage?: boolean;
265
252
  }
266
253
 
267
- export type GetEngineMaxMintVlpAmountResponse = BigDecimal;
254
+ export type GetEngineMaxMintNlpAmountResponse = BigDecimal;