@nadohq/engine-client 0.1.0-alpha.1

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 (142) hide show
  1. package/README.md +2 -0
  2. package/dist/EngineBaseClient.cjs +166 -0
  3. package/dist/EngineBaseClient.cjs.map +1 -0
  4. package/dist/EngineBaseClient.d.cts +75 -0
  5. package/dist/EngineBaseClient.d.ts +75 -0
  6. package/dist/EngineBaseClient.js +133 -0
  7. package/dist/EngineBaseClient.js.map +1 -0
  8. package/dist/EngineClient.cjs +40 -0
  9. package/dist/EngineClient.cjs.map +1 -0
  10. package/dist/EngineClient.d.cts +23 -0
  11. package/dist/EngineClient.d.ts +23 -0
  12. package/dist/EngineClient.js +15 -0
  13. package/dist/EngineClient.js.map +1 -0
  14. package/dist/EngineExecuteBuilder.cjs +304 -0
  15. package/dist/EngineExecuteBuilder.cjs.map +1 -0
  16. package/dist/EngineExecuteBuilder.d.cts +118 -0
  17. package/dist/EngineExecuteBuilder.d.ts +118 -0
  18. package/dist/EngineExecuteBuilder.js +282 -0
  19. package/dist/EngineExecuteBuilder.js.map +1 -0
  20. package/dist/EngineExecuteClient.cjs +114 -0
  21. package/dist/EngineExecuteClient.cjs.map +1 -0
  22. package/dist/EngineExecuteClient.d.cts +28 -0
  23. package/dist/EngineExecuteClient.d.ts +28 -0
  24. package/dist/EngineExecuteClient.js +89 -0
  25. package/dist/EngineExecuteClient.js.map +1 -0
  26. package/dist/EngineQueryClient.cjs +431 -0
  27. package/dist/EngineQueryClient.cjs.map +1 -0
  28. package/dist/EngineQueryClient.d.cts +143 -0
  29. package/dist/EngineQueryClient.d.ts +143 -0
  30. package/dist/EngineQueryClient.js +424 -0
  31. package/dist/EngineQueryClient.js.map +1 -0
  32. package/dist/EngineWebClient.cjs +75 -0
  33. package/dist/EngineWebClient.cjs.map +1 -0
  34. package/dist/EngineWebClient.d.cts +31 -0
  35. package/dist/EngineWebClient.d.ts +31 -0
  36. package/dist/EngineWebClient.js +50 -0
  37. package/dist/EngineWebClient.js.map +1 -0
  38. package/dist/endpoints.cjs +49 -0
  39. package/dist/endpoints.cjs.map +1 -0
  40. package/dist/endpoints.d.cts +7 -0
  41. package/dist/endpoints.d.ts +7 -0
  42. package/dist/endpoints.js +22 -0
  43. package/dist/endpoints.js.map +1 -0
  44. package/dist/index.cjs +31 -0
  45. package/dist/index.cjs.map +1 -0
  46. package/dist/index.d.cts +20 -0
  47. package/dist/index.d.ts +20 -0
  48. package/dist/index.js +6 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/types/EngineServerFailureError.cjs +36 -0
  51. package/dist/types/EngineServerFailureError.cjs.map +1 -0
  52. package/dist/types/EngineServerFailureError.d.cts +11 -0
  53. package/dist/types/EngineServerFailureError.d.ts +11 -0
  54. package/dist/types/EngineServerFailureError.js +11 -0
  55. package/dist/types/EngineServerFailureError.js.map +1 -0
  56. package/dist/types/clientExecuteTypes.cjs +19 -0
  57. package/dist/types/clientExecuteTypes.cjs.map +1 -0
  58. package/dist/types/clientExecuteTypes.d.cts +74 -0
  59. package/dist/types/clientExecuteTypes.d.ts +74 -0
  60. package/dist/types/clientExecuteTypes.js +1 -0
  61. package/dist/types/clientExecuteTypes.js.map +1 -0
  62. package/dist/types/clientQueryTypes.cjs +19 -0
  63. package/dist/types/clientQueryTypes.cjs.map +1 -0
  64. package/dist/types/clientQueryTypes.d.cts +189 -0
  65. package/dist/types/clientQueryTypes.d.ts +189 -0
  66. package/dist/types/clientQueryTypes.js +1 -0
  67. package/dist/types/clientQueryTypes.js.map +1 -0
  68. package/dist/types/index.cjs +39 -0
  69. package/dist/types/index.cjs.map +1 -0
  70. package/dist/types/index.d.cts +10 -0
  71. package/dist/types/index.d.ts +10 -0
  72. package/dist/types/index.js +10 -0
  73. package/dist/types/index.js.map +1 -0
  74. package/dist/types/serverExecuteTypes.cjs +19 -0
  75. package/dist/types/serverExecuteTypes.cjs.map +1 -0
  76. package/dist/types/serverExecuteTypes.d.cts +91 -0
  77. package/dist/types/serverExecuteTypes.d.ts +91 -0
  78. package/dist/types/serverExecuteTypes.js +1 -0
  79. package/dist/types/serverExecuteTypes.js.map +1 -0
  80. package/dist/types/serverQueryModelTypes.cjs +19 -0
  81. package/dist/types/serverQueryModelTypes.cjs.map +1 -0
  82. package/dist/types/serverQueryModelTypes.d.cts +73 -0
  83. package/dist/types/serverQueryModelTypes.d.ts +73 -0
  84. package/dist/types/serverQueryModelTypes.js +1 -0
  85. package/dist/types/serverQueryModelTypes.js.map +1 -0
  86. package/dist/types/serverQueryTypes.cjs +19 -0
  87. package/dist/types/serverQueryTypes.cjs.map +1 -0
  88. package/dist/types/serverQueryTypes.d.cts +292 -0
  89. package/dist/types/serverQueryTypes.d.ts +292 -0
  90. package/dist/types/serverQueryTypes.js +1 -0
  91. package/dist/types/serverQueryTypes.js.map +1 -0
  92. package/dist/types/serverSubscriptionEventTypes.cjs +19 -0
  93. package/dist/types/serverSubscriptionEventTypes.cjs.map +1 -0
  94. package/dist/types/serverSubscriptionEventTypes.d.cts +71 -0
  95. package/dist/types/serverSubscriptionEventTypes.d.ts +71 -0
  96. package/dist/types/serverSubscriptionEventTypes.js +1 -0
  97. package/dist/types/serverSubscriptionEventTypes.js.map +1 -0
  98. package/dist/types/serverSubscriptionTypes.cjs +19 -0
  99. package/dist/types/serverSubscriptionTypes.cjs.map +1 -0
  100. package/dist/types/serverSubscriptionTypes.d.cts +63 -0
  101. package/dist/types/serverSubscriptionTypes.d.ts +63 -0
  102. package/dist/types/serverSubscriptionTypes.js +1 -0
  103. package/dist/types/serverSubscriptionTypes.js.map +1 -0
  104. package/dist/utils/index.cjs +25 -0
  105. package/dist/utils/index.cjs.map +1 -0
  106. package/dist/utils/index.d.cts +6 -0
  107. package/dist/utils/index.d.ts +6 -0
  108. package/dist/utils/index.js +3 -0
  109. package/dist/utils/index.js.map +1 -0
  110. package/dist/utils/productEngineTypeMappers.cjs +49 -0
  111. package/dist/utils/productEngineTypeMappers.cjs.map +1 -0
  112. package/dist/utils/productEngineTypeMappers.d.cts +7 -0
  113. package/dist/utils/productEngineTypeMappers.d.ts +7 -0
  114. package/dist/utils/productEngineTypeMappers.js +23 -0
  115. package/dist/utils/productEngineTypeMappers.js.map +1 -0
  116. package/dist/utils/queryDataMappers.cjs +282 -0
  117. package/dist/utils/queryDataMappers.cjs.map +1 -0
  118. package/dist/utils/queryDataMappers.d.cts +18 -0
  119. package/dist/utils/queryDataMappers.d.ts +18 -0
  120. package/dist/utils/queryDataMappers.js +258 -0
  121. package/dist/utils/queryDataMappers.js.map +1 -0
  122. package/package.json +52 -0
  123. package/src/EngineBaseClient.ts +223 -0
  124. package/src/EngineClient.ts +13 -0
  125. package/src/EngineExecuteBuilder.ts +381 -0
  126. package/src/EngineExecuteClient.ts +122 -0
  127. package/src/EngineQueryClient.ts +553 -0
  128. package/src/EngineWebClient.ts +72 -0
  129. package/src/endpoints.ts +21 -0
  130. package/src/index.ts +4 -0
  131. package/src/types/EngineServerFailureError.ts +12 -0
  132. package/src/types/clientExecuteTypes.ts +118 -0
  133. package/src/types/clientQueryTypes.ts +267 -0
  134. package/src/types/index.ts +8 -0
  135. package/src/types/serverExecuteTypes.ts +138 -0
  136. package/src/types/serverQueryModelTypes.ts +83 -0
  137. package/src/types/serverQueryTypes.ts +382 -0
  138. package/src/types/serverSubscriptionEventTypes.ts +74 -0
  139. package/src/types/serverSubscriptionTypes.ts +79 -0
  140. package/src/utils/index.ts +1 -0
  141. package/src/utils/productEngineTypeMappers.ts +24 -0
  142. package/src/utils/queryDataMappers.ts +303 -0
@@ -0,0 +1,143 @@
1
+ import { MarketWithProduct } from '@nadohq/contracts';
2
+ import { EngineBaseClient } from './EngineBaseClient.js';
3
+ import { GetEngineContractsResponse, GetEngineSubaccountSummaryParams, GetEngineSubaccountSummaryResponse, GetEngineIsolatedPositionsParams, GetEngineIsolatedPositionsResponse, GetEngineEstimatedSubaccountSummaryParams, GetEngineSymbolsParams, EngineSymbolsResponse, GetEngineAllMarketsResponse, GetEngineHealthGroupsResponse, GetEngineMinDepositRatesResponse, GetEngineOrderParams, GetEngineOrderResponse, ValidateEngineOrderParams, ValidateEngineOrderResponse, ValidateSignedEngineOrderParams, GetEngineSubaccountOrdersParams, GetEngineSubaccountOrdersResponse, GetEngineSubaccountProductOrdersParams, GetEngineSubaccountProductOrdersResponse, GetEngineSubaccountFeeRatesParams, GetEngineSubaccountFeeRatesResponse, GetEngineMarketLiquidityParams, GetEngineMarketLiquidityResponse, GetEngineMarketPriceParams, GetEngineMarketPriceResponse, GetEngineMarketPricesParams, GetEngineMarketPricesResponse, GetEngineMaxOrderSizeParams, GetEngineMaxOrderSizeResponse, GetEngineMaxWithdrawableParams, GetEngineMaxWithdrawableResponse, GetEngineMaxMintVlpAmountParams, GetEngineMaxMintVlpAmountResponse, GetEngineLinkedSignerParams, GetEngineLinkedSignerResponse, GetEngineInsuranceResponse } from './types/clientQueryTypes.js';
4
+ import { EngineServerStatusResponse } from './types/serverQueryTypes.js';
5
+ import 'axios';
6
+ import './types/serverExecuteTypes.js';
7
+ import '@nadohq/utils';
8
+ import './types/serverQueryModelTypes.js';
9
+
10
+ declare class EngineQueryClient extends EngineBaseClient {
11
+ /**
12
+ * Retrieves the set of contracts that the engine is interfacing with
13
+ */
14
+ getContracts(): Promise<GetEngineContractsResponse>;
15
+ /**
16
+ * Retrieves current engine status
17
+ */
18
+ getStatus(): Promise<EngineServerStatusResponse>;
19
+ /**
20
+ * Retrieves a subaccount summary reflective of the state within the offchain engine. This adheres to the
21
+ * same return interface as the contract version
22
+ *
23
+ * @param params
24
+ */
25
+ getSubaccountSummary(params: GetEngineSubaccountSummaryParams): Promise<GetEngineSubaccountSummaryResponse>;
26
+ /**
27
+ * Retrieves a list of isolated positions
28
+ *
29
+ * @param params
30
+ */
31
+ getIsolatedPositions(params: GetEngineIsolatedPositionsParams): Promise<GetEngineIsolatedPositionsResponse>;
32
+ /**
33
+ * Retrieves an estimated subaccount summary with the applied transactions
34
+ *
35
+ * @param params
36
+ */
37
+ getEstimatedSubaccountSummary(params: GetEngineEstimatedSubaccountSummaryParams): Promise<GetEngineSubaccountSummaryResponse>;
38
+ /**
39
+ * Retrieves symbols and product info
40
+ *
41
+ * @param params
42
+ */
43
+ getSymbols(params: GetEngineSymbolsParams): Promise<EngineSymbolsResponse>;
44
+ /**
45
+ * Retrieves all market states as per the offchain engine. Same return interface as contracts
46
+ */
47
+ getAllMarkets(): Promise<GetEngineAllMarketsResponse>;
48
+ /**
49
+ * Retrieves all markets by chain id.
50
+ */
51
+ getEdgeAllMarkets(): Promise<Record<number, MarketWithProduct[]>>;
52
+ /**
53
+ * Retrieves all health groups (linked spot & perp products) from the engine
54
+ */
55
+ getHealthGroups(): Promise<GetEngineHealthGroupsResponse>;
56
+ /**
57
+ * Retrieves min deposit rates for all spot products from the engine
58
+ */
59
+ getMinDepositRates(): Promise<GetEngineMinDepositRatesResponse>;
60
+ /**
61
+ * Retrieves an order from the offchain engine
62
+ *
63
+ * @param params
64
+ */
65
+ getOrder(params: GetEngineOrderParams): Promise<GetEngineOrderResponse>;
66
+ /**
67
+ * Signs and validates with the engine that the order is valid to be submitted (i.e. does not violate health reqs)
68
+ *
69
+ * @param params
70
+ */
71
+ validateOrderParams(params: ValidateEngineOrderParams): Promise<ValidateEngineOrderResponse>;
72
+ /**
73
+ * Validates an existing signed order with the engine as a pre-check for health
74
+ *
75
+ * @param params
76
+ */
77
+ validateSignedOrderParams(params: ValidateSignedEngineOrderParams): Promise<ValidateEngineOrderResponse>;
78
+ /**
79
+ * Get all subaccount orders from the engine, per product ID
80
+ * @param params
81
+ */
82
+ getSubaccountOrders(params: GetEngineSubaccountOrdersParams): Promise<GetEngineSubaccountOrdersResponse>;
83
+ /**
84
+ * Get all subaccount orders from the engine, for multiple products
85
+ * @param params
86
+ */
87
+ getSubaccountMultiProductOrders(params: GetEngineSubaccountProductOrdersParams): Promise<GetEngineSubaccountProductOrdersResponse>;
88
+ /**
89
+ * Gets maker & taker fee rates for order fees
90
+ * @param params
91
+ */
92
+ getSubaccountFeeRates(params: GetEngineSubaccountFeeRatesParams): Promise<GetEngineSubaccountFeeRatesResponse>;
93
+ /**
94
+ * Gets "price ticks" for a given market, useful for constructing liquidity levels at each price
95
+ * @param params
96
+ */
97
+ getMarketLiquidity(params: GetEngineMarketLiquidityParams): Promise<GetEngineMarketLiquidityResponse>;
98
+ /**
99
+ * Retrieves the latest price for a given market
100
+ * @param params
101
+ */
102
+ getMarketPrice(params: GetEngineMarketPriceParams): Promise<GetEngineMarketPriceResponse>;
103
+ /**
104
+ * Retrieves the latest prices for provided markets
105
+ * @param params
106
+ */
107
+ getMarketPrices(params: GetEngineMarketPricesParams): Promise<GetEngineMarketPricesResponse>;
108
+ /**
109
+ * Retrieves the estimated max order size for a product
110
+ * @param params
111
+ */
112
+ getMaxOrderSize(params: GetEngineMaxOrderSizeParams): Promise<GetEngineMaxOrderSizeResponse>;
113
+ /**
114
+ * Retrieves the estimated max withdrawal size for a product
115
+ * @param params
116
+ */
117
+ getMaxWithdrawable(params: GetEngineMaxWithdrawableParams): Promise<GetEngineMaxWithdrawableResponse>;
118
+ /**
119
+ * Retrieves the estimated max quote amount for minting VLP.
120
+ *
121
+ * @param params
122
+ */
123
+ getMaxMintVlpAmount(params: GetEngineMaxMintVlpAmountParams): Promise<GetEngineMaxMintVlpAmountResponse>;
124
+ /**
125
+ * Gets the currently linked signer for the subaccount
126
+ * @param params
127
+ * @returns
128
+ */
129
+ getLinkedSigner(params: GetEngineLinkedSignerParams): Promise<GetEngineLinkedSignerResponse>;
130
+ /**
131
+ * Gets the insurance funds in USDC.
132
+ * @returns
133
+ */
134
+ getInsurance(): Promise<GetEngineInsuranceResponse>;
135
+ /**
136
+ * Gets the orderbook contract address for a given product
137
+ * @param productId
138
+ * @returns
139
+ */
140
+ getOrderbookAddress(productId: number): Promise<string>;
141
+ }
142
+
143
+ export { EngineQueryClient };
@@ -0,0 +1,424 @@
1
+ // src/EngineQueryClient.ts
2
+ import {
3
+ encodeSignedOrder,
4
+ subaccountToHex
5
+ } from "@nadohq/contracts";
6
+ import {
7
+ addDecimals,
8
+ mapValues,
9
+ removeDecimals,
10
+ toBigDecimal,
11
+ toIntegerString
12
+ } from "@nadohq/utils";
13
+ import { EngineBaseClient } from "./EngineBaseClient.js";
14
+ import { mapProductEngineType } from "./utils/productEngineTypeMappers.js";
15
+ import {
16
+ mapEngineMarketPrice,
17
+ mapEngineServerIsolatedPositions,
18
+ mapEngineServerOrder,
19
+ mapEngineServerPerpProduct,
20
+ mapEngineServerSpotProduct,
21
+ mapEngineServerSymbols,
22
+ mapEngineServerTickLiquidity,
23
+ mapSubaccountSummary
24
+ } from "./utils/queryDataMappers.js";
25
+ var EngineQueryClient = class extends EngineBaseClient {
26
+ /**
27
+ * Retrieves the set of contracts that the engine is interfacing with
28
+ */
29
+ async getContracts() {
30
+ const baseResponse = await this.query("contracts", {});
31
+ return {
32
+ chainId: Number(baseResponse.chain_id),
33
+ endpointAddr: baseResponse.endpoint_addr,
34
+ orderbookAddrs: baseResponse.book_addrs
35
+ };
36
+ }
37
+ /**
38
+ * Retrieves current engine status
39
+ */
40
+ async getStatus() {
41
+ return this.query("status", {});
42
+ }
43
+ /**
44
+ * Retrieves a subaccount summary reflective of the state within the offchain engine. This adheres to the
45
+ * same return interface as the contract version
46
+ *
47
+ * @param params
48
+ */
49
+ async getSubaccountSummary(params) {
50
+ const subaccount = subaccountToHex({
51
+ subaccountOwner: params.subaccountOwner,
52
+ subaccountName: params.subaccountName
53
+ });
54
+ const baseResponse = await this.query("subaccount_info", {
55
+ subaccount
56
+ });
57
+ return mapSubaccountSummary(baseResponse);
58
+ }
59
+ /**
60
+ * Retrieves a list of isolated positions
61
+ *
62
+ * @param params
63
+ */
64
+ async getIsolatedPositions(params) {
65
+ const subaccount = subaccountToHex({
66
+ subaccountOwner: params.subaccountOwner,
67
+ subaccountName: params.subaccountName
68
+ });
69
+ const baseResponse = await this.query("isolated_positions", {
70
+ subaccount
71
+ });
72
+ return mapEngineServerIsolatedPositions(baseResponse);
73
+ }
74
+ /**
75
+ * Retrieves an estimated subaccount summary with the applied transactions
76
+ *
77
+ * @param params
78
+ */
79
+ async getEstimatedSubaccountSummary(params) {
80
+ const subaccount = subaccountToHex({
81
+ subaccountOwner: params.subaccountOwner,
82
+ subaccountName: params.subaccountName
83
+ });
84
+ const queryParams = {
85
+ subaccount,
86
+ txns: params.txs.map(
87
+ (tx) => {
88
+ switch (tx.type) {
89
+ case "apply_delta":
90
+ return {
91
+ apply_delta: {
92
+ product_id: tx.tx.productId,
93
+ subaccount,
94
+ amount_delta: toIntegerString(tx.tx.amountDelta),
95
+ v_quote_delta: toIntegerString(tx.tx.vQuoteDelta)
96
+ }
97
+ };
98
+ }
99
+ }
100
+ )
101
+ };
102
+ const baseResponse = await this.query("subaccount_info", {
103
+ subaccount: queryParams.subaccount,
104
+ txns: JSON.stringify(queryParams.txns)
105
+ });
106
+ return mapSubaccountSummary(baseResponse);
107
+ }
108
+ /**
109
+ * Retrieves symbols and product info
110
+ *
111
+ * @param params
112
+ */
113
+ async getSymbols(params) {
114
+ const baseResponse = await this.query("symbols", {
115
+ product_ids: params.productIds,
116
+ product_type: params.productType != null ? mapProductEngineType(params.productType) : void 0
117
+ });
118
+ return mapEngineServerSymbols(baseResponse);
119
+ }
120
+ /**
121
+ * Retrieves all market states as per the offchain engine. Same return interface as contracts
122
+ */
123
+ async getAllMarkets() {
124
+ const markets = [];
125
+ const baseResponse = await this.query("all_products", {});
126
+ baseResponse.spot_products.forEach((spotProduct) => {
127
+ markets.push(mapEngineServerSpotProduct(spotProduct));
128
+ });
129
+ baseResponse.perp_products.forEach((perpProduct) => {
130
+ markets.push(mapEngineServerPerpProduct(perpProduct));
131
+ });
132
+ return markets;
133
+ }
134
+ /**
135
+ * Retrieves all markets by chain id.
136
+ */
137
+ async getEdgeAllMarkets() {
138
+ const baseResponse = await this.query("edge_all_products", {});
139
+ return mapValues(baseResponse.edge_all_products, (allProducts) => {
140
+ const markets = [];
141
+ allProducts.spot_products.forEach((spotProduct) => {
142
+ markets.push(mapEngineServerSpotProduct(spotProduct));
143
+ });
144
+ allProducts.perp_products.forEach((perpProduct) => {
145
+ markets.push(mapEngineServerPerpProduct(perpProduct));
146
+ });
147
+ return markets;
148
+ });
149
+ }
150
+ /**
151
+ * Retrieves all health groups (linked spot & perp products) from the engine
152
+ */
153
+ async getHealthGroups() {
154
+ const baseResponse = await this.query("health_groups", {});
155
+ return {
156
+ healthGroups: baseResponse.health_groups.map(
157
+ ([spotProductId, perpProductId]) => {
158
+ return {
159
+ spotProductId,
160
+ perpProductId
161
+ };
162
+ }
163
+ )
164
+ };
165
+ }
166
+ /**
167
+ * Retrieves min deposit rates for all spot products from the engine
168
+ */
169
+ async getMinDepositRates() {
170
+ const baseResponse = await this.query("min_deposit_rates", {});
171
+ return {
172
+ minDepositRates: mapValues(baseResponse.min_deposit_rates, (m) => {
173
+ return {
174
+ productId: m.product_id,
175
+ minDepositRate: removeDecimals(m.min_deposit_rate_x18)
176
+ };
177
+ })
178
+ };
179
+ }
180
+ /**
181
+ * Retrieves an order from the offchain engine
182
+ *
183
+ * @param params
184
+ */
185
+ async getOrder(params) {
186
+ const baseResponse = await this.query("order", {
187
+ digest: params.digest,
188
+ product_id: params.productId
189
+ });
190
+ return mapEngineServerOrder(baseResponse);
191
+ }
192
+ /**
193
+ * Signs and validates with the engine that the order is valid to be submitted (i.e. does not violate health reqs)
194
+ *
195
+ * @param params
196
+ */
197
+ async validateOrderParams(params) {
198
+ const signedOrder = {
199
+ order: params.order,
200
+ signature: await this.sign(
201
+ "place_order",
202
+ params.orderbookAddr,
203
+ params.chainId,
204
+ params.order
205
+ )
206
+ };
207
+ return this.validateSignedOrderParams({
208
+ signedOrder,
209
+ productId: params.productId
210
+ });
211
+ }
212
+ /**
213
+ * Validates an existing signed order with the engine as a pre-check for health
214
+ *
215
+ * @param params
216
+ */
217
+ async validateSignedOrderParams(params) {
218
+ const baseResponse = await this.query("validate_order", {
219
+ product_id: params.productId,
220
+ order: encodeSignedOrder(params.signedOrder)
221
+ });
222
+ return {
223
+ productId: baseResponse.product_id,
224
+ valid: baseResponse.valid
225
+ };
226
+ }
227
+ /**
228
+ * Get all subaccount orders from the engine, per product ID
229
+ * @param params
230
+ */
231
+ async getSubaccountOrders(params) {
232
+ const baseResponse = await this.query("subaccount_orders", {
233
+ sender: subaccountToHex({
234
+ subaccountOwner: params.subaccountOwner,
235
+ subaccountName: params.subaccountName
236
+ }),
237
+ product_id: params.productId
238
+ });
239
+ return {
240
+ orders: baseResponse.orders.map(mapEngineServerOrder),
241
+ productId: params.productId
242
+ };
243
+ }
244
+ /**
245
+ * Get all subaccount orders from the engine, for multiple products
246
+ * @param params
247
+ */
248
+ async getSubaccountMultiProductOrders(params) {
249
+ const baseResponse = await this.query("orders", {
250
+ sender: subaccountToHex({
251
+ subaccountOwner: params.subaccountOwner,
252
+ subaccountName: params.subaccountName
253
+ }),
254
+ product_ids: params.productIds
255
+ });
256
+ return {
257
+ productOrders: baseResponse.product_orders.map((orders) => {
258
+ return {
259
+ orders: orders.orders.map(mapEngineServerOrder),
260
+ productId: orders.product_id
261
+ };
262
+ })
263
+ };
264
+ }
265
+ /**
266
+ * Gets maker & taker fee rates for order fees
267
+ * @param params
268
+ */
269
+ async getSubaccountFeeRates(params) {
270
+ const baseResponse = await this.query("fee_rates", {
271
+ sender: subaccountToHex({
272
+ subaccountOwner: params.subaccountOwner,
273
+ subaccountName: params.subaccountName
274
+ })
275
+ });
276
+ return {
277
+ healthCheckSequencerFee: toBigDecimal(
278
+ baseResponse.health_check_sequencer_fee
279
+ ),
280
+ liquidationSequencerFee: toBigDecimal(
281
+ baseResponse.liquidation_sequencer_fee
282
+ ),
283
+ takerSequencerFee: toBigDecimal(baseResponse.taker_sequencer_fee),
284
+ orders: baseResponse.taker_fee_rates_x18.reduce(
285
+ (acc, takerRateX18, currIndex) => {
286
+ acc[currIndex] = {
287
+ taker: removeDecimals(takerRateX18),
288
+ maker: removeDecimals(baseResponse.maker_fee_rates_x18[currIndex])
289
+ };
290
+ return acc;
291
+ },
292
+ {}
293
+ ),
294
+ withdrawal: baseResponse.withdraw_sequencer_fees.reduce(
295
+ (acc, productFee, currIndex) => {
296
+ acc[currIndex] = toBigDecimal(productFee);
297
+ return acc;
298
+ },
299
+ {}
300
+ )
301
+ };
302
+ }
303
+ /**
304
+ * Gets "price ticks" for a given market, useful for constructing liquidity levels at each price
305
+ * @param params
306
+ */
307
+ async getMarketLiquidity(params) {
308
+ const baseResponse = await this.query("market_liquidity", {
309
+ product_id: params.productId,
310
+ depth: params.depth
311
+ });
312
+ return {
313
+ asks: baseResponse.asks.map(mapEngineServerTickLiquidity),
314
+ bids: baseResponse.bids.map(mapEngineServerTickLiquidity)
315
+ };
316
+ }
317
+ /**
318
+ * Retrieves the latest price for a given market
319
+ * @param params
320
+ */
321
+ async getMarketPrice(params) {
322
+ const baseResponse = await this.query("market_price", {
323
+ product_id: params.productId
324
+ });
325
+ return mapEngineMarketPrice(baseResponse);
326
+ }
327
+ /**
328
+ * Retrieves the latest prices for provided markets
329
+ * @param params
330
+ */
331
+ async getMarketPrices(params) {
332
+ const baseResponse = await this.query("market_prices", {
333
+ product_ids: params.productIds
334
+ });
335
+ return {
336
+ marketPrices: baseResponse.market_prices.map(mapEngineMarketPrice)
337
+ };
338
+ }
339
+ /**
340
+ * Retrieves the estimated max order size for a product
341
+ * @param params
342
+ */
343
+ async getMaxOrderSize(params) {
344
+ const baseResponse = await this.query("max_order_size", {
345
+ direction: params.side,
346
+ price_x18: toIntegerString(addDecimals(params.price)),
347
+ product_id: params.productId,
348
+ sender: subaccountToHex({
349
+ subaccountOwner: params.subaccountOwner,
350
+ subaccountName: params.subaccountName
351
+ }),
352
+ spot_leverage: params.spotLeverage != null ? String(params.spotLeverage) : null,
353
+ reduce_only: params.reduceOnly != null ? String(params.reduceOnly) : null
354
+ });
355
+ return toBigDecimal(baseResponse.max_order_size);
356
+ }
357
+ /**
358
+ * Retrieves the estimated max withdrawal size for a product
359
+ * @param params
360
+ */
361
+ async getMaxWithdrawable(params) {
362
+ const baseResponse = await this.query("max_withdrawable", {
363
+ product_id: params.productId,
364
+ sender: subaccountToHex({
365
+ subaccountOwner: params.subaccountOwner,
366
+ subaccountName: params.subaccountName
367
+ }),
368
+ spot_leverage: params.spotLeverage != null ? String(params.spotLeverage) : null
369
+ });
370
+ return toBigDecimal(baseResponse.max_withdrawable);
371
+ }
372
+ /**
373
+ * Retrieves the estimated max quote amount for minting VLP.
374
+ *
375
+ * @param params
376
+ */
377
+ async getMaxMintVlpAmount(params) {
378
+ const baseResponse = await this.query("max_vlp_mintable", {
379
+ sender: subaccountToHex({
380
+ subaccountOwner: params.subaccountOwner,
381
+ subaccountName: params.subaccountName
382
+ }),
383
+ spot_leverage: params.spotLeverage != null ? String(params.spotLeverage) : null
384
+ });
385
+ return toBigDecimal(baseResponse.max_quote_amount);
386
+ }
387
+ /**
388
+ * Gets the currently linked signer for the subaccount
389
+ * @param params
390
+ * @returns
391
+ */
392
+ async getLinkedSigner(params) {
393
+ const baseResponse = await this.query("linked_signer", {
394
+ subaccount: subaccountToHex({
395
+ subaccountOwner: params.subaccountOwner,
396
+ subaccountName: params.subaccountName
397
+ })
398
+ });
399
+ return {
400
+ signer: baseResponse.linked_signer
401
+ };
402
+ }
403
+ /**
404
+ * Gets the insurance funds in USDC.
405
+ * @returns
406
+ */
407
+ async getInsurance() {
408
+ const baseResponse = await this.query("insurance", {});
409
+ return toBigDecimal(baseResponse.insurance);
410
+ }
411
+ /**
412
+ * Gets the orderbook contract address for a given product
413
+ * @param productId
414
+ * @returns
415
+ */
416
+ async getOrderbookAddress(productId) {
417
+ const contracts = await this.getContracts();
418
+ return contracts.orderbookAddrs[productId];
419
+ }
420
+ };
421
+ export {
422
+ EngineQueryClient
423
+ };
424
+ //# sourceMappingURL=EngineQueryClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/EngineQueryClient.ts"],"sourcesContent":["import {\n encodeSignedOrder,\n MarketWithProduct,\n subaccountToHex,\n} from '@nadohq/contracts';\nimport {\n addDecimals,\n BigDecimal,\n mapValues,\n removeDecimals,\n toBigDecimal,\n toIntegerString,\n} from '@nadohq/utils';\nimport { EngineBaseClient } from './EngineBaseClient';\nimport {\n EngineServerStatusResponse,\n EngineServerSubaccountInfoQueryParams,\n EngineSymbolsResponse,\n GetEngineAllMarketsResponse,\n GetEngineContractsResponse,\n GetEngineEstimatedSubaccountSummaryParams,\n GetEngineHealthGroupsResponse,\n GetEngineInsuranceResponse,\n GetEngineIsolatedPositionsParams,\n GetEngineIsolatedPositionsResponse,\n GetEngineLinkedSignerParams,\n GetEngineLinkedSignerResponse,\n GetEngineMarketLiquidityParams,\n GetEngineMarketLiquidityResponse,\n GetEngineMarketPriceParams,\n GetEngineMarketPriceResponse,\n GetEngineMarketPricesParams,\n GetEngineMarketPricesResponse,\n GetEngineMaxMintVlpAmountParams,\n GetEngineMaxMintVlpAmountResponse,\n GetEngineMaxOrderSizeParams,\n GetEngineMaxOrderSizeResponse,\n GetEngineMaxWithdrawableParams,\n GetEngineMaxWithdrawableResponse,\n GetEngineMinDepositRatesResponse,\n GetEngineOrderParams,\n GetEngineOrderResponse,\n GetEngineSubaccountFeeRatesParams,\n GetEngineSubaccountFeeRatesResponse,\n GetEngineSubaccountOrdersParams,\n GetEngineSubaccountOrdersResponse,\n GetEngineSubaccountProductOrdersParams,\n GetEngineSubaccountProductOrdersResponse,\n GetEngineSubaccountSummaryParams,\n GetEngineSubaccountSummaryResponse,\n GetEngineSymbolsParams,\n SubaccountOrderFeeRates,\n ValidateEngineOrderParams,\n ValidateEngineOrderResponse,\n ValidateSignedEngineOrderParams,\n} from './types';\nimport { mapProductEngineType } from './utils/productEngineTypeMappers';\nimport {\n mapEngineMarketPrice,\n mapEngineServerIsolatedPositions,\n mapEngineServerOrder,\n mapEngineServerPerpProduct,\n mapEngineServerSpotProduct,\n mapEngineServerSymbols,\n mapEngineServerTickLiquidity,\n mapSubaccountSummary,\n} from './utils/queryDataMappers';\n\nexport class EngineQueryClient extends EngineBaseClient {\n /**\n * Retrieves the set of contracts that the engine is interfacing with\n */\n async getContracts(): Promise<GetEngineContractsResponse> {\n const baseResponse = await this.query('contracts', {});\n return {\n chainId: Number(baseResponse.chain_id),\n endpointAddr: baseResponse.endpoint_addr,\n orderbookAddrs: baseResponse.book_addrs,\n };\n }\n\n /**\n * Retrieves current engine status\n */\n async getStatus(): Promise<EngineServerStatusResponse> {\n return this.query('status', {});\n }\n\n /**\n * Retrieves a subaccount summary reflective of the state within the offchain engine. This adheres to the\n * same return interface as the contract version\n *\n * @param params\n */\n async getSubaccountSummary(\n params: GetEngineSubaccountSummaryParams,\n ): Promise<GetEngineSubaccountSummaryResponse> {\n const subaccount = subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n });\n const baseResponse = await this.query('subaccount_info', {\n subaccount,\n });\n\n return mapSubaccountSummary(baseResponse);\n }\n\n /**\n * Retrieves a list of isolated positions\n *\n * @param params\n */\n async getIsolatedPositions(\n params: GetEngineIsolatedPositionsParams,\n ): Promise<GetEngineIsolatedPositionsResponse> {\n const subaccount = subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n });\n const baseResponse = await this.query('isolated_positions', {\n subaccount,\n });\n\n return mapEngineServerIsolatedPositions(baseResponse);\n }\n\n /**\n * Retrieves an estimated subaccount summary with the applied transactions\n *\n * @param params\n */\n async getEstimatedSubaccountSummary(\n params: GetEngineEstimatedSubaccountSummaryParams,\n ): Promise<GetEngineSubaccountSummaryResponse> {\n const subaccount = subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n });\n const queryParams: EngineServerSubaccountInfoQueryParams = {\n subaccount: subaccount,\n txns: params.txs.map(\n (\n tx,\n ): NonNullable<\n EngineServerSubaccountInfoQueryParams['txns']\n >[number] => {\n switch (tx.type) {\n case 'apply_delta':\n return {\n apply_delta: {\n product_id: tx.tx.productId,\n subaccount,\n amount_delta: toIntegerString(tx.tx.amountDelta),\n v_quote_delta: toIntegerString(tx.tx.vQuoteDelta),\n },\n };\n }\n },\n ),\n };\n const baseResponse = await this.query('subaccount_info', {\n subaccount: queryParams.subaccount,\n txns: JSON.stringify(queryParams.txns),\n });\n\n return mapSubaccountSummary(baseResponse);\n }\n\n /**\n * Retrieves symbols and product info\n *\n * @param params\n */\n async getSymbols(\n params: GetEngineSymbolsParams,\n ): Promise<EngineSymbolsResponse> {\n const baseResponse = await this.query('symbols', {\n product_ids: params.productIds,\n product_type:\n params.productType != null\n ? mapProductEngineType(params.productType)\n : undefined,\n });\n return mapEngineServerSymbols(baseResponse);\n }\n\n /**\n * Retrieves all market states as per the offchain engine. Same return interface as contracts\n */\n async getAllMarkets(): Promise<GetEngineAllMarketsResponse> {\n const markets: MarketWithProduct[] = [];\n\n const baseResponse = await this.query('all_products', {});\n baseResponse.spot_products.forEach((spotProduct) => {\n markets.push(mapEngineServerSpotProduct(spotProduct));\n });\n baseResponse.perp_products.forEach((perpProduct) => {\n markets.push(mapEngineServerPerpProduct(perpProduct));\n });\n\n return markets;\n }\n\n /**\n * Retrieves all markets by chain id.\n */\n async getEdgeAllMarkets(): Promise<Record<number, MarketWithProduct[]>> {\n const baseResponse = await this.query('edge_all_products', {});\n\n return mapValues(baseResponse.edge_all_products, (allProducts) => {\n const markets: MarketWithProduct[] = [];\n\n allProducts.spot_products.forEach((spotProduct) => {\n markets.push(mapEngineServerSpotProduct(spotProduct));\n });\n\n allProducts.perp_products.forEach((perpProduct) => {\n markets.push(mapEngineServerPerpProduct(perpProduct));\n });\n\n return markets;\n });\n }\n\n /**\n * Retrieves all health groups (linked spot & perp products) from the engine\n */\n async getHealthGroups(): Promise<GetEngineHealthGroupsResponse> {\n const baseResponse = await this.query('health_groups', {});\n\n return {\n healthGroups: baseResponse.health_groups.map(\n ([spotProductId, perpProductId]) => {\n return {\n spotProductId,\n perpProductId,\n };\n },\n ),\n };\n }\n\n /**\n * Retrieves min deposit rates for all spot products from the engine\n */\n async getMinDepositRates(): Promise<GetEngineMinDepositRatesResponse> {\n const baseResponse = await this.query('min_deposit_rates', {});\n\n return {\n minDepositRates: mapValues(baseResponse.min_deposit_rates, (m) => {\n return {\n productId: m.product_id,\n minDepositRate: removeDecimals(m.min_deposit_rate_x18),\n };\n }),\n };\n }\n\n /**\n * Retrieves an order from the offchain engine\n *\n * @param params\n */\n async getOrder(\n params: GetEngineOrderParams,\n ): Promise<GetEngineOrderResponse> {\n const baseResponse = await this.query('order', {\n digest: params.digest,\n product_id: params.productId,\n });\n\n return mapEngineServerOrder(baseResponse);\n }\n\n /**\n * Signs and validates with the engine that the order is valid to be submitted (i.e. does not violate health reqs)\n *\n * @param params\n */\n async validateOrderParams(\n params: ValidateEngineOrderParams,\n ): Promise<ValidateEngineOrderResponse> {\n const signedOrder = {\n order: params.order,\n signature: await this.sign(\n 'place_order',\n params.orderbookAddr,\n params.chainId,\n params.order,\n ),\n };\n return this.validateSignedOrderParams({\n signedOrder,\n productId: params.productId,\n });\n }\n\n /**\n * Validates an existing signed order with the engine as a pre-check for health\n *\n * @param params\n */\n async validateSignedOrderParams(\n params: ValidateSignedEngineOrderParams,\n ): Promise<ValidateEngineOrderResponse> {\n const baseResponse = await this.query('validate_order', {\n product_id: params.productId,\n order: encodeSignedOrder(params.signedOrder),\n });\n\n return {\n productId: baseResponse.product_id,\n valid: baseResponse.valid,\n };\n }\n\n /**\n * Get all subaccount orders from the engine, per product ID\n * @param params\n */\n async getSubaccountOrders(\n params: GetEngineSubaccountOrdersParams,\n ): Promise<GetEngineSubaccountOrdersResponse> {\n const baseResponse = await this.query('subaccount_orders', {\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n product_id: params.productId,\n });\n\n return {\n orders: baseResponse.orders.map(mapEngineServerOrder),\n productId: params.productId,\n };\n }\n\n /**\n * Get all subaccount orders from the engine, for multiple products\n * @param params\n */\n async getSubaccountMultiProductOrders(\n params: GetEngineSubaccountProductOrdersParams,\n ): Promise<GetEngineSubaccountProductOrdersResponse> {\n const baseResponse = await this.query('orders', {\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n product_ids: params.productIds,\n });\n\n return {\n productOrders: baseResponse.product_orders.map((orders) => {\n return {\n orders: orders.orders.map(mapEngineServerOrder),\n productId: orders.product_id,\n };\n }),\n };\n }\n\n /**\n * Gets maker & taker fee rates for order fees\n * @param params\n */\n async getSubaccountFeeRates(\n params: GetEngineSubaccountFeeRatesParams,\n ): Promise<GetEngineSubaccountFeeRatesResponse> {\n const baseResponse = await this.query('fee_rates', {\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n });\n\n return {\n healthCheckSequencerFee: toBigDecimal(\n baseResponse.health_check_sequencer_fee,\n ),\n liquidationSequencerFee: toBigDecimal(\n baseResponse.liquidation_sequencer_fee,\n ),\n takerSequencerFee: toBigDecimal(baseResponse.taker_sequencer_fee),\n orders: baseResponse.taker_fee_rates_x18.reduce(\n (acc, takerRateX18, currIndex) => {\n acc[currIndex] = {\n taker: removeDecimals(takerRateX18),\n maker: removeDecimals(baseResponse.maker_fee_rates_x18[currIndex]),\n };\n return acc;\n },\n {} as Record<number, SubaccountOrderFeeRates>,\n ),\n withdrawal: baseResponse.withdraw_sequencer_fees.reduce(\n (acc, productFee, currIndex) => {\n acc[currIndex] = toBigDecimal(productFee);\n return acc;\n },\n {} as Record<number, BigDecimal>,\n ),\n };\n }\n\n /**\n * Gets \"price ticks\" for a given market, useful for constructing liquidity levels at each price\n * @param params\n */\n async getMarketLiquidity(\n params: GetEngineMarketLiquidityParams,\n ): Promise<GetEngineMarketLiquidityResponse> {\n const baseResponse = await this.query('market_liquidity', {\n product_id: params.productId,\n depth: params.depth,\n });\n return {\n asks: baseResponse.asks.map(mapEngineServerTickLiquidity),\n bids: baseResponse.bids.map(mapEngineServerTickLiquidity),\n };\n }\n\n /**\n * Retrieves the latest price for a given market\n * @param params\n */\n async getMarketPrice(\n params: GetEngineMarketPriceParams,\n ): Promise<GetEngineMarketPriceResponse> {\n const baseResponse = await this.query('market_price', {\n product_id: params.productId,\n });\n return mapEngineMarketPrice(baseResponse);\n }\n\n /**\n * Retrieves the latest prices for provided markets\n * @param params\n */\n async getMarketPrices(\n params: GetEngineMarketPricesParams,\n ): Promise<GetEngineMarketPricesResponse> {\n const baseResponse = await this.query('market_prices', {\n product_ids: params.productIds,\n });\n return {\n marketPrices: baseResponse.market_prices.map(mapEngineMarketPrice),\n };\n }\n\n /**\n * Retrieves the estimated max order size for a product\n * @param params\n */\n async getMaxOrderSize(\n params: GetEngineMaxOrderSizeParams,\n ): Promise<GetEngineMaxOrderSizeResponse> {\n const baseResponse = await this.query('max_order_size', {\n direction: params.side,\n price_x18: toIntegerString(addDecimals(params.price)),\n product_id: params.productId,\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n spot_leverage:\n params.spotLeverage != null ? String(params.spotLeverage) : null,\n reduce_only: params.reduceOnly != null ? String(params.reduceOnly) : null,\n });\n\n return toBigDecimal(baseResponse.max_order_size);\n }\n\n /**\n * Retrieves the estimated max withdrawal size for a product\n * @param params\n */\n async getMaxWithdrawable(\n params: GetEngineMaxWithdrawableParams,\n ): Promise<GetEngineMaxWithdrawableResponse> {\n const baseResponse = await this.query('max_withdrawable', {\n product_id: params.productId,\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n spot_leverage:\n params.spotLeverage != null ? String(params.spotLeverage) : null,\n });\n\n return toBigDecimal(baseResponse.max_withdrawable);\n }\n\n /**\n * Retrieves the estimated max quote amount for minting VLP.\n *\n * @param params\n */\n async getMaxMintVlpAmount(\n params: GetEngineMaxMintVlpAmountParams,\n ): Promise<GetEngineMaxMintVlpAmountResponse> {\n const baseResponse = await this.query('max_vlp_mintable', {\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n spot_leverage:\n params.spotLeverage != null ? String(params.spotLeverage) : null,\n });\n\n return toBigDecimal(baseResponse.max_quote_amount);\n }\n\n /**\n * Gets the currently linked signer for the subaccount\n * @param params\n * @returns\n */\n public async getLinkedSigner(\n params: GetEngineLinkedSignerParams,\n ): Promise<GetEngineLinkedSignerResponse> {\n const baseResponse = await this.query('linked_signer', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n });\n\n return {\n signer: baseResponse.linked_signer,\n };\n }\n\n /**\n * Gets the insurance funds in USDC.\n * @returns\n */\n public async getInsurance(): Promise<GetEngineInsuranceResponse> {\n const baseResponse = await this.query('insurance', {});\n\n return toBigDecimal(baseResponse.insurance);\n }\n\n /**\n * Gets the orderbook contract address for a given product\n * @param productId\n * @returns\n */\n public async getOrderbookAddress(productId: number): Promise<string> {\n const contracts = await this.getContracts();\n return contracts.orderbookAddrs[productId];\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AA2CjC,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,IAAM,oBAAN,cAAgC,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAItD,MAAM,eAAoD;AACxD,UAAM,eAAe,MAAM,KAAK,MAAM,aAAa,CAAC,CAAC;AACrD,WAAO;AAAA,MACL,SAAS,OAAO,aAAa,QAAQ;AAAA,MACrC,cAAc,aAAa;AAAA,MAC3B,gBAAgB,aAAa;AAAA,IAC/B;AAAA,EACF;AAAA;AAAA;AAAA;AAA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