@polyester/sdk 0.36.0-devnet-20261120040128 → 0.36.0-devnet-20261121035512
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.
- package/CHANGELOG.md +3 -1
- package/dist/services/account-activity/account-activity.schemas.d.ts +4 -4
- package/dist/services/address-book/address-book.schemas.d.ts +2 -2
- package/dist/services/api-keys/api-keys.schemas.d.ts +6 -6
- package/dist/services/assistant/assistant-events.schemas.d.ts +35 -35
- package/dist/services/assistant/assistant.schemas.d.ts +1 -1
- package/dist/services/balances/balances.schemas.d.ts +3 -3
- package/dist/services/candles/candles.schemas.d.ts +10 -10
- package/dist/services/changelog/changelog.schemas.d.ts +38 -38
- package/dist/services/checkpoints/checkpoints.schemas.d.ts +1 -1
- package/dist/services/claims/claims.schemas.d.ts +2 -2
- package/dist/services/dust-conversion/dust-conversion.schemas.d.ts +8 -8
- package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +5 -5
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +94 -94
- package/dist/services/market-data/market-data.d.ts +20 -0
- package/dist/services/market-data/market-data.d.ts.map +1 -1
- package/dist/services/market-data/market-data.js +94 -2
- package/dist/services/market-data/market-data.js.map +1 -1
- package/dist/services/notifications/notifications.schemas.d.ts +5 -25
- package/dist/services/notifications/notifications.schemas.d.ts.map +1 -1
- package/dist/services/orders/order-errors.schemas.d.ts +6 -6
- package/dist/services/orders/orders-batch.schemas.d.ts +72 -72
- package/dist/services/orders/orders-input.schemas.d.ts +11 -11
- package/dist/services/orders/orders-output.schemas.d.ts +16 -16
- package/dist/services/price-alerts/price-alerts.schemas.d.ts +10 -10
- package/dist/services/rewards/rewards.schemas.d.ts +4 -4
- package/dist/services/statement-exports/statement-exports.schemas.d.ts +6 -6
- package/dist/services/strategies/strategies.schemas.d.ts +5 -5
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +17 -17
- package/dist/services/swap/swap.schemas.d.ts +1 -1
- package/dist/services/system/system.schemas.d.ts +6 -6
- package/dist/services/trades/trades.schemas.d.ts +1 -1
- package/dist/services/transfers/transfers.schemas.d.ts +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
- package/dist/services/triggers/triggers-output.schemas.d.ts +49 -49
- package/package.json +1 -1
|
@@ -9,6 +9,9 @@ import { AssetInfo, GetMarketTradesInput, GetPriceBandInput, ListAssetInfoInput,
|
|
|
9
9
|
interface SubscribeTradesInput extends BaseSubscribeInput<MarketTrade> {
|
|
10
10
|
symbolId: number;
|
|
11
11
|
}
|
|
12
|
+
interface SubscribePriceBandInput extends BaseSubscribeInput<LivePriceBand> {
|
|
13
|
+
symbolId: number;
|
|
14
|
+
}
|
|
12
15
|
/**
|
|
13
16
|
* Exposes public spot trades, spot configuration, and live trade streams.
|
|
14
17
|
*/
|
|
@@ -52,6 +55,23 @@ declare class MarketDataService {
|
|
|
52
55
|
* throws `ResourceNotFoundError`.
|
|
53
56
|
*/
|
|
54
57
|
getPriceBand(input: GetPriceBandInput, options?: PolyesterRequestOptions): Promise<LivePriceBand>;
|
|
58
|
+
/**
|
|
59
|
+
* Streams one pair's live price band from public:spot:market:price_band:{symbolId}:proto,
|
|
60
|
+
* emitting the same `LivePriceBand` as `getPriceBand`. Each connection is seeded with
|
|
61
|
+
* `getPriceBand`; the stream sends a changed band at once and re-sends a current one about
|
|
62
|
+
* every 2 seconds.
|
|
63
|
+
*
|
|
64
|
+
* Only a newer band is emitted (greater `epoch`, then `updateId`, then `asOfTsNs`); repeated,
|
|
65
|
+
* late and replayed messages, and a seed the stream already passed, are dropped.
|
|
66
|
+
*
|
|
67
|
+
* Unknown bands arrive as `state: "unknown"` with null prices, never as `onError`: when the
|
|
68
|
+
* seed is refused `PRICE_BAND_STALE` / `PRICE_BAND_UNKNOWN`, when the stream says so, and
|
|
69
|
+
* when `validUntilMs` passes (by the local clock) with no newer message. An emitted band
|
|
70
|
+
* other than `unknown` is current until the next emission, so callers need no
|
|
71
|
+
* `validUntilMs` timer of their own. A seed that fails otherwise (network, unknown
|
|
72
|
+
* `symbolId`) goes to `onError` as `type: "snapshot"`, and the stream still delivers.
|
|
73
|
+
*/
|
|
74
|
+
subscribePriceBand(input: SubscribePriceBandInput): () => void;
|
|
55
75
|
/**
|
|
56
76
|
* Subscribes to public trade prints on public:spot:market:trades:{symbolId}:proto for the requested symbol and emits parsed market trades.
|
|
57
77
|
* Each publication batches trades, emitted one at a time in execution order; a trade
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"market-data.d.ts","names":[],"sources":["../../../src/services/market-data/market-data.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"market-data.d.ts","names":[],"sources":["../../../src/services/market-data/market-data.ts"],"mappings":";;;;;;;;UA0CU,6BAA6B,mBAAmB;EACtD;;UAGM,gCAAgC,mBAAmB;EACzD;;;;;cAuBS;;EAKG,YAAA,YAAY,qBAAqB,UAAU,mBAAmB,QAAQ;;;;;;;;;;EAe5E,WACF,OAAO,sBACP,UAAU,0BACX;IAAU,QAAQ;IAAe;IAAuB,WAAW;;;;;;;;;EAsBhE,cAAc,UAAU,0BAA0B,QAAQ;;;;;;;EAW1D,cACF,QAAO,oBACP,UAAU,0BACX,QAAQ;;;;;;;;EAaL,aACF,OAAO,mBACP,UAAU,0BACX,QAAQ;;;;;;;;;;;;;;;;;EAuBX,mBAAmB,OAAO;;;;;;EA4E1B,gBAAgB,OAAO"}
|
|
@@ -1,14 +1,33 @@
|
|
|
1
|
-
import { MarketDataService as MarketDataService$1, MarketTradeBatchSchema } from "../../gen/marketdata/v1/marketdata_pb.js";
|
|
1
|
+
import { GetPriceBandResponseSchema, LivePriceBandSchema, MarketDataService as MarketDataService$1, MarketTradeBatchSchema } from "../../gen/marketdata/v1/marketdata_pb.js";
|
|
2
|
+
import { ServiceUnavailableError } from "../../shared/errors.js";
|
|
2
3
|
import { parse } from "../../shared/validation.js";
|
|
3
4
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
4
|
-
import { deliverBatch } from "../../shared/subscription-errors.js";
|
|
5
|
+
import { deliverBatch, publicationHandlerErrorContext } from "../../shared/subscription-errors.js";
|
|
5
6
|
import { SymbolIdInputSchema } from "../shared.js";
|
|
6
7
|
import { connectReadyGatedProtoChannel } from "../../realtime/ready-gated-subscription.js";
|
|
7
8
|
import { isDev } from "../../utils/is-dev.js";
|
|
9
|
+
import { snapshotThenStream } from "../../realtime/snapshot-then-stream.js";
|
|
8
10
|
import { AssetInfoSchema, GetMarketTradesInputSchema, GetPriceBandInputSchema, ListAssetInfoInputSchema, SpotConfigSchema, TradeBackfillSchema, formatLivePriceBand, formatMarketTrade } from "./market-data.schemas.js";
|
|
11
|
+
import { create } from "@bufbuild/protobuf";
|
|
9
12
|
import { createClient } from "@connectrpc/connect";
|
|
10
13
|
import * as v from "valibot";
|
|
11
14
|
//#region src/services/market-data/market-data.ts
|
|
15
|
+
/** Newer by `epoch`, then `updateId`, then `asOfTsNs`; at an equal one, `unknown` replaces a band. */
|
|
16
|
+
function isNewerBand(band, than) {
|
|
17
|
+
for (const key of [
|
|
18
|
+
"epoch",
|
|
19
|
+
"updateId",
|
|
20
|
+
"asOfTsNs"
|
|
21
|
+
]) {
|
|
22
|
+
const d = BigInt(band[key]) - BigInt(than[key]);
|
|
23
|
+
if (d !== 0n) return d > 0n;
|
|
24
|
+
}
|
|
25
|
+
return band.state === "unknown" && than.state !== "unknown";
|
|
26
|
+
}
|
|
27
|
+
/** True for `getPriceBand`'s refusal of a band not confirmed in the last 5 seconds. */
|
|
28
|
+
function isPriceBandUnknownError(error) {
|
|
29
|
+
return error instanceof ServiceUnavailableError && /^PRICE_BAND_(STALE|UNKNOWN)$/.test(error.message);
|
|
30
|
+
}
|
|
12
31
|
/**
|
|
13
32
|
* Exposes public spot trades, spot configuration, and live trade streams.
|
|
14
33
|
*/
|
|
@@ -81,6 +100,79 @@ var MarketDataService = class {
|
|
|
81
100
|
return formatLivePriceBand(this.#scales, res.band);
|
|
82
101
|
}
|
|
83
102
|
/**
|
|
103
|
+
* Streams one pair's live price band from public:spot:market:price_band:{symbolId}:proto,
|
|
104
|
+
* emitting the same `LivePriceBand` as `getPriceBand`. Each connection is seeded with
|
|
105
|
+
* `getPriceBand`; the stream sends a changed band at once and re-sends a current one about
|
|
106
|
+
* every 2 seconds.
|
|
107
|
+
*
|
|
108
|
+
* Only a newer band is emitted (greater `epoch`, then `updateId`, then `asOfTsNs`); repeated,
|
|
109
|
+
* late and replayed messages, and a seed the stream already passed, are dropped.
|
|
110
|
+
*
|
|
111
|
+
* Unknown bands arrive as `state: "unknown"` with null prices, never as `onError`: when the
|
|
112
|
+
* seed is refused `PRICE_BAND_STALE` / `PRICE_BAND_UNKNOWN`, when the stream says so, and
|
|
113
|
+
* when `validUntilMs` passes (by the local clock) with no newer message. An emitted band
|
|
114
|
+
* other than `unknown` is current until the next emission, so callers need no
|
|
115
|
+
* `validUntilMs` timer of their own. A seed that fails otherwise (network, unknown
|
|
116
|
+
* `symbolId`) goes to `onError` as `type: "snapshot"`, and the stream still delivers.
|
|
117
|
+
*/
|
|
118
|
+
subscribePriceBand(input) {
|
|
119
|
+
const symbolId = parse(SymbolIdInputSchema, input.symbolId);
|
|
120
|
+
const channel = `public:spot:market:price_band:${symbolId}:proto`;
|
|
121
|
+
const scales = this.#scales;
|
|
122
|
+
let current;
|
|
123
|
+
let lapseTimer;
|
|
124
|
+
const unknownBand = (from) => {
|
|
125
|
+
const asOfTsNs = BigInt(from?.asOfTsNs ?? 0);
|
|
126
|
+
return formatLivePriceBand(scales, create(LivePriceBandSchema, {
|
|
127
|
+
symbolId,
|
|
128
|
+
state: 4,
|
|
129
|
+
epoch: BigInt(from?.epoch ?? 0),
|
|
130
|
+
updateId: BigInt(from?.updateId ?? 0),
|
|
131
|
+
asOfTsNs,
|
|
132
|
+
updatedTsNs: asOfTsNs,
|
|
133
|
+
validUntilTsNs: asOfTsNs
|
|
134
|
+
}));
|
|
135
|
+
};
|
|
136
|
+
const apply = (...bands) => {
|
|
137
|
+
const band = bands.reduce((a, b) => isNewerBand(b, a) ? b : a);
|
|
138
|
+
if (current && !isNewerBand(band, current)) return;
|
|
139
|
+
clearTimeout(lapseTimer);
|
|
140
|
+
current = band.state !== "unknown" && band.validUntilMs <= Date.now() ? unknownBand(band) : band;
|
|
141
|
+
if (current.state !== "unknown") {
|
|
142
|
+
const live = current;
|
|
143
|
+
lapseTimer = setTimeout(() => {
|
|
144
|
+
try {
|
|
145
|
+
apply(unknownBand(live));
|
|
146
|
+
} catch (error) {
|
|
147
|
+
input.onError?.(publicationHandlerErrorContext(channel, error));
|
|
148
|
+
}
|
|
149
|
+
}, live.validUntilMs - Date.now());
|
|
150
|
+
}
|
|
151
|
+
input.onEvent(current);
|
|
152
|
+
};
|
|
153
|
+
const stream = snapshotThenStream({
|
|
154
|
+
realtime: this.#realtime,
|
|
155
|
+
channel,
|
|
156
|
+
schema: GetPriceBandResponseSchema,
|
|
157
|
+
snapshotErrorLog: "Failed to fetch price band",
|
|
158
|
+
snapshotFailureMode: "live",
|
|
159
|
+
fetchSnapshot: () => this.getPriceBand({ symbolId }).catch((error) => {
|
|
160
|
+
if (isPriceBandUnknownError(error)) return unknownBand();
|
|
161
|
+
throw error;
|
|
162
|
+
}),
|
|
163
|
+
readPublication: (res) => res.band ? [res.band] : [],
|
|
164
|
+
applySnapshot: (seed, buffered) => apply(seed, ...buffered.map((band) => formatLivePriceBand(scales, band))),
|
|
165
|
+
applyLivePublications: (bands) => apply(...bands.map((band) => formatLivePriceBand(scales, band))),
|
|
166
|
+
onOpen: input.onOpen,
|
|
167
|
+
onClose: input.onClose,
|
|
168
|
+
onError: input.onError
|
|
169
|
+
});
|
|
170
|
+
return () => {
|
|
171
|
+
clearTimeout(lapseTimer);
|
|
172
|
+
stream.unsubscribe();
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
84
176
|
* Subscribes to public trade prints on public:spot:market:trades:{symbolId}:proto for the requested symbol and emits parsed market trades.
|
|
85
177
|
* Each publication batches trades, emitted one at a time in execution order; a trade
|
|
86
178
|
* whose `matchId` was already emitted replaces the earlier copy.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"market-data.js","names":["#client","Proto.MarketDataService","#realtime","#scales","Proto.MarketTradeBatchSchema"],"sources":["../../../src/services/market-data/market-data.ts"],"sourcesContent":["import * as Proto from \"../../gen/marketdata/v1/marketdata_pb.js\";\nimport { SymbolIdInputSchema } from \"../shared.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport {\n deliverBatch,\n type SdkSubscriptionErrorContext,\n} from \"../../shared/subscription-errors.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport { connectReadyGatedProtoChannel } from \"../../realtime/ready-gated-subscription.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 * as v from \"valibot\";\nimport {\n AssetInfoSchema,\n GetMarketTradesInputSchema,\n GetPriceBandInputSchema,\n formatLivePriceBand,\n type GetPriceBandInput,\n type LivePriceBand,\n ListAssetInfoInputSchema,\n type AssetInfo,\n type ListAssetInfoInput,\n formatMarketTrade,\n type GetMarketTradesInput,\n type SpotConfig,\n SpotConfigSchema,\n type MarketTrade,\n TradeBackfillSchema,\n type TradeBackfill,\n} from \"./market-data.schemas.js\";\nimport { isDev } from \"../../utils/is-dev.js\";\n\ninterface SubscribeTradesInput extends BaseSubscribeInput<MarketTrade> {\n symbolId: number;\n}\n\n/**\n * Exposes public spot trades, spot configuration, and live trade streams.\n */\nexport class MarketDataService {\n #client: Client<typeof Proto.MarketDataService>;\n #realtime: PolyesterRealtime;\n #scales: SdkScales;\n\n constructor(transports: PublicApiTransports, realtime: PolyesterRealtime, scales: SdkScales) {\n this.#client = createClient(Proto.MarketDataService, transports.publicApi);\n this.#realtime = realtime;\n this.#scales = scales;\n }\n\n /**\n * Returns recent public trades for one spot market, ordered newest-first by execution timestamp with match id as a tie-breaker. Supports limit, time bounds, side filtering, and match-id pagination.\n *\n * With `afterTradeId`, it instead walks the symbol's trades by `matchId`, oldest first and\n * gap-free, to backfill trades missed on a live stream, and the result carries `backfill`.\n * Start from `\"0\"`, then pass `backfill.nextAfterTradeId`; when it equals the `afterTradeId`\n * sent, nothing newer is available yet, so retry later with backoff. `afterTradeId` cannot\n * be combined with `side`, `startTsNs`, `endTsNs` or `pageToken`.\n */\n async listTrades(\n input: GetMarketTradesInput,\n options?: PolyesterRequestOptions,\n ): Promise<{ trades: MarketTrade[]; nextPageToken: string; backfill?: TradeBackfill }> {\n await this.#scales.ready();\n const validatedInput = parse(GetMarketTradesInputSchema, input);\n const res = await this.#client.getTrades(validatedInput, toConnectCallOptions(options));\n const trades = res.trades.map((trade) => formatMarketTrade(this.#scales, trade));\n if (validatedInput.afterTradeId === undefined) {\n return { trades, nextPageToken: res.nextPageToken };\n }\n return {\n trades,\n nextPageToken: res.nextPageToken,\n backfill: parse(TradeBackfillSchema, res),\n };\n }\n\n /**\n * Returns the cacheable spot reference-data snapshot, including asset metadata, pair trading constraints, display scales, statuses, and market slippage defaults.\n *\n * This is the catalog's own data source, so it must never wait on catalog\n * readiness (that would deadlock the initial catalog refresh) and carries\n * no decimal conversion.\n */\n async getSpotConfig(options?: PolyesterRequestOptions): Promise<SpotConfig> {\n const res = await this.#client.getSpotConfig({}, toConnectCallOptions(options));\n return parse(SpotConfigSchema, res);\n }\n\n /**\n * Returns team-maintained asset information (description, official links, launch date and\n * price) and market statistics (supplies, market caps and rank) for the requested ledger\n * asset IDs, or for every asset with either, ordered by `assetId`. Assets with neither are\n * omitted. Public and cacheable; no pagination.\n */\n async listAssetInfo(\n input: ListAssetInfoInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<AssetInfo[]> {\n const request = parse(ListAssetInfoInputSchema, input);\n const res = await this.#client.listAssetInfo(request, toConnectCallOptions(options));\n return parse(v.array(AssetInfoSchema), res.assetInfo);\n }\n\n /**\n * Returns a spot pair's live price band: its reference price and the limit prices the pair\n * admits now. Advisory: the pair checks each order against its own band on arrival. Never\n * cached. A band not confirmed in the last 5 seconds throws `ServiceUnavailableError`\n * (`PRICE_BAND_STALE` or `PRICE_BAND_UNKNOWN`); retry after a second. An unknown `symbolId`\n * throws `ResourceNotFoundError`.\n */\n async getPriceBand(\n input: GetPriceBandInput,\n options?: PolyesterRequestOptions,\n ): Promise<LivePriceBand> {\n const request = parse(GetPriceBandInputSchema, input);\n const res = await this.#client.getPriceBand(request, toConnectCallOptions(options));\n if (!res.band) throw new Error(\"GetPriceBand response is missing its band\");\n return formatLivePriceBand(this.#scales, res.band);\n }\n\n /**\n * Subscribes to public trade prints on public:spot:market:trades:{symbolId}:proto for the requested symbol and emits parsed market trades.\n * Each publication batches trades, emitted one at a time in execution order; a trade\n * whose `matchId` was already emitted replaces the earlier copy.\n */\n subscribeTrades(input: SubscribeTradesInput): () => void {\n const symbolId = parse(SymbolIdInputSchema, input.symbolId);\n const channel = `public:spot:market:trades:${symbolId}:proto`;\n const notifyError = (error: SdkSubscriptionErrorContext) => {\n if (isDev()) {\n console.error(\"Market trades subscription error\", error);\n }\n input.onError?.(error);\n };\n return connectReadyGatedProtoChannel(this.#realtime, {\n channel,\n schema: Proto.MarketTradeBatchSchema,\n ready: () => this.#scales.ready(),\n onPublication: (batch) =>\n deliverBatch(\n channel,\n batch.events,\n (trade) => input.onEvent(formatMarketTrade(this.#scales, trade)),\n notifyError,\n ),\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: notifyError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA6CA,IAAa,oBAAb,MAA+B;CAC3B;CACA;CACA;CAEA,YAAY,YAAiC,UAA6B,QAA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,eAAe,UAAuC;GACxD,IAAI,MAAM,GACN,QAAQ,MAAM,oCAAoC,KAAK;GAE3D,MAAM,UAAU,KAAK;EACzB;EACA,OAAO,8BAA8B,KAAKD,WAAW;GACjD;GACA,QAAQE;GACR,aAAa,KAAKD,QAAQ,MAAM;GAChC,gBAAgB,UACZ,aACI,SACA,MAAM,SACL,UAAU,MAAM,QAAQ,kBAAkB,KAAKA,SAAS,KAAK,CAAC,GAC/D,WACJ;GACJ,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS;EACb,CAAC;CACL;AACJ"}
|
|
1
|
+
{"version":3,"file":"market-data.js","names":["#client","Proto.MarketDataService","#realtime","#scales","Proto.LivePriceBandSchema","Proto.GetPriceBandResponseSchema","Proto.MarketTradeBatchSchema"],"sources":["../../../src/services/market-data/market-data.ts"],"sourcesContent":["import * as Proto from \"../../gen/marketdata/v1/marketdata_pb.js\";\nimport { SymbolIdInputSchema } from \"../shared.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport { create } from \"@bufbuild/protobuf\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport {\n deliverBatch,\n publicationHandlerErrorContext,\n type SdkSubscriptionErrorContext,\n} from \"../../shared/subscription-errors.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport { connectReadyGatedProtoChannel } from \"../../realtime/ready-gated-subscription.js\";\nimport { snapshotThenStream } from \"../../realtime/snapshot-then-stream.js\";\nimport { ServiceUnavailableError } from \"../../shared/errors.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 * as v from \"valibot\";\nimport {\n AssetInfoSchema,\n GetMarketTradesInputSchema,\n GetPriceBandInputSchema,\n formatLivePriceBand,\n type GetPriceBandInput,\n type LivePriceBand,\n ListAssetInfoInputSchema,\n type AssetInfo,\n type ListAssetInfoInput,\n formatMarketTrade,\n type GetMarketTradesInput,\n type SpotConfig,\n SpotConfigSchema,\n type MarketTrade,\n TradeBackfillSchema,\n type TradeBackfill,\n} from \"./market-data.schemas.js\";\nimport { isDev } from \"../../utils/is-dev.js\";\n\ninterface SubscribeTradesInput extends BaseSubscribeInput<MarketTrade> {\n symbolId: number;\n}\n\ninterface SubscribePriceBandInput extends BaseSubscribeInput<LivePriceBand> {\n symbolId: number;\n}\n\n/** Newer by `epoch`, then `updateId`, then `asOfTsNs`; at an equal one, `unknown` replaces a band. */\nfunction isNewerBand(band: LivePriceBand, than: LivePriceBand): boolean {\n for (const key of [\"epoch\", \"updateId\", \"asOfTsNs\"] as const) {\n const d = BigInt(band[key]) - BigInt(than[key]);\n if (d !== 0n) return d > 0n;\n }\n return band.state === \"unknown\" && than.state !== \"unknown\";\n}\n\n/** True for `getPriceBand`'s refusal of a band not confirmed in the last 5 seconds. */\nfunction isPriceBandUnknownError(error: unknown): boolean {\n return (\n error instanceof ServiceUnavailableError &&\n /^PRICE_BAND_(STALE|UNKNOWN)$/.test(error.message)\n );\n}\n\n/**\n * Exposes public spot trades, spot configuration, and live trade streams.\n */\nexport class MarketDataService {\n #client: Client<typeof Proto.MarketDataService>;\n #realtime: PolyesterRealtime;\n #scales: SdkScales;\n\n constructor(transports: PublicApiTransports, realtime: PolyesterRealtime, scales: SdkScales) {\n this.#client = createClient(Proto.MarketDataService, transports.publicApi);\n this.#realtime = realtime;\n this.#scales = scales;\n }\n\n /**\n * Returns recent public trades for one spot market, ordered newest-first by execution timestamp with match id as a tie-breaker. Supports limit, time bounds, side filtering, and match-id pagination.\n *\n * With `afterTradeId`, it instead walks the symbol's trades by `matchId`, oldest first and\n * gap-free, to backfill trades missed on a live stream, and the result carries `backfill`.\n * Start from `\"0\"`, then pass `backfill.nextAfterTradeId`; when it equals the `afterTradeId`\n * sent, nothing newer is available yet, so retry later with backoff. `afterTradeId` cannot\n * be combined with `side`, `startTsNs`, `endTsNs` or `pageToken`.\n */\n async listTrades(\n input: GetMarketTradesInput,\n options?: PolyesterRequestOptions,\n ): Promise<{ trades: MarketTrade[]; nextPageToken: string; backfill?: TradeBackfill }> {\n await this.#scales.ready();\n const validatedInput = parse(GetMarketTradesInputSchema, input);\n const res = await this.#client.getTrades(validatedInput, toConnectCallOptions(options));\n const trades = res.trades.map((trade) => formatMarketTrade(this.#scales, trade));\n if (validatedInput.afterTradeId === undefined) {\n return { trades, nextPageToken: res.nextPageToken };\n }\n return {\n trades,\n nextPageToken: res.nextPageToken,\n backfill: parse(TradeBackfillSchema, res),\n };\n }\n\n /**\n * Returns the cacheable spot reference-data snapshot, including asset metadata, pair trading constraints, display scales, statuses, and market slippage defaults.\n *\n * This is the catalog's own data source, so it must never wait on catalog\n * readiness (that would deadlock the initial catalog refresh) and carries\n * no decimal conversion.\n */\n async getSpotConfig(options?: PolyesterRequestOptions): Promise<SpotConfig> {\n const res = await this.#client.getSpotConfig({}, toConnectCallOptions(options));\n return parse(SpotConfigSchema, res);\n }\n\n /**\n * Returns team-maintained asset information (description, official links, launch date and\n * price) and market statistics (supplies, market caps and rank) for the requested ledger\n * asset IDs, or for every asset with either, ordered by `assetId`. Assets with neither are\n * omitted. Public and cacheable; no pagination.\n */\n async listAssetInfo(\n input: ListAssetInfoInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<AssetInfo[]> {\n const request = parse(ListAssetInfoInputSchema, input);\n const res = await this.#client.listAssetInfo(request, toConnectCallOptions(options));\n return parse(v.array(AssetInfoSchema), res.assetInfo);\n }\n\n /**\n * Returns a spot pair's live price band: its reference price and the limit prices the pair\n * admits now. Advisory: the pair checks each order against its own band on arrival. Never\n * cached. A band not confirmed in the last 5 seconds throws `ServiceUnavailableError`\n * (`PRICE_BAND_STALE` or `PRICE_BAND_UNKNOWN`); retry after a second. An unknown `symbolId`\n * throws `ResourceNotFoundError`.\n */\n async getPriceBand(\n input: GetPriceBandInput,\n options?: PolyesterRequestOptions,\n ): Promise<LivePriceBand> {\n const request = parse(GetPriceBandInputSchema, input);\n const res = await this.#client.getPriceBand(request, toConnectCallOptions(options));\n if (!res.band) throw new Error(\"GetPriceBand response is missing its band\");\n return formatLivePriceBand(this.#scales, res.band);\n }\n\n /**\n * Streams one pair's live price band from public:spot:market:price_band:{symbolId}:proto,\n * emitting the same `LivePriceBand` as `getPriceBand`. Each connection is seeded with\n * `getPriceBand`; the stream sends a changed band at once and re-sends a current one about\n * every 2 seconds.\n *\n * Only a newer band is emitted (greater `epoch`, then `updateId`, then `asOfTsNs`); repeated,\n * late and replayed messages, and a seed the stream already passed, are dropped.\n *\n * Unknown bands arrive as `state: \"unknown\"` with null prices, never as `onError`: when the\n * seed is refused `PRICE_BAND_STALE` / `PRICE_BAND_UNKNOWN`, when the stream says so, and\n * when `validUntilMs` passes (by the local clock) with no newer message. An emitted band\n * other than `unknown` is current until the next emission, so callers need no\n * `validUntilMs` timer of their own. A seed that fails otherwise (network, unknown\n * `symbolId`) goes to `onError` as `type: \"snapshot\"`, and the stream still delivers.\n */\n subscribePriceBand(input: SubscribePriceBandInput): () => void {\n const symbolId = parse(SymbolIdInputSchema, input.symbolId);\n const channel = `public:spot:market:price_band:${symbolId}:proto`;\n const scales = this.#scales;\n let current: LivePriceBand | undefined;\n let lapseTimer: ReturnType<typeof setTimeout> | undefined;\n\n // Shaped like the stream's UNKNOWN: the confirmation it replaces, 0 when none.\n const unknownBand = (from?: LivePriceBand): LivePriceBand => {\n const asOfTsNs = BigInt(from?.asOfTsNs ?? 0);\n return formatLivePriceBand(\n scales,\n create(Proto.LivePriceBandSchema, {\n symbolId,\n state: Proto.PriceBandState.UNKNOWN,\n epoch: BigInt(from?.epoch ?? 0),\n updateId: BigInt(from?.updateId ?? 0),\n asOfTsNs,\n updatedTsNs: asOfTsNs,\n validUntilTsNs: asOfTsNs,\n }),\n );\n };\n\n // Emits only the newest of `bands`, and only when it is newer than the current band.\n const apply = (...bands: LivePriceBand[]): void => {\n const band = bands.reduce((a, b) => (isNewerBand(b, a) ? b : a));\n if (current && !isNewerBand(band, current)) return;\n clearTimeout(lapseTimer);\n const lapsed = band.state !== \"unknown\" && band.validUntilMs <= Date.now();\n current = lapsed ? unknownBand(band) : band;\n if (current.state !== \"unknown\") {\n const live = current;\n lapseTimer = setTimeout(() => {\n try {\n apply(unknownBand(live));\n } catch (error) {\n input.onError?.(publicationHandlerErrorContext(channel, error));\n }\n }, live.validUntilMs - Date.now());\n }\n input.onEvent(current);\n };\n\n const stream = snapshotThenStream({\n realtime: this.#realtime,\n channel,\n schema: Proto.GetPriceBandResponseSchema,\n snapshotErrorLog: \"Failed to fetch price band\",\n snapshotFailureMode: \"live\",\n fetchSnapshot: () =>\n this.getPriceBand({ symbolId }).catch((error: unknown) => {\n if (isPriceBandUnknownError(error)) return unknownBand();\n throw error;\n }),\n readPublication: (res) => (res.band ? [res.band] : []),\n applySnapshot: (seed, buffered) =>\n apply(seed, ...buffered.map((band) => formatLivePriceBand(scales, band))),\n applyLivePublications: (bands) =>\n apply(...bands.map((band) => formatLivePriceBand(scales, band))),\n onOpen: input.onOpen,\n onClose: input.onClose,\n onError: input.onError,\n });\n\n return () => {\n clearTimeout(lapseTimer);\n stream.unsubscribe();\n };\n }\n\n /**\n * Subscribes to public trade prints on public:spot:market:trades:{symbolId}:proto for the requested symbol and emits parsed market trades.\n * Each publication batches trades, emitted one at a time in execution order; a trade\n * whose `matchId` was already emitted replaces the earlier copy.\n */\n subscribeTrades(input: SubscribeTradesInput): () => void {\n const symbolId = parse(SymbolIdInputSchema, input.symbolId);\n const channel = `public:spot:market:trades:${symbolId}:proto`;\n const notifyError = (error: SdkSubscriptionErrorContext) => {\n if (isDev()) {\n console.error(\"Market trades subscription error\", error);\n }\n input.onError?.(error);\n };\n return connectReadyGatedProtoChannel(this.#realtime, {\n channel,\n schema: Proto.MarketTradeBatchSchema,\n ready: () => this.#scales.ready(),\n onPublication: (batch) =>\n deliverBatch(\n channel,\n batch.events,\n (trade) => input.onEvent(formatMarketTrade(this.#scales, trade)),\n notifyError,\n ),\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: notifyError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmDA,SAAS,YAAY,MAAqB,MAA8B;CACpE,KAAK,MAAM,OAAO;EAAC;EAAS;EAAY;CAAU,GAAY;EAC1D,MAAM,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,IAAI;EAC9C,IAAI,MAAM,IAAI,OAAO,IAAI;CAC7B;CACA,OAAO,KAAK,UAAU,aAAa,KAAK,UAAU;AACtD;;AAGA,SAAS,wBAAwB,OAAyB;CACtD,OACI,iBAAiB,2BACjB,+BAA+B,KAAK,MAAM,OAAO;AAEzD;;;;AAKA,IAAa,oBAAb,MAA+B;CAC3B;CACA;CACA;CAEA,YAAY,YAAiC,UAA6B,QAAmB;EACzF,KAAKA,UAAU,aAAaC,qBAAyB,WAAW,SAAS;EACzE,KAAKC,YAAY;EACjB,KAAKC,UAAU;CACnB;;;;;;;;;;CAWA,MAAM,WACF,OACA,SACmF;EACnF,MAAM,KAAKA,QAAQ,MAAM;EACzB,MAAM,iBAAiB,MAAM,4BAA4B,KAAK;EAC9D,MAAM,MAAM,MAAM,KAAKH,QAAQ,UAAU,gBAAgB,qBAAqB,OAAO,CAAC;EACtF,MAAM,SAAS,IAAI,OAAO,KAAK,UAAU,kBAAkB,KAAKG,SAAS,KAAK,CAAC;EAC/E,IAAI,eAAe,iBAAiB,KAAA,GAChC,OAAO;GAAE;GAAQ,eAAe,IAAI;EAAc;EAEtD,OAAO;GACH;GACA,eAAe,IAAI;GACnB,UAAU,MAAM,qBAAqB,GAAG;EAC5C;CACJ;;;;;;;;CASA,MAAM,cAAc,SAAwD;EACxE,MAAM,MAAM,MAAM,KAAKH,QAAQ,cAAc,CAAC,GAAG,qBAAqB,OAAO,CAAC;EAC9E,OAAO,MAAM,kBAAkB,GAAG;CACt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AAC;CACL;AACJ"}
|
|
@@ -2,7 +2,7 @@ import { GetNotificationCountsResponse, Notification, NotificationCategory, Read
|
|
|
2
2
|
import * as v from "valibot";
|
|
3
3
|
//#region src/services/notifications/notifications.schemas.d.ts
|
|
4
4
|
declare const ListNotificationsInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
5
|
-
readonly categories: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["alerts", "security"], undefined>, undefined>, v.TransformAction<("
|
|
5
|
+
readonly categories: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["alerts", "security"], undefined>, undefined>, v.TransformAction<("alerts" | "security")[], (NotificationCategory.ALERTS | NotificationCategory.SECURITY)[]>]>, undefined>;
|
|
6
6
|
/** Only read or only unread notifications; omit for both. */
|
|
7
7
|
readonly readState: v.OptionalSchema<v.PicklistSchema<readonly ["unread", "read"], undefined>, undefined>;
|
|
8
8
|
/** Epoch ms, inclusive. */
|
|
@@ -46,7 +46,7 @@ declare const MarkNotificationsInputSchema: v.StrictObjectSchema<{
|
|
|
46
46
|
}, undefined>;
|
|
47
47
|
type MarkNotificationsInput = v.InferInput<typeof MarkNotificationsInputSchema>;
|
|
48
48
|
declare const MarkAllNotificationsReadInputSchema: v.StrictObjectSchema<{
|
|
49
|
-
readonly categories: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["alerts", "security"], undefined>, undefined>, v.TransformAction<("
|
|
49
|
+
readonly categories: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.PicklistSchema<readonly ["alerts", "security"], undefined>, undefined>, v.TransformAction<("alerts" | "security")[], (NotificationCategory.ALERTS | NotificationCategory.SECURITY)[]>]>, undefined>;
|
|
50
50
|
/**
|
|
51
51
|
* Mark only this notification and older ones. Pass the newest one shown, so one that arrives
|
|
52
52
|
* later stays unread; omit to mark every notification that exists when the call runs.
|
|
@@ -57,7 +57,7 @@ type MarkAllNotificationsReadInput = v.InferInput<typeof MarkAllNotificationsRea
|
|
|
57
57
|
declare function formatNotification(notification: Notification): {
|
|
58
58
|
notificationId: string;
|
|
59
59
|
type: "unspecified" | "price_alert" | "telegram_approval" | "broker_allowlist_change" | "telegram_linked" | "admin_key_action";
|
|
60
|
-
category: "unspecified" | "
|
|
60
|
+
category: "unspecified" | "alerts" | "security";
|
|
61
61
|
/** Plain-text title, the same for every notification of a type. */
|
|
62
62
|
title: string;
|
|
63
63
|
/** Plain-text summary; may span several lines. */
|
|
@@ -77,13 +77,10 @@ declare function formatNotification(notification: Notification): {
|
|
|
77
77
|
/** Price that fired the alert, as a decimal string. */
|
|
78
78
|
triggeredPrice: string;
|
|
79
79
|
triggeredAt: number | null;
|
|
80
|
-
/** The approval's ID in `client.assistant`. */
|
|
81
80
|
approvalId?: undefined;
|
|
82
81
|
action?: undefined;
|
|
83
|
-
/** Trading account (subaccount) the action acted on. */
|
|
84
82
|
accountId?: undefined;
|
|
85
83
|
summary?: undefined;
|
|
86
|
-
/** Key parameters in display order, such as market, side and quantity. */
|
|
87
84
|
parameters?: undefined;
|
|
88
85
|
approvedAt?: undefined;
|
|
89
86
|
broker?: undefined;
|
|
@@ -117,7 +114,7 @@ declare function formatNotification(notification: Notification): {
|
|
|
117
114
|
type: "telegram_approval";
|
|
118
115
|
/** The approval's ID in `client.assistant`. */
|
|
119
116
|
approvalId: string;
|
|
120
|
-
action: "unspecified" | "
|
|
117
|
+
action: "unspecified" | "swap" | "place_orders" | "place_order" | "modify_orders" | "cancel_order" | "cancel_all_orders" | "modify_trigger" | "pause_trigger" | "resume_trigger" | "convert_dust";
|
|
121
118
|
/** Trading account (subaccount) the action acted on. */
|
|
122
119
|
accountId: string;
|
|
123
120
|
summary: string;
|
|
@@ -132,7 +129,6 @@ declare function formatNotification(notification: Notification): {
|
|
|
132
129
|
symbolId?: undefined;
|
|
133
130
|
direction?: undefined;
|
|
134
131
|
priceSource?: undefined;
|
|
135
|
-
/** Alert price, as a decimal string. */
|
|
136
132
|
price?: undefined;
|
|
137
133
|
/** Price that fired the alert, as a decimal string. */
|
|
138
134
|
triggeredPrice?: undefined;
|
|
@@ -189,17 +185,13 @@ declare function formatNotification(notification: Notification): {
|
|
|
189
185
|
symbolId?: undefined;
|
|
190
186
|
direction?: undefined;
|
|
191
187
|
priceSource?: undefined;
|
|
192
|
-
/** Alert price, as a decimal string. */
|
|
193
188
|
price?: undefined;
|
|
194
189
|
/** Price that fired the alert, as a decimal string. */
|
|
195
190
|
triggeredPrice?: undefined;
|
|
196
191
|
triggeredAt?: undefined;
|
|
197
|
-
/** The approval's ID in `client.assistant`. */
|
|
198
192
|
approvalId?: undefined;
|
|
199
|
-
/** Trading account (subaccount) the action acted on. */
|
|
200
193
|
accountId?: undefined;
|
|
201
194
|
summary?: undefined;
|
|
202
|
-
/** Key parameters in display order, such as market, side and quantity. */
|
|
203
195
|
parameters?: undefined;
|
|
204
196
|
approvedAt?: undefined;
|
|
205
197
|
linkedAt?: undefined;
|
|
@@ -221,18 +213,14 @@ declare function formatNotification(notification: Notification): {
|
|
|
221
213
|
symbolId?: undefined;
|
|
222
214
|
direction?: undefined;
|
|
223
215
|
priceSource?: undefined;
|
|
224
|
-
/** Alert price, as a decimal string. */
|
|
225
216
|
price?: undefined;
|
|
226
217
|
/** Price that fired the alert, as a decimal string. */
|
|
227
218
|
triggeredPrice?: undefined;
|
|
228
219
|
triggeredAt?: undefined;
|
|
229
|
-
/** The approval's ID in `client.assistant`. */
|
|
230
220
|
approvalId?: undefined;
|
|
231
221
|
action?: undefined;
|
|
232
|
-
/** Trading account (subaccount) the action acted on. */
|
|
233
222
|
accountId?: undefined;
|
|
234
223
|
summary?: undefined;
|
|
235
|
-
/** Key parameters in display order, such as market, side and quantity. */
|
|
236
224
|
parameters?: undefined;
|
|
237
225
|
approvedAt?: undefined;
|
|
238
226
|
broker?: undefined;
|
|
@@ -279,17 +267,13 @@ declare function formatNotification(notification: Notification): {
|
|
|
279
267
|
symbolId?: undefined;
|
|
280
268
|
direction?: undefined;
|
|
281
269
|
priceSource?: undefined;
|
|
282
|
-
/** Alert price, as a decimal string. */
|
|
283
270
|
price?: undefined;
|
|
284
271
|
/** Price that fired the alert, as a decimal string. */
|
|
285
272
|
triggeredPrice?: undefined;
|
|
286
273
|
triggeredAt?: undefined;
|
|
287
|
-
/** The approval's ID in `client.assistant`. */
|
|
288
274
|
approvalId?: undefined;
|
|
289
|
-
/** Trading account (subaccount) the action acted on. */
|
|
290
275
|
accountId?: undefined;
|
|
291
276
|
summary?: undefined;
|
|
292
|
-
/** Key parameters in display order, such as market, side and quantity. */
|
|
293
277
|
parameters?: undefined;
|
|
294
278
|
approvedAt?: undefined;
|
|
295
279
|
broker?: undefined;
|
|
@@ -317,18 +301,14 @@ declare function formatNotification(notification: Notification): {
|
|
|
317
301
|
symbolId?: undefined;
|
|
318
302
|
direction?: undefined;
|
|
319
303
|
priceSource?: undefined;
|
|
320
|
-
/** Alert price, as a decimal string. */
|
|
321
304
|
price?: undefined;
|
|
322
305
|
/** Price that fired the alert, as a decimal string. */
|
|
323
306
|
triggeredPrice?: undefined;
|
|
324
307
|
triggeredAt?: undefined;
|
|
325
|
-
/** The approval's ID in `client.assistant`. */
|
|
326
308
|
approvalId?: undefined;
|
|
327
309
|
action?: undefined;
|
|
328
|
-
/** Trading account (subaccount) the action acted on. */
|
|
329
310
|
accountId?: undefined;
|
|
330
311
|
summary?: undefined;
|
|
331
|
-
/** Key parameters in display order, such as market, side and quantity. */
|
|
332
312
|
parameters?: undefined;
|
|
333
313
|
approvedAt?: undefined;
|
|
334
314
|
broker?: undefined;
|
|
@@ -377,7 +357,7 @@ declare function formatNotificationCounts(counts: GetNotificationCountsResponse)
|
|
|
377
357
|
/** Every type in ascending enum order, including types with no notification. */
|
|
378
358
|
types: {
|
|
379
359
|
type: "unspecified" | "price_alert" | "telegram_approval" | "broker_allowlist_change" | "telegram_linked" | "admin_key_action";
|
|
380
|
-
category: "unspecified" | "
|
|
360
|
+
category: "unspecified" | "alerts" | "security";
|
|
381
361
|
total: number;
|
|
382
362
|
unread: number;
|
|
383
363
|
}[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.schemas.d.ts","names":[],"sources":["../../../src/services/notifications/notifications.schemas.ts"],"mappings":";;;cA4Ca,8BAA4B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2B7B,yBAAyB,EAAE,kBAAkB;cAE5C,4BAA0B,EAAA;;;KAI3B,uBAAuB,EAAE,kBAAkB;cAE1C,8BAA4B,EAAA;;;;KAU7B,yBAAyB,EAAE,kBAAkB;cAE5C,qCAAmC,EAAA;;;;;;;;KASpC,gCAAgC,EAAE,kBACnC;iBAmGK,mBAAmB,cAAc
|
|
1
|
+
{"version":3,"file":"notifications.schemas.d.ts","names":[],"sources":["../../../src/services/notifications/notifications.schemas.ts"],"mappings":";;;cA4Ca,8BAA4B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2B7B,yBAAyB,EAAE,kBAAkB;cAE5C,4BAA0B,EAAA;;;KAI3B,uBAAuB,EAAE,kBAAkB;cAE1C,8BAA4B,EAAA;;;;KAU7B,yBAAyB,EAAE,kBAAkB;cAE5C,qCAAmC,EAAA;;;;;;;;KASpC,gCAAgC,EAAE,kBACnC;iBAmGK,mBAAmB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoBrC,sBAAsB,kBAAkB;KAExC,4BAA4B;;KAG5B;EACR,eAAe;EACf;;iBAGY,yBAAyB,QAAQ;;;;;;;;;;;;KAerC,qBAAqB,kBAAkB"}
|