@polyester/sdk 0.36.0-devnet-20261120015159 → 0.36.0-devnet-20261120040128

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 (203) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/dist/client.d.ts +2 -0
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +2 -0
  5. package/dist/client.js.map +1 -1
  6. package/dist/gen/ai/v1/assistant_pb.d.ts +1 -1
  7. package/dist/gen/ai/v1/assistant_pb.js +1 -1
  8. package/dist/gen/alerts/v1/price_alerts_pb.d.ts +1 -1
  9. package/dist/gen/auth/v1/activity_pb.d.ts +1 -1
  10. package/dist/gen/auth/v1/address_book_pb.d.ts +1 -1
  11. package/dist/gen/auth/v1/address_book_pb.js +1 -1
  12. package/dist/gen/auth/v1/api_keys_pb.d.ts +1 -1
  13. package/dist/gen/auth/v1/auth_pb.d.ts +1 -1
  14. package/dist/gen/auth/v1/auth_pb.js +1 -1
  15. package/dist/gen/auth/v1/connected_apps_pb.d.ts +1 -1
  16. package/dist/gen/auth/v1/mfa_pb.d.ts +1 -1
  17. package/dist/gen/auth/v1/policies_pb.d.ts +1 -1
  18. package/dist/gen/auth/v1/profile_pb.d.ts +1 -1
  19. package/dist/gen/auth/v1/resolve_pb.d.ts +1 -1
  20. package/dist/gen/auth/v1/social_verification_pb.d.ts +1 -1
  21. package/dist/gen/auth/v1/subaccounts_pb.d.ts +1 -1
  22. package/dist/gen/auth/v1/subaccounts_pb.js +1 -1
  23. package/dist/gen/chain/analytics/v1/analytics_read_pb.d.ts +1 -1
  24. package/dist/gen/chain/deposit/v1/deposit_pb.d.ts +1 -1
  25. package/dist/gen/chain/guard/v1/guard_signer_pb.d.ts +1 -1
  26. package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.d.ts +1 -1
  27. package/dist/gen/chain/lifecycle/v1/types_pb.d.ts +1 -1
  28. package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts +1 -1
  29. package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts +1 -1
  30. package/dist/gen/chain/zipper/v1/reason_pb.d.ts +1 -1
  31. package/dist/gen/chain/zipper/v1/zipper_pb.d.ts +1 -1
  32. package/dist/gen/changelog/v1/changelog_pb.d.ts +1 -1
  33. package/dist/gen/checkpoints/v1/checkpoints_pb.d.ts +1 -1
  34. package/dist/gen/claims/v1/claims_pb.d.ts +1 -1
  35. package/dist/gen/fees/v1/fees_pb.d.ts +1 -1
  36. package/dist/gen/index.d.ts +1 -1
  37. package/dist/gen/index.js +27 -27
  38. package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +1 -1
  39. package/dist/gen/ledger/read/v1/statement_export_pb.d.ts +1 -1
  40. package/dist/gen/marketdata/v1/asset_info_pb.d.ts +1 -1
  41. package/dist/gen/marketdata/v1/heatmap_pb.d.ts +1 -1
  42. package/dist/gen/marketdata/v1/marketdata_pb.d.ts +1 -1
  43. package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts +1 -1
  44. package/dist/gen/notifications/v1/notifications_pb.d.ts +1 -1
  45. package/dist/gen/orderbook/v1/orderbook_pb.d.ts +1 -1
  46. package/dist/gen/orders/v1/orders_pb.d.ts +1 -1
  47. package/dist/gen/orders/v1/orders_read_pb.d.ts +1 -1
  48. package/dist/gen/polyester/api/v1/request_error_pb.d.ts +1 -1
  49. package/dist/gen/polyester/ratelimit/v1/types_pb.d.ts +1 -1
  50. package/dist/gen/polyester/type/v1/u128_pb.d.ts +1 -1
  51. package/dist/gen/privatews/v1/private_ws_pb.d.ts +1 -1
  52. package/dist/gen/ratelimit/v1/ratelimit_pb.d.ts +1 -1
  53. package/dist/gen/rewards/v1/rewards_pb.d.ts +1 -1
  54. package/dist/gen/strategies/v1/strategies_pb.d.ts +1 -1
  55. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts +1 -1
  56. package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.d.ts +1 -1
  57. package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts +1 -1
  58. package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.d.ts +1 -1
  59. package/dist/gen/swap/v1/swap_pb.d.ts +1 -1
  60. package/dist/gen/system/v1/system_pb.d.ts +1 -1
  61. package/dist/gen/tradews/v1/trade_ws_pb.d.ts +1 -1
  62. package/dist/gen/transfer/v1/dust_conversion_pb.d.ts +1 -1
  63. package/dist/gen/transfer/v1/internal_transfer_pb.d.ts +1 -1
  64. package/dist/gen/triggers/v1/triggers_pb.d.ts +1 -1
  65. package/dist/gen/vip/v1/vip_pb.d.ts +1 -1
  66. package/dist/index.d.ts +4 -1
  67. package/dist/services/account-activity/account-activity.js +1 -1
  68. package/dist/services/account-activity/account-activity.schemas.d.ts +6 -6
  69. package/dist/services/accounts/accounts.js +1 -1
  70. package/dist/services/accounts/accounts.schemas.js +1 -1
  71. package/dist/services/address-book/address-book.js +1 -1
  72. package/dist/services/address-book/address-book.schemas.d.ts +2 -2
  73. package/dist/services/api-keys/api-keys.js +1 -1
  74. package/dist/services/api-keys/api-keys.schemas.d.ts +3 -3
  75. package/dist/services/assistant/assistant-events.schemas.d.ts +28 -28
  76. package/dist/services/assistant/assistant.js +1 -1
  77. package/dist/services/assistant/assistant.schemas.d.ts +1 -1
  78. package/dist/services/auth/profile/profile.js +1 -1
  79. package/dist/services/auto-withdraw/auto-withdraw.js +1 -1
  80. package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts.map +1 -1
  81. package/dist/services/auto-withdraw/auto-withdraw.schemas.js +5 -12
  82. package/dist/services/auto-withdraw/auto-withdraw.schemas.js.map +1 -1
  83. package/dist/services/balances/balances.js +1 -1
  84. package/dist/services/balances/balances.schemas.d.ts +3 -3
  85. package/dist/services/candles/candles.js +1 -1
  86. package/dist/services/chain-analytics/chain-analytics.js +1 -1
  87. package/dist/services/changelog/changelog.js +1 -1
  88. package/dist/services/changelog/changelog.schemas.d.ts +38 -38
  89. package/dist/services/checkpoints/checkpoints.js +1 -1
  90. package/dist/services/claims/claims.js +1 -1
  91. package/dist/services/claims/claims.schemas.d.ts +2 -2
  92. package/dist/services/claims/claims.schemas.js +1 -1
  93. package/dist/services/connected-apps/connected-apps.js +1 -1
  94. package/dist/services/deposit/deposit.js +1 -1
  95. package/dist/services/dust-conversion/dust-conversion.js +1 -1
  96. package/dist/services/dust-conversion/dust-conversion.schemas.d.ts +8 -8
  97. package/dist/services/dust-conversion/dust-conversion.schemas.js +1 -1
  98. package/dist/services/fees/fees.js +1 -1
  99. package/dist/services/guard-signer/guard-signer.js +1 -1
  100. package/dist/services/heatmap/heatmap.js +1 -1
  101. package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
  102. package/dist/services/internal-transfers/internal-transfers.js +1 -1
  103. package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +6 -6
  104. package/dist/services/lifecycle/lifecycle.js +1 -1
  105. package/dist/services/lifecycle/lifecycle.schemas.d.ts +66 -66
  106. package/dist/services/lifecycle/lifecycle.schemas.js +2 -2
  107. package/dist/services/market-data/market-data.js +1 -1
  108. package/dist/services/market-overview/market-overview.js +1 -1
  109. package/dist/services/market-overview/market-overview.schemas.js +1 -1
  110. package/dist/services/notifications/notifications.js +1 -1
  111. package/dist/services/orderbook/orderbook.js +1 -1
  112. package/dist/services/orders/order-errors.schemas.d.ts +9 -9
  113. package/dist/services/orders/order-errors.schemas.js +1 -1
  114. package/dist/services/orders/orders-batch.schemas.d.ts +97 -97
  115. package/dist/services/orders/orders-batch.schemas.js +1 -1
  116. package/dist/services/orders/orders-input.schemas.d.ts +16 -16
  117. package/dist/services/orders/orders-input.schemas.js +1 -1
  118. package/dist/services/orders/orders-modify.schemas.js +1 -1
  119. package/dist/services/orders/orders-output.schemas.d.ts +16 -16
  120. package/dist/services/orders/orders-risk.schemas.js +2 -2
  121. package/dist/services/orders/orders.js +2 -2
  122. package/dist/services/policies/api-key-policies/api-key-policies.js +1 -1
  123. package/dist/services/policies/shared.codecs.js +1 -1
  124. package/dist/services/policies/subaccount-policies/subaccount-policies.js +1 -1
  125. package/dist/services/price-alerts/price-alerts.js +1 -1
  126. package/dist/services/rate-limits/rate-limits.js +1 -1
  127. package/dist/services/rewards/rewards.js +1 -1
  128. package/dist/services/rewards/rewards.schemas.d.ts +4 -4
  129. package/dist/services/social-verification/social-verification.js +1 -1
  130. package/dist/services/social-verification/social-verification.schemas.js +1 -1
  131. package/dist/services/statement-exports/statement-exports.js +1 -1
  132. package/dist/services/statement-exports/statement-exports.schemas.d.ts +6 -6
  133. package/dist/services/strategies/strategies.js +1 -1
  134. package/dist/services/strategies/strategies.schemas.d.ts +1 -1
  135. package/dist/services/subaccounts/subaccounts.js +2 -2
  136. package/dist/services/subaccounts/subaccounts.schemas.d.ts +16 -16
  137. package/dist/services/swap/service.d.ts +8 -0
  138. package/dist/services/swap/service.d.ts.map +1 -0
  139. package/dist/services/swap/service.js +9 -0
  140. package/dist/services/swap/service.js.map +1 -0
  141. package/dist/services/swap/swap.codecs.d.ts +19 -0
  142. package/dist/services/swap/swap.codecs.d.ts.map +1 -0
  143. package/dist/services/swap/swap.codecs.js +39 -0
  144. package/dist/services/swap/swap.codecs.js.map +1 -0
  145. package/dist/services/swap/swap.d.ts +51 -0
  146. package/dist/services/swap/swap.d.ts.map +1 -0
  147. package/dist/services/swap/swap.js +71 -0
  148. package/dist/services/swap/swap.js.map +1 -0
  149. package/dist/services/swap/swap.schemas.d.ts +520 -0
  150. package/dist/services/swap/swap.schemas.d.ts.map +1 -0
  151. package/dist/services/swap/swap.schemas.js +213 -0
  152. package/dist/services/swap/swap.schemas.js.map +1 -0
  153. package/dist/services/swap/swap.types.d.ts +3 -0
  154. package/dist/services/system/system.js +1 -1
  155. package/dist/services/system/system.schemas.d.ts +13 -13
  156. package/dist/services/trades/trades.js +1 -1
  157. package/dist/services/trades/trades.schemas.d.ts +1 -1
  158. package/dist/services/trading-withdraws/trading-withdraws.js +1 -1
  159. package/dist/services/trading-withdraws/trading-withdraws.schemas.js +1 -1
  160. package/dist/services/trading-withdraws/wallet-message.js +1 -1
  161. package/dist/services/transfers/transfers.js +1 -1
  162. package/dist/services/transfers/transfers.schemas.d.ts +1 -1
  163. package/dist/services/triggers/trigger-child-order.schemas.js +2 -2
  164. package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
  165. package/dist/services/triggers/trigger-input.schemas.js +2 -2
  166. package/dist/services/triggers/triggers-output.schemas.d.ts +53 -53
  167. package/dist/services/triggers/triggers.js +1 -1
  168. package/dist/services/vip/vip.js +1 -1
  169. package/dist/services/vip/vip.schemas.d.ts +3 -3
  170. package/dist/services/vip/vip.schemas.js +1 -1
  171. package/dist/services/zipper/zipper.js +1 -1
  172. package/dist/services/zipper/zipper.schemas.js +1 -1
  173. package/dist/shared/connect-error-mapping.d.ts.map +1 -1
  174. package/dist/shared/connect-error-mapping.js +1 -0
  175. package/dist/shared/connect-error-mapping.js.map +1 -1
  176. package/dist/shared/decimal-surface.d.ts.map +1 -1
  177. package/dist/shared/decimal-surface.js +11 -1
  178. package/dist/shared/decimal-surface.js.map +1 -1
  179. package/dist/shared/error-detail.d.ts +16 -4
  180. package/dist/shared/error-detail.d.ts.map +1 -1
  181. package/dist/shared/error-detail.js +1 -0
  182. package/dist/shared/error-detail.js.map +1 -1
  183. package/dist/shared/error-details/alerts.js +1 -1
  184. package/dist/shared/error-details/assistant.js +1 -1
  185. package/dist/shared/error-details/auth.js +1 -1
  186. package/dist/shared/error-details/claims.js +1 -1
  187. package/dist/shared/error-details/internal-transfer.js +1 -1
  188. package/dist/shared/error-details/ledger.js +1 -1
  189. package/dist/shared/error-details/market-overview.js +1 -1
  190. package/dist/shared/error-details/notifications.js +1 -1
  191. package/dist/shared/error-details/orders.js +1 -1
  192. package/dist/shared/error-details/profile.js +1 -1
  193. package/dist/shared/error-details/rate-limit.js +1 -1
  194. package/dist/shared/error-details/strategies.js +1 -1
  195. package/dist/shared/error-details/swap.js +22 -0
  196. package/dist/shared/error-details/swap.js.map +1 -0
  197. package/dist/shared/error-details/withdraw.js +1 -1
  198. package/dist/shared/rate-limit.schemas.d.ts +1 -1
  199. package/dist/shared/rate-limit.schemas.js +1 -1
  200. package/dist/wired-services.d.ts.map +1 -1
  201. package/dist/wired-services.js +23 -21
  202. package/dist/wired-services.js.map +1 -1
  203. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","names":[],"sources":["../../../src/services/swap/service.ts"],"mappings":";;;;cAIa,cAAW,QAAX,kBAAW"}
@@ -0,0 +1,9 @@
1
+ import { defineService } from "../../core-client.js";
2
+ import { SwapService } from "./swap.js";
3
+ //#region src/services/swap/service.ts
4
+ /** Returns the client's SwapService, creating it on first use. */
5
+ const swapService = defineService((context) => new SwapService(context.transports, context.resolver));
6
+ //#endregion
7
+ export { swapService };
8
+
9
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","names":[],"sources":["../../../src/services/swap/service.ts"],"sourcesContent":["import { defineService } from \"../../core-client.js\";\nimport { SwapService } from \"./swap.js\";\n\n/** Returns the client's SwapService, creating it on first use. */\nexport const swapService = defineService(\n (context) => new SwapService(context.transports, context.resolver),\n);\n"],"mappings":";;;;AAIA,MAAa,cAAc,eACtB,YAAY,IAAI,YAAY,QAAQ,YAAY,QAAQ,QAAQ,CACrE"}
@@ -0,0 +1,19 @@
1
+ import { ErrorCode } from "../../gen/swap/v1/swap_pb.js";
2
+ //#region src/services/swap/swap.codecs.d.ts
3
+ declare const SWAP_STATUS_VALUES: readonly ["executing", "completed", "partially_completed", "failed", "reconciling"];
4
+ /**
5
+ * `executing` places, fills and settles orders; `reconciling` is establishing an order's outcome
6
+ * (balances already show settled fills). `completed`, `partially_completed` and `failed` are
7
+ * terminal: anything not traded stays on the account.
8
+ */
9
+ type SwapStatus = (typeof SWAP_STATUS_VALUES)[number];
10
+ declare const SWAP_REASON_VALUES: readonly ["insufficient_balance", "price_protection", "market_unavailable", "order_size_out_of_range", "rate_limited", "order_rejected", "expired", "minimum_not_met", "max_order_quantity"];
11
+ /** Why a `partially_completed` or `failed` swap did not trade its whole amount. */
12
+ type SwapReason = (typeof SWAP_REASON_VALUES)[number];
13
+ declare const SWAP_ORDER_STATUS_VALUES: readonly ["placing", "placed", "refused", "not_placed", "unconfirmed"];
14
+ type SwapOrderStatus = (typeof SWAP_ORDER_STATUS_VALUES)[number];
15
+ /** Swap API error code on a rejected call's `detail` (service `swap`), e.g. `QUOTE_EXPIRED`. */
16
+ type SwapErrorCode = keyof typeof ErrorCode;
17
+ //#endregion
18
+ export { SWAP_ORDER_STATUS_VALUES, SWAP_REASON_VALUES, SWAP_STATUS_VALUES, SwapErrorCode, SwapOrderStatus, SwapReason, SwapStatus };
19
+ //# sourceMappingURL=swap.codecs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swap.codecs.d.ts","names":[],"sources":["../../../src/services/swap/swap.codecs.ts"],"mappings":";;cAGa;;;;;;KAYD,qBAAqB;cAEpB;;KAYD,qBAAqB;cAEpB;KAOD,0BAA0B;;KAG1B,6BAA6B"}
@@ -0,0 +1,39 @@
1
+ import "../../gen/swap/v1/swap_pb.js";
2
+ //#region src/services/swap/swap.codecs.ts
3
+ const SwapStatusCodec = { protoToOutput: {
4
+ [0]: "unspecified",
5
+ [1]: "executing",
6
+ [2]: "completed",
7
+ [3]: "partially_completed",
8
+ [4]: "failed",
9
+ [5]: "reconciling"
10
+ } };
11
+ const SwapReasonCodec = { protoToOutput: {
12
+ [0]: "unspecified",
13
+ [1]: "insufficient_balance",
14
+ [2]: "price_protection",
15
+ [3]: "market_unavailable",
16
+ [4]: "order_size_out_of_range",
17
+ [5]: "rate_limited",
18
+ [6]: "order_rejected",
19
+ [7]: "expired",
20
+ [8]: "minimum_not_met",
21
+ [9]: "max_order_quantity"
22
+ } };
23
+ const SwapOrderStatusCodec = { protoToOutput: {
24
+ [0]: "unspecified",
25
+ [1]: "placing",
26
+ [2]: "placed",
27
+ [3]: "refused",
28
+ [4]: "not_placed",
29
+ [5]: "unconfirmed"
30
+ } };
31
+ const SwapSideCodec = { protoToOutput: {
32
+ [0]: "unspecified",
33
+ [1]: "buy",
34
+ [2]: "sell"
35
+ } };
36
+ //#endregion
37
+ export { SwapOrderStatusCodec, SwapReasonCodec, SwapSideCodec, SwapStatusCodec };
38
+
39
+ //# sourceMappingURL=swap.codecs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swap.codecs.js","names":[],"sources":["../../../src/services/swap/swap.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/swap/v1/swap_pb.js\";\nimport type { ProtoToOutput } from \"../../utils/types.js\";\n\nexport const SWAP_STATUS_VALUES = [\n \"executing\",\n \"completed\",\n \"partially_completed\",\n \"failed\",\n \"reconciling\",\n] as const;\n/**\n * `executing` places, fills and settles orders; `reconciling` is establishing an order's outcome\n * (balances already show settled fills). `completed`, `partially_completed` and `failed` are\n * terminal: anything not traded stays on the account.\n */\nexport type SwapStatus = (typeof SWAP_STATUS_VALUES)[number];\n\nexport const SWAP_REASON_VALUES = [\n \"insufficient_balance\",\n \"price_protection\",\n \"market_unavailable\",\n \"order_size_out_of_range\",\n \"rate_limited\",\n \"order_rejected\",\n \"expired\",\n \"minimum_not_met\",\n \"max_order_quantity\",\n] as const;\n/** Why a `partially_completed` or `failed` swap did not trade its whole amount. */\nexport type SwapReason = (typeof SWAP_REASON_VALUES)[number];\n\nexport const SWAP_ORDER_STATUS_VALUES = [\n \"placing\",\n \"placed\",\n \"refused\",\n \"not_placed\",\n \"unconfirmed\",\n] as const;\nexport type SwapOrderStatus = (typeof SWAP_ORDER_STATUS_VALUES)[number];\n\n/** Swap API error code on a rejected call's `detail` (service `swap`), e.g. `QUOTE_EXPIRED`. */\nexport type SwapErrorCode = keyof typeof Proto.ErrorCode;\n\nexport const SwapStatusCodec = {\n protoToOutput: {\n [Proto.SwapStatus.STATUS_UNSPECIFIED]: \"unspecified\",\n [Proto.SwapStatus.EXECUTING]: \"executing\",\n [Proto.SwapStatus.COMPLETED]: \"completed\",\n [Proto.SwapStatus.PARTIALLY_COMPLETED]: \"partially_completed\",\n [Proto.SwapStatus.FAILED]: \"failed\",\n [Proto.SwapStatus.RECONCILING]: \"reconciling\",\n } satisfies ProtoToOutput<Proto.SwapStatus, SwapStatus>,\n} as const;\n\nexport const SwapReasonCodec = {\n protoToOutput: {\n [Proto.SwapReason.REASON_UNSPECIFIED]: \"unspecified\",\n [Proto.SwapReason.INSUFFICIENT_BALANCE]: \"insufficient_balance\",\n [Proto.SwapReason.PRICE_PROTECTION]: \"price_protection\",\n [Proto.SwapReason.MARKET_UNAVAILABLE]: \"market_unavailable\",\n [Proto.SwapReason.ORDER_SIZE_OUT_OF_RANGE]: \"order_size_out_of_range\",\n [Proto.SwapReason.RATE_LIMITED]: \"rate_limited\",\n [Proto.SwapReason.ORDER_REJECTED]: \"order_rejected\",\n [Proto.SwapReason.EXPIRED]: \"expired\",\n [Proto.SwapReason.MINIMUM_NOT_MET]: \"minimum_not_met\",\n [Proto.SwapReason.MAX_ORDER_QUANTITY]: \"max_order_quantity\",\n } satisfies ProtoToOutput<Proto.SwapReason, SwapReason>,\n} as const;\n\nexport const SwapOrderStatusCodec = {\n protoToOutput: {\n [Proto.SwapOrderStatus.ORDER_STATUS_UNSPECIFIED]: \"unspecified\",\n [Proto.SwapOrderStatus.PLACING]: \"placing\",\n [Proto.SwapOrderStatus.PLACED]: \"placed\",\n [Proto.SwapOrderStatus.REFUSED]: \"refused\",\n [Proto.SwapOrderStatus.NOT_PLACED]: \"not_placed\",\n [Proto.SwapOrderStatus.UNCONFIRMED]: \"unconfirmed\",\n } satisfies ProtoToOutput<Proto.SwapOrderStatus, SwapOrderStatus>,\n} as const;\n\nexport const SwapSideCodec = {\n protoToOutput: {\n [Proto.Side.SIDE_UNSPECIFIED]: \"unspecified\",\n [Proto.Side.BUY]: \"buy\",\n [Proto.Side.SELL]: \"sell\",\n } satisfies ProtoToOutput<Proto.Side, \"buy\" | \"sell\">,\n} as const;\n"],"mappings":";;AA2CA,MAAa,kBAAkB,EAC3B,eAAe;EAC4B,IAAA;EACT,IAAA;EACA,IAAA;EACU,IAAA;EACb,IAAA;EACK,IAAA;AACpC,EACJ;AAEA,MAAa,kBAAkB,EAC3B,eAAe;EAC4B,IAAA;EACE,IAAA;EACJ,IAAA;EACE,IAAA;EACK,IAAA;EACX,IAAA;EACE,IAAA;EACP,IAAA;EACQ,IAAA;EACG,IAAA;AAC3C,EACJ;AAEA,MAAa,uBAAuB,EAChC,eAAe;EACuC,IAAA;EACjB,IAAA;EACD,IAAA;EACC,IAAA;EACG,IAAA;EACC,IAAA;AACzC,EACJ;AAEA,MAAa,gBAAgB,EACzB,eAAe;EACoB,IAAA;EACb,IAAA;EACC,IAAA;AACvB,EACJ"}
@@ -0,0 +1,51 @@
1
+ import { AuthApiTransports } from "../../shared/transports.js";
2
+ import { PolyesterRequestOptions } from "../../shared/request-options.js";
3
+ import { SubaccountResolver } from "../subaccount-resolver.js";
4
+ import { CreateSwapInput, GetSwapInput, QuoteSwapInput, Swap, SwapQuote } from "./swap.schemas.js";
5
+ //#region src/services/swap/swap.d.ts
6
+ /**
7
+ * Converts one asset of an account's Trading balance into another with immediate-or-cancel spot
8
+ * orders on that account, at its spot taker fee and no other fee. Every part that trades nets at
9
+ * least the accepted `minAmountOut` rate; anything that cannot stays on the account. Sized by
10
+ * source amount only. Flow: `quote`, then `create` with the quote's `minAmountOut` and
11
+ * `expiresAt`, then `get` until `isTerminal`; a direct swap usually finishes within seconds.
12
+ *
13
+ * Needs a session or a signed API key with the `swap` policy action; subaccount members need the
14
+ * `swap` permission. The swap's orders also follow the subaccount's spot trading policy.
15
+ * Rejection codes are on the error's `detail` (service `swap`). Available on devnet only.
16
+ */
17
+ declare class SwapService {
18
+ #private;
19
+ constructor(transports: AuthApiTransports, resolver?: SubaccountResolver);
20
+ /**
21
+ * Prices a swap against current order-book depth and the account's taker fee. Reserves
22
+ * nothing. `AMOUNT_OUT_OF_RANGE` throws `ValidationError` with the current `minAmount` and
23
+ * `maxAmount` on its `detail` when known; `ROUTE_UNSUPPORTED`, `DIRECTION_UNSUPPORTED` and
24
+ * `PROTECTION_UNACHIEVABLE` throw `PreconditionFailedError`; `QUOTE_UNAVAILABLE` throws
25
+ * `ServiceUnavailableError` (retry later).
26
+ */
27
+ quote(input: QuoteSwapInput, options?: PolyesterRequestOptions): Promise<SwapQuote>;
28
+ /**
29
+ * Creates the swap for `idempotencyKey` and executes it at once, after re-pricing: it is
30
+ * created only while the quote is unexpired and `minAmountOut` is achievable. The result is
31
+ * usually still `executing`; follow it with `get`.
32
+ *
33
+ * Idempotent per caller and key: an unknown outcome (`TimeoutError`, `ServiceUnavailableError`,
34
+ * `NetworkError`, all `retryable`) is settled by calling `create` again with the same input,
35
+ * which returns the same swap, or by `get({ idempotencyKey })`. Pass `account` explicitly
36
+ * (e.g. from the quote's `subaccountId`) so a retry after the active subaccount changes sends
37
+ * the same request. Reusing the key with
38
+ * different input throws `AlreadyExistsError` (`IDEMPOTENCY_CONFLICT`, with the original
39
+ * `swapId` on `detail`). `QUOTE_EXPIRED` and `PROTECTION_UNACHIEVABLE` throw
40
+ * `PreconditionFailedError` and create nothing: quote again with a new key.
41
+ */
42
+ create(input: CreateSwapInput, options?: PolyesterRequestOptions): Promise<Swap>;
43
+ /**
44
+ * Reads one of the caller's swaps by `swapId` or the `idempotencyKey` it was created with.
45
+ * An unknown one throws `ResourceNotFoundError` (`SWAP_NOT_FOUND`).
46
+ */
47
+ get(input: GetSwapInput, options?: PolyesterRequestOptions): Promise<Swap>;
48
+ }
49
+ //#endregion
50
+ export { SwapService };
51
+ //# sourceMappingURL=swap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swap.d.ts","names":[],"sources":["../../../src/services/swap/swap.ts"],"mappings":";;;;;;;;;;;;;;;;cAkCa;;EAIG,YAAA,YAAY,mBAAmB,WAAW;;;;;;;;EAYhD,MAAM,OAAO,gBAAgB,UAAU,0BAA0B,QAAQ;;;;;;;;;;;;;;;EA0BzE,OAAO,OAAO,iBAAiB,UAAU,0BAA0B,QAAQ;;;;;EAgB3E,IAAI,OAAO,cAAc,UAAU,0BAA0B,QAAQ"}
@@ -0,0 +1,71 @@
1
+ import { SwapService as SwapService$1 } from "../../gen/swap/v1/swap_pb.js";
2
+ import { parse } from "../../shared/validation.js";
3
+ import { removeUndefined } from "../../utils/remove-undefined.js";
4
+ import { toConnectCallOptions } from "../../shared/request-options.js";
5
+ import { resolveAccountScopedInput } from "../subaccount-resolver.js";
6
+ import { CreateSwapInputSchema, GetSwapInputSchema, QuoteSwapInputSchema, SwapQuoteSchema, SwapSchema } from "./swap.schemas.js";
7
+ import { createClient } from "@connectrpc/connect";
8
+ //#region src/services/swap/swap.ts
9
+ /**
10
+ * Converts one asset of an account's Trading balance into another with immediate-or-cancel spot
11
+ * orders on that account, at its spot taker fee and no other fee. Every part that trades nets at
12
+ * least the accepted `minAmountOut` rate; anything that cannot stays on the account. Sized by
13
+ * source amount only. Flow: `quote`, then `create` with the quote's `minAmountOut` and
14
+ * `expiresAt`, then `get` until `isTerminal`; a direct swap usually finishes within seconds.
15
+ *
16
+ * Needs a session or a signed API key with the `swap` policy action; subaccount members need the
17
+ * `swap` permission. The swap's orders also follow the subaccount's spot trading policy.
18
+ * Rejection codes are on the error's `detail` (service `swap`). Available on devnet only.
19
+ */
20
+ var SwapService = class {
21
+ #client;
22
+ #resolver;
23
+ constructor(transports, resolver) {
24
+ this.#client = createClient(SwapService$1, transports.authApi);
25
+ this.#resolver = resolver;
26
+ }
27
+ /**
28
+ * Prices a swap against current order-book depth and the account's taker fee. Reserves
29
+ * nothing. `AMOUNT_OUT_OF_RANGE` throws `ValidationError` with the current `minAmount` and
30
+ * `maxAmount` on its `detail` when known; `ROUTE_UNSUPPORTED`, `DIRECTION_UNSUPPORTED` and
31
+ * `PROTECTION_UNACHIEVABLE` throw `PreconditionFailedError`; `QUOTE_UNAVAILABLE` throws
32
+ * `ServiceUnavailableError` (retry later).
33
+ */
34
+ async quote(input, options) {
35
+ const request = parse(QuoteSwapInputSchema, resolveAccountScopedInput(input, this.#resolver));
36
+ const response = await this.#client.quoteSwap(removeUndefined(request), toConnectCallOptions(options));
37
+ return parse(SwapQuoteSchema, response.quote);
38
+ }
39
+ /**
40
+ * Creates the swap for `idempotencyKey` and executes it at once, after re-pricing: it is
41
+ * created only while the quote is unexpired and `minAmountOut` is achievable. The result is
42
+ * usually still `executing`; follow it with `get`.
43
+ *
44
+ * Idempotent per caller and key: an unknown outcome (`TimeoutError`, `ServiceUnavailableError`,
45
+ * `NetworkError`, all `retryable`) is settled by calling `create` again with the same input,
46
+ * which returns the same swap, or by `get({ idempotencyKey })`. Pass `account` explicitly
47
+ * (e.g. from the quote's `subaccountId`) so a retry after the active subaccount changes sends
48
+ * the same request. Reusing the key with
49
+ * different input throws `AlreadyExistsError` (`IDEMPOTENCY_CONFLICT`, with the original
50
+ * `swapId` on `detail`). `QUOTE_EXPIRED` and `PROTECTION_UNACHIEVABLE` throw
51
+ * `PreconditionFailedError` and create nothing: quote again with a new key.
52
+ */
53
+ async create(input, options) {
54
+ const request = parse(CreateSwapInputSchema, resolveAccountScopedInput(input, this.#resolver));
55
+ const response = await this.#client.createSwap(removeUndefined(request), toConnectCallOptions(options));
56
+ return parse(SwapSchema, response.swap);
57
+ }
58
+ /**
59
+ * Reads one of the caller's swaps by `swapId` or the `idempotencyKey` it was created with.
60
+ * An unknown one throws `ResourceNotFoundError` (`SWAP_NOT_FOUND`).
61
+ */
62
+ async get(input, options) {
63
+ const request = parse(GetSwapInputSchema, input);
64
+ const response = await this.#client.getSwap(request, toConnectCallOptions(options));
65
+ return parse(SwapSchema, response.swap);
66
+ }
67
+ };
68
+ //#endregion
69
+ export { SwapService };
70
+
71
+ //# sourceMappingURL=swap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swap.js","names":["#client","Proto.SwapService","#resolver"],"sources":["../../../src/services/swap/swap.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/swap/v1/swap_pb.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport { resolveAccountScopedInput, type SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSwapInputSchema,\n GetSwapInputSchema,\n QuoteSwapInputSchema,\n SwapQuoteSchema,\n SwapSchema,\n type CreateSwapInput,\n type GetSwapInput,\n type QuoteSwapInput,\n type Swap,\n type SwapQuote,\n} from \"./swap.schemas.js\";\n\n/**\n * Converts one asset of an account's Trading balance into another with immediate-or-cancel spot\n * orders on that account, at its spot taker fee and no other fee. Every part that trades nets at\n * least the accepted `minAmountOut` rate; anything that cannot stays on the account. Sized by\n * source amount only. Flow: `quote`, then `create` with the quote's `minAmountOut` and\n * `expiresAt`, then `get` until `isTerminal`; a direct swap usually finishes within seconds.\n *\n * Needs a session or a signed API key with the `swap` policy action; subaccount members need the\n * `swap` permission. The swap's orders also follow the subaccount's spot trading policy.\n * Rejection codes are on the error's `detail` (service `swap`). Available on devnet only.\n */\nexport class SwapService {\n #client: Client<typeof Proto.SwapService>;\n #resolver?: SubaccountResolver;\n\n constructor(transports: AuthApiTransports, resolver?: SubaccountResolver) {\n this.#client = createClient(Proto.SwapService, transports.authApi);\n this.#resolver = resolver;\n }\n\n /**\n * Prices a swap against current order-book depth and the account's taker fee. Reserves\n * nothing. `AMOUNT_OUT_OF_RANGE` throws `ValidationError` with the current `minAmount` and\n * `maxAmount` on its `detail` when known; `ROUTE_UNSUPPORTED`, `DIRECTION_UNSUPPORTED` and\n * `PROTECTION_UNACHIEVABLE` throw `PreconditionFailedError`; `QUOTE_UNAVAILABLE` throws\n * `ServiceUnavailableError` (retry later).\n */\n async quote(input: QuoteSwapInput, options?: PolyesterRequestOptions): Promise<SwapQuote> {\n const request = parse(\n QuoteSwapInputSchema,\n resolveAccountScopedInput(input, this.#resolver),\n );\n const response = await this.#client.quoteSwap(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(SwapQuoteSchema, response.quote);\n }\n\n /**\n * Creates the swap for `idempotencyKey` and executes it at once, after re-pricing: it is\n * created only while the quote is unexpired and `minAmountOut` is achievable. The result is\n * usually still `executing`; follow it with `get`.\n *\n * Idempotent per caller and key: an unknown outcome (`TimeoutError`, `ServiceUnavailableError`,\n * `NetworkError`, all `retryable`) is settled by calling `create` again with the same input,\n * which returns the same swap, or by `get({ idempotencyKey })`. Pass `account` explicitly\n * (e.g. from the quote's `subaccountId`) so a retry after the active subaccount changes sends\n * the same request. Reusing the key with\n * different input throws `AlreadyExistsError` (`IDEMPOTENCY_CONFLICT`, with the original\n * `swapId` on `detail`). `QUOTE_EXPIRED` and `PROTECTION_UNACHIEVABLE` throw\n * `PreconditionFailedError` and create nothing: quote again with a new key.\n */\n async create(input: CreateSwapInput, options?: PolyesterRequestOptions): Promise<Swap> {\n const request = parse(\n CreateSwapInputSchema,\n resolveAccountScopedInput(input, this.#resolver),\n );\n const response = await this.#client.createSwap(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(SwapSchema, response.swap);\n }\n\n /**\n * Reads one of the caller's swaps by `swapId` or the `idempotencyKey` it was created with.\n * An unknown one throws `ResourceNotFoundError` (`SWAP_NOT_FOUND`).\n */\n async get(input: GetSwapInput, options?: PolyesterRequestOptions): Promise<Swap> {\n const request = parse(GetSwapInputSchema, input);\n const response = await this.#client.getSwap(request, toConnectCallOptions(options));\n return parse(SwapSchema, response.swap);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkCA,IAAa,cAAb,MAAyB;CACrB;CACA;CAEA,YAAY,YAA+B,UAA+B;EACtE,KAAKA,UAAU,aAAaC,eAAmB,WAAW,OAAO;EACjE,KAAKC,YAAY;CACrB;;;;;;;;CASA,MAAM,MAAM,OAAuB,SAAuD;EACtF,MAAM,UAAU,MACZ,sBACA,0BAA0B,OAAO,KAAKA,SAAS,CACnD;EACA,MAAM,WAAW,MAAM,KAAKF,QAAQ,UAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,iBAAiB,SAAS,KAAK;CAChD;;;;;;;;;;;;;;;CAgBA,MAAM,OAAO,OAAwB,SAAkD;EACnF,MAAM,UAAU,MACZ,uBACA,0BAA0B,OAAO,KAAKE,SAAS,CACnD;EACA,MAAM,WAAW,MAAM,KAAKF,QAAQ,WAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,YAAY,SAAS,IAAI;CAC1C;;;;;CAMA,MAAM,IAAI,OAAqB,SAAkD;EAC7E,MAAM,UAAU,MAAM,oBAAoB,KAAK;EAC/C,MAAM,WAAW,MAAM,KAAKA,QAAQ,QAAQ,SAAS,qBAAqB,OAAO,CAAC;EAClF,OAAO,MAAM,YAAY,SAAS,IAAI;CAC1C;AACJ"}