@polyester/sdk 0.21.0 → 0.22.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 (63) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +5 -0
  3. package/dist/catalogs/market-data-catalog.d.ts +5 -14
  4. package/dist/catalogs/market-data-catalog.d.ts.map +1 -1
  5. package/dist/catalogs/market-data-catalog.js +1 -11
  6. package/dist/catalogs/market-data-catalog.js.map +1 -1
  7. package/dist/catalogs/snapshot-validation.js +3 -1
  8. package/dist/catalogs/snapshot-validation.js.map +1 -1
  9. package/dist/catalogs/zipper-catalog.js +1 -9
  10. package/dist/catalogs/zipper-catalog.js.map +1 -1
  11. package/dist/environment.js +43 -1
  12. package/dist/environment.js.map +1 -1
  13. package/dist/gen/chain/zipper/v1/zipper_pb.d.ts +0 -6
  14. package/dist/gen/chain/zipper/v1/zipper_pb.d.ts.map +1 -1
  15. package/dist/gen/chain/zipper/v1/zipper_pb.js +1 -1
  16. package/dist/gen/chain/zipper/v1/zipper_pb.js.map +1 -1
  17. package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts +236 -8
  18. package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts.map +1 -1
  19. package/dist/gen/marketoverview/v1/marketoverview_pb.js +50 -2
  20. package/dist/gen/marketoverview/v1/marketoverview_pb.js.map +1 -1
  21. package/dist/gen/orders/v1/orders_pb.d.ts +9 -6
  22. package/dist/gen/orders/v1/orders_pb.d.ts.map +1 -1
  23. package/dist/gen/orders/v1/orders_pb.js.map +1 -1
  24. package/dist/gen/orders/v1/orders_read_pb.d.ts +2 -1
  25. package/dist/gen/orders/v1/orders_read_pb.d.ts.map +1 -1
  26. package/dist/gen/orders/v1/orders_read_pb.js.map +1 -1
  27. package/dist/index.d.ts +2 -2
  28. package/dist/services/candles/candles.schemas.d.ts +10 -10
  29. package/dist/services/heatmap/heatmap.schemas.d.ts +9 -9
  30. package/dist/services/lifecycle/lifecycle.schemas.d.ts +42 -42
  31. package/dist/services/market-overview/index.d.ts +2 -2
  32. package/dist/services/market-overview/market-overview.d.ts +9 -1
  33. package/dist/services/market-overview/market-overview.d.ts.map +1 -1
  34. package/dist/services/market-overview/market-overview.js +15 -1
  35. package/dist/services/market-overview/market-overview.js.map +1 -1
  36. package/dist/services/market-overview/market-overview.schemas.d.ts +163 -4
  37. package/dist/services/market-overview/market-overview.schemas.d.ts.map +1 -1
  38. package/dist/services/market-overview/market-overview.schemas.js +46 -1
  39. package/dist/services/market-overview/market-overview.schemas.js.map +1 -1
  40. package/dist/services/market-overview/market-overview.types.d.ts +2 -2
  41. package/dist/services/orders/orders-batch.schemas.d.ts +14 -14
  42. package/dist/services/orders/orders-output.schemas.d.ts +18 -18
  43. package/dist/services/orders/orders.d.ts +1 -1
  44. package/dist/services/orders/orders.d.ts.map +1 -1
  45. package/dist/services/orders/orders.js +10 -3
  46. package/dist/services/orders/orders.js.map +1 -1
  47. package/dist/services/subaccounts/subaccounts.schemas.d.ts +1 -1
  48. package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts.map +1 -1
  49. package/dist/services/trading-withdraws/trading-withdraws.schemas.js +3 -5
  50. package/dist/services/trading-withdraws/trading-withdraws.schemas.js.map +1 -1
  51. package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
  52. package/dist/services/triggers/triggers-output.schemas.d.ts +18 -18
  53. package/dist/services/zipper/zipper.schemas.d.ts.map +1 -1
  54. package/dist/services/zipper/zipper.schemas.js +0 -1
  55. package/dist/services/zipper/zipper.schemas.js.map +1 -1
  56. package/dist/shared/catalog-config.d.ts +0 -1
  57. package/dist/shared/catalog-config.d.ts.map +1 -1
  58. package/dist/shared/catalog-config.js.map +1 -1
  59. package/dist/shared/errors.d.ts +3 -2
  60. package/dist/shared/errors.d.ts.map +1 -1
  61. package/dist/shared/errors.js +3 -2
  62. package/dist/shared/errors.js.map +1 -1
  63. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { PolyesterError } from "../../shared/errors.js";
1
+ import { ConfigurationError, PolyesterError } from "../../shared/errors.js";
2
2
  import { OrdersService as OrdersService$1 } from "../../gen/orders/v1/orders_pb.js";
3
3
  import { toPolyesterError } from "../../shared/connect-error-mapping.js";
4
4
  import { parse } from "../../shared/validation.js";
@@ -29,7 +29,14 @@ function isOrderNotFoundError(error) {
29
29
  return isResourceNotFoundError(error) || mapped instanceof PolyesterError && mapped.detail?.service === "orders" && mapped.detail.code === "NOT_FOUND" || formatConnectError(error, "").toLowerCase() === MISCLASSIFIED_ORDER_NOT_FOUND_MESSAGE;
30
30
  }
31
31
  function createMutationRequestId() {
32
- return globalThis.crypto?.randomUUID?.() ?? `req_${Date.now()}_${Math.random().toString(16).slice(2)}`;
32
+ const crypto = globalThis.crypto;
33
+ if (crypto?.randomUUID) return crypto.randomUUID();
34
+ if (crypto?.getRandomValues) {
35
+ const bytes = /* @__PURE__ */ new Uint8Array(16);
36
+ crypto.getRandomValues(bytes);
37
+ return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
38
+ }
39
+ throw new ConfigurationError("Secure request ID generation requires crypto.randomUUID or crypto.getRandomValues.");
33
40
  }
34
41
  function assertBatchResultCount(operation, requested, returned) {
35
42
  if (requested !== returned) throw new Error(`${operation} returned ${returned} results for ${requested} requested items.`);
@@ -97,7 +104,7 @@ var OrdersService = class {
97
104
  return parse(createPreviewOrderResultSchema(this.#scales, request.order.symbolId), response);
98
105
  }
99
106
  /**
100
- * Places a spot order with an explicit market-IOC, limit-GTC, limit-IOC, or limit-FOK execution policy and optional attached risk controls. clientOrderId is the caller-controlled idempotency key and should be reused only for the same logical order.
107
+ * Places a spot order with an explicit market-IOC, limit-GTC, limit-IOC, or limit-FOK execution policy and optional attached risk controls. clientOrderId is an account-scoped correlation, lookup, and cancellation identifier. Reuse while retained returns CONFLICT_DUPLICATE_CLIENT_ORDER_ID, including after rejection or completion; it does not replay the earlier result.
101
108
  */
102
109
  async create(input, options) {
103
110
  await this.#scales.ready();
@@ -1 +1 @@
1
- {"version":3,"file":"orders.js","names":["#readClient","ProtoRead.OrdersReadService","#writeClient","ProtoWrite.OrdersService","#realtime","#resolver","#scales","#orderSchema","#orderDetailsSchema","#newOrderInputSchema","#modifyOrderInputSchema","#batchCreateOrdersInputSchema","ProtoRead.OrderSchema"],"sources":["../../../src/services/orders/orders.ts"],"sourcesContent":["import * as ProtoRead from \"../../gen/orders/v1/orders_read_pb.js\";\nimport * as ProtoWrite from \"../../gen/orders/v1/orders_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport { connectReadyGatedProtoChannel } from \"../../realtime/ready-gated-subscription.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport { toPolyesterError } from \"../../shared/connect-error-mapping.js\";\nimport { PolyesterError } from \"../../shared/errors.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { formatConnectError, isResourceNotFoundError } from \"../../utils/errors.js\";\nimport {\n OpenOrdersInputSchema,\n OrderHistoryInputSchema,\n type NewOrderInput,\n createNewOrderInputSchema,\n CancelOrderInputSchema,\n CancelOrderResultSchema,\n type CancelOrderResult,\n CancelAllOrdersInputSchema,\n CancelAllOrdersResponseSchema,\n type CancelAllOrdersResponse,\n type Order,\n GetOrderDetailsInputSchema,\n createCreateOrderResultSchema,\n createPreviewOrderResultSchema,\n type PreviewOrderResult,\n type ModifyOrderInput,\n assertKnownModifyOrderInputKeys,\n createModifyOrderInputSchema,\n ModifyOrderResultSchema,\n type CreateOrderResult,\n type ModifyOrderResult,\n type OrderDetails,\n createOrderSchema,\n createOrderDetailsSchema,\n CancelAllAfterInputSchema,\n CancelAllAfterResultSchema,\n type CancelAllAfterInput,\n type CancelAllAfterResult,\n BatchCancelOrdersInputSchema,\n BatchCancelOrdersResultSchema,\n type BatchCancelOrdersInput,\n type BatchCancelOrdersResult,\n createBatchCreateOrdersResultSchema,\n type BatchCreateOrdersInput,\n type BatchCreateOrdersResult,\n BatchReplaceOrdersResultSchema,\n type BatchReplaceOrdersInput,\n type BatchReplaceOrdersResult,\n GetBatchReplaceStatusInputSchema,\n GetBatchReplaceStatusResultSchema,\n type GetBatchReplaceStatusInput,\n type GetBatchReplaceStatusResult,\n assertKnownBatchReplaceOrderItemInputKeys,\n createBatchCreateOrdersInputSchema,\n createBatchReplaceOrdersInputSchema,\n} from \"./orders.schemas.js\";\n\nfunction hasKnownOrderSymbol(scales: SdkScales, order: { symbolId: number }): boolean {\n try {\n scales.baseQty(order.symbolId);\n return true;\n } catch {\n return false;\n }\n}\n\nconst MISCLASSIFIED_ORDER_NOT_FOUND_MESSAGE = \"order not found\";\n\nfunction isOrderNotFoundError(error: unknown): boolean {\n const mapped = toPolyesterError(error);\n return (\n isResourceNotFoundError(error) ||\n (mapped instanceof PolyesterError &&\n mapped.detail?.service === \"orders\" &&\n mapped.detail.code === \"NOT_FOUND\") ||\n formatConnectError(error, \"\").toLowerCase() === MISCLASSIFIED_ORDER_NOT_FOUND_MESSAGE\n );\n}\n\ninterface SubscribeOrdersInput extends BaseSubscribeInput<Order> {\n accountId: string;\n}\n\nfunction createMutationRequestId(): string {\n return (\n globalThis.crypto?.randomUUID?.() ??\n `req_${Date.now()}_${Math.random().toString(16).slice(2)}`\n );\n}\n\nfunction assertBatchResultCount(operation: string, requested: number, returned: number): void {\n if (requested !== returned) {\n throw new Error(\n `${operation} returned ${returned} results for ${requested} requested items.`,\n );\n }\n}\n\n/**\n * Manages account-scoped spot orders across read, write, and realtime order update surfaces.\n */\nexport class OrdersService {\n #readClient: Client<typeof ProtoRead.OrdersReadService>;\n #writeClient: Client<typeof ProtoWrite.OrdersService>;\n #realtime: PolyesterRealtime;\n #resolver?: SubaccountResolver;\n #scales: SdkScales;\n #orderSchema: ReturnType<typeof createOrderSchema>;\n #orderDetailsSchema: ReturnType<typeof createOrderDetailsSchema>;\n #newOrderInputSchema: ReturnType<typeof createNewOrderInputSchema>;\n #modifyOrderInputSchema: ReturnType<typeof createModifyOrderInputSchema>;\n #batchCreateOrdersInputSchema: ReturnType<typeof createBatchCreateOrdersInputSchema>;\n\n constructor(\n transports: AuthApiTransports,\n realtime: PolyesterRealtime,\n resolver: SubaccountResolver | undefined,\n scales: SdkScales,\n ) {\n this.#readClient = createClient(ProtoRead.OrdersReadService, transports.authApi);\n this.#writeClient = createClient(ProtoWrite.OrdersService, transports.authApi);\n this.#realtime = realtime;\n this.#resolver = resolver;\n this.#scales = scales;\n this.#orderSchema = createOrderSchema(scales);\n this.#orderDetailsSchema = createOrderDetailsSchema(scales);\n this.#newOrderInputSchema = createNewOrderInputSchema(scales);\n this.#modifyOrderInputSchema = createModifyOrderInputSchema(scales);\n this.#batchCreateOrdersInputSchema = createBatchCreateOrdersInputSchema(scales);\n }\n\n /**\n * Returns open orders for the resolved root account or subaccount, with optional symbol IDs, trigger ID, side, pagination, and attached-risk inclusion filters. Results are paginated with a server-determined page size: a single call is not the full set of open orders — keep calling with the returned nextPageToken until it is empty.\n */\n async listOpen(\n input: v.InferInput<typeof OpenOrdersInputSchema> = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ orders: Order[]; nextPageToken: string }> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(OpenOrdersInputSchema, resolved);\n const res = await this.#readClient.getOpenOrders(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n return {\n orders: parse(\n v.array(this.#orderSchema),\n res.orders.filter((order) => hasKnownOrderSymbol(this.#scales, order)),\n ),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Returns historical orders for the resolved account scope, supporting symbol IDs, trigger ID, side, status, time range, pagination, and attached-risk filters. Results are paginated with the backend nextPageToken.\n */\n async listHistory(\n input: v.InferInput<typeof OrderHistoryInputSchema> = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ orders: Order[]; nextPageToken: string }> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(OrderHistoryInputSchema, resolved);\n const res = await this.#readClient.getOrderHistory(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n return {\n orders: parse(\n v.array(this.#orderSchema),\n res.orders.filter((order) => hasKnownOrderSymbol(this.#scales, order)),\n ),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Evaluates one complete order intent against current market, policy, risk, and balance state without creating an order, reserving funds, or claiming its client order ID.\n */\n async preview(\n input: NewOrderInput,\n options?: PolyesterRequestOptions,\n ): Promise<PreviewOrderResult> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const request = parse(this.#newOrderInputSchema, resolved);\n const response = await this.#writeClient.previewOrder(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(\n createPreviewOrderResultSchema(this.#scales, request.order.symbolId),\n response,\n );\n }\n\n /**\n * Places a spot order with an explicit market-IOC, limit-GTC, limit-IOC, or limit-FOK execution policy and optional attached risk controls. clientOrderId is the caller-controlled idempotency key and should be reused only for the same logical order.\n */\n async create(\n input: NewOrderInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateOrderResult> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(this.#newOrderInputSchema, resolved);\n const requestPayload = removeUndefined(validatedInput);\n const res = await this.#writeClient.createOrder(\n requestPayload,\n toConnectCallOptions(options),\n );\n return parse(\n createCreateOrderResultSchema(this.#scales, validatedInput.order.symbolId),\n res,\n );\n }\n\n /**\n * Places 1–20 spot orders in one best-effort request. Results preserve item order and report admission as accepted or rejected; accepted orders still require lifecycle reconciliation. requestId is the idempotency boundary for the ordered batch and is generated when omitted; supply and reuse it when an ambiguous batch may be retried. Per-item clientOrderId values are optional correlation identifiers and must be unique when supplied.\n */\n async batchCreate(\n input: BatchCreateOrdersInput,\n options?: PolyesterMutationOptions,\n ): Promise<BatchCreateOrdersResult> {\n await this.#scales.ready();\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(this.#batchCreateOrdersInputSchema, resolved);\n const response = await this.#writeClient.batchCreateOrders(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n const result = parse(\n createBatchCreateOrdersResultSchema(\n this.#scales,\n request.items.map((item) => item.symbolId),\n ),\n response,\n );\n assertBatchResultCount(\"batchCreate\", input.items.length, result.results.length);\n return result;\n }\n\n /**\n * Requests cancellation of one order in the resolved account scope by order id or client order id, with optional symbol routing. The response acknowledges the cancellation request, not the order's final lifecycle state; reconcile through order reads or realtime before releasing local state. A missing target remains a {@link ResourceNotFoundError}; callers performing desired-state cleanup may treat that error as success when the order could already have filled or left the book.\n */\n async cancel(\n input: v.InferInput<typeof CancelOrderInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CancelOrderResult> {\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n\n const validated = parse(CancelOrderInputSchema, resolved);\n\n const res = await this.#writeClient.cancelOrder(\n {\n key: validated.key,\n symbolId: validated.symbolId,\n subaccountId: validated.subaccountId,\n },\n toConnectCallOptions(options),\n );\n return parse(CancelOrderResultSchema, res);\n }\n\n /**\n * Cancels 1–50 explicit orders in one best-effort request. Results preserve item order and acknowledge cancellation admission rather than final order state. Supply a stable requestId when an ambiguous batch may be retried.\n */\n async batchCancel(\n input: BatchCancelOrdersInput,\n options?: PolyesterMutationOptions,\n ): Promise<BatchCancelOrdersResult> {\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(BatchCancelOrdersInputSchema, resolved);\n const response = await this.#writeClient.batchCancelOrders(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n const result = parse(BatchCancelOrdersResultSchema, response);\n assertBatchResultCount(\"batchCancel\", input.items.length, result.results.length);\n return result;\n }\n\n /**\n * Applies a price, quantity, client id, or attached-risk patch to one open order. The symbol ID routes policy checks and quantity scaling. A requestId is generated when omitted; provide a stable value when retrying the same logical modification.\n */\n async modify(\n input: ModifyOrderInput,\n options?: PolyesterMutationOptions,\n ): Promise<ModifyOrderResult> {\n await this.#scales.ready();\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n assertKnownModifyOrderInputKeys(resolved);\n const validated = parse(this.#modifyOrderInputSchema, resolved);\n const res = await this.#writeClient.modifyOrder(\n removeUndefined(validated),\n toConnectCallOptions(options),\n );\n return parse(ModifyOrderResultSchema, res);\n }\n\n /**\n * Replaces 1–50 same-symbol orders and returns an index-stable durable admission receipt. Reuse requestId only when retrying the same logical batch; use the returned batchRequestId for later status reads.\n */\n async batchReplace(\n input: BatchReplaceOrdersInput,\n options?: PolyesterMutationOptions,\n ): Promise<BatchReplaceOrdersResult> {\n await this.#scales.ready();\n for (const item of input.items) {\n assertKnownBatchReplaceOrderItemInputKeys(item);\n }\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(createBatchReplaceOrdersInputSchema(this.#scales), resolved);\n const response = await this.#writeClient.batchReplaceOrders(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n const result = parse(BatchReplaceOrdersResultSchema, response);\n assertBatchResultCount(\"batchReplace\", input.items.length, result.results.length);\n return result;\n }\n\n /**\n * Reads the durable per-item execution status for a batch replacement receipt.\n */\n async getBatchReplaceStatus(\n input: GetBatchReplaceStatusInput,\n options?: PolyesterRequestOptions,\n ): Promise<GetBatchReplaceStatusResult> {\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const request = parse(GetBatchReplaceStatusInputSchema, resolved);\n const response = await this.#readClient.getBatchReplaceStatus(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(GetBatchReplaceStatusResultSchema, response);\n }\n\n /**\n * Cancels all matching open orders for the resolved account scope, optionally narrowed by up to 100 symbol IDs and side, with dry-run preview. A requestId is generated when omitted; reuse it with the same criteria for retries. Completed results are retained for at least two minutes; use a fresh key for each new cancellation.\n */\n async cancelAll(\n input: v.InferInput<typeof CancelAllOrdersInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CancelAllOrdersResponse> {\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const validated = parse(CancelAllOrdersInputSchema, resolved);\n const res = await this.#writeClient.cancelAllOrders(\n removeUndefined(validated),\n toConnectCallOptions(options),\n );\n return parse(CancelAllOrdersResponseSchema, res);\n }\n\n /**\n * Arms, refreshes, or disables the account dead-man switch, optionally scoped by symbol ID and side. timeoutSec 0 disables it; 10–120 arms it. Generate a new requestId for each deliberate heartbeat, but reuse the same ID when retrying one ambiguous heartbeat.\n */\n async cancelAllAfter(\n input: CancelAllAfterInput,\n options?: PolyesterMutationOptions,\n ): Promise<CancelAllAfterResult> {\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(CancelAllAfterInputSchema, resolved);\n const response = await this.#writeClient.cancelAllAfter(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(CancelAllAfterResultSchema, response);\n }\n\n /**\n * Fetches one order by id or client order id and returns its order, trades, and transfer details when found. Returns null when the requested order is not found.\n */\n async getDetails(\n input: v.InferInput<typeof GetOrderDetailsInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<OrderDetails | null> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(GetOrderDetailsInputSchema, resolved);\n let res: ProtoRead.GetOrderResponse;\n try {\n res = await this.#readClient.getOrder(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n } catch (error) {\n if (isOrderNotFoundError(error)) return null;\n throw error;\n }\n if (!res.order) return null;\n return parse(this.#orderDetailsSchema, res);\n }\n\n /**\n * Subscribes to private order updates on private:spot:orders:{accountId}:proto and emits parsed order records until the returned unsubscribe function is called.\n */\n subscribe(input: SubscribeOrdersInput): () => void {\n const channel = `private:spot:orders:${input.accountId}:proto`;\n return connectReadyGatedProtoChannel(this.#realtime, {\n channel,\n schema: ProtoRead.OrderSchema,\n ready: () => this.#scales.ready(),\n onPublication: (data) => {\n const order = parse(this.#orderSchema, data);\n input.onEvent(order);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoEA,SAAS,oBAAoB,QAAmB,OAAsC;CAClF,IAAI;EACA,OAAO,QAAQ,MAAM,QAAQ;EAC7B,OAAO;CACX,QAAQ;EACJ,OAAO;CACX;AACJ;AAEA,MAAM,wCAAwC;AAE9C,SAAS,qBAAqB,OAAyB;CACnD,MAAM,SAAS,iBAAiB,KAAK;CACrC,OACI,wBAAwB,KAAK,KAC5B,kBAAkB,kBACf,OAAO,QAAQ,YAAY,YAC3B,OAAO,OAAO,SAAS,eAC3B,mBAAmB,OAAO,EAAE,CAAC,CAAC,YAAY,MAAM;AAExD;AAMA,SAAS,0BAAkC;CACvC,OACI,WAAW,QAAQ,aAAa,KAChC,OAAO,KAAK,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC;AAE/D;AAEA,SAAS,uBAAuB,WAAmB,WAAmB,UAAwB;CAC1F,IAAI,cAAc,UACd,MAAM,IAAI,MACN,GAAG,UAAU,YAAY,SAAS,eAAe,UAAU,kBAC/D;AAER;;;;AAKA,IAAa,gBAAb,MAA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J,SAAS,OAAO;GACZ,IAAI,qBAAqB,KAAK,GAAG,OAAO;GACxC,MAAM;EACV;EACA,IAAI,CAAC,IAAI,OAAO,OAAO;EACvB,OAAO,MAAM,KAAKQ,qBAAqB,GAAG;CAC9C;;;;CAKA,UAAU,OAAyC;EAC/C,MAAM,UAAU,uBAAuB,MAAM,UAAU;EACvD,OAAO,8BAA8B,KAAKJ,WAAW;GACjD;GACA,QAAQQ;GACR,aAAa,KAAKN,QAAQ,MAAM;GAChC,gBAAgB,SAAS;IACrB,MAAM,QAAQ,MAAM,KAAKC,cAAc,IAAI;IAC3C,MAAM,QAAQ,KAAK;GACvB;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
1
+ {"version":3,"file":"orders.js","names":["#readClient","ProtoRead.OrdersReadService","#writeClient","ProtoWrite.OrdersService","#realtime","#resolver","#scales","#orderSchema","#orderDetailsSchema","#newOrderInputSchema","#modifyOrderInputSchema","#batchCreateOrdersInputSchema","ProtoRead.OrderSchema"],"sources":["../../../src/services/orders/orders.ts"],"sourcesContent":["import * as ProtoRead from \"../../gen/orders/v1/orders_read_pb.js\";\nimport * as ProtoWrite from \"../../gen/orders/v1/orders_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport { connectReadyGatedProtoChannel } from \"../../realtime/ready-gated-subscription.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport { toPolyesterError } from \"../../shared/connect-error-mapping.js\";\nimport { ConfigurationError, PolyesterError } from \"../../shared/errors.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { formatConnectError, isResourceNotFoundError } from \"../../utils/errors.js\";\nimport {\n OpenOrdersInputSchema,\n OrderHistoryInputSchema,\n type NewOrderInput,\n createNewOrderInputSchema,\n CancelOrderInputSchema,\n CancelOrderResultSchema,\n type CancelOrderResult,\n CancelAllOrdersInputSchema,\n CancelAllOrdersResponseSchema,\n type CancelAllOrdersResponse,\n type Order,\n GetOrderDetailsInputSchema,\n createCreateOrderResultSchema,\n createPreviewOrderResultSchema,\n type PreviewOrderResult,\n type ModifyOrderInput,\n assertKnownModifyOrderInputKeys,\n createModifyOrderInputSchema,\n ModifyOrderResultSchema,\n type CreateOrderResult,\n type ModifyOrderResult,\n type OrderDetails,\n createOrderSchema,\n createOrderDetailsSchema,\n CancelAllAfterInputSchema,\n CancelAllAfterResultSchema,\n type CancelAllAfterInput,\n type CancelAllAfterResult,\n BatchCancelOrdersInputSchema,\n BatchCancelOrdersResultSchema,\n type BatchCancelOrdersInput,\n type BatchCancelOrdersResult,\n createBatchCreateOrdersResultSchema,\n type BatchCreateOrdersInput,\n type BatchCreateOrdersResult,\n BatchReplaceOrdersResultSchema,\n type BatchReplaceOrdersInput,\n type BatchReplaceOrdersResult,\n GetBatchReplaceStatusInputSchema,\n GetBatchReplaceStatusResultSchema,\n type GetBatchReplaceStatusInput,\n type GetBatchReplaceStatusResult,\n assertKnownBatchReplaceOrderItemInputKeys,\n createBatchCreateOrdersInputSchema,\n createBatchReplaceOrdersInputSchema,\n} from \"./orders.schemas.js\";\n\nfunction hasKnownOrderSymbol(scales: SdkScales, order: { symbolId: number }): boolean {\n try {\n scales.baseQty(order.symbolId);\n return true;\n } catch {\n return false;\n }\n}\n\nconst MISCLASSIFIED_ORDER_NOT_FOUND_MESSAGE = \"order not found\";\n\nfunction isOrderNotFoundError(error: unknown): boolean {\n const mapped = toPolyesterError(error);\n return (\n isResourceNotFoundError(error) ||\n (mapped instanceof PolyesterError &&\n mapped.detail?.service === \"orders\" &&\n mapped.detail.code === \"NOT_FOUND\") ||\n formatConnectError(error, \"\").toLowerCase() === MISCLASSIFIED_ORDER_NOT_FOUND_MESSAGE\n );\n}\n\ninterface SubscribeOrdersInput extends BaseSubscribeInput<Order> {\n accountId: string;\n}\n\nfunction createMutationRequestId(): string {\n const crypto = globalThis.crypto;\n if (crypto?.randomUUID) return crypto.randomUUID();\n\n if (crypto?.getRandomValues) {\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\");\n }\n\n throw new ConfigurationError(\n \"Secure request ID generation requires crypto.randomUUID or crypto.getRandomValues.\",\n );\n}\n\nfunction assertBatchResultCount(operation: string, requested: number, returned: number): void {\n if (requested !== returned) {\n throw new Error(\n `${operation} returned ${returned} results for ${requested} requested items.`,\n );\n }\n}\n\n/**\n * Manages account-scoped spot orders across read, write, and realtime order update surfaces.\n */\nexport class OrdersService {\n #readClient: Client<typeof ProtoRead.OrdersReadService>;\n #writeClient: Client<typeof ProtoWrite.OrdersService>;\n #realtime: PolyesterRealtime;\n #resolver?: SubaccountResolver;\n #scales: SdkScales;\n #orderSchema: ReturnType<typeof createOrderSchema>;\n #orderDetailsSchema: ReturnType<typeof createOrderDetailsSchema>;\n #newOrderInputSchema: ReturnType<typeof createNewOrderInputSchema>;\n #modifyOrderInputSchema: ReturnType<typeof createModifyOrderInputSchema>;\n #batchCreateOrdersInputSchema: ReturnType<typeof createBatchCreateOrdersInputSchema>;\n\n constructor(\n transports: AuthApiTransports,\n realtime: PolyesterRealtime,\n resolver: SubaccountResolver | undefined,\n scales: SdkScales,\n ) {\n this.#readClient = createClient(ProtoRead.OrdersReadService, transports.authApi);\n this.#writeClient = createClient(ProtoWrite.OrdersService, transports.authApi);\n this.#realtime = realtime;\n this.#resolver = resolver;\n this.#scales = scales;\n this.#orderSchema = createOrderSchema(scales);\n this.#orderDetailsSchema = createOrderDetailsSchema(scales);\n this.#newOrderInputSchema = createNewOrderInputSchema(scales);\n this.#modifyOrderInputSchema = createModifyOrderInputSchema(scales);\n this.#batchCreateOrdersInputSchema = createBatchCreateOrdersInputSchema(scales);\n }\n\n /**\n * Returns open orders for the resolved root account or subaccount, with optional symbol IDs, trigger ID, side, pagination, and attached-risk inclusion filters. Results are paginated with a server-determined page size: a single call is not the full set of open orders — keep calling with the returned nextPageToken until it is empty.\n */\n async listOpen(\n input: v.InferInput<typeof OpenOrdersInputSchema> = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ orders: Order[]; nextPageToken: string }> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(OpenOrdersInputSchema, resolved);\n const res = await this.#readClient.getOpenOrders(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n return {\n orders: parse(\n v.array(this.#orderSchema),\n res.orders.filter((order) => hasKnownOrderSymbol(this.#scales, order)),\n ),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Returns historical orders for the resolved account scope, supporting symbol IDs, trigger ID, side, status, time range, pagination, and attached-risk filters. Results are paginated with the backend nextPageToken.\n */\n async listHistory(\n input: v.InferInput<typeof OrderHistoryInputSchema> = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ orders: Order[]; nextPageToken: string }> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(OrderHistoryInputSchema, resolved);\n const res = await this.#readClient.getOrderHistory(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n return {\n orders: parse(\n v.array(this.#orderSchema),\n res.orders.filter((order) => hasKnownOrderSymbol(this.#scales, order)),\n ),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Evaluates one complete order intent against current market, policy, risk, and balance state without creating an order, reserving funds, or claiming its client order ID.\n */\n async preview(\n input: NewOrderInput,\n options?: PolyesterRequestOptions,\n ): Promise<PreviewOrderResult> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const request = parse(this.#newOrderInputSchema, resolved);\n const response = await this.#writeClient.previewOrder(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(\n createPreviewOrderResultSchema(this.#scales, request.order.symbolId),\n response,\n );\n }\n\n /**\n * Places a spot order with an explicit market-IOC, limit-GTC, limit-IOC, or limit-FOK execution policy and optional attached risk controls. clientOrderId is an account-scoped correlation, lookup, and cancellation identifier. Reuse while retained returns CONFLICT_DUPLICATE_CLIENT_ORDER_ID, including after rejection or completion; it does not replay the earlier result.\n */\n async create(\n input: NewOrderInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateOrderResult> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(this.#newOrderInputSchema, resolved);\n const requestPayload = removeUndefined(validatedInput);\n const res = await this.#writeClient.createOrder(\n requestPayload,\n toConnectCallOptions(options),\n );\n return parse(\n createCreateOrderResultSchema(this.#scales, validatedInput.order.symbolId),\n res,\n );\n }\n\n /**\n * Places 1–20 spot orders in one best-effort request. Results preserve item order and report admission as accepted or rejected; accepted orders still require lifecycle reconciliation. requestId is the idempotency boundary for the ordered batch and is generated when omitted; supply and reuse it when an ambiguous batch may be retried. Per-item clientOrderId values are optional correlation identifiers and must be unique when supplied.\n */\n async batchCreate(\n input: BatchCreateOrdersInput,\n options?: PolyesterMutationOptions,\n ): Promise<BatchCreateOrdersResult> {\n await this.#scales.ready();\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(this.#batchCreateOrdersInputSchema, resolved);\n const response = await this.#writeClient.batchCreateOrders(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n const result = parse(\n createBatchCreateOrdersResultSchema(\n this.#scales,\n request.items.map((item) => item.symbolId),\n ),\n response,\n );\n assertBatchResultCount(\"batchCreate\", input.items.length, result.results.length);\n return result;\n }\n\n /**\n * Requests cancellation of one order in the resolved account scope by order id or client order id, with optional symbol routing. The response acknowledges the cancellation request, not the order's final lifecycle state; reconcile through order reads or realtime before releasing local state. A missing target remains a {@link ResourceNotFoundError}; callers performing desired-state cleanup may treat that error as success when the order could already have filled or left the book.\n */\n async cancel(\n input: v.InferInput<typeof CancelOrderInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CancelOrderResult> {\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n\n const validated = parse(CancelOrderInputSchema, resolved);\n\n const res = await this.#writeClient.cancelOrder(\n {\n key: validated.key,\n symbolId: validated.symbolId,\n subaccountId: validated.subaccountId,\n },\n toConnectCallOptions(options),\n );\n return parse(CancelOrderResultSchema, res);\n }\n\n /**\n * Cancels 1–50 explicit orders in one best-effort request. Results preserve item order and acknowledge cancellation admission rather than final order state. Supply a stable requestId when an ambiguous batch may be retried.\n */\n async batchCancel(\n input: BatchCancelOrdersInput,\n options?: PolyesterMutationOptions,\n ): Promise<BatchCancelOrdersResult> {\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(BatchCancelOrdersInputSchema, resolved);\n const response = await this.#writeClient.batchCancelOrders(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n const result = parse(BatchCancelOrdersResultSchema, response);\n assertBatchResultCount(\"batchCancel\", input.items.length, result.results.length);\n return result;\n }\n\n /**\n * Applies a price, quantity, client id, or attached-risk patch to one open order. The symbol ID routes policy checks and quantity scaling. A requestId is generated when omitted; provide a stable value when retrying the same logical modification.\n */\n async modify(\n input: ModifyOrderInput,\n options?: PolyesterMutationOptions,\n ): Promise<ModifyOrderResult> {\n await this.#scales.ready();\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n assertKnownModifyOrderInputKeys(resolved);\n const validated = parse(this.#modifyOrderInputSchema, resolved);\n const res = await this.#writeClient.modifyOrder(\n removeUndefined(validated),\n toConnectCallOptions(options),\n );\n return parse(ModifyOrderResultSchema, res);\n }\n\n /**\n * Replaces 1–50 same-symbol orders and returns an index-stable durable admission receipt. Reuse requestId only when retrying the same logical batch; use the returned batchRequestId for later status reads.\n */\n async batchReplace(\n input: BatchReplaceOrdersInput,\n options?: PolyesterMutationOptions,\n ): Promise<BatchReplaceOrdersResult> {\n await this.#scales.ready();\n for (const item of input.items) {\n assertKnownBatchReplaceOrderItemInputKeys(item);\n }\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(createBatchReplaceOrdersInputSchema(this.#scales), resolved);\n const response = await this.#writeClient.batchReplaceOrders(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n const result = parse(BatchReplaceOrdersResultSchema, response);\n assertBatchResultCount(\"batchReplace\", input.items.length, result.results.length);\n return result;\n }\n\n /**\n * Reads the durable per-item execution status for a batch replacement receipt.\n */\n async getBatchReplaceStatus(\n input: GetBatchReplaceStatusInput,\n options?: PolyesterRequestOptions,\n ): Promise<GetBatchReplaceStatusResult> {\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const request = parse(GetBatchReplaceStatusInputSchema, resolved);\n const response = await this.#readClient.getBatchReplaceStatus(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(GetBatchReplaceStatusResultSchema, response);\n }\n\n /**\n * Cancels all matching open orders for the resolved account scope, optionally narrowed by up to 100 symbol IDs and side, with dry-run preview. A requestId is generated when omitted; reuse it with the same criteria for retries. Completed results are retained for at least two minutes; use a fresh key for each new cancellation.\n */\n async cancelAll(\n input: v.InferInput<typeof CancelAllOrdersInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CancelAllOrdersResponse> {\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const validated = parse(CancelAllOrdersInputSchema, resolved);\n const res = await this.#writeClient.cancelAllOrders(\n removeUndefined(validated),\n toConnectCallOptions(options),\n );\n return parse(CancelAllOrdersResponseSchema, res);\n }\n\n /**\n * Arms, refreshes, or disables the account dead-man switch, optionally scoped by symbol ID and side. timeoutSec 0 disables it; 10–120 arms it. Generate a new requestId for each deliberate heartbeat, but reuse the same ID when retrying one ambiguous heartbeat.\n */\n async cancelAllAfter(\n input: CancelAllAfterInput,\n options?: PolyesterMutationOptions,\n ): Promise<CancelAllAfterResult> {\n const resolved = {\n ...resolveAccountScopedInput(input, this.#resolver),\n requestId: input.requestId ?? createMutationRequestId(),\n };\n const request = parse(CancelAllAfterInputSchema, resolved);\n const response = await this.#writeClient.cancelAllAfter(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(CancelAllAfterResultSchema, response);\n }\n\n /**\n * Fetches one order by id or client order id and returns its order, trades, and transfer details when found. Returns null when the requested order is not found.\n */\n async getDetails(\n input: v.InferInput<typeof GetOrderDetailsInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<OrderDetails | null> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(GetOrderDetailsInputSchema, resolved);\n let res: ProtoRead.GetOrderResponse;\n try {\n res = await this.#readClient.getOrder(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n } catch (error) {\n if (isOrderNotFoundError(error)) return null;\n throw error;\n }\n if (!res.order) return null;\n return parse(this.#orderDetailsSchema, res);\n }\n\n /**\n * Subscribes to private order updates on private:spot:orders:{accountId}:proto and emits parsed order records until the returned unsubscribe function is called.\n */\n subscribe(input: SubscribeOrdersInput): () => void {\n const channel = `private:spot:orders:${input.accountId}:proto`;\n return connectReadyGatedProtoChannel(this.#realtime, {\n channel,\n schema: ProtoRead.OrderSchema,\n ready: () => this.#scales.ready(),\n onPublication: (data) => {\n const order = parse(this.#orderSchema, data);\n input.onEvent(order);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n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QAAQ,MAAM,KAAKC,cAAc,IAAI;IAC3C,MAAM,QAAQ,KAAK;GACvB;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
@@ -280,7 +280,7 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
280
280
  nanos: number;
281
281
  } | undefined, number | undefined>]>;
282
282
  readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "policy" | "member" | "invite" | "security">]>;
283
- readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "failed" | "created" | "updated" | "deleted" | "removed" | "role_set" | "received" | "replied" | "revoked" | "blocked" | "hold_placed" | "hold_released">]>;
283
+ readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "failed" | "revoked" | "created" | "updated" | "deleted" | "removed" | "role_set" | "received" | "replied" | "blocked" | "hold_placed" | "hold_released">]>;
284
284
  readonly source: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventSource, undefined>, v.TransformAction<ActivityEventSource, "unspecified" | "web" | "mobile" | "api">]>;
285
285
  readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
286
286
  readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"trading-withdraws.schemas.d.ts","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"mappings":";;;;;KAiBY;EACR,QAAQ;EACR;EACA;EACA,WAAW;EACX;EACA,OAAO;EACP;EACA;;KAGC;EACD;EACA,SAAS;EACT,mBAAmB;;iBAoCP,gDAAgD,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;GA+BhF;iBAEe,sDAAsD,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;GAqCtF;KAEW,sCAAsC,EAAE,WAChD,kBAAkB;KAOV,4CAA4C,EAAE,WACtD,kBAAkB;cAOT,mCAAiC,EAAA;;;KAIlC,8BAA8B,EAAE,mBAAmB;cAOlD,wCAAsC,EAAA,yBAAA,EAAA;;;;;;;;;;KAgBvC,mCAAmC,EAAE,kBACtC;cA4CE,yCAAuC,EAAA,aAAA,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKxC,oCAAoC,EAAE,mBACvC"}
1
+ {"version":3,"file":"trading-withdraws.schemas.d.ts","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"mappings":";;;;;KAkBY;EACR,QAAQ;EACR;EACA;EACA,WAAW;EACX;EACA,OAAO;EACP;EACA;;KAGC;EACD;EACA,SAAS;EACT,mBAAmB;;iBAmCP,gDAAgD,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;GA+BhF;iBAEe,sDAAsD,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;GAqCtF;KAEW,sCAAsC,EAAE,WAChD,kBAAkB;KAOV,4CAA4C,EAAE,WACtD,kBAAkB;cAOT,mCAAiC,EAAA;;;KAIlC,8BAA8B,EAAE,mBAAmB;cAOlD,wCAAsC,EAAA,yBAAA,EAAA;;;;;;;;;;KAgBvC,mCAAmC,EAAE,kBACtC;cA4CE,yCAAuC,EAAA,aAAA,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKxC,oCAAoC,EAAE,mBACvC"}
@@ -1,3 +1,4 @@
1
+ import { ConfigurationError } from "../../shared/errors.js";
1
2
  import "../../gen/chain/withdraw/v1/withdraw_pb.js";
2
3
  import { PositiveUint32InputSchema } from "../shared.js";
3
4
  import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
@@ -9,13 +10,10 @@ import * as v from "valibot";
9
10
  const DEFAULT_DEADLINE_SECONDS = 300;
10
11
  function createNonce() {
11
12
  const random = globalThis.crypto?.getRandomValues?.bind(globalThis.crypto);
12
- if (!random) {
13
- const nonce = BigInt(Date.now());
14
- return nonce === 0n ? 1n : nonce;
15
- }
13
+ if (!random) throw new ConfigurationError("Secure nonce generation requires crypto.getRandomValues.");
16
14
  const bytes = /* @__PURE__ */ new BigUint64Array(1);
17
15
  random(bytes);
18
- const nonce = bytes[0] ?? BigInt(Date.now());
16
+ const nonce = bytes[0];
19
17
  return nonce === 0n ? 1n : nonce;
20
18
  }
21
19
  function createTradingWithdrawPayload(input) {
@@ -1 +1 @@
1
- {"version":3,"file":"trading-withdraws.schemas.js","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { PositiveUint32InputSchema } from \"../shared.js\";\nimport { quantityInputToE18, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport type * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { WithdrawDestinationValidationCode } from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { toU128, type U128Value } from \"../../utils/u128.js\";\nimport {\n TradingWithdrawActionCodec,\n WithdrawDestinationValidationCodeCodec,\n} from \"./trading-withdraws.codecs.js\";\n\nconst DEFAULT_DEADLINE_SECONDS = 5 * 60;\n\nexport type TradingWithdrawIntentPayloadRequest = {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n amountE18: U128Value;\n deadlineTsSec: bigint;\n nonce: U128Value;\n destinationAddress: string;\n idempotencyKey: string;\n};\n\ntype CreateTradingWithdrawRequestBase = {\n subaccountId: bigint | undefined;\n payload: TradingWithdrawIntentPayloadRequest;\n payloadSignature?: Uint8Array;\n};\n\nfunction createNonce(): bigint {\n const random = globalThis.crypto?.getRandomValues?.bind(globalThis.crypto);\n if (!random) {\n const nonce = BigInt(Date.now());\n return nonce === 0n ? 1n : nonce;\n }\n\n const bytes = new BigUint64Array(1);\n random(bytes);\n const nonce = bytes[0] ?? BigInt(Date.now());\n return nonce === 0n ? 1n : nonce;\n}\n\nfunction createTradingWithdrawPayload(input: {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n quantityScaled: bigint;\n destinationAddress: string;\n idempotencyKey: string;\n}): TradingWithdrawIntentPayloadRequest {\n return {\n action: input.action,\n assetId: input.assetId,\n destinationChainId: input.destinationChainId,\n amountE18: toU128(input.quantityScaled),\n deadlineTsSec: BigInt(Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE_SECONDS),\n nonce: toU128(createNonce()),\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n };\n}\n\nexport function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n destinationAddress: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_funding,\n assetId: input.assetId,\n destinationChainId: 0n,\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport function createCreateTradingWithdrawToExternalChainInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_external_chain,\n assetId: input.assetId,\n destinationChainId: BigInt(input.destinationChainId),\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport type CreateTradingWithdrawToFundingInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToFundingRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport const CreateTradingWithdrawResultSchema = v.object({\n intentId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n});\n\nexport type CreateTradingWithdrawResult = v.InferOutput<typeof CreateTradingWithdrawResultSchema>;\n\nexport const CreateWalletTradingWithdrawResultSchema = CreateTradingWithdrawResultSchema;\nexport type CreateWalletTradingWithdrawResult = v.InferOutput<\n typeof CreateWalletTradingWithdrawResultSchema\n>;\n\nexport const ValidateWithdrawDestinationInputSchema = v.pipe(\n v.strictObject({\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((input) => ({\n destinationChainId: BigInt(input.destinationChainId),\n destinationAddress: input.destinationAddress,\n })),\n);\n\nexport type ValidateWithdrawDestinationInput = v.InferInput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\nexport type ValidateWithdrawDestinationRequest = v.InferOutput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\n\nconst ValidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(true),\n code: v.literal(WithdrawDestinationValidationCode.VALID),\n message: v.string(),\n canonicalDestinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((result) => ({\n ...result,\n code: WithdrawDestinationValidationCodeCodec.protoToOutput[result.code],\n })),\n);\n\nconst {\n [WithdrawDestinationValidationCode.VALID]: _validWithdrawDestinationCode,\n ...InvalidWithdrawDestinationCodeCodec\n} = WithdrawDestinationValidationCodeCodec.protoToOutput;\n\nconst InvalidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(false),\n code: v.picklist([\n WithdrawDestinationValidationCode.RESULT_UNSPECIFIED,\n WithdrawDestinationValidationCode.INVALID_ADDRESS,\n WithdrawDestinationValidationCode.UNSUPPORTED_CHAIN,\n WithdrawDestinationValidationCode.POLYESTER_SMART_ACCOUNT,\n WithdrawDestinationValidationCode.TOKEN_CONTRACT,\n WithdrawDestinationValidationCode.DENYLISTED_ADDRESS,\n ]),\n message: v.string(),\n canonicalDestinationAddress: v.string(),\n }),\n v.transform((result) => ({\n ...result,\n code: InvalidWithdrawDestinationCodeCodec[result.code],\n })),\n);\n\nexport const ValidateWithdrawDestinationResultSchema = v.union([\n ValidWithdrawDestinationResultSchema,\n InvalidWithdrawDestinationResultSchema,\n]);\n\nexport type ValidateWithdrawDestinationResult = v.InferOutput<\n typeof ValidateWithdrawDestinationResultSchema\n>;\n"],"mappings":";;;;;;;;AAeA,MAAM,2BAA2B;AAmBjC,SAAS,cAAsB;CAC3B,MAAM,SAAS,WAAW,QAAQ,iBAAiB,KAAK,WAAW,MAAM;CACzE,IAAI,CAAC,QAAQ;EACT,MAAM,QAAQ,OAAO,KAAK,IAAI,CAAC;EAC/B,OAAO,UAAU,KAAK,KAAK;CAC/B;CAEA,MAAM,wBAAQ,IAAI,eAAe,CAAC;CAClC,OAAO,KAAK;CACZ,MAAM,QAAQ,MAAM,MAAM,OAAO,KAAK,IAAI,CAAC;CAC3C,OAAO,UAAU,KAAK,KAAK;AAC/B;AAEA,SAAS,6BAA6B,OAOE;CACpC,OAAO;EACH,QAAQ,MAAM;EACd,SAAS,MAAM;EACf,oBAAoB,MAAM;EAC1B,WAAW,OAAO,MAAM,cAAc;EACtC,eAAe,OAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,IAAI,wBAAwB;EAC9E,OAAO,OAAO,YAAY,CAAC;EAC3B,oBAAoB,MAAM;EAC1B,gBAAgB,MAAM;CAC1B;AACJ;AAEA,SAAgB,gDAAgD,QAAmB;CAC/E,OAAO,EAAE,KACL,EAAE,aAAa;EACX,GAAG;EACH,SAAS;EACT,UAAU,EAAE,OAAO;EACnB,gBAAgB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;EAC3D,oBAAoB,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;EAC/D,cAAc,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;EACzD,kBAAkB,EAAE,SAAS,EAAE,SAAS,UAAU,CAAC;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draws.schemas.js","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { PositiveUint32InputSchema } from \"../shared.js\";\nimport { quantityInputToE18, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport type * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { WithdrawDestinationValidationCode } from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { toU128, type U128Value } from \"../../utils/u128.js\";\nimport { ConfigurationError } from \"../../shared/errors.js\";\nimport {\n TradingWithdrawActionCodec,\n WithdrawDestinationValidationCodeCodec,\n} from \"./trading-withdraws.codecs.js\";\n\nconst DEFAULT_DEADLINE_SECONDS = 5 * 60;\n\nexport type TradingWithdrawIntentPayloadRequest = {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n amountE18: U128Value;\n deadlineTsSec: bigint;\n nonce: U128Value;\n destinationAddress: string;\n idempotencyKey: string;\n};\n\ntype CreateTradingWithdrawRequestBase = {\n subaccountId: bigint | undefined;\n payload: TradingWithdrawIntentPayloadRequest;\n payloadSignature?: Uint8Array;\n};\n\nfunction createNonce(): bigint {\n const random = globalThis.crypto?.getRandomValues?.bind(globalThis.crypto);\n if (!random) {\n throw new ConfigurationError(\"Secure nonce generation requires crypto.getRandomValues.\");\n }\n\n const bytes = new BigUint64Array(1);\n random(bytes);\n const nonce = bytes[0]!;\n return nonce === 0n ? 1n : nonce;\n}\n\nfunction createTradingWithdrawPayload(input: {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n quantityScaled: bigint;\n destinationAddress: string;\n idempotencyKey: string;\n}): TradingWithdrawIntentPayloadRequest {\n return {\n action: input.action,\n assetId: input.assetId,\n destinationChainId: input.destinationChainId,\n amountE18: toU128(input.quantityScaled),\n deadlineTsSec: BigInt(Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE_SECONDS),\n nonce: toU128(createNonce()),\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n };\n}\n\nexport function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n destinationAddress: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_funding,\n assetId: input.assetId,\n destinationChainId: 0n,\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport function createCreateTradingWithdrawToExternalChainInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_external_chain,\n assetId: input.assetId,\n destinationChainId: BigInt(input.destinationChainId),\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport type CreateTradingWithdrawToFundingInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToFundingRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport const CreateTradingWithdrawResultSchema = v.object({\n intentId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n});\n\nexport type CreateTradingWithdrawResult = v.InferOutput<typeof CreateTradingWithdrawResultSchema>;\n\nexport const CreateWalletTradingWithdrawResultSchema = CreateTradingWithdrawResultSchema;\nexport type CreateWalletTradingWithdrawResult = v.InferOutput<\n typeof CreateWalletTradingWithdrawResultSchema\n>;\n\nexport const ValidateWithdrawDestinationInputSchema = v.pipe(\n v.strictObject({\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((input) => ({\n destinationChainId: BigInt(input.destinationChainId),\n destinationAddress: input.destinationAddress,\n })),\n);\n\nexport type ValidateWithdrawDestinationInput = v.InferInput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\nexport type ValidateWithdrawDestinationRequest = v.InferOutput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\n\nconst ValidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(true),\n code: v.literal(WithdrawDestinationValidationCode.VALID),\n message: v.string(),\n canonicalDestinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((result) => ({\n ...result,\n code: WithdrawDestinationValidationCodeCodec.protoToOutput[result.code],\n })),\n);\n\nconst {\n [WithdrawDestinationValidationCode.VALID]: _validWithdrawDestinationCode,\n ...InvalidWithdrawDestinationCodeCodec\n} = WithdrawDestinationValidationCodeCodec.protoToOutput;\n\nconst InvalidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(false),\n code: v.picklist([\n WithdrawDestinationValidationCode.RESULT_UNSPECIFIED,\n WithdrawDestinationValidationCode.INVALID_ADDRESS,\n WithdrawDestinationValidationCode.UNSUPPORTED_CHAIN,\n WithdrawDestinationValidationCode.POLYESTER_SMART_ACCOUNT,\n WithdrawDestinationValidationCode.TOKEN_CONTRACT,\n WithdrawDestinationValidationCode.DENYLISTED_ADDRESS,\n ]),\n message: v.string(),\n canonicalDestinationAddress: v.string(),\n }),\n v.transform((result) => ({\n ...result,\n code: InvalidWithdrawDestinationCodeCodec[result.code],\n })),\n);\n\nexport const ValidateWithdrawDestinationResultSchema = v.union([\n ValidWithdrawDestinationResultSchema,\n InvalidWithdrawDestinationResultSchema,\n]);\n\nexport type ValidateWithdrawDestinationResult = v.InferOutput<\n typeof ValidateWithdrawDestinationResultSchema\n>;\n"],"mappings":";;;;;;;;;AAgBA,MAAM,2BAA2B;AAmBjC,SAAS,cAAsB;CAC3B,MAAM,SAAS,WAAW,QAAQ,iBAAiB,KAAK,WAAW,MAAM;CACzE,IAAI,CAAC,QACD,MAAM,IAAI,mBAAmB,0DAA0D;CAG3F,MAAM,wBAAQ,IAAI,eAAe,CAAC;CAClC,OAAO,KAAK;CACZ,MAAM,QAAQ,MAAM;CACpB,OAAO,UAAU,KAAK,KAAK;AAC/B;AAEA,SAAS,6BAA6B,OAOE;CACpC,OAAO;EACH,QAAQ,MAAM;EACd,SAAS,MAAM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AAM,EAAE,QAAA,CAA+C;CACvD,SAAS,EAAE,OAAO;CAClB,6BAA6B,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;AAC5E,CAAC,GACD,EAAE,WAAW,YAAY;CACrB,GAAG;CACH,MAAM,uCAAuC,cAAc,OAAO;AACtE,EAAE,CACN;AAEA,MAAM,GAAA,IACyC,+BAC3C,GAAG,wCACH,uCAAuC;AAE3C,MAAM,yCAAyC,EAAE,KAC7C,EAAE,OAAO;CACL,OAAO,EAAE,QAAQ,KAAK;CACtB,MAAM,EAAE,SAAS;;;;;;;CAOjB,CAAC;CACD,SAAS,EAAE,OAAO;CAClB,6BAA6B,EAAE,OAAO;AAC1C,CAAC,GACD,EAAE,WAAW,YAAY;CACrB,GAAG;CACH,MAAM,oCAAoC,OAAO;AACrD,EAAE,CACN;AAEA,MAAa,0CAA0C,EAAE,MAAM,CAC3D,sCACA,sCACJ,CAAC"}
@@ -845,8 +845,8 @@ type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInpu
845
845
  declare const ListTriggersInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
846
846
  readonly parentOrderId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
847
847
  readonly symbolId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>;
848
- readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
849
- readonly triggerType: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["stop_loss", "take_profit", "trailing_stop", "twap", "ladder"], undefined>, undefined>, v.TransformAction<"twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop" | undefined, TriggerType>]>;
848
+ readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
849
+ readonly triggerType: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["stop_loss", "take_profit", "trailing_stop", "twap", "ladder"], undefined>, undefined>, v.TransformAction<"stop_loss" | "take_profit" | "trailing_stop" | "twap" | "ladder" | undefined, TriggerType>]>;
850
850
  readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 1000, undefined>]>, 50>;
851
851
  readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
852
852
  readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
@@ -31,62 +31,62 @@ declare const CreateTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSche
31
31
  type CreateTriggerResult = v.InferOutput<typeof CreateTriggerResultSchema>;
32
32
  declare const CancelTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
33
33
  readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
34
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused">]>;
34
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused">]>;
35
35
  readonly tsNs: v.BigintSchema<undefined>;
36
36
  }, undefined>, v.TransformAction<{
37
37
  triggerId: string;
38
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
38
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
39
39
  tsNs: bigint;
40
40
  }, {
41
41
  ts: number;
42
42
  tsNs: string;
43
43
  triggerId: string;
44
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
44
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
45
45
  }>]>;
46
46
  type CancelTriggerResult = v.InferOutput<typeof CancelTriggerResultSchema>;
47
47
  declare const ModifyTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
48
48
  readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
49
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused">]>;
49
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused">]>;
50
50
  readonly tsNs: v.BigintSchema<undefined>;
51
51
  }, undefined>, v.TransformAction<{
52
52
  triggerId: string;
53
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
53
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
54
54
  tsNs: bigint;
55
55
  }, {
56
56
  ts: number;
57
57
  tsNs: string;
58
58
  triggerId: string;
59
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
59
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
60
60
  }>]>;
61
61
  type ModifyTriggerResult = v.InferOutput<typeof ModifyTriggerResultSchema>;
62
62
  declare const PauseTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
63
63
  readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
64
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused">]>;
64
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused">]>;
65
65
  readonly tsNs: v.BigintSchema<undefined>;
66
66
  }, undefined>, v.TransformAction<{
67
67
  triggerId: string;
68
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
68
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
69
69
  tsNs: bigint;
70
70
  }, {
71
71
  ts: number;
72
72
  tsNs: string;
73
73
  triggerId: string;
74
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
74
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
75
75
  }>]>;
76
76
  type PauseTriggerResult = v.InferOutput<typeof PauseTriggerResultSchema>;
77
77
  declare const ResumeTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
78
78
  readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
79
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused">]>;
79
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused">]>;
80
80
  readonly tsNs: v.BigintSchema<undefined>;
81
81
  }, undefined>, v.TransformAction<{
82
82
  triggerId: string;
83
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
83
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
84
84
  tsNs: bigint;
85
85
  }, {
86
86
  ts: number;
87
87
  tsNs: string;
88
88
  triggerId: string;
89
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
89
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
90
90
  }>]>;
91
91
  type ResumeTriggerResult = v.InferOutput<typeof ResumeTriggerResultSchema>;
92
92
  type StopDetailsOutput = {
@@ -558,7 +558,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
558
558
  triggerId: string;
559
559
  subaccountId: string;
560
560
  symbolId: number;
561
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
561
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
562
562
  parentOrderId: string | undefined;
563
563
  qty: string;
564
564
  feeAsset: "unspecified" | "quote" | "base";
@@ -714,7 +714,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
714
714
  triggerId: string;
715
715
  subaccountId: string;
716
716
  symbolId: number;
717
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
717
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
718
718
  parentOrderId: string | undefined;
719
719
  qty: string;
720
720
  feeAsset: "unspecified" | "quote" | "base";
@@ -870,7 +870,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
870
870
  triggerId: string;
871
871
  subaccountId: string;
872
872
  symbolId: number;
873
- status: "unspecified" | "failed" | "cancelled" | "created" | "completed" | "armed" | "running" | "paused";
873
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
874
874
  parentOrderId: string | undefined;
875
875
  qty: string;
876
876
  feeAsset: "unspecified" | "quote" | "base";
@@ -1068,7 +1068,7 @@ declare function createTriggerEventSchema(scales: SdkScales): v.SchemaWithPipe<r
1068
1068
  triggerId: string;
1069
1069
  subaccountId: string;
1070
1070
  symbolId: number;
1071
- triggerType: "unspecified" | "twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop";
1071
+ triggerType: "unspecified" | "stop_loss" | "take_profit" | "trailing_stop" | "twap" | "ladder";
1072
1072
  eventType: "unspecified" | "failed" | "updated" | "fired" | "canceled";
1073
1073
  ts: number;
1074
1074
  childSeq: number;
@@ -1080,7 +1080,7 @@ declare function createTriggerEventSchema(scales: SdkScales): v.SchemaWithPipe<r
1080
1080
  triggerId: string;
1081
1081
  subaccountId: string;
1082
1082
  symbolId: number;
1083
- triggerType: "unspecified" | "twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop";
1083
+ triggerType: "unspecified" | "stop_loss" | "take_profit" | "trailing_stop" | "twap" | "ladder";
1084
1084
  eventType: "unspecified" | "failed" | "updated" | "fired" | "canceled";
1085
1085
  ts: number;
1086
1086
  childSeq: number;
@@ -1092,7 +1092,7 @@ declare function createTriggerEventSchema(scales: SdkScales): v.SchemaWithPipe<r
1092
1092
  triggerId: string;
1093
1093
  subaccountId: string;
1094
1094
  symbolId: number;
1095
- triggerType: "unspecified" | "twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop";
1095
+ triggerType: "unspecified" | "stop_loss" | "take_profit" | "trailing_stop" | "twap" | "ladder";
1096
1096
  eventType: "unspecified" | "failed" | "updated" | "fired" | "canceled";
1097
1097
  ts: number;
1098
1098
  childSeq: number;
@@ -1 +1 @@
1
- {"version":3,"file":"zipper.schemas.d.ts","names":[],"sources":["../../../src/services/zipper/zipper.schemas.ts"],"mappings":";;;;KAuHY;EACR;EACA;;KAGQ;EACR,SAAS"}
1
+ {"version":3,"file":"zipper.schemas.d.ts","names":[],"sources":["../../../src/services/zipper/zipper.schemas.ts"],"mappings":";;;;KAsHY;EACR;EACA;;KAGQ;EACR,SAAS"}
@@ -67,7 +67,6 @@ const DepositWithdrawConfigSchema = v.pipe(v.object({
67
67
  chains: v.array(ZipperChainConfigSchema),
68
68
  assets: v.array(ZipperAssetConfigSchema),
69
69
  tsSec: v.bigint(),
70
- polyesterChainId: v.number(),
71
70
  contracts: v.optional(v.array(ZipperChainContractConfigSchema), [])
72
71
  }), v.transform(({ tsSec, ...config }) => ({
73
72
  ...config,
@@ -1 +1 @@
1
- {"version":3,"file":"zipper.schemas.js","names":[],"sources":["../../../src/services/zipper/zipper.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport type {\n DepositWithdrawConfig,\n ZipperAssetChainVariant,\n ZipperAssetConfig,\n ZipperChainConfig,\n ZipperChainContractConfig,\n} from \"../../shared/catalog-config.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\n\nexport type {\n DepositWithdrawConfig,\n ZipperAssetChainVariant,\n ZipperAssetConfig,\n ZipperChainConfig,\n ZipperChainContractConfig,\n};\n\nexport const ZipperChainConfigSchema = v.object({\n chainId: v.number(),\n code: v.string(),\n name: v.string(),\n nativeChainId: v.optional(v.string(), \"\"),\n nativeCurrencySymbol: v.string(),\n explorerUrl: v.string(),\n icon: v.string(),\n requiredConfirmations: v.number(),\n confirmationTimeSeconds: v.number(),\n isCaseSensitive: v.optional(v.boolean(), false),\n minAddressLength: v.number(),\n maxAddressLength: v.number(),\n});\n\nconst ZipperAssetChainVariantWireSchema = v.object({\n zippedAssetId: v.number(),\n chainId: v.number(),\n isNativeAsset: v.optional(v.boolean(), false),\n networkFee: v.optional(v.string(), \"0\"),\n networkFeeTsSec: v.pipe(v.optional(v.bigint(), 0n), v.transform(Number)),\n ztokenAddress: v.optional(v.string(), \"\"),\n sourceAddress: v.optional(v.string(), \"\"),\n sourceDecimals: v.optional(v.number(), 18),\n ztokenDecimals: v.optional(v.number(), 18),\n depositMinAmount: v.optional(v.string(), \"\"),\n withdrawMinAmount: v.optional(v.string(), \"\"),\n supplyQ: v.optional(v.bigint(), 0n),\n});\n\nfunction normalizeZipperAssetChainVariant(\n quantityScale: number,\n {\n sourceAddress,\n sourceDecimals,\n supplyQ,\n ztokenAddress,\n ztokenDecimals,\n ...variant\n }: v.InferOutput<typeof ZipperAssetChainVariantWireSchema>,\n): ZipperAssetChainVariant {\n return {\n ...variant,\n supply: scaledToDecimalOutput(supplyQ, quantityScale),\n sourceToken: {\n address: sourceAddress,\n decimals: sourceDecimals,\n },\n zToken: {\n address: ztokenAddress,\n decimals: ztokenDecimals,\n },\n };\n}\n\nexport const ZipperAssetConfigSchema = v.pipe(\n v.object({\n asset: v.string(),\n ledgerId: v.number(),\n name: v.string(),\n icon: v.string(),\n quantityScale: v.number(),\n quantityDisplayDecimals: v.number(),\n variants: v.array(ZipperAssetChainVariantWireSchema),\n uAssetId: v.optional(v.string(), \"\"),\n }),\n v.transform(({ variants, ...asset }) => ({\n ...asset,\n variants: variants.map((variant) =>\n normalizeZipperAssetChainVariant(asset.quantityScale, variant),\n ),\n })),\n);\n\nexport const ZipperChainContractConfigSchema = v.object({\n name: v.string(),\n address: v.string(),\n type: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n version: v.optional(v.number(), 0),\n});\n\nexport const DepositWithdrawConfigSchema = v.pipe(\n v.object({\n chains: v.array(ZipperChainConfigSchema),\n assets: v.array(ZipperAssetConfigSchema),\n tsSec: v.bigint(),\n polyesterChainId: v.number(),\n contracts: v.optional(v.array(ZipperChainContractConfigSchema), []),\n }),\n v.transform(({ tsSec, ...config }) => ({\n ...config,\n tsMs: Number(tsSec) * 1000,\n })),\n);\n\nconst ZippedAssetSupplyUpdateWireSchema = v.object({\n zippedAssetId: v.number(),\n supplyQ: v.bigint(),\n});\n\nexport type ZippedAssetSupplyUpdate = {\n zippedAssetId: number;\n supply: string;\n};\n\nexport type ZippedAssetSupplyBatch = {\n updates: ZippedAssetSupplyUpdate[];\n};\n\nexport function createZippedAssetSupplyBatchSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n updates: v.array(ZippedAssetSupplyUpdateWireSchema),\n }),\n v.transform(\n (batch): ZippedAssetSupplyBatch => ({\n updates: batch.updates.map((update) => ({\n zippedAssetId: update.zippedAssetId,\n supply: scaledToDecimalOutput(\n update.supplyQ,\n scales.zippedAssetAmount(update.zippedAssetId),\n ),\n })),\n }),\n ),\n );\n}\n"],"mappings":";;;AAkBA,MAAa,0BAA0B,EAAE,OAAO;CAC5C,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO;CACf,MAAM,EAAE,OAAO;CACf,eAAe,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACxC,sBAAsB,EAAE,OAAO;CAC/B,aAAa,EAAE,OAAO;CACtB,MAAM,EAAE,OAAO;CACf,uBAAuB,EAAE,OAAO;CAChC,yBAAyB,EAAE,OAAO;CAClC,iBAAiB,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;CAC9C,kBAAkB,EAAE,OAAO;CAC3B,kBAAkB,EAAE,OAAO;AAC/B,CAAC;AAED,MAAM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J,EAAE,CACN;AAEA,MAAa,kCAAkC,EAAE,OAAO;CACpD,MAAM,EAAE,OAAO;CACf,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CAC/B,aAAa,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACtC,SAAS,EAAE,SAAS,EAAE,OAAO,GAAG,CAAC;AACrC,CAAC;AAED,MAAa,8BAA8B,EAAE,KACzC,EAAE,OAAO;CACL,QAAQ,EAAE,MAAM,uBAAuB;CACvC,QAAQ,EAAE,MAAM,uBAAuB;CACvC,OAAO,EAAE,OAAO;CAChB,kBAAkB,EAAE,OAAO;CAC3B,WAAW,EAAE,SAAS,EAAE,MAAM,+BAA+B,GAAG,CAAC,CAAC;AACtE,CAAC,GACD,EAAE,WAAW,EAAE,OAAO,GAAG,cAAc;CACnC,GAAG;CACH,MAAM,OAAO,KAAK,IAAI;AAC1B,EAAE,CACN;AAEA,MAAM,oCAAoC,EAAE,OAAO;CAC/C,eAAe,EAAE,OAAO;CACxB,SAAS,EAAE,OAAO;AACtB,CAAC;AAWD,SAAgB,mCAAmC,QAAmB;CAClE,OAAO,EAAE,KACL,EAAE,OAAO,EACL,SAAS,EAAE,MAAM,iCAAiC,EACtD,CAAC,GACD,EAAE,WACG,WAAmC,EAChC,SAAS,MAAM,QAAQ,KAAK,YAAY;EACpC,eAAe,OAAO;EACtB,QAAQ,sBACJ,OAAO,SACP,OAAO,kBAAkB,OAAO,aAAa,CACjD;CACJ,EAAE,EACN,EACJ,CACJ;AACJ"}
1
+ {"version":3,"file":"zipper.schemas.js","names":[],"sources":["../../../src/services/zipper/zipper.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport type {\n DepositWithdrawConfig,\n ZipperAssetChainVariant,\n ZipperAssetConfig,\n ZipperChainConfig,\n ZipperChainContractConfig,\n} from \"../../shared/catalog-config.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\n\nexport type {\n DepositWithdrawConfig,\n ZipperAssetChainVariant,\n ZipperAssetConfig,\n ZipperChainConfig,\n ZipperChainContractConfig,\n};\n\nexport const ZipperChainConfigSchema = v.object({\n chainId: v.number(),\n code: v.string(),\n name: v.string(),\n nativeChainId: v.optional(v.string(), \"\"),\n nativeCurrencySymbol: v.string(),\n explorerUrl: v.string(),\n icon: v.string(),\n requiredConfirmations: v.number(),\n confirmationTimeSeconds: v.number(),\n isCaseSensitive: v.optional(v.boolean(), false),\n minAddressLength: v.number(),\n maxAddressLength: v.number(),\n});\n\nconst ZipperAssetChainVariantWireSchema = v.object({\n zippedAssetId: v.number(),\n chainId: v.number(),\n isNativeAsset: v.optional(v.boolean(), false),\n networkFee: v.optional(v.string(), \"0\"),\n networkFeeTsSec: v.pipe(v.optional(v.bigint(), 0n), v.transform(Number)),\n ztokenAddress: v.optional(v.string(), \"\"),\n sourceAddress: v.optional(v.string(), \"\"),\n sourceDecimals: v.optional(v.number(), 18),\n ztokenDecimals: v.optional(v.number(), 18),\n depositMinAmount: v.optional(v.string(), \"\"),\n withdrawMinAmount: v.optional(v.string(), \"\"),\n supplyQ: v.optional(v.bigint(), 0n),\n});\n\nfunction normalizeZipperAssetChainVariant(\n quantityScale: number,\n {\n sourceAddress,\n sourceDecimals,\n supplyQ,\n ztokenAddress,\n ztokenDecimals,\n ...variant\n }: v.InferOutput<typeof ZipperAssetChainVariantWireSchema>,\n): ZipperAssetChainVariant {\n return {\n ...variant,\n supply: scaledToDecimalOutput(supplyQ, quantityScale),\n sourceToken: {\n address: sourceAddress,\n decimals: sourceDecimals,\n },\n zToken: {\n address: ztokenAddress,\n decimals: ztokenDecimals,\n },\n };\n}\n\nexport const ZipperAssetConfigSchema = v.pipe(\n v.object({\n asset: v.string(),\n ledgerId: v.number(),\n name: v.string(),\n icon: v.string(),\n quantityScale: v.number(),\n quantityDisplayDecimals: v.number(),\n variants: v.array(ZipperAssetChainVariantWireSchema),\n uAssetId: v.optional(v.string(), \"\"),\n }),\n v.transform(({ variants, ...asset }) => ({\n ...asset,\n variants: variants.map((variant) =>\n normalizeZipperAssetChainVariant(asset.quantityScale, variant),\n ),\n })),\n);\n\nexport const ZipperChainContractConfigSchema = v.object({\n name: v.string(),\n address: v.string(),\n type: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n version: v.optional(v.number(), 0),\n});\n\nexport const DepositWithdrawConfigSchema = v.pipe(\n v.object({\n chains: v.array(ZipperChainConfigSchema),\n assets: v.array(ZipperAssetConfigSchema),\n tsSec: v.bigint(),\n contracts: v.optional(v.array(ZipperChainContractConfigSchema), []),\n }),\n v.transform(({ tsSec, ...config }) => ({\n ...config,\n tsMs: Number(tsSec) * 1000,\n })),\n);\n\nconst ZippedAssetSupplyUpdateWireSchema = v.object({\n zippedAssetId: v.number(),\n supplyQ: v.bigint(),\n});\n\nexport type ZippedAssetSupplyUpdate = {\n zippedAssetId: number;\n supply: string;\n};\n\nexport type ZippedAssetSupplyBatch = {\n updates: ZippedAssetSupplyUpdate[];\n};\n\nexport function createZippedAssetSupplyBatchSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n updates: v.array(ZippedAssetSupplyUpdateWireSchema),\n }),\n v.transform(\n (batch): ZippedAssetSupplyBatch => ({\n updates: batch.updates.map((update) => ({\n zippedAssetId: update.zippedAssetId,\n supply: scaledToDecimalOutput(\n update.supplyQ,\n scales.zippedAssetAmount(update.zippedAssetId),\n ),\n })),\n }),\n ),\n );\n}\n"],"mappings":";;;AAkBA,MAAa,0BAA0B,EAAE,OAAO;CAC5C,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO;CACf,MAAM,EAAE,OAAO;CACf,eAAe,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACxC,sBAAsB,EAAE,OAAO;CAC/B,aAAa,EAAE,OAAO;CACtB,MAAM,EAAE,OAAO;CACf,uBAAuB,EAAE,OAAO;CAChC,yBAAyB,EAAE,OAAO;CAClC,iBAAiB,EAAE,SAAS,EAA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EAAE,UAAU,GAAG,aAAa;CACrC,GAAG;CACH,UAAU,SAAS,KAAK,YACpB,iCAAiC,MAAM,eAAe,OAAO,CACjE;AACJ,EAAE,CACN;AAEA,MAAa,kCAAkC,EAAE,OAAO;CACpD,MAAM,EAAE,OAAO;CACf,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CAC/B,aAAa,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACtC,SAAS,EAAE,SAAS,EAAE,OAAO,GAAG,CAAC;AACrC,CAAC;AAED,MAAa,8BAA8B,EAAE,KACzC,EAAE,OAAO;CACL,QAAQ,EAAE,MAAM,uBAAuB;CACvC,QAAQ,EAAE,MAAM,uBAAuB;CACvC,OAAO,EAAE,OAAO;CAChB,WAAW,EAAE,SAAS,EAAE,MAAM,+BAA+B,GAAG,CAAC,CAAC;AACtE,CAAC,GACD,EAAE,WAAW,EAAE,OAAO,GAAG,cAAc;CACnC,GAAG;CACH,MAAM,OAAO,KAAK,IAAI;AAC1B,EAAE,CACN;AAEA,MAAM,oCAAoC,EAAE,OAAO;CAC/C,eAAe,EAAE,OAAO;CACxB,SAAS,EAAE,OAAO;AACtB,CAAC;AAWD,SAAgB,mCAAmC,QAAmB;CAClE,OAAO,EAAE,KACL,EAAE,OAAO,EACL,SAAS,EAAE,MAAM,iCAAiC,EACtD,CAAC,GACD,EAAE,WACG,WAAmC,EAChC,SAAS,MAAM,QAAQ,KAAK,YAAY;EACpC,eAAe,OAAO;EACtB,QAAQ,sBACJ,OAAO,SACP,OAAO,kBAAkB,OAAO,aAAa,CACjD;CACJ,EAAE,EACN,EACJ,CACJ;AACJ"}
@@ -86,7 +86,6 @@ interface ZipperChainContractConfig {
86
86
  interface DepositWithdrawConfig {
87
87
  chains: ZipperChainConfig[];
88
88
  assets: ZipperAssetConfig[];
89
- polyesterChainId: number;
90
89
  contracts: ZipperChainContractConfig[];
91
90
  tsMs: number;
92
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"catalog-config.d.ts","names":[],"sources":["../../src/shared/catalog-config.ts"],"mappings":";KAAY;EACR;;KAGQ;cAQC;UAQI;EACb;EACA;EACA;EACA;EACA;;UAGa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;EACb;EACA;EACA;EACA;EACA,QAAQ;;UAGK;EACb,QAAQ;EACR,OAAO;EACP;;UAGa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGa;EACb;EACA;;UAGa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;EACb,QAAQ;;UAGK;EACb;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;;UAGa;EACb;EACA;EACA;EACA;EACA;;UAGa;EACb,QAAQ;EACR,QAAQ;EACR;EACA,WAAW;EACX"}
1
+ {"version":3,"file":"catalog-config.d.ts","names":[],"sources":["../../src/shared/catalog-config.ts"],"mappings":";KAAY;EACR;;KAGQ;cAQC;UAQI;EACb;EACA;EACA;EACA;EACA;;UAGa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;EACb;EACA;EACA;EACA;EACA,QAAQ;;UAGK;EACb,QAAQ;EACR,OAAO;EACP;;UAGa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGa;EACb;EACA;;UAGa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;EACb,QAAQ;;UAGK;EACb;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;;UAGa;EACb;EACA;EACA;EACA;EACA;;UAGa;EACb,QAAQ;EACR,QAAQ;EACR,WAAW;EACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"catalog-config.js","names":[],"sources":["../../src/shared/catalog-config.ts"],"sourcesContent":["export type PairMarketDataConfig = {\n orderbookPriceBuckets: number[];\n};\n\nexport type PairStatus =\n | \"enabled\"\n | \"disabled\"\n | \"cancel_only\"\n | \"post_only\"\n | \"reduce_only\"\n | \"unknown\";\n\nexport const PAIR_STATUSES = [\n \"enabled\",\n \"disabled\",\n \"cancel_only\",\n \"post_only\",\n \"reduce_only\",\n] as const satisfies readonly PairStatus[];\n\nexport interface AssetConfig {\n symbol: string;\n ledgerId: number;\n name: string;\n quantityDisplayDecimals: number;\n quantityScale: number;\n}\n\nexport interface PairConfig {\n symbolId: number;\n symbol: string;\n baseAsset: string;\n quoteAsset: string;\n tickSize: string;\n stepSize: string;\n minNotionalQuote: string;\n minQtyBase: string;\n allowBuyFeeFromBase: boolean;\n defaultMarketSlippagePctBuy: number;\n defaultMarketSlippagePctSell: number;\n maxClientRefDriftPct: number;\n marketdata?: PairMarketDataConfig;\n baseQuantityScale: number;\n quoteQuantityScale: number;\n listingAt?: number | null;\n delistingAt?: number | null;\n status: PairStatus;\n}\n\nexport interface SpotConfig {\n assets: AssetConfig[];\n pairs: PairConfig[];\n tsSec: number;\n}\n\nexport interface ZipperChainConfig {\n chainId: number;\n code: string;\n name: string;\n nativeChainId: string;\n nativeCurrencySymbol: string;\n explorerUrl: string;\n icon: string;\n requiredConfirmations: number;\n confirmationTimeSeconds: number;\n isCaseSensitive: boolean;\n minAddressLength: number;\n maxAddressLength: number;\n}\n\nexport interface ZipperTokenConfig {\n address: string;\n decimals: number;\n}\n\nexport interface ZipperAssetChainVariant {\n zippedAssetId: number;\n chainId: number;\n isNativeAsset: boolean;\n networkFee: string;\n networkFeeTsSec: number;\n depositMinAmount: string;\n withdrawMinAmount: string;\n supply: string;\n sourceToken: ZipperTokenConfig;\n zToken: ZipperTokenConfig;\n}\n\nexport interface ZipperAssetConfig {\n asset: string;\n ledgerId: number;\n name: string;\n icon: string;\n quantityScale: number;\n quantityDisplayDecimals: number;\n variants: ZipperAssetChainVariant[];\n uAssetId: string;\n}\n\nexport interface ZipperChainContractConfig {\n name: string;\n address: string;\n type: string;\n description: string;\n version: number;\n}\n\nexport interface DepositWithdrawConfig {\n chains: ZipperChainConfig[];\n assets: ZipperAssetConfig[];\n polyesterChainId: number;\n contracts: ZipperChainContractConfig[];\n tsMs: number;\n}\n"],"mappings":";AAYA,MAAa,gBAAgB;CACzB;CACA;CACA;CACA;CACA;AACJ"}
1
+ {"version":3,"file":"catalog-config.js","names":[],"sources":["../../src/shared/catalog-config.ts"],"sourcesContent":["export type PairMarketDataConfig = {\n orderbookPriceBuckets: number[];\n};\n\nexport type PairStatus =\n | \"enabled\"\n | \"disabled\"\n | \"cancel_only\"\n | \"post_only\"\n | \"reduce_only\"\n | \"unknown\";\n\nexport const PAIR_STATUSES = [\n \"enabled\",\n \"disabled\",\n \"cancel_only\",\n \"post_only\",\n \"reduce_only\",\n] as const satisfies readonly PairStatus[];\n\nexport interface AssetConfig {\n symbol: string;\n ledgerId: number;\n name: string;\n quantityDisplayDecimals: number;\n quantityScale: number;\n}\n\nexport interface PairConfig {\n symbolId: number;\n symbol: string;\n baseAsset: string;\n quoteAsset: string;\n tickSize: string;\n stepSize: string;\n minNotionalQuote: string;\n minQtyBase: string;\n allowBuyFeeFromBase: boolean;\n defaultMarketSlippagePctBuy: number;\n defaultMarketSlippagePctSell: number;\n maxClientRefDriftPct: number;\n marketdata?: PairMarketDataConfig;\n baseQuantityScale: number;\n quoteQuantityScale: number;\n listingAt?: number | null;\n delistingAt?: number | null;\n status: PairStatus;\n}\n\nexport interface SpotConfig {\n assets: AssetConfig[];\n pairs: PairConfig[];\n tsSec: number;\n}\n\nexport interface ZipperChainConfig {\n chainId: number;\n code: string;\n name: string;\n nativeChainId: string;\n nativeCurrencySymbol: string;\n explorerUrl: string;\n icon: string;\n requiredConfirmations: number;\n confirmationTimeSeconds: number;\n isCaseSensitive: boolean;\n minAddressLength: number;\n maxAddressLength: number;\n}\n\nexport interface ZipperTokenConfig {\n address: string;\n decimals: number;\n}\n\nexport interface ZipperAssetChainVariant {\n zippedAssetId: number;\n chainId: number;\n isNativeAsset: boolean;\n networkFee: string;\n networkFeeTsSec: number;\n depositMinAmount: string;\n withdrawMinAmount: string;\n supply: string;\n sourceToken: ZipperTokenConfig;\n zToken: ZipperTokenConfig;\n}\n\nexport interface ZipperAssetConfig {\n asset: string;\n ledgerId: number;\n name: string;\n icon: string;\n quantityScale: number;\n quantityDisplayDecimals: number;\n variants: ZipperAssetChainVariant[];\n uAssetId: string;\n}\n\nexport interface ZipperChainContractConfig {\n name: string;\n address: string;\n type: string;\n description: string;\n version: number;\n}\n\nexport interface DepositWithdrawConfig {\n chains: ZipperChainConfig[];\n assets: ZipperAssetConfig[];\n contracts: ZipperChainContractConfig[];\n tsMs: number;\n}\n"],"mappings":";AAYA,MAAa,gBAAgB;CACzB;CACA;CACA;CACA;CACA;AACJ"}
@@ -80,8 +80,9 @@ declare abstract class PolyesterError extends Error {
80
80
  }
81
81
  /**
82
82
  * A transient failure — the request may never have reached the backend or the
83
- * backend was temporarily unable to serve it. Safe to retry (use the same
84
- * `requestId`/`clientOrderId` for mutations; the backend dedupes).
83
+ * backend was temporarily unable to serve it. Follow the operation's retry
84
+ * contract: reuse requestId for idempotent mutations. For single-order creation,
85
+ * reconcile by clientOrderId; reusing it returns a conflict rather than replay.
85
86
  */
86
87
  declare class TransientError extends PolyesterError {
87
88
  readonly code: string;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","names":[],"sources":["../../src/shared/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2DY;UA+BK;;EAEb;;EAEA,SAAS;;iBAKG,sBAAsB;;;;;;;;uBAWhB,uBAAuB;;oBAEvB;;oBAEA;WACT,QAAQ;EAEL,YAAA,iBAAiB,UAAU;;;;;;;cAc9B,uBAAuB;WACvB;WACA;EAEG,YAAA,iBAAiB,UAAU;;;cAO9B,qBAAqB;WACZ;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,qBAAqB;WACZ;EAEN,YAAA,iBA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;WACxB;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,2BAA2B;WAClB;EAEN,YAAA,iBAAiB,UAAU;;;;;;cAU9B,yBAAyB;WAChB;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,mCAAmC;WAC1B;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,4BAA4B;WACnB;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,sCAAsC;WAC7B;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,mCAAmC;WAC1B;EAEN,YAAA,iBAAiB,UAAU;;;KAO/B;;;;;cAWC,6BAA6B;WAKzB,QAAQ;WAJH;EAGd,YAAA,iBACS,QAAQ,8BACjB,UAAU;;;;;;;cAYL,4BAA4B;WAC5B;WACA;EAEG,YAAA,iBAAiB,UAAU;;;;;;;iBAW3B,aAAa;;iBAKb,oBACZ,gBACA,iBACA,UAAU,wBACX"}
@@ -20,8 +20,9 @@ var PolyesterError = class PolyesterError extends Error {
20
20
  };
21
21
  /**
22
22
  * A transient failure — the request may never have reached the backend or the
23
- * backend was temporarily unable to serve it. Safe to retry (use the same
24
- * `requestId`/`clientOrderId` for mutations; the backend dedupes).
23
+ * backend was temporarily unable to serve it. Follow the operation's retry
24
+ * contract: reuse requestId for idempotent mutations. For single-order creation,
25
+ * reconcile by clientOrderId; reusing it returns a conflict rather than replay.
25
26
  */
26
27
  var TransientError = class extends PolyesterError {
27
28
  code = "TRANSIENT_FAILURE";