@nadohq/engine-client 0.1.0-alpha.4 → 0.1.0-alpha.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/EngineBaseClient.d.cts +1 -1
  2. package/dist/EngineBaseClient.d.ts +1 -1
  3. package/dist/EngineExecuteBuilder.cjs +9 -6
  4. package/dist/EngineExecuteBuilder.cjs.map +1 -1
  5. package/dist/EngineExecuteBuilder.js +9 -6
  6. package/dist/EngineExecuteBuilder.js.map +1 -1
  7. package/dist/EngineExecuteClient.cjs +6 -6
  8. package/dist/EngineExecuteClient.cjs.map +1 -1
  9. package/dist/EngineExecuteClient.d.cts +1 -1
  10. package/dist/EngineExecuteClient.d.ts +1 -1
  11. package/dist/EngineExecuteClient.js +6 -6
  12. package/dist/EngineExecuteClient.js.map +1 -1
  13. package/dist/EngineQueryClient.cjs +48 -4
  14. package/dist/EngineQueryClient.cjs.map +1 -1
  15. package/dist/EngineQueryClient.d.cts +18 -2
  16. package/dist/EngineQueryClient.d.ts +18 -2
  17. package/dist/EngineQueryClient.js +50 -4
  18. package/dist/EngineQueryClient.js.map +1 -1
  19. package/dist/endpoints.cjs +6 -6
  20. package/dist/endpoints.cjs.map +1 -1
  21. package/dist/endpoints.js +6 -6
  22. package/dist/endpoints.js.map +1 -1
  23. package/dist/index.cjs +4 -4
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +9 -9
  26. package/dist/index.d.ts +9 -9
  27. package/dist/index.js +2 -2
  28. package/dist/index.js.map +1 -1
  29. package/dist/types/EngineServerFailureError.cjs +1 -1
  30. package/dist/types/EngineServerFailureError.cjs.map +1 -1
  31. package/dist/types/EngineServerFailureError.js +1 -1
  32. package/dist/types/EngineServerFailureError.js.map +1 -1
  33. package/dist/types/clientExecuteTypes.cjs.map +1 -1
  34. package/dist/types/clientExecuteTypes.d.cts +8 -1
  35. package/dist/types/clientExecuteTypes.d.ts +8 -1
  36. package/dist/types/clientQueryTypes.cjs.map +1 -1
  37. package/dist/types/clientQueryTypes.d.cts +37 -5
  38. package/dist/types/clientQueryTypes.d.ts +37 -5
  39. package/dist/types/index.cjs +10 -10
  40. package/dist/types/index.cjs.map +1 -1
  41. package/dist/types/index.d.cts +6 -6
  42. package/dist/types/index.d.ts +6 -6
  43. package/dist/types/index.js +5 -5
  44. package/dist/types/index.js.map +1 -1
  45. package/dist/types/serverExecuteTypes.cjs.map +1 -1
  46. package/dist/types/serverExecuteTypes.d.cts +8 -1
  47. package/dist/types/serverExecuteTypes.d.ts +8 -1
  48. package/dist/types/serverQueryModelTypes.cjs.map +1 -1
  49. package/dist/types/serverQueryModelTypes.d.cts +24 -1
  50. package/dist/types/serverQueryModelTypes.d.ts +24 -1
  51. package/dist/types/serverQueryTypes.cjs.map +1 -1
  52. package/dist/types/serverQueryTypes.d.cts +47 -22
  53. package/dist/types/serverQueryTypes.d.ts +47 -22
  54. package/dist/types/serverSubscriptionEventTypes.cjs.map +1 -1
  55. package/dist/types/serverSubscriptionEventTypes.d.cts +86 -22
  56. package/dist/types/serverSubscriptionEventTypes.d.ts +86 -22
  57. package/dist/types/serverSubscriptionTypes.cjs.map +1 -1
  58. package/dist/types/serverSubscriptionTypes.d.cts +21 -4
  59. package/dist/types/serverSubscriptionTypes.d.ts +21 -4
  60. package/dist/utils/index.d.cts +2 -2
  61. package/dist/utils/index.d.ts +2 -2
  62. package/dist/utils/queryDataMappers.cjs +66 -19
  63. package/dist/utils/queryDataMappers.cjs.map +1 -1
  64. package/dist/utils/queryDataMappers.d.cts +5 -3
  65. package/dist/utils/queryDataMappers.d.ts +5 -3
  66. package/dist/utils/queryDataMappers.js +64 -19
  67. package/dist/utils/queryDataMappers.js.map +1 -1
  68. package/package.json +7 -3
  69. package/src/EngineExecuteBuilder.ts +9 -6
  70. package/src/EngineExecuteClient.ts +7 -7
  71. package/src/EngineQueryClient.ts +63 -1
  72. package/src/endpoints.ts +6 -6
  73. package/src/index.ts +2 -2
  74. package/src/types/EngineServerFailureError.ts +1 -1
  75. package/src/types/clientExecuteTypes.ts +9 -2
  76. package/src/types/clientQueryTypes.ts +49 -4
  77. package/src/types/index.ts +5 -5
  78. package/src/types/serverExecuteTypes.ts +9 -2
  79. package/src/types/serverQueryModelTypes.ts +25 -0
  80. package/src/types/serverQueryTypes.ts +61 -21
  81. package/src/types/serverSubscriptionEventTypes.ts +131 -21
  82. package/src/types/serverSubscriptionTypes.ts +23 -3
  83. package/src/utils/queryDataMappers.ts +85 -20
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/queryDataMappers.ts"],"sourcesContent":["import {\n BalanceHealthContributions,\n calcTotalBorrowed,\n calcTotalDeposited,\n mapValues,\n PerpMarket,\n ProductEngineType,\n removeDecimals,\n SpotMarket,\n subaccountFromHex,\n toBigDecimal,\n unpackOrderAppendix,\n} from '@nadohq/shared';\nimport {\n EngineMarketPrice,\n EngineOrder,\n EnginePriceTickLiquidity,\n EngineServerIsolatedPositionsResponse,\n EngineServerMarketPrice,\n EngineServerOrderResponse,\n EngineServerPerpProduct,\n EngineServerPriceTickLiquidity,\n EngineServerSpotProduct,\n EngineServerSubaccountInfoResponse,\n EngineServerSymbol,\n EngineServerSymbolsResponse,\n EngineSymbol,\n EngineSymbolsResponse,\n GetEngineIsolatedPositionsResponse,\n GetEngineSubaccountSummaryResponse,\n} from '../types';\nimport { mapEngineServerProductType } from './productEngineTypeMappers';\n\nexport function mapEngineServerTickLiquidity(\n tick: EngineServerPriceTickLiquidity,\n): EnginePriceTickLiquidity {\n return {\n price: removeDecimals(tick[0]),\n liquidity: toBigDecimal(tick[1]),\n };\n}\n\nexport function mapEngineServerOrder(\n order: EngineServerOrderResponse,\n): EngineOrder {\n const subaccount = subaccountFromHex(order.sender);\n return {\n digest: order.digest,\n expiration: Number(order.expiration),\n nonce: order.nonce,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccountOwner: subaccount.subaccountOwner,\n subaccountName: subaccount.subaccountName,\n totalAmount: toBigDecimal(order.amount),\n unfilledAmount: toBigDecimal(order.unfilled_amount),\n placementTime: order.placed_at,\n appendix: unpackOrderAppendix(order.appendix),\n };\n}\n\nexport function mapEngineServerSpotProduct(\n product: EngineServerSpotProduct,\n): SpotMarket {\n return {\n type: ProductEngineType.SPOT,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.SPOT,\n totalBorrowed: calcTotalBorrowed(\n product.state.total_borrows_normalized,\n product.state.cumulative_borrows_multiplier_x18,\n ),\n totalDeposited: calcTotalDeposited(\n product.state.total_deposits_normalized,\n product.state.cumulative_deposits_multiplier_x18,\n ),\n oraclePrice: removeDecimals(product.oracle_price_x18),\n interestFloor: removeDecimals(product.config.interest_floor_x18),\n interestInflectionUtil: removeDecimals(\n product.config.interest_inflection_util_x18,\n ),\n interestLargeCap: removeDecimals(product.config.interest_large_cap_x18),\n interestSmallCap: removeDecimals(product.config.interest_small_cap_x18),\n minDepositRate: removeDecimals(product.config.min_deposit_rate_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n tokenAddr: product.config.token,\n },\n };\n}\n\nexport function mapEngineServerPerpProduct(\n product: EngineServerPerpProduct,\n): PerpMarket {\n return {\n type: ProductEngineType.PERP,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.PERP,\n oraclePrice: removeDecimals(product.oracle_price_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n openInterest: toBigDecimal(product.state.open_interest),\n cumulativeFundingLong: removeDecimals(\n product.state.cumulative_funding_long_x18,\n ),\n cumulativeFundingShort: removeDecimals(\n product.state.cumulative_funding_short_x18,\n ),\n },\n };\n}\n\nexport function mapEngineServerBalanceHealthContributions(\n healthContributionsForBalance: string[],\n): BalanceHealthContributions {\n return {\n initial: toBigDecimal(healthContributionsForBalance[0]),\n maintenance: toBigDecimal(healthContributionsForBalance[1]),\n unweighted: toBigDecimal(healthContributionsForBalance[2]),\n };\n}\n\nexport function mapSubaccountSummary(\n baseResponse: EngineServerSubaccountInfoResponse,\n): GetEngineSubaccountSummaryResponse {\n const balances: GetEngineSubaccountSummaryResponse['balances'] = [];\n\n baseResponse.spot_balances.forEach((spotBalance) => {\n const product = baseResponse.spot_products.find(\n (product) => product.product_id === spotBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${spotBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(spotBalance.balance.amount),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[spotBalance.product_id],\n ),\n ...mapEngineServerSpotProduct(product).product,\n });\n });\n\n baseResponse.perp_balances.forEach((perpBalance) => {\n const product = baseResponse.perp_products.find(\n (product) => product.product_id === perpBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${perpBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[perpBalance.product_id],\n ),\n ...mapEngineServerPerpProduct(product).product,\n });\n });\n\n return {\n balances: balances,\n exists: baseResponse.exists,\n health: {\n initial: {\n health: toBigDecimal(baseResponse.healths[0].health),\n assets: toBigDecimal(baseResponse.healths[0].assets),\n liabilities: toBigDecimal(baseResponse.healths[0].liabilities),\n },\n maintenance: {\n health: toBigDecimal(baseResponse.healths[1].health),\n assets: toBigDecimal(baseResponse.healths[1].assets),\n liabilities: toBigDecimal(baseResponse.healths[1].liabilities),\n },\n unweighted: {\n health: toBigDecimal(baseResponse.healths[2].health),\n assets: toBigDecimal(baseResponse.healths[2].assets),\n liabilities: toBigDecimal(baseResponse.healths[2].liabilities),\n },\n },\n };\n}\n\nexport function mapEngineServerIsolatedPositions(\n baseResponse: EngineServerIsolatedPositionsResponse,\n): GetEngineIsolatedPositionsResponse {\n return baseResponse.isolated_positions.map((position) => {\n const perpBalance = position.base_balance;\n const quoteBalance = position.quote_balance;\n\n return {\n subaccount: subaccountFromHex(position.subaccount),\n healths: {\n initial: toBigDecimal(position.healths[0].health),\n maintenance: toBigDecimal(position.healths[1].health),\n unweighted: toBigDecimal(position.healths[2].health),\n },\n baseBalance: {\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n // Health contributions === healths for an isolated position\n healthContributions: {\n initial: toBigDecimal(position.base_healths[0]),\n maintenance: toBigDecimal(position.base_healths[1]),\n unweighted: toBigDecimal(position.base_healths[2]),\n },\n ...mapEngineServerPerpProduct(position.base_product).product,\n },\n quoteBalance: {\n amount: toBigDecimal(quoteBalance.balance.amount),\n healthContributions: {\n initial: toBigDecimal(position.quote_healths[0]),\n maintenance: toBigDecimal(position.quote_healths[1]),\n unweighted: toBigDecimal(position.quote_healths[2]),\n },\n ...mapEngineServerSpotProduct(position.quote_product).product,\n },\n };\n });\n}\n\nexport function mapEngineServerSymbols(\n baseResponse: EngineServerSymbolsResponse,\n): EngineSymbolsResponse {\n const symbols: Record<string, EngineSymbol> = mapValues(\n baseResponse.symbols,\n mapEngineServerSymbol,\n );\n\n return {\n symbols,\n };\n}\n\nexport function mapEngineServerSymbol(\n engineServerSymbol: EngineServerSymbol,\n): EngineSymbol {\n return {\n type: mapEngineServerProductType(engineServerSymbol.type),\n productId: engineServerSymbol.product_id,\n symbol: engineServerSymbol.symbol,\n priceIncrement: removeDecimals(engineServerSymbol.price_increment_x18),\n sizeIncrement: toBigDecimal(engineServerSymbol.size_increment),\n minSize: toBigDecimal(engineServerSymbol.min_size),\n minDepth: removeDecimals(engineServerSymbol.min_depth_x18),\n maxSpreadRate: removeDecimals(engineServerSymbol.max_spread_rate_x18),\n makerFeeRate: removeDecimals(engineServerSymbol.maker_fee_rate_x18),\n takerFeeRate: removeDecimals(engineServerSymbol.taker_fee_rate_x18),\n longWeightInitial: removeDecimals(\n engineServerSymbol.long_weight_initial_x18,\n ),\n longWeightMaintenance: removeDecimals(\n engineServerSymbol.long_weight_maintenance_x18,\n ),\n };\n}\n\nexport function mapEngineMarketPrice(\n baseResponse: EngineServerMarketPrice,\n): EngineMarketPrice {\n return {\n ask: removeDecimals(baseResponse.ask_x18),\n bid: removeDecimals(baseResponse.bid_x18),\n productId: baseResponse.product_id,\n };\n}\n"],"mappings":";AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAmBP,SAAS,kCAAkC;AAEpC,SAAS,6BACd,MAC0B;AAC1B,SAAO;AAAA,IACL,OAAO,eAAe,KAAK,CAAC,CAAC;AAAA,IAC7B,WAAW,aAAa,KAAK,CAAC,CAAC;AAAA,EACjC;AACF;AAEO,SAAS,qBACd,OACa;AACb,QAAM,aAAa,kBAAkB,MAAM,MAAM;AACjD,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd,YAAY,OAAO,MAAM,UAAU;AAAA,IACnC,OAAO,MAAM;AAAA,IACb,OAAO,eAAe,MAAM,SAAS;AAAA,IACrC,WAAW,MAAM;AAAA,IACjB,iBAAiB,WAAW;AAAA,IAC5B,gBAAgB,WAAW;AAAA,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B;AAAA,IAC9B,QAAQ,mBAAmB;AAAA,IAC3B,gBAAgB,eAAe,mBAAmB,mBAAmB;AAAA,IACrE,eAAe,aAAa,mBAAmB,cAAc;AAAA,IAC7D,SAAS,aAAa,mBAAmB,QAAQ;AAAA,IACjD,UAAU,eAAe,mBAAmB,aAAa;AAAA,IACzD,eAAe,eAAe,mBAAmB,mBAAmB;AAAA,IACpE,cAAc,eAAe,mBAAmB,kBAAkB;AAAA,IAClE,cAAc,eAAe,mBAAmB,kBAAkB;AAAA,IAClE,mBAAmB;AAAA,MACjB,mBAAmB;AAAA,IACrB;AAAA,IACA,uBAAuB;AAAA,MACrB,mBAAmB;AAAA,IACrB;AAAA,EACF;AACF;AAEO,SAAS,qBACd,cACmB;AACnB,SAAO;AAAA,IACL,KAAK,eAAe,aAAa,OAAO;AAAA,IACxC,KAAK,eAAe,aAAa,OAAO;AAAA,IACxC,WAAW,aAAa;AAAA,EAC1B;AACF;","names":["product"]}
1
+ {"version":3,"sources":["../../src/utils/queryDataMappers.ts"],"sourcesContent":["import {\n BalanceHealthContributions,\n calcTotalBorrowed,\n calcTotalDeposited,\n mapValues,\n PerpMarket,\n ProductEngineType,\n removeDecimals,\n SpotMarket,\n subaccountFromHex,\n toBigDecimal,\n unpackOrderAppendix,\n} from '@nadohq/shared';\nimport {\n EngineMarketPrice,\n EngineNlpLockedBalance,\n EngineOrder,\n EnginePriceTickLiquidity,\n EngineServerIsolatedPositionsResponse,\n EngineServerMarketPrice,\n EngineServerNlpLockedBalancesResponse,\n EngineServerNlpPoolInfoResponse,\n EngineServerOrderResponse,\n EngineServerPerpProduct,\n EngineServerPriceTickLiquidity,\n EngineServerSpotProduct,\n EngineServerSubaccountInfoResponse,\n EngineServerSubaccountInfoState,\n EngineServerSymbol,\n EngineServerSymbolsResponse,\n EngineSymbol,\n EngineSymbolsResponse,\n GetEngineIsolatedPositionsResponse,\n GetEngineNlpLockedBalancesResponse,\n GetEngineNlpPoolInfoResponse,\n GetEngineSubaccountSummaryResponse,\n SubaccountSummaryState,\n} from '../types';\nimport { mapEngineServerProductType } from './productEngineTypeMappers';\n\nexport function mapEngineServerTickLiquidity(\n tick: EngineServerPriceTickLiquidity,\n): EnginePriceTickLiquidity {\n return {\n price: removeDecimals(tick[0]),\n liquidity: toBigDecimal(tick[1]),\n };\n}\n\nexport function mapEngineServerOrder(\n order: EngineServerOrderResponse,\n): EngineOrder {\n const subaccount = subaccountFromHex(order.sender);\n return {\n digest: order.digest,\n expiration: Number(order.expiration),\n nonce: order.nonce,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccountOwner: subaccount.subaccountOwner,\n subaccountName: subaccount.subaccountName,\n totalAmount: toBigDecimal(order.amount),\n unfilledAmount: toBigDecimal(order.unfilled_amount),\n placementTime: order.placed_at,\n appendix: unpackOrderAppendix(order.appendix),\n };\n}\n\nexport function mapEngineServerSpotProduct(\n product: EngineServerSpotProduct,\n): SpotMarket {\n return {\n type: ProductEngineType.SPOT,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.SPOT,\n totalBorrowed: calcTotalBorrowed(\n product.state.total_borrows_normalized,\n product.state.cumulative_borrows_multiplier_x18,\n ),\n totalDeposited: calcTotalDeposited(\n product.state.total_deposits_normalized,\n product.state.cumulative_deposits_multiplier_x18,\n ),\n oraclePrice: removeDecimals(product.oracle_price_x18),\n interestFloor: removeDecimals(product.config.interest_floor_x18),\n interestInflectionUtil: removeDecimals(\n product.config.interest_inflection_util_x18,\n ),\n interestLargeCap: removeDecimals(product.config.interest_large_cap_x18),\n interestSmallCap: removeDecimals(product.config.interest_small_cap_x18),\n minDepositRate: removeDecimals(product.config.min_deposit_rate_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n tokenAddr: product.config.token,\n },\n };\n}\n\nexport function mapEngineServerPerpProduct(\n product: EngineServerPerpProduct,\n): PerpMarket {\n return {\n type: ProductEngineType.PERP,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.PERP,\n oraclePrice: removeDecimals(product.oracle_price_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n openInterest: toBigDecimal(product.state.open_interest),\n cumulativeFundingLong: removeDecimals(\n product.state.cumulative_funding_long_x18,\n ),\n cumulativeFundingShort: removeDecimals(\n product.state.cumulative_funding_short_x18,\n ),\n },\n };\n}\n\nexport function mapEngineServerBalanceHealthContributions(\n healthContributionsForBalance: string[],\n): BalanceHealthContributions {\n return {\n initial: toBigDecimal(healthContributionsForBalance[0]),\n maintenance: toBigDecimal(healthContributionsForBalance[1]),\n unweighted: toBigDecimal(healthContributionsForBalance[2]),\n };\n}\n\nexport function mapSubaccountSummary(\n baseResponse: EngineServerSubaccountInfoResponse,\n): GetEngineSubaccountSummaryResponse {\n return {\n exists: baseResponse.exists,\n ...mapSubaccountSummaryState(\n baseResponse,\n baseResponse.spot_products,\n baseResponse.perp_products,\n ),\n preState: baseResponse.pre_state\n ? mapSubaccountSummaryState(\n baseResponse.pre_state,\n baseResponse.spot_products,\n baseResponse.perp_products,\n )\n : undefined,\n };\n}\n\nfunction mapSubaccountSummaryState(\n state: EngineServerSubaccountInfoState,\n spotProducts: EngineServerSubaccountInfoResponse['spot_products'],\n perpProducts: EngineServerSubaccountInfoResponse['perp_products'],\n): SubaccountSummaryState {\n const balances: SubaccountSummaryState['balances'] = [];\n\n state.spot_balances.forEach((spotBalance) => {\n const product = spotProducts.find(\n (product) => product.product_id === spotBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${spotBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(spotBalance.balance.amount),\n healthContributions: mapEngineServerBalanceHealthContributions(\n state.health_contributions[spotBalance.product_id],\n ),\n ...mapEngineServerSpotProduct(product).product,\n });\n });\n\n state.perp_balances.forEach((perpBalance) => {\n const product = perpProducts.find(\n (product) => product.product_id === perpBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${perpBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n healthContributions: mapEngineServerBalanceHealthContributions(\n state.health_contributions[perpBalance.product_id],\n ),\n ...mapEngineServerPerpProduct(product).product,\n });\n });\n\n return {\n balances,\n health: {\n initial: {\n health: toBigDecimal(state.healths[0].health),\n assets: toBigDecimal(state.healths[0].assets),\n liabilities: toBigDecimal(state.healths[0].liabilities),\n },\n maintenance: {\n health: toBigDecimal(state.healths[1].health),\n assets: toBigDecimal(state.healths[1].assets),\n liabilities: toBigDecimal(state.healths[1].liabilities),\n },\n unweighted: {\n health: toBigDecimal(state.healths[2].health),\n assets: toBigDecimal(state.healths[2].assets),\n liabilities: toBigDecimal(state.healths[2].liabilities),\n },\n },\n };\n}\n\nexport function mapEngineServerIsolatedPositions(\n baseResponse: EngineServerIsolatedPositionsResponse,\n): GetEngineIsolatedPositionsResponse {\n return baseResponse.isolated_positions.map((position) => {\n const perpBalance = position.base_balance;\n const quoteBalance = position.quote_balance;\n\n return {\n subaccount: subaccountFromHex(position.subaccount),\n healths: {\n initial: toBigDecimal(position.healths[0].health),\n maintenance: toBigDecimal(position.healths[1].health),\n unweighted: toBigDecimal(position.healths[2].health),\n },\n baseBalance: {\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n // Health contributions === healths for an isolated position\n healthContributions: {\n initial: toBigDecimal(position.base_healths[0]),\n maintenance: toBigDecimal(position.base_healths[1]),\n unweighted: toBigDecimal(position.base_healths[2]),\n },\n ...mapEngineServerPerpProduct(position.base_product).product,\n },\n quoteBalance: {\n amount: toBigDecimal(quoteBalance.balance.amount),\n healthContributions: {\n initial: toBigDecimal(position.quote_healths[0]),\n maintenance: toBigDecimal(position.quote_healths[1]),\n unweighted: toBigDecimal(position.quote_healths[2]),\n },\n ...mapEngineServerSpotProduct(position.quote_product).product,\n },\n };\n });\n}\n\nexport function mapEngineServerSymbols(\n baseResponse: EngineServerSymbolsResponse,\n): EngineSymbolsResponse {\n const symbols: Record<string, EngineSymbol> = mapValues(\n baseResponse.symbols,\n mapEngineServerSymbol,\n );\n\n return {\n symbols,\n };\n}\n\nexport function mapEngineServerSymbol(\n engineServerSymbol: EngineServerSymbol,\n): EngineSymbol {\n return {\n type: mapEngineServerProductType(engineServerSymbol.type),\n productId: engineServerSymbol.product_id,\n symbol: engineServerSymbol.symbol,\n priceIncrement: removeDecimals(engineServerSymbol.price_increment_x18),\n sizeIncrement: toBigDecimal(engineServerSymbol.size_increment),\n minSize: toBigDecimal(engineServerSymbol.min_size),\n makerFeeRate: removeDecimals(engineServerSymbol.maker_fee_rate_x18),\n takerFeeRate: removeDecimals(engineServerSymbol.taker_fee_rate_x18),\n longWeightInitial: removeDecimals(\n engineServerSymbol.long_weight_initial_x18,\n ),\n longWeightMaintenance: removeDecimals(\n engineServerSymbol.long_weight_maintenance_x18,\n ),\n maxOpenInterest: removeDecimals(engineServerSymbol.max_open_interest_x18),\n };\n}\n\nexport function mapEngineMarketPrice(\n baseResponse: EngineServerMarketPrice,\n): EngineMarketPrice {\n return {\n ask: removeDecimals(baseResponse.ask_x18),\n bid: removeDecimals(baseResponse.bid_x18),\n productId: baseResponse.product_id,\n };\n}\n\nexport function mapEngineServerNlpLockedBalances(\n baseResponse: EngineServerNlpLockedBalancesResponse,\n): GetEngineNlpLockedBalancesResponse {\n const lockedBalances: EngineNlpLockedBalance[] =\n baseResponse.locked_balances.map((lockedBalance) => ({\n productId: lockedBalance.balance.product_id,\n balance: toBigDecimal(lockedBalance.balance.balance.amount),\n unlockedAt: lockedBalance.unlocked_at,\n }));\n\n return {\n lockedBalances,\n balanceLocked: {\n productId: baseResponse.balance_locked.product_id,\n balance: toBigDecimal(baseResponse.balance_locked.balance.amount),\n },\n balanceUnlocked: {\n productId: baseResponse.balance_unlocked.product_id,\n balance: toBigDecimal(baseResponse.balance_unlocked.balance.amount),\n },\n };\n}\n\nexport function mapEngineServerNlpPoolInfo(\n baseResponse: EngineServerNlpPoolInfoResponse,\n): GetEngineNlpPoolInfoResponse {\n return {\n nlpPools: baseResponse.nlp_pools.map((pool) => ({\n poolId: pool.pool_id,\n subaccountHex: pool.subaccount,\n ownerAddress: pool.owner,\n balanceWeight: removeDecimals(pool.balance_weight_x18),\n subaccountInfo: mapSubaccountSummary(pool.subaccount_info),\n openOrders: pool.open_orders.map(mapEngineServerOrder),\n })),\n };\n}\n"],"mappings":";AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA0BP,SAAS,kCAAkC;AAEpC,SAAS,6BACd,MAC0B;AAC1B,SAAO;AAAA,IACL,OAAO,eAAe,KAAK,CAAC,CAAC;AAAA,IAC7B,WAAW,aAAa,KAAK,CAAC,CAAC;AAAA,EACjC;AACF;AAEO,SAAS,qBACd,OACa;AACb,QAAM,aAAa,kBAAkB,MAAM,MAAM;AACjD,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd,YAAY,OAAO,MAAM,UAAU;AAAA,IACnC,OAAO,MAAM;AAAA,IACb,OAAO,eAAe,MA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f,WAAW,aAAa,iBAAiB;AAAA,MACzC,SAAS,aAAa,aAAa,iBAAiB,QAAQ,MAAM;AAAA,IACpE;AAAA,EACF;AACF;AAEO,SAAS,2BACd,cAC8B;AAC9B,SAAO;AAAA,IACL,UAAU,aAAa,UAAU,IAAI,CAAC,UAAU;AAAA,MAC9C,QAAQ,KAAK;AAAA,MACb,eAAe,KAAK;AAAA,MACpB,cAAc,KAAK;AAAA,MACnB,eAAe,eAAe,KAAK,kBAAkB;AAAA,MACrD,gBAAgB,qBAAqB,KAAK,eAAe;AAAA,MACzD,YAAY,KAAK,YAAY,IAAI,oBAAoB;AAAA,IACvD,EAAE;AAAA,EACJ;AACF;","names":["product"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nadohq/engine-client",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-alpha.41",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "> TODO: description",
@@ -36,8 +36,12 @@
36
36
  }
37
37
  }
38
38
  },
39
+ "react-native": "./dist/index.js",
40
+ "main": "./dist/index.cjs",
41
+ "module": "./dist/index.js",
42
+ "types": "./dist/index.d.ts",
39
43
  "dependencies": {
40
- "@nadohq/shared": "^0.1.0-alpha.4",
44
+ "@nadohq/shared": "^0.1.0-alpha.41",
41
45
  "axios": "*",
42
46
  "ts-mixer": "*"
43
47
  },
@@ -47,5 +51,5 @@
47
51
  "devDependencies": {
48
52
  "viem": "*"
49
53
  },
50
- "gitHead": "b852ce36b851303225d3f4b81739ac667c64cf8c"
54
+ "gitHead": "dbfcd352246b8914985af6b333cc49e2b8624473"
51
55
  }
@@ -138,12 +138,15 @@ export class EngineExecuteBuilder {
138
138
  async buildPlaceOrdersPayload(
139
139
  clientParams: EngineExecuteRequestParamsByType['place_orders'],
140
140
  ): Promise<EngineServerExecuteRequestByType['place_orders']> {
141
- return Promise.all(
142
- clientParams.map(async (orderParams) => {
143
- const payload = await this.buildPlaceOrderPayload(orderParams);
144
- return payload.payload;
145
- }),
146
- );
141
+ return {
142
+ orders: await Promise.all(
143
+ clientParams.orders.map(async (orderParams) => {
144
+ const payload = await this.buildPlaceOrderPayload(orderParams);
145
+ return payload.payload;
146
+ }),
147
+ ),
148
+ stop_on_failure: clientParams.stopOnFailure ?? null,
149
+ };
147
150
  }
148
151
 
149
152
  /**
@@ -42,6 +42,13 @@ export class EngineExecuteClient extends EngineBaseClient {
42
42
  };
43
43
  }
44
44
 
45
+ async placeOrders(params: EngineExecuteRequestParamsByType['place_orders']) {
46
+ return this.execute(
47
+ 'place_orders',
48
+ await this.payloadBuilder.buildPlaceOrdersPayload(params),
49
+ );
50
+ }
51
+
45
52
  async cancelOrders(
46
53
  params: EngineExecuteRequestParamsByType['cancel_orders'],
47
54
  ) {
@@ -104,11 +111,4 @@ export class EngineExecuteClient extends EngineBaseClient {
104
111
  await this.payloadBuilder.buildBurnNlpPayload(params),
105
112
  );
106
113
  }
107
-
108
- async placeOrders(params: EngineExecuteRequestParamsByType['place_orders']) {
109
- return this.execute(
110
- 'place_orders',
111
- await this.payloadBuilder.buildPlaceOrdersPayload(params),
112
- );
113
- }
114
114
  }
@@ -30,12 +30,17 @@ import {
30
30
  GetEngineMarketPriceResponse,
31
31
  GetEngineMarketPricesParams,
32
32
  GetEngineMarketPricesResponse,
33
+ GetEngineMaxBurnNlpAmountParams,
34
+ GetEngineMaxBurnNlpAmountResponse,
33
35
  GetEngineMaxMintNlpAmountParams,
34
36
  GetEngineMaxMintNlpAmountResponse,
35
37
  GetEngineMaxOrderSizeParams,
36
38
  GetEngineMaxOrderSizeResponse,
37
39
  GetEngineMaxWithdrawableParams,
38
40
  GetEngineMaxWithdrawableResponse,
41
+ GetEngineNlpLockedBalancesParams,
42
+ GetEngineNlpLockedBalancesResponse,
43
+ GetEngineNlpPoolInfoResponse,
39
44
  GetEngineOrderParams,
40
45
  GetEngineOrderResponse,
41
46
  GetEngineSubaccountFeeRatesParams,
@@ -56,6 +61,8 @@ import { mapProductEngineType } from './utils/productEngineTypeMappers';
56
61
  import {
57
62
  mapEngineMarketPrice,
58
63
  mapEngineServerIsolatedPositions,
64
+ mapEngineServerNlpLockedBalances,
65
+ mapEngineServerNlpPoolInfo,
59
66
  mapEngineServerOrder,
60
67
  mapEngineServerPerpProduct,
61
68
  mapEngineServerSpotProduct,
@@ -159,6 +166,9 @@ export class EngineQueryClient extends EngineBaseClient {
159
166
  const baseResponse = await this.query('subaccount_info', {
160
167
  subaccount: queryParams.subaccount,
161
168
  txns: JSON.stringify(queryParams.txns),
169
+ // Backend expects string variants of booleans
170
+ pre_state:
171
+ params.preState !== undefined ? String(params.preState) : undefined,
162
172
  });
163
173
 
164
174
  return mapSubaccountSummary(baseResponse);
@@ -381,6 +391,7 @@ export class EngineQueryClient extends EngineBaseClient {
381
391
  },
382
392
  {} as Record<number, BigDecimal>,
383
393
  ),
394
+ feeTier: baseResponse.fee_tier,
384
395
  };
385
396
  }
386
397
 
@@ -444,9 +455,16 @@ export class EngineQueryClient extends EngineBaseClient {
444
455
  subaccountOwner: params.subaccountOwner,
445
456
  subaccountName: params.subaccountName,
446
457
  }),
458
+ // Backend expects string variants of booleans
447
459
  spot_leverage:
448
460
  params.spotLeverage != null ? String(params.spotLeverage) : null,
449
461
  reduce_only: params.reduceOnly != null ? String(params.reduceOnly) : null,
462
+ isolated: params.isolated != null ? String(params.isolated) : null,
463
+ borrow_margin:
464
+ // This field is only relevant for isolated orders
465
+ params.isolated && params.isoBorrowMargin != null
466
+ ? String(params.isoBorrowMargin)
467
+ : null,
450
468
  });
451
469
 
452
470
  return toBigDecimal(baseResponse.max_order_size);
@@ -492,6 +510,24 @@ export class EngineQueryClient extends EngineBaseClient {
492
510
  return toBigDecimal(baseResponse.max_quote_amount);
493
511
  }
494
512
 
513
+ /**
514
+ * Retrieves the max amount of NLP that can be burned.
515
+ *
516
+ * @param params
517
+ */
518
+ async getMaxBurnNlpAmount(
519
+ params: GetEngineMaxBurnNlpAmountParams,
520
+ ): Promise<GetEngineMaxBurnNlpAmountResponse> {
521
+ const baseResponse = await this.query('max_nlp_burnable', {
522
+ sender: subaccountToHex({
523
+ subaccountOwner: params.subaccountOwner,
524
+ subaccountName: params.subaccountName,
525
+ }),
526
+ });
527
+
528
+ return toBigDecimal(baseResponse.max_nlp_amount);
529
+ }
530
+
495
531
  /**
496
532
  * Gets the currently linked signer for the subaccount
497
533
  * @param params
@@ -513,7 +549,7 @@ export class EngineQueryClient extends EngineBaseClient {
513
549
  }
514
550
 
515
551
  /**
516
- * Gets the insurance funds in USDC.
552
+ * Gets the insurance funds in USDT.
517
553
  * @returns
518
554
  */
519
555
  public async getInsurance(): Promise<GetEngineInsuranceResponse> {
@@ -521,4 +557,30 @@ export class EngineQueryClient extends EngineBaseClient {
521
557
 
522
558
  return toBigDecimal(baseResponse.insurance);
523
559
  }
560
+
561
+ /**
562
+ * Retrieves the NLP locked and unlocked balances for a subaccount.
563
+ *
564
+ * @param params
565
+ */
566
+ async getNlpLockedBalances(
567
+ params: GetEngineNlpLockedBalancesParams,
568
+ ): Promise<GetEngineNlpLockedBalancesResponse> {
569
+ const baseResponse = await this.query('nlp_locked_balances', {
570
+ subaccount: subaccountToHex({
571
+ subaccountOwner: params.subaccountOwner,
572
+ subaccountName: params.subaccountName,
573
+ }),
574
+ });
575
+
576
+ return mapEngineServerNlpLockedBalances(baseResponse);
577
+ }
578
+
579
+ /**
580
+ * Retrieves information about all NLP sub-pools
581
+ */
582
+ async getNlpPoolInfo(): Promise<GetEngineNlpPoolInfoResponse> {
583
+ const baseResponse = await this.query('nlp_pool_info', {});
584
+ return mapEngineServerNlpPoolInfo(baseResponse);
585
+ }
524
586
  }
package/src/endpoints.ts CHANGED
@@ -2,19 +2,19 @@ import { ChainEnv } from '@nadohq/shared';
2
2
 
3
3
  export const ENGINE_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {
4
4
  local: 'http://localhost:80',
5
- arbitrum: 'https://gateway.prod.vertexprotocol.com/v1',
6
- inkTestnet: 'https://gateway.test.nado-backend.xyz/v1',
5
+ inkTestnet: 'https://gateway.test.nado.xyz/v1',
6
+ inkMainnet: 'https://gateway.prod.nado.xyz/v1',
7
7
  };
8
8
 
9
9
  export const ENGINE_WS_CLIENT_ENDPOINTS: Record<ChainEnv, string> = {
10
10
  local: 'ws://localhost:80',
11
- arbitrum: 'wss://gateway.prod.vertexprotocol.com/v1/ws',
12
- inkTestnet: 'wss://gateway.test.nado-backend.xyz/v1/ws',
11
+ inkTestnet: 'wss://gateway.test.nado.xyz/v1/ws',
12
+ inkMainnet: 'wss://gateway.prod.nado.xyz/v1/ws',
13
13
  };
14
14
 
15
15
  export const ENGINE_WS_SUBSCRIPTION_CLIENT_ENDPOINTS: Record<ChainEnv, string> =
16
16
  {
17
17
  local: 'ws://localhost:80',
18
- arbitrum: 'wss://gateway.prod.vertexprotocol.com/v1/subscribe',
19
- inkTestnet: 'wss://gateway.test.nado-backend.xyz/v1/subscribe',
18
+ inkTestnet: 'wss://gateway.test.nado.xyz/v1/subscribe',
19
+ inkMainnet: 'wss://gateway.prod.nado.xyz/v1/subscribe',
20
20
  };
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './types';
2
- export * from './EngineClient';
3
1
  export * from './endpoints';
2
+ export * from './EngineClient';
3
+ export * from './types';
4
4
  export * from './utils';
@@ -7,6 +7,6 @@ export class EngineServerFailureError extends Error {
7
7
  | EngineServerQueryFailureResponse
8
8
  | EngineServerExecuteFailureResult,
9
9
  ) {
10
- super(`${responseData.error_code}: ${responseData.error_code}`);
10
+ super(`${responseData.error_code}: ${responseData.error}`);
11
11
  }
12
12
  }
@@ -49,7 +49,7 @@ export type EnginePlaceOrderParams = WithBaseEngineExecuteParams<{
49
49
  order: EngineOrderParams;
50
50
  // If not given, engine defaults to true (leverage/borrow enabled)
51
51
  spotLeverage?: boolean;
52
- // For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative USDC balance)
52
+ // For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative USDT balance)
53
53
  borrowMargin?: boolean;
54
54
  }>;
55
55
 
@@ -84,7 +84,14 @@ export type EngineMintNlpParams = WithBaseEngineExecuteParams<
84
84
  export type EngineBurnNlpParams =
85
85
  WithBaseEngineExecuteParams<EIP712BurnNlpParams>;
86
86
 
87
- export type EnginePlaceOrdersParams = EnginePlaceOrderParams[];
87
+ export type EnginePlaceOrdersParams = {
88
+ orders: EnginePlaceOrderParams[];
89
+ /**
90
+ * If `true`, aborts the batch after the first failed order; if `false`, remaining orders continue to execute.
91
+ * If not provided, the default value is `false`.
92
+ */
93
+ stopOnFailure?: boolean;
94
+ };
88
95
 
89
96
  export interface EngineExecuteRequestParamsByType {
90
97
  burn_nlp: EngineBurnNlpParams;
@@ -19,11 +19,16 @@ import {
19
19
  EngineServerTimeResponse,
20
20
  } from './serverQueryTypes';
21
21
 
22
- export type GetEngineSubaccountSummaryResponse = {
22
+ export interface GetEngineSubaccountSummaryResponse
23
+ extends SubaccountSummaryState {
23
24
  exists: boolean;
25
+ preState?: SubaccountSummaryState;
26
+ }
27
+
28
+ export interface SubaccountSummaryState {
24
29
  balances: BalanceWithProduct[];
25
30
  health: HealthStatusByType;
26
- };
31
+ }
27
32
 
28
33
  export type GetEngineSubaccountSummaryParams = Subaccount;
29
34
 
@@ -56,6 +61,7 @@ export interface GetEngineContractsResponse {
56
61
 
57
62
  export type GetEngineEstimatedSubaccountSummaryParams = Subaccount & {
58
63
  txs: SubaccountTx[];
64
+ preState?: boolean;
59
65
  };
60
66
 
61
67
  export type GetEngineNoncesParams = EngineServerNoncesParams;
@@ -82,12 +88,12 @@ export interface EngineSymbol {
82
88
  priceIncrement: BigDecimal;
83
89
  sizeIncrement: BigDecimal;
84
90
  minSize: BigDecimal;
85
- minDepth: BigDecimal;
86
- maxSpreadRate: BigDecimal;
87
91
  makerFeeRate: BigDecimal;
88
92
  takerFeeRate: BigDecimal;
89
93
  longWeightInitial: BigDecimal;
90
94
  longWeightMaintenance: BigDecimal;
95
+ // undefined when there is no max open interest limit (always undefined for spot products)
96
+ maxOpenInterest: BigDecimal | undefined;
91
97
  }
92
98
 
93
99
  export type GetEngineAllMarketsResponse = MarketWithProduct[];
@@ -166,6 +172,7 @@ export interface GetEngineSubaccountFeeRatesResponse {
166
172
  liquidationSequencerFee: BigDecimal;
167
173
  healthCheckSequencerFee: BigDecimal;
168
174
  takerSequencerFee: BigDecimal;
175
+ feeTier: number;
169
176
  }
170
177
 
171
178
  export interface EnginePriceTickLiquidity {
@@ -215,6 +222,10 @@ export interface GetEngineMaxOrderSizeParams extends Subaccount {
215
222
  // If not given, engine defaults to false. If true, the max order size will be capped to the subaccount's current position size;
216
223
  // If no position exists, it will return 0.
217
224
  reduceOnly?: boolean;
225
+ isolated?: boolean;
226
+ // If not given, engine defaults to true (do not borrow margin for isolated orders)
227
+ // Max order size query for `isolated` includes available transfer from the cross subaccount
228
+ isoBorrowMargin?: boolean;
218
229
  }
219
230
 
220
231
  export type GetEngineMaxOrderSizeResponse = BigDecimal;
@@ -251,3 +262,37 @@ export interface GetEngineMaxMintNlpAmountParams extends Subaccount {
251
262
  }
252
263
 
253
264
  export type GetEngineMaxMintNlpAmountResponse = BigDecimal;
265
+
266
+ export type GetEngineMaxBurnNlpAmountParams = Subaccount;
267
+
268
+ export type GetEngineMaxBurnNlpAmountResponse = BigDecimal;
269
+
270
+ export type GetEngineNlpLockedBalancesParams = Subaccount;
271
+
272
+ export interface EngineNlpBalance {
273
+ productId: number;
274
+ balance: BigDecimal;
275
+ }
276
+
277
+ export interface EngineNlpLockedBalance extends EngineNlpBalance {
278
+ unlockedAt: number;
279
+ }
280
+
281
+ export interface GetEngineNlpLockedBalancesResponse {
282
+ lockedBalances: EngineNlpLockedBalance[];
283
+ balanceLocked: EngineNlpBalance;
284
+ balanceUnlocked: EngineNlpBalance;
285
+ }
286
+
287
+ export interface NlpPool {
288
+ poolId: number;
289
+ subaccountHex: string;
290
+ ownerAddress: string;
291
+ balanceWeight: BigDecimal;
292
+ subaccountInfo: GetEngineSubaccountSummaryResponse;
293
+ openOrders: EngineOrder[];
294
+ }
295
+
296
+ export interface GetEngineNlpPoolInfoResponse {
297
+ nlpPools: NlpPool[];
298
+ }
@@ -1,8 +1,8 @@
1
- export * from './clientQueryTypes';
2
1
  export * from './clientExecuteTypes';
3
- export * from './serverQueryTypes';
4
- export * from './serverQueryModelTypes';
2
+ export * from './clientQueryTypes';
3
+ export * from './EngineServerFailureError';
5
4
  export * from './serverExecuteTypes';
6
- export * from './serverSubscriptionTypes';
5
+ export * from './serverQueryModelTypes';
6
+ export * from './serverQueryTypes';
7
7
  export * from './serverSubscriptionEventTypes';
8
- export * from './EngineServerFailureError';
8
+ export * from './serverSubscriptionTypes';
@@ -73,7 +73,7 @@ export interface EngineServerPlaceOrderParams {
73
73
  signature: string;
74
74
  // Engine defaults this to true
75
75
  spot_leverage: boolean | null;
76
- // For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative USDC balance)
76
+ // For isolated orders, this specifies whether margin can be borrowed (i.e. whether the cross account can have a negative USDT balance)
77
77
  borrow_margin: boolean | null;
78
78
  }
79
79
 
@@ -111,7 +111,14 @@ export interface EngineServerExecuteRequestByType {
111
111
  liquidate_subaccount: SignedTx<EIP712LiquidateSubaccountValues>;
112
112
  mint_nlp: WithSpotLeverage<SignedTx<EIP712MintNlpValues>>;
113
113
  place_order: EngineServerPlaceOrderParams;
114
- place_orders: EngineServerPlaceOrderParams[];
114
+ place_orders: {
115
+ orders: EngineServerPlaceOrderParams[];
116
+ /**
117
+ * If `true`, aborts the batch after the first failed order; if `false`, remaining orders continue to execute.
118
+ * If `null`, the default value is `false`.
119
+ */
120
+ stop_on_failure: boolean | null;
121
+ };
115
122
  transfer_quote: SignedTx<EIP712TransferQuoteValues>;
116
123
  withdraw_collateral: WithSpotLeverage<
117
124
  SignedTx<EIP712WithdrawCollateralValues>
@@ -81,3 +81,28 @@ export interface EngineServerPerpBalance {
81
81
  }
82
82
 
83
83
  export type EngineServerProductType = 'perp' | 'spot';
84
+
85
+ export interface EngineServerOrder {
86
+ product_id: number;
87
+ sender: string;
88
+ price_x18: string;
89
+ amount: string;
90
+ expiration: string;
91
+ nonce: string;
92
+ unfilled_amount: string;
93
+ digest: string;
94
+ placed_at: number;
95
+ order_type: string;
96
+ appendix: string;
97
+ }
98
+
99
+ export interface EngineServerNlpBalance {
100
+ product_id: number;
101
+ balance: {
102
+ amount: string;
103
+ };
104
+ }
105
+ export interface EngineServerNlpLockedBalance {
106
+ unlocked_at: number;
107
+ balance: EngineServerNlpBalance;
108
+ }