@pod-network/trade-sdk 0.10.0 → 0.11.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/README.md +6 -4
- package/dist/client.d.ts +20 -10
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +26 -11
- package/dist/client.js.map +1 -1
- package/dist/codec/activity.d.ts +11 -0
- package/dist/codec/activity.d.ts.map +1 -0
- package/dist/codec/activity.js +33 -0
- package/dist/codec/activity.js.map +1 -0
- package/dist/codec/decode.d.ts +14 -6
- package/dist/codec/decode.d.ts.map +1 -1
- package/dist/codec/decode.js +58 -24
- package/dist/codec/decode.js.map +1 -1
- package/dist/codec/orders-v2.d.ts +9 -3
- package/dist/codec/orders-v2.d.ts.map +1 -1
- package/dist/codec/orders-v2.js +12 -9
- package/dist/codec/orders-v2.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/sync/activity.d.ts +58 -0
- package/dist/sync/activity.d.ts.map +1 -0
- package/dist/sync/activity.js +259 -0
- package/dist/sync/activity.js.map +1 -0
- package/dist/sync/orders.d.ts +4 -64
- package/dist/sync/orders.d.ts.map +1 -1
- package/dist/sync/orders.js +40 -190
- package/dist/sync/orders.js.map +1 -1
- package/dist/sync/pnl-history.d.ts +33 -14
- package/dist/sync/pnl-history.d.ts.map +1 -1
- package/dist/sync/pnl-history.js +255 -65
- package/dist/sync/pnl-history.js.map +1 -1
- package/dist/sync/stream.d.ts +101 -0
- package/dist/sync/stream.d.ts.map +1 -0
- package/dist/sync/stream.js +243 -0
- package/dist/sync/stream.js.map +1 -0
- package/dist/transport/jsonrpc.d.ts +0 -5
- package/dist/transport/jsonrpc.d.ts.map +1 -1
- package/dist/transport/jsonrpc.js +0 -20
- package/dist/transport/jsonrpc.js.map +1 -1
- package/dist/transport/rest.d.ts +36 -4
- package/dist/transport/rest.d.ts.map +1 -1
- package/dist/transport/rest.js +43 -10
- package/dist/transport/rest.js.map +1 -1
- package/dist/transport/ws.d.ts +5 -1
- package/dist/transport/ws.d.ts.map +1 -1
- package/dist/transport/ws.js.map +1 -1
- package/dist/types/public.d.ts +62 -23
- package/dist/types/public.d.ts.map +1 -1
- package/dist/types/wire.d.ts +98 -16
- package/dist/types/wire.d.ts.map +1 -1
- package/dist/write/index.d.ts +3 -3
- package/dist/write/index.d.ts.map +1 -1
- package/dist/write/index.js +0 -3
- package/dist/write/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +28 -13
- package/src/codec/activity.ts +46 -0
- package/src/codec/decode.ts +65 -30
- package/src/codec/orders-v2.ts +24 -11
- package/src/index.ts +3 -1
- package/src/sync/activity.ts +266 -0
- package/src/sync/orders.ts +41 -187
- package/src/sync/pnl-history.ts +244 -75
- package/src/sync/stream.ts +270 -0
- package/src/transport/jsonrpc.ts +0 -23
- package/src/transport/rest.ts +62 -14
- package/src/transport/ws.ts +5 -1
- package/src/types/public.ts +62 -26
- package/src/types/wire.ts +105 -18
- package/src/write/index.ts +3 -6
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Channel, PodWsClient, SubParams } from "../transport/ws.js";
|
|
2
|
+
/**
|
|
3
|
+
* Order two positions in the stream, the way the server does.
|
|
4
|
+
*
|
|
5
|
+
* A batch is delivered as one frame per book, so a position is the pair
|
|
6
|
+
* `(batch, book)` — and an absent book means the whole batch, which sorts *above*
|
|
7
|
+
* every book in it. This mirrors `already_delivered` in
|
|
8
|
+
* `node/src/rpc/orders_v2.rs`: `(frame_batch, frame_book) <= (since,
|
|
9
|
+
* since_book.unwrap_or(0xff…))`. Getting the absent case wrong turns "all of batch
|
|
10
|
+
* N" into "up to book B of batch N", which asks the server to re-send the rest.
|
|
11
|
+
*
|
|
12
|
+
* `pod_activity` sends one frame per tick and names no book, so the pair collapses
|
|
13
|
+
* to the batch there — the same comparison, with both books absent.
|
|
14
|
+
*
|
|
15
|
+
* Book ids are fixed-width lowercase hex, so comparing them as strings is
|
|
16
|
+
* comparing their bytes.
|
|
17
|
+
*/
|
|
18
|
+
export declare function compareCursor(a: SubParams, b: SubParams): number;
|
|
19
|
+
export interface ResumableStreamOptions {
|
|
20
|
+
ws: PodWsClient;
|
|
21
|
+
channel: Channel;
|
|
22
|
+
/** Everything that identifies the subscription except the cursor. */
|
|
23
|
+
params: SubParams;
|
|
24
|
+
/**
|
|
25
|
+
* Re-seed over REST, and raise the cursor to the page's watermark. `true` when
|
|
26
|
+
* the page was applied, `false` when it was abandoned (the stream stopped, or a
|
|
27
|
+
* fresher seed overtook it); a rejection is a failed fetch, which is what decides
|
|
28
|
+
* between backing off and giving up.
|
|
29
|
+
*/
|
|
30
|
+
reseed(): Promise<boolean>;
|
|
31
|
+
onFrame(result: unknown): void;
|
|
32
|
+
}
|
|
33
|
+
export declare class ResumableStream {
|
|
34
|
+
private readonly opts;
|
|
35
|
+
/**
|
|
36
|
+
* Where the stream is: the last frame accepted. Replaced whole rather than
|
|
37
|
+
* patched half at a time — on `pod_orders_v2` `sinceBook` names a book *within*
|
|
38
|
+
* `since`, so the two are one fact and a mismatched pair asks the server to skip
|
|
39
|
+
* books we never saw.
|
|
40
|
+
*/
|
|
41
|
+
cursor: SubParams;
|
|
42
|
+
private sub;
|
|
43
|
+
private alive;
|
|
44
|
+
private subRetries;
|
|
45
|
+
private fastResumes;
|
|
46
|
+
private retryTimer?;
|
|
47
|
+
private offOpen?;
|
|
48
|
+
constructor(opts: ResumableStreamOptions);
|
|
49
|
+
/** Whether the owner's resource is still running; guards its async seeds. */
|
|
50
|
+
get running(): boolean;
|
|
51
|
+
start(): void;
|
|
52
|
+
stop(): void;
|
|
53
|
+
/** The server's `already_delivered`: is this frame at or behind where we are? */
|
|
54
|
+
delivered(at: SubParams): boolean;
|
|
55
|
+
/** Move to `at` and tell the transport, so a reconnect resumes from there. */
|
|
56
|
+
advance(at: SubParams): void;
|
|
57
|
+
/** Move to `at` only when it is ahead. Never rewinds — a re-delivered frame is dropped. */
|
|
58
|
+
raise(at: SubParams): void;
|
|
59
|
+
seed(): void;
|
|
60
|
+
private resume;
|
|
61
|
+
private subscribe;
|
|
62
|
+
/**
|
|
63
|
+
* Push the cursor to the transport, both halves.
|
|
64
|
+
*
|
|
65
|
+
* `update` merges, so sending `{ since }` alone would leave whatever `sinceBook`
|
|
66
|
+
* was there before — a book from an older batch beside a newer `since`, which asks
|
|
67
|
+
* the server to skip less than it should and re-send the difference.
|
|
68
|
+
*/
|
|
69
|
+
private pushCursor;
|
|
70
|
+
private clearRetry;
|
|
71
|
+
private onFrame;
|
|
72
|
+
/**
|
|
73
|
+
* The subscription is not running: `eth_subscribe` was rejected, or the server
|
|
74
|
+
* closed it.
|
|
75
|
+
*
|
|
76
|
+
* A resumable close needs neither a re-seed nor a delay: the server reports where
|
|
77
|
+
* it stopped, so resubscribing from that delivers exactly the frames we never got.
|
|
78
|
+
* That fast path is only taken while the socket is actually open — `resubscribe()`
|
|
79
|
+
* is a no-op otherwise, which would spend the budget without an attempt and leave
|
|
80
|
+
* nothing scheduled, and `-32021` (node shutting down) arrives exactly as the
|
|
81
|
+
* socket goes away.
|
|
82
|
+
*
|
|
83
|
+
* Everything else (a rejection, a server bug, a close with the socket already
|
|
84
|
+
* gone, or closes that keep coming) takes the slow path: backed off and capped, so
|
|
85
|
+
* a server that keeps refusing cannot spin this into a tight re-seed loop, and
|
|
86
|
+
* eventually the cursor is dropped (the likely culprit) to just stream live. Both
|
|
87
|
+
* counters reset once live data flows (`onFrame`).
|
|
88
|
+
*/
|
|
89
|
+
private onSubError;
|
|
90
|
+
/**
|
|
91
|
+
* Back off, re-seed over REST, then resubscribe — and keep trying.
|
|
92
|
+
*
|
|
93
|
+
* The re-seed can fail too (the same node is usually behind both the stream and the
|
|
94
|
+
* indexer), and a failure has to re-arm here: not resubscribing means no further
|
|
95
|
+
* close or rejection arrives, so nothing else would ever schedule another attempt and
|
|
96
|
+
* the stream would stay down with no error surfaced. Capped, so a node that keeps
|
|
97
|
+
* refusing cannot spin this.
|
|
98
|
+
*/
|
|
99
|
+
private scheduleReseed;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/sync/stream.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAgB,MAAM,oBAAoB,CAAC;AAoBxF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,MAAM,CAOhE;AASD,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,WAAW,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,qEAAqE;IACrE,MAAM,EAAE,SAAS,CAAC;IAClB;;;;;OAKG;IACH,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3B,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CAChC;AAED,qBAAa,eAAe;IAed,OAAO,CAAC,QAAQ,CAAC,IAAI;IAdjC;;;;;OAKG;IACH,MAAM,EAAE,SAAS,CAAM;IACvB,OAAO,CAAC,GAAG,CAA2B;IACtC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,UAAU,CAAC,CAAgC;IACnD,OAAO,CAAC,OAAO,CAAC,CAAa;gBAEA,IAAI,EAAE,sBAAsB;IAEzD,6EAA6E;IAC7E,IAAI,OAAO,IAAI,OAAO,CAAuB;IAE7C,KAAK,IAAI,IAAI;IAMb,IAAI,IAAI,IAAI;IASZ,iFAAiF;IACjF,SAAS,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO;IAIjC,8EAA8E;IAC9E,OAAO,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI;IAK5B,2FAA2F;IAC3F,KAAK,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI;IAI1B,IAAI,IAAI,IAAI;IAkBZ,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,SAAS;IASjB;;;;;;OAMG;IACH,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,OAAO;IASf;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,UAAU;IA8BlB;;;;;;;;OAQG;IACH,OAAO,CAAC,cAAc;CA2BvB"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// The subscribe / resume / re-seed loop shared by the account feeds.
|
|
2
|
+
//
|
|
3
|
+
// Reconnect: on every (re)connect the owner re-seeds its first page (the
|
|
4
|
+
// authoritative snapshot) and refreshes the cursor from its watermark; the WS
|
|
5
|
+
// auto-resubscribes, and if the cursor is too old (down too long) `onSubError`
|
|
6
|
+
// re-seeds and resubscribes. A server-initiated close is not the same as a
|
|
7
|
+
// rejection: it reports where delivery stopped, so resuming from one is a bare
|
|
8
|
+
// `resubscribe()` with no re-seed.
|
|
9
|
+
import { PodHttpError } from "../transport/rest.js";
|
|
10
|
+
import { PodSubscriptionClosedError } from "../transport/ws.js";
|
|
11
|
+
/**
|
|
12
|
+
* Consecutive server closes we resume from before falling back to the re-seed
|
|
13
|
+
* path. A lagged close is recoverable by resubscribing, so the fast path is the
|
|
14
|
+
* right default — but a stream that keeps closing is one we are not keeping up
|
|
15
|
+
* with, and re-seeding beats replaying a growing backlog on every attempt.
|
|
16
|
+
*/
|
|
17
|
+
const FAST_RESUMES_BEFORE_RESEED = 3;
|
|
18
|
+
/**
|
|
19
|
+
* Re-seed attempts that keep the cursor before we conclude the cursor is what the
|
|
20
|
+
* server is rejecting, drop it, and settle for streaming live.
|
|
21
|
+
*/
|
|
22
|
+
const RETRIES_BEFORE_DROPPING_CURSOR = 2;
|
|
23
|
+
/** The largest book id, which is what an absent `sinceBook` means. */
|
|
24
|
+
const WHOLE_BATCH = `0x${"ff".repeat(32)}`;
|
|
25
|
+
/**
|
|
26
|
+
* Order two positions in the stream, the way the server does.
|
|
27
|
+
*
|
|
28
|
+
* A batch is delivered as one frame per book, so a position is the pair
|
|
29
|
+
* `(batch, book)` — and an absent book means the whole batch, which sorts *above*
|
|
30
|
+
* every book in it. This mirrors `already_delivered` in
|
|
31
|
+
* `node/src/rpc/orders_v2.rs`: `(frame_batch, frame_book) <= (since,
|
|
32
|
+
* since_book.unwrap_or(0xff…))`. Getting the absent case wrong turns "all of batch
|
|
33
|
+
* N" into "up to book B of batch N", which asks the server to re-send the rest.
|
|
34
|
+
*
|
|
35
|
+
* `pod_activity` sends one frame per tick and names no book, so the pair collapses
|
|
36
|
+
* to the batch there — the same comparison, with both books absent.
|
|
37
|
+
*
|
|
38
|
+
* Book ids are fixed-width lowercase hex, so comparing them as strings is
|
|
39
|
+
* comparing their bytes.
|
|
40
|
+
*/
|
|
41
|
+
export function compareCursor(a, b) {
|
|
42
|
+
const aBatch = a.since ?? 0;
|
|
43
|
+
const bBatch = b.since ?? 0;
|
|
44
|
+
if (aBatch !== bBatch)
|
|
45
|
+
return aBatch < bBatch ? -1 : 1;
|
|
46
|
+
const aBook = a.sinceBook ?? WHOLE_BATCH;
|
|
47
|
+
const bBook = b.sinceBook ?? WHOLE_BATCH;
|
|
48
|
+
return aBook === bBook ? 0 : aBook < bBook ? -1 : 1;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A seed the server refused on its own terms. Retrying reproduces it, so the
|
|
52
|
+
* backoff would be an infinite loop against an answer that will not change.
|
|
53
|
+
*/
|
|
54
|
+
const permanent = (err) => err instanceof PodHttpError && err.status >= 400 && err.status < 500;
|
|
55
|
+
export class ResumableStream {
|
|
56
|
+
opts;
|
|
57
|
+
/**
|
|
58
|
+
* Where the stream is: the last frame accepted. Replaced whole rather than
|
|
59
|
+
* patched half at a time — on `pod_orders_v2` `sinceBook` names a book *within*
|
|
60
|
+
* `since`, so the two are one fact and a mismatched pair asks the server to skip
|
|
61
|
+
* books we never saw.
|
|
62
|
+
*/
|
|
63
|
+
cursor = {};
|
|
64
|
+
sub;
|
|
65
|
+
alive = false;
|
|
66
|
+
subRetries = 0;
|
|
67
|
+
fastResumes = 0;
|
|
68
|
+
retryTimer;
|
|
69
|
+
offOpen;
|
|
70
|
+
constructor(opts) {
|
|
71
|
+
this.opts = opts;
|
|
72
|
+
}
|
|
73
|
+
/** Whether the owner's resource is still running; guards its async seeds. */
|
|
74
|
+
get running() { return this.alive; }
|
|
75
|
+
start() {
|
|
76
|
+
this.alive = true;
|
|
77
|
+
this.offOpen = this.opts.ws.on("open", () => { if (this.alive)
|
|
78
|
+
this.seed(); });
|
|
79
|
+
this.seed(); // initial paint (REST is independent of the socket being open)
|
|
80
|
+
}
|
|
81
|
+
stop() {
|
|
82
|
+
this.alive = false;
|
|
83
|
+
this.offOpen?.();
|
|
84
|
+
this.offOpen = undefined;
|
|
85
|
+
this.clearRetry();
|
|
86
|
+
this.sub?.unsubscribe();
|
|
87
|
+
this.sub = undefined;
|
|
88
|
+
}
|
|
89
|
+
/** The server's `already_delivered`: is this frame at or behind where we are? */
|
|
90
|
+
delivered(at) {
|
|
91
|
+
return compareCursor(at, this.cursor) <= 0;
|
|
92
|
+
}
|
|
93
|
+
/** Move to `at` and tell the transport, so a reconnect resumes from there. */
|
|
94
|
+
advance(at) {
|
|
95
|
+
this.cursor = at;
|
|
96
|
+
this.sub?.update(at);
|
|
97
|
+
}
|
|
98
|
+
/** Move to `at` only when it is ahead. Never rewinds — a re-delivered frame is dropped. */
|
|
99
|
+
raise(at) {
|
|
100
|
+
if (compareCursor(at, this.cursor) > 0)
|
|
101
|
+
this.cursor = at;
|
|
102
|
+
}
|
|
103
|
+
seed() {
|
|
104
|
+
// A seed that lands supersedes whatever the last failure armed; leaving the
|
|
105
|
+
// timer would re-seed and resubscribe a stream that is already healthy.
|
|
106
|
+
const armed = this.retryTimer !== undefined;
|
|
107
|
+
this.clearRetry();
|
|
108
|
+
void this.opts.reseed().then((ok) => { if (ok)
|
|
109
|
+
this.resume(); }, (err) => {
|
|
110
|
+
// Nothing is subscribed yet, so no close or rejection can arrive to schedule
|
|
111
|
+
// another attempt — a failed first paint has to re-arm itself or the resource
|
|
112
|
+
// stays empty for good. With a subscription up, the live stream is unaffected
|
|
113
|
+
// and its own error path owns the recovery; the exception is a retry this call
|
|
114
|
+
// just disarmed, which nothing else would re-arm.
|
|
115
|
+
if (this.alive && (!this.sub || armed) && !permanent(err))
|
|
116
|
+
this.scheduleReseed();
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
resume() {
|
|
120
|
+
if (!this.alive)
|
|
121
|
+
return;
|
|
122
|
+
if (!this.sub)
|
|
123
|
+
this.subscribe();
|
|
124
|
+
else
|
|
125
|
+
this.pushCursor(); // refresh for the next reconnect
|
|
126
|
+
}
|
|
127
|
+
subscribe() {
|
|
128
|
+
this.sub = this.opts.ws.subscribe(this.opts.channel, { ...this.opts.params, ...this.cursor }, (r) => this.onFrame(r), (e) => this.onSubError(e));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Push the cursor to the transport, both halves.
|
|
132
|
+
*
|
|
133
|
+
* `update` merges, so sending `{ since }` alone would leave whatever `sinceBook`
|
|
134
|
+
* was there before — a book from an older batch beside a newer `since`, which asks
|
|
135
|
+
* the server to skip less than it should and re-send the difference.
|
|
136
|
+
*/
|
|
137
|
+
pushCursor() {
|
|
138
|
+
this.sub?.update({ since: this.cursor.since, sinceBook: this.cursor.sinceBook });
|
|
139
|
+
}
|
|
140
|
+
clearRetry() {
|
|
141
|
+
if (this.retryTimer) {
|
|
142
|
+
clearTimeout(this.retryTimer);
|
|
143
|
+
this.retryTimer = undefined;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
onFrame(result) {
|
|
147
|
+
// Live data flowing → the subscription is healthy on both paths, and a retry
|
|
148
|
+
// armed by whatever went wrong before has nothing left to recover.
|
|
149
|
+
this.subRetries = 0;
|
|
150
|
+
this.fastResumes = 0;
|
|
151
|
+
this.clearRetry();
|
|
152
|
+
this.opts.onFrame(result);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The subscription is not running: `eth_subscribe` was rejected, or the server
|
|
156
|
+
* closed it.
|
|
157
|
+
*
|
|
158
|
+
* A resumable close needs neither a re-seed nor a delay: the server reports where
|
|
159
|
+
* it stopped, so resubscribing from that delivers exactly the frames we never got.
|
|
160
|
+
* That fast path is only taken while the socket is actually open — `resubscribe()`
|
|
161
|
+
* is a no-op otherwise, which would spend the budget without an attempt and leave
|
|
162
|
+
* nothing scheduled, and `-32021` (node shutting down) arrives exactly as the
|
|
163
|
+
* socket goes away.
|
|
164
|
+
*
|
|
165
|
+
* Everything else (a rejection, a server bug, a close with the socket already
|
|
166
|
+
* gone, or closes that keep coming) takes the slow path: backed off and capped, so
|
|
167
|
+
* a server that keeps refusing cannot spin this into a tight re-seed loop, and
|
|
168
|
+
* eventually the cursor is dropped (the likely culprit) to just stream live. Both
|
|
169
|
+
* counters reset once live data flows (`onFrame`).
|
|
170
|
+
*/
|
|
171
|
+
onSubError(err) {
|
|
172
|
+
if (!this.alive)
|
|
173
|
+
return;
|
|
174
|
+
const canFastResume = err instanceof PodSubscriptionClosedError && err.resumable
|
|
175
|
+
&& this.fastResumes < FAST_RESUMES_BEFORE_RESEED && this.opts.ws.state === "open";
|
|
176
|
+
if (canFastResume) {
|
|
177
|
+
this.fastResumes++;
|
|
178
|
+
// Adopt the server's watermark only when it is ahead of ours: it knows which
|
|
179
|
+
// frames it handed over, but a re-seed may already have carried us past it,
|
|
180
|
+
// and rewinding would re-deliver frames we have applied.
|
|
181
|
+
const reported = { since: err.resumeSince, sinceBook: err.resumeSinceBook };
|
|
182
|
+
if (err.resumeSince !== undefined)
|
|
183
|
+
this.raise(reported);
|
|
184
|
+
// The transport rewrote `sub.params` from the close before this ran, so without
|
|
185
|
+
// pushing our own decision back the wire resumes from the server's point
|
|
186
|
+
// regardless and the guard above protects nothing.
|
|
187
|
+
this.pushCursor();
|
|
188
|
+
this.sub?.resubscribe();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
// The slow path, and the one that answers "what if we fell behind the server's
|
|
192
|
+
// replay buffer": `eth_subscribe` rejects a `since` older than what the buffer
|
|
193
|
+
// retains, and the prescribed recovery is to backfill over REST and resubscribe.
|
|
194
|
+
// That is what this is. The re-seed also *raises the cursor* to the page's
|
|
195
|
+
// watermark, so the position that was too old is gone by the first retry and the
|
|
196
|
+
// resubscribe is accepted with no gap — the server replays from the page forward.
|
|
197
|
+
// Dropping the cursor below is the backstop for when even that fresh watermark is
|
|
198
|
+
// refused (the indexer further behind than the buffer retains): live-only
|
|
199
|
+
// resubscribe, trading the unreplayable window for a working stream.
|
|
200
|
+
this.scheduleReseed();
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Back off, re-seed over REST, then resubscribe — and keep trying.
|
|
204
|
+
*
|
|
205
|
+
* The re-seed can fail too (the same node is usually behind both the stream and the
|
|
206
|
+
* indexer), and a failure has to re-arm here: not resubscribing means no further
|
|
207
|
+
* close or rejection arrives, so nothing else would ever schedule another attempt and
|
|
208
|
+
* the stream would stay down with no error surfaced. Capped, so a node that keeps
|
|
209
|
+
* refusing cannot spin this.
|
|
210
|
+
*/
|
|
211
|
+
scheduleReseed() {
|
|
212
|
+
this.subRetries++;
|
|
213
|
+
const delay = Math.min(30_000, 500 * 2 ** (this.subRetries - 1));
|
|
214
|
+
this.clearRetry();
|
|
215
|
+
this.retryTimer = setTimeout(() => {
|
|
216
|
+
this.retryTimer = undefined;
|
|
217
|
+
void this.opts.reseed().then((ok) => {
|
|
218
|
+
if (!this.alive || !ok)
|
|
219
|
+
return;
|
|
220
|
+
if (!this.sub) {
|
|
221
|
+
// Retrying the first paint: there is no subscription to resume, and no
|
|
222
|
+
// cursor the server has refused — open one from the page we just landed,
|
|
223
|
+
// and let the live stream start on a full budget rather than inheriting
|
|
224
|
+
// the attempts the indexer's outage cost.
|
|
225
|
+
this.subRetries = 0;
|
|
226
|
+
this.fastResumes = 0;
|
|
227
|
+
this.subscribe();
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const tooOld = this.subRetries > RETRIES_BEFORE_DROPPING_CURSOR;
|
|
231
|
+
if (tooOld)
|
|
232
|
+
this.sub.update({ since: undefined, sinceBook: undefined });
|
|
233
|
+
else
|
|
234
|
+
this.pushCursor();
|
|
235
|
+
this.sub.resubscribe();
|
|
236
|
+
}, (err) => {
|
|
237
|
+
if (this.alive && !permanent(err))
|
|
238
|
+
this.scheduleReseed();
|
|
239
|
+
});
|
|
240
|
+
}, delay);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/sync/stream.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,yEAAyE;AACzE,8EAA8E;AAC9E,+EAA+E;AAC/E,2EAA2E;AAC3E,+EAA+E;AAC/E,mCAAmC;AAGnC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAErC;;;GAGG;AACH,MAAM,8BAA8B,GAAG,CAAC,CAAC;AAEzC,sEAAsE;AACtE,MAAM,WAAW,GAAG,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAc,CAAC;AAEvD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,aAAa,CAAC,CAAY,EAAE,CAAY;IACtD,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;IAC5B,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;IAC5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AAC,UAAU,GAAG,UAAU,CAAC,GAAG,EAAE;YAChC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;YAC5B,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE;gBAClC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,EAAE;oBAAE,OAAO;gBAC/B,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;oBACd,uEAAuE;oBACvE,yEAAyE;oBACzE,wEAAwE;oBACxE,0CAA0C;oBAC1C,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;oBACpB,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;oBACrB,IAAI,CAAC,SAAS,EAAE,CAAC;oBACjB,OAAO;gBACT,CAAC;gBACD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,GAAG,8BAA8B,CAAC;gBAChE,IAAI,MAAM;oBAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;;oBACnE,IAAI,CAAC,UAAU,EAAE,CAAC;gBACvB,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;YACzB,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE;gBACT,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;oBAAE,IAAI,CAAC,cAAc,EAAE,CAAC;YAC3D,CAAC,CAAC,CAAC;QACL,CAAC,EAAE,KAAK,CAAC,CAAC;IACZ,CAAC;CACF"}
|
|
@@ -13,9 +13,4 @@ export declare function rpc<T>(rpcUrl: string, method: string, params?: unknown[
|
|
|
13
13
|
* `undefined` instead of throwing — for methods whose failure is a state the
|
|
14
14
|
* caller expects and handles, not an exception. */
|
|
15
15
|
export declare function tryRpc<T>(rpcUrl: string, method: string, params?: unknown[], opts?: RpcOptions): Promise<T | undefined>;
|
|
16
|
-
/** One HTTP round trip carrying many calls; results come back in call order. */
|
|
17
|
-
export declare function rpcBatch<T>(rpcUrl: string, calls: {
|
|
18
|
-
method: string;
|
|
19
|
-
params: unknown[];
|
|
20
|
-
}[], opts?: RpcOptions): Promise<T[]>;
|
|
21
16
|
//# sourceMappingURL=jsonrpc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonrpc.d.ts","sourceRoot":"","sources":["../../src/transport/jsonrpc.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,qBAAa,WAAY,SAAQ,KAAK;IACjB,IAAI,EAAE,MAAM,GAAG,SAAS;gBAAxB,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM;CAI7D;AAED;6EAC6E;AAC7E,wBAAsB,GAAG,CAAC,CAAC,EACzB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,OAAO,EAAO,EACtB,IAAI,CAAC,EAAE,UAAU,GAChB,OAAO,CAAC,CAAC,CAAC,CAYZ;AAED;;mDAEmD;AACnD,wBAAsB,MAAM,CAAC,CAAC,EAC5B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,OAAO,EAAO,EACtB,IAAI,CAAC,EAAE,UAAU,GAChB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAMxB
|
|
1
|
+
{"version":3,"file":"jsonrpc.d.ts","sourceRoot":"","sources":["../../src/transport/jsonrpc.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,qBAAa,WAAY,SAAQ,KAAK;IACjB,IAAI,EAAE,MAAM,GAAG,SAAS;gBAAxB,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM;CAI7D;AAED;6EAC6E;AAC7E,wBAAsB,GAAG,CAAC,CAAC,EACzB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,OAAO,EAAO,EACtB,IAAI,CAAC,EAAE,UAAU,GAChB,OAAO,CAAC,CAAC,CAAC,CAYZ;AAED;;mDAEmD;AACnD,wBAAsB,MAAM,CAAC,CAAC,EAC5B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,OAAO,EAAO,EACtB,IAAI,CAAC,EAAE,UAAU,GAChB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAMxB"}
|
|
@@ -39,24 +39,4 @@ export async function tryRpc(rpcUrl, method, params = [], opts) {
|
|
|
39
39
|
return undefined;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
/** One HTTP round trip carrying many calls; results come back in call order. */
|
|
43
|
-
export async function rpcBatch(rpcUrl, calls, opts) {
|
|
44
|
-
const doFetch = opts?.fetch ?? fetch;
|
|
45
|
-
const res = await doFetch(rpcUrl, {
|
|
46
|
-
method: "POST",
|
|
47
|
-
headers: { "content-type": "application/json" },
|
|
48
|
-
body: JSON.stringify(calls.map((c, id) => ({ jsonrpc: "2.0", id, ...c }))),
|
|
49
|
-
signal: opts?.signal,
|
|
50
|
-
});
|
|
51
|
-
const json = (await res.json());
|
|
52
|
-
if (!Array.isArray(json))
|
|
53
|
-
throw new PodRpcError(undefined, "batch response is not an array");
|
|
54
|
-
const out = new Array(calls.length);
|
|
55
|
-
for (const r of json) {
|
|
56
|
-
if (r.error)
|
|
57
|
-
throw new PodRpcError(r.error.code, r.error.message ?? `${calls[r.id]?.method} failed`);
|
|
58
|
-
out[r.id] = r.result;
|
|
59
|
-
}
|
|
60
|
-
return out;
|
|
61
|
-
}
|
|
62
42
|
//# sourceMappingURL=jsonrpc.js.map
|
|
@@ -1 +1 @@
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C,KAAK;QAAE,MAAM,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,GAAG,MAAM,SAAS,CAAC,CAAC;IACjG,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;QAAE,MAAM,IAAI,WAAW,CAAC,SAAS,EAAE,GAAG,MAAM,qBAAqB,CAAC,CAAC;IAChG,OAAO,IAAI,CAAC,MAAM,CAAC;AACrB,CAAC;AAED;;mDAEmD;AACnD,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,MAAc,EACd,MAAc,EACd,SAAoB,EAAE,EACtB,IAAiB;IAEjB,IAAI,CAAC;QACH,OAAO,MAAM,GAAG,CAAI,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/transport/rest.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WireFillRow, WireSolutionRow } from "../types/wire.js";
|
|
2
|
+
import type { ActivityEntry, ActivityType, Address, BackstopTransfer, Balances, Bar, BridgeConfig, CandleQuery, Market, MarketId, Order, Orderbook, PositionsSnapshot, Resolution, Status, Trigger, TxExplorer, Withdrawal, WithdrawalsQuery } from "../types/public.js";
|
|
2
3
|
export type MarketDynamicsPatch = Partial<Market> & {
|
|
3
4
|
id: string;
|
|
4
5
|
};
|
|
@@ -12,6 +13,11 @@ export interface OrdersPage {
|
|
|
12
13
|
totalCount: number;
|
|
13
14
|
solutionNow: number;
|
|
14
15
|
}
|
|
16
|
+
export interface ActivityPage {
|
|
17
|
+
activity: ActivityEntry[];
|
|
18
|
+
nextCursor: string | null;
|
|
19
|
+
solutionNow: number;
|
|
20
|
+
}
|
|
15
21
|
export interface BackstopPage {
|
|
16
22
|
transfers: BackstopTransfer[];
|
|
17
23
|
totalCount: number;
|
|
@@ -36,6 +42,13 @@ export interface OrdersQueryRest {
|
|
|
36
42
|
limit?: number;
|
|
37
43
|
cursor?: string;
|
|
38
44
|
}
|
|
45
|
+
export interface ActivityQueryRest {
|
|
46
|
+
limit?: number;
|
|
47
|
+
cursor?: string;
|
|
48
|
+
types?: ActivityType[];
|
|
49
|
+
from?: number;
|
|
50
|
+
to?: number;
|
|
51
|
+
}
|
|
39
52
|
export interface TriggersQueryRest {
|
|
40
53
|
orderbook?: MarketId;
|
|
41
54
|
limit?: number;
|
|
@@ -73,6 +86,28 @@ export declare class PodRestClient {
|
|
|
73
86
|
}): Promise<MarketStatsPage>;
|
|
74
87
|
candles(id: MarketId, q: CandleQuery): Promise<CandlesPage>;
|
|
75
88
|
orders(account: Address, q?: OrdersQueryRest): Promise<OrdersPage>;
|
|
89
|
+
/**
|
|
90
|
+
* One account's activity, newest first: orders at their placement tick, and the
|
|
91
|
+
* money that moved (ADR 0057 §5). The seed behind `pod_activity`; page it
|
|
92
|
+
* with `cursor`.
|
|
93
|
+
*/
|
|
94
|
+
activity(account: Address, q?: ActivityQueryRest): Promise<ActivityPage>;
|
|
95
|
+
/** An account's fills with `fromUs ≤ timestamp < toUs`, newest first, at
|
|
96
|
+
* most 500; page by moving `toUs` down to the oldest timestamp seen. */
|
|
97
|
+
fills(account: Address, q: {
|
|
98
|
+
fromUs: number;
|
|
99
|
+
toUs?: number;
|
|
100
|
+
orderbook?: MarketId;
|
|
101
|
+
limit?: number;
|
|
102
|
+
}): Promise<WireFillRow[]>;
|
|
103
|
+
/** Solutions rows, newest first, with `sinceUs ≤ timestamp < untilUs`;
|
|
104
|
+
* `limit` counts ticks, so one tick returns every market's row. */
|
|
105
|
+
solutions(q: {
|
|
106
|
+
orderbook?: MarketId;
|
|
107
|
+
sinceUs?: number;
|
|
108
|
+
untilUs?: number;
|
|
109
|
+
limit?: number;
|
|
110
|
+
}): Promise<WireSolutionRow[]>;
|
|
76
111
|
backstopTransfers(account: Address): Promise<BackstopPage>;
|
|
77
112
|
orderbook(id: MarketId): Promise<Orderbook>;
|
|
78
113
|
/** Perp positions + account aggregates (spot holdings are at `/clob/balances`). */
|
|
@@ -82,9 +117,6 @@ export declare class PodRestClient {
|
|
|
82
117
|
/** Flat explorer view of a transaction (fields, receipt, logs, attestations,
|
|
83
118
|
* decoded calldata). Returned as-is (hex fields raw). */
|
|
84
119
|
transaction(hash: string): Promise<TxExplorer>;
|
|
85
|
-
/** Accounts ranked by net PnL (realized + unrealized), descending. Paginate
|
|
86
|
-
* with `{ limit, offset }`; ranks are 1-based over the full ordering. */
|
|
87
|
-
leaderboard(q?: LeaderboardQuery): Promise<LeaderboardPage>;
|
|
88
120
|
/** Static bridge config: the claim chain, the bridge contract, and every
|
|
89
121
|
* bridged token's L1 address, decimals and withdraw window (ADR 0033 §5).
|
|
90
122
|
* Served unconditionally — it is not behind the CLOB indexer's gate. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../src/transport/rest.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,GAAG,EAAE,YAAY,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../src/transport/rest.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EACV,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,GAAG,EAAE,YAAY,EAAE,WAAW,EAChG,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EACzE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAClD,MAAM,oBAAoB,CAAC;AAa5B,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,M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,GAAG,OAAO,CAAC,YAAY,CAAC;CAW/E"}
|
package/dist/transport/rest.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Layer 1: typed one-shot REST reads of `/clob/*`. Plain fetch so the browser /
|
|
2
2
|
// CDN honor the server's Cache-Control; identical concurrent GETs are deduped.
|
|
3
3
|
// ms in, decoded (bigint / ms) out.
|
|
4
|
-
import { decodeBackstopTransfer, decodeBalances, decodeBridgeConfig, decodeCandle,
|
|
5
|
-
import { msToSecs, usToMs } from "../codec/units.js";
|
|
4
|
+
import { decodeActivityEntry, decodeBackstopTransfer, decodeBalances, decodeBridgeConfig, decodeCandle, decodeMarketDynamics, decodeMarketStatic, decodeOrder, decodeOrderbook, decodePositions, decodeStatus, decodeTrigger, decodeWithdrawal, } from "../codec/decode.js";
|
|
5
|
+
import { msToSecs, msToUs, usToMs } from "../codec/units.js";
|
|
6
6
|
export class PodHttpError extends Error {
|
|
7
7
|
status;
|
|
8
8
|
url;
|
|
@@ -106,6 +106,47 @@ export class PodRestClient {
|
|
|
106
106
|
solutionNow: Math.trunc(w.solution_now / 1000),
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* One account's activity, newest first: orders at their placement tick, and the
|
|
111
|
+
* money that moved (ADR 0057 §5). The seed behind `pod_activity`; page it
|
|
112
|
+
* with `cursor`.
|
|
113
|
+
*/
|
|
114
|
+
async activity(account, q) {
|
|
115
|
+
const w = await this.get(`/clob/activity/${account}`, {
|
|
116
|
+
limit: q?.limit,
|
|
117
|
+
cursor: q?.cursor,
|
|
118
|
+
activity_types: q?.types?.length ? q.types.join(",") : undefined,
|
|
119
|
+
from: q?.from !== undefined ? msToUs(q.from) : undefined,
|
|
120
|
+
to: q?.to !== undefined ? msToUs(q.to) : undefined,
|
|
121
|
+
});
|
|
122
|
+
return {
|
|
123
|
+
activity: w.activity.map(decodeActivityEntry).filter((e) => e !== undefined),
|
|
124
|
+
nextCursor: w.next_cursor,
|
|
125
|
+
solutionNow: usToMs(w.solution_now),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** An account's fills with `fromUs ≤ timestamp < toUs`, newest first, at
|
|
129
|
+
* most 500; page by moving `toUs` down to the oldest timestamp seen. */
|
|
130
|
+
async fills(account, q) {
|
|
131
|
+
const w = await this.get(`/clob/fills/${account}`, {
|
|
132
|
+
from_us: q.fromUs,
|
|
133
|
+
to_us: q.toUs,
|
|
134
|
+
orderbook: q.orderbook,
|
|
135
|
+
limit: q.limit,
|
|
136
|
+
});
|
|
137
|
+
return w.fills;
|
|
138
|
+
}
|
|
139
|
+
/** Solutions rows, newest first, with `sinceUs ≤ timestamp < untilUs`;
|
|
140
|
+
* `limit` counts ticks, so one tick returns every market's row. */
|
|
141
|
+
async solutions(q) {
|
|
142
|
+
const w = await this.get(`/clob/solutions`, {
|
|
143
|
+
orderbook: q.orderbook,
|
|
144
|
+
since_us: q.sinceUs,
|
|
145
|
+
until_us: q.untilUs,
|
|
146
|
+
limit: q.limit,
|
|
147
|
+
});
|
|
148
|
+
return w.solutions;
|
|
149
|
+
}
|
|
109
150
|
async backstopTransfers(account) {
|
|
110
151
|
const w = await this.get(`/clob/backstop-transfers/${account}`);
|
|
111
152
|
return {
|
|
@@ -130,14 +171,6 @@ export class PodRestClient {
|
|
|
130
171
|
async transaction(hash) {
|
|
131
172
|
return this.get(`/tx/${hash}`);
|
|
132
173
|
}
|
|
133
|
-
/** Accounts ranked by net PnL (realized + unrealized), descending. Paginate
|
|
134
|
-
* with `{ limit, offset }`; ranks are 1-based over the full ordering. */
|
|
135
|
-
async leaderboard(q) {
|
|
136
|
-
const w = await this.get("/clob/leaderboard", {
|
|
137
|
-
limit: q?.limit, offset: q?.offset, address: q?.account,
|
|
138
|
-
});
|
|
139
|
-
return decodeLeaderboard(w, q?.offset ?? 0);
|
|
140
|
-
}
|
|
141
174
|
/** Static bridge config: the claim chain, the bridge contract, and every
|
|
142
175
|
* bridged token's L1 address, decimals and withdraw window (ADR 0033 §5).
|
|
143
176
|
* Served unconditionally — it is not behind the CLOB indexer's gate. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../src/transport/rest.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+EAA+E;AAC/E,oCAAoC;
|
|
1
|
+
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../src/transport/rest.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+EAA+E;AAC/E,oCAAoC;AAapC,OAAO,EACL,mBAAmB,EAAE,sBAAsB,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAC7F,oBAAoB,EAAE,kBAAkB,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EACvF,YAAY,EAAE,aAAa,EAAE,gBAAgB,GAC9C,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAqD7D,MAAM,OAAO,YAAa,SAAQ,KAAK;IAClB;IAAuB;IAA1C,YAAmB,MAAc,EAAS,GAAW,EAAE,OAAe;QACpE,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,WAAM,GAAN,MAAM,CAAQ;QAAS,QAAG,GAAH,GAAG,CAAQ;QAEnD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAgBD,MAAM,OAAO,aAAa;IACP,IAAI,CAAS;IACb,OAAO,CAAU;IACjB,SAAS,CAAS;IAClB,QAAQ,GAAG,IAAI,GAAG,EAA4B,CAAC;IAEhE,YAAY,IAAuB;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/D,IAAI,CAA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AE,EAAE;YACtE,SAAS,EAAE,CAAC,EAAE,SAAS;YACvB,KAAK,EAAE,CAAC,EAAE,KAAK;SAChB,CAAC,CAAC;QACH,OAAO;YACL,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC;YACvC,UAAU,EAAE,CAAC,CAAC,WAAW;YACzB,UAAU,EAAE,CAAC,CAAC,WAAW;SAC1B,CAAC;IACJ,CAAC;CACF"}
|
package/dist/transport/ws.d.ts
CHANGED
|
@@ -2,7 +2,11 @@ import type { Address, MarketId } from "../types/public.js";
|
|
|
2
2
|
export type Channel = "pod_orderbook" | "pod_orders_v2" | "pod_candles" | "pod_markets" | "pod_positions" | "pod_triggers"
|
|
3
3
|
/** Terminal withdrawal outcomes; one array per tick, `account`-filtered on the
|
|
4
4
|
* debited account. ADR 0033 §6. */
|
|
5
|
-
| "pod_withdrawals"
|
|
5
|
+
| "pod_withdrawals"
|
|
6
|
+
/** One account's whole activity: `pod_orders_v2` for every book the tick
|
|
7
|
+
* cleared, plus the money it moved. One frame per tick, so `since` alone
|
|
8
|
+
* resumes it. ADR 0057 §6. */
|
|
9
|
+
| "pod_activity";
|
|
6
10
|
export interface SubParams {
|
|
7
11
|
clobIds?: MarketId[];
|
|
8
12
|
account?: Address;
|