@polyester/sdk 0.36.0-devnet-20261116002603 → 0.36.0-devnet-20261116150503

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 (107) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/dist/gen/auth/v1/auth_pb.d.ts +1 -1
  3. package/dist/gen/auth/v1/auth_pb.js +1 -1
  4. package/dist/gen/auth/v1/auth_pb.js.map +1 -1
  5. package/dist/gen/auth/v1/subaccounts_pb.d.ts +1 -1
  6. package/dist/gen/auth/v1/subaccounts_pb.js.map +1 -1
  7. package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts +3 -2
  8. package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts.map +1 -1
  9. package/dist/gen/chain/withdraw/v1/withdraw_pb.js +3 -2
  10. package/dist/gen/chain/withdraw/v1/withdraw_pb.js.map +1 -1
  11. package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +2 -1
  12. package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts.map +1 -1
  13. package/dist/gen/ledger/read/v1/ledger_read_pb.js +2 -1
  14. package/dist/gen/ledger/read/v1/ledger_read_pb.js.map +1 -1
  15. package/dist/gen/marketdata/v1/heatmap_pb.d.ts +0 -3
  16. package/dist/gen/marketdata/v1/heatmap_pb.d.ts.map +1 -1
  17. package/dist/gen/marketdata/v1/heatmap_pb.js +0 -3
  18. package/dist/gen/marketdata/v1/heatmap_pb.js.map +1 -1
  19. package/dist/gen/orderbook/v1/orderbook_pb.d.ts +28 -79
  20. package/dist/gen/orderbook/v1/orderbook_pb.d.ts.map +1 -1
  21. package/dist/gen/orderbook/v1/orderbook_pb.js +3 -77
  22. package/dist/gen/orderbook/v1/orderbook_pb.js.map +1 -1
  23. package/dist/gen/orders/v1/orders_pb.d.ts +126 -71
  24. package/dist/gen/orders/v1/orders_pb.d.ts.map +1 -1
  25. package/dist/gen/orders/v1/orders_pb.js +37 -19
  26. package/dist/gen/orders/v1/orders_pb.js.map +1 -1
  27. package/dist/gen/orders/v1/orders_read_pb.d.ts +30 -12
  28. package/dist/gen/orders/v1/orders_read_pb.d.ts.map +1 -1
  29. package/dist/gen/orders/v1/orders_read_pb.js.map +1 -1
  30. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts +87 -60
  31. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts.map +1 -1
  32. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js +1 -1
  33. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js.map +1 -1
  34. package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts +14 -11
  35. package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts.map +1 -1
  36. package/dist/gen/swap/quickswap/v1/quickswap_pb.js +8 -4
  37. package/dist/gen/swap/quickswap/v1/quickswap_pb.js.map +1 -1
  38. package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.d.ts +45 -42
  39. package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.d.ts.map +1 -1
  40. package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.js +10 -10
  41. package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.js.map +1 -1
  42. package/dist/gen/transfer/v1/internal_transfer_pb.d.ts +2 -1
  43. package/dist/gen/transfer/v1/internal_transfer_pb.d.ts.map +1 -1
  44. package/dist/gen/transfer/v1/internal_transfer_pb.js +2 -1
  45. package/dist/gen/transfer/v1/internal_transfer_pb.js.map +1 -1
  46. package/dist/gen/triggers/v1/triggers_pb.d.ts +65 -49
  47. package/dist/gen/triggers/v1/triggers_pb.d.ts.map +1 -1
  48. package/dist/gen/triggers/v1/triggers_pb.js.map +1 -1
  49. package/dist/services/address-book/address-book.schemas.d.ts +2 -2
  50. package/dist/services/assistant/assistant-events.schemas.d.ts +75 -75
  51. package/dist/services/assistant/assistant.schemas.d.ts +1 -1
  52. package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts +16 -16
  53. package/dist/services/auto-withdraw/auto-withdraw.schemas.js +1 -1
  54. package/dist/services/balances/balances.schemas.js +1 -1
  55. package/dist/services/candles/candles.schemas.d.ts +10 -10
  56. package/dist/services/changelog/changelog.schemas.d.ts +38 -38
  57. package/dist/services/checkpoints/checkpoints.schemas.d.ts +2 -2
  58. package/dist/services/claims/claims.schemas.d.ts +2 -2
  59. package/dist/services/claims/claims.schemas.js +1 -1
  60. package/dist/services/dust-conversion/dust-conversion.schemas.d.ts +6 -6
  61. package/dist/services/dust-conversion/dust-conversion.schemas.js +1 -1
  62. package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
  63. package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +3 -3
  64. package/dist/services/internal-transfers/internal-transfers.schemas.js +1 -1
  65. package/dist/services/lifecycle/lifecycle.schemas.d.ts +12 -12
  66. package/dist/services/lifecycle/lifecycle.schemas.js +1 -1
  67. package/dist/services/orderbook/orderbook.codecs.js +2 -42
  68. package/dist/services/orderbook/orderbook.codecs.js.map +1 -1
  69. package/dist/services/orderbook/orderbook.d.ts +3 -1
  70. package/dist/services/orderbook/orderbook.d.ts.map +1 -1
  71. package/dist/services/orderbook/orderbook.js +18 -11
  72. package/dist/services/orderbook/orderbook.js.map +1 -1
  73. package/dist/services/orderbook/orderbook.schemas.d.ts +12 -11
  74. package/dist/services/orderbook/orderbook.schemas.d.ts.map +1 -1
  75. package/dist/services/orderbook/orderbook.schemas.js +10 -12
  76. package/dist/services/orderbook/orderbook.schemas.js.map +1 -1
  77. package/dist/services/orders/order-errors.schemas.d.ts +2 -2
  78. package/dist/services/orders/orders-batch.schemas.d.ts +40 -40
  79. package/dist/services/orders/orders-input.schemas.d.ts +6 -6
  80. package/dist/services/orders/orders-output.schemas.d.ts +11 -11
  81. package/dist/services/orders/orders-output.schemas.js +1 -1
  82. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +2 -2
  83. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts.map +1 -1
  84. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +2 -3
  85. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
  86. package/dist/services/price-alerts/price-alerts.schemas.d.ts +10 -10
  87. package/dist/services/rewards/rewards.schemas.d.ts +4 -4
  88. package/dist/services/statement-exports/statement-exports.schemas.d.ts +12 -12
  89. package/dist/services/subaccounts/subaccounts.schemas.d.ts +12 -12
  90. package/dist/services/system/system.schemas.d.ts +13 -13
  91. package/dist/services/trades/trades.schemas.d.ts +2 -2
  92. package/dist/services/trades/trades.schemas.js +1 -1
  93. package/dist/services/trading-withdraws/trading-withdraws.schemas.js +1 -1
  94. package/dist/services/transfers/transfers.schemas.js +1 -1
  95. package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
  96. package/dist/services/triggers/triggers-output.schemas.d.ts +50 -50
  97. package/dist/shared/decimal-surface.d.ts.map +1 -1
  98. package/dist/shared/decimal-surface.js +4 -1
  99. package/dist/shared/decimal-surface.js.map +1 -1
  100. package/dist/shared/error-details/withdraw.js +1 -1
  101. package/dist/shared/schemas.js +2 -2
  102. package/dist/shared/schemas.js.map +1 -1
  103. package/dist/utils/numbers.js +1 -10
  104. package/dist/utils/numbers.js.map +1 -1
  105. package/dist/utils/u128.js +1 -1
  106. package/dist/utils/u128.js.map +1 -1
  107. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { OptionalPublicIdSchema, OptionalTimestampMsSchema, U128Schema, optionalSubaccountIdInputSchema } from "../../shared/schemas.js";
2
2
  import { enumLabelSchema } from "../../shared/proto-enum-codec.js";
3
- import { scaledToDecimalOutput } from "../../shared/decimal-surface.js";
4
3
  import { fromU128 } from "../../utils/u128.js";
4
+ import { scaledToDecimalOutput } from "../../shared/decimal-surface.js";
5
5
  import { ErrorCode } from "../../gen/claims/v1/claims_pb.js";
6
6
  import { ClaimPolicyCodec, DailyClaimStateCodec } from "./claims.codecs.js";
7
7
  import * as v from "valibot";
@@ -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" | "processing" | "completed" | "refused">]>;
150
+ readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "refused" | "processing" | "completed">]>;
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" | "processing" | "completed" | "refused";
190
+ state: "unspecified" | "refused" | "processing" | "completed";
191
191
  refusalCode: number;
192
192
  targetAssetId: number;
193
193
  sources: {
@@ -216,7 +216,7 @@ 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" | "processing" | "completed" | "refused";
219
+ state: "unspecified" | "refused" | "processing" | "completed";
220
220
  /** Why a `refused` conversion was refused; null otherwise. */
221
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;
@@ -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" | "processing" | "completed" | "refused">]>;
466
+ readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "refused" | "processing" | "completed">]>;
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" | "processing" | "completed" | "refused";
506
+ state: "unspecified" | "refused" | "processing" | "completed";
507
507
  refusalCode: number;
508
508
  targetAssetId: number;
509
509
  sources: {
@@ -532,7 +532,7 @@ declare const ListDustConversionsResultSchema: v.ObjectSchema<{
532
532
  conversionId: string;
533
533
  /** The quote the conversion converted. */
534
534
  quoteId: string;
535
- state: "unspecified" | "processing" | "completed" | "refused";
535
+ state: "unspecified" | "refused" | "processing" | "completed";
536
536
  /** Why a `refused` conversion was refused; null otherwise. */
537
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;
@@ -1,10 +1,10 @@
1
1
  import { codeName } from "../../shared/error-detail.js";
2
2
  import { OptionalTimestampMsSchema, U128Schema } from "../../shared/schemas.js";
3
3
  import { enumLabelSchema } from "../../shared/proto-enum-codec.js";
4
+ import { fromU128 } from "../../utils/u128.js";
4
5
  import { scaledToDecimalOutput } from "../../shared/decimal-surface.js";
5
6
  import { PositiveUint32InputSchema } from "../shared.js";
6
7
  import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
7
- import { fromU128 } from "../../utils/u128.js";
8
8
  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";
@@ -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 | 200 | 100 | 500 | 1000 | 50, 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 | 200 | 100 | 500 | 1000 | 50>]>;
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 | 200 | 100 | 500 | 1000 | 50;
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 | 200 | 100 | 500 | 1000 | 50;
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" | "accepted" | "rejected">]>;
141
+ readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "accepted" | "rejected" | "failed">]>;
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" | "accepted" | "rejected";
160
+ status: "unspecified" | "accepted" | "rejected" | "failed";
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" | "accepted" | "rejected";
177
+ status: "unspecified" | "accepted" | "rejected" | "failed";
178
178
  flowId: string;
179
179
  }>]>;
180
180
  type CreateInternalTransferResult = v.InferOutput<ReturnType<typeof createCreateInternalTransferResultSchema>>;
@@ -1,10 +1,10 @@
1
1
  import { tsNsToMs } from "../../utils/time.js";
2
2
  import { U128Schema, idInputSchema } from "../../shared/schemas.js";
3
3
  import { enumLabelSchema } from "../../shared/proto-enum-codec.js";
4
+ import { fromU128, toU128 } from "../../utils/u128.js";
4
5
  import { quantityInputToE18, scaledToDecimalOutput } from "../../shared/decimal-surface.js";
5
6
  import { PositiveUint32InputSchema } from "../shared.js";
6
7
  import { AccountScopeInputEntries, accountScopeToSubaccountId, accountScopeToSubaccountIdOrZero } from "../../shared/account-scope.js";
7
- import { fromU128, toU128 } from "../../utils/u128.js";
8
8
  import { InternalTransferBatchLegStatusCodec, InternalTransferBatchStatusCodec, InternalTransferDestinationCodec, InternalTransferStatusCodec, internalTransferErrorCodeName } from "./internal-transfers.codecs.js";
9
9
  import * as v from "valibot";
10
10
  //#region src/services/internal-transfers/internal-transfers.schemas.ts
@@ -669,7 +669,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
669
669
  * `"unspecified"` outside `listAccountFlows`, `getAccountFlow` and `listFlows` with an
670
670
  * `accountSelector`.
671
671
  */
672
- readonly participation: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "owner" | "recipient">]>, FlowParticipation.PARTICIPATION_UNSPECIFIED>;
672
+ readonly participation: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "owner" | "unspecified" | "recipient">]>, FlowParticipation.PARTICIPATION_UNSPECIFIED>;
673
673
  }, undefined>, v.TransformAction<{
674
674
  smartAccountAddress: string;
675
675
  flowId: string;
@@ -732,7 +732,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
732
732
  }[];
733
733
  estimatedCompletionUnixMs: number;
734
734
  isDelayed: boolean;
735
- participation: "unspecified" | "owner" | "recipient";
735
+ participation: "owner" | "unspecified" | "recipient";
736
736
  }, Omit<{
737
737
  smartAccountAddress: string;
738
738
  flowId: string;
@@ -795,7 +795,7 @@ declare const LifecycleFlowSummarySchema: v.SchemaWithPipe<readonly [v.ObjectSch
795
795
  }[];
796
796
  estimatedCompletionUnixMs: number;
797
797
  isDelayed: boolean;
798
- participation: "unspecified" | "owner" | "recipient";
798
+ participation: "owner" | "unspecified" | "recipient";
799
799
  }, "amountE18"> & {
800
800
  amount?: string;
801
801
  }>]>;
@@ -897,7 +897,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
897
897
  * `"unspecified"` outside `listAccountFlows`, `getAccountFlow` and `listFlows` with an
898
898
  * `accountSelector`.
899
899
  */
900
- readonly participation: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "owner" | "recipient">]>, FlowParticipation.PARTICIPATION_UNSPECIFIED>;
900
+ readonly participation: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "owner" | "unspecified" | "recipient">]>, FlowParticipation.PARTICIPATION_UNSPECIFIED>;
901
901
  }, undefined>, v.TransformAction<{
902
902
  smartAccountAddress: string;
903
903
  flowId: string;
@@ -960,7 +960,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
960
960
  }[];
961
961
  estimatedCompletionUnixMs: number;
962
962
  isDelayed: boolean;
963
- participation: "unspecified" | "owner" | "recipient";
963
+ participation: "owner" | "unspecified" | "recipient";
964
964
  }, Omit<{
965
965
  smartAccountAddress: string;
966
966
  flowId: string;
@@ -1023,7 +1023,7 @@ declare const LifecycleFlowDetailSchema: v.ObjectSchema<{
1023
1023
  }[];
1024
1024
  estimatedCompletionUnixMs: number;
1025
1025
  isDelayed: boolean;
1026
- participation: "unspecified" | "owner" | "recipient";
1026
+ participation: "owner" | "unspecified" | "recipient";
1027
1027
  }, "amountE18"> & {
1028
1028
  amount?: string;
1029
1029
  }>]>, undefined>;
@@ -1407,7 +1407,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
1407
1407
  * `"unspecified"` outside `listAccountFlows`, `getAccountFlow` and `listFlows` with an
1408
1408
  * `accountSelector`.
1409
1409
  */
1410
- readonly participation: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "owner" | "recipient">]>, FlowParticipation.PARTICIPATION_UNSPECIFIED>;
1410
+ readonly participation: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "owner" | "unspecified" | "recipient">]>, FlowParticipation.PARTICIPATION_UNSPECIFIED>;
1411
1411
  }, undefined>, v.TransformAction<{
1412
1412
  smartAccountAddress: string;
1413
1413
  flowId: string;
@@ -1470,7 +1470,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
1470
1470
  }[];
1471
1471
  estimatedCompletionUnixMs: number;
1472
1472
  isDelayed: boolean;
1473
- participation: "unspecified" | "owner" | "recipient";
1473
+ participation: "owner" | "unspecified" | "recipient";
1474
1474
  }, Omit<{
1475
1475
  smartAccountAddress: string;
1476
1476
  flowId: string;
@@ -1533,7 +1533,7 @@ declare const ListLifecycleFlowsOutputSchema: v.ObjectSchema<{
1533
1533
  }[];
1534
1534
  estimatedCompletionUnixMs: number;
1535
1535
  isDelayed: boolean;
1536
- participation: "unspecified" | "owner" | "recipient";
1536
+ participation: "owner" | "unspecified" | "recipient";
1537
1537
  }, "amountE18"> & {
1538
1538
  amount?: string;
1539
1539
  }>]>, undefined>, readonly []>;
@@ -1638,7 +1638,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
1638
1638
  * `"unspecified"` outside `listAccountFlows`, `getAccountFlow` and `listFlows` with an
1639
1639
  * `accountSelector`.
1640
1640
  */
1641
- readonly participation: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "owner" | "recipient">]>, FlowParticipation.PARTICIPATION_UNSPECIFIED>;
1641
+ readonly participation: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "owner" | "unspecified" | "recipient">]>, FlowParticipation.PARTICIPATION_UNSPECIFIED>;
1642
1642
  }, undefined>, v.TransformAction<{
1643
1643
  smartAccountAddress: string;
1644
1644
  flowId: string;
@@ -1701,7 +1701,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
1701
1701
  }[];
1702
1702
  estimatedCompletionUnixMs: number;
1703
1703
  isDelayed: boolean;
1704
- participation: "unspecified" | "owner" | "recipient";
1704
+ participation: "owner" | "unspecified" | "recipient";
1705
1705
  }, Omit<{
1706
1706
  smartAccountAddress: string;
1707
1707
  flowId: string;
@@ -1764,7 +1764,7 @@ declare const GetLifecycleFlowOutputSchema: v.ObjectSchema<{
1764
1764
  }[];
1765
1765
  estimatedCompletionUnixMs: number;
1766
1766
  isDelayed: boolean;
1767
- participation: "unspecified" | "owner" | "recipient";
1767
+ participation: "owner" | "unspecified" | "recipient";
1768
1768
  }, "amountE18"> & {
1769
1769
  amount?: string;
1770
1770
  }>]>, undefined>;
@@ -1,7 +1,7 @@
1
1
  import { enumLabelSchema } from "../../shared/proto-enum-codec.js";
2
+ import { fromU128 } from "../../utils/u128.js";
2
3
  import { scaledToDecimalOutput } from "../../shared/decimal-surface.js";
3
4
  import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
4
- import { fromU128 } from "../../utils/u128.js";
5
5
  import "../../gen/chain/lifecycle/v1/types_pb.js";
6
6
  import "../../gen/chain/lifecycle/v1/lifecycle_read_pb.js";
7
7
  import { LIFECYCLE_FLOW_KIND_VALUES, LIFECYCLE_FLOW_PARTICIPATION_VALUES, LIFECYCLE_FLOW_STATE_VALUES, LIFECYCLE_LIST_ORDER_BY_VALUES, LIFECYCLE_LIST_SCOPE_VALUES, LIFECYCLE_SORT_VALUES, LIFECYCLE_TX_LOOKUP_KIND_VALUES, LifecycleFlowDomainCodec, LifecycleFlowKindCodec, LifecycleFlowParticipationCodec, LifecycleFlowStateCodec, LifecycleFlowStepActivityKindCodec, LifecycleFlowStepCodec, LifecycleFlowTimelineStatusCodec, LifecycleListOrderByCodec, LifecycleListScopeCodec, LifecycleRequestFeeStatusCodec, LifecycleSortCodec, LifecycleSourceCodec, LifecycleTxLookupKindCodec, lifecycleReasonFromCode, zipperReasonFromCode } from "./lifecycle.codecs.js";
@@ -1,47 +1,7 @@
1
- import "../../gen/orderbook/v1/orderbook_pb.js";
2
1
  //#region src/services/orderbook/orderbook.codecs.ts
3
- const ORDERBOOK_SUPPORTED_DEPTHS = [
4
- 1,
5
- 5,
6
- 10,
7
- 20,
8
- 50,
9
- 100,
10
- 200,
11
- 500,
12
- 1e3
13
- ];
14
- const DepthCodec = {
15
- inputToProto: {
16
- 1: 1,
17
- 5: 2,
18
- 10: 3,
19
- 20: 4,
20
- 50: 5,
21
- 100: 6,
22
- 200: 7,
23
- 500: 8,
24
- 1e3: 9
25
- },
26
- supportedDepths: ORDERBOOK_SUPPORTED_DEPTHS
27
- };
28
- function normalizeOrderbookDepth(depth) {
29
- if (depth in DepthCodec.inputToProto) {
30
- const levels = depth;
31
- return {
32
- levels,
33
- protoDepth: DepthCodec.inputToProto[levels]
34
- };
35
- }
36
- const levels = DepthCodec.supportedDepths.reduce((prev, curr) => Math.abs(curr - depth) < Math.abs(prev - depth) ? curr : prev);
37
- return {
38
- levels,
39
- protoDepth: DepthCodec.inputToProto[levels]
40
- };
41
- }
42
2
  /**
43
3
  * Depths for which the backend publishes `public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto`
44
- * channels. Narrower than ORDERBOOK_SUPPORTED_DEPTHS, which is the set the REST snapshot accepts:
4
+ * channels. Narrower than the depths the REST snapshot accepts (1 to its `maxDepth`):
45
5
  * subscribing to a depth outside this set succeeds and then never delivers a publication, so the book
46
6
  * silently stays empty.
47
7
  */
@@ -61,6 +21,6 @@ function orderbookWsChannelDepth(depth) {
61
21
  return 500;
62
22
  }
63
23
  //#endregion
64
- export { DepthCodec, ORDERBOOK_SUPPORTED_DEPTHS, ORDERBOOK_WS_DEPTHS, normalizeOrderbookDepth, orderbookWsChannelDepth };
24
+ export { ORDERBOOK_WS_DEPTHS, orderbookWsChannelDepth };
65
25
 
66
26
  //# sourceMappingURL=orderbook.codecs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"orderbook.codecs.js","names":[],"sources":["../../../src/services/orderbook/orderbook.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/orderbook/v1/orderbook_pb.js\";\n\nexport const ORDERBOOK_SUPPORTED_DEPTHS = [1, 5, 10, 20, 50, 100, 200, 500, 1000] as const;\n\nexport type OrderbookSupportedDepth = (typeof ORDERBOOK_SUPPORTED_DEPTHS)[number];\n\nexport type NormalizedOrderbookDepth = {\n levels: OrderbookSupportedDepth;\n protoDepth: Proto.Depth;\n};\n\nexport const DepthCodec = {\n inputToProto: {\n 1: Proto.Depth.DEPTH_1,\n 5: Proto.Depth.DEPTH_5,\n 10: Proto.Depth.DEPTH_10,\n 20: Proto.Depth.DEPTH_20,\n 50: Proto.Depth.DEPTH_50,\n 100: Proto.Depth.DEPTH_100,\n 200: Proto.Depth.DEPTH_200,\n 500: Proto.Depth.DEPTH_500,\n 1000: Proto.Depth.DEPTH_1000,\n } satisfies Record<OrderbookSupportedDepth, Proto.Depth>,\n supportedDepths: ORDERBOOK_SUPPORTED_DEPTHS,\n} as const;\n\nexport function normalizeOrderbookDepth(depth: number): NormalizedOrderbookDepth {\n if (depth in DepthCodec.inputToProto) {\n const levels = depth as OrderbookSupportedDepth;\n return { levels, protoDepth: DepthCodec.inputToProto[levels] };\n }\n\n const levels = DepthCodec.supportedDepths.reduce((prev, curr) =>\n Math.abs(curr - depth) < Math.abs(prev - depth) ? curr : prev,\n );\n return { levels, protoDepth: DepthCodec.inputToProto[levels] };\n}\n\n/**\n * Depths for which the backend publishes `public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto`\n * channels. Narrower than ORDERBOOK_SUPPORTED_DEPTHS, which is the set the REST snapshot accepts:\n * subscribing to a depth outside this set succeeds and then never delivers a publication, so the book\n * silently stays empty.\n */\nexport const ORDERBOOK_WS_DEPTHS = [1, 20, 50, 200, 500] as const;\n\nexport type OrderbookWsDepth = (typeof ORDERBOOK_WS_DEPTHS)[number];\n\n/**\n * Smallest published channel depth that covers `depth`, so a request for an unpublished depth rides a\n * deeper feed and is sliced back down locally instead of subscribing to a channel with no publisher.\n */\nexport function orderbookWsChannelDepth(depth: number): OrderbookWsDepth {\n for (const d of ORDERBOOK_WS_DEPTHS) if (d >= depth) return d;\n return 500;\n}\n"],"mappings":";;AAEA,MAAa,6BAA6B;CAAC;CAAG;CAAG;CAAI;CAAI;CAAI;CAAK;CAAK;CAAK;AAAI;AAShF,MAAa,aAAa;CACtB,cAAc;EACV,GAAA;EACA,GAAA;EACA,IAAA;EACA,IAAA;EACA,IAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;CACJ;CACA,iBAAiB;AACrB;AAEA,SAAgB,wBAAwB,OAAyC;CAC7E,IAAI,SAAS,WAAW,cAAc;EAClC,MAAM,SAAS;EACf,OAAO;GAAE;GAAQ,YAAY,WAAW,aAAa;EAAQ;CACjE;CAEA,MAAM,SAAS,WAAW,gBAAgB,QAAQ,MAAM,SACpD,KAAK,IAAI,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,KAAK,IAAI,OAAO,IAC7D;CACA,OAAO;EAAE;EAAQ,YAAY,WAAW,aAAa;CAAQ;AACjE;;;;;;;AAQA,MAAa,sBAAsB;CAAC;CAAG;CAAI;CAAI;CAAK;AAAG;;;;;AAQvD,SAAgB,wBAAwB,OAAiC;CACrE,KAAK,MAAM,KAAK,qBAAqB,IAAI,KAAK,OAAO,OAAO;CAC5D,OAAO;AACX"}
1
+ {"version":3,"file":"orderbook.codecs.js","names":[],"sources":["../../../src/services/orderbook/orderbook.codecs.ts"],"sourcesContent":["/**\n * Depths for which the backend publishes `public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto`\n * channels. Narrower than the depths the REST snapshot accepts (1 to its `maxDepth`):\n * subscribing to a depth outside this set succeeds and then never delivers a publication, so the book\n * silently stays empty.\n */\nexport const ORDERBOOK_WS_DEPTHS = [1, 20, 50, 200, 500] as const;\n\nexport type OrderbookWsDepth = (typeof ORDERBOOK_WS_DEPTHS)[number];\n\n/**\n * Smallest published channel depth that covers `depth`, so a request for an unpublished depth rides a\n * deeper feed and is sliced back down locally instead of subscribing to a channel with no publisher.\n */\nexport function orderbookWsChannelDepth(depth: number): OrderbookWsDepth {\n for (const d of ORDERBOOK_WS_DEPTHS) if (d >= depth) return d;\n return 500;\n}\n"],"mappings":";;;;;;;AAMA,MAAa,sBAAsB;CAAC;CAAG;CAAI;CAAI;CAAK;AAAG;;;;;AAQvD,SAAgB,wBAAwB,OAAiC;CACrE,KAAK,MAAM,KAAK,qBAAqB,IAAI,KAAK,OAAO,OAAO;CAC5D,OAAO;AACX"}
@@ -35,7 +35,9 @@ declare class OrderbookService {
35
35
  /**
36
36
  * Creates a stateful order book subscription that first fetches a snapshot, buffers proto deltas from public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto, applies each delta only when it chains onto the book, and refetches on reconnects. After a sequence gap the book holds its last state until the server's next reset, sent about every 30 seconds and after gaps. A snapshot whose book is not available fails with ServiceUnavailableError through onError and is retried; no event is emitted until a snapshot is available. The snapshot is fetched once the channel opens, so a socket that cannot connect reports a retryable RealtimeError with type "transport" through onError instead, once per outage; onOpen follows when it recovers. The returned handle can unsubscribe or change local price bucket aggregation without reconnecting.
37
37
  *
38
- * `depth` is clamped to [1, 500] and rides the smallest published channel depth that covers it (see ORDERBOOK_WS_DEPTHS); levels are sliced back to the requested depth locally.
38
+ * `depth` is capped at 500 and rides the smallest published channel depth that covers it (see ORDERBOOK_WS_DEPTHS); levels are sliced back to the requested depth locally.
39
+ *
40
+ * A refetched snapshot from an older `bookEpoch` than the book's is discarded and retried.
39
41
  *
40
42
  * Refetching is driven by reconnect events only. A feed that stays subscribed but stops publishing is indistinguishable from a quiet market, so it does not trigger onError or a refetch. Callers that must detect a stalled book need their own idle watchdog plus a REST refetch.
41
43
  */
@@ -1 +1 @@
1
- {"version":3,"file":"orderbook.d.ts","names":[],"sources":["../../../src/services/orderbook/orderbook.ts"],"mappings":";;;;;;;;UA6BU,gCAAgC,mBAAmB;EACzD;EACA;EACA;;UAGa,gCAAgC,mBAAmB;UAEnD;EACb;EACA,YAAY;;UAGC,yCAET,yBACA,KAAK;;;;cAOA;;EAKG,YAAA,YAAY,qBAAqB,UAAU,mBAAmB,QAAQ;;;;;EAU5E,IACF,OAAO,EAAE,kBAAkB,0BAC3B,UAAU,0BACX,QAAQ;;;;EAqBX,UAAU,OAAO;;;;;;;;EAWjB,mBAAmB,OAAO,mCAAmC"}
1
+ {"version":3,"file":"orderbook.d.ts","names":[],"sources":["../../../src/services/orderbook/orderbook.ts"],"mappings":";;;;;;;;UA6BU,gCAAgC,mBAAmB;EACzD;EACA;EACA;;UAGa,gCAAgC,mBAAmB;UAEnD;EACb;EACA,YAAY;;UAGC,yCAET,yBACA,KAAK;;;;cAOA;;EAKG,YAAA,YAAY,qBAAqB,UAAU,mBAAmB,QAAQ;;;;;EAU5E,IACF,OAAO,EAAE,kBAAkB,0BAC3B,UAAU,0BACX,QAAQ;;;;EAuBX,UAAU,OAAO;;;;;;;;;;EAajB,mBAAmB,OAAO,mCAAmC"}
@@ -6,8 +6,8 @@ import { publicationHandlerErrorContext } from "../../shared/subscription-errors
6
6
  import { isResourceNotFoundError } from "../../utils/errors.js";
7
7
  import { snapshotThenStream } from "../../realtime/snapshot-then-stream.js";
8
8
  import { GetOrderBookResponseSchema, OrderBookDeltaSchema, OrderbookService as OrderbookService$1 } from "../../gen/orderbook/v1/orderbook_pb.js";
9
- import { orderbookWsChannelDepth } from "./orderbook.codecs.js";
10
9
  import { GetOrderbookInputSchema, createOrderbookDataSchema, formatOrderbookLevel } from "./orderbook.schemas.js";
10
+ import { orderbookWsChannelDepth } from "./orderbook.codecs.js";
11
11
  import { create } from "@bufbuild/protobuf";
12
12
  import { createClient } from "@connectrpc/connect";
13
13
  //#region src/services/orderbook/orderbook.ts
@@ -32,12 +32,14 @@ var OrderbookService = class {
32
32
  await this.#scales.ready();
33
33
  const res = await this.#client.getOrderBook({
34
34
  symbolId: validated.symbolId,
35
- depth: validated.protoDepth
35
+ depth: validated.depth
36
36
  }, toConnectCallOptions(options));
37
37
  return parse(createOrderbookDataSchema(this.#scales, validated.symbolId), {
38
38
  symbolId: res.symbolId,
39
39
  depth: validated.depth,
40
40
  bookSeq: res.bookSeq,
41
+ bookEpoch: res.bookEpoch,
42
+ maxDepth: res.maxDepth,
41
43
  available: isBookAvailable(res),
42
44
  bids: res.bids,
43
45
  asks: res.asks,
@@ -53,16 +55,18 @@ var OrderbookService = class {
53
55
  /**
54
56
  * Creates a stateful order book subscription that first fetches a snapshot, buffers proto deltas from public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto, applies each delta only when it chains onto the book, and refetches on reconnects. After a sequence gap the book holds its last state until the server's next reset, sent about every 30 seconds and after gaps. A snapshot whose book is not available fails with ServiceUnavailableError through onError and is retried; no event is emitted until a snapshot is available. The snapshot is fetched once the channel opens, so a socket that cannot connect reports a retryable RealtimeError with type "transport" through onError instead, once per outage; onOpen follows when it recovers. The returned handle can unsubscribe or change local price bucket aggregation without reconnecting.
55
57
  *
56
- * `depth` is clamped to [1, 500] and rides the smallest published channel depth that covers it (see ORDERBOOK_WS_DEPTHS); levels are sliced back to the requested depth locally.
58
+ * `depth` is capped at 500 and rides the smallest published channel depth that covers it (see ORDERBOOK_WS_DEPTHS); levels are sliced back to the requested depth locally.
59
+ *
60
+ * A refetched snapshot from an older `bookEpoch` than the book's is discarded and retried.
57
61
  *
58
62
  * Refetching is driven by reconnect events only. A feed that stays subscribed but stops publishing is indistinguishable from a quiet market, so it does not trigger onError or a refetch. Callers that must detect a stalled book need their own idle watchdog plus a REST refetch.
59
63
  */
60
64
  createSubscription(input) {
61
- const { symbolId } = parse(GetOrderbookInputSchema, {
65
+ const { symbolId, depth } = parse(GetOrderbookInputSchema, {
62
66
  symbolId: input.symbolId,
63
67
  depth: input.depth
64
68
  });
65
- const requestedDepth = Math.min(500, Math.max(1, Math.trunc(input.depth ?? 50)));
69
+ const requestedDepth = Math.min(500, depth);
66
70
  const channelDepth = orderbookWsChannelDepth(requestedDepth);
67
71
  const channel = `public:spot:orderbook:deltas:depth:${channelDepth}:${symbolId}:proto`;
68
72
  const client = this.#client;
@@ -70,6 +74,8 @@ var OrderbookService = class {
70
74
  let bidsMap = /* @__PURE__ */ new Map();
71
75
  let asksMap = /* @__PURE__ */ new Map();
72
76
  let currentBookSeq = 0n;
77
+ let currentBookEpoch = 0n;
78
+ let maxDepth = 0;
73
79
  let awaitingReset = false;
74
80
  let bucketTicks = null;
75
81
  let stream;
@@ -113,6 +119,8 @@ var OrderbookService = class {
113
119
  symbolId,
114
120
  depth: requestedDepth,
115
121
  bookSeq: currentBookSeq.toString(),
122
+ bookEpoch: currentBookEpoch.toString(),
123
+ maxDepth,
116
124
  available: true,
117
125
  bids: sideToUIBucketed(bidsMap, "bids", requestedDepth, bucketTicks),
118
126
  asks: sideToUIBucketed(asksMap, "asks", requestedDepth, bucketTicks)
@@ -132,15 +140,11 @@ var OrderbookService = class {
132
140
  }
133
141
  async function inputServiceFetch() {
134
142
  await scales.ready();
135
- const validated = parse(GetOrderbookInputSchema, {
136
- symbolId,
137
- depth: channelDepth
138
- });
139
143
  let res;
140
144
  try {
141
145
  res = await client.getOrderBook({
142
- symbolId: validated.symbolId,
143
- depth: validated.protoDepth
146
+ symbolId,
147
+ depth: channelDepth
144
148
  });
145
149
  } catch (error) {
146
150
  if (!isResourceNotFoundError(error)) throw error;
@@ -153,6 +157,7 @@ var OrderbookService = class {
153
157
  });
154
158
  }
155
159
  if (!isBookAvailable(res)) throw new ServiceUnavailableError(`Order book for symbol ${symbolId} is not available yet`);
160
+ if (res.bookEpoch < currentBookEpoch) throw new ServiceUnavailableError(`Order book snapshot for symbol ${symbolId} is from an older epoch`);
156
161
  return res;
157
162
  }
158
163
  /**
@@ -192,6 +197,8 @@ var OrderbookService = class {
192
197
  bidsMap = levelsToMap(snapshot.bids);
193
198
  asksMap = levelsToMap(snapshot.asks);
194
199
  currentBookSeq = snapshot.bookSeq;
200
+ currentBookEpoch = snapshot.bookEpoch;
201
+ maxDepth = snapshot.maxDepth;
195
202
  awaitingReset = false;
196
203
  emit();
197
204
  for (const delta of bufferedDeltas) {
@@ -1 +1 @@
1
- {"version":3,"file":"orderbook.js","names":["#client","Proto.OrderbookService","#realtime","#scales","Proto.GetOrderBookResponseSchema","Proto.OrderBookDeltaSchema"],"sources":["../../../src/services/orderbook/orderbook.ts"],"sourcesContent":["import { create } from \"@bufbuild/protobuf\";\nimport * as Proto from \"../../gen/orderbook/v1/orderbook_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport { publicationHandlerErrorContext } from \"../../shared/subscription-errors.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport {\n snapshotThenStream,\n type SnapshotThenStreamSubscription,\n} from \"../../realtime/snapshot-then-stream.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { decimalInputToScaled, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n formatOrderbookLevel,\n GetOrderbookInputSchema,\n createOrderbookDataSchema,\n type OrderbookLevel,\n type OrderbookData,\n} from \"./orderbook.schemas.js\";\nimport { orderbookWsChannelDepth } from \"./orderbook.codecs.js\";\nimport { isResourceNotFoundError } from \"../../utils/errors.js\";\nimport { ServiceUnavailableError } from \"../../shared/errors.js\";\nimport type * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport type { PublicApiTransports } from \"../../shared/transports.js\";\n\ninterface SubscribeOrderbookInput extends BaseSubscribeInput<OrderbookData> {\n symbolId: number;\n depth?: number;\n bucket?: string | null;\n}\n\nexport interface OrderbookStreamHandlers extends BaseSubscribeInput<OrderbookData> {}\n\nexport interface OrderbookSubscription {\n unsubscribe: () => void;\n setBucket: (bucket: string | null | undefined) => void;\n}\n\nexport interface CreateOrderbookSubscriptionInput\n extends\n OrderbookStreamHandlers,\n Pick<SubscribeOrderbookInput, \"symbolId\" | \"depth\" | \"bucket\"> {}\n\ntype BookSide = Map<bigint, bigint>;\n\n/**\n * Reads spot order book snapshots and maintains realtime local order book state from public delta channels.\n */\nexport class OrderbookService {\n #client: Client<typeof Proto.OrderbookService>;\n #realtime: PolyesterRealtime;\n #scales: SdkScales;\n\n constructor(transports: PublicApiTransports, realtime: PolyesterRealtime, scales: SdkScales) {\n this.#client = createClient(Proto.OrderbookService, transports.publicApi);\n this.#realtime = realtime;\n this.#scales = scales;\n }\n\n /**\n * Fetches a spot order book depth snapshot for a symbol ID and requested depth, returning best bids and asks with the backend book sequence.\n * When `available` is false the book is being built or was invalidated: its levels are unknown, not empty, so read it again later instead of treating empty sides as no liquidity.\n */\n async get(\n input: v.InferInput<typeof GetOrderbookInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<OrderbookData> {\n const validated = parse(GetOrderbookInputSchema, input);\n await this.#scales.ready();\n const res = await this.#client.getOrderBook(\n { symbolId: validated.symbolId, depth: validated.protoDepth },\n toConnectCallOptions(options),\n );\n return parse(createOrderbookDataSchema(this.#scales, validated.symbolId), {\n symbolId: res.symbolId,\n depth: validated.depth,\n bookSeq: res.bookSeq,\n available: isBookAvailable(res),\n bids: res.bids,\n asks: res.asks,\n ts: res.ts,\n });\n }\n\n /**\n * Subscribes to the managed order book stream for a symbol ID and forwards reconstructed snapshots to onEvent. This is a convenience wrapper around createSubscription().unsubscribe.\n */\n subscribe(input: SubscribeOrderbookInput): () => void {\n return this.createSubscription(input).unsubscribe;\n }\n\n /**\n * Creates a stateful order book subscription that first fetches a snapshot, buffers proto deltas from public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto, applies each delta only when it chains onto the book, and refetches on reconnects. After a sequence gap the book holds its last state until the server's next reset, sent about every 30 seconds and after gaps. A snapshot whose book is not available fails with ServiceUnavailableError through onError and is retried; no event is emitted until a snapshot is available. The snapshot is fetched once the channel opens, so a socket that cannot connect reports a retryable RealtimeError with type \"transport\" through onError instead, once per outage; onOpen follows when it recovers. The returned handle can unsubscribe or change local price bucket aggregation without reconnecting.\n *\n * `depth` is clamped to [1, 500] and rides the smallest published channel depth that covers it (see ORDERBOOK_WS_DEPTHS); levels are sliced back to the requested depth locally.\n *\n * Refetching is driven by reconnect events only. A feed that stays subscribed but stops publishing is indistinguishable from a quiet market, so it does not trigger onError or a refetch. Callers that must detect a stalled book need their own idle watchdog plus a REST refetch.\n */\n createSubscription(input: CreateOrderbookSubscriptionInput): OrderbookSubscription {\n const { symbolId } = parse(GetOrderbookInputSchema, {\n symbolId: input.symbolId,\n depth: input.depth,\n });\n const requestedDepth = Math.min(500, Math.max(1, Math.trunc(input.depth ?? 50)));\n const channelDepth = orderbookWsChannelDepth(requestedDepth);\n const channel = `public:spot:orderbook:deltas:depth:${channelDepth}:${symbolId}:proto`;\n\n const client = this.#client;\n const scales = this.#scales;\n let bidsMap: BookSide = new Map();\n let asksMap: BookSide = new Map();\n let currentBookSeq = 0n;\n // Set when a delta does not chain onto the book; only the next reset recovers it.\n let awaitingReset = false;\n let bucketTicks: bigint | null = null;\n let stream: SnapshotThenStreamSubscription | undefined;\n\n function levelsToMap(levels: Proto.PriceLevel[] | undefined): BookSide {\n const map: BookSide = new Map();\n for (const l of levels ?? []) {\n if (l.qtyScaled === 0n) continue;\n map.set(l.priceTicks, l.qtyScaled);\n }\n return map;\n }\n\n function applySideDelta(map: BookSide, levels: Proto.PriceLevel[] | undefined): void {\n for (const l of levels ?? []) {\n if (l.qtyScaled === 0n) map.delete(l.priceTicks);\n else map.set(l.priceTicks, l.qtyScaled);\n }\n }\n\n function sideToUI(map: BookSide, side: \"bids\" | \"asks\", limit: number): OrderbookLevel[] {\n const entries = Array.from(map.entries());\n entries.sort(([pa], [pb]) => {\n if (pa === pb) return 0;\n return side === \"bids\" ? (pa > pb ? -1 : 1) : pa < pb ? -1 : 1;\n });\n return entries\n .slice(0, limit)\n .map(([priceTicks, qtyScaled]) =>\n formatOrderbookLevel({ priceTicks, qtyScaled }, scales, symbolId),\n );\n }\n\n function sideToUIBucketed(\n map: BookSide,\n side: \"bids\" | \"asks\",\n limit: number,\n bucket: bigint | null,\n ): OrderbookLevel[] {\n if (!bucket || bucket <= 0n) return sideToUI(map, side, limit);\n\n const agg: BookSide = new Map();\n for (const [priceTicks, qtyScaled] of map.entries()) {\n if (qtyScaled <= 0n) continue;\n const bucketFloor = (priceTicks / bucket) * bucket;\n const bucketPrice =\n side === \"asks\" && bucketFloor !== priceTicks\n ? bucketFloor + bucket\n : bucketFloor;\n agg.set(bucketPrice, (agg.get(bucketPrice) ?? 0n) + qtyScaled);\n }\n return sideToUI(agg, side, limit);\n }\n\n function emit(): void {\n try {\n input.onEvent({\n symbolId,\n depth: requestedDepth,\n bookSeq: currentBookSeq.toString(),\n available: true,\n bids: sideToUIBucketed(bidsMap, \"bids\", requestedDepth, bucketTicks),\n asks: sideToUIBucketed(asksMap, \"asks\", requestedDepth, bucketTicks),\n });\n } catch (error) {\n input.onError?.(publicationHandlerErrorContext(channel, error));\n }\n }\n\n function setBucket(bucket: string | null | undefined): void {\n if (!bucket) {\n bucketTicks = null;\n } else {\n try {\n bucketTicks = decimalInputToScaled(\"bucket\", bucket, scales.price());\n } catch {\n bucketTicks = null;\n }\n }\n if (stream?.isReady()) emit();\n }\n\n async function inputServiceFetch(): Promise<Proto.GetOrderBookResponse> {\n await scales.ready();\n const validated = parse(GetOrderbookInputSchema, {\n symbolId,\n depth: channelDepth,\n });\n let res: Proto.GetOrderBookResponse;\n try {\n res = await client.getOrderBook({\n symbolId: validated.symbolId,\n depth: validated.protoDepth,\n });\n } catch (error: unknown) {\n if (!isResourceNotFoundError(error)) throw error;\n\n return create(Proto.GetOrderBookResponseSchema, {\n symbolId,\n bookSeq: 0n,\n available: true,\n bids: [],\n asks: [],\n });\n }\n // An unavailable book's levels are unknown, not empty: fail the snapshot so it is retried.\n if (!isBookAvailable(res)) {\n throw new ServiceUnavailableError(\n `Order book for symbol ${symbolId} is not available yet`,\n );\n }\n return res;\n }\n\n /**\n * Applies a delta only when it chains onto the current book (`bookSeqStart` equals the\n * last applied `bookSeqEnd`) or is a reset. A delta that does not chain leaves the book\n * waiting for the next reset, which the server sends periodically and after a gap.\n */\n function handleDelta(delta: Proto.OrderBookDelta): void {\n if (delta.bookSeqEnd <= currentBookSeq) return;\n\n if (delta.reset) {\n bidsMap.clear();\n asksMap.clear();\n awaitingReset = false;\n } else if (awaitingReset || delta.bookSeqStart !== currentBookSeq) {\n awaitingReset = true;\n return;\n }\n\n applySideDelta(bidsMap, delta.bids);\n applySideDelta(asksMap, delta.asks);\n\n currentBookSeq = delta.bookSeqEnd;\n emit();\n }\n\n setBucket(input.bucket);\n stream = snapshotThenStream({\n realtime: this.#realtime,\n channel,\n schema: Proto.OrderBookDeltaSchema,\n maxBufferedPublications: 200,\n snapshotErrorLog: \"Failed to fetch orderbook\",\n snapshotRetry: { maxAttempts: 3, delayMs: 1_000 },\n fetchSnapshot: inputServiceFetch,\n readPublication: (delta) => [delta],\n applySnapshot: (snapshot, bufferedDeltas) => {\n bidsMap = levelsToMap(snapshot.bids);\n asksMap = levelsToMap(snapshot.asks);\n currentBookSeq = snapshot.bookSeq;\n awaitingReset = false;\n emit();\n for (const delta of bufferedDeltas) {\n if (stream?.isDisposed()) return;\n handleDelta(delta);\n }\n },\n applyLivePublications: (deltas) => {\n for (const delta of deltas) {\n if (stream?.isDisposed()) return;\n handleDelta(delta);\n }\n },\n onOpen: input.onOpen,\n onClose: input.onClose,\n onError: input.onError,\n });\n\n function dispose(): void {\n stream?.unsubscribe();\n }\n\n return { unsubscribe: dispose, setBucket };\n }\n}\n\n/**\n * Whether a snapshot's levels are the book. A snapshot carrying levels is current even with\n * `available` false, which is how servers that predate the field encode every snapshot.\n */\nfunction isBookAvailable(res: Proto.GetOrderBookResponse): boolean {\n return res.available || res.bids.length > 0 || res.asks.length > 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoDA,IAAa,mBAAb,MAA8B;CAC1B;CACA;CACA;CAEA,YAAY,YAAiC,UAA6B,QAAmB;EACzF,KAAKA,UAAU,aAAaC,oBAAwB,WAAW,SAAS;EACxE,KAAKC,YAAY;EACjB,KAAKC,UAAU;CACnB;;;;;CAMA,MAAM,IACF,OACA,SACsB;EACtB,MAAM,YAAY,MAAM,yBAAyB,KAAK;EACtD,MAAM,KAAKA,QAAQ,MAAM;EACzB,MAAM,MAAM,MAAM,KAAKH,QAAQ,aAC3B;GAAE,UAAU,UAAU;GAAU,OAAO,UAAU;EAAW,GAC5D,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,0BAA0B,KAAKG,SAAS,UAAU,QAAQ,GAAG;GACtE,UAAU,IAAI;GACd,OAAO,UAAU;GACjB,SAAS,IAAI;GACb,WAAW,gBAAgB,GAAG;GAC9B,MAAM,IAAI;GACV,MAAM,IAAI;GACV,IAAI,IAAI;EACZ,CAAC;CACL;;;;CAKA,UAAU,OAA4C;EAClD,OAAO,KAAK,mBAAmB,KAAK,CAAC,CAAC;CAC1C;;;;;;;;CASA,mBAAmB,OAAgE;EAC/E,MAAM,EAAE,aAAa,MAAM,yBAAyB;GAChD,UAAU,MAAM;GAChB,OAAO,MAAM;EACjB,CAAC;EACD,MAAM,iBAAiB,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,MAAM,MAAM,SAAS,EAAE,CAAC,CAAC;EAC/E,MAAM,eAAe,wBAAwB,cAAc;EAC3D,MAAM,UAAU,sCAAsC,aAAa,GAAG,SAAS;EAE/E,MAAM,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AAgB;IAChB;GACJ;GAEA,eAAe,SAAS,MAAM,IAAI;GAClC,eAAe,SAAS,MAAM,IAAI;GAElC,iBAAiB,MAAM;GACvB,KAAK;EACT;EAEA,UAAU,MAAM,MAAM;EACtB,SAAS,mBAAmB;GACxB,UAAU,KAAKF;GACf;GACA,QAAQG;GACR,yBAAyB;GACzB,kBAAkB;GAClB,eAAe;IAAE,aAAa;IAAG,SAAS;GAAM;GAChD,eAAe;GACf,kBAAkB,UAAU,CAAC,KAAK;GAClC,gBAAgB,UAAU,mBAAmB;IACzC,UAAU,YAAY,SAAS,IAAI;IACnC,UAAU,YAAY,SAAS,IAAI;IACnC,iBAAiB,SAAS;IAC1B,gBAAgB;IAChB,KAAK;IACL,KAAK,MAAM,SAAS,gBAAgB;KAChC,IAAI,QAAQ,WAAW,GAAG;KAC1B,YAAY,KAAK;IACrB;GACJ;GACA,wBAAwB,WAAW;IAC/B,KAAK,MAAM,SAAS,QAAQ;KACxB,IAAI,QAAQ,WAAW,GAAG;KAC1B,YAAY,KAAK;IACrB;GACJ;GACA,QAAQ,MAAM;GACd,SAAS,MAAM;GACf,SAAS,MAAM;EACnB,CAAC;EAED,SAAS,UAAgB;GACrB,QAAQ,YAAY;EACxB;EAEA,OAAO;GAAE,aAAa;GAAS;EAAU;CAC7C;AACJ;;;;;AAMA,SAAS,gBAAgB,KAA0C;CAC/D,OAAO,IAAI,aAAa,IAAI,KAAK,SAAS,KAAK,IAAI,KAAK,SAAS;AACrE"}
1
+ {"version":3,"file":"orderbook.js","names":["#client","Proto.OrderbookService","#realtime","#scales","Proto.GetOrderBookResponseSchema","Proto.OrderBookDeltaSchema"],"sources":["../../../src/services/orderbook/orderbook.ts"],"sourcesContent":["import { create } from \"@bufbuild/protobuf\";\nimport * as Proto from \"../../gen/orderbook/v1/orderbook_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport { publicationHandlerErrorContext } from \"../../shared/subscription-errors.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport {\n snapshotThenStream,\n type SnapshotThenStreamSubscription,\n} from \"../../realtime/snapshot-then-stream.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { decimalInputToScaled, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n formatOrderbookLevel,\n GetOrderbookInputSchema,\n createOrderbookDataSchema,\n type OrderbookLevel,\n type OrderbookData,\n} from \"./orderbook.schemas.js\";\nimport { orderbookWsChannelDepth } from \"./orderbook.codecs.js\";\nimport { isResourceNotFoundError } from \"../../utils/errors.js\";\nimport { ServiceUnavailableError } from \"../../shared/errors.js\";\nimport type * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport type { PublicApiTransports } from \"../../shared/transports.js\";\n\ninterface SubscribeOrderbookInput extends BaseSubscribeInput<OrderbookData> {\n symbolId: number;\n depth?: number;\n bucket?: string | null;\n}\n\nexport interface OrderbookStreamHandlers extends BaseSubscribeInput<OrderbookData> {}\n\nexport interface OrderbookSubscription {\n unsubscribe: () => void;\n setBucket: (bucket: string | null | undefined) => void;\n}\n\nexport interface CreateOrderbookSubscriptionInput\n extends\n OrderbookStreamHandlers,\n Pick<SubscribeOrderbookInput, \"symbolId\" | \"depth\" | \"bucket\"> {}\n\ntype BookSide = Map<bigint, bigint>;\n\n/**\n * Reads spot order book snapshots and maintains realtime local order book state from public delta channels.\n */\nexport class OrderbookService {\n #client: Client<typeof Proto.OrderbookService>;\n #realtime: PolyesterRealtime;\n #scales: SdkScales;\n\n constructor(transports: PublicApiTransports, realtime: PolyesterRealtime, scales: SdkScales) {\n this.#client = createClient(Proto.OrderbookService, transports.publicApi);\n this.#realtime = realtime;\n this.#scales = scales;\n }\n\n /**\n * Fetches a spot order book depth snapshot for a symbol ID and requested depth, returning best bids and asks with the backend book sequence.\n * When `available` is false the book is being built or was invalidated: its levels are unknown, not empty, so read it again later instead of treating empty sides as no liquidity.\n */\n async get(\n input: v.InferInput<typeof GetOrderbookInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<OrderbookData> {\n const validated = parse(GetOrderbookInputSchema, input);\n await this.#scales.ready();\n const res = await this.#client.getOrderBook(\n { symbolId: validated.symbolId, depth: validated.depth },\n toConnectCallOptions(options),\n );\n return parse(createOrderbookDataSchema(this.#scales, validated.symbolId), {\n symbolId: res.symbolId,\n depth: validated.depth,\n bookSeq: res.bookSeq,\n bookEpoch: res.bookEpoch,\n maxDepth: res.maxDepth,\n available: isBookAvailable(res),\n bids: res.bids,\n asks: res.asks,\n ts: res.ts,\n });\n }\n\n /**\n * Subscribes to the managed order book stream for a symbol ID and forwards reconstructed snapshots to onEvent. This is a convenience wrapper around createSubscription().unsubscribe.\n */\n subscribe(input: SubscribeOrderbookInput): () => void {\n return this.createSubscription(input).unsubscribe;\n }\n\n /**\n * Creates a stateful order book subscription that first fetches a snapshot, buffers proto deltas from public:spot:orderbook:deltas:depth:{depth}:{symbolId}:proto, applies each delta only when it chains onto the book, and refetches on reconnects. After a sequence gap the book holds its last state until the server's next reset, sent about every 30 seconds and after gaps. A snapshot whose book is not available fails with ServiceUnavailableError through onError and is retried; no event is emitted until a snapshot is available. The snapshot is fetched once the channel opens, so a socket that cannot connect reports a retryable RealtimeError with type \"transport\" through onError instead, once per outage; onOpen follows when it recovers. The returned handle can unsubscribe or change local price bucket aggregation without reconnecting.\n *\n * `depth` is capped at 500 and rides the smallest published channel depth that covers it (see ORDERBOOK_WS_DEPTHS); levels are sliced back to the requested depth locally.\n *\n * A refetched snapshot from an older `bookEpoch` than the book's is discarded and retried.\n *\n * Refetching is driven by reconnect events only. A feed that stays subscribed but stops publishing is indistinguishable from a quiet market, so it does not trigger onError or a refetch. Callers that must detect a stalled book need their own idle watchdog plus a REST refetch.\n */\n createSubscription(input: CreateOrderbookSubscriptionInput): OrderbookSubscription {\n const { symbolId, depth } = parse(GetOrderbookInputSchema, {\n symbolId: input.symbolId,\n depth: input.depth,\n });\n const requestedDepth = Math.min(500, depth);\n const channelDepth = orderbookWsChannelDepth(requestedDepth);\n const channel = `public:spot:orderbook:deltas:depth:${channelDepth}:${symbolId}:proto`;\n\n const client = this.#client;\n const scales = this.#scales;\n let bidsMap: BookSide = new Map();\n let asksMap: BookSide = new Map();\n let currentBookSeq = 0n;\n let currentBookEpoch = 0n;\n let maxDepth = 0;\n // Set when a delta does not chain onto the book; only the next reset recovers it.\n let awaitingReset = false;\n let bucketTicks: bigint | null = null;\n let stream: SnapshotThenStreamSubscription | undefined;\n\n function levelsToMap(levels: Proto.PriceLevel[] | undefined): BookSide {\n const map: BookSide = new Map();\n for (const l of levels ?? []) {\n if (l.qtyScaled === 0n) continue;\n map.set(l.priceTicks, l.qtyScaled);\n }\n return map;\n }\n\n function applySideDelta(map: BookSide, levels: Proto.PriceLevel[] | undefined): void {\n for (const l of levels ?? []) {\n if (l.qtyScaled === 0n) map.delete(l.priceTicks);\n else map.set(l.priceTicks, l.qtyScaled);\n }\n }\n\n function sideToUI(map: BookSide, side: \"bids\" | \"asks\", limit: number): OrderbookLevel[] {\n const entries = Array.from(map.entries());\n entries.sort(([pa], [pb]) => {\n if (pa === pb) return 0;\n return side === \"bids\" ? (pa > pb ? -1 : 1) : pa < pb ? -1 : 1;\n });\n return entries\n .slice(0, limit)\n .map(([priceTicks, qtyScaled]) =>\n formatOrderbookLevel({ priceTicks, qtyScaled }, scales, symbolId),\n );\n }\n\n function sideToUIBucketed(\n map: BookSide,\n side: \"bids\" | \"asks\",\n limit: number,\n bucket: bigint | null,\n ): OrderbookLevel[] {\n if (!bucket || bucket <= 0n) return sideToUI(map, side, limit);\n\n const agg: BookSide = new Map();\n for (const [priceTicks, qtyScaled] of map.entries()) {\n if (qtyScaled <= 0n) continue;\n const bucketFloor = (priceTicks / bucket) * bucket;\n const bucketPrice =\n side === \"asks\" && bucketFloor !== priceTicks\n ? bucketFloor + bucket\n : bucketFloor;\n agg.set(bucketPrice, (agg.get(bucketPrice) ?? 0n) + qtyScaled);\n }\n return sideToUI(agg, side, limit);\n }\n\n function emit(): void {\n try {\n input.onEvent({\n symbolId,\n depth: requestedDepth,\n bookSeq: currentBookSeq.toString(),\n bookEpoch: currentBookEpoch.toString(),\n maxDepth,\n available: true,\n bids: sideToUIBucketed(bidsMap, \"bids\", requestedDepth, bucketTicks),\n asks: sideToUIBucketed(asksMap, \"asks\", requestedDepth, bucketTicks),\n });\n } catch (error) {\n input.onError?.(publicationHandlerErrorContext(channel, error));\n }\n }\n\n function setBucket(bucket: string | null | undefined): void {\n if (!bucket) {\n bucketTicks = null;\n } else {\n try {\n bucketTicks = decimalInputToScaled(\"bucket\", bucket, scales.price());\n } catch {\n bucketTicks = null;\n }\n }\n if (stream?.isReady()) emit();\n }\n\n async function inputServiceFetch(): Promise<Proto.GetOrderBookResponse> {\n await scales.ready();\n let res: Proto.GetOrderBookResponse;\n try {\n res = await client.getOrderBook({ symbolId, depth: channelDepth });\n } catch (error: unknown) {\n if (!isResourceNotFoundError(error)) throw error;\n\n return create(Proto.GetOrderBookResponseSchema, {\n symbolId,\n bookSeq: 0n,\n available: true,\n bids: [],\n asks: [],\n });\n }\n // An unavailable book's levels are unknown, not empty: fail the snapshot so it is retried.\n if (!isBookAvailable(res)) {\n throw new ServiceUnavailableError(\n `Order book for symbol ${symbolId} is not available yet`,\n );\n }\n if (res.bookEpoch < currentBookEpoch) {\n throw new ServiceUnavailableError(\n `Order book snapshot for symbol ${symbolId} is from an older epoch`,\n );\n }\n return res;\n }\n\n /**\n * Applies a delta only when it chains onto the current book (`bookSeqStart` equals the\n * last applied `bookSeqEnd`) or is a reset. A delta that does not chain leaves the book\n * waiting for the next reset, which the server sends periodically and after a gap.\n */\n function handleDelta(delta: Proto.OrderBookDelta): void {\n if (delta.bookSeqEnd <= currentBookSeq) return;\n\n if (delta.reset) {\n bidsMap.clear();\n asksMap.clear();\n awaitingReset = false;\n } else if (awaitingReset || delta.bookSeqStart !== currentBookSeq) {\n awaitingReset = true;\n return;\n }\n\n applySideDelta(bidsMap, delta.bids);\n applySideDelta(asksMap, delta.asks);\n\n currentBookSeq = delta.bookSeqEnd;\n emit();\n }\n\n setBucket(input.bucket);\n stream = snapshotThenStream({\n realtime: this.#realtime,\n channel,\n schema: Proto.OrderBookDeltaSchema,\n maxBufferedPublications: 200,\n snapshotErrorLog: \"Failed to fetch orderbook\",\n snapshotRetry: { maxAttempts: 3, delayMs: 1_000 },\n fetchSnapshot: inputServiceFetch,\n readPublication: (delta) => [delta],\n applySnapshot: (snapshot, bufferedDeltas) => {\n bidsMap = levelsToMap(snapshot.bids);\n asksMap = levelsToMap(snapshot.asks);\n currentBookSeq = snapshot.bookSeq;\n currentBookEpoch = snapshot.bookEpoch;\n maxDepth = snapshot.maxDepth;\n awaitingReset = false;\n emit();\n for (const delta of bufferedDeltas) {\n if (stream?.isDisposed()) return;\n handleDelta(delta);\n }\n },\n applyLivePublications: (deltas) => {\n for (const delta of deltas) {\n if (stream?.isDisposed()) return;\n handleDelta(delta);\n }\n },\n onOpen: input.onOpen,\n onClose: input.onClose,\n onError: input.onError,\n });\n\n function dispose(): void {\n stream?.unsubscribe();\n }\n\n return { unsubscribe: dispose, setBucket };\n }\n}\n\n/**\n * Whether a snapshot's levels are the book. A snapshot carrying levels is current even with\n * `available` false, which is how servers that predate the field encode every snapshot.\n */\nfunction isBookAvailable(res: Proto.GetOrderBookResponse): boolean {\n return res.available || res.bids.length > 0 || res.asks.length > 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoDA,IAAa,mBAAb,MAA8B;CAC1B;CACA;CACA;CAEA,YAAY,YAAiC,UAA6B,QAAmB;EACzF,KAAKA,UAAU,aAAaC,oBAAwB,WAAW,SAAS;EACxE,KAAKC,YAAY;EACjB,KAAKC,UAAU;CACnB;;;;;CAMA,MAAM,IACF,OACA,SACsB;EACtB,MAAM,YAAY,MAAM,yBAAyB,KAAK;EACtD,MAAM,KAAKA,QAAQ,MAAM;EACzB,MAAM,M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,KAAK,MAAM,SAAS,gBAAgB;KAChC,IAAI,QAAQ,WAAW,GAAG;KAC1B,YAAY,KAAK;IACrB;GACJ;GACA,wBAAwB,WAAW;IAC/B,KAAK,MAAM,SAAS,QAAQ;KACxB,IAAI,QAAQ,WAAW,GAAG;KAC1B,YAAY,KAAK;IACrB;GACJ;GACA,QAAQ,MAAM;GACd,SAAS,MAAM;GACf,SAAS,MAAM;EACnB,CAAC;EAED,SAAS,UAAgB;GACrB,QAAQ,YAAY;EACxB;EAEA,OAAO;GAAE,aAAa;GAAS;EAAU;CAC7C;AACJ;;;;;AAMA,SAAS,gBAAgB,KAA0C;CAC/D,OAAO,IAAI,aAAa,IAAI,KAAK,SAAS,KAAK,IAAI,KAAK,SAAS;AACrE"}
@@ -1,18 +1,11 @@
1
- import { Depth } from "../../gen/orderbook/v1/orderbook_pb.js";
2
1
  import { SdkScales } from "../../shared/decimal-surface.js";
3
2
  import * as v from "valibot";
4
3
  //#region src/services/orderbook/orderbook.schemas.d.ts
5
- declare const GetOrderbookInputSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
4
+ declare const GetOrderbookInputSchema: v.ObjectSchema<{
6
5
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
7
- readonly depth: v.OptionalSchema<v.NumberSchema<undefined>, 50>;
8
- }, undefined>, v.TransformAction<{
9
- symbolId: number;
10
- depth: number;
11
- }, {
12
- symbolId: number;
13
- depth: 1 | 5 | 10 | 20 | 100 | 200 | 500 | 1000 | 50;
14
- protoDepth: Depth;
15
- }>]>;
6
+ /** Price levels per side, sent as given. The server rejects a depth above the `maxDepth` it reports. */
7
+ readonly depth: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, 50>;
8
+ }, undefined>;
16
9
  type GetOrderbookInput = v.InferInput<typeof GetOrderbookInputSchema>;
17
10
  declare const OrderbookLevelInputSchema: v.ObjectSchema<{
18
11
  readonly priceTicks: v.BigintSchema<undefined>;
@@ -28,6 +21,10 @@ declare function createOrderbookDataSchema(scales: SdkScales, symbolId: number):
28
21
  readonly symbolId: v.LiteralSchema<number, undefined>;
29
22
  readonly depth: v.NumberSchema<undefined>;
30
23
  readonly bookSeq: v.BigintSchema<undefined>;
24
+ /** Epoch of `bookSeq`: order snapshots by `(bookEpoch, bookSeq)`, since a new epoch may restart `bookSeq`. */
25
+ readonly bookEpoch: v.BigintSchema<undefined>;
26
+ /** Largest `depth` the server accepts. */
27
+ readonly maxDepth: v.NumberSchema<undefined>;
31
28
  /** False while the book is being built or after it was invalidated: its levels are unknown, not empty. */
32
29
  readonly available: v.BooleanSchema<undefined>;
33
30
  readonly bids: v.ArraySchema<v.ObjectSchema<{
@@ -50,6 +47,8 @@ declare function createOrderbookDataSchema(scales: SdkScales, symbolId: number):
50
47
  symbolId: number;
51
48
  depth: number;
52
49
  bookSeq: bigint;
50
+ bookEpoch: bigint;
51
+ maxDepth: number;
53
52
  available: boolean;
54
53
  bids: {
55
54
  priceTicks: bigint;
@@ -62,6 +61,7 @@ declare function createOrderbookDataSchema(scales: SdkScales, symbolId: number):
62
61
  ts?: number | undefined;
63
62
  }, {
64
63
  bookSeq: string;
64
+ bookEpoch: string;
65
65
  bids: {
66
66
  price: string;
67
67
  qty: string;
@@ -72,6 +72,7 @@ declare function createOrderbookDataSchema(scales: SdkScales, symbolId: number):
72
72
  }[];
73
73
  symbolId: number;
74
74
  depth: number;
75
+ maxDepth: number;
75
76
  available: boolean;
76
77
  ts?: number | undefined;
77
78
  }>]>;
@@ -1 +1 @@
1
- {"version":3,"file":"orderbook.schemas.d.ts","names":[],"sources":["../../../src/services/orderbook/orderbook.schemas.ts"],"mappings":";;;;cAMa,yBAAuB,EAAA,yBAAA,EAAA;;;;;;;;;cAAA;;KAexB,oBAAoB,EAAE,kBAAkB;cAE9C,2BAAyB,EAAA;;;;KAKnB,sBAAsB,EAAE,mBAAmB;iBAEvC,qBACZ,OAAO,qBACP,QAAQ,WACR;;;;KAQQ,iBAAiB,kBAAkB;iBAE/B,0BAA0B,QAAQ,WAAW,mBAAgB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsBjE,gBAAgB,EAAE,YAAY,kBAAkB"}
1
+ {"version":3,"file":"orderbook.schemas.d.ts","names":[],"sources":["../../../src/services/orderbook/orderbook.schemas.ts"],"mappings":";;;cAKa,yBAAuB,EAAA;;;;;KAMxB,oBAAoB,EAAE,kBAAkB;cAE9C,2BAAyB,EAAA;;;;KAKnB,sBAAsB,EAAE,mBAAmB;iBAEvC,qBACZ,OAAO,qBACP,QAAQ,WACR;;;;KAQQ,iBAAiB,kBAAkB;iBAE/B,0BAA0B,QAAQ,WAAW,mBAAgB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2BjE,gBAAgB,EAAE,YAAY,kBAAkB"}