@nadohq/engine-client 0.15.0 → 0.18.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 (187) hide show
  1. package/dist/EngineBaseClient-DOOXIhnZ.d.ts +75 -0
  2. package/dist/EngineBaseClient-DOOXIhnZ.d.ts.map +1 -0
  3. package/dist/EngineBaseClient-L1ue7jBx.d.cts +75 -0
  4. package/dist/EngineBaseClient-L1ue7jBx.d.cts.map +1 -0
  5. package/dist/EngineBaseClient-Uc1D8ftx.cjs +150 -0
  6. package/dist/EngineBaseClient-Uc1D8ftx.cjs.map +1 -0
  7. package/dist/EngineBaseClient.cjs +3 -167
  8. package/dist/EngineBaseClient.d.cts +2 -75
  9. package/dist/EngineBaseClient.d.ts +2 -75
  10. package/dist/EngineBaseClient.js +112 -131
  11. package/dist/EngineBaseClient.js.map +1 -1
  12. package/dist/EngineClient.cjs +13 -38
  13. package/dist/EngineClient.cjs.map +1 -1
  14. package/dist/EngineClient.d.cts +8 -18
  15. package/dist/EngineClient.d.cts.map +1 -0
  16. package/dist/EngineClient.d.ts +8 -18
  17. package/dist/EngineClient.d.ts.map +1 -0
  18. package/dist/EngineClient.js +9 -11
  19. package/dist/EngineClient.js.map +1 -1
  20. package/dist/EngineExecuteBuilder-VLrEndhv.d.cts +105 -0
  21. package/dist/EngineExecuteBuilder-VLrEndhv.d.cts.map +1 -0
  22. package/dist/EngineExecuteBuilder-t8EQ5Rmp.d.ts +105 -0
  23. package/dist/EngineExecuteBuilder-t8EQ5Rmp.d.ts.map +1 -0
  24. package/dist/EngineExecuteBuilder.cjs +232 -277
  25. package/dist/EngineExecuteBuilder.cjs.map +1 -1
  26. package/dist/EngineExecuteBuilder.d.cts +2 -108
  27. package/dist/EngineExecuteBuilder.d.ts +2 -108
  28. package/dist/EngineExecuteBuilder.js +230 -256
  29. package/dist/EngineExecuteBuilder.js.map +1 -1
  30. package/dist/EngineExecuteClient-0EBoXRd7.d.ts +24 -0
  31. package/dist/EngineExecuteClient-0EBoXRd7.d.ts.map +1 -0
  32. package/dist/EngineExecuteClient-BGlNK5Le.d.cts +24 -0
  33. package/dist/EngineExecuteClient-BGlNK5Le.d.cts.map +1 -0
  34. package/dist/EngineExecuteClient.cjs +57 -110
  35. package/dist/EngineExecuteClient.cjs.map +1 -1
  36. package/dist/EngineExecuteClient.d.cts +2 -28
  37. package/dist/EngineExecuteClient.d.ts +2 -28
  38. package/dist/EngineExecuteClient.js +54 -83
  39. package/dist/EngineExecuteClient.js.map +1 -1
  40. package/dist/EngineQueryClient-C_7p1oRx.d.cts +147 -0
  41. package/dist/EngineQueryClient-C_7p1oRx.d.cts.map +1 -0
  42. package/dist/EngineQueryClient-DQwCRaYl.d.ts +147 -0
  43. package/dist/EngineQueryClient-DQwCRaYl.d.ts.map +1 -0
  44. package/dist/EngineQueryClient.cjs +354 -448
  45. package/dist/EngineQueryClient.cjs.map +1 -1
  46. package/dist/EngineQueryClient.d.cts +2 -149
  47. package/dist/EngineQueryClient.d.ts +2 -149
  48. package/dist/EngineQueryClient.js +351 -441
  49. package/dist/EngineQueryClient.js.map +1 -1
  50. package/dist/EngineServerFailureError-CDabRrF4.d.ts +11 -0
  51. package/dist/EngineServerFailureError-CDabRrF4.d.ts.map +1 -0
  52. package/dist/EngineServerFailureError-DpPY0--L.d.cts +11 -0
  53. package/dist/EngineServerFailureError-DpPY0--L.d.cts.map +1 -0
  54. package/dist/EngineWebClient-CEwqgd4t.d.ts +35 -0
  55. package/dist/EngineWebClient-CEwqgd4t.d.ts.map +1 -0
  56. package/dist/EngineWebClient-DajZqKAQ.d.cts +35 -0
  57. package/dist/EngineWebClient-DajZqKAQ.d.cts.map +1 -0
  58. package/dist/EngineWebClient.cjs +49 -86
  59. package/dist/EngineWebClient.cjs.map +1 -1
  60. package/dist/EngineWebClient.d.cts +2 -39
  61. package/dist/EngineWebClient.d.ts +2 -39
  62. package/dist/EngineWebClient.js +47 -60
  63. package/dist/EngineWebClient.js.map +1 -1
  64. package/dist/clientExecuteTypes-BlJOgCL_.d.cts +91 -0
  65. package/dist/clientExecuteTypes-BlJOgCL_.d.cts.map +1 -0
  66. package/dist/clientExecuteTypes-CJ08_c4q.d.ts +91 -0
  67. package/dist/clientExecuteTypes-CJ08_c4q.d.ts.map +1 -0
  68. package/dist/clientQueryTypes-DlTtS_mX.d.cts +221 -0
  69. package/dist/clientQueryTypes-DlTtS_mX.d.cts.map +1 -0
  70. package/dist/clientQueryTypes-DuRgEeBT.d.ts +221 -0
  71. package/dist/clientQueryTypes-DuRgEeBT.d.ts.map +1 -0
  72. package/dist/endpoints.cjs +19 -45
  73. package/dist/endpoints.cjs.map +1 -1
  74. package/dist/endpoints.d.cts +4 -2
  75. package/dist/endpoints.d.cts.map +1 -0
  76. package/dist/endpoints.d.ts +4 -2
  77. package/dist/endpoints.d.ts.map +1 -0
  78. package/dist/endpoints.js +16 -18
  79. package/dist/endpoints.js.map +1 -1
  80. package/dist/index-CmCelmEL.d.cts +1 -0
  81. package/dist/index-D0E78WnU.d.ts +1 -0
  82. package/dist/index.cjs +26 -31
  83. package/dist/index.d.cts +12 -20
  84. package/dist/index.d.ts +12 -20
  85. package/dist/index.js +8 -6
  86. package/dist/queryDataMappers-BguxA579.d.ts +21 -0
  87. package/dist/queryDataMappers-BguxA579.d.ts.map +1 -0
  88. package/dist/queryDataMappers-DO9yWdLo.d.cts +21 -0
  89. package/dist/queryDataMappers-DO9yWdLo.d.cts.map +1 -0
  90. package/dist/serverExecuteTypes-CgbHjnWM.d.ts +92 -0
  91. package/dist/serverExecuteTypes-CgbHjnWM.d.ts.map +1 -0
  92. package/dist/serverExecuteTypes-DejTR8Is.d.cts +92 -0
  93. package/dist/serverExecuteTypes-DejTR8Is.d.cts.map +1 -0
  94. package/dist/serverQueryModelTypes-85xnbU-a.d.cts +98 -0
  95. package/dist/serverQueryModelTypes-85xnbU-a.d.cts.map +1 -0
  96. package/dist/serverQueryModelTypes-CENoy5Hm.d.ts +98 -0
  97. package/dist/serverQueryModelTypes-CENoy5Hm.d.ts.map +1 -0
  98. package/dist/serverQueryTypes-B3vC8vxT.d.ts +301 -0
  99. package/dist/serverQueryTypes-B3vC8vxT.d.ts.map +1 -0
  100. package/dist/serverQueryTypes-Dva9R2tV.d.cts +301 -0
  101. package/dist/serverQueryTypes-Dva9R2tV.d.cts.map +1 -0
  102. package/dist/serverSubscriptionEventTypes-BMUrTkTg.d.cts +135 -0
  103. package/dist/serverSubscriptionEventTypes-BMUrTkTg.d.cts.map +1 -0
  104. package/dist/serverSubscriptionEventTypes-UCYAjmt7.d.ts +135 -0
  105. package/dist/serverSubscriptionEventTypes-UCYAjmt7.d.ts.map +1 -0
  106. package/dist/serverSubscriptionTypes-BSuYa6z_.d.cts +82 -0
  107. package/dist/serverSubscriptionTypes-BSuYa6z_.d.cts.map +1 -0
  108. package/dist/serverSubscriptionTypes-DoMWeKgY.d.ts +82 -0
  109. package/dist/serverSubscriptionTypes-DoMWeKgY.d.ts.map +1 -0
  110. package/dist/types/EngineServerFailureError.cjs +9 -33
  111. package/dist/types/EngineServerFailureError.cjs.map +1 -1
  112. package/dist/types/EngineServerFailureError.d.cts +2 -11
  113. package/dist/types/EngineServerFailureError.d.ts +2 -11
  114. package/dist/types/EngineServerFailureError.js +8 -8
  115. package/dist/types/EngineServerFailureError.js.map +1 -1
  116. package/dist/types/clientExecuteTypes.cjs +0 -19
  117. package/dist/types/clientExecuteTypes.d.cts +2 -91
  118. package/dist/types/clientExecuteTypes.d.ts +2 -91
  119. package/dist/types/clientExecuteTypes.js +1 -1
  120. package/dist/types/clientQueryTypes.cjs +0 -19
  121. package/dist/types/clientQueryTypes.d.cts +2 -220
  122. package/dist/types/clientQueryTypes.d.ts +2 -220
  123. package/dist/types/clientQueryTypes.js +1 -1
  124. package/dist/types/index.cjs +5 -39
  125. package/dist/types/index.d.cts +9 -10
  126. package/dist/types/index.d.ts +9 -10
  127. package/dist/types/index.js +3 -10
  128. package/dist/types/serverExecuteTypes.cjs +0 -19
  129. package/dist/types/serverExecuteTypes.d.cts +2 -93
  130. package/dist/types/serverExecuteTypes.d.ts +2 -93
  131. package/dist/types/serverExecuteTypes.js +1 -1
  132. package/dist/types/serverQueryModelTypes.cjs +0 -19
  133. package/dist/types/serverQueryModelTypes.d.cts +2 -96
  134. package/dist/types/serverQueryModelTypes.d.ts +2 -96
  135. package/dist/types/serverQueryModelTypes.js +1 -1
  136. package/dist/types/serverQueryTypes.cjs +12 -36
  137. package/dist/types/serverQueryTypes.cjs.map +1 -1
  138. package/dist/types/serverQueryTypes.d.cts +2 -310
  139. package/dist/types/serverQueryTypes.d.ts +2 -310
  140. package/dist/types/serverQueryTypes.js +11 -11
  141. package/dist/types/serverQueryTypes.js.map +1 -1
  142. package/dist/types/serverSubscriptionEventTypes.cjs +0 -19
  143. package/dist/types/serverSubscriptionEventTypes.d.cts +2 -135
  144. package/dist/types/serverSubscriptionEventTypes.d.ts +2 -135
  145. package/dist/types/serverSubscriptionEventTypes.js +1 -1
  146. package/dist/types/serverSubscriptionTypes.cjs +0 -19
  147. package/dist/types/serverSubscriptionTypes.d.cts +2 -80
  148. package/dist/types/serverSubscriptionTypes.d.ts +2 -80
  149. package/dist/types/serverSubscriptionTypes.js +1 -1
  150. package/dist/utils/index.cjs +14 -25
  151. package/dist/utils/index.d.cts +2 -6
  152. package/dist/utils/index.d.ts +2 -6
  153. package/dist/utils/index.js +2 -3
  154. package/dist/utils/productEngineTypeMappers.cjs +16 -44
  155. package/dist/utils/productEngineTypeMappers.cjs.map +1 -1
  156. package/dist/utils/productEngineTypeMappers.d.cts +5 -3
  157. package/dist/utils/productEngineTypeMappers.d.cts.map +1 -0
  158. package/dist/utils/productEngineTypeMappers.d.ts +5 -3
  159. package/dist/utils/productEngineTypeMappers.d.ts.map +1 -0
  160. package/dist/utils/productEngineTypeMappers.js +12 -17
  161. package/dist/utils/productEngineTypeMappers.js.map +1 -1
  162. package/dist/utils/queryDataMappers.cjs +204 -292
  163. package/dist/utils/queryDataMappers.cjs.map +1 -1
  164. package/dist/utils/queryDataMappers.d.cts +2 -20
  165. package/dist/utils/queryDataMappers.d.ts +2 -20
  166. package/dist/utils/queryDataMappers.js +190 -264
  167. package/dist/utils/queryDataMappers.js.map +1 -1
  168. package/package.json +9 -9
  169. package/dist/EngineBaseClient.cjs.map +0 -1
  170. package/dist/index.cjs.map +0 -1
  171. package/dist/index.js.map +0 -1
  172. package/dist/types/clientExecuteTypes.cjs.map +0 -1
  173. package/dist/types/clientExecuteTypes.js.map +0 -1
  174. package/dist/types/clientQueryTypes.cjs.map +0 -1
  175. package/dist/types/clientQueryTypes.js.map +0 -1
  176. package/dist/types/index.cjs.map +0 -1
  177. package/dist/types/index.js.map +0 -1
  178. package/dist/types/serverExecuteTypes.cjs.map +0 -1
  179. package/dist/types/serverExecuteTypes.js.map +0 -1
  180. package/dist/types/serverQueryModelTypes.cjs.map +0 -1
  181. package/dist/types/serverQueryModelTypes.js.map +0 -1
  182. package/dist/types/serverSubscriptionEventTypes.cjs.map +0 -1
  183. package/dist/types/serverSubscriptionEventTypes.js.map +0 -1
  184. package/dist/types/serverSubscriptionTypes.cjs.map +0 -1
  185. package/dist/types/serverSubscriptionTypes.js.map +0 -1
  186. package/dist/utils/index.cjs.map +0 -1
  187. package/dist/utils/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/EngineQueryClient.ts"],"sourcesContent":["import {\n addDecimals,\n encodeSignedOrder,\n getOrderVerifyingAddress,\n mapValues,\n MarketWithProduct,\n removeDecimals,\n subaccountToHex,\n toBigNumber,\n toIntegerString,\n} from '@nadohq/shared';\nimport BigNumber from 'bignumber.js';\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 GetEngineMaxBurnNlpAmountParams,\n GetEngineMaxBurnNlpAmountResponse,\n GetEngineMaxMintNlpAmountParams,\n GetEngineMaxMintNlpAmountResponse,\n GetEngineMaxOrderSizeParams,\n GetEngineMaxOrderSizeResponse,\n GetEngineMaxWithdrawableParams,\n GetEngineMaxWithdrawableResponse,\n GetEngineNlpLockedBalancesParams,\n GetEngineNlpLockedBalancesResponse,\n GetEngineNlpPoolInfoResponse,\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 mapEngineServerNlpLockedBalances,\n mapEngineServerNlpPoolInfo,\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 };\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 // Backend expects string variants of booleans\n pre_state:\n params.preState !== undefined ? String(params.preState) : undefined,\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 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 getOrderVerifyingAddress(params.productId),\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: toBigNumber(\n baseResponse.health_check_sequencer_fee,\n ),\n liquidationSequencerFee: toBigNumber(\n baseResponse.liquidation_sequencer_fee,\n ),\n takerSequencerFee: toBigNumber(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] = toBigNumber(productFee);\n return acc;\n },\n {} as Record<number, BigNumber>,\n ),\n feeTier: baseResponse.fee_tier,\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 avg_price_x18:\n params.avgPrice != null\n ? toIntegerString(addDecimals(params.avgPrice))\n : null,\n product_id: params.productId,\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n // Backend expects string variants of booleans\n spot_leverage:\n params.spotLeverage != null ? String(params.spotLeverage) : null,\n reduce_only: params.reduceOnly != null ? String(params.reduceOnly) : null,\n isolated: params.isolated != null ? String(params.isolated) : null,\n borrow_margin:\n // This field is only relevant for isolated orders\n params.isolated && params.isoBorrowMargin != null\n ? String(params.isoBorrowMargin)\n : null,\n });\n\n return toBigNumber(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 toBigNumber(baseResponse.max_withdrawable);\n }\n\n /**\n * Retrieves the estimated max quote amount for minting NLP.\n *\n * @param params\n */\n async getMaxMintNlpAmount(\n params: GetEngineMaxMintNlpAmountParams,\n ): Promise<GetEngineMaxMintNlpAmountResponse> {\n const baseResponse = await this.query('max_nlp_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 toBigNumber(baseResponse.max_quote_amount);\n }\n\n /**\n * Retrieves the max amount of NLP that can be burned.\n *\n * @param params\n */\n async getMaxBurnNlpAmount(\n params: GetEngineMaxBurnNlpAmountParams,\n ): Promise<GetEngineMaxBurnNlpAmountResponse> {\n const baseResponse = await this.query('max_nlp_burnable', {\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n });\n\n return toBigNumber(baseResponse.max_nlp_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 USDT.\n * @returns\n */\n public async getInsurance(): Promise<GetEngineInsuranceResponse> {\n const baseResponse = await this.query('insurance', {});\n\n return toBigNumber(baseResponse.insurance);\n }\n\n /**\n * Retrieves the NLP locked and unlocked balances for a subaccount.\n *\n * @param params\n */\n async getNlpLockedBalances(\n params: GetEngineNlpLockedBalancesParams,\n ): Promise<GetEngineNlpLockedBalancesResponse> {\n const baseResponse = await this.query('nlp_locked_balances', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n });\n\n return mapEngineServerNlpLockedBalances(baseResponse);\n }\n\n /**\n * Retrieves information about all NLP sub-pools\n */\n async getNlpPoolInfo(): Promise<GetEngineNlpPoolInfoResponse> {\n const baseResponse = await this.query('nlp_pool_info', {});\n return mapEngineServerNlpPoolInfo(baseResponse);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAUO;AAEP,8BAAiC;AA+CjC,sCAAqC;AACrC,8BAWO;AAEA,IAAM,oBAAN,cAAgC,yCAAiB;AAAA;AAAA;AAAA;AAAA,EAItD,MAAM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AAK,MAAM,oBAAoB;AAAA,MACxD,YAAQ,+BAAgB;AAAA,QACtB,iBAAiB,OAAO;AAAA,QACxB,gBAAgB,OAAO;AAAA,MACzB,CAAC;AAAA,IACH,CAAC;AAED,eAAO,2BAAY,aAAa,cAAc;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAa,gBACX,QACwC;AACxC,UAAM,eAAe,MAAM,KAAK,MAAM,iBAAiB;AAAA,MACrD,gBAAY,+BAAgB;AAAA,QAC1B,iBAAiB,OAAO;AAAA,QACxB,gBAAgB,OAAO;AAAA,MACzB,CAAC;AAAA,IACH,CAAC;AAED,WAAO;AAAA,MACL,QAAQ,aAAa;AAAA,IACvB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAa,eAAoD;AAC/D,UAAM,eAAe,MAAM,KAAK,MAAM,aAAa,CAAC,CAAC;AAErD,eAAO,2BAAY,aAAa,SAAS;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,qBACJ,QAC6C;AAC7C,UAAM,eAAe,MAAM,KAAK,MAAM,uBAAuB;AAAA,MAC3D,gBAAY,+BAAgB;AAAA,QAC1B,iBAAiB,OAAO;AAAA,QACxB,gBAAgB,OAAO;AAAA,MACzB,CAAC;AAAA,IACH,CAAC;AAED,eAAO,0DAAiC,YAAY;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,iBAAwD;AAC5D,UAAM,eAAe,MAAM,KAAK,MAAM,iBAAiB,CAAC,CAAC;AACzD,eAAO,oDAA2B,YAAY;AAAA,EAChD;AACF;","names":[]}
1
+ {"version":3,"file":"EngineQueryClient.cjs","names":["EngineBaseClient","mapSubaccountSummary","mapEngineServerIsolatedPositions","mapEngineServerSymbols","mapProductEngineType","mapEngineServerSpotProduct","mapEngineServerPerpProduct","mapEngineServerOrder","mapEngineServerTickLiquidity","mapEngineMarketPrice","mapEngineServerNlpLockedBalances","mapEngineServerNlpPoolInfo"],"sources":["../src/EngineQueryClient.ts"],"sourcesContent":["import {\n addDecimals,\n encodeSignedOrder,\n getOrderVerifyingAddress,\n mapValues,\n MarketWithProduct,\n removeDecimals,\n subaccountToHex,\n toBigNumber,\n toIntegerString,\n} from '@nadohq/shared';\nimport BigNumber from 'bignumber.js';\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 GetEngineMaxBurnNlpAmountParams,\n GetEngineMaxBurnNlpAmountResponse,\n GetEngineMaxMintNlpAmountParams,\n GetEngineMaxMintNlpAmountResponse,\n GetEngineMaxOrderSizeParams,\n GetEngineMaxOrderSizeResponse,\n GetEngineMaxWithdrawableParams,\n GetEngineMaxWithdrawableResponse,\n GetEngineNlpLockedBalancesParams,\n GetEngineNlpLockedBalancesResponse,\n GetEngineNlpPoolInfoResponse,\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 mapEngineServerNlpLockedBalances,\n mapEngineServerNlpPoolInfo,\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 };\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 // Backend expects string variants of booleans\n pre_state:\n params.preState !== undefined ? String(params.preState) : undefined,\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 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 getOrderVerifyingAddress(params.productId),\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: toBigNumber(\n baseResponse.health_check_sequencer_fee,\n ),\n liquidationSequencerFee: toBigNumber(\n baseResponse.liquidation_sequencer_fee,\n ),\n takerSequencerFee: toBigNumber(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] = toBigNumber(productFee);\n return acc;\n },\n {} as Record<number, BigNumber>,\n ),\n feeTier: baseResponse.fee_tier,\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 avg_price_x18:\n params.avgPrice != null\n ? toIntegerString(addDecimals(params.avgPrice))\n : null,\n product_id: params.productId,\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n // Backend expects string variants of booleans\n spot_leverage:\n params.spotLeverage != null ? String(params.spotLeverage) : null,\n reduce_only: params.reduceOnly != null ? String(params.reduceOnly) : null,\n isolated: params.isolated != null ? String(params.isolated) : null,\n borrow_margin:\n // This field is only relevant for isolated orders\n params.isolated && params.isoBorrowMargin != null\n ? String(params.isoBorrowMargin)\n : null,\n });\n\n return toBigNumber(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 toBigNumber(baseResponse.max_withdrawable);\n }\n\n /**\n * Retrieves the estimated max quote amount for minting NLP.\n *\n * @param params\n */\n async getMaxMintNlpAmount(\n params: GetEngineMaxMintNlpAmountParams,\n ): Promise<GetEngineMaxMintNlpAmountResponse> {\n const baseResponse = await this.query('max_nlp_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 toBigNumber(baseResponse.max_quote_amount);\n }\n\n /**\n * Retrieves the max amount of NLP that can be burned.\n *\n * @param params\n */\n async getMaxBurnNlpAmount(\n params: GetEngineMaxBurnNlpAmountParams,\n ): Promise<GetEngineMaxBurnNlpAmountResponse> {\n const baseResponse = await this.query('max_nlp_burnable', {\n sender: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n });\n\n return toBigNumber(baseResponse.max_nlp_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 USDT.\n * @returns\n */\n public async getInsurance(): Promise<GetEngineInsuranceResponse> {\n const baseResponse = await this.query('insurance', {});\n\n return toBigNumber(baseResponse.insurance);\n }\n\n /**\n * Retrieves the NLP locked and unlocked balances for a subaccount.\n *\n * @param params\n */\n async getNlpLockedBalances(\n params: GetEngineNlpLockedBalancesParams,\n ): Promise<GetEngineNlpLockedBalancesResponse> {\n const baseResponse = await this.query('nlp_locked_balances', {\n subaccount: subaccountToHex({\n subaccountOwner: params.subaccountOwner,\n subaccountName: params.subaccountName,\n }),\n });\n\n return mapEngineServerNlpLockedBalances(baseResponse);\n }\n\n /**\n * Retrieves information about all NLP sub-pools\n */\n async getNlpPoolInfo(): Promise<GetEngineNlpPoolInfoResponse> {\n const baseResponse = await this.query('nlp_pool_info', {});\n return mapEngineServerNlpPoolInfo(baseResponse);\n }\n}\n"],"mappings":";;;;;;AAyEA,IAAa,oBAAb,cAAuCA,yBAAAA,iBAAiB;;;;CAItD,MAAM,eAAoD;EACxD,MAAM,eAAe,MAAM,KAAK,MAAM,aAAa,CAAC,CAAC;EACrD,OAAO;GACL,SAAS,OAAO,aAAa,QAAQ;GACrC,cAAc,aAAa;EAC7B;CACF;;;;CAKA,MAAM,YAAiD;EACrD,OAAO,KAAK,MAAM,UAAU,CAAC,CAAC;CAChC;;;;;;;CAQA,MAAM,qBACJ,QAC6C;EAC7C,MAAM,cAAA,GAAA,eAAA,iBAA6B;GACjC,iBAAiB,OAAO;GACxB,gBAAgB,OAAO;EACzB,CAAC;EAKD,OAAOC,+BAAAA,qBAAqB,MAJD,KAAK,MAAM,mBAAmB,EACvD,WACF,CAAC,CAEuC;CAC1C;;;;;;CAOA,MAAM,qBACJ,QAC6C;EAC7C,MAAM,cAAA,GAAA,eAAA,iBAA6B;GACjC,iBAAiB,OAAO;GACxB,gBAAgB,OAAO;EACzB,CAAC;EAKD,OAAOC,+BAAAA,iCAAiC,MAJb,KAAK,MAAM,sBAAsB,EAC1D,WACF,CAAC,CAEmD;CACtD;;;;;;CAOA,MAAM,8BACJ,QAC6C;EAC7C,MAAM,cAAA,GAAA,eAAA,iBAA6B;GACjC,iBAAiB,OAAO;GACxB,gBAAgB,OAAO;EACzB,CAAC;EACD,MAAM,cAAqD;GAC7C;GACZ,MAAM,OAAO,IAAI,KAEb,OAGW;IACX,QAAQ,GAAG,MAAX;KACE,KAAK,eACH,OAAO,EACL,aAAa;MACX,YAAY,GAAG,GAAG;MAClB;MACA,eAAA,GAAA,eAAA,iBAA8B,G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C4C;EAQ5C,QAAA,GAAA,eAAA,cAAmB,MAPQ,KAAK,MAAM,oBAAoB,EACxD,SAAA,GAAA,eAAA,iBAAwB;GACtB,iBAAiB,OAAO;GACxB,gBAAgB,OAAO;EACzB,CAAC,EACH,CAAC,GAE+B,cAAc;CAChD;;;;;;CAOA,MAAa,gBACX,QACwC;EAQxC,OAAO,EACL,SAAQ,MARiB,KAAK,MAAM,iBAAiB,EACrD,aAAA,GAAA,eAAA,iBAA4B;GAC1B,iBAAiB,OAAO;GACxB,gBAAgB,OAAO;EACzB,CAAC,EACH,CAAC,GAGsB,cACvB;CACF;;;;;CAMA,MAAa,eAAoD;EAG/D,QAAA,GAAA,eAAA,cAAmB,MAFQ,KAAK,MAAM,aAAa,CAAC,CAAC,GAErB,SAAS;CAC3C;;;;;;CAOA,MAAM,qBACJ,QAC6C;EAQ7C,OAAOC,+BAAAA,iCAAiC,MAPb,KAAK,MAAM,uBAAuB,EAC3D,aAAA,GAAA,eAAA,iBAA4B;GAC1B,iBAAiB,OAAO;GACxB,gBAAgB,OAAO;EACzB,CAAC,EACH,CAAC,CAEmD;CACtD;;;;CAKA,MAAM,iBAAwD;EAE5D,OAAOC,+BAAAA,2BAA2B,MADP,KAAK,MAAM,iBAAiB,CAAC,CAAC,CACX;CAChD;AACF"}
@@ -1,149 +1,2 @@
1
- import { MarketWithProduct } from '@nadohq/shared';
2
- import { EngineBaseClient } from './EngineBaseClient.cjs';
3
- import { EngineServerStatusResponse } from './types/serverQueryTypes.cjs';
4
- import { GetEngineContractsResponse, GetEngineSubaccountSummaryParams, GetEngineSubaccountSummaryResponse, GetEngineIsolatedPositionsParams, GetEngineIsolatedPositionsResponse, GetEngineEstimatedSubaccountSummaryParams, GetEngineSymbolsParams, EngineSymbolsResponse, GetEngineAllMarketsResponse, GetEngineHealthGroupsResponse, GetEngineOrderParams, GetEngineOrderResponse, ValidateEngineOrderParams, ValidateEngineOrderResponse, ValidateSignedEngineOrderParams, GetEngineSubaccountOrdersParams, GetEngineSubaccountOrdersResponse, GetEngineSubaccountProductOrdersParams, GetEngineSubaccountProductOrdersResponse, GetEngineSubaccountFeeRatesParams, GetEngineSubaccountFeeRatesResponse, GetEngineMarketLiquidityParams, GetEngineMarketLiquidityResponse, GetEngineMarketPriceParams, GetEngineMarketPriceResponse, GetEngineMarketPricesParams, GetEngineMarketPricesResponse, GetEngineMaxOrderSizeParams, GetEngineMaxOrderSizeResponse, GetEngineMaxWithdrawableParams, GetEngineMaxWithdrawableResponse, GetEngineMaxMintNlpAmountParams, GetEngineMaxMintNlpAmountResponse, GetEngineMaxBurnNlpAmountParams, GetEngineMaxBurnNlpAmountResponse, GetEngineLinkedSignerParams, GetEngineLinkedSignerResponse, GetEngineInsuranceResponse, GetEngineNlpLockedBalancesParams, GetEngineNlpLockedBalancesResponse, GetEngineNlpPoolInfoResponse } from './types/clientQueryTypes.cjs';
5
- import 'axios';
6
- import './types/serverExecuteTypes.cjs';
7
- import './types/serverQueryModelTypes.cjs';
8
- import 'bignumber.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 an order from the offchain engine
58
- *
59
- * @param params
60
- */
61
- getOrder(params: GetEngineOrderParams): Promise<GetEngineOrderResponse>;
62
- /**
63
- * Signs and validates with the engine that the order is valid to be submitted (i.e. does not violate health reqs)
64
- *
65
- * @param params
66
- */
67
- validateOrderParams(params: ValidateEngineOrderParams): Promise<ValidateEngineOrderResponse>;
68
- /**
69
- * Validates an existing signed order with the engine as a pre-check for health
70
- *
71
- * @param params
72
- */
73
- validateSignedOrderParams(params: ValidateSignedEngineOrderParams): Promise<ValidateEngineOrderResponse>;
74
- /**
75
- * Get all subaccount orders from the engine, per product ID
76
- * @param params
77
- */
78
- getSubaccountOrders(params: GetEngineSubaccountOrdersParams): Promise<GetEngineSubaccountOrdersResponse>;
79
- /**
80
- * Get all subaccount orders from the engine, for multiple products
81
- * @param params
82
- */
83
- getSubaccountMultiProductOrders(params: GetEngineSubaccountProductOrdersParams): Promise<GetEngineSubaccountProductOrdersResponse>;
84
- /**
85
- * Gets maker & taker fee rates for order fees
86
- * @param params
87
- */
88
- getSubaccountFeeRates(params: GetEngineSubaccountFeeRatesParams): Promise<GetEngineSubaccountFeeRatesResponse>;
89
- /**
90
- * Gets "price ticks" for a given market, useful for constructing liquidity levels at each price
91
- * @param params
92
- */
93
- getMarketLiquidity(params: GetEngineMarketLiquidityParams): Promise<GetEngineMarketLiquidityResponse>;
94
- /**
95
- * Retrieves the latest price for a given market
96
- * @param params
97
- */
98
- getMarketPrice(params: GetEngineMarketPriceParams): Promise<GetEngineMarketPriceResponse>;
99
- /**
100
- * Retrieves the latest prices for provided markets
101
- * @param params
102
- */
103
- getMarketPrices(params: GetEngineMarketPricesParams): Promise<GetEngineMarketPricesResponse>;
104
- /**
105
- * Retrieves the estimated max order size for a product
106
- * @param params
107
- */
108
- getMaxOrderSize(params: GetEngineMaxOrderSizeParams): Promise<GetEngineMaxOrderSizeResponse>;
109
- /**
110
- * Retrieves the estimated max withdrawal size for a product
111
- * @param params
112
- */
113
- getMaxWithdrawable(params: GetEngineMaxWithdrawableParams): Promise<GetEngineMaxWithdrawableResponse>;
114
- /**
115
- * Retrieves the estimated max quote amount for minting NLP.
116
- *
117
- * @param params
118
- */
119
- getMaxMintNlpAmount(params: GetEngineMaxMintNlpAmountParams): Promise<GetEngineMaxMintNlpAmountResponse>;
120
- /**
121
- * Retrieves the max amount of NLP that can be burned.
122
- *
123
- * @param params
124
- */
125
- getMaxBurnNlpAmount(params: GetEngineMaxBurnNlpAmountParams): Promise<GetEngineMaxBurnNlpAmountResponse>;
126
- /**
127
- * Gets the currently linked signer for the subaccount
128
- * @param params
129
- * @returns
130
- */
131
- getLinkedSigner(params: GetEngineLinkedSignerParams): Promise<GetEngineLinkedSignerResponse>;
132
- /**
133
- * Gets the insurance funds in USDT.
134
- * @returns
135
- */
136
- getInsurance(): Promise<GetEngineInsuranceResponse>;
137
- /**
138
- * Retrieves the NLP locked and unlocked balances for a subaccount.
139
- *
140
- * @param params
141
- */
142
- getNlpLockedBalances(params: GetEngineNlpLockedBalancesParams): Promise<GetEngineNlpLockedBalancesResponse>;
143
- /**
144
- * Retrieves information about all NLP sub-pools
145
- */
146
- getNlpPoolInfo(): Promise<GetEngineNlpPoolInfoResponse>;
147
- }
148
-
149
- export { EngineQueryClient };
1
+ import { t as EngineQueryClient } from "./EngineQueryClient-C_7p1oRx.cjs";
2
+ export { EngineQueryClient };
@@ -1,149 +1,2 @@
1
- import { MarketWithProduct } from '@nadohq/shared';
2
- import { EngineBaseClient } from './EngineBaseClient.js';
3
- import { EngineServerStatusResponse } from './types/serverQueryTypes.js';
4
- import { GetEngineContractsResponse, GetEngineSubaccountSummaryParams, GetEngineSubaccountSummaryResponse, GetEngineIsolatedPositionsParams, GetEngineIsolatedPositionsResponse, GetEngineEstimatedSubaccountSummaryParams, GetEngineSymbolsParams, EngineSymbolsResponse, GetEngineAllMarketsResponse, GetEngineHealthGroupsResponse, GetEngineOrderParams, GetEngineOrderResponse, ValidateEngineOrderParams, ValidateEngineOrderResponse, ValidateSignedEngineOrderParams, GetEngineSubaccountOrdersParams, GetEngineSubaccountOrdersResponse, GetEngineSubaccountProductOrdersParams, GetEngineSubaccountProductOrdersResponse, GetEngineSubaccountFeeRatesParams, GetEngineSubaccountFeeRatesResponse, GetEngineMarketLiquidityParams, GetEngineMarketLiquidityResponse, GetEngineMarketPriceParams, GetEngineMarketPriceResponse, GetEngineMarketPricesParams, GetEngineMarketPricesResponse, GetEngineMaxOrderSizeParams, GetEngineMaxOrderSizeResponse, GetEngineMaxWithdrawableParams, GetEngineMaxWithdrawableResponse, GetEngineMaxMintNlpAmountParams, GetEngineMaxMintNlpAmountResponse, GetEngineMaxBurnNlpAmountParams, GetEngineMaxBurnNlpAmountResponse, GetEngineLinkedSignerParams, GetEngineLinkedSignerResponse, GetEngineInsuranceResponse, GetEngineNlpLockedBalancesParams, GetEngineNlpLockedBalancesResponse, GetEngineNlpPoolInfoResponse } from './types/clientQueryTypes.js';
5
- import 'axios';
6
- import './types/serverExecuteTypes.js';
7
- import './types/serverQueryModelTypes.js';
8
- import 'bignumber.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 an order from the offchain engine
58
- *
59
- * @param params
60
- */
61
- getOrder(params: GetEngineOrderParams): Promise<GetEngineOrderResponse>;
62
- /**
63
- * Signs and validates with the engine that the order is valid to be submitted (i.e. does not violate health reqs)
64
- *
65
- * @param params
66
- */
67
- validateOrderParams(params: ValidateEngineOrderParams): Promise<ValidateEngineOrderResponse>;
68
- /**
69
- * Validates an existing signed order with the engine as a pre-check for health
70
- *
71
- * @param params
72
- */
73
- validateSignedOrderParams(params: ValidateSignedEngineOrderParams): Promise<ValidateEngineOrderResponse>;
74
- /**
75
- * Get all subaccount orders from the engine, per product ID
76
- * @param params
77
- */
78
- getSubaccountOrders(params: GetEngineSubaccountOrdersParams): Promise<GetEngineSubaccountOrdersResponse>;
79
- /**
80
- * Get all subaccount orders from the engine, for multiple products
81
- * @param params
82
- */
83
- getSubaccountMultiProductOrders(params: GetEngineSubaccountProductOrdersParams): Promise<GetEngineSubaccountProductOrdersResponse>;
84
- /**
85
- * Gets maker & taker fee rates for order fees
86
- * @param params
87
- */
88
- getSubaccountFeeRates(params: GetEngineSubaccountFeeRatesParams): Promise<GetEngineSubaccountFeeRatesResponse>;
89
- /**
90
- * Gets "price ticks" for a given market, useful for constructing liquidity levels at each price
91
- * @param params
92
- */
93
- getMarketLiquidity(params: GetEngineMarketLiquidityParams): Promise<GetEngineMarketLiquidityResponse>;
94
- /**
95
- * Retrieves the latest price for a given market
96
- * @param params
97
- */
98
- getMarketPrice(params: GetEngineMarketPriceParams): Promise<GetEngineMarketPriceResponse>;
99
- /**
100
- * Retrieves the latest prices for provided markets
101
- * @param params
102
- */
103
- getMarketPrices(params: GetEngineMarketPricesParams): Promise<GetEngineMarketPricesResponse>;
104
- /**
105
- * Retrieves the estimated max order size for a product
106
- * @param params
107
- */
108
- getMaxOrderSize(params: GetEngineMaxOrderSizeParams): Promise<GetEngineMaxOrderSizeResponse>;
109
- /**
110
- * Retrieves the estimated max withdrawal size for a product
111
- * @param params
112
- */
113
- getMaxWithdrawable(params: GetEngineMaxWithdrawableParams): Promise<GetEngineMaxWithdrawableResponse>;
114
- /**
115
- * Retrieves the estimated max quote amount for minting NLP.
116
- *
117
- * @param params
118
- */
119
- getMaxMintNlpAmount(params: GetEngineMaxMintNlpAmountParams): Promise<GetEngineMaxMintNlpAmountResponse>;
120
- /**
121
- * Retrieves the max amount of NLP that can be burned.
122
- *
123
- * @param params
124
- */
125
- getMaxBurnNlpAmount(params: GetEngineMaxBurnNlpAmountParams): Promise<GetEngineMaxBurnNlpAmountResponse>;
126
- /**
127
- * Gets the currently linked signer for the subaccount
128
- * @param params
129
- * @returns
130
- */
131
- getLinkedSigner(params: GetEngineLinkedSignerParams): Promise<GetEngineLinkedSignerResponse>;
132
- /**
133
- * Gets the insurance funds in USDT.
134
- * @returns
135
- */
136
- getInsurance(): Promise<GetEngineInsuranceResponse>;
137
- /**
138
- * Retrieves the NLP locked and unlocked balances for a subaccount.
139
- *
140
- * @param params
141
- */
142
- getNlpLockedBalances(params: GetEngineNlpLockedBalancesParams): Promise<GetEngineNlpLockedBalancesResponse>;
143
- /**
144
- * Retrieves information about all NLP sub-pools
145
- */
146
- getNlpPoolInfo(): Promise<GetEngineNlpPoolInfoResponse>;
147
- }
148
-
149
- export { EngineQueryClient };
1
+ import { t as EngineQueryClient } from "./EngineQueryClient-DQwCRaYl.js";
2
+ export { EngineQueryClient };