@polyester/sdk 0.36.0-devnet-20261117035807 → 0.36.0-devnet-20261118123359

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 (56) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/dist/realtime/client.js +5 -1
  3. package/dist/realtime/client.js.map +1 -1
  4. package/dist/realtime/snapshot-then-stream.js +5 -3
  5. package/dist/realtime/snapshot-then-stream.js.map +1 -1
  6. package/dist/services/address-book/address-book.schemas.d.ts +2 -2
  7. package/dist/services/assistant/assistant-events.schemas.d.ts +82 -82
  8. package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts +22 -22
  9. package/dist/services/candles/candles.schemas.d.ts +10 -10
  10. package/dist/services/changelog/changelog.schemas.d.ts +38 -38
  11. package/dist/services/checkpoints/checkpoints.schemas.d.ts +3 -3
  12. package/dist/services/claims/claims.schemas.d.ts +2 -2
  13. package/dist/services/dust-conversion/dust-conversion.schemas.d.ts +11 -11
  14. package/dist/services/dust-conversion/dust-conversion.schemas.d.ts.map +1 -1
  15. package/dist/services/dust-conversion/dust-conversion.schemas.js +1 -1
  16. package/dist/services/dust-conversion/dust-conversion.schemas.js.map +1 -1
  17. package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
  18. package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +12 -12
  19. package/dist/services/lifecycle/lifecycle.d.ts +1 -1
  20. package/dist/services/lifecycle/lifecycle.js +2 -3
  21. package/dist/services/lifecycle/lifecycle.js.map +1 -1
  22. package/dist/services/lifecycle/lifecycle.schemas.d.ts +54 -54
  23. package/dist/services/notifications/notifications.schemas.d.ts +13 -1
  24. package/dist/services/notifications/notifications.schemas.d.ts.map +1 -1
  25. package/dist/services/orderbook/orderbook.js +3 -2
  26. package/dist/services/orderbook/orderbook.js.map +1 -1
  27. package/dist/services/orders/order-errors.schemas.d.ts +2 -2
  28. package/dist/services/orders/orders-batch.schemas.d.ts +52 -52
  29. package/dist/services/orders/orders-input.schemas.d.ts +6 -6
  30. package/dist/services/orders/orders-output.schemas.d.ts +17 -17
  31. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +1 -27
  32. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
  33. package/dist/services/rewards/rewards.schemas.d.ts +4 -4
  34. package/dist/services/statement-exports/statement-exports.schemas.d.ts +7 -7
  35. package/dist/services/statement-exports/statement-exports.schemas.d.ts.map +1 -1
  36. package/dist/services/statement-exports/statement-exports.schemas.js +1 -1
  37. package/dist/services/statement-exports/statement-exports.schemas.js.map +1 -1
  38. package/dist/services/subaccounts/subaccounts.d.ts +2 -1
  39. package/dist/services/subaccounts/subaccounts.d.ts.map +1 -1
  40. package/dist/services/subaccounts/subaccounts.js +2 -2
  41. package/dist/services/subaccounts/subaccounts.js.map +1 -1
  42. package/dist/services/subaccounts/subaccounts.schemas.d.ts +15 -15
  43. package/dist/services/system/system.schemas.d.ts +13 -13
  44. package/dist/services/trades/trades.schemas.d.ts +2 -2
  45. package/dist/services/triggers/trigger-child-order.schemas.js +1 -1
  46. package/dist/services/triggers/trigger-child-order.schemas.js.map +1 -1
  47. package/dist/services/triggers/trigger-input.schemas.d.ts +9 -9
  48. package/dist/services/triggers/triggers-output.schemas.d.ts +45 -45
  49. package/dist/shared/connect-error-mapping.d.ts.map +1 -1
  50. package/dist/shared/connect-error-mapping.js +24 -3
  51. package/dist/shared/connect-error-mapping.js.map +1 -1
  52. package/dist/shared/errors.d.ts +5 -1
  53. package/dist/shared/errors.d.ts.map +1 -1
  54. package/dist/shared/errors.js +3 -0
  55. package/dist/shared/errors.js.map +1 -1
  56. package/package.json +1 -1
@@ -49,7 +49,7 @@ declare const CheckpointBiggestTradeSchema: v.SchemaWithPipe<readonly [v.ObjectS
49
49
  side: number;
50
50
  at: number;
51
51
  }, {
52
- side: "buy" | "sell" | "unspecified";
52
+ side: "unspecified" | "buy" | "sell";
53
53
  symbolId: number;
54
54
  symbol: string;
55
55
  at: number;
@@ -229,7 +229,7 @@ declare const CheckpointSchema: v.ObjectSchema<{
229
229
  side: number;
230
230
  at: number;
231
231
  }, {
232
- side: "buy" | "sell" | "unspecified";
232
+ side: "unspecified" | "buy" | "sell";
233
233
  symbolId: number;
234
234
  symbol: string;
235
235
  at: number;
@@ -427,7 +427,7 @@ declare const CheckpointSchema: v.ObjectSchema<{
427
427
  readonly seasonResultUsd: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
428
428
  readonly subaccounts: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.MaxValueAction<bigint, bigint, undefined>, v.TransformAction<any, number>]>;
429
429
  /** Values computed from partial evidence; show them with an approximation marker. */
430
- readonly incomplete: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "volume" | "tools" | "deposits" | "withdrawals" | "top_pairs" | "order_types" | "time_in_force" | "order_status" | "median_limit_rest" | "internal_transfers" | "daily_claim_amounts" | "portfolio_value" | "trading_balances" | "funding_balances" | "transfers" | "season_result">]>, undefined>, readonly []>;
430
+ readonly incomplete: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "tools" | "deposits" | "withdrawals" | "volume" | "top_pairs" | "order_types" | "time_in_force" | "order_status" | "median_limit_rest" | "internal_transfers" | "daily_claim_amounts" | "portfolio_value" | "trading_balances" | "funding_balances" | "transfers" | "season_result">]>, undefined>, readonly []>;
431
431
  }, undefined>;
432
432
  /**
433
433
  * One frozen season recap of a root account and all of its subaccounts. An absent USD value
@@ -36,7 +36,7 @@ declare const DailyClaimTransferSchema: v.ObjectSchema<{
36
36
  }, undefined>;
37
37
  type DailyClaimTransfer = v.InferOutput<typeof DailyClaimTransferSchema>;
38
38
  declare const DailyClaimStatusSchema: v.ObjectSchema<{
39
- readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "available" | "processing" | "claimed" | "unavailable" | "payout_delayed">]>;
39
+ readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "processing" | "available" | "claimed" | "unavailable" | "payout_delayed">]>;
40
40
  readonly resetAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
41
41
  readonly seconds: v.BigintSchema<undefined>;
42
42
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -76,7 +76,7 @@ declare const DailyClaimStatusSchema: v.ObjectSchema<{
76
76
  type DailyClaimStatus = v.InferOutput<typeof DailyClaimStatusSchema>;
77
77
  declare const ClaimDailyRewardResultSchema: v.ObjectSchema<{
78
78
  readonly claimId: v.StringSchema<undefined>;
79
- readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "available" | "processing" | "claimed" | "unavailable" | "payout_delayed">]>;
79
+ readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "processing" | "available" | "claimed" | "unavailable" | "payout_delayed">]>;
80
80
  readonly claimedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
81
81
  readonly seconds: v.BigintSchema<undefined>;
82
82
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -34,9 +34,9 @@ declare const QuoteDustConversionInputSchema: v.SchemaWithPipe<readonly [v.Stric
34
34
  type QuoteDustConversionInput = v.InferInput<typeof QuoteDustConversionInputSchema>;
35
35
  declare const CreateDustConversionInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
36
36
  /** `quoteId` from `quote`, at most 30 seconds old. A quote converts once. */
37
- readonly quoteId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
37
+ readonly quoteId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
38
38
  /** Stable key collapsing retries for the account; reusing it returns the same conversion. */
39
- readonly idempotencyKey: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
39
+ readonly idempotencyKey: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
40
40
  readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
41
41
  readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
42
42
  }, undefined>], undefined>, undefined>;
@@ -53,7 +53,7 @@ declare const CreateDustConversionInputSchema: v.SchemaWithPipe<readonly [v.Stri
53
53
  }>]>;
54
54
  type CreateDustConversionInput = v.InferInput<typeof CreateDustConversionInputSchema>;
55
55
  declare const GetDustConversionInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
56
- readonly conversionId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
56
+ readonly conversionId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
57
57
  readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
58
58
  readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
59
59
  }, undefined>], undefined>, undefined>;
@@ -147,7 +147,7 @@ type DustAssetPrice = v.InferOutput<typeof DustAssetPriceSchema>;
147
147
  declare const DustConversionSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
148
148
  readonly conversionId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
149
149
  readonly quoteId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
150
- readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "completed" | "processing" | "refused">]>;
150
+ readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "processing" | "completed" | "refused">]>;
151
151
  readonly refusalCode: v.NumberSchema<undefined>;
152
152
  readonly targetAssetId: v.NumberSchema<undefined>;
153
153
  readonly sources: v.ArraySchema<v.ObjectSchema<{
@@ -187,7 +187,7 @@ declare const DustConversionSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
187
187
  }, undefined>, v.TransformAction<{
188
188
  conversionId: string;
189
189
  quoteId: string;
190
- state: "unspecified" | "completed" | "processing" | "refused";
190
+ state: "unspecified" | "processing" | "completed" | "refused";
191
191
  refusalCode: number;
192
192
  targetAssetId: number;
193
193
  sources: {
@@ -216,9 +216,9 @@ declare const DustConversionSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
216
216
  conversionId: string;
217
217
  /** The quote the conversion converted. */
218
218
  quoteId: string;
219
- state: "unspecified" | "completed" | "processing" | "refused";
219
+ state: "unspecified" | "processing" | "completed" | "refused";
220
220
  /** Why a `refused` conversion was refused; null otherwise. */
221
- refusalCode: "UNSPECIFIED" | "INSUFFICIENT_FUNDS" | "UNAUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INTERNAL_ERROR" | "RATE_LIMIT_EXCEEDED" | "CONFLICT" | "INVALID_REQUEST" | "SERVICE_UNAVAILABLE" | "FAILED_PRECONDITION" | "SUBACCOUNT_NOT_FOUND" | "INVALID_SUBACCOUNT_ID" | "SOURCE_ACCOUNT_INACTIVE" | "UNSUPPORTED_ASSET" | "INVALID_AMOUNT" | "INVALID_DESTINATION" | "DESTINATION_NOT_FOUND" | "DESTINATION_INACTIVE" | "SAME_SOURCE_DESTINATION" | "DESTINATION_NOT_WHITELISTED" | "SMART_ACCOUNT_UNAVAILABLE" | "STEP_UP_UNAVAILABLE" | "IDEMPOTENCY_CONFLICT" | "FUNDS_LOCK_CONFLICT" | "CAPITAL_VIEW_UNAVAILABLE" | "ACCOUNT_SHARD_UNAVAILABLE" | "POLICY_DENIED" | "DUST_QUOTE_EXPIRED" | "DUST_PRICE_MOVED" | "DUST_NOT_ELIGIBLE" | "DUST_WINDOW_ACTIVE" | "DUST_DAILY_LIMIT" | "DUST_BUSY" | "DUST_TARGET_UNAVAILABLE" | "DUST_BALANCE_CHANGED" | "DUST_CONVERSION_FAILED" | null;
221
+ refusalCode: "UNSPECIFIED" | "INSUFFICIENT_FUNDS" | "INVALID_REQUEST" | "UNAUTHENTICATED" | "PERMISSION_DENIED" | "RATE_LIMIT_EXCEEDED" | "SERVICE_UNAVAILABLE" | "INTERNAL_ERROR" | "INVALID_SUBACCOUNT_ID" | "SUBACCOUNT_NOT_FOUND" | "SOURCE_ACCOUNT_INACTIVE" | "UNSUPPORTED_ASSET" | "INVALID_AMOUNT" | "INVALID_DESTINATION" | "DESTINATION_NOT_FOUND" | "DESTINATION_INACTIVE" | "SAME_SOURCE_DESTINATION" | "DESTINATION_NOT_WHITELISTED" | "SMART_ACCOUNT_UNAVAILABLE" | "STEP_UP_UNAVAILABLE" | "IDEMPOTENCY_CONFLICT" | "FUNDS_LOCK_CONFLICT" | "CAPITAL_VIEW_UNAVAILABLE" | "ACCOUNT_SHARD_UNAVAILABLE" | "POLICY_DENIED" | "FAILED_PRECONDITION" | "NOT_FOUND" | "CONFLICT" | "DUST_QUOTE_EXPIRED" | "DUST_PRICE_MOVED" | "DUST_NOT_ELIGIBLE" | "DUST_WINDOW_ACTIVE" | "DUST_DAILY_LIMIT" | "DUST_BUSY" | "DUST_TARGET_UNAVAILABLE" | "DUST_BALANCE_CHANGED" | "DUST_CONVERSION_FAILED" | null;
222
222
  targetAssetId: number;
223
223
  /** Whole quoted balances moved, in asset id order. */
224
224
  sources: {
@@ -463,7 +463,7 @@ declare const ListDustConversionsResultSchema: v.ObjectSchema<{
463
463
  readonly conversions: v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
464
464
  readonly conversionId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
465
465
  readonly quoteId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
466
- readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "completed" | "processing" | "refused">]>;
466
+ readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "processing" | "completed" | "refused">]>;
467
467
  readonly refusalCode: v.NumberSchema<undefined>;
468
468
  readonly targetAssetId: v.NumberSchema<undefined>;
469
469
  readonly sources: v.ArraySchema<v.ObjectSchema<{
@@ -503,7 +503,7 @@ declare const ListDustConversionsResultSchema: v.ObjectSchema<{
503
503
  }, undefined>, v.TransformAction<{
504
504
  conversionId: string;
505
505
  quoteId: string;
506
- state: "unspecified" | "completed" | "processing" | "refused";
506
+ state: "unspecified" | "processing" | "completed" | "refused";
507
507
  refusalCode: number;
508
508
  targetAssetId: number;
509
509
  sources: {
@@ -532,9 +532,9 @@ declare const ListDustConversionsResultSchema: v.ObjectSchema<{
532
532
  conversionId: string;
533
533
  /** The quote the conversion converted. */
534
534
  quoteId: string;
535
- state: "unspecified" | "completed" | "processing" | "refused";
535
+ state: "unspecified" | "processing" | "completed" | "refused";
536
536
  /** Why a `refused` conversion was refused; null otherwise. */
537
- refusalCode: "UNSPECIFIED" | "INSUFFICIENT_FUNDS" | "UNAUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INTERNAL_ERROR" | "RATE_LIMIT_EXCEEDED" | "CONFLICT" | "INVALID_REQUEST" | "SERVICE_UNAVAILABLE" | "FAILED_PRECONDITION" | "SUBACCOUNT_NOT_FOUND" | "INVALID_SUBACCOUNT_ID" | "SOURCE_ACCOUNT_INACTIVE" | "UNSUPPORTED_ASSET" | "INVALID_AMOUNT" | "INVALID_DESTINATION" | "DESTINATION_NOT_FOUND" | "DESTINATION_INACTIVE" | "SAME_SOURCE_DESTINATION" | "DESTINATION_NOT_WHITELISTED" | "SMART_ACCOUNT_UNAVAILABLE" | "STEP_UP_UNAVAILABLE" | "IDEMPOTENCY_CONFLICT" | "FUNDS_LOCK_CONFLICT" | "CAPITAL_VIEW_UNAVAILABLE" | "ACCOUNT_SHARD_UNAVAILABLE" | "POLICY_DENIED" | "DUST_QUOTE_EXPIRED" | "DUST_PRICE_MOVED" | "DUST_NOT_ELIGIBLE" | "DUST_WINDOW_ACTIVE" | "DUST_DAILY_LIMIT" | "DUST_BUSY" | "DUST_TARGET_UNAVAILABLE" | "DUST_BALANCE_CHANGED" | "DUST_CONVERSION_FAILED" | null;
537
+ refusalCode: "UNSPECIFIED" | "INSUFFICIENT_FUNDS" | "INVALID_REQUEST" | "UNAUTHENTICATED" | "PERMISSION_DENIED" | "RATE_LIMIT_EXCEEDED" | "SERVICE_UNAVAILABLE" | "INTERNAL_ERROR" | "INVALID_SUBACCOUNT_ID" | "SUBACCOUNT_NOT_FOUND" | "SOURCE_ACCOUNT_INACTIVE" | "UNSUPPORTED_ASSET" | "INVALID_AMOUNT" | "INVALID_DESTINATION" | "DESTINATION_NOT_FOUND" | "DESTINATION_INACTIVE" | "SAME_SOURCE_DESTINATION" | "DESTINATION_NOT_WHITELISTED" | "SMART_ACCOUNT_UNAVAILABLE" | "STEP_UP_UNAVAILABLE" | "IDEMPOTENCY_CONFLICT" | "FUNDS_LOCK_CONFLICT" | "CAPITAL_VIEW_UNAVAILABLE" | "ACCOUNT_SHARD_UNAVAILABLE" | "POLICY_DENIED" | "FAILED_PRECONDITION" | "NOT_FOUND" | "CONFLICT" | "DUST_QUOTE_EXPIRED" | "DUST_PRICE_MOVED" | "DUST_NOT_ELIGIBLE" | "DUST_WINDOW_ACTIVE" | "DUST_DAILY_LIMIT" | "DUST_BUSY" | "DUST_TARGET_UNAVAILABLE" | "DUST_BALANCE_CHANGED" | "DUST_CONVERSION_FAILED" | null;
538
538
  targetAssetId: number;
539
539
  /** Whole quoted balances moved, in asset id order. */
540
540
  sources: {
@@ -1 +1 @@
1
- {"version":3,"file":"dust-conversion.schemas.d.ts","names":[],"sources":["../../../src/services/dust-conversion/dust-conversion.schemas.ts"],"mappings":";;cAkBa,6BAA2B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;KAe5B,wBAAwB,EAAE,kBAAkB;cAE3C,gCAA8B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;KAe/B,2BAA2B,EAAE,kBAAkB;cAE9C,iCAA+B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;KAmBhC,4BAA4B,EAAE,kBAAkB;cAE/C,8BAA4B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;KAc7B,yBAAyB,EAAE,kBAAkB;cAE5C,gCAA8B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;KAkB/B,2BAA2B,EAAE,kBAAkB;;cAa9C,mBAAiB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiBlB,cAAc,EAAE,mBAAmB;;cAGlC,sBAAoB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;KAgBrB,iBAAiB,EAAE,mBAAmB;cAErC,sBAAoB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6CrB,iBAAiB,EAAE,mBAAmB;cAErC,8BAA4B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6B7B,yBAAyB,EAAE,mBAAmB;cAE7C,2BAAyB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;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AAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6B7B,yBAAyB,EAAE,mBAAmB;cAE7C,2BAAyB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+B1B,sBAAsB,EAAE,mBAAmB;cAE1C,iCAA+B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAMhC,4BAA4B,EAAE,mBAAmB"}
@@ -9,7 +9,7 @@ import { ErrorCode } from "../../gen/transfer/v1/internal_transfer_pb.js";
9
9
  import { DustAssetEligibilityCodec, DustConversionStateCodec } from "./dust-conversion.codecs.js";
10
10
  import * as v from "valibot";
11
11
  //#region src/services/dust-conversion/dust-conversion.schemas.ts
12
- const RequiredInputStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));
12
+ const RequiredInputStringSchema = v.pipe(v.string(), v.minLength(1));
13
13
  const ListDustBalancesInputSchema = v.pipe(v.strictObject({
14
14
  ...AccountScopeInputEntries,
15
15
  /** One of the response's `targets`; omit for the first. */
@@ -1 +1 @@
1
- {"version":3,"file":"dust-conversion.schemas.js","names":[],"sources":["../../../src/services/dust-conversion/dust-conversion.schemas.ts"],"sourcesContent":["import type { MessageInitShape } from \"@bufbuild/protobuf\";\nimport * as v from \"valibot\";\nimport type * as Proto from \"../../gen/transfer/v1/dust_conversion_pb.js\";\nimport { ErrorCode } from \"../../gen/transfer/v1/internal_transfer_pb.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { E18_SCALE, scaledToDecimalOutput } from \"../../shared/decimal-surface.js\";\nimport { codeName } from \"../../shared/error-detail.js\";\nimport { enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport { OptionalTimestampMsSchema, U128Schema } from \"../../shared/schemas.js\";\nimport { fromU128, type U128Value } from \"../../utils/u128.js\";\nimport { PositiveUint32InputSchema } from \"../shared.js\";\nimport { DustAssetEligibilityCodec, DustConversionStateCodec } from \"./dust-conversion.codecs.js\";\n\nconst RequiredInputStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\n\nexport const ListDustBalancesInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n /** One of the response's `targets`; omit for the first. */\n targetAssetId: v.optional(PositiveUint32InputSchema),\n }),\n v.transform(\n ({ account, targetAssetId }) =>\n ({\n subaccountId: accountScopeToSubaccountId(account),\n targetAssetId,\n }) satisfies MessageInitShape<typeof Proto.ListDustBalancesRequestSchema>,\n ),\n);\n\nexport type ListDustBalancesInput = v.InferInput<typeof ListDustBalancesInputSchema>;\n\nexport const QuoteDustConversionInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n /** One of `listBalances`' `targets`. */\n targetAssetId: PositiveUint32InputSchema,\n }),\n v.transform(\n ({ account, targetAssetId }) =>\n ({\n subaccountId: accountScopeToSubaccountId(account),\n targetAssetId,\n }) satisfies MessageInitShape<typeof Proto.QuoteDustConversionRequestSchema>,\n ),\n);\n\nexport type QuoteDustConversionInput = v.InferInput<typeof QuoteDustConversionInputSchema>;\n\nexport const CreateDustConversionInputSchema = v.pipe(\n v.strictObject({\n /** Must select the quote's account. */\n ...AccountScopeInputEntries,\n /** `quoteId` from `quote`, at most 30 seconds old. A quote converts once. */\n quoteId: RequiredInputStringSchema,\n /** Stable key collapsing retries for the account; reusing it returns the same conversion. */\n idempotencyKey: RequiredInputStringSchema,\n }),\n v.transform(\n ({ account, quoteId, idempotencyKey }) =>\n ({\n subaccountId: accountScopeToSubaccountId(account),\n quoteId,\n idempotencyKey,\n }) satisfies MessageInitShape<typeof Proto.CreateDustConversionRequestSchema>,\n ),\n);\n\nexport type CreateDustConversionInput = v.InferInput<typeof CreateDustConversionInputSchema>;\n\nexport const GetDustConversionInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n conversionId: RequiredInputStringSchema,\n }),\n v.transform(\n ({ account, conversionId }) =>\n ({\n subaccountId: accountScopeToSubaccountId(account),\n conversionId,\n }) satisfies MessageInitShape<typeof Proto.GetDustConversionRequestSchema>,\n ),\n);\n\nexport type GetDustConversionInput = v.InferInput<typeof GetDustConversionInputSchema>;\n\nexport const ListDustConversionsInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n /** Page size: default 20, at most 100. */\n limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(100))),\n /** Previous `nextPageToken`; reuse only with the same account. */\n pageToken: v.optional(v.pipe(v.string(), v.trim())),\n }),\n v.transform(\n ({ account, limit, pageToken }) =>\n ({\n subaccountId: accountScopeToSubaccountId(account),\n limit,\n pageToken,\n }) satisfies MessageInitShape<typeof Proto.ListDustConversionsRequestSchema>,\n ),\n);\n\nexport type ListDustConversionsInput = v.InferInput<typeof ListDustConversionsInputSchema>;\n\n/** Wire `*_e18` U128 → exact decimal string; an unset amount is `\"0\"`. */\nfunction e18ToDecimal(value: U128Value | undefined): string {\n return scaledToDecimalOutput(fromU128(value), E18_SCALE);\n}\n\nconst AmountE18Schema = v.optional(U128Schema);\n\n/** Decimal scale a wire price may carry, as catalog scales are bounded. */\nconst PriceScaleSchema = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(18));\n\n/** One Trading balance judged for conversion. Amounts are decimal strings. */\nexport const DustBalanceSchema = v.pipe(\n v.object({\n assetId: v.number(),\n amountE18: AmountE18Schema,\n eligibility: enumLabelSchema(DustAssetEligibilityCodec.protoToOutput),\n usdValueE18: AmountE18Schema,\n }),\n v.transform((balance) => ({\n assetId: balance.assetId,\n /** The whole available balance: what no open order or other reservation holds. */\n amount: e18ToDecimal(balance.amountE18),\n eligibility: balance.eligibility,\n /** USD value, rounded down; null when the asset has no current price. */\n usdValue: balance.usdValueE18 === undefined ? null : e18ToDecimal(balance.usdValueE18),\n })),\n);\n\nexport type DustBalance = v.InferOutput<typeof DustBalanceSchema>;\n\n/** USD index price a quote used for one asset. */\nexport const DustAssetPriceSchema = v.pipe(\n v.object({\n assetId: v.number(),\n priceTicks: v.bigint(),\n priceScale: PriceScaleSchema,\n asOf: OptionalTimestampMsSchema,\n }),\n v.transform((price) => ({\n assetId: price.assetId,\n /** USD per whole asset unit, exact. */\n price: scaledToDecimalOutput(price.priceTicks, price.priceScale),\n /** Time of the oldest index observation the price used. */\n asOf: price.asOf ?? null,\n })),\n);\n\nexport type DustAssetPrice = v.InferOutput<typeof DustAssetPriceSchema>;\n\nexport const DustConversionSchema = v.pipe(\n v.object({\n conversionId: v.pipe(v.string(), v.minLength(1)),\n quoteId: v.pipe(v.string(), v.minLength(1)),\n state: enumLabelSchema(DustConversionStateCodec.protoToOutput),\n refusalCode: v.number(),\n targetAssetId: v.number(),\n sources: v.array(v.object({ assetId: v.number(), amountE18: AmountE18Schema })),\n payoutE18: AmountE18Schema,\n quotedPayoutE18: AmountE18Schema,\n feeE18: AmountE18Schema,\n feeBps: v.number(),\n createdAt: OptionalTimestampMsSchema,\n completedAt: OptionalTimestampMsSchema,\n }),\n v.transform((conversion) => ({\n conversionId: conversion.conversionId,\n /** The quote the conversion converted. */\n quoteId: conversion.quoteId,\n state: conversion.state,\n /** Why a `refused` conversion was refused; null otherwise. */\n refusalCode:\n conversion.refusalCode === ErrorCode.UNSPECIFIED\n ? null\n : (codeName(ErrorCode, conversion.refusalCode) ?? \"UNSPECIFIED\"),\n targetAssetId: conversion.targetAssetId,\n /** Whole quoted balances moved, in asset id order. */\n sources: conversion.sources.map((source) => ({\n assetId: source.assetId,\n amount: e18ToDecimal(source.amountE18),\n })),\n /** Target amount credited after the fee, at the index prices when it was created. */\n payout: e18ToDecimal(conversion.payoutE18),\n /** The payout the quote showed. */\n quotedPayout: e18ToDecimal(conversion.quotedPayoutE18),\n /** Fee taken from the payout, in the target asset. */\n fee: e18ToDecimal(conversion.feeE18),\n feeBps: conversion.feeBps,\n createdAt: conversion.createdAt ?? null,\n /** Null until `completed`. */\n completedAt: conversion.completedAt ?? null,\n })),\n);\n\n/** One conversion of the account's dust into a target asset. Amounts are decimal strings. */\nexport type DustConversion = v.InferOutput<typeof DustConversionSchema>;\n\nexport const ListDustBalancesResultSchema = v.pipe(\n v.object({\n targetAssetId: v.number(),\n targets: v.array(v.number()),\n feeBps: v.number(),\n balances: v.array(DustBalanceSchema),\n grossUsdE18: AmountE18Schema,\n payoutE18: AmountE18Schema,\n targetAvailable: v.boolean(),\n }),\n v.transform((result) => ({\n /** Target the balances were judged for. */\n targetAssetId: result.targetAssetId,\n /** Every asset the account can convert dust into, in preference order. */\n targets: result.targets,\n /** Fee taken from the payout. */\n feeBps: result.feeBps,\n /** Every nonzero available Trading balance, in asset id order. */\n balances: result.balances,\n /** Eligible balances' total USD value, rounded down. */\n grossUsd: e18ToDecimal(result.grossUsdE18),\n /** Target amount they would bring now, after the fee. */\n payout: e18ToDecimal(result.payoutE18),\n /** False when the target cannot be paid now; `quote` is then refused. */\n targetAvailable: result.targetAvailable,\n })),\n);\n\n/** The account's balances judged for one target. Reserves nothing. */\nexport type ListDustBalancesResult = v.InferOutput<typeof ListDustBalancesResultSchema>;\n\nexport const DustConversionQuoteSchema = v.pipe(\n v.object({\n quoteId: v.string(),\n expiresAt: OptionalTimestampMsSchema,\n targetAssetId: v.number(),\n feeBps: v.number(),\n grossUsdE18: AmountE18Schema,\n payoutE18: AmountE18Schema,\n balances: v.array(DustBalanceSchema),\n prices: v.array(DustAssetPriceSchema),\n }),\n v.transform((quote) => ({\n /** Pass to `create`. Empty when nothing converts; `balances` says why. */\n quoteId: quote.quoteId,\n /** After this, `create` refuses the quote with `DUST_QUOTE_EXPIRED`. */\n expiresAt: quote.expiresAt ?? null,\n targetAssetId: quote.targetAssetId,\n /** Fee taken from the payout. */\n feeBps: quote.feeBps,\n /** Sources' total USD value, rounded down. */\n grossUsd: e18ToDecimal(quote.grossUsdE18),\n /** Target amount after the fee, rounded down to the target's quantity precision. */\n payout: e18ToDecimal(quote.payoutE18),\n /** Every nonzero available Trading balance, sources and others, in asset id order. */\n balances: quote.balances,\n /** Prices of the sources and the target, in asset id order. */\n prices: quote.prices,\n })),\n);\n\n/** A quote valid for 30 seconds. Reserves nothing. */\nexport type DustConversionQuote = v.InferOutput<typeof DustConversionQuoteSchema>;\n\nexport const ListDustConversionsResultSchema = v.object({\n conversions: v.array(DustConversionSchema),\n nextPageToken: v.optional(v.string(), \"\"),\n});\n\n/** One page of conversions, newest first; an empty `nextPageToken` means no more. */\nexport type ListDustConversionsResult = v.InferOutput<typeof ListDustConversionsResultSchema>;\n"],"mappings":";;;;;;;;;;;AAgBA,MAAM,4BAA4B,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;AAE7E,MAAa,8BAA8B,EAAE,KACzC,EAAE,aAAa;CACX,GAAG;;CAEH,eAAe,EAAE,SAAS,yBAAyB;AACvD,CAAC,GACD,EAAE,WACG,EAAE,SAAS,qBACP;CACG,cAAc,2BAA2B,OAAO;CAChD;AACJ,EACR,CACJ;AAIA,MAAa,iCAAiC,EAAE,KAC5C,EAAE,aAAa;CACX,GAAG;;CAEH,eAAe;AACnB,CAAC,GACD,EAAE,WACG,EAAE,SAAS,qBACP;CACG,cAAc,2BAA2B,OAAO;CAChD;AACJ,EACR,CACJ;AAIA,MAAa,kCAAkC,EAAE,KAC7C,EAAE,aAAa;;CAEX,GAAG;;CAEH,SAAS;;CAET,gBAAgB;AACpB,CAAC,GACD,EAAE,WACG,EAAE,SAAS,SAAS,sBAChB;CACG,cAAc,2BAA2B,OAAO;CAChD;CACA;AACJ,EACR,CACJ;AAIA,MA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C/B,CAAC,GACD,EAAE,WAAW,YAAY;;CAErB,eAAe,OAAO;;CAEtB,SAAS,OAAO;;CAEhB,QAAQ,OAAO;;CAEf,UAAU,OAAO;;CAEjB,UAAU,aAAa,OAAO,WAAW;;CAEzC,QAAQ,aAAa,OAAO,SAAS;;CAErC,iBAAiB,OAAO;AAC5B,EAAE,CACN;AAKA,MAAa,4BAA4B,EAAE,KACvC,EAAE,OAAO;CACL,SAAS,EAAE,OAAO;CAClB,WAAW;CACX,eAAe,EAAE,OAAO;CACxB,QAAQ,EAAE,OAAO;CACjB,aAAa;CACb,WAAW;CACX,UAAU,EAAE,MAAM,iBAAiB;CACnC,QAAQ,EAAE,MAAM,oBAAoB;AACxC,CAAC,GACD,EAAE,WAAW,WAAW;;CAEpB,SAAS,MAAM;;CAEf,WAAW,MAAM,aAAa;CAC9B,eAAe,MAAM;;CAErB,QAAQ,MAAM;;CAEd,UAAU,aAAa,MAAM,WAAW;;CAExC,QAAQ,aAAa,MAAM,SAAS;;CAEpC,UAAU,MAAM;;CAEhB,QAAQ,MAAM;AAClB,EAAE,CACN;AAKA,MAAa,kCAAkC,EAAE,OAAO;CACpD,aAAa,EAAE,MAAM,oBAAoB;CACzC,eAAe,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;AAC5C,CAAC"}
1
+ {"version":3,"file":"dust-conversion.schemas.js","names":[],"sources":["../../../src/services/dust-conversion/dust-conversion.schemas.ts"],"sourcesContent":["import type { MessageInitShape } from \"@bufbuild/protobuf\";\nimport * as v from \"valibot\";\nimport type * as Proto from \"../../gen/transfer/v1/dust_conversion_pb.js\";\nimport { ErrorCode } from \"../../gen/transfer/v1/internal_transfer_pb.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { E18_SCALE, scaledToDecimalOutput } from \"../../shared/decimal-surface.js\";\nimport { codeName } from \"../../shared/error-detail.js\";\nimport { enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport { OptionalTimestampMsSchema, U128Schema } from \"../../shared/schemas.js\";\nimport { fromU128, type U128Value } from \"../../utils/u128.js\";\nimport { PositiveUint32InputSchema } from \"../shared.js\";\nimport { DustAssetEligibilityCodec, DustConversionStateCodec } from \"./dust-conversion.codecs.js\";\n\n// Sent exactly as given: trimming would make \" k \" and \"k\" the same idempotency key.\nconst RequiredInputStringSchema = v.pipe(v.string(), v.minLength(1));\n\nexport const ListDustBalancesInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n /** One of the response's `targets`; omit for the first. */\n targetAssetId: v.optional(PositiveUint32InputSchema),\n }),\n v.transform(\n ({ account, targetAssetId }) =>\n ({\n subaccountId: accountScopeToSubaccountId(account),\n targetAssetId,\n }) satisfies MessageInitShape<typeof Proto.ListDustBalancesRequestSchema>,\n ),\n);\n\nexport type ListDustBalancesInput = v.InferInput<typeof ListDustBalancesInputSchema>;\n\nexport const QuoteDustConversionInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n /** One of `listBalances`' `targets`. */\n targetAssetId: PositiveUint32InputSchema,\n }),\n v.transform(\n ({ account, targetAssetId }) =>\n ({\n subaccountId: accountScopeToSubaccountId(account),\n targetAssetId,\n }) satisfies MessageInitShape<typeof Proto.QuoteDustConversionRequestSchema>,\n ),\n);\n\nexport type QuoteDustConversionInput = v.InferInput<typeof QuoteDustConversionInputSchema>;\n\nexport const CreateDustConversionInputSchema = v.pipe(\n v.strictObject({\n /** Must select the quote's account. */\n ...AccountScopeInputEntries,\n /** `quoteId` from `quote`, at most 30 seconds old. A quote converts once. */\n quoteId: RequiredInputStringSchema,\n /** Stable key collapsing retries for the account; reusing it returns the same conversion. */\n idempotencyKey: RequiredInputStringSchema,\n }),\n v.transform(\n ({ account, quoteId, idempotencyKey }) =>\n ({\n subaccountId: accountScopeToSubaccountId(account),\n quoteId,\n idempotencyKey,\n }) satisfies MessageInitShape<typeof Proto.CreateDustConversionRequestSchema>,\n ),\n);\n\nexport type CreateDustConversionInput = v.InferInput<typeof CreateDustConversionInputSchema>;\n\nexport const GetDustConversionInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n conversionId: RequiredInputStringSchema,\n }),\n v.transform(\n ({ account, conversionId }) =>\n ({\n subaccountId: accountScopeToSubaccountId(account),\n conversionId,\n }) satisfies MessageInitShape<typeof Proto.GetDustConversionRequestSchema>,\n ),\n);\n\nexport type GetDustConversionInput = v.InferInput<typeof GetDustConversionInputSchema>;\n\nexport const ListDustConversionsInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n /** Page size: default 20, at most 100. */\n limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(100))),\n /** Previous `nextPageToken`; reuse only with the same account. */\n pageToken: v.optional(v.pipe(v.string(), v.trim())),\n }),\n v.transform(\n ({ account, limit, pageToken }) =>\n ({\n subaccountId: accountScopeToSubaccountId(account),\n limit,\n pageToken,\n }) satisfies MessageInitShape<typeof Proto.ListDustConversionsRequestSchema>,\n ),\n);\n\nexport type ListDustConversionsInput = v.InferInput<typeof ListDustConversionsInputSchema>;\n\n/** Wire `*_e18` U128 → exact decimal string; an unset amount is `\"0\"`. */\nfunction e18ToDecimal(value: U128Value | undefined): string {\n return scaledToDecimalOutput(fromU128(value), E18_SCALE);\n}\n\nconst AmountE18Schema = v.optional(U128Schema);\n\n/** Decimal scale a wire price may carry, as catalog scales are bounded. */\nconst PriceScaleSchema = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(18));\n\n/** One Trading balance judged for conversion. Amounts are decimal strings. */\nexport const DustBalanceSchema = v.pipe(\n v.object({\n assetId: v.number(),\n amountE18: AmountE18Schema,\n eligibility: enumLabelSchema(DustAssetEligibilityCodec.protoToOutput),\n usdValueE18: AmountE18Schema,\n }),\n v.transform((balance) => ({\n assetId: balance.assetId,\n /** The whole available balance: what no open order or other reservation holds. */\n amount: e18ToDecimal(balance.amountE18),\n eligibility: balance.eligibility,\n /** USD value, rounded down; null when the asset has no current price. */\n usdValue: balance.usdValueE18 === undefined ? null : e18ToDecimal(balance.usdValueE18),\n })),\n);\n\nexport type DustBalance = v.InferOutput<typeof DustBalanceSchema>;\n\n/** USD index price a quote used for one asset. */\nexport const DustAssetPriceSchema = v.pipe(\n v.object({\n assetId: v.number(),\n priceTicks: v.bigint(),\n priceScale: PriceScaleSchema,\n asOf: OptionalTimestampMsSchema,\n }),\n v.transform((price) => ({\n assetId: price.assetId,\n /** USD per whole asset unit, exact. */\n price: scaledToDecimalOutput(price.priceTicks, price.priceScale),\n /** Time of the oldest index observation the price used. */\n asOf: price.asOf ?? null,\n })),\n);\n\nexport type DustAssetPrice = v.InferOutput<typeof DustAssetPriceSchema>;\n\nexport const DustConversionSchema = v.pipe(\n v.object({\n conversionId: v.pipe(v.string(), v.minLength(1)),\n quoteId: v.pipe(v.string(), v.minLength(1)),\n state: enumLabelSchema(DustConversionStateCodec.protoToOutput),\n refusalCode: v.number(),\n targetAssetId: v.number(),\n sources: v.array(v.object({ assetId: v.number(), amountE18: AmountE18Schema })),\n payoutE18: AmountE18Schema,\n quotedPayoutE18: AmountE18Schema,\n feeE18: AmountE18Schema,\n feeBps: v.number(),\n createdAt: OptionalTimestampMsSchema,\n completedAt: OptionalTimestampMsSchema,\n }),\n v.transform((conversion) => ({\n conversionId: conversion.conversionId,\n /** The quote the conversion converted. */\n quoteId: conversion.quoteId,\n state: conversion.state,\n /** Why a `refused` conversion was refused; null otherwise. */\n refusalCode:\n conversion.refusalCode === ErrorCode.UNSPECIFIED\n ? null\n : (codeName(ErrorCode, conversion.refusalCode) ?? \"UNSPECIFIED\"),\n targetAssetId: conversion.targetAssetId,\n /** Whole quoted balances moved, in asset id order. */\n sources: conversion.sources.map((source) => ({\n assetId: source.assetId,\n amount: e18ToDecimal(source.amountE18),\n })),\n /** Target amount credited after the fee, at the index prices when it was created. */\n payout: e18ToDecimal(conversion.payoutE18),\n /** The payout the quote showed. */\n quotedPayout: e18ToDecimal(conversion.quotedPayoutE18),\n /** Fee taken from the payout, in the target asset. */\n fee: e18ToDecimal(conversion.feeE18),\n feeBps: conversion.feeBps,\n createdAt: conversion.createdAt ?? null,\n /** Null until `completed`. */\n completedAt: conversion.completedAt ?? null,\n })),\n);\n\n/** One conversion of the account's dust into a target asset. Amounts are decimal strings. */\nexport type DustConversion = v.InferOutput<typeof DustConversionSchema>;\n\nexport const ListDustBalancesResultSchema = v.pipe(\n v.object({\n targetAssetId: v.number(),\n targets: v.array(v.number()),\n feeBps: v.number(),\n balances: v.array(DustBalanceSchema),\n grossUsdE18: AmountE18Schema,\n payoutE18: AmountE18Schema,\n targetAvailable: v.boolean(),\n }),\n v.transform((result) => ({\n /** Target the balances were judged for. */\n targetAssetId: result.targetAssetId,\n /** Every asset the account can convert dust into, in preference order. */\n targets: result.targets,\n /** Fee taken from the payout. */\n feeBps: result.feeBps,\n /** Every nonzero available Trading balance, in asset id order. */\n balances: result.balances,\n /** Eligible balances' total USD value, rounded down. */\n grossUsd: e18ToDecimal(result.grossUsdE18),\n /** Target amount they would bring now, after the fee. */\n payout: e18ToDecimal(result.payoutE18),\n /** False when the target cannot be paid now; `quote` is then refused. */\n targetAvailable: result.targetAvailable,\n })),\n);\n\n/** The account's balances judged for one target. Reserves nothing. */\nexport type ListDustBalancesResult = v.InferOutput<typeof ListDustBalancesResultSchema>;\n\nexport const DustConversionQuoteSchema = v.pipe(\n v.object({\n quoteId: v.string(),\n expiresAt: OptionalTimestampMsSchema,\n targetAssetId: v.number(),\n feeBps: v.number(),\n grossUsdE18: AmountE18Schema,\n payoutE18: AmountE18Schema,\n balances: v.array(DustBalanceSchema),\n prices: v.array(DustAssetPriceSchema),\n }),\n v.transform((quote) => ({\n /** Pass to `create`. Empty when nothing converts; `balances` says why. */\n quoteId: quote.quoteId,\n /** After this, `create` refuses the quote with `DUST_QUOTE_EXPIRED`. */\n expiresAt: quote.expiresAt ?? null,\n targetAssetId: quote.targetAssetId,\n /** Fee taken from the payout. */\n feeBps: quote.feeBps,\n /** Sources' total USD value, rounded down. */\n grossUsd: e18ToDecimal(quote.grossUsdE18),\n /** Target amount after the fee, rounded down to the target's quantity precision. */\n payout: e18ToDecimal(quote.payoutE18),\n /** Every nonzero available Trading balance, sources and others, in asset id order. */\n balances: quote.balances,\n /** Prices of the sources and the target, in asset id order. */\n prices: quote.prices,\n })),\n);\n\n/** A quote valid for 30 seconds. Reserves nothing. */\nexport type DustConversionQuote = v.InferOutput<typeof DustConversionQuoteSchema>;\n\nexport const ListDustConversionsResultSchema = v.object({\n conversions: v.array(DustConversionSchema),\n nextPageToken: v.optional(v.string(), \"\"),\n});\n\n/** One page of conversions, newest first; an empty `nextPageToken` means no more. */\nexport type ListDustConversionsResult = v.InferOutput<typeof ListDustConversionsResultSchema>;\n"],"mappings":";;;;;;;;;;;AAiBA,MAAM,4BAA4B,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,CAAC,CAAC;AAEnE,MAAa,8BAA8B,EAAE,KACzC,EAAE,aAAa;CACX,GAAG;;CAEH,eAAe,EAAE,SAAS,yBAAyB;AACvD,CAAC,GACD,EAAE,WACG,EAAE,SAAS,qBACP;CACG,cAAc,2BAA2B,OAAO;CAChD;AACJ,EACR,CACJ;AAIA,MAAa,iCAAiC,EAAE,KAC5C,EAAE,aAAa;CACX,GAAG;;CAEH,eAAe;AACnB,CAAC,GACD,EAAE,WACG,EAAE,SAAS,qBACP;CACG,cAAc,2BAA2B,OAAO;CAChD;AACJ,EACR,CACJ;AAIA,MAAa,kCAAkC,EAAE,KAC7C,EAAE,aAAa;;CAEX,GAAG;;CAEH,SAAS;;CAET,gBAAgB;AACpB,CAAC,GACD,EAAE,WACG,EAAE,SAAS,SAAS,sBAChB;CACG,cAAc,2BAA2B,OAAO;CAChD;CACA;AACJ,EACR,CACJ;AAIA,MAAa,+BAA+B,EAAE,KAC1C,EAAE,aAAa;CACX,GAAG;CACH,cAAc;AAClB,CAAC,GACD,EAAE,WACG,EAAE,SAAS,oBACP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AAU,OAAO;;CAEjB,UAAU,aAAa,OAAO,WAAW;;CAEzC,QAAQ,aAAa,OAAO,SAAS;;CAErC,iBAAiB,OAAO;AAC5B,EAAE,CACN;AAKA,MAAa,4BAA4B,EAAE,KACvC,EAAE,OAAO;CACL,SAAS,EAAE,OAAO;CAClB,WAAW;CACX,eAAe,EAAE,OAAO;CACxB,QAAQ,EAAE,OAAO;CACjB,aAAa;CACb,WAAW;CACX,UAAU,EAAE,MAAM,iBAAiB;CACnC,QAAQ,EAAE,MAAM,oBAAoB;AACxC,CAAC,GACD,EAAE,WAAW,WAAW;;CAEpB,SAAS,MAAM;;CAEf,WAAW,MAAM,aAAa;CAC9B,eAAe,MAAM;;CAErB,QAAQ,MAAM;;CAEd,UAAU,aAAa,MAAM,WAAW;;CAExC,QAAQ,aAAa,MAAM,SAAS;;CAEpC,UAAU,MAAM;;CAEhB,QAAQ,MAAM;AAClB,EAAE,CACN;AAKA,MAAa,kCAAkC,EAAE,OAAO;CACpD,aAAa,EAAE,MAAM,oBAAoB;CACzC,eAAe,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;AAC5C,CAAC"}
@@ -14,7 +14,7 @@ type TimestampInit = {
14
14
  declare const GetOrderbookHeatmapInputSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
15
15
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
16
16
  readonly interval: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["1s", "1m", "5m", "1h"], undefined>, "1s">, v.TransformAction<"1s" | "1m" | "5m" | "1h", HeatmapInterval>]>;
17
- readonly depth: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly [1, 5, 10, 20, 50, 100, 200, 500, 1000], undefined>, 50>, v.TransformAction<1 | 5 | 10 | 20 | 100 | 200 | 500 | 1000 | 50, HeatmapDepth>]>;
17
+ readonly depth: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly [1, 5, 10, 20, 50, 100, 200, 500, 1000], undefined>, 50>, v.TransformAction<1 | 5 | 10 | 20 | 100 | 500 | 200 | 50 | 1000, HeatmapDepth>]>;
18
18
  readonly quantityMode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["close", "peak"], undefined>, "close">, v.TransformAction<"close" | "peak", HeatmapQuantityMode>]>;
19
19
  readonly limit: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 20000, undefined>]>;
20
20
  readonly startTsSec: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, number, undefined>, v.TransformAction<number, bigint>]>, undefined>;
@@ -227,7 +227,7 @@ type OrderbookHeatmapDeltaChain = ReturnType<typeof convertHeatmapDeltaChain>;
227
227
  declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.ObjectSchema<{
228
228
  readonly symbolId: v.NumberSchema<undefined>;
229
229
  readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"1s" | "1m" | "5m" | "1h">>]>;
230
- readonly depth: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, 1 | 5 | 10 | 20 | "unspecified" | 100 | 200 | 500 | 1000 | 50>]>;
230
+ readonly depth: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, 1 | "unspecified" | 5 | 10 | 20 | 100 | 500 | 200 | 50 | 1000>]>;
231
231
  readonly chain: v.OptionalSchema<v.ObjectSchema<{
232
232
  readonly baseKeyframe: v.OptionalSchema<v.ObjectSchema<{
233
233
  readonly tsSec: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
@@ -287,7 +287,7 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
287
287
  }, undefined>, v.TransformAction<{
288
288
  symbolId: number;
289
289
  interval: DecodedEnum<"1s" | "1m" | "5m" | "1h">;
290
- depth: 1 | 5 | 10 | 20 | "unspecified" | 100 | 200 | 500 | 1000 | 50;
290
+ depth: 1 | "unspecified" | 5 | 10 | 20 | 100 | 500 | 200 | 50 | 1000;
291
291
  chain?: {
292
292
  baseKeyframe?: {
293
293
  tsSec: number;
@@ -347,7 +347,7 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
347
347
  }, {
348
348
  symbolId: number;
349
349
  interval: DecodedEnum<"1s" | "1m" | "5m" | "1h">;
350
- depth: 1 | 5 | 10 | 20 | "unspecified" | 100 | 200 | 500 | 1000 | 50;
350
+ depth: 1 | "unspecified" | 5 | 10 | 20 | 100 | 500 | 200 | 50 | 1000;
351
351
  chain: {
352
352
  baseKeyframe: {
353
353
  tsSec: number;
@@ -138,7 +138,7 @@ declare function createCreateInternalTransferResultSchema(): v.SchemaWithPipe<re
138
138
  subaccountId: string | undefined;
139
139
  smartAccountAddress: string | undefined;
140
140
  }>]>, undefined>;
141
- readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "rejected" | "accepted">]>;
141
+ readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "accepted" | "rejected">]>;
142
142
  /** Lifecycle flow ID for `lifecycle.getAccountFlow`; empty when the server did not return one. */
143
143
  readonly flowId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
144
144
  }, undefined>, v.TransformAction<{
@@ -157,7 +157,7 @@ declare function createCreateInternalTransferResultSchema(): v.SchemaWithPipe<re
157
157
  subaccountId: string | undefined;
158
158
  smartAccountAddress: string | undefined;
159
159
  } | undefined;
160
- status: "unspecified" | "failed" | "rejected" | "accepted";
160
+ status: "unspecified" | "failed" | "accepted" | "rejected";
161
161
  flowId: string;
162
162
  }, {
163
163
  acceptedAtUnixMs: number;
@@ -174,7 +174,7 @@ declare function createCreateInternalTransferResultSchema(): v.SchemaWithPipe<re
174
174
  subaccountId: string | undefined;
175
175
  smartAccountAddress: string | undefined;
176
176
  } | undefined;
177
- status: "unspecified" | "failed" | "rejected" | "accepted";
177
+ status: "unspecified" | "failed" | "accepted" | "rejected";
178
178
  flowId: string;
179
179
  }>]>;
180
180
  type CreateInternalTransferResult = v.InferOutput<ReturnType<typeof createCreateInternalTransferResultSchema>>;
@@ -294,7 +294,7 @@ type BatchCreateInternalTransfersInput = v.InferInput<ReturnType<typeof createBa
294
294
  type InternalTransferBatchLegInput = BatchCreateInternalTransfersInput["legs"][number];
295
295
  declare const InternalTransferBatchLegResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
296
296
  readonly legIndex: v.NumberSchema<undefined>;
297
- readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "pending" | "accepted" | "refused" | "not_submitted">]>;
297
+ readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "refused" | "pending" | "accepted" | "not_submitted">]>;
298
298
  readonly requestId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, string | undefined>]>;
299
299
  readonly transferId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, string | undefined>]>;
300
300
  readonly flowId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, string | undefined>]>;
@@ -322,7 +322,7 @@ declare const InternalTransferBatchLegResultSchema: v.SchemaWithPipe<readonly [v
322
322
  readonly errorMessage: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, string | undefined>]>;
323
323
  }, undefined>, v.TransformAction<{
324
324
  legIndex: number;
325
- status: "unspecified" | "pending" | "accepted" | "refused" | "not_submitted";
325
+ status: "unspecified" | "refused" | "pending" | "accepted" | "not_submitted";
326
326
  requestId?: string | undefined;
327
327
  transferId?: string | undefined;
328
328
  flowId?: string | undefined;
@@ -345,9 +345,9 @@ declare const InternalTransferBatchLegResultSchema: v.SchemaWithPipe<readonly [v
345
345
  acceptedAtNs: string | undefined;
346
346
  quantity: string | undefined;
347
347
  /** Why the leg was refused, or why its outcome is not known yet; unset otherwise. */
348
- errorCode: "UNSPECIFIED" | "INSUFFICIENT_FUNDS" | "UNAUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INTERNAL_ERROR" | "RATE_LIMIT_EXCEEDED" | "CONFLICT" | "INVALID_REQUEST" | "SERVICE_UNAVAILABLE" | "FAILED_PRECONDITION" | "SUBACCOUNT_NOT_FOUND" | "INVALID_SUBACCOUNT_ID" | "SOURCE_ACCOUNT_INACTIVE" | "UNSUPPORTED_ASSET" | "INVALID_AMOUNT" | "INVALID_DESTINATION" | "DESTINATION_NOT_FOUND" | "DESTINATION_INACTIVE" | "SAME_SOURCE_DESTINATION" | "DESTINATION_NOT_WHITELISTED" | "SMART_ACCOUNT_UNAVAILABLE" | "STEP_UP_UNAVAILABLE" | "IDEMPOTENCY_CONFLICT" | "FUNDS_LOCK_CONFLICT" | "CAPITAL_VIEW_UNAVAILABLE" | "ACCOUNT_SHARD_UNAVAILABLE" | "POLICY_DENIED" | "DUST_QUOTE_EXPIRED" | "DUST_PRICE_MOVED" | "DUST_NOT_ELIGIBLE" | "DUST_WINDOW_ACTIVE" | "DUST_DAILY_LIMIT" | "DUST_BUSY" | "DUST_TARGET_UNAVAILABLE" | "DUST_BALANCE_CHANGED" | "DUST_CONVERSION_FAILED" | undefined;
348
+ errorCode: "UNSPECIFIED" | "INSUFFICIENT_FUNDS" | "INVALID_REQUEST" | "UNAUTHENTICATED" | "PERMISSION_DENIED" | "RATE_LIMIT_EXCEEDED" | "SERVICE_UNAVAILABLE" | "INTERNAL_ERROR" | "INVALID_SUBACCOUNT_ID" | "SUBACCOUNT_NOT_FOUND" | "SOURCE_ACCOUNT_INACTIVE" | "UNSUPPORTED_ASSET" | "INVALID_AMOUNT" | "INVALID_DESTINATION" | "DESTINATION_NOT_FOUND" | "DESTINATION_INACTIVE" | "SAME_SOURCE_DESTINATION" | "DESTINATION_NOT_WHITELISTED" | "SMART_ACCOUNT_UNAVAILABLE" | "STEP_UP_UNAVAILABLE" | "IDEMPOTENCY_CONFLICT" | "FUNDS_LOCK_CONFLICT" | "CAPITAL_VIEW_UNAVAILABLE" | "ACCOUNT_SHARD_UNAVAILABLE" | "POLICY_DENIED" | "FAILED_PRECONDITION" | "NOT_FOUND" | "CONFLICT" | "DUST_QUOTE_EXPIRED" | "DUST_PRICE_MOVED" | "DUST_NOT_ELIGIBLE" | "DUST_WINDOW_ACTIVE" | "DUST_DAILY_LIMIT" | "DUST_BUSY" | "DUST_TARGET_UNAVAILABLE" | "DUST_BALANCE_CHANGED" | "DUST_CONVERSION_FAILED" | undefined;
349
349
  legIndex: number;
350
- status: "unspecified" | "pending" | "accepted" | "refused" | "not_submitted";
350
+ status: "unspecified" | "refused" | "pending" | "accepted" | "not_submitted";
351
351
  requestId?: string | undefined;
352
352
  transferId?: string | undefined;
353
353
  flowId?: string | undefined;
@@ -364,11 +364,11 @@ type InternalTransferBatchLegResult = v.InferOutput<typeof InternalTransferBatch
364
364
  declare const BatchCreateInternalTransfersResultSchema: v.ObjectSchema<{
365
365
  /** Batch request ID; unset when the batch was refused. */
366
366
  readonly requestId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, string | undefined>]>;
367
- readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "submitted" | "refused">]>;
367
+ readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "refused" | "submitted">]>;
368
368
  /** One result per leg, in request order. */
369
369
  readonly legs: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
370
370
  readonly legIndex: v.NumberSchema<undefined>;
371
- readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "pending" | "accepted" | "refused" | "not_submitted">]>;
371
+ readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "refused" | "pending" | "accepted" | "not_submitted">]>;
372
372
  readonly requestId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, string | undefined>]>;
373
373
  readonly transferId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, string | undefined>]>;
374
374
  readonly flowId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, string | undefined>]>;
@@ -396,7 +396,7 @@ declare const BatchCreateInternalTransfersResultSchema: v.ObjectSchema<{
396
396
  readonly errorMessage: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, string | undefined>]>;
397
397
  }, undefined>, v.TransformAction<{
398
398
  legIndex: number;
399
- status: "unspecified" | "pending" | "accepted" | "refused" | "not_submitted";
399
+ status: "unspecified" | "refused" | "pending" | "accepted" | "not_submitted";
400
400
  requestId?: string | undefined;
401
401
  transferId?: string | undefined;
402
402
  flowId?: string | undefined;
@@ -419,9 +419,9 @@ declare const BatchCreateInternalTransfersResultSchema: v.ObjectSchema<{
419
419
  acceptedAtNs: string | undefined;
420
420
  quantity: string | undefined;
421
421
  /** Why the leg was refused, or why its outcome is not known yet; unset otherwise. */
422
- errorCode: "UNSPECIFIED" | "INSUFFICIENT_FUNDS" | "UNAUTHENTICATED" | "PERMISSION_DENIED" | "NOT_FOUND" | "INTERNAL_ERROR" | "RATE_LIMIT_EXCEEDED" | "CONFLICT" | "INVALID_REQUEST" | "SERVICE_UNAVAILABLE" | "FAILED_PRECONDITION" | "SUBACCOUNT_NOT_FOUND" | "INVALID_SUBACCOUNT_ID" | "SOURCE_ACCOUNT_INACTIVE" | "UNSUPPORTED_ASSET" | "INVALID_AMOUNT" | "INVALID_DESTINATION" | "DESTINATION_NOT_FOUND" | "DESTINATION_INACTIVE" | "SAME_SOURCE_DESTINATION" | "DESTINATION_NOT_WHITELISTED" | "SMART_ACCOUNT_UNAVAILABLE" | "STEP_UP_UNAVAILABLE" | "IDEMPOTENCY_CONFLICT" | "FUNDS_LOCK_CONFLICT" | "CAPITAL_VIEW_UNAVAILABLE" | "ACCOUNT_SHARD_UNAVAILABLE" | "POLICY_DENIED" | "DUST_QUOTE_EXPIRED" | "DUST_PRICE_MOVED" | "DUST_NOT_ELIGIBLE" | "DUST_WINDOW_ACTIVE" | "DUST_DAILY_LIMIT" | "DUST_BUSY" | "DUST_TARGET_UNAVAILABLE" | "DUST_BALANCE_CHANGED" | "DUST_CONVERSION_FAILED" | undefined;
422
+ errorCode: "UNSPECIFIED" | "INSUFFICIENT_FUNDS" | "INVALID_REQUEST" | "UNAUTHENTICATED" | "PERMISSION_DENIED" | "RATE_LIMIT_EXCEEDED" | "SERVICE_UNAVAILABLE" | "INTERNAL_ERROR" | "INVALID_SUBACCOUNT_ID" | "SUBACCOUNT_NOT_FOUND" | "SOURCE_ACCOUNT_INACTIVE" | "UNSUPPORTED_ASSET" | "INVALID_AMOUNT" | "INVALID_DESTINATION" | "DESTINATION_NOT_FOUND" | "DESTINATION_INACTIVE" | "SAME_SOURCE_DESTINATION" | "DESTINATION_NOT_WHITELISTED" | "SMART_ACCOUNT_UNAVAILABLE" | "STEP_UP_UNAVAILABLE" | "IDEMPOTENCY_CONFLICT" | "FUNDS_LOCK_CONFLICT" | "CAPITAL_VIEW_UNAVAILABLE" | "ACCOUNT_SHARD_UNAVAILABLE" | "POLICY_DENIED" | "FAILED_PRECONDITION" | "NOT_FOUND" | "CONFLICT" | "DUST_QUOTE_EXPIRED" | "DUST_PRICE_MOVED" | "DUST_NOT_ELIGIBLE" | "DUST_WINDOW_ACTIVE" | "DUST_DAILY_LIMIT" | "DUST_BUSY" | "DUST_TARGET_UNAVAILABLE" | "DUST_BALANCE_CHANGED" | "DUST_CONVERSION_FAILED" | undefined;
423
423
  legIndex: number;
424
- status: "unspecified" | "pending" | "accepted" | "refused" | "not_submitted";
424
+ status: "unspecified" | "refused" | "pending" | "accepted" | "not_submitted";
425
425
  requestId?: string | undefined;
426
426
  transferId?: string | undefined;
427
427
  flowId?: string | undefined;
@@ -52,7 +52,7 @@ declare class LifecycleService {
52
52
  */
53
53
  listFlowsByTx(input: ListLifecycleFlowsByTxInput, options?: PolyesterRequestOptions): Promise<ListLifecycleFlowsByTxOutput>;
54
54
  /**
55
- * Subscribes to open lifecycle flow summary updates, using private:chain:lifecycle:flows:{accountId}:proto when an account id is provided and the public flow channel otherwise.
55
+ * Subscribes to open lifecycle flow summary updates, using private:chain:lifecycle:flows:{accountId}:proto when `accountId` is set and the public all-accounts flow channel only when it is omitted.
56
56
  */
57
57
  subscribeOpenFlows(input: SubscribeOpenLifecycleFlowsInput): () => void;
58
58
  /**
@@ -79,11 +79,10 @@ var LifecycleService = class {
79
79
  return parse(ListLifecycleFlowsByTxOutputSchema, response);
80
80
  }
81
81
  /**
82
- * Subscribes to open lifecycle flow summary updates, using private:chain:lifecycle:flows:{accountId}:proto when an account id is provided and the public flow channel otherwise.
82
+ * Subscribes to open lifecycle flow summary updates, using private:chain:lifecycle:flows:{accountId}:proto when `accountId` is set and the public all-accounts flow channel only when it is omitted.
83
83
  */
84
84
  subscribeOpenFlows(input) {
85
- const accountId = input.accountId?.trim();
86
- const channel = accountId ? `private:chain:lifecycle:flows:${accountId}:proto` : "public:chain:lifecycle:flows:proto";
85
+ const channel = input.accountId === void 0 ? "public:chain:lifecycle:flows:proto" : `private:chain:lifecycle:flows:${input.accountId}:proto`;
87
86
  return this.#realtime.connectProtoChannel({
88
87
  channel,
89
88
  schema: FlowSummaryViewSchema,
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle.js","names":["#client","#authClient","#realtime","#resolver"],"sources":["../../../src/services/lifecycle/lifecycle.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport { create } from \"@bufbuild/protobuf\";\nimport {\n FlowDetailViewSchema,\n FlowSummaryViewSchema,\n GetFlowByIdRequestSchema,\n LifecycleReadService,\n} from \"../../gen/chain/lifecycle/v1/lifecycle_read_pb.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport { resolveAccountScopedInput, type SubaccountResolver } from \"../subaccount-resolver.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { isDev } from \"../../utils/is-dev.js\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport {\n GetLifecycleAccountFlowInputSchema,\n GetLifecycleFlowInputSchema,\n GetLifecycleFlowOutputSchema,\n LifecycleFlowDetailSchema,\n LifecycleFlowSummarySchema,\n ListLifecycleFlowsByTxOutputSchema,\n ListLifecycleFlowsByTxInputSchema,\n ListLifecycleFlowsOutputSchema,\n ListLifecycleFlowsInputSchema,\n ListLifecycleAccountFlowsInputSchema,\n type GetLifecycleAccountFlowInput,\n type GetLifecycleFlowInput,\n type GetLifecycleFlowOutput,\n type LifecycleFlowDetail,\n type LifecycleFlowSummary,\n type ListLifecycleFlowsByTxInput,\n type ListLifecycleFlowsByTxOutput,\n type ListLifecycleFlowsInput,\n type ListLifecycleAccountFlowsInput,\n type ListLifecycleFlowsOutput,\n} from \"./lifecycle.schemas.js\";\n\ninterface SubscribeOpenLifecycleFlowsInput extends BaseSubscribeInput<LifecycleFlowSummary> {\n accountId?: string;\n}\n\ninterface SubscribeLifecycleFlowDetailInput extends BaseSubscribeInput<LifecycleFlowDetail> {\n flowId: string;\n}\n\n/**\n * Reads and streams chain lifecycle flow state, history, progress, and transaction matches.\n */\nexport class LifecycleService {\n #client: Client<typeof LifecycleReadService>;\n #authClient: Client<typeof LifecycleReadService>;\n #realtime: PolyesterRealtime;\n #resolver?: SubaccountResolver;\n\n constructor(\n transports: AuthAndPublicApiTransports,\n realtime: PolyesterRealtime,\n resolver?: SubaccountResolver,\n ) {\n this.#client = createClient(LifecycleReadService, transports.publicApi);\n this.#authClient = createClient(LifecycleReadService, transports.authApi);\n this.#realtime = realtime;\n this.#resolver = resolver;\n }\n\n /**\n * Returns paginated lifecycle flow summaries filtered by kind, state, scope, account selector, transaction reference, chain ids, and asset ids. The response is ordered by the selected timestamp and includes an opaque next page token.\n *\n * Lists only flows a chain transaction started. With an `accountSelector` (a smart\n * account address), the list holds the flows the account owns and the transfers it\n * receives from other accounts; each row's `participation` says which. Pass\n * `participation: \"owner\"` for the owned flows only. A `pageToken` only resumes the\n * request it came from: change nothing but `limit` between pages. Use `listAccountFlows`\n * for every flow of the signed-in account.\n */\n async listFlows(\n input: ListLifecycleFlowsInput,\n options?: PolyesterRequestOptions,\n ): Promise<ListLifecycleFlowsOutput> {\n const parsedInput = parse(ListLifecycleFlowsInputSchema, input);\n const response = await this.#client.listFlows(parsedInput, toConnectCallOptions(options));\n const res = parse(ListLifecycleFlowsOutputSchema, response);\n return res;\n }\n\n /**\n * Lists the signed-in account's flows: the ones it owns and the transfers it receives,\n * including flows no chain transaction started, such as transfers between Trading accounts.\n * Each row's `participation` says which. Takes the same filters as `listFlows`; a\n * `pageToken` only resumes the request it came from. API keys need `read-funding-flows`.\n */\n async listAccountFlows(\n input: ListLifecycleAccountFlowsInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<ListLifecycleFlowsOutput> {\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const request = parse(ListLifecycleAccountFlowsInputSchema, resolved);\n const response = await this.#authClient.listAccountFlows(\n request,\n toConnectCallOptions(options),\n );\n return parse(ListLifecycleFlowsOutputSchema, response);\n }\n\n /**\n * Fetches one flow the signed-in account owns or receives, including one no chain\n * transaction started. A flow the account takes no part in throws `ResourceNotFoundError`. API keys\n * need `read-funding-flows`.\n */\n async getAccountFlow(\n input: GetLifecycleAccountFlowInput,\n options?: PolyesterRequestOptions,\n ): Promise<GetLifecycleFlowOutput> {\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const request = parse(GetLifecycleAccountFlowInputSchema, resolved);\n const response = await this.#authClient.getAccountFlow(\n request,\n toConnectCallOptions(options),\n );\n return parse(GetLifecycleFlowOutputSchema, response);\n }\n\n /**\n * Fetches one lifecycle flow by its public flow id and returns summary, factual steps,\n * timeline, and live-state detail when available. Finds only flows a chain transaction\n * started; the account reads its other flows with `getAccountFlow`.\n */\n async getFlow(\n input: GetLifecycleFlowInput,\n options?: PolyesterRequestOptions,\n ): Promise<GetLifecycleFlowOutput> {\n const parsedInput = parse(GetLifecycleFlowInputSchema, input);\n const response = await this.#client.getFlowById(\n create(GetFlowByIdRequestSchema, parsedInput),\n toConnectCallOptions(options),\n );\n return parse(GetLifecycleFlowOutputSchema, response);\n }\n\n /**\n * Searches lifecycle flows that reference a 0x-prefixed transaction hash, using source-only or any-reference lookup mode. A single transaction may match zero, one, or many flows.\n */\n async listFlowsByTx(\n input: ListLifecycleFlowsByTxInput,\n options?: PolyesterRequestOptions,\n ): Promise<ListLifecycleFlowsByTxOutput> {\n const parsedInput = parse(ListLifecycleFlowsByTxInputSchema, input);\n const response = await this.#client.listFlowsByTx(\n parsedInput,\n toConnectCallOptions(options),\n );\n return parse(ListLifecycleFlowsByTxOutputSchema, response);\n }\n\n /**\n * Subscribes to open lifecycle flow summary updates, using private:chain:lifecycle:flows:{accountId}:proto when an account id is provided and the public flow channel otherwise.\n */\n subscribeOpenFlows(input: SubscribeOpenLifecycleFlowsInput): () => void {\n const accountId = input.accountId?.trim();\n const channel = accountId\n ? `private:chain:lifecycle:flows:${accountId}:proto`\n : \"public:chain:lifecycle:flows:proto\";\n return this.#realtime.connectProtoChannel({\n channel,\n schema: FlowSummaryViewSchema,\n onPublication: (data) => {\n const flow = parse(LifecycleFlowSummarySchema, data);\n input.onEvent(flow);\n },\n onConnected: input.onOpen,\n onDisconnected: input.onClose,\n onError: input.onError,\n });\n }\n\n /**\n * Subscribes to detail updates for one lifecycle flow on public:chain:lifecycle:flow:{flowId}:proto. Invalid flow ids are rejected locally with a no-op unsubscribe function.\n */\n subscribeFlowDetail(input: SubscribeLifecycleFlowDetailInput): () => void {\n const parsedFlowId = v.safeParse(GetLifecycleFlowInputSchema, { flowId: input.flowId });\n if (!parsedFlowId.success) {\n if (isDev()) {\n console.error(\n \"[LifecycleService] flowId is required for flow detail subscription.\",\n );\n }\n return () => {};\n }\n\n const channel = `public:chain:lifecycle:flow:${parsedFlowId.output.flowId}:proto`;\n return this.#realtime.connectProtoChannel({\n channel,\n schema: FlowDetailViewSchema,\n onPublication: (data) => {\n const flow = parse(LifecycleFlowDetailSchema, data);\n input.onEvent(flow);\n },\n onConnected: input.onOpen,\n onDisconnected: input.onClose,\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAqDA,IAAa,mBAAb,MAA8B;CAC1B;CACA;CACA;CACA;CAEA,YACI,YACA,UACA,UACF;EACE,KAAKA,UAAU,aAAa,sBAAsB,WAAW,SAAS;EACtE,KAAKC,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,OAAO,KAAKE,UAAU,oBAAoB;GACtC;GACA,QAAQ;GACR,gBAAgB,SAAS;IACrB,MAAM,OAAO,MAAM,4BAA4B,IAAI;IACnD,MAAM,QAAQ,IAAI;GACtB;GACA,aAAa,MAAM;GACnB,gBAAgB,MAAM;GACtB,SAAS,MAAM;EACnB,CAAC;CACL;;;;CAKA,oBAAoB,OAAsD;EACtE,MAAM,eAAe,EAAE,UAAU,6BAA6B,EAAE,QAAQ,MAAM,OAAO,CAAC;EACtF,IAAI,CAAC,aAAa,SAAS;GACvB,IAAI,MAAM,GACN,QAAQ,MACJ,qEACJ;GAEJ,aAAa,CAAC;EAClB;EAEA,MAAM,UAAU,+BAA+B,aAAa,OAAO,OAAO;EAC1E,OAAO,KAAKA,UAAU,oBAAoB;GACtC;GACA,QAAQ;GACR,gBAAgB,SAAS;IACrB,MAAM,OAAO,MAAM,2BAA2B,IAAI;IAClD,MAAM,QAAQ,IAAI;GACtB;GACA,aAAa,MAAM;GACnB,gBAAgB,MAAM;GACtB,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
1
+ {"version":3,"file":"lifecycle.js","names":["#client","#authClient","#realtime","#resolver"],"sources":["../../../src/services/lifecycle/lifecycle.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport { create } from \"@bufbuild/protobuf\";\nimport {\n FlowDetailViewSchema,\n FlowSummaryViewSchema,\n GetFlowByIdRequestSchema,\n LifecycleReadService,\n} from \"../../gen/chain/lifecycle/v1/lifecycle_read_pb.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport { resolveAccountScopedInput, type SubaccountResolver } from \"../subaccount-resolver.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { isDev } from \"../../utils/is-dev.js\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport {\n GetLifecycleAccountFlowInputSchema,\n GetLifecycleFlowInputSchema,\n GetLifecycleFlowOutputSchema,\n LifecycleFlowDetailSchema,\n LifecycleFlowSummarySchema,\n ListLifecycleFlowsByTxOutputSchema,\n ListLifecycleFlowsByTxInputSchema,\n ListLifecycleFlowsOutputSchema,\n ListLifecycleFlowsInputSchema,\n ListLifecycleAccountFlowsInputSchema,\n type GetLifecycleAccountFlowInput,\n type GetLifecycleFlowInput,\n type GetLifecycleFlowOutput,\n type LifecycleFlowDetail,\n type LifecycleFlowSummary,\n type ListLifecycleFlowsByTxInput,\n type ListLifecycleFlowsByTxOutput,\n type ListLifecycleFlowsInput,\n type ListLifecycleAccountFlowsInput,\n type ListLifecycleFlowsOutput,\n} from \"./lifecycle.schemas.js\";\n\ninterface SubscribeOpenLifecycleFlowsInput extends BaseSubscribeInput<LifecycleFlowSummary> {\n accountId?: string;\n}\n\ninterface SubscribeLifecycleFlowDetailInput extends BaseSubscribeInput<LifecycleFlowDetail> {\n flowId: string;\n}\n\n/**\n * Reads and streams chain lifecycle flow state, history, progress, and transaction matches.\n */\nexport class LifecycleService {\n #client: Client<typeof LifecycleReadService>;\n #authClient: Client<typeof LifecycleReadService>;\n #realtime: PolyesterRealtime;\n #resolver?: SubaccountResolver;\n\n constructor(\n transports: AuthAndPublicApiTransports,\n realtime: PolyesterRealtime,\n resolver?: SubaccountResolver,\n ) {\n this.#client = createClient(LifecycleReadService, transports.publicApi);\n this.#authClient = createClient(LifecycleReadService, transports.authApi);\n this.#realtime = realtime;\n this.#resolver = resolver;\n }\n\n /**\n * Returns paginated lifecycle flow summaries filtered by kind, state, scope, account selector, transaction reference, chain ids, and asset ids. The response is ordered by the selected timestamp and includes an opaque next page token.\n *\n * Lists only flows a chain transaction started. With an `accountSelector` (a smart\n * account address), the list holds the flows the account owns and the transfers it\n * receives from other accounts; each row's `participation` says which. Pass\n * `participation: \"owner\"` for the owned flows only. A `pageToken` only resumes the\n * request it came from: change nothing but `limit` between pages. Use `listAccountFlows`\n * for every flow of the signed-in account.\n */\n async listFlows(\n input: ListLifecycleFlowsInput,\n options?: PolyesterRequestOptions,\n ): Promise<ListLifecycleFlowsOutput> {\n const parsedInput = parse(ListLifecycleFlowsInputSchema, input);\n const response = await this.#client.listFlows(parsedInput, toConnectCallOptions(options));\n const res = parse(ListLifecycleFlowsOutputSchema, response);\n return res;\n }\n\n /**\n * Lists the signed-in account's flows: the ones it owns and the transfers it receives,\n * including flows no chain transaction started, such as transfers between Trading accounts.\n * Each row's `participation` says which. Takes the same filters as `listFlows`; a\n * `pageToken` only resumes the request it came from. API keys need `read-funding-flows`.\n */\n async listAccountFlows(\n input: ListLifecycleAccountFlowsInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<ListLifecycleFlowsOutput> {\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const request = parse(ListLifecycleAccountFlowsInputSchema, resolved);\n const response = await this.#authClient.listAccountFlows(\n request,\n toConnectCallOptions(options),\n );\n return parse(ListLifecycleFlowsOutputSchema, response);\n }\n\n /**\n * Fetches one flow the signed-in account owns or receives, including one no chain\n * transaction started. A flow the account takes no part in throws `ResourceNotFoundError`. API keys\n * need `read-funding-flows`.\n */\n async getAccountFlow(\n input: GetLifecycleAccountFlowInput,\n options?: PolyesterRequestOptions,\n ): Promise<GetLifecycleFlowOutput> {\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const request = parse(GetLifecycleAccountFlowInputSchema, resolved);\n const response = await this.#authClient.getAccountFlow(\n request,\n toConnectCallOptions(options),\n );\n return parse(GetLifecycleFlowOutputSchema, response);\n }\n\n /**\n * Fetches one lifecycle flow by its public flow id and returns summary, factual steps,\n * timeline, and live-state detail when available. Finds only flows a chain transaction\n * started; the account reads its other flows with `getAccountFlow`.\n */\n async getFlow(\n input: GetLifecycleFlowInput,\n options?: PolyesterRequestOptions,\n ): Promise<GetLifecycleFlowOutput> {\n const parsedInput = parse(GetLifecycleFlowInputSchema, input);\n const response = await this.#client.getFlowById(\n create(GetFlowByIdRequestSchema, parsedInput),\n toConnectCallOptions(options),\n );\n return parse(GetLifecycleFlowOutputSchema, response);\n }\n\n /**\n * Searches lifecycle flows that reference a 0x-prefixed transaction hash, using source-only or any-reference lookup mode. A single transaction may match zero, one, or many flows.\n */\n async listFlowsByTx(\n input: ListLifecycleFlowsByTxInput,\n options?: PolyesterRequestOptions,\n ): Promise<ListLifecycleFlowsByTxOutput> {\n const parsedInput = parse(ListLifecycleFlowsByTxInputSchema, input);\n const response = await this.#client.listFlowsByTx(\n parsedInput,\n toConnectCallOptions(options),\n );\n return parse(ListLifecycleFlowsByTxOutputSchema, response);\n }\n\n /**\n * Subscribes to open lifecycle flow summary updates, using private:chain:lifecycle:flows:{accountId}:proto when `accountId` is set and the public all-accounts flow channel only when it is omitted.\n */\n subscribeOpenFlows(input: SubscribeOpenLifecycleFlowsInput): () => void {\n const channel =\n input.accountId === undefined\n ? \"public:chain:lifecycle:flows:proto\"\n : `private:chain:lifecycle:flows:${input.accountId}:proto`;\n return this.#realtime.connectProtoChannel({\n channel,\n schema: FlowSummaryViewSchema,\n onPublication: (data) => {\n const flow = parse(LifecycleFlowSummarySchema, data);\n input.onEvent(flow);\n },\n onConnected: input.onOpen,\n onDisconnected: input.onClose,\n onError: input.onError,\n });\n }\n\n /**\n * Subscribes to detail updates for one lifecycle flow on public:chain:lifecycle:flow:{flowId}:proto. Invalid flow ids are rejected locally with a no-op unsubscribe function.\n */\n subscribeFlowDetail(input: SubscribeLifecycleFlowDetailInput): () => void {\n const parsedFlowId = v.safeParse(GetLifecycleFlowInputSchema, { flowId: input.flowId });\n if (!parsedFlowId.success) {\n if (isDev()) {\n console.error(\n \"[LifecycleService] flowId is required for flow detail subscription.\",\n );\n }\n return () => {};\n }\n\n const channel = `public:chain:lifecycle:flow:${parsedFlowId.output.flowId}:proto`;\n return this.#realtime.connectProtoChannel({\n channel,\n schema: FlowDetailViewSchema,\n onPublication: (data) => {\n const flow = parse(LifecycleFlowDetailSchema, data);\n input.onEvent(flow);\n },\n onConnected: input.onOpen,\n onDisconnected: input.onClose,\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAqDA,IAAa,mBAAb,MAA8B;CAC1B;CACA;CACA;CACA;CAEA,YACI,YACA,UACA,UACF;EACE,KAAKA,UAAU,aAAa,sBAAsB,WAAW,SAAS;EACtE,KAAKC,cAAc,aAAa,sBAAsB,WAAW,OAAO;EACxE,KAAKC,YAAY;EACjB,KAAKC,YAAY;CACrB;;;;;;;;;;;CAYA,MAAM,UACF,OACA,SACiC;EACjC,MAAM,cAAc,MAAM,+BAA+B,KAAK;EAC9D,MAAM,WAAW,MAAM,KAAKH,QAAQ,UAAU,aAAa,qBAAqB,OAAO,CAAC;EAExF,OADY,MAAM,gCAAgC,QACzC;CACb;;;;;;;CAQA,MAAM,iBACF,QAAwC,CAAC,GACzC,SACiC;EACjC,MAAM,WAAW,0BAA0B,OAAO,KAAKG,SAAS;EAChE,MAAM,UAAU,MAAM,sCAAsC,QAAQ;EACpE,MAAM,WAAW,MAAM,KAAKF,YAAY,iBACpC,SACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,gCAAgC,QAAQ;CACzD;;;;;;CAOA,MAAM,eACF,OACA,SAC+B;EAC/B,MAAM,WAAW,0BAA0B,OAAO,KAAKE,SAAS;EAChE,MAAM,UAAU,MAAM,oCAAoC,QAAQ;EAClE,MAAM,WAAW,MAAM,KAAKF,YAAY,eACpC,SACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,8BAA8B,QAAQ;CACvD;;;;;;CAOA,MAAM,QACF,OACA,SAC+B;EAC/B,MAAM,cAAc,MAAM,6BAA6B,KAAK;EAC5D,MAAM,WAAW,MAAM,KAAKD,QAAQ,YAChC,OAAO,0BAA0B,WAAW,GAC5C,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,8BAA8B,QAAQ;CACvD;;;;CAKA,MAAM,cACF,OACA,SACqC;EACrC,MAA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