@polyester/sdk 0.18.0 → 0.19.1

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 (36) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +258 -3
  3. package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts.map +1 -1
  4. package/dist/gen/ledger/read/v1/ledger_read_pb.js +55 -13
  5. package/dist/gen/ledger/read/v1/ledger_read_pb.js.map +1 -1
  6. package/dist/index.d.ts +2 -2
  7. package/dist/services/balances/balances.d.ts +9 -1
  8. package/dist/services/balances/balances.d.ts.map +1 -1
  9. package/dist/services/balances/balances.js +22 -1
  10. package/dist/services/balances/balances.js.map +1 -1
  11. package/dist/services/balances/balances.schemas.d.ts +165 -1
  12. package/dist/services/balances/balances.schemas.d.ts.map +1 -1
  13. package/dist/services/balances/balances.schemas.js +84 -3
  14. package/dist/services/balances/balances.schemas.js.map +1 -1
  15. package/dist/services/balances/balances.types.d.ts +2 -2
  16. package/dist/services/balances/index.d.ts +2 -2
  17. package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
  18. package/dist/services/market-overview/market-overview.d.ts +1 -0
  19. package/dist/services/market-overview/market-overview.d.ts.map +1 -1
  20. package/dist/services/market-overview/market-overview.js +24 -6
  21. package/dist/services/market-overview/market-overview.js.map +1 -1
  22. package/dist/services/orderbook/orderbook.schemas.d.ts +1 -1
  23. package/dist/services/orders/orders-input.schemas.d.ts +1 -1
  24. package/dist/services/orders/orders-output.schemas.d.ts +6 -6
  25. package/dist/services/subaccounts/subaccounts.schemas.d.ts +5 -5
  26. package/dist/services/trades/trades.d.ts +3 -4
  27. package/dist/services/trades/trades.d.ts.map +1 -1
  28. package/dist/services/trades/trades.js +1 -1
  29. package/dist/services/trades/trades.js.map +1 -1
  30. package/dist/services/trades/trades.schemas.d.ts +41 -7
  31. package/dist/services/trades/trades.schemas.d.ts.map +1 -1
  32. package/dist/services/trades/trades.schemas.js +20 -10
  33. package/dist/services/trades/trades.schemas.js.map +1 -1
  34. package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
  35. package/dist/services/triggers/triggers-output.schemas.d.ts +18 -18
  36. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"balances.schemas.d.ts","names":[],"sources":["../../../src/services/balances/balances.schemas.ts"],"mappings":";;;;;;;;;;;;;iBAuCgB,6BAAyB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+B7B,gBAAgB,EAAE,YAAY,kBAAkB;cAQ/C,oBAAkB,EAAA;KAEnB,eAAe,EAAE,mBAAmB;cAInC,qBAAmB,EAAA;KAEpB,gBAAgB,EAAE,mBAAmB;cAEpC,2BAAyB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;KA2B1B,sBAAsB,EAAE,kBAAkB;iBAQtC,sCAAkC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA0CtC,yBAAyB,EAAE,YACnC,kBAAkB;cAGT,0BAAwB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;KA2BzB,qBAAqB,EAAE,kBAAkB;KAmBzC;EAEF;EACA,aAAa,YAAY;EACzB;;EAGA;EACA;EACA;;cAGG,oBAAkB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKO,UAAA;EAA8B;;iBA6BpD,kCAAkC,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA7B7B,UAAA;IAA8B;;;;;;;;;;;IAA9B,UAAA;IAA8B;;;;;;;;;;;IAA9B,UAAA;IAA8B;;;;KAiExD,eAAe,EAAE,mBAAmB;KACpC,wBAAwB,EAAE,YAClC,kBAAkB"}
1
+ {"version":3,"file":"balances.schemas.d.ts","names":[],"sources":["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;;;;;;;;;;IAZtC,UAAA;IAAuC;;;;;;;;;;;IAAvC,UAAA;IAAuC;;;;;;;;;;;IAAvC,UAAA;IAAuC;;;;KA+CjE,wBAAwB,EAAE,mBAAmB;KAC7C,iCAAiC,EAAE,YAC3C,kBAAkB;iBA6BN,4CAA4C,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmBjE,kCAAkC,EAAE,YAC5C,kBAAkB"}
@@ -1,4 +1,5 @@
1
1
  import { requiredEnumLabel } from "../../shared/proto-enum-codec.js";
2
+ import { PublicIdSchema } from "../../shared/schemas.js";
2
3
  import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
3
4
  import { BalanceRange } from "../../gen/ledger/read/v1/ledger_read_pb.js";
4
5
  import { scaledToDecimalOutput } from "../../shared/decimal-surface.js";
@@ -57,11 +58,12 @@ const BALANCE_RANGES = [
57
58
  "365d"
58
59
  ];
59
60
  const BalanceRangeSchema = v.picklist(BALANCE_RANGES);
61
+ const BalanceRangeInputSchema = v.pipe(BalanceRangeSchema, v.transform((value) => BalanceRangeCodec.inputToProto[value]));
60
62
  const EQUITY_GROUP_BYS = ["account", "asset"];
61
63
  const EquityGroupBySchema = v.picklist(EQUITY_GROUP_BYS);
62
64
  const BalanceHistoryInputSchema = v.pipe(v.strictObject({
63
65
  ...AccountScopeInputEntries,
64
- range: v.pipe(BalanceRangeSchema, v.transform((v) => BalanceRangeCodec.inputToProto[v])),
66
+ range: BalanceRangeInputSchema,
65
67
  ledger: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(4294967295)), 0),
66
68
  accountCodes: v.optional(v.array(v.pipe(v.picklist(ACCOUNT_CODE_VALUES), v.transform((value) => AccountCodeCodec.inputToProto[value]))), [])
67
69
  }), v.transform(({ account, ...input }) => ({
@@ -98,13 +100,14 @@ function createBalanceHistoryResponseSchema() {
98
100
  }
99
101
  const EquityHistoryInputSchema = v.pipe(v.strictObject({
100
102
  ...AccountScopeInputEntries,
101
- range: v.pipe(BalanceRangeSchema, v.transform((v) => BalanceRangeCodec.inputToProto[v])),
103
+ range: BalanceRangeInputSchema,
102
104
  accountCodes: v.optional(v.array(v.pipe(v.picklist(ACCOUNT_CODE_VALUES), v.transform((value) => AccountCodeCodec.inputToProto[value]))), []),
103
105
  groupBy: v.pipe(v.optional(EquityGroupBySchema, "account"), v.transform((v) => EquityGroupByCodec.inputToProto[v ?? "account"]))
104
106
  }), v.transform(({ account, ...input }) => ({
105
107
  ...input,
106
108
  subaccountId: accountScopeToSubaccountId(account)
107
109
  })));
110
+ const PortfolioEquityHistoryInputSchema = v.strictObject({ range: BalanceRangeInputSchema });
108
111
  const EquitySeriesGroupingSchema = v.union([v.object({
109
112
  case: v.literal("account"),
110
113
  value: v.object({
@@ -161,7 +164,85 @@ function createEquityHistoryResponseSchema(scales) {
161
164
  btcPrices: data.btcPricesQ.map((value) => scaledToDecimalOutput(value, scales.price()))
162
165
  })));
163
166
  }
167
+ const PortfolioAccountGroupingSchema = v.variant("remaining", [v.object({
168
+ accountId: PublicIdSchema,
169
+ remaining: v.literal(false)
170
+ }), v.object({
171
+ accountId: v.optional(v.never()),
172
+ remaining: v.literal(true)
173
+ })]);
174
+ const PortfolioEquitySeriesSchema = v.pipe(v.object({
175
+ grouping: v.object({
176
+ case: v.literal("portfolioAccount"),
177
+ value: PortfolioAccountGroupingSchema
178
+ }),
179
+ equityQ: v.array(v.bigint())
180
+ }), v.transform((series) => ({
181
+ grouping: series.grouping.value.remaining ? {
182
+ type: "portfolioAccount",
183
+ remaining: true
184
+ } : {
185
+ type: "portfolioAccount",
186
+ accountId: series.grouping.value.accountId,
187
+ remaining: false
188
+ },
189
+ equity: series.equityQ.map((value) => scaledToDecimalOutput(value, EQUITY_SCALE))
190
+ })));
191
+ function createPortfolioEquityHistoryResponseSchema(scales) {
192
+ return v.pipe(v.object({
193
+ range: v.pipe(v.enum(BalanceRange), v.transform((value) => requiredEnumLabel(BalanceRangeCodec.protoToOutput, value, "PortfolioEquityHistoryResponseSchema", "range"))),
194
+ bucket: v.string(),
195
+ startTsSec: v.number(),
196
+ endTsSec: v.number(),
197
+ quoteAsset: v.string(),
198
+ points: v.number(),
199
+ series: v.array(PortfolioEquitySeriesSchema),
200
+ btcPricesQ: v.optional(v.array(v.bigint()), [])
201
+ }), v.transform((data) => ({
202
+ range: data.range,
203
+ bucket: data.bucket,
204
+ startTsSec: data.startTsSec,
205
+ endTsSec: data.endTsSec,
206
+ quoteAsset: data.quoteAsset,
207
+ points: data.points,
208
+ series: data.series,
209
+ btcPrices: data.btcPricesQ.map((value) => scaledToDecimalOutput(value, scales.price()))
210
+ })));
211
+ }
212
+ const PortfolioAccountEquitySchema = v.pipe(v.object({
213
+ accountId: PublicIdSchema,
214
+ equityQ: v.bigint(),
215
+ topAssetIds: v.array(v.number())
216
+ }), v.transform((account) => ({
217
+ accountId: account.accountId,
218
+ equity: scaledToDecimalOutput(account.equityQ, EQUITY_SCALE),
219
+ topAssetIds: account.topAssetIds
220
+ })));
221
+ const PortfolioAssetEquitySchema = v.pipe(v.object({
222
+ assetId: v.number(),
223
+ balanceQ: v.bigint(),
224
+ equityQ: v.bigint()
225
+ }), v.transform((asset) => ({
226
+ assetId: asset.assetId,
227
+ balance: scaledToDecimalOutput(asset.balanceQ, BALANCE_HISTORY_SCALE),
228
+ equity: scaledToDecimalOutput(asset.equityQ, EQUITY_SCALE)
229
+ })));
230
+ function createPortfolioEquitySnapshotResponseSchema(scales) {
231
+ return v.pipe(v.object({
232
+ quoteAsset: v.string(),
233
+ totalEquityQ: v.bigint(),
234
+ accounts: v.array(PortfolioAccountEquitySchema),
235
+ assets: v.array(PortfolioAssetEquitySchema),
236
+ btcPriceQ: v.bigint()
237
+ }), v.transform((snapshot) => ({
238
+ quoteAsset: snapshot.quoteAsset,
239
+ totalEquity: scaledToDecimalOutput(snapshot.totalEquityQ, EQUITY_SCALE),
240
+ accounts: snapshot.accounts,
241
+ assets: snapshot.assets,
242
+ btcPrice: scaledToDecimalOutput(snapshot.btcPriceQ, scales.price())
243
+ })));
244
+ }
164
245
  //#endregion
165
- export { BALANCE_RANGES, BalanceHistoryInputSchema, BalanceRangeSchema, BalancesListInputSchema, EQUITY_GROUP_BYS, EquityGroupBySchema, EquityHistoryInputSchema, EquitySeriesSchema, createBalanceHistoryResponseSchema, createEquityHistoryResponseSchema, createLedgerBalanceSchema };
246
+ export { BALANCE_RANGES, BalanceHistoryInputSchema, BalanceRangeSchema, BalancesListInputSchema, EQUITY_GROUP_BYS, EquityGroupBySchema, EquityHistoryInputSchema, EquitySeriesSchema, PortfolioEquityHistoryInputSchema, PortfolioEquitySeriesSchema, createBalanceHistoryResponseSchema, createEquityHistoryResponseSchema, createLedgerBalanceSchema, createPortfolioEquityHistoryResponseSchema, createPortfolioEquitySnapshotResponseSchema };
166
247
 
167
248
  //# sourceMappingURL=balances.schemas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"balances.schemas.js","names":["Proto.BalanceRange"],"sources":["../../../src/services/balances/balances.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { fromU128 } from \"../../utils/u128.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport type { DecodedEnum } from \"../../utils/types.js\";\nimport * as Proto from \"../../gen/ledger/read/v1/ledger_read_pb.js\";\nimport {\n AccountCodeCodec,\n ACCOUNT_CODE_VALUES,\n type AccountCodeValue,\n} from \"../../shared/ledger-codes.js\";\nimport { E18_SCALE, scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { BalanceRangeCodec, EquityGroupByCodec } from \"./balances.codecs.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\n\n/**\n * Equity history values are quoted in the response's quote currency at a fixed\n * 4-decimal wire scale (proto: \"Equity in quote currency scaled by 1e4\").\n */\nconst EQUITY_SCALE = 4;\n\n/**\n * Balance history buckets use a fixed 7-decimal scale (proto: \"balance in\n * asset units scaled by 1e7\"), unlike live ledger balances which use E18.\n */\nconst BALANCE_HISTORY_SCALE = 7;\n\nconst U128Schema = v.object({\n hi: v.bigint(),\n lo: v.bigint(),\n});\n\n/**\n * AssetBalance u128 fields on the ledger wire are always 18-decimal scaled\n * (PolyesterChain base units), independent of per-asset quantityScale used\n * elsewhere for order quantities and transfer inputs.\n */\nexport function createLedgerBalanceSchema() {\n return v.pipe(\n v.object({\n assetId: v.number(),\n trading: v.pipe(v.optional(U128Schema), v.transform(fromU128)),\n funding: v.pipe(v.optional(U128Schema), v.transform(fromU128)),\n reserved: v.pipe(v.optional(U128Schema), v.transform(fromU128)),\n available: v.pipe(v.optional(U128Schema), v.transform(fromU128)),\n tradingRevision: v.pipe(\n v.optional(v.bigint(), 0n),\n v.transform((value) => value.toString()),\n ),\n fundingRevision: v.pipe(\n v.optional(v.bigint(), 0n),\n v.transform((value) => value.toString()),\n ),\n }),\n v.transform((b) => {\n return {\n assetId: b.assetId,\n funding: scaledToDecimalOutput(b.funding ?? 0n, E18_SCALE),\n trading: scaledToDecimalOutput(b.trading ?? 0n, E18_SCALE),\n reserved: scaledToDecimalOutput(b.reserved ?? 0n, E18_SCALE),\n available: scaledToDecimalOutput(b.available ?? 0n, E18_SCALE),\n tradingRevision: b.tradingRevision,\n fundingRevision: b.fundingRevision,\n };\n }),\n );\n}\n\nexport type LedgerBalance = v.InferOutput<ReturnType<typeof createLedgerBalanceSchema>>;\n\nexport const BalancesListInputSchema = v.strictObject(AccountScopeInputEntries);\n\nexport type BalancesListInput = v.InferInput<typeof BalancesListInputSchema>;\n\nexport const BALANCE_RANGES = [\"1d\", \"7d\", \"30d\", \"90d\", \"180d\", \"365d\"] as const;\n\nexport const BalanceRangeSchema = v.picklist(BALANCE_RANGES);\n\nexport type BalanceRange = v.InferOutput<typeof BalanceRangeSchema>;\n\nexport const EQUITY_GROUP_BYS = [\"account\", \"asset\"] as const;\n\nexport const EquityGroupBySchema = v.picklist(EQUITY_GROUP_BYS);\n\nexport type EquityGroupBy = v.InferOutput<typeof EquityGroupBySchema>;\n\nexport const BalanceHistoryInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n range: v.pipe(\n BalanceRangeSchema,\n v.transform((v) => BalanceRangeCodec.inputToProto[v]),\n ),\n ledger: v.optional(\n v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(4_294_967_295)),\n 0,\n ),\n accountCodes: v.optional(\n v.array(\n v.pipe(\n v.picklist(ACCOUNT_CODE_VALUES),\n v.transform((value) => AccountCodeCodec.inputToProto[value]),\n ),\n ),\n [],\n ),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type BalanceHistoryInput = v.InferInput<typeof BalanceHistoryInputSchema>;\n\nconst BalanceSeriesSchema = v.object({\n assetId: v.number(),\n accountCode: v.enum(AccountCodeCodec.inputToProto),\n balanceQ: v.array(v.bigint()),\n});\n\nexport function createBalanceHistoryResponseSchema() {\n return v.pipe(\n v.object({\n range: v.pipe(\n v.enum(Proto.BalanceRange),\n v.transform((v) =>\n requiredEnumLabel(\n BalanceRangeCodec.protoToOutput,\n v,\n \"BalanceHistoryResponseSchema\",\n \"range\",\n ),\n ),\n ),\n bucket: v.string(),\n startTsSec: v.number(),\n endTsSec: v.number(),\n points: v.number(),\n series: v.array(BalanceSeriesSchema),\n }),\n v.transform((data) => ({\n range: data.range,\n bucket: data.bucket,\n startTsSec: data.startTsSec,\n endTsSec: data.endTsSec,\n points: data.points,\n series: data.series.map((s) => {\n return {\n assetId: s.assetId,\n accountCode: requiredEnumLabel(\n AccountCodeCodec.protoToOutput,\n s.accountCode,\n \"BalanceHistoryResponseSchema\",\n \"account code\",\n ),\n balance: s.balanceQ.map((b) => scaledToDecimalOutput(b, BALANCE_HISTORY_SCALE)),\n };\n }),\n })),\n );\n}\n\nexport type BalanceHistoryResponse = v.InferOutput<\n ReturnType<typeof createBalanceHistoryResponseSchema>\n>;\n\nexport const EquityHistoryInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n range: v.pipe(\n BalanceRangeSchema,\n v.transform((v) => BalanceRangeCodec.inputToProto[v]),\n ),\n accountCodes: v.optional(\n v.array(\n v.pipe(\n v.picklist(ACCOUNT_CODE_VALUES),\n v.transform((value) => AccountCodeCodec.inputToProto[value]),\n ),\n ),\n [],\n ),\n groupBy: v.pipe(\n v.optional(EquityGroupBySchema, \"account\"),\n v.transform((v) => EquityGroupByCodec.inputToProto[v ?? \"account\"]),\n ),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type EquityHistoryInput = v.InferInput<typeof EquityHistoryInputSchema>;\n\nconst EquitySeriesGroupingSchema = v.union([\n v.object({\n case: v.literal(\"account\"),\n value: v.object({\n accountCode: v.enum(AccountCodeCodec.inputToProto),\n name: v.string(),\n }),\n }),\n v.object({\n case: v.literal(\"asset\"),\n value: v.object({\n id: v.number(),\n symbol: v.string(),\n }),\n }),\n]);\n\nexport type EquitySeriesGrouping =\n | {\n type: \"account\";\n accountCode: DecodedEnum<AccountCodeValue>;\n name: string;\n }\n | {\n type: \"asset\";\n assetId: number;\n symbol: string;\n };\n\nexport const EquitySeriesSchema = v.pipe(\n v.object({\n grouping: EquitySeriesGroupingSchema,\n equityQ: v.array(v.bigint()),\n }),\n v.transform((series): { grouping: EquitySeriesGrouping; equity: string[] } => {\n const equity = series.equityQ.map((value) => scaledToDecimalOutput(value, EQUITY_SCALE));\n if (series.grouping.case === \"account\") {\n return {\n grouping: {\n type: \"account\",\n accountCode: requiredEnumLabel(\n AccountCodeCodec.protoToOutput,\n series.grouping.value.accountCode,\n \"EquitySeriesSchema\",\n \"account code\",\n ),\n name: series.grouping.value.name,\n },\n equity,\n };\n }\n\n return {\n grouping: {\n type: \"asset\",\n assetId: series.grouping.value.id,\n symbol: series.grouping.value.symbol,\n },\n equity,\n };\n }),\n);\n\nexport function createEquityHistoryResponseSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n range: v.pipe(\n v.enum(Proto.BalanceRange),\n v.transform((v) =>\n requiredEnumLabel(\n BalanceRangeCodec.protoToOutput,\n v,\n \"EquityHistoryResponseSchema\",\n \"range\",\n ),\n ),\n ),\n bucket: v.string(),\n startTsSec: v.number(),\n endTsSec: v.number(),\n quoteAsset: v.string(),\n points: v.number(),\n series: v.array(EquitySeriesSchema),\n btcPricesQ: v.optional(v.array(v.bigint()), []),\n }),\n v.transform((data) => ({\n range: data.range,\n bucket: data.bucket,\n startTsSec: data.startTsSec,\n endTsSec: data.endTsSec,\n quoteAsset: data.quoteAsset,\n points: data.points,\n series: data.series,\n // BTC price in USDT at each timestamp, carried as price ticks on the wire.\n btcPrices: data.btcPricesQ.map((value) => scaledToDecimalOutput(value, scales.price())),\n })),\n );\n}\n\nexport type EquitySeries = v.InferOutput<typeof EquitySeriesSchema>;\nexport type EquityHistoryResponse = v.InferOutput<\n ReturnType<typeof createEquityHistoryResponseSchema>\n>;\n"],"mappings":";;;;;;;;;;;;;AAqBA,MAAM,eAAe;;;;;AAMrB,MAAM,wBAAwB;AAE9B,MAAM,aAAa,EAAE,OAAO;CACxB,IAAI,EAAE,OAAO;CACb,IAAI,EAAE,OAAO;AACjB,CAAC;;;;;;AAOD,SAAgB,4BAA4B;CACxC,OAAO,EAAE,KACL,EAAE,OAAO;EACL,SAAS,EAAE,OAAO;EAClB,SAAS,EAAE,KAAK,EAAE,SAAS,UAAU,GAAG,EAAE,UAAU,QAAQ,CAAC;EAC7D,SAAS,EAAE,KAAK,EAAE,SAAS,UAAU,GAAG,EAAE,UAAU,QAAQ,CAAC;EAC7D,UAAU,EAAE,KAAK,EAAE,SAAS,UAAU,GAAG,EAAE,UAAU,QAAQ,CAAC;EAC9D,WAAW,EAAE,KAAK,EAAE,SAAS,UAAU,GAAG,EAAE,UAAU,QAAQ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EAAE,OAAO;EACjB,QAAQ,EAAE,MAAM,kBAAkB;EAClC,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;CAClD,CAAC,GACD,EAAE,WAAW,UAAU;EACnB,OAAO,KAAK;EACZ,QAAQ,KAAK;EACb,YAAY,KAAK;EACjB,UAAU,KAAK;EACf,YAAY,KAAK;EACjB,QAAQ,KAAK;EACb,QAAQ,KAAK;EAEb,WAAW,KAAK,WAAW,KAAK,UAAU,sBAAsB,OAAO,OAAO,MAAM,CAAC,CAAC;CAC1F,EAAE,CACN;AACJ"}
1
+ {"version":3,"file":"balances.schemas.js","names":["Proto.BalanceRange"],"sources":["../../../src/services/balances/balances.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { fromU128 } from \"../../utils/u128.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport type { DecodedEnum } from \"../../utils/types.js\";\nimport * as Proto from \"../../gen/ledger/read/v1/ledger_read_pb.js\";\nimport {\n AccountCodeCodec,\n ACCOUNT_CODE_VALUES,\n type AccountCodeValue,\n} from \"../../shared/ledger-codes.js\";\nimport { E18_SCALE, scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { BalanceRangeCodec, EquityGroupByCodec } from \"./balances.codecs.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { PublicIdSchema } from \"../../shared/schemas.js\";\n\n/**\n * Equity history values are quoted in the response's quote currency at a fixed\n * 4-decimal wire scale (proto: \"Equity in quote currency scaled by 1e4\").\n */\nconst EQUITY_SCALE = 4;\n\n/**\n * Balance history buckets use a fixed 7-decimal scale (proto: \"balance in\n * asset units scaled by 1e7\"), unlike live ledger balances which use E18.\n */\nconst BALANCE_HISTORY_SCALE = 7;\n\nconst U128Schema = v.object({\n hi: v.bigint(),\n lo: v.bigint(),\n});\n\n/**\n * AssetBalance u128 fields on the ledger wire are always 18-decimal scaled\n * (PolyesterChain base units), independent of per-asset quantityScale used\n * elsewhere for order quantities and transfer inputs.\n */\nexport function createLedgerBalanceSchema() {\n return v.pipe(\n v.object({\n assetId: v.number(),\n trading: v.pipe(v.optional(U128Schema), v.transform(fromU128)),\n funding: v.pipe(v.optional(U128Schema), v.transform(fromU128)),\n reserved: v.pipe(v.optional(U128Schema), v.transform(fromU128)),\n available: v.pipe(v.optional(U128Schema), v.transform(fromU128)),\n tradingRevision: v.pipe(\n v.optional(v.bigint(), 0n),\n v.transform((value) => value.toString()),\n ),\n fundingRevision: v.pipe(\n v.optional(v.bigint(), 0n),\n v.transform((value) => value.toString()),\n ),\n }),\n v.transform((b) => {\n return {\n assetId: b.assetId,\n funding: scaledToDecimalOutput(b.funding ?? 0n, E18_SCALE),\n trading: scaledToDecimalOutput(b.trading ?? 0n, E18_SCALE),\n reserved: scaledToDecimalOutput(b.reserved ?? 0n, E18_SCALE),\n available: scaledToDecimalOutput(b.available ?? 0n, E18_SCALE),\n tradingRevision: b.tradingRevision,\n fundingRevision: b.fundingRevision,\n };\n }),\n );\n}\n\nexport type LedgerBalance = v.InferOutput<ReturnType<typeof createLedgerBalanceSchema>>;\n\nexport const BalancesListInputSchema = v.strictObject(AccountScopeInputEntries);\n\nexport type BalancesListInput = v.InferInput<typeof BalancesListInputSchema>;\n\nexport const BALANCE_RANGES = [\"1d\", \"7d\", \"30d\", \"90d\", \"180d\", \"365d\"] as const;\n\nexport const BalanceRangeSchema = v.picklist(BALANCE_RANGES);\n\nexport type BalanceRange = v.InferOutput<typeof BalanceRangeSchema>;\n\nconst BalanceRangeInputSchema = v.pipe(\n BalanceRangeSchema,\n v.transform((value) => BalanceRangeCodec.inputToProto[value]),\n);\n\nexport const EQUITY_GROUP_BYS = [\"account\", \"asset\"] as const;\n\nexport const EquityGroupBySchema = v.picklist(EQUITY_GROUP_BYS);\n\nexport type EquityGroupBy = v.InferOutput<typeof EquityGroupBySchema>;\n\nexport const BalanceHistoryInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n range: BalanceRangeInputSchema,\n ledger: v.optional(\n v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(4_294_967_295)),\n 0,\n ),\n accountCodes: v.optional(\n v.array(\n v.pipe(\n v.picklist(ACCOUNT_CODE_VALUES),\n v.transform((value) => AccountCodeCodec.inputToProto[value]),\n ),\n ),\n [],\n ),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type BalanceHistoryInput = v.InferInput<typeof BalanceHistoryInputSchema>;\n\nconst BalanceSeriesSchema = v.object({\n assetId: v.number(),\n accountCode: v.enum(AccountCodeCodec.inputToProto),\n balanceQ: v.array(v.bigint()),\n});\n\nexport function createBalanceHistoryResponseSchema() {\n return v.pipe(\n v.object({\n range: v.pipe(\n v.enum(Proto.BalanceRange),\n v.transform((v) =>\n requiredEnumLabel(\n BalanceRangeCodec.protoToOutput,\n v,\n \"BalanceHistoryResponseSchema\",\n \"range\",\n ),\n ),\n ),\n bucket: v.string(),\n startTsSec: v.number(),\n endTsSec: v.number(),\n points: v.number(),\n series: v.array(BalanceSeriesSchema),\n }),\n v.transform((data) => ({\n range: data.range,\n bucket: data.bucket,\n startTsSec: data.startTsSec,\n endTsSec: data.endTsSec,\n points: data.points,\n series: data.series.map((s) => {\n return {\n assetId: s.assetId,\n accountCode: requiredEnumLabel(\n AccountCodeCodec.protoToOutput,\n s.accountCode,\n \"BalanceHistoryResponseSchema\",\n \"account code\",\n ),\n balance: s.balanceQ.map((b) => scaledToDecimalOutput(b, BALANCE_HISTORY_SCALE)),\n };\n }),\n })),\n );\n}\n\nexport type BalanceHistoryResponse = v.InferOutput<\n ReturnType<typeof createBalanceHistoryResponseSchema>\n>;\n\nexport const EquityHistoryInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n range: BalanceRangeInputSchema,\n accountCodes: v.optional(\n v.array(\n v.pipe(\n v.picklist(ACCOUNT_CODE_VALUES),\n v.transform((value) => AccountCodeCodec.inputToProto[value]),\n ),\n ),\n [],\n ),\n groupBy: v.pipe(\n v.optional(EquityGroupBySchema, \"account\"),\n v.transform((v) => EquityGroupByCodec.inputToProto[v ?? \"account\"]),\n ),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type EquityHistoryInput = v.InferInput<typeof EquityHistoryInputSchema>;\n\nexport const PortfolioEquityHistoryInputSchema = v.strictObject({\n range: BalanceRangeInputSchema,\n});\n\nexport type PortfolioEquityHistoryInput = v.InferInput<typeof PortfolioEquityHistoryInputSchema>;\n\nconst EquitySeriesGroupingSchema = v.union([\n v.object({\n case: v.literal(\"account\"),\n value: v.object({\n accountCode: v.enum(AccountCodeCodec.inputToProto),\n name: v.string(),\n }),\n }),\n v.object({\n case: v.literal(\"asset\"),\n value: v.object({\n id: v.number(),\n symbol: v.string(),\n }),\n }),\n]);\n\nexport type EquitySeriesGrouping =\n | {\n type: \"account\";\n accountCode: DecodedEnum<AccountCodeValue>;\n name: string;\n }\n | {\n type: \"asset\";\n assetId: number;\n symbol: string;\n };\n\nexport const EquitySeriesSchema = v.pipe(\n v.object({\n grouping: EquitySeriesGroupingSchema,\n equityQ: v.array(v.bigint()),\n }),\n v.transform((series): { grouping: EquitySeriesGrouping; equity: string[] } => {\n const equity = series.equityQ.map((value) => scaledToDecimalOutput(value, EQUITY_SCALE));\n if (series.grouping.case === \"account\") {\n return {\n grouping: {\n type: \"account\",\n accountCode: requiredEnumLabel(\n AccountCodeCodec.protoToOutput,\n series.grouping.value.accountCode,\n \"EquitySeriesSchema\",\n \"account code\",\n ),\n name: series.grouping.value.name,\n },\n equity,\n };\n }\n\n return {\n grouping: {\n type: \"asset\",\n assetId: series.grouping.value.id,\n symbol: series.grouping.value.symbol,\n },\n equity,\n };\n }),\n);\n\nexport function createEquityHistoryResponseSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n range: v.pipe(\n v.enum(Proto.BalanceRange),\n v.transform((v) =>\n requiredEnumLabel(\n BalanceRangeCodec.protoToOutput,\n v,\n \"EquityHistoryResponseSchema\",\n \"range\",\n ),\n ),\n ),\n bucket: v.string(),\n startTsSec: v.number(),\n endTsSec: v.number(),\n quoteAsset: v.string(),\n points: v.number(),\n series: v.array(EquitySeriesSchema),\n btcPricesQ: v.optional(v.array(v.bigint()), []),\n }),\n v.transform((data) => ({\n range: data.range,\n bucket: data.bucket,\n startTsSec: data.startTsSec,\n endTsSec: data.endTsSec,\n quoteAsset: data.quoteAsset,\n points: data.points,\n series: data.series,\n // BTC price in USDT at each timestamp, carried as price ticks on the wire.\n btcPrices: data.btcPricesQ.map((value) => scaledToDecimalOutput(value, scales.price())),\n })),\n );\n}\n\nexport type EquitySeries = v.InferOutput<typeof EquitySeriesSchema>;\nexport type EquityHistoryResponse = v.InferOutput<\n ReturnType<typeof createEquityHistoryResponseSchema>\n>;\n\nconst PortfolioAccountGroupingSchema = v.variant(\"remaining\", [\n v.object({\n accountId: PublicIdSchema,\n remaining: v.literal(false),\n }),\n v.object({\n accountId: v.optional(v.never()),\n remaining: v.literal(true),\n }),\n]);\n\nexport type PortfolioEquitySeriesGrouping =\n | { type: \"portfolioAccount\"; accountId: string; remaining: false }\n | { type: \"portfolioAccount\"; accountId?: never; remaining: true };\n\nexport const PortfolioEquitySeriesSchema = v.pipe(\n v.object({\n grouping: v.object({\n case: v.literal(\"portfolioAccount\"),\n value: PortfolioAccountGroupingSchema,\n }),\n equityQ: v.array(v.bigint()),\n }),\n v.transform((series): { grouping: PortfolioEquitySeriesGrouping; equity: string[] } => ({\n grouping: series.grouping.value.remaining\n ? { type: \"portfolioAccount\", remaining: true }\n : {\n type: \"portfolioAccount\",\n accountId: series.grouping.value.accountId,\n remaining: false,\n },\n equity: series.equityQ.map((value) => scaledToDecimalOutput(value, EQUITY_SCALE)),\n })),\n);\n\nexport function createPortfolioEquityHistoryResponseSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n range: v.pipe(\n v.enum(Proto.BalanceRange),\n v.transform((value) =>\n requiredEnumLabel(\n BalanceRangeCodec.protoToOutput,\n value,\n \"PortfolioEquityHistoryResponseSchema\",\n \"range\",\n ),\n ),\n ),\n bucket: v.string(),\n startTsSec: v.number(),\n endTsSec: v.number(),\n quoteAsset: v.string(),\n points: v.number(),\n series: v.array(PortfolioEquitySeriesSchema),\n btcPricesQ: v.optional(v.array(v.bigint()), []),\n }),\n v.transform((data) => ({\n range: data.range,\n bucket: data.bucket,\n startTsSec: data.startTsSec,\n endTsSec: data.endTsSec,\n quoteAsset: data.quoteAsset,\n points: data.points,\n series: data.series,\n btcPrices: data.btcPricesQ.map((value) => scaledToDecimalOutput(value, scales.price())),\n })),\n );\n}\n\nexport type PortfolioEquitySeries = v.InferOutput<typeof PortfolioEquitySeriesSchema>;\nexport type PortfolioEquityHistoryResponse = v.InferOutput<\n ReturnType<typeof createPortfolioEquityHistoryResponseSchema>\n>;\n\nconst PortfolioAccountEquitySchema = v.pipe(\n v.object({\n accountId: PublicIdSchema,\n equityQ: v.bigint(),\n topAssetIds: v.array(v.number()),\n }),\n v.transform((account) => ({\n accountId: account.accountId,\n equity: scaledToDecimalOutput(account.equityQ, EQUITY_SCALE),\n topAssetIds: account.topAssetIds,\n })),\n);\n\nconst PortfolioAssetEquitySchema = v.pipe(\n v.object({\n assetId: v.number(),\n balanceQ: v.bigint(),\n equityQ: v.bigint(),\n }),\n v.transform((asset) => ({\n assetId: asset.assetId,\n balance: scaledToDecimalOutput(asset.balanceQ, BALANCE_HISTORY_SCALE),\n equity: scaledToDecimalOutput(asset.equityQ, EQUITY_SCALE),\n })),\n);\n\nexport function createPortfolioEquitySnapshotResponseSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n quoteAsset: v.string(),\n totalEquityQ: v.bigint(),\n accounts: v.array(PortfolioAccountEquitySchema),\n assets: v.array(PortfolioAssetEquitySchema),\n btcPriceQ: v.bigint(),\n }),\n v.transform((snapshot) => ({\n quoteAsset: snapshot.quoteAsset,\n totalEquity: scaledToDecimalOutput(snapshot.totalEquityQ, EQUITY_SCALE),\n accounts: snapshot.accounts,\n assets: snapshot.assets,\n btcPrice: scaledToDecimalOutput(snapshot.btcPriceQ, scales.price()),\n })),\n );\n}\n\nexport type PortfolioEquitySnapshotResponse = v.InferOutput<\n ReturnType<typeof createPortfolioEquitySnapshotResponseSchema>\n>;\n"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAM,eAAe;;;;;AAMrB,MAAM,wBAAwB;AAE9B,MAAM,aAAa,EAAE,OAAO;CACxB,IAAI,EAAE,OAAO;CACb,IAAI,EAAE,OAAO;AACjB,CAAC;;;;;;AAOD,SAAgB,4BAA4B;CACxC,OAAO,EAAE,KACL,EAAE,OAAO;EACL,SAAS,EAAE,OAAO;EAClB,SAAS,EAAE,KAAK,EAAE,SAAS,UAAU,GAAG,EAAE,UAAU,QAAQ,CAAC;EAC7D,SAAS,EAAE,KAAK,EAAE,SAAS,UAAU,GAAG,EAAE,UAAU,QAAQ,CAAC;EAC7D,UAAU,EAAE,KAAK,EAAE,SAAS,UAAU,GAAG,EAAE,UAAU,QAAQ,CAAC;EAC9D,WAAW,EAAE,KAAK,EAAE,SAAS,UAAU,GAAG,EAAE,UAAU,QAAQ,CAAC;EAC/D,iBAAiB,EAAE,KACf,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE,GACzB,EAAE,WAAW,UAAU,MAAM,SAAS,CAAC,CAC3C;EACA,iBAAiB,EAAE,KACf,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE,GACzB,EAAE,WAAW,UAAU,MAAM,SAAS,CAAC,CAC3C;CACJ,CAAC,GACD,EAAE,WAAW,MAAM;EACf,OAAO;GACH,SAAS,EAAE;GACX,SAAS,sBAAsB,EAAE,WAAW,IAAA,EAAa;GACzD,SAAS,sBAAsB,EAAE,WAAW,IAAA,EAAa;GACzD,UAAU,sBAAsB,EAAE,YAAY,IAAA,EAA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,OAAO,MAAM,CAAC,CAAC;CAC1F,EAAE,CACN;AACJ;AAOA,MAAM,+BAA+B,EAAE,KACnC,EAAE,OAAO;CACL,WAAW;CACX,SAAS,EAAE,OAAO;CAClB,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC;AACnC,CAAC,GACD,EAAE,WAAW,aAAa;CACtB,WAAW,QAAQ;CACnB,QAAQ,sBAAsB,QAAQ,SAAS,YAAY;CAC3D,aAAa,QAAQ;AACzB,EAAE,CACN;AAEA,MAAM,6BAA6B,EAAE,KACjC,EAAE,OAAO;CACL,SAAS,EAAE,OAAO;CAClB,UAAU,EAAE,OAAO;CACnB,SAAS,EAAE,OAAO;AACtB,CAAC,GACD,EAAE,WAAW,WAAW;CACpB,SAAS,MAAM;CACf,SAAS,sBAAsB,MAAM,UAAU,qBAAqB;CACpE,QAAQ,sBAAsB,MAAM,SAAS,YAAY;AAC7D,EAAE,CACN;AAEA,SAAgB,4CAA4C,QAAmB;CAC3E,OAAO,EAAE,KACL,EAAE,OAAO;EACL,YAAY,EAAE,OAAO;EACrB,cAAc,EAAE,OAAO;EACvB,UAAU,EAAE,MAAM,4BAA4B;EAC9C,QAAQ,EAAE,MAAM,0BAA0B;EAC1C,WAAW,EAAE,OAAO;CACxB,CAAC,GACD,EAAE,WAAW,cAAc;EACvB,YAAY,SAAS;EACrB,aAAa,sBAAsB,SAAS,cAAc,YAAY;EACtE,UAAU,SAAS;EACnB,QAAQ,SAAS;EACjB,UAAU,sBAAsB,SAAS,WAAW,OAAO,MAAM,CAAC;CACtE,EAAE,CACN;AACJ"}
@@ -1,2 +1,2 @@
1
- import { BalanceHistoryInput, BalanceHistoryResponse, BalanceRange, EquityGroupBy, EquityHistoryInput, EquityHistoryResponse, EquitySeries, EquitySeriesGrouping, LedgerBalance } from "./balances.schemas.js";
2
- export type { BalanceHistoryInput, BalanceHistoryResponse, BalanceRange, EquityGroupBy, EquityHistoryInput, EquityHistoryResponse, EquitySeries, EquitySeriesGrouping, LedgerBalance };
1
+ import { BalanceHistoryInput, BalanceHistoryResponse, BalanceRange, EquityGroupBy, EquityHistoryInput, EquityHistoryResponse, EquitySeries, EquitySeriesGrouping, LedgerBalance, PortfolioEquityHistoryInput, PortfolioEquityHistoryResponse, PortfolioEquitySeries, PortfolioEquitySeriesGrouping, PortfolioEquitySnapshotResponse } from "./balances.schemas.js";
2
+ export type { BalanceHistoryInput, BalanceHistoryResponse, BalanceRange, EquityGroupBy, EquityHistoryInput, EquityHistoryResponse, EquitySeries, EquitySeriesGrouping, LedgerBalance, PortfolioEquityHistoryInput, PortfolioEquityHistoryResponse, PortfolioEquitySeries, PortfolioEquitySeriesGrouping, PortfolioEquitySnapshotResponse };
@@ -1,4 +1,4 @@
1
- import { BalanceHistoryInput, BalanceHistoryInputSchema, BalanceHistoryResponse, BalanceRange, BalanceRangeSchema, EquityGroupBy, EquityGroupBySchema, EquityHistoryInput, EquityHistoryInputSchema, EquityHistoryResponse, EquitySeries, EquitySeriesGrouping, EquitySeriesSchema, LedgerBalance, createBalanceHistoryResponseSchema, createEquityHistoryResponseSchema, createLedgerBalanceSchema } from "./balances.schemas.js";
1
+ import { BalanceHistoryInput, BalanceHistoryInputSchema, BalanceHistoryResponse, BalanceRange, BalanceRangeSchema, EquityGroupBy, EquityGroupBySchema, EquityHistoryInput, EquityHistoryInputSchema, EquityHistoryResponse, EquitySeries, EquitySeriesGrouping, EquitySeriesSchema, LedgerBalance, PortfolioEquityHistoryInput, PortfolioEquityHistoryInputSchema, PortfolioEquityHistoryResponse, PortfolioEquitySeries, PortfolioEquitySeriesGrouping, PortfolioEquitySeriesSchema, PortfolioEquitySnapshotResponse, createBalanceHistoryResponseSchema, createEquityHistoryResponseSchema, createLedgerBalanceSchema, createPortfolioEquityHistoryResponseSchema, createPortfolioEquitySnapshotResponseSchema } from "./balances.schemas.js";
2
2
  import { BalancesService } from "./balances.js";
3
3
  import { mergeLedgerBalances } from "./balances.merge.js";
4
- export { BalanceHistoryInput, BalanceHistoryInputSchema, BalanceHistoryResponse, BalanceRange, BalanceRangeSchema, BalancesService, EquityGroupBy, EquityGroupBySchema, EquityHistoryInput, EquityHistoryInputSchema, EquityHistoryResponse, EquitySeries, EquitySeriesGrouping, EquitySeriesSchema, LedgerBalance, createBalanceHistoryResponseSchema, createEquityHistoryResponseSchema, createLedgerBalanceSchema, mergeLedgerBalances };
4
+ export { BalanceHistoryInput, BalanceHistoryInputSchema, BalanceHistoryResponse, BalanceRange, BalanceRangeSchema, BalancesService, EquityGroupBy, EquityGroupBySchema, EquityHistoryInput, EquityHistoryInputSchema, EquityHistoryResponse, EquitySeries, EquitySeriesGrouping, EquitySeriesSchema, LedgerBalance, PortfolioEquityHistoryInput, PortfolioEquityHistoryInputSchema, PortfolioEquityHistoryResponse, PortfolioEquitySeries, PortfolioEquitySeriesGrouping, PortfolioEquitySeriesSchema, PortfolioEquitySnapshotResponse, createBalanceHistoryResponseSchema, createEquityHistoryResponseSchema, createLedgerBalanceSchema, createPortfolioEquityHistoryResponseSchema, createPortfolioEquitySnapshotResponseSchema, mergeLedgerBalances };
@@ -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<5 | 10 | 20 | 1 | 200 | 1000 | 500 | 50 | 100, 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<5 | 10 | 20 | 1 | 200 | 1000 | 500 | 100 | 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, 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 50 | 100>]>;
230
+ readonly depth: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 100 | 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: 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 50 | 100;
290
+ depth: 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 100 | 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: 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 50 | 100;
350
+ depth: 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 100 | 50;
351
351
  chain: {
352
352
  baseKeyframe: {
353
353
  tsSec: number;
@@ -6,6 +6,7 @@ import { SdkScales } from "../../shared/decimal-surface.js";
6
6
  import { ListMarketOverviewInput, MarketOverview, SparklineIntervalName } from "./market-overview.schemas.js";
7
7
  //#region src/services/market-overview/market-overview.d.ts
8
8
  interface SubscribeMarketOverviewInput extends BaseSubscribeInput<MarketOverview[]> {
9
+ symbolIds?: number[];
9
10
  includeSparklines?: boolean;
10
11
  sparklineIntervals?: SparklineIntervalName[];
11
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"market-overview.d.ts","names":[],"sources":["../../../src/services/market-overview/market-overview.ts"],"mappings":";;;;;;;UAqBU,qCAAqC,mBAAmB;EAC9D;EACA,qBAAqB;;;;;cAMZ;;EAMG,YAAA,YAAY,qBAAqB,UAAU,mBAAmB,QAAQ;;;;EAU5E,KACF,QAAO,yBACP,UAAU,0BACX;IAAU,SAAS;IAAkB;;;;;EAgBxC,UAAU,OAAO"}
1
+ {"version":3,"file":"market-overview.d.ts","names":[],"sources":["../../../src/services/market-overview/market-overview.ts"],"mappings":";;;;;;;UAsBU,qCAAqC,mBAAmB;EAC9D;EACA;EACA,qBAAqB;;;;;cAMZ;;EAMG,YAAA,YAAY,qBAAqB,UAAU,mBAAmB,QAAQ;;;;EAU5E,KACF,QAAO,yBACP,UAAU,0BACX;IAAU,SAAS;IAAkB;;;;;EA8CxC,UAAU,OAAO"}
@@ -1,10 +1,11 @@
1
1
  import { parse } from "../../shared/validation.js";
2
2
  import { toConnectCallOptions } from "../../shared/request-options.js";
3
+ import { CatalogLookupError } from "../../catalogs/types.js";
4
+ import { isDev } from "../../utils/is-dev.js";
3
5
  import { MarketOverviewBatchSchema, MarketOverviewService as MarketOverviewService$1 } from "../../gen/marketoverview/v1/marketoverview_pb.js";
4
6
  import { snapshotThenStream } from "../../realtime/snapshot-then-stream.js";
5
7
  import { ListMarketOverviewInputSchema, createMarketOverviewSchema } from "./market-overview.schemas.js";
6
8
  import { createClient } from "@connectrpc/connect";
7
- import * as v from "valibot";
8
9
  //#region src/services/market-overview/market-overview.ts
9
10
  /**
10
11
  * Provides ticker-style per-market stats and a live merged overview stream.
@@ -28,11 +29,30 @@ var MarketOverviewService = class {
28
29
  await this.#scales.ready();
29
30
  const res = await this.#client.listMarketOverview(validatedInput, toConnectCallOptions(options));
30
31
  return {
31
- markets: parse(v.array(this.#marketOverviewSchema), res.markets),
32
+ markets: this.#decodeMarkets(res.markets),
32
33
  nextPageToken: res.nextPageToken
33
34
  };
34
35
  }
35
36
  /**
37
+ * Decodes market rows, skipping any whose symbolId the catalog cannot resolve
38
+ * (unknown or disabled pairs the backend still reports). Other errors propagate.
39
+ */
40
+ #decodeMarkets(markets) {
41
+ const decoded = [];
42
+ const skipped = [];
43
+ for (const m of markets) try {
44
+ decoded.push(parse(this.#marketOverviewSchema, m));
45
+ } catch (error) {
46
+ if (error instanceof CatalogLookupError && error.domain === "market" && error.lookup === "symbolId") {
47
+ skipped.push(m.symbolId);
48
+ continue;
49
+ }
50
+ throw error;
51
+ }
52
+ if (skipped.length > 0 && isDev()) console.warn(`[market-overview] skipped ${skipped.length} row(s) with unknown symbolId: ${skipped.join(", ")}`);
53
+ return decoded;
54
+ }
55
+ /**
36
56
  * Subscribes to public:spot:market_overview:updates:proto, fetches an initial snapshot, buffers updates until ready, and emits the merged set of latest market rows. On reconnect it refetches the snapshot before resuming updates.
37
57
  */
38
58
  subscribe(input) {
@@ -41,7 +61,7 @@ var MarketOverviewService = class {
41
61
  const includeSparklines = input.includeSparklines ?? true;
42
62
  const sparklineIntervals = input.sparklineIntervals ?? ["24h"];
43
63
  const listMarketOverview = this.list.bind(this);
44
- const schema = this.#marketOverviewSchema;
64
+ const parseMarkets = this.#decodeMarkets.bind(this);
45
65
  function emit() {
46
66
  input.onEvent(Array.from(bySymbolId.values()));
47
67
  }
@@ -51,11 +71,9 @@ var MarketOverviewService = class {
51
71
  function applyMarkets(markets) {
52
72
  for (const market of markets) handleMarketUpdate(market);
53
73
  }
54
- function parseMarkets(markets) {
55
- return markets.map((m) => parse(schema, m));
56
- }
57
74
  async function fetchSnapshot() {
58
75
  return (await listMarketOverview({
76
+ symbolIds: input.symbolIds,
59
77
  includeSparklines,
60
78
  sparklineIntervals
61
79
  })).markets;
@@ -1 +1 @@
1
- {"version":3,"file":"market-overview.js","names":["#client","Proto.MarketOverviewService","#realtime","#scales","#marketOverviewSchema","Proto.MarketOverviewBatchSchema"],"sources":["../../../src/services/market-overview/market-overview.ts"],"sourcesContent":["import * as Proto from \"../../gen/marketoverview/v1/marketoverview_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport { snapshotThenStream } 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 type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport type { PublicApiTransports } from \"../../shared/transports.js\";\nimport {\n ListMarketOverviewInputSchema,\n createMarketOverviewSchema,\n type SparklineIntervalName,\n type ListMarketOverviewInput,\n type MarketOverview,\n} from \"./market-overview.schemas.js\";\n\ninterface SubscribeMarketOverviewInput extends BaseSubscribeInput<MarketOverview[]> {\n includeSparklines?: boolean;\n sparklineIntervals?: SparklineIntervalName[];\n}\n\n/**\n * Provides ticker-style per-market stats and a live merged overview stream.\n */\nexport class MarketOverviewService {\n #client: Client<typeof Proto.MarketOverviewService>;\n #realtime: PolyesterRealtime;\n #scales: SdkScales;\n #marketOverviewSchema: ReturnType<typeof createMarketOverviewSchema>;\n\n constructor(transports: PublicApiTransports, realtime: PolyesterRealtime, scales: SdkScales) {\n this.#client = createClient(Proto.MarketOverviewService, transports.publicApi);\n this.#realtime = realtime;\n this.#scales = scales;\n this.#marketOverviewSchema = createMarketOverviewSchema(scales);\n }\n\n /**\n * Returns market overview rows with last and index prices, 24h stats, top-of-book values, listing timestamp, and optional sparklines. Supports symbol ID filtering, sorting, pagination, and sparkline interval selection.\n */\n async list(\n input: ListMarketOverviewInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ markets: MarketOverview[]; nextPageToken: string }> {\n const validatedInput = parse(ListMarketOverviewInputSchema, input);\n await this.#scales.ready();\n const res = await this.#client.listMarketOverview(\n validatedInput,\n toConnectCallOptions(options),\n );\n return {\n markets: parse(v.array(this.#marketOverviewSchema), res.markets),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Subscribes to public:spot:market_overview:updates:proto, fetches an initial snapshot, buffers updates until ready, and emits the merged set of latest market rows. On reconnect it refetches the snapshot before resuming updates.\n */\n subscribe(input: SubscribeMarketOverviewInput): () => void {\n const channel = \"public:spot:market_overview:updates:proto\";\n const bySymbolId = new Map<number, MarketOverview>();\n const includeSparklines = input.includeSparklines ?? true;\n const sparklineIntervals = input.sparklineIntervals ?? [\"24h\"];\n const listMarketOverview = this.list.bind(this);\n const schema = this.#marketOverviewSchema;\n function emit(): void {\n input.onEvent(Array.from(bySymbolId.values()));\n }\n\n function handleMarketUpdate(m: MarketOverview): void {\n bySymbolId.set(m.symbolId, m);\n }\n\n function applyMarkets(markets: readonly MarketOverview[]): void {\n for (const market of markets) {\n handleMarketUpdate(market);\n }\n }\n\n function parseMarkets(markets: readonly Proto.MarketOverview[]): MarketOverview[] {\n return markets.map((m) => parse(schema, m));\n }\n\n async function fetchSnapshot(): Promise<MarketOverview[]> {\n const result = await listMarketOverview({\n includeSparklines,\n sparklineIntervals,\n });\n return result.markets;\n }\n\n const stream = snapshotThenStream({\n realtime: this.#realtime,\n channel,\n schema: Proto.MarketOverviewBatchSchema,\n maxBufferedPublications: 2000,\n snapshotErrorLog: \"Failed to fetch market overview\",\n fetchSnapshot,\n readPublication: (batch) => batch.markets ?? [],\n bufferPublicationKey: (market) => market.symbolId,\n applySnapshot: (markets, bufferedMarkets) => {\n bySymbolId.clear();\n applyMarkets(markets);\n applyMarkets(parseMarkets(bufferedMarkets));\n emit();\n },\n applyLivePublications: (markets) => {\n applyMarkets(parseMarkets(markets));\n emit();\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 dispose;\n }\n}\n"],"mappings":";;;;;;;;;;;AA6BA,IAAa,wBAAb,MAAmC;CAC/B;CACA;CACA;CACA;CAEA,YAAY,YAAiC,UAA6B,QAAmB;EACzF,KAAKA,UAAU,aAAaC,yBAA6B,WAAW,SAAS;EAC7E,KAAKC,YAAY;EACjB,KAAKC,UAAU;EACf,KAAKC,wBAAwB,2BAA2B,MAAM;CAClE;;;;CAKA,MAAM,KACF,QAAiC,CAAC,GAClC,SAC6D;EAC7D,MAAM,iBAAiB,MAAM,+BAA+B,KAAK;EACjE,MAAM,KAAKD,QAAQ,MAAM;EACzB,MAAM,MAAM,MAAM,KAAKH,QAAQ,mBAC3B,gBACA,qBAAqB,OAAO,CAChC;EACA,OAAO;GACH,SAAS,MAAM,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realtime","#scales","#marketOverviewSchema","#decodeMarkets","Proto.MarketOverviewBatchSchema"],"sources":["../../../src/services/market-overview/market-overview.ts"],"sourcesContent":["import * as Proto from \"../../gen/marketoverview/v1/marketoverview_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport { parse } from \"../../shared/validation.js\";\nimport { CatalogLookupError } from \"../../catalogs/types.js\";\nimport { isDev } from \"../../utils/is-dev.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport { snapshotThenStream } 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 type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport type { PublicApiTransports } from \"../../shared/transports.js\";\nimport {\n ListMarketOverviewInputSchema,\n createMarketOverviewSchema,\n type SparklineIntervalName,\n type ListMarketOverviewInput,\n type MarketOverview,\n} from \"./market-overview.schemas.js\";\n\ninterface SubscribeMarketOverviewInput extends BaseSubscribeInput<MarketOverview[]> {\n symbolIds?: number[];\n includeSparklines?: boolean;\n sparklineIntervals?: SparklineIntervalName[];\n}\n\n/**\n * Provides ticker-style per-market stats and a live merged overview stream.\n */\nexport class MarketOverviewService {\n #client: Client<typeof Proto.MarketOverviewService>;\n #realtime: PolyesterRealtime;\n #scales: SdkScales;\n #marketOverviewSchema: ReturnType<typeof createMarketOverviewSchema>;\n\n constructor(transports: PublicApiTransports, realtime: PolyesterRealtime, scales: SdkScales) {\n this.#client = createClient(Proto.MarketOverviewService, transports.publicApi);\n this.#realtime = realtime;\n this.#scales = scales;\n this.#marketOverviewSchema = createMarketOverviewSchema(scales);\n }\n\n /**\n * Returns market overview rows with last and index prices, 24h stats, top-of-book values, listing timestamp, and optional sparklines. Supports symbol ID filtering, sorting, pagination, and sparkline interval selection.\n */\n async list(\n input: ListMarketOverviewInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ markets: MarketOverview[]; nextPageToken: string }> {\n const validatedInput = parse(ListMarketOverviewInputSchema, input);\n await this.#scales.ready();\n const res = await this.#client.listMarketOverview(\n validatedInput,\n toConnectCallOptions(options),\n );\n return {\n markets: this.#decodeMarkets(res.markets),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Decodes market rows, skipping any whose symbolId the catalog cannot resolve\n * (unknown or disabled pairs the backend still reports). Other errors propagate.\n */\n #decodeMarkets(markets: readonly Proto.MarketOverview[]): MarketOverview[] {\n const decoded: MarketOverview[] = [];\n const skipped: number[] = [];\n for (const m of markets) {\n try {\n decoded.push(parse(this.#marketOverviewSchema, m));\n } catch (error) {\n if (\n error instanceof CatalogLookupError &&\n error.domain === \"market\" &&\n error.lookup === \"symbolId\"\n ) {\n skipped.push(m.symbolId);\n continue;\n }\n throw error;\n }\n }\n if (skipped.length > 0 && isDev()) {\n console.warn(\n `[market-overview] skipped ${skipped.length} row(s) with unknown symbolId: ${skipped.join(\", \")}`,\n );\n }\n return decoded;\n }\n\n /**\n * Subscribes to public:spot:market_overview:updates:proto, fetches an initial snapshot, buffers updates until ready, and emits the merged set of latest market rows. On reconnect it refetches the snapshot before resuming updates.\n */\n subscribe(input: SubscribeMarketOverviewInput): () => void {\n const channel = \"public:spot:market_overview:updates:proto\";\n const bySymbolId = new Map<number, MarketOverview>();\n const includeSparklines = input.includeSparklines ?? true;\n const sparklineIntervals = input.sparklineIntervals ?? [\"24h\"];\n const listMarketOverview = this.list.bind(this);\n const parseMarkets = this.#decodeMarkets.bind(this);\n function emit(): void {\n input.onEvent(Array.from(bySymbolId.values()));\n }\n\n function handleMarketUpdate(m: MarketOverview): void {\n bySymbolId.set(m.symbolId, m);\n }\n\n function applyMarkets(markets: readonly MarketOverview[]): void {\n for (const market of markets) {\n handleMarketUpdate(market);\n }\n }\n\n async function fetchSnapshot(): Promise<MarketOverview[]> {\n const result = await listMarketOverview({\n symbolIds: input.symbolIds,\n includeSparklines,\n sparklineIntervals,\n });\n return result.markets;\n }\n\n const stream = snapshotThenStream({\n realtime: this.#realtime,\n channel,\n schema: Proto.MarketOverviewBatchSchema,\n maxBufferedPublications: 2000,\n snapshotErrorLog: \"Failed to fetch market overview\",\n fetchSnapshot,\n readPublication: (batch) => batch.markets ?? [],\n bufferPublicationKey: (market) => market.symbolId,\n applySnapshot: (markets, bufferedMarkets) => {\n bySymbolId.clear();\n applyMarkets(markets);\n applyMarkets(parseMarkets(bufferedMarkets));\n emit();\n },\n applyLivePublications: (markets) => {\n applyMarkets(parseMarkets(markets));\n emit();\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 dispose;\n }\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,IAAa,wBAAb,MAAmC;CAC/B;CACA;CACA;CACA;CAEA,YAAY,YAAiC,UAA6B,QAAmB;EACzF,KAAKA,UAAU,aAAaC,yBAA6B,WAAW,SAAS;EAC7E,KAAKC,YAAY;EACjB,KAAKC,UAAU;EACf,KAAKC,wBAAwB,2BAA2B,MAAM;CAClE;;;;CAKA,MAAM,KACF,QAAiC,CAAC,GAClC,SAC6D;EAC7D,MAAM,iBAAiB,MAAM,+BAA+B,KAAK;EACjE,MAAM,KAAKD,QAAQ,MAAM;EACzB,MAAM,MAAM,MAAM,KAAKH,QAAQ,mBAC3B,gBACA,qBAAqB,OAAO,CAChC;EACA,OAAO;GACH,SAAS,KAAKK,eAAe,IAAI,OAAO;GACxC,eAAe,IAAI;EACvB;CACJ;;;;;CAMA,eAAe,SAA4D;EACvE,MAAM,UAA4B,CAAC;EACnC,MAAM,UAAoB,CAAC;EAC3B,KAAK,MAAM,KAAK,SACZ,IAAI;GACA,QAAQ,KAAK,MAAM,KAAKD,uBAAuB,CAAC,CAAC;EACrD,SAAS,OAAO;GACZ,IACI,iBAAiB,sBACjB,MAAM,WAAW,YACjB,MAAM,WAAW,YACnB;IACE,QAAQ,KAAK,EAAE,QAAQ;IACvB;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derbookInputSchema: v.SchemaWithPipe<readonly [v.ObjectSchema
10
10
  depth: number;
11
11
  }, {
12
12
  symbolId: number;
13
- depth: 5 | 10 | 20 | 1 | 200 | 1000 | 500 | 50 | 100;
13
+ depth: 5 | 10 | 20 | 1 | 200 | 1000 | 500 | 100 | 50;
14
14
  protoDepth: Depth;
15
15
  }>]>;
16
16
  type GetOrderbookInput = v.InferInput<typeof GetOrderbookInputSchema>;
@@ -40,7 +40,7 @@ type OpenOrdersInput = v.InferInput<typeof OpenOrdersInputSchema>;
40
40
  declare const OrderHistoryInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
41
41
  readonly includeAttachedRisk: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
42
42
  readonly includeAttachedRiskState: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
43
- readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["FILLED", "CANCELED", "REJECTED"], undefined>, undefined>, v.TransformAction<"CANCELED" | "REJECTED" | "FILLED" | undefined, OrderStatus.FILLED | OrderStatus.CANCELED | OrderStatus.REJECTED | undefined>]>;
43
+ readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["FILLED", "CANCELED", "REJECTED"], undefined>, undefined>, v.TransformAction<"CANCELED" | "FILLED" | "REJECTED" | undefined, OrderStatus.FILLED | OrderStatus.CANCELED | OrderStatus.REJECTED | undefined>]>;
44
44
  readonly startTsNs: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
45
45
  readonly endTsNs: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
46
46
  readonly symbolId: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>, undefined>;
@@ -243,7 +243,7 @@ declare function createOrderSchema(scales: SdkScales): v.SchemaWithPipe<readonly
243
243
  attachedRisk: {
244
244
  takeProfit: {
245
245
  state: {
246
- status: "unspecified" | "created" | "failed" | "completed" | "armed" | "running" | "paused" | "canceled" | "not_configured";
246
+ status: "unspecified" | "failed" | "completed" | "created" | "armed" | "running" | "paused" | "canceled" | "not_configured";
247
247
  armedTs: number | undefined;
248
248
  armedTsNs: string | undefined;
249
249
  terminalTs: number | undefined;
@@ -262,7 +262,7 @@ declare function createOrderSchema(scales: SdkScales): v.SchemaWithPipe<readonly
262
262
  } | undefined;
263
263
  stopLoss: {
264
264
  state: {
265
- status: "unspecified" | "created" | "failed" | "completed" | "armed" | "running" | "paused" | "canceled" | "not_configured";
265
+ status: "unspecified" | "failed" | "completed" | "created" | "armed" | "running" | "paused" | "canceled" | "not_configured";
266
266
  armedTs: number | undefined;
267
267
  armedTsNs: string | undefined;
268
268
  terminalTs: number | undefined;
@@ -281,7 +281,7 @@ declare function createOrderSchema(scales: SdkScales): v.SchemaWithPipe<readonly
281
281
  } | undefined;
282
282
  trailingStop: {
283
283
  state: {
284
- status: "unspecified" | "created" | "failed" | "completed" | "armed" | "running" | "paused" | "canceled" | "not_configured";
284
+ status: "unspecified" | "failed" | "completed" | "created" | "armed" | "running" | "paused" | "canceled" | "not_configured";
285
285
  armedTs: number | undefined;
286
286
  armedTsNs: string | undefined;
287
287
  terminalTs: number | undefined;
@@ -586,7 +586,7 @@ declare function createOrderDetailsSchema(scales: SdkScales): v.ObjectSchema<{
586
586
  attachedRisk: {
587
587
  takeProfit: {
588
588
  state: {
589
- status: "unspecified" | "created" | "failed" | "completed" | "armed" | "running" | "paused" | "canceled" | "not_configured";
589
+ status: "unspecified" | "failed" | "completed" | "created" | "armed" | "running" | "paused" | "canceled" | "not_configured";
590
590
  armedTs: number | undefined;
591
591
  armedTsNs: string | undefined;
592
592
  terminalTs: number | undefined;
@@ -605,7 +605,7 @@ declare function createOrderDetailsSchema(scales: SdkScales): v.ObjectSchema<{
605
605
  } | undefined;
606
606
  stopLoss: {
607
607
  state: {
608
- status: "unspecified" | "created" | "failed" | "completed" | "armed" | "running" | "paused" | "canceled" | "not_configured";
608
+ status: "unspecified" | "failed" | "completed" | "created" | "armed" | "running" | "paused" | "canceled" | "not_configured";
609
609
  armedTs: number | undefined;
610
610
  armedTsNs: string | undefined;
611
611
  terminalTs: number | undefined;
@@ -624,7 +624,7 @@ declare function createOrderDetailsSchema(scales: SdkScales): v.ObjectSchema<{
624
624
  } | undefined;
625
625
  trailingStop: {
626
626
  state: {
627
- status: "unspecified" | "created" | "failed" | "completed" | "armed" | "running" | "paused" | "canceled" | "not_configured";
627
+ status: "unspecified" | "failed" | "completed" | "created" | "armed" | "running" | "paused" | "canceled" | "not_configured";
628
628
  armedTs: number | undefined;
629
629
  armedTsNs: string | undefined;
630
630
  terminalTs: number | undefined;
@@ -212,7 +212,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
212
212
  readonly granteeAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
213
213
  readonly inviterAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
214
214
  readonly role: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountRole$1, undefined>, v.TransformAction<SubaccountRole$1, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
215
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountInviteStatus$1, undefined>, v.TransformAction<SubaccountInviteStatus$1, "unspecified" | "pending" | "accepted" | "declined" | "cancelled">]>;
215
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof SubaccountInviteStatus$1, undefined>, v.TransformAction<SubaccountInviteStatus$1, "unspecified" | "pending" | "cancelled" | "accepted" | "declined">]>;
216
216
  readonly createdAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
217
217
  readonly seconds: v.BigintSchema<undefined>;
218
218
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -239,7 +239,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
239
239
  granteeAccountId: string;
240
240
  inviterAccountId: string;
241
241
  role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
242
- status: "unspecified" | "pending" | "accepted" | "declined" | "cancelled";
242
+ status: "unspecified" | "pending" | "cancelled" | "accepted" | "declined";
243
243
  createdAt?: number | undefined;
244
244
  respondedAt?: number | undefined;
245
245
  granteeUsername: string;
@@ -257,7 +257,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
257
257
  granteeAccountId: string;
258
258
  inviterAccountId: string;
259
259
  role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
260
- status: "unspecified" | "pending" | "accepted" | "declined" | "cancelled";
260
+ status: "unspecified" | "pending" | "cancelled" | "accepted" | "declined";
261
261
  createdAt?: number | undefined;
262
262
  respondedAt?: number | undefined;
263
263
  granteeUsername: string;
@@ -279,8 +279,8 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
279
279
  seconds: bigint;
280
280
  nanos: number;
281
281
  } | undefined, number | undefined>]>;
282
- readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "member" | "policy" | "invite" | "security">]>;
283
- readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "created" | "updated" | "deleted" | "removed" | "role_set" | "received" | "replied" | "failed" | "revoked" | "blocked" | "hold_placed" | "hold_released">]>;
282
+ readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "policy" | "member" | "invite" | "security">]>;
283
+ readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "failed" | "revoked" | "created" | "updated" | "deleted" | "removed" | "role_set" | "received" | "replied" | "blocked" | "hold_placed" | "hold_released">]>;
284
284
  readonly source: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventSource, undefined>, v.TransformAction<ActivityEventSource, "unspecified" | "web" | "mobile" | "api">]>;
285
285
  readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
286
286
  readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -4,8 +4,7 @@ import { SubaccountResolver } from "../subaccount-resolver.js";
4
4
  import { PolyesterRealtime } from "../../realtime/types.js";
5
5
  import { BaseSubscribeInput } from "../../shared/types.js";
6
6
  import { SdkScales } from "../../shared/decimal-surface.js";
7
- import { GetUserTradesInputSchema, Trade } from "./trades.schemas.js";
8
- import * as v from "valibot";
7
+ import { GetUserTradesInput, Trade } from "./trades.schemas.js";
9
8
  //#region src/services/trades/trades.d.ts
10
9
  interface SubscribeTradesInput extends BaseSubscribeInput<Trade> {
11
10
  accountId: string;
@@ -17,9 +16,9 @@ declare class TradesService {
17
16
  #private;
18
17
  constructor(transports: AuthApiTransports, realtime: PolyesterRealtime, resolver: SubaccountResolver | undefined, scales: SdkScales);
19
18
  /**
20
- * Returns user trades for the resolved root account or subaccount, supporting symbol, side, time range, limit, page token, and after-match-ID replay cursor filters. Results include the next page token from GetUserTrades.
19
+ * Returns user trades for the resolved root account or subaccount, supporting symbol, side, time range, limit, page token, and after-match-ID replay cursor filters. The `afterMatchId` cursor requires `symbolId`, enforced at the type and validation level. Results include the next page token from GetUserTrades.
21
20
  */
22
- list(input?: v.InferInput<typeof GetUserTradesInputSchema>, options?: PolyesterRequestOptions): Promise<{
21
+ list(input?: GetUserTradesInput, options?: PolyesterRequestOptions): Promise<{
23
22
  trades: Trade[];
24
23
  nextPageToken: string;
25
24
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"trades.d.ts","names":[],"sources":["../../../src/services/trades/trades.ts"],"mappings":";;;;;;;;;UAiBU,6BAA6B,mBAAmB;EACtD;;;;;cAMS;;EAQL,YAAA,YAAY,mBACZ,UAAU,mBACV,UAAU,gCACV,QAAQ;;;;EAYN,KACF,QAAO,EAAE,kBAAkB,2BAC3B,UAAU,0BACX;IAAU,QAAQ;IAAS;;;;;EAiB9B,UAAU,OAAO"}
1
+ {"version":3,"file":"trades.d.ts","names":[],"sources":["../../../src/services/trades/trades.ts"],"mappings":";;;;;;;;UAsBU,6BAA6B,mBAAmB;EACtD;;;;;cAMS;;EAQL,YAAA,YAAY,mBACZ,UAAU,mBACV,UAAU,gCACV,QAAQ;;;;EAYN,KACF,QAAO,oBACP,UAAU,0BACX;IAAU,QAAQ;IAAS;;;;;EAiB9B,UAAU,OAAO"}
@@ -25,7 +25,7 @@ var TradesService = class {
25
25
  this.#userTradeSchema = createUserTradeSchema(scales);
26
26
  }
27
27
  /**
28
- * Returns user trades for the resolved root account or subaccount, supporting symbol, side, time range, limit, page token, and after-match-ID replay cursor filters. Results include the next page token from GetUserTrades.
28
+ * Returns user trades for the resolved root account or subaccount, supporting symbol, side, time range, limit, page token, and after-match-ID replay cursor filters. The `afterMatchId` cursor requires `symbolId`, enforced at the type and validation level. Results include the next page token from GetUserTrades.
29
29
  */
30
30
  async list(input = {}, options) {
31
31
  await this.#scales.ready();
@@ -1 +1 @@
1
- {"version":3,"file":"trades.js","names":["#client","Proto.OrdersReadService","#realtime","#resolver","#scales","#userTradeSchema","Proto.UserTradeSchema"],"sources":["../../../src/services/trades/trades.ts"],"sourcesContent":["import * as Proto from \"../../gen/orders/v1/orders_read_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport { connectReadyGatedProtoChannel } from \"../../realtime/ready-gated-subscription.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { GetUserTradesInputSchema, createUserTradeSchema, type Trade } from \"./trades.schemas.js\";\n\ninterface SubscribeTradesInput extends BaseSubscribeInput<Trade> {\n accountId: string;\n}\n\n/**\n * Reads and streams authenticated user trade fills.\n */\nexport class TradesService {\n #client: Client<typeof Proto.OrdersReadService>;\n #realtime: PolyesterRealtime;\n #resolver?: SubaccountResolver;\n #scales: SdkScales;\n #userTradeSchema: ReturnType<typeof createUserTradeSchema>;\n\n constructor(\n transports: AuthApiTransports,\n realtime: PolyesterRealtime,\n resolver: SubaccountResolver | undefined,\n scales: SdkScales,\n ) {\n this.#client = createClient(Proto.OrdersReadService, transports.authApi);\n this.#realtime = realtime;\n this.#resolver = resolver;\n this.#scales = scales;\n this.#userTradeSchema = createUserTradeSchema(scales);\n }\n\n /**\n * Returns user trades for the resolved root account or subaccount, supporting symbol, side, time range, limit, page token, and after-match-ID replay cursor filters. Results include the next page token from GetUserTrades.\n */\n async list(\n input: v.InferInput<typeof GetUserTradesInputSchema> = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ trades: Trade[]; nextPageToken: string }> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(GetUserTradesInputSchema, resolved);\n const res = await this.#client.getUserTrades(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n return {\n trades: parse(v.array(this.#userTradeSchema), res.trades),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Subscribes to private user trade updates on private:spot:trades:{accountId}:proto and emits parsed fills.\n */\n subscribe(input: SubscribeTradesInput) {\n const channel = `private:spot:trades:${input.accountId}:proto`;\n return connectReadyGatedProtoChannel(this.#realtime, {\n channel,\n schema: Proto.UserTradeSchema,\n ready: () => this.#scales.ready(),\n onPublication: (data) => {\n const trade = parse(this.#userTradeSchema, data);\n input.onEvent(trade);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAwBA,IAAa,gBAAb,MAA2B;CACvB;CACA;CACA;CACA;CACA;CAEA,YACI,YACA,UACA,UACA,QACF;EACE,KAAKA,UAAU,aAAaC,mBAAyB,WAAW,OAAO;EACvE,KAAKC,YAAY;EACjB,KAAKC,YAAY;EACjB,KAAKC,UAAU;EACf,KAAKC,mBAAmB,sBAAsB,MAAM;CACxD;;;;CAKA,MAAM,KACF,QAAuD,CAAC,GACxD,SACmD;EACnD,MAAM,KAAKD,QAAQ,MAAM;EACzB,MAAM,WAAW,0BAA0B,OAAO,KAAKD,SAAS;EAChE,MAAM,iBAAiB,MAAM,0BAA0B,QAAQ;EAC/D,MAAM,MAAM,MAAM,KAAKH,QAAQ,cAC3B,gBAAgB,cAAc,GAC9B,qBAAqB,OAAO,CAChC;EACA,OAAO;GACH,QAAQ,MAAM,EAAE,MAAM,KAAKK,gBAAgB,GAAG,IAAI,MAAM;GACxD,eAAe,IAAI;EACvB;CACJ;;;;CAKA,UAAU,OAA6B;EACnC,MAAM,UAAU,uBAAuB,MAAM,UAAU;EACvD,OAAO,8BAA8B,KAAKH,WAAW;GACjD;GACA,QAAQI;GACR,aAAa,KAAKF,QAAQ,MAAM;GAChC,gBAAgB,SAAS;IACrB,MAAM,QAAQ,MAAM,KAAKC,kBAAkB,IAAI;IAC/C,MAAM,QAAQ,KAAK;GACvB;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
1
+ {"version":3,"file":"trades.js","names":["#client","Proto.OrdersReadService","#realtime","#resolver","#scales","#userTradeSchema","Proto.UserTradeSchema"],"sources":["../../../src/services/trades/trades.ts"],"sourcesContent":["import * as Proto from \"../../gen/orders/v1/orders_read_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport { connectReadyGatedProtoChannel } from \"../../realtime/ready-gated-subscription.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport {\n GetUserTradesInputSchema,\n createUserTradeSchema,\n type GetUserTradesInput,\n type Trade,\n} from \"./trades.schemas.js\";\n\ninterface SubscribeTradesInput extends BaseSubscribeInput<Trade> {\n accountId: string;\n}\n\n/**\n * Reads and streams authenticated user trade fills.\n */\nexport class TradesService {\n #client: Client<typeof Proto.OrdersReadService>;\n #realtime: PolyesterRealtime;\n #resolver?: SubaccountResolver;\n #scales: SdkScales;\n #userTradeSchema: ReturnType<typeof createUserTradeSchema>;\n\n constructor(\n transports: AuthApiTransports,\n realtime: PolyesterRealtime,\n resolver: SubaccountResolver | undefined,\n scales: SdkScales,\n ) {\n this.#client = createClient(Proto.OrdersReadService, transports.authApi);\n this.#realtime = realtime;\n this.#resolver = resolver;\n this.#scales = scales;\n this.#userTradeSchema = createUserTradeSchema(scales);\n }\n\n /**\n * Returns user trades for the resolved root account or subaccount, supporting symbol, side, time range, limit, page token, and after-match-ID replay cursor filters. The `afterMatchId` cursor requires `symbolId`, enforced at the type and validation level. Results include the next page token from GetUserTrades.\n */\n async list(\n input: GetUserTradesInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ trades: Trade[]; nextPageToken: string }> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(GetUserTradesInputSchema, resolved);\n const res = await this.#client.getUserTrades(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n return {\n trades: parse(v.array(this.#userTradeSchema), res.trades),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Subscribes to private user trade updates on private:spot:trades:{accountId}:proto and emits parsed fills.\n */\n subscribe(input: SubscribeTradesInput) {\n const channel = `private:spot:trades:${input.accountId}:proto`;\n return connectReadyGatedProtoChannel(this.#realtime, {\n channel,\n schema: Proto.UserTradeSchema,\n ready: () => this.#scales.ready(),\n onPublication: (data) => {\n const trade = parse(this.#userTradeSchema, data);\n input.onEvent(trade);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA6BA,IAAa,gBAAb,MAA2B;CACvB;CACA;CACA;CACA;CACA;CAEA,YACI,YACA,UACA,UACA,QACF;EACE,KAAKA,UAAU,aAAaC,mBAAyB,WAAW,OAAO;EACvE,KAAKC,YAAY;EACjB,KAAKC,YAAY;EACjB,KAAKC,UAAU;EACf,KAAKC,mBAAmB,sBAAsB,MAAM;CACxD;;;;CAKA,MAAM,KACF,QAA4B,CAAC,GAC7B,SACmD;EACnD,MAAM,KAAKD,QAAQ,MAAM;EACzB,MAAM,WAAW,0BAA0B,OAAO,KAAKD,SAAS;EAChE,MAAM,iBAAiB,MAAM,0BAA0B,QAAQ;EAC/D,MAAM,MAAM,MAAM,KAAKH,QAAQ,cAC3B,gBAAgB,cAAc,GAC9B,qBAAqB,OAAO,CAChC;EACA,OAAO;GACH,QAAQ,MAAM,EAAE,MAAM,KAAKK,gBAAgB,GAAG,IAAI,MAAM;GACxD,eAAe,IAAI;EACvB;CACJ;;;;CAKA,UAAU,OAA6B;EACnC,MAAM,UAAU,uBAAuB,MAAM,UAAU;EACvD,OAAO,8BAA8B,KAAKH,WAAW;GACjD;GACA,QAAQI;GACR,aAAa,KAAKF,QAAQ,MAAM;GAChC,gBAAgB,SAAS;IACrB,MAAM,QAAQ,MAAM,KAAKC,kBAAkB,IAAI;IAC/C,MAAM,QAAQ,KAAK;GACvB;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}