@agg-build/sdk 4.25.0 → 4.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agg-websocket-BstVWtLA.d.mts +6004 -0
- package/dist/agg-websocket-BstVWtLA.d.mts.map +1 -0
- package/dist/agg-websocket-BstVWtLA.d.ts +6004 -0
- package/dist/agg-websocket-BstVWtLA.d.ts.map +1 -0
- package/dist/agg-websocket-CK2iXfti.mjs +1427 -0
- package/dist/agg-websocket-CK2iXfti.mjs.map +1 -0
- package/dist/agg-websocket-DJbIfxKb.js +1478 -0
- package/dist/browser.d.mts +67 -66
- package/dist/browser.d.mts.map +1 -0
- package/dist/browser.d.ts +67 -66
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +720 -2047
- package/dist/browser.mjs +423 -799
- package/dist/browser.mjs.map +1 -0
- package/dist/candle-builder-BNewIe9K.mjs +148 -0
- package/dist/candle-builder-BNewIe9K.mjs.map +1 -0
- package/dist/candle-builder-BULYdxB4.js +151 -0
- package/dist/index.d.mts +2 -1342
- package/dist/index.d.ts +2 -1342
- package/dist/index.js +2794 -4656
- package/dist/index.mjs +2788 -2486
- package/dist/index.mjs.map +1 -0
- package/dist/market-data.d.mts +6 -6
- package/dist/market-data.d.mts.map +1 -0
- package/dist/market-data.d.ts +6 -6
- package/dist/market-data.d.ts.map +1 -0
- package/dist/market-data.js +314 -1774
- package/dist/market-data.mjs +314 -350
- package/dist/market-data.mjs.map +1 -0
- package/dist/server.d.mts +235 -234
- package/dist/server.d.mts.map +1 -0
- package/dist/server.d.ts +235 -234
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +168 -296
- package/dist/server.mjs +163 -234
- package/dist/server.mjs.map +1 -0
- package/package.json +4 -4
- package/dist/agg-websocket-Bxt9PzTz.d.mts +0 -4479
- package/dist/agg-websocket-Bxt9PzTz.d.ts +0 -4479
- package/dist/chunk-QXBVA5TW.mjs +0 -2073
- package/dist/chunk-VD5UTAVD.mjs +0 -158
- package/dist/chunk-WNQUEZJF.mjs +0 -58
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"market-data.mjs","names":[],"sources":["../src/market-data/engine.ts"],"sourcesContent":["import {\n AggWebSocket,\n type AggWebSocketCallbacks,\n type AggWebSocketOptions,\n} from \"../agg-websocket\";\nimport { CandleBuilder, type Candle, type CandleInterval } from \"../candle-builder\";\nimport type { OrderbookState } from \"../orderbook-utils\";\nimport { loadImmutableHistory } from \"../market-history\";\nimport type { ChartHistoryManifest, ChartCandle, ChartBarsResponse } from \"../types\";\nimport type { WsTrade } from \"../ws-types\";\nimport { decodeChartHistory, readChartHistoryText } from \"./history-decoder\";\n\nexport type MarketSubscription = {\n id: string;\n channel: \"orderbook\" | \"trades\" | \"arb\" | \"arb-feed\";\n};\nexport type CandleTail = Record<CandleInterval, { forming: Candle | null; closed: Candle[] }>;\nexport interface MarketView {\n revision: number;\n integrity: \"ok\" | \"resyncing\";\n outcomeId: string;\n book: OrderbookState | null;\n snapshot: boolean;\n candles: CandleTail;\n trades: WsTrade[];\n receivedAtMs: number;\n}\nexport interface MarketViewBatch {\n generation: number;\n views: MarketView[];\n publishedAtMs: number;\n}\nexport type EngineEvent = { name: keyof AggWebSocketCallbacks; args: unknown[]; revision: number };\nexport interface HistoryRangeRequest {\n key: string;\n generation: number;\n url: string;\n headers?: Record<string, string>;\n}\nconst intervals = [\"1m\", \"5m\", \"1h\", \"1d\"] as const;\n\n/** Framework-independent processing. The native worker and replay tests run this exact engine. */\nexport class MarketDataEngine {\n private socket: AggWebSocket | null = null;\n private generation = 0;\n private receivedAtMs = 0;\n private revision = 0;\n private deliveredClosed = new Map<string, Partial<Record<CandleInterval, number>>>();\n private subscriptions = new Map<string, () => void>();\n private builders = new Map<string, CandleBuilder>();\n private dirty = new Map<string, { snapshot: boolean; receivedAtMs: number; trades: WsTrade[] }>();\n private observer?: (batch: MarketViewBatch) => Promise<void> | void;\n private timer?: ReturnType<typeof setTimeout>;\n private inFlight = false;\n private deliveryToken: object | null = null;\n private cancelDelivery?: () => void;\n private disposed = false;\n private history = new Map<string, { generation: number; controller: AbortController }>();\n private measurements = {\n received: 0,\n published: 0,\n coalesced: 0,\n maxPendingOutcomes: 0,\n maxInFlight: 0,\n };\n\n start(\n options: Omit<AggWebSocketOptions, \"callbacks\">,\n event: (event: EngineEvent) => void,\n ): void {\n this.dispose();\n this.disposed = false;\n this.generation = 0;\n this.revision = 0;\n const callbacks: AggWebSocketCallbacks = {};\n const names: (keyof AggWebSocketCallbacks)[] = [\n \"onConnected\",\n \"onAuthenticated\",\n \"onHeartbeat\",\n \"onSubscribed\",\n \"onUnsubscribed\",\n \"onMarketResolved\",\n \"onError\",\n \"onOrderSubmitted\",\n \"onBalanceUpdate\",\n \"onOrderEvent\",\n \"onRedeemEvent\",\n \"onWithdrawalLifecycle\",\n \"onArbMarket\",\n \"onArbFeed\",\n \"onDiagnostics\",\n \"onConnectionStateChange\",\n ];\n for (const name of names) {\n Object.assign(callbacks, {\n [name]: (...args: unknown[]) => {\n if (name === \"onConnectionStateChange\" && args[0] === false) {\n for (const builder of this.builders.values()) builder.reset();\n this.dirty.clear();\n this.deliveredClosed.clear();\n }\n if (name === \"onMarketResolved\") {\n const id = (args[0] as { outcomeId: string }).outcomeId;\n this.builders.get(id)?.dispose();\n this.builders.delete(id);\n this.dirty.delete(id);\n }\n if (name === \"onDiagnostics\") {\n const diagnostic = args[0] as { type: string; outcomeId?: string };\n if (diagnostic.outcomeId && [\"seq_gap\", \"checksum_mismatch\"].includes(diagnostic.type))\n this.mark(diagnostic.outcomeId, false);\n }\n event({ name, args, revision: this.revision });\n },\n });\n }\n callbacks.onFrameReceived = (receivedAtMs) => {\n this.receivedAtMs = receivedAtMs;\n this.revision++;\n };\n callbacks.onBookTick = (id, tick) => {\n if (tick.midpoint != null) this.builder(id).addMidpoint(tick.midpoint, tick.timestamp);\n this.mark(id, tick.source === \"snapshot\");\n };\n callbacks.onTrade = (trade) => {\n this.builder(trade.outcomeId).addTrade(trade.price, trade.size, trade.timestamp);\n this.mark(trade.outcomeId, false, trade);\n };\n this.socket = new AggWebSocket({ ...options, callbacks, deferBookViews: true });\n }\n\n observeViews(observer: (batch: MarketViewBatch) => Promise<void> | void): void {\n this.observer = observer;\n }\n\n setSubscriptions(subscriptions: MarketSubscription[], generation: number): void {\n if (generation < this.generation) return;\n this.generation = generation;\n const desired = new Map(subscriptions.map((sub) => [`${sub.channel}:${sub.id}`, sub]));\n for (const [key, unsubscribe] of this.subscriptions) {\n if (!desired.has(key)) {\n unsubscribe();\n this.subscriptions.delete(key);\n }\n }\n for (const [key, sub] of desired) {\n if (this.subscriptions.has(key) || !this.socket) continue;\n const unsubscribe =\n sub.channel === \"arb\"\n ? this.socket.subscribeArb(sub.id, () => {})\n : sub.channel === \"arb-feed\"\n ? this.socket.subscribeArbFeed(() => {})\n : this.socket.subscribe(sub.id, sub.channel);\n this.subscriptions.set(key, unsubscribe);\n }\n for (const sub of subscriptions)\n if (sub.channel === \"orderbook\" && this.socket?.getBook(sub.id)) this.mark(sub.id, false);\n const outcomes = new Set(\n subscriptions\n .filter((sub) => sub.channel === \"orderbook\" || sub.channel === \"trades\")\n .map((sub) => sub.id),\n );\n for (const id of this.dirty.keys()) if (!outcomes.has(id)) this.dirty.delete(id);\n for (const id of this.deliveredClosed.keys())\n if (!outcomes.has(id)) this.deliveredClosed.delete(id);\n for (const [id, builder] of this.builders)\n if (!outcomes.has(id)) {\n builder.dispose();\n this.builders.delete(id);\n this.dirty.delete(id);\n this.deliveredClosed.delete(id);\n }\n }\n\n authenticate(token: string): void {\n this.socket?.authenticate(token);\n }\n resnapshot(ids: string[]): void {\n this.socket?.resnapshot(ids);\n }\n connect(): void {\n this.socket?.connect();\n }\n disconnect(): void {\n this.socket?.disconnect();\n }\n resume(): void {\n this.socket?.resnapshot([...this.builders.keys()]);\n }\n getMeasurements() {\n const socket = this.socket?.getDiagnostics() ?? null;\n return {\n ...this.measurements,\n activeSubscriptions: this.subscriptions.size,\n activeOutcomes: new Set([\n ...(socket?.orderbookOutcomeIds ?? []),\n ...(socket?.tradeOutcomeIds ?? []),\n ]).size,\n cachedBooks: socket?.cachedBooks ?? 0,\n builders: this.builders.size,\n historyTasks: this.history.size,\n pendingOutcomes: this.dirty.size,\n inFlightDeliveries: this.inFlight ? 1 : 0,\n retainedCandleOutcomes: this.deliveredClosed.size,\n socket,\n };\n }\n\n decodeHistory(payload: string): ChartBarsResponse {\n return decodeChartHistory(payload);\n }\n\n /** Fetch/decode on the processing side; newer range generations abort obsolete fetches. */\n async loadHistoryRange(request: HistoryRangeRequest): Promise<ChartBarsResponse | null> {\n const previous = this.history.get(request.key);\n if (previous && previous.generation > request.generation) return null;\n previous?.controller.abort();\n const controller = new AbortController();\n const entry = { generation: request.generation, controller };\n this.history.set(request.key, entry);\n const timeout = setTimeout(() => controller.abort(), 10_000);\n try {\n const response = await fetch(request.url, {\n headers: request.headers,\n signal: controller.signal,\n });\n if (!response.ok) throw new Error(`History request failed (${response.status})`);\n const body = decodeChartHistory(await readChartHistoryText(response));\n if (body.data.length > 4096) throw new Error(\"Invalid or unbounded history response\");\n if (this.history.get(request.key) !== entry || this.disposed) return null;\n return { ...body, data: [...body.data].sort((a, b) => a.t - b.t) };\n } finally {\n clearTimeout(timeout);\n if (this.history.get(request.key) === entry) this.history.delete(request.key);\n }\n }\n async loadImmutableRange(\n key: string,\n generation: number,\n manifest: ChartHistoryManifest,\n ): Promise<ChartCandle[]> {\n const previous = this.history.get(key);\n if (previous && previous.generation > generation) throw new Error(\"Obsolete history range\");\n previous?.controller.abort();\n const entry = { generation, controller: new AbortController() };\n this.history.set(key, entry);\n const timer = setTimeout(() => entry.controller.abort(), 10_000);\n try {\n const data = await loadImmutableHistory({ manifest, signal: entry.controller.signal });\n if (this.history.get(key) !== entry || this.disposed)\n throw new Error(\"Obsolete history range\");\n return data;\n } finally {\n clearTimeout(timer);\n if (this.history.get(key) === entry) this.history.delete(key);\n }\n }\n cancelHistoryRange(key: string, generation?: number): void {\n const entry = this.history.get(key);\n if (!entry || (generation !== undefined && entry.generation !== generation)) return;\n entry.controller.abort();\n this.history.delete(key);\n }\n\n dispose(): void {\n this.disposed = true;\n this.cancelDelivery?.();\n this.cancelDelivery = undefined;\n this.deliveryToken = null;\n this.inFlight = false;\n this.observer = undefined;\n this.socket?.destroy();\n this.socket = null;\n if (this.timer) clearTimeout(this.timer);\n this.timer = undefined;\n this.subscriptions.clear();\n this.dirty.clear();\n this.deliveredClosed.clear();\n for (const builder of this.builders.values()) builder.dispose();\n this.builders.clear();\n for (const request of this.history.values()) request.controller.abort();\n this.history.clear();\n }\n\n private builder(id: string): CandleBuilder {\n let builder = this.builders.get(id);\n if (!builder) {\n builder = new CandleBuilder();\n this.builders.set(id, builder);\n }\n return builder;\n }\n private mark(id: string, snapshot: boolean, trade?: WsTrade): void {\n const previous = this.dirty.get(id);\n this.measurements.received++;\n if (previous) this.measurements.coalesced++;\n this.dirty.set(id, {\n snapshot: snapshot || !!previous?.snapshot,\n receivedAtMs: previous?.receivedAtMs ?? (this.receivedAtMs || Date.now()),\n trades: trade ? [trade, ...(previous?.trades ?? [])].slice(0, 50) : (previous?.trades ?? []),\n });\n this.measurements.maxPendingOutcomes = Math.max(\n this.measurements.maxPendingOutcomes,\n this.dirty.size,\n );\n this.schedule();\n }\n private schedule(): void {\n if (this.timer || this.inFlight || this.disposed || !this.observer) return;\n this.timer = setTimeout(() => {\n this.timer = undefined;\n void this.publish();\n }, 50);\n }\n private async publish(): Promise<void> {\n if (this.inFlight || this.disposed || !this.observer || !this.dirty.size) return;\n const views = [...this.dirty].map(([outcomeId, dirty]): MarketView => {\n const builder = this.builder(outcomeId);\n return {\n outcomeId,\n revision: this.revision,\n integrity: this.socket?.isResyncing(outcomeId) ? \"resyncing\" : \"ok\",\n book: this.socket?.getBook(outcomeId) ?? null,\n ...dirty,\n candles: Object.fromEntries(\n intervals.map((interval) => [\n interval,\n {\n forming: builder.getForming(interval) ? { ...builder.getForming(interval)! } : null,\n // Bounded recovery tail. Full historical ranges never travel per tick.\n closed: builder\n .getClosed(interval)\n .filter(\n (candle) =>\n candle.openTime >\n (this.deliveredClosed.get(outcomeId)?.[interval] ?? -Infinity),\n )\n .map((candle) => ({ ...candle })),\n },\n ]),\n ) as CandleTail,\n };\n });\n const generation = this.generation;\n this.dirty.clear();\n this.inFlight = true;\n const token = {};\n this.deliveryToken = token;\n const cancelled = new Promise<void>((resolve) => {\n this.cancelDelivery = resolve;\n });\n this.measurements.maxInFlight = 1;\n try {\n await Promise.race([\n this.observer({ generation, views, publishedAtMs: Date.now() }),\n cancelled,\n ]);\n if (this.disposed || this.deliveryToken !== token) return;\n for (const view of generation === this.generation ? views : []) {\n const delivered = this.deliveredClosed.get(view.outcomeId) ?? {};\n for (const interval of intervals) {\n const last = view.candles[interval].closed.at(-1);\n if (last) delivered[interval] = last.openTime;\n }\n this.deliveredClosed.set(view.outcomeId, delivered);\n }\n this.measurements.published++;\n } catch {\n if (!this.disposed && this.deliveryToken === token) this.socket?.disconnect();\n } finally {\n if (this.deliveryToken === token) {\n this.deliveryToken = null;\n this.cancelDelivery = undefined;\n this.inFlight = false;\n if (this.dirty.size) this.schedule();\n }\n }\n }\n}\n"],"mappings":";;;AAuCA,MAAM,YAAY;CAAC;CAAM;CAAM;CAAM;AAAI;;AAGzC,IAAa,mBAAb,MAA8B;;EACU,KAAA,SAAA;EACjB,KAAA,aAAA;EACE,KAAA,eAAA;EACJ,KAAA,WAAA;EACO,KAAA,kCAAA,IAAI,IAAqD;EAC3D,KAAA,gCAAA,IAAI,IAAwB;EACjC,KAAA,2BAAA,IAAI,IAA2B;EAClC,KAAA,wBAAA,IAAI,IAA4E;EAG7E,KAAA,WAAA;EACoB,KAAA,gBAAA;EAEpB,KAAA,WAAA;EACD,KAAA,0BAAA,IAAI,IAAiE;EAChE,KAAA,eAAA;GACrB,UAAU;GACV,WAAW;GACX,WAAW;GACX,oBAAoB;GACpB,aAAa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AY,IAAI,SAAe,YAAY;GAC/C,KAAK,iBAAiB;EACxB,CAAC;EACD,KAAK,aAAa,cAAc;EAChC,IAAI;GACF,MAAM,QAAQ,KAAK,CACjB,KAAK,SAAS;IAAE;IAAY;IAAO,eAAe,KAAK,IAAI;GAAE,CAAC,GAC9D,SACF,CAAC;GACD,IAAI,KAAK,YAAY,KAAK,kBAAkB,OAAO;GACnD,KAAK,MAAM,QAAQ,eAAe,KAAK,aAAa,QAAQ,CAAC,GAAG;IAC9D,MAAM,YAAY,KAAK,gBAAgB,IAAI,KAAK,SAAS,KAAK,CAAC;IAC/D,KAAK,MAAM,YAAY,WAAW;KAChC,MAAM,OAAO,KAAK,QAAQ,SAAS,CAAC,OAAO,GAAG,EAAE;KAChD,IAAI,MAAM,UAAU,YAAY,KAAK;IACvC;IACA,KAAK,gBAAgB,IAAI,KAAK,WAAW,SAAS;GACpD;GACA,KAAK,aAAa;EACpB,QAAQ;GACN,IAAI,CAAC,KAAK,YAAY,KAAK,kBAAkB,OAAO,KAAK,QAAQ,WAAW;EAC9E,UAAU;GACR,IAAI,KAAK,kBAAkB,OAAO;IAChC,KAAK,gBAAgB;IACrB,KAAK,iBAAiB,KAAA;IACtB,KAAK,WAAW;IAChB,IAAI,KAAK,MAAM,MAAM,KAAK,SAAS;GACrC;EACF;CACF;AACF"}
|
package/dist/server.d.mts
CHANGED
|
@@ -1,263 +1,264 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//#region src/server.d.ts
|
|
2
|
+
export interface ExternalIdAssertion {
|
|
3
|
+
externalId: string;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
hmac: string;
|
|
5
6
|
}
|
|
6
|
-
declare function signExternalId(appSecret: string, externalId: string): ExternalIdAssertion;
|
|
7
|
-
declare class WebhookVerificationError extends Error {
|
|
8
|
-
|
|
7
|
+
export declare function signExternalId(appSecret: string, externalId: string): ExternalIdAssertion;
|
|
8
|
+
export declare class WebhookVerificationError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
9
10
|
}
|
|
10
|
-
interface VerifyWebhookOptions {
|
|
11
|
-
|
|
11
|
+
export interface VerifyWebhookOptions {
|
|
12
|
+
toleranceSeconds?: number;
|
|
12
13
|
}
|
|
13
|
-
declare function verifyWebhook(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): void;
|
|
14
|
-
declare function parseWebhookEvent(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): WebhookEvent;
|
|
14
|
+
export declare function verifyWebhook(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): void;
|
|
15
|
+
export declare function parseWebhookEvent(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): WebhookEvent;
|
|
15
16
|
/**
|
|
16
17
|
* Async, edge-runtime-friendly variant of {@link verifyWebhook}. Same
|
|
17
18
|
* Svix v1 signing scheme. Use this in Cloudflare Workers / Vercel Edge /
|
|
18
19
|
* Deno / Bun. The sync variant remains available for Node.js consumers.
|
|
19
20
|
*/
|
|
20
|
-
declare function verifyWebhookAsync(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): Promise<void>;
|
|
21
|
+
export declare function verifyWebhookAsync(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): Promise<void>;
|
|
21
22
|
/**
|
|
22
23
|
* Async, edge-runtime-friendly variant of {@link parseWebhookEvent}.
|
|
23
24
|
*/
|
|
24
|
-
declare function parseWebhookEventAsync(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): Promise<WebhookEvent>;
|
|
25
|
+
export declare function parseWebhookEventAsync(payload: string, headers: Record<string, string | string[] | undefined>, secret: string, options?: VerifyWebhookOptions): Promise<WebhookEvent>;
|
|
25
26
|
interface WebhookEventBase {
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
id: string;
|
|
28
|
+
createdAt: string;
|
|
28
29
|
}
|
|
29
|
-
interface AccountsCreatedEvent extends WebhookEventBase {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
export interface AccountsCreatedEvent extends WebhookEventBase {
|
|
31
|
+
type: "accounts.created";
|
|
32
|
+
data: {
|
|
33
|
+
userId: string;
|
|
34
|
+
appId: string;
|
|
35
|
+
createdAt: string;
|
|
36
|
+
email: string | null;
|
|
37
|
+
};
|
|
37
38
|
}
|
|
38
|
-
interface AccountsLinkedEvent extends WebhookEventBase {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
export interface AccountsLinkedEvent extends WebhookEventBase {
|
|
40
|
+
type: "accounts.linked";
|
|
41
|
+
data: {
|
|
42
|
+
userId: string;
|
|
43
|
+
externalId: string;
|
|
44
|
+
linkedAt: string;
|
|
45
|
+
};
|
|
45
46
|
}
|
|
46
|
-
interface WalletsReadyEvent extends WebhookEventBase {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
export interface WalletsReadyEvent extends WebhookEventBase {
|
|
48
|
+
type: "wallets.ready";
|
|
49
|
+
data: {
|
|
50
|
+
userId: string;
|
|
51
|
+
evmAddress: string;
|
|
52
|
+
svmAddress: string;
|
|
53
|
+
createdAt: string;
|
|
54
|
+
};
|
|
54
55
|
}
|
|
55
|
-
interface TradesPlacedEvent extends WebhookEventBase {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
56
|
+
export interface TradesPlacedEvent extends WebhookEventBase {
|
|
57
|
+
type: "trades.placed";
|
|
58
|
+
data: {
|
|
59
|
+
orderId: string;
|
|
60
|
+
userId: string;
|
|
61
|
+
side: string;
|
|
62
|
+
timestamp: string;
|
|
63
|
+
/** Your trade id from `POST /execution/orders`, or `null` if the trade did not carry one. */
|
|
64
|
+
externalId: string | null;
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated Never emitted by the server in 1.x — the SDK type lied
|
|
67
|
+
* here for several releases. Reads always return `undefined`. The field
|
|
68
|
+
* is retained as `undefined`-typed for one minor release so existing
|
|
69
|
+
* partner code that destructures it keeps compiling; remove in 2.0.
|
|
70
|
+
*/
|
|
71
|
+
venue?: undefined;
|
|
72
|
+
/** @deprecated See `venue`. */
|
|
73
|
+
venueMarketId?: undefined;
|
|
74
|
+
};
|
|
74
75
|
}
|
|
75
|
-
interface TradesFilledEvent extends WebhookEventBase {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
76
|
+
export interface TradesFilledEvent extends WebhookEventBase {
|
|
77
|
+
type: "trades.filled";
|
|
78
|
+
data: {
|
|
79
|
+
orderId: string;
|
|
80
|
+
userId: string;
|
|
81
|
+
status: string;
|
|
82
|
+
timestamp: string;
|
|
83
|
+
/** Your trade id from `POST /execution/orders`, or `null` if the trade did not carry one. */
|
|
84
|
+
externalId: string | null;
|
|
85
|
+
/**
|
|
86
|
+
* Post-execution accuracy data. All `*Raw` values are decimal strings in
|
|
87
|
+
* 6-decimal atomic units. `*PriceRaw` are decimal strings (e.g. "0.5").
|
|
88
|
+
* `partialFillReason` is set only on `status === "partial_fill"`.
|
|
89
|
+
*/
|
|
90
|
+
filledAmountRaw?: string;
|
|
91
|
+
quotedSharesRaw?: string;
|
|
92
|
+
actualSharesRaw?: string;
|
|
93
|
+
quotedToWinRaw?: string;
|
|
94
|
+
actualToWinRaw?: string;
|
|
95
|
+
quotedPriceRaw?: string;
|
|
96
|
+
executionPriceRaw?: string;
|
|
97
|
+
partialFillReason?: string;
|
|
98
|
+
/** @deprecated See `executionPriceRaw` — never emitted; remove in 2.0. */
|
|
99
|
+
fillPrice?: undefined;
|
|
100
|
+
/** @deprecated See `actualSharesRaw` / `filledAmountRaw` — never emitted; remove in 2.0. */
|
|
101
|
+
fillSize?: undefined;
|
|
102
|
+
};
|
|
102
103
|
}
|
|
103
104
|
/**
|
|
104
105
|
* A self-custody trade's app fee reached its final state. Sent once per trade,
|
|
105
106
|
* a few seconds after `trades.filled` (the fee needs the user's second
|
|
106
107
|
* signature and an on-chain confirmation).
|
|
107
108
|
*/
|
|
108
|
-
interface TradesFeeReconciledEvent extends WebhookEventBase {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
109
|
+
export interface TradesFeeReconciledEvent extends WebhookEventBase {
|
|
110
|
+
type: "trades.fee_reconciled";
|
|
111
|
+
data: {
|
|
112
|
+
dagRunId: string;
|
|
113
|
+
quoteId: string;
|
|
114
|
+
userId: string;
|
|
115
|
+
/** Every order in the trade. The fee is charged once across all of them. */
|
|
116
|
+
orders: Array<{
|
|
117
|
+
orderId: string;
|
|
118
|
+
externalId: string | null;
|
|
119
|
+
}>;
|
|
120
|
+
/**
|
|
121
|
+
* `confirmed`, `under_collected`, `failed`, `skipped_zero`, … or `none`
|
|
122
|
+
* when no fee applied to the trade.
|
|
123
|
+
*/
|
|
124
|
+
status: string;
|
|
125
|
+
/** Token-native atomic units. `"0"` when `status` is `none`. */
|
|
126
|
+
feeDueRaw: string;
|
|
127
|
+
feeCollectedRaw: string;
|
|
128
|
+
appShareRaw: string;
|
|
129
|
+
platformShareRaw: string;
|
|
130
|
+
chainId: string | null;
|
|
131
|
+
tokenSymbol: string | null;
|
|
132
|
+
tokenAddress: string | null;
|
|
133
|
+
appTxHash: string | null;
|
|
134
|
+
platformTxHash: string | null;
|
|
135
|
+
timestamp: string;
|
|
136
|
+
};
|
|
136
137
|
}
|
|
137
|
-
interface MarketsResolvedEvent extends WebhookEventBase {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
138
|
+
export interface MarketsResolvedEvent extends WebhookEventBase {
|
|
139
|
+
type: "markets.resolved";
|
|
140
|
+
data: {
|
|
141
|
+
venueMarketId: string;
|
|
142
|
+
externalIdentifier: string;
|
|
143
|
+
status: string;
|
|
144
|
+
outcomes: Array<{
|
|
145
|
+
label: string;
|
|
146
|
+
winner?: boolean;
|
|
147
|
+
externalIdentifier?: string;
|
|
148
|
+
}>;
|
|
149
|
+
affectedUsersCount: number;
|
|
150
|
+
/**
|
|
151
|
+
* Path on the AGG API where this resolution's affected users can be
|
|
152
|
+
* paginated. Combine with the configured base URL — e.g.
|
|
153
|
+
* `https://api.agg.market${detailsPath}`.
|
|
154
|
+
*/
|
|
155
|
+
detailsPath: string;
|
|
156
|
+
/**
|
|
157
|
+
* @deprecated Singular `outcome` was never emitted; use `outcomes` array.
|
|
158
|
+
* Remove in 2.0.
|
|
159
|
+
*/
|
|
160
|
+
outcome?: undefined;
|
|
161
|
+
};
|
|
161
162
|
}
|
|
162
|
-
interface DepositsConfirmedEvent extends WebhookEventBase {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
163
|
+
export interface DepositsConfirmedEvent extends WebhookEventBase {
|
|
164
|
+
type: "deposits.confirmed";
|
|
165
|
+
data: {
|
|
166
|
+
userId: string;
|
|
167
|
+
chainId: number;
|
|
168
|
+
tokenSymbol: string;
|
|
169
|
+
tokenAddress: string;
|
|
170
|
+
/** Token-native atomic units (6 decimals for USDC). */
|
|
171
|
+
amountRaw: string;
|
|
172
|
+
txHash: string;
|
|
173
|
+
fromAddress: string;
|
|
174
|
+
timestamp: string;
|
|
175
|
+
};
|
|
175
176
|
}
|
|
176
|
-
interface UnknownWebhookEvent extends WebhookEventBase {
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
export interface UnknownWebhookEvent extends WebhookEventBase {
|
|
178
|
+
type: string;
|
|
179
|
+
data: Record<string, unknown>;
|
|
179
180
|
}
|
|
180
|
-
type KnownWebhookEvent = AccountsCreatedEvent | AccountsLinkedEvent | WalletsReadyEvent | TradesPlacedEvent | TradesFilledEvent | TradesFeeReconciledEvent | MarketsResolvedEvent | DepositsConfirmedEvent;
|
|
181
|
-
type WebhookEvent = KnownWebhookEvent | UnknownWebhookEvent;
|
|
182
|
-
interface AggAdminClientOptions {
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
export type KnownWebhookEvent = AccountsCreatedEvent | AccountsLinkedEvent | WalletsReadyEvent | TradesPlacedEvent | TradesFilledEvent | TradesFeeReconciledEvent | MarketsResolvedEvent | DepositsConfirmedEvent;
|
|
182
|
+
export type WebhookEvent = KnownWebhookEvent | UnknownWebhookEvent;
|
|
183
|
+
export interface AggAdminClientOptions {
|
|
184
|
+
baseUrl: string;
|
|
185
|
+
apiKey: string;
|
|
185
186
|
}
|
|
186
|
-
declare class AggAdminClient {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
187
|
+
export declare class AggAdminClient {
|
|
188
|
+
private readonly baseUrl;
|
|
189
|
+
private readonly apiKey;
|
|
190
|
+
constructor(options: AggAdminClientOptions);
|
|
191
|
+
request<T>(path: string, init?: RequestInit & {
|
|
192
|
+
query?: Record<string, string | string[] | undefined>;
|
|
193
|
+
}): Promise<T>;
|
|
194
|
+
private rawFetch;
|
|
195
|
+
private throwResponseError;
|
|
196
|
+
listUsers(appId: string, query?: {
|
|
197
|
+
limit?: number;
|
|
198
|
+
cursor?: string;
|
|
199
|
+
search?: string;
|
|
200
|
+
}): Promise<{
|
|
201
|
+
data: {
|
|
202
|
+
id: string;
|
|
203
|
+
username: string | null;
|
|
204
|
+
externalId: string | null;
|
|
205
|
+
suspended: boolean;
|
|
206
|
+
createdAt: string;
|
|
207
|
+
}[];
|
|
208
|
+
nextCursor: string | null;
|
|
209
|
+
hasMore: boolean;
|
|
210
|
+
}>;
|
|
211
|
+
getUser(appId: string, userId: string): Promise<{
|
|
212
|
+
id: string;
|
|
213
|
+
username: string | null;
|
|
214
|
+
externalId: string | null;
|
|
215
|
+
suspended: boolean;
|
|
216
|
+
createdAt: string;
|
|
217
|
+
updatedAt: string;
|
|
218
|
+
_count: {
|
|
219
|
+
orders: number;
|
|
220
|
+
};
|
|
221
|
+
}>;
|
|
222
|
+
getAnalytics(appId: string): Promise<{
|
|
223
|
+
totalUsers: number;
|
|
224
|
+
totalOrders: number;
|
|
225
|
+
ordersByStatus: Record<string, number>;
|
|
226
|
+
ordersByVenue: Record<string, number>;
|
|
227
|
+
usersLast30Days: number;
|
|
228
|
+
usersLast7Days: number;
|
|
229
|
+
ordersLast30Days: number;
|
|
230
|
+
ordersLast7Days: number;
|
|
231
|
+
}>;
|
|
232
|
+
listOrders(appId: string, query?: {
|
|
233
|
+
limit?: number;
|
|
234
|
+
cursor?: string;
|
|
235
|
+
venue?: string;
|
|
236
|
+
status?: string;
|
|
237
|
+
}): Promise<{
|
|
238
|
+
data: unknown[];
|
|
239
|
+
nextCursor: string | null;
|
|
240
|
+
hasMore: boolean;
|
|
241
|
+
}>;
|
|
242
|
+
rotateWebhookSecret(appId: string, webhookId: string): Promise<{
|
|
243
|
+
secret: string;
|
|
244
|
+
}>;
|
|
245
|
+
replayWebhookDeliveries(appId: string, webhookId: string): Promise<{
|
|
246
|
+
success: boolean;
|
|
247
|
+
}>;
|
|
248
|
+
listMarketResolutionUsers(appId: string, venueMarketId: string, query?: {
|
|
249
|
+
limit?: number;
|
|
250
|
+
cursor?: string;
|
|
251
|
+
includeEmails?: boolean;
|
|
252
|
+
}): Promise<{
|
|
253
|
+
venueMarketId: string;
|
|
254
|
+
note: string;
|
|
255
|
+
data: {
|
|
256
|
+
userId: string;
|
|
257
|
+
email?: string | null;
|
|
258
|
+
}[];
|
|
259
|
+
nextCursor: string | null;
|
|
260
|
+
hasMore: boolean;
|
|
261
|
+
}>;
|
|
261
262
|
}
|
|
262
|
-
|
|
263
|
-
|
|
263
|
+
//#endregion
|
|
264
|
+
//# sourceMappingURL=server.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.mts","names":[],"sources":["../src/server.ts"],"mappings":";iBAIiB;EACf;EACA;EACA;;wBAGc,eAAe,mBAAmB,qBAAqB;qBAyC1D,iCAAiC;EAChC,YAAA;;iBAMG;EACf;;wBAGc,cACd,iBACA,SAAS,+CACT,gBACA,UAAU;wBAmCI,kBACd,iBACA,SAAS,+CACT,gBACA,UAAU,uBACT;;;;;;wBAgBmB,mBACpB,iBACA,SAAS,+CACT,gBACA,UAAU,uBACT;;;;wBAyCmB,uBACpB,iBACA,SAAS,+CACT,gBACA,UAAU,uBACT,QAAQ;UAoBD;EACR;EACA;;iBAGe,6BAA6B;EAC5C;EACA;IAAQ;IAAgB;IAAe;IAAmB;;;iBAG3C,4BAA4B;EAC3C;EACA;IAAQ;IAAgB;IAAoB;;;iBAG7B,0BAA0B;EACzC;EACA;IACE;IACA;IACA;IACA;;;iBAIa,0BAA0B;EACzC;EACA;IACE;IACA;IACA;IACA;;IAEA;;;;;;;IAOA;;IAEA;;;iBAIa,0BAA0B;EACzC;EACA;IACE;IACA;IACA;IAC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