@pod-network/trade-sdk 0.2.0 → 0.4.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 +94 -2
- package/dist/client.d.ts +19 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +25 -13
- package/dist/client.js.map +1 -1
- package/dist/codec/bridge.d.ts +82 -0
- package/dist/codec/bridge.d.ts.map +1 -0
- package/dist/codec/bridge.js +114 -0
- package/dist/codec/bridge.js.map +1 -0
- package/dist/codec/decode.d.ts +15 -2
- package/dist/codec/decode.d.ts.map +1 -1
- package/dist/codec/decode.js +46 -6
- package/dist/codec/decode.js.map +1 -1
- package/dist/codec/direction.d.ts +10 -0
- package/dist/codec/direction.d.ts.map +1 -0
- package/dist/codec/direction.js +46 -0
- package/dist/codec/direction.js.map +1 -0
- package/dist/codec/orders-v2.d.ts +19 -0
- package/dist/codec/orders-v2.d.ts.map +1 -0
- package/dist/codec/orders-v2.js +200 -0
- package/dist/codec/orders-v2.js.map +1 -0
- package/dist/codec/units.d.ts +10 -0
- package/dist/codec/units.d.ts.map +1 -1
- package/dist/codec/units.js +25 -1
- package/dist/codec/units.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/sync/orders.d.ts +71 -16
- package/dist/sync/orders.d.ts.map +1 -1
- package/dist/sync/orders.js +202 -83
- package/dist/sync/orders.js.map +1 -1
- package/dist/sync/sources.d.ts +5 -1
- package/dist/sync/sources.d.ts.map +1 -1
- package/dist/sync/sources.js +16 -0
- package/dist/sync/sources.js.map +1 -1
- package/dist/sync/withdrawals.d.ts +5 -0
- package/dist/sync/withdrawals.d.ts.map +1 -0
- package/dist/sync/withdrawals.js +172 -0
- package/dist/sync/withdrawals.js.map +1 -0
- package/dist/transport/claim.d.ts +160 -0
- package/dist/transport/claim.d.ts.map +1 -0
- package/dist/transport/claim.js +341 -0
- package/dist/transport/claim.js.map +1 -0
- package/dist/transport/jsonrpc.d.ts +16 -0
- package/dist/transport/jsonrpc.d.ts.map +1 -0
- package/dist/transport/jsonrpc.js +42 -0
- package/dist/transport/jsonrpc.js.map +1 -0
- package/dist/transport/rest.d.ts +15 -1
- package/dist/transport/rest.d.ts.map +1 -1
- package/dist/transport/rest.js +25 -1
- package/dist/transport/rest.js.map +1 -1
- package/dist/transport/ws.d.ts +22 -2
- package/dist/transport/ws.d.ts.map +1 -1
- package/dist/transport/ws.js +14 -2
- package/dist/transport/ws.js.map +1 -1
- package/dist/types/public.d.ts +212 -9
- package/dist/types/public.d.ts.map +1 -1
- package/dist/types/wire.d.ts +147 -41
- package/dist/types/wire.d.ts.map +1 -1
- package/dist/write/delegation.d.ts.map +1 -1
- package/dist/write/delegation.js +2 -12
- package/dist/write/delegation.js.map +1 -1
- package/dist/write/index.d.ts +26 -1
- package/dist/write/index.d.ts.map +1 -1
- package/dist/write/index.js +21 -14
- package/dist/write/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +33 -18
- package/src/codec/bridge.ts +138 -0
- package/src/codec/decode.ts +54 -10
- package/src/codec/direction.ts +36 -0
- package/src/codec/orders-v2.ts +222 -0
- package/src/codec/units.ts +24 -1
- package/src/index.ts +16 -0
- package/src/sync/orders.ts +203 -83
- package/src/sync/sources.ts +16 -1
- package/src/sync/withdrawals.ts +177 -0
- package/src/transport/claim.ts +434 -0
- package/src/transport/jsonrpc.ts +54 -0
- package/src/transport/rest.ts +35 -7
- package/src/transport/ws.ts +30 -4
- package/src/types/public.ts +233 -7
- package/src/types/wire.ts +161 -29
- package/src/write/delegation.ts +2 -12
- package/src/write/index.ts +59 -13
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direction.d.ts","sourceRoot":"","sources":["../../src/codec/direction.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,CAenF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// What a perp fill did to the owner's position: opened, added to, reduced, closed
|
|
2
|
+
// or flipped it.
|
|
3
|
+
//
|
|
4
|
+
// A port of `classify_perp_order_direction` in `node/src/rpc/types.rs`, branch for
|
|
5
|
+
// branch and in the same order. It exists because the two sources of an order's
|
|
6
|
+
// direction have to agree: REST sends the server's label on `OrderResponse`, while
|
|
7
|
+
// `pod_orders_v2` sends the raw position and leaves the classification to the
|
|
8
|
+
// client. A divergence here would show one label on a streamed row and another after
|
|
9
|
+
// a refetch — so this file is a transcription, not an interpretation, and the test
|
|
10
|
+
// pins every branch.
|
|
11
|
+
/**
|
|
12
|
+
* Classify a position transition.
|
|
13
|
+
*
|
|
14
|
+
* `before` is not on the wire: it is `after - sign(size) * filledThisFill`, which is
|
|
15
|
+
* the same arithmetic the engine used to produce the pair (`buy_bookends` /
|
|
16
|
+
* `sell_bookends` in `trading/src/book.rs`), so deriving it loses nothing.
|
|
17
|
+
*/
|
|
18
|
+
export function classifyPerpDirection(before, after) {
|
|
19
|
+
if (before === 0n && after === 0n)
|
|
20
|
+
return "reduce_long";
|
|
21
|
+
if (before === after)
|
|
22
|
+
return before > 0n ? "reduce_long" : "reduce_short";
|
|
23
|
+
if (before === 0n && after > 0n)
|
|
24
|
+
return "open_long";
|
|
25
|
+
if (before === 0n && after < 0n)
|
|
26
|
+
return "open_short";
|
|
27
|
+
if (before > 0n && after === 0n)
|
|
28
|
+
return "close_long";
|
|
29
|
+
if (before < 0n && after === 0n)
|
|
30
|
+
return "close_short";
|
|
31
|
+
if (before > 0n && after < 0n)
|
|
32
|
+
return "long_to_short";
|
|
33
|
+
if (before < 0n && after > 0n)
|
|
34
|
+
return "short_to_long";
|
|
35
|
+
if (before > 0n && after > before)
|
|
36
|
+
return "add_long";
|
|
37
|
+
if (before > 0n && after < before)
|
|
38
|
+
return "reduce_long";
|
|
39
|
+
if (before < 0n && after < before)
|
|
40
|
+
return "add_short";
|
|
41
|
+
if (before < 0n && after > before)
|
|
42
|
+
return "reduce_short";
|
|
43
|
+
// Unreachable, and the Rust returns the same rather than erroring.
|
|
44
|
+
return "open_long";
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=direction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direction.js","sourceRoot":"","sources":["../../src/codec/direction.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,iBAAiB;AACjB,EAAE;AACF,mFAAmF;AACnF,gFAAgF;AAChF,mFAAmF;AACnF,8EAA8E;AAC9E,qFAAqF;AACrF,mFAAmF;AACnF,qBAAqB;AAIrB;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc,EAAE,KAAa;IACjE,IAAI,MAAM,KAAK,EAAE,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,aAAa,CAAC;IACxD,IAAI,MAAM,KAAK,KAAK;QAAE,OAAO,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,CAAC;IAC1E,IAAI,MAAM,KAAK,EAAE,IAAI,KAAK,GAAG,EAAE;QAAE,OAAO,WAAW,CAAC;IACpD,IAAI,MAAM,KAAK,EAAE,IAAI,KAAK,GAAG,EAAE;QAAE,OAAO,YAAY,CAAC;IACrD,IAAI,MAAM,GAAG,EAAE,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,YAAY,CAAC;IACrD,IAAI,MAAM,GAAG,EAAE,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,aAAa,CAAC;IACtD,IAAI,MAAM,GAAG,EAAE,IAAI,KAAK,GAAG,EAAE;QAAE,OAAO,eAAe,CAAC;IACtD,IAAI,MAAM,GAAG,EAAE,IAAI,KAAK,GAAG,EAAE;QAAE,OAAO,eAAe,CAAC;IACtD,IAAI,MAAM,GAAG,EAAE,IAAI,KAAK,GAAG,MAAM;QAAE,OAAO,UAAU,CAAC;IACrD,IAAI,MAAM,GAAG,EAAE,IAAI,KAAK,GAAG,MAAM;QAAE,OAAO,aAAa,CAAC;IACxD,IAAI,MAAM,GAAG,EAAE,IAAI,KAAK,GAAG,MAAM;QAAE,OAAO,WAAW,CAAC;IACtD,IAAI,MAAM,GAAG,EAAE,IAAI,KAAK,GAAG,MAAM;QAAE,OAAO,cAAc,CAAC;IACzD,mEAAmE;IACnE,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Address, Order, OrderEvent } from "../types/public.js";
|
|
2
|
+
import type { WireOrdersFrame } from "../types/wire.js";
|
|
3
|
+
export interface OrdersFrameContext {
|
|
4
|
+
/** The account the subscription is filtered to, used when the frame omits `accts`. */
|
|
5
|
+
account: Address;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Fold one frame into `byId`, in place, and report the transitions it applied.
|
|
9
|
+
*
|
|
10
|
+
* Events naming an order that is not in `byId` and not in this frame are skipped:
|
|
11
|
+
* they belong to an order resting outside the caller's window, and its terms have
|
|
12
|
+
* never been on the wire, so there is nothing to display — and nothing to report.
|
|
13
|
+
*
|
|
14
|
+
* The returned events carry the order as the *whole* frame left it, not as it stood
|
|
15
|
+
* mid-frame: they are collected while applying but the rows are mutated in place, so a
|
|
16
|
+
* consumer never sees a half-applied order.
|
|
17
|
+
*/
|
|
18
|
+
export declare function applyOrdersFrame(frame: WireOrdersFrame, byId: Map<string, Order>, ctx: OrdersFrameContext): OrderEvent[];
|
|
19
|
+
//# sourceMappingURL=orders-v2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orders-v2.d.ts","sourceRoot":"","sources":["../../src/codec/orders-v2.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,OAAO,EAAkB,KAAK,EAAE,UAAU,EAE3C,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAmC,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKzF,MAAM,WAAW,kBAAkB;IACjC,sFAAsF;IACtF,OAAO,EAAE,OAAO,CAAC;CAClB;AAQD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,kBAAkB,GAAG,UAAU,EAAE,CAsCxH"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// `pod_orders_v2` frames -> the public `Order` map (ADR 0029).
|
|
2
|
+
//
|
|
3
|
+
// A frame is entity/event shaped: identity and terms cross the wire once, in
|
|
4
|
+
// `orders`, and everything after that is a reference. So decoding is two passes —
|
|
5
|
+
// materialize this batch's entities, then let the events say what happened to
|
|
6
|
+
// them and to orders already held. Status lives only in the events, which is what
|
|
7
|
+
// lets the server add transition kinds without changing the entity.
|
|
8
|
+
import { dec, endMsFromUs, usToMs } from "./units.js";
|
|
9
|
+
import { div } from "./fixed.js";
|
|
10
|
+
import { classifyPerpDirection } from "./direction.js";
|
|
11
|
+
/**
|
|
12
|
+
* Fold one frame into `byId`, in place, and report the transitions it applied.
|
|
13
|
+
*
|
|
14
|
+
* Events naming an order that is not in `byId` and not in this frame are skipped:
|
|
15
|
+
* they belong to an order resting outside the caller's window, and its terms have
|
|
16
|
+
* never been on the wire, so there is nothing to display — and nothing to report.
|
|
17
|
+
*
|
|
18
|
+
* The returned events carry the order as the *whole* frame left it, not as it stood
|
|
19
|
+
* mid-frame: they are collected while applying but the rows are mutated in place, so a
|
|
20
|
+
* consumer never sees a half-applied order.
|
|
21
|
+
*/
|
|
22
|
+
export function applyOrdersFrame(frame, byId, ctx) {
|
|
23
|
+
// The book and the batch are frame constants: resolved once, not per entity.
|
|
24
|
+
const batchMs = usToMs(frame.batch);
|
|
25
|
+
const facts = { batchMs, accts: frame.accts };
|
|
26
|
+
const created = frame.orders.map((e) => decodeEntity(e, frame, batchMs, ctx.account));
|
|
27
|
+
const applied = [];
|
|
28
|
+
for (const event of frame.events) {
|
|
29
|
+
// `o` indexes this frame's entities and `id` names one resting from an earlier
|
|
30
|
+
// batch — but an event kind added later (ADR 0029 §6 reserves several) may name
|
|
31
|
+
// an entity from *this* frame by id, so try both before giving up. `created` is
|
|
32
|
+
// not in `byId` yet: entities are inserted after the events, so their own
|
|
33
|
+
// `new`/`reject` decides the status they land with.
|
|
34
|
+
const target = event.o !== undefined
|
|
35
|
+
? created[event.o]
|
|
36
|
+
: byId.get(event.id ?? "") ?? created.find((o) => o.id === event.id);
|
|
37
|
+
if (!target)
|
|
38
|
+
continue;
|
|
39
|
+
// `undefined` means a kind this version does not know, which is ignored rather than
|
|
40
|
+
// handed on as an event a consumer cannot act on (ADR 0029 §6). The switch is the
|
|
41
|
+
// only list of what is recognised — a separate one could disagree with it.
|
|
42
|
+
const outcome = applyEvent(event, target, facts);
|
|
43
|
+
if (outcome) {
|
|
44
|
+
applied.push({
|
|
45
|
+
kind: event.k,
|
|
46
|
+
order: target,
|
|
47
|
+
batchMs,
|
|
48
|
+
fill: outcome.fill,
|
|
49
|
+
amendRejection: outcome.amendRejection,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// After the events, not before: an entity's own `new`/`reject` decides the
|
|
54
|
+
// status it lands with. Entities left untouched by every event this version
|
|
55
|
+
// understands are still inserted — the frame said the order exists, and a
|
|
56
|
+
// transition from a newer server is no reason to drop the row.
|
|
57
|
+
for (const order of created)
|
|
58
|
+
byId.set(order.id, order);
|
|
59
|
+
return applied;
|
|
60
|
+
}
|
|
61
|
+
function decodeEntity(e, frame, batchMs, account) {
|
|
62
|
+
const initialSize = dec(e.sz);
|
|
63
|
+
return {
|
|
64
|
+
id: e.id,
|
|
65
|
+
txHash: e.tx,
|
|
66
|
+
// The frame names the book, so this is exact rather than inferred. Whether
|
|
67
|
+
// that book is spot or perp is static market metadata, joined at read time by
|
|
68
|
+
// whoever needs it — freezing it here would strand every order decoded before
|
|
69
|
+
// the markets list loaded.
|
|
70
|
+
orderbookId: frame.book,
|
|
71
|
+
side: initialSize < 0n ? "sell" : "buy",
|
|
72
|
+
orderType: e.type === "market" ? "market" : "limit",
|
|
73
|
+
// Not on the entity: an order that rests is `active`, and the events below
|
|
74
|
+
// move it from there.
|
|
75
|
+
status: "active",
|
|
76
|
+
kind: (e.kind ?? "user_signed"),
|
|
77
|
+
nonce: e.n,
|
|
78
|
+
// A frame with no `accts` covers exactly one account, so every row is its. An
|
|
79
|
+
// index the table does not reach falls back the same way rather than becoming an
|
|
80
|
+
// `undefined` typed as an address.
|
|
81
|
+
bidder: (e.a !== undefined ? frame.accts?.[e.a] : undefined) ?? account,
|
|
82
|
+
price: dec(e.px),
|
|
83
|
+
initialSize,
|
|
84
|
+
filledBase: 0n,
|
|
85
|
+
filledQuote: 0n,
|
|
86
|
+
fee: 0n,
|
|
87
|
+
endMs: endMsFromUs(e.end),
|
|
88
|
+
// When the order became real. The signed deadline is not on this wire and is
|
|
89
|
+
// deliberately not invented from the batch: REST reports both separately, so
|
|
90
|
+
// inclusion time is the one thing every source agrees on and the only honest
|
|
91
|
+
// key to order by.
|
|
92
|
+
includedMs: batchMs,
|
|
93
|
+
fills: [],
|
|
94
|
+
reduceOnly: e.reduce_only ?? false,
|
|
95
|
+
ioc: e.ioc ?? false,
|
|
96
|
+
triggerType: e.trigger,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Take the order's life-to-date totals off the event that reports them.
|
|
101
|
+
*
|
|
102
|
+
* Every fill, cancel and expiry carries all three, zero included (ADR 0029 §4.1) —
|
|
103
|
+
* so they are read unconditionally, and an order that leaves the book reports what
|
|
104
|
+
* it filled rather than keeping whatever it last had. Authoritative rather than
|
|
105
|
+
* accumulated, so a client that missed a fill cannot drift.
|
|
106
|
+
*/
|
|
107
|
+
function applyTotals(event, order) {
|
|
108
|
+
order.filledBase = dec(event.tb);
|
|
109
|
+
order.filledQuote = dec(event.tq);
|
|
110
|
+
order.fee = dec(event.tf);
|
|
111
|
+
// Cleared, not skipped, when nothing is filled: a row reporting zero filled beside
|
|
112
|
+
// a fill price from before is worse than one with no fill price.
|
|
113
|
+
order.effectivePrice = order.filledBase > 0n ? div(order.filledQuote, order.filledBase) : undefined;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Apply one event. `undefined` when the kind is not one this version knows; otherwise what
|
|
117
|
+
* the event contributed beyond the order's own state — the fill, or the refused amendment.
|
|
118
|
+
*/
|
|
119
|
+
function applyEvent(event, order, facts) {
|
|
120
|
+
switch (event.k) {
|
|
121
|
+
case "new":
|
|
122
|
+
order.status = "active";
|
|
123
|
+
return {};
|
|
124
|
+
case "reject":
|
|
125
|
+
order.status = "invalid";
|
|
126
|
+
order.rejectReason = event.why;
|
|
127
|
+
return {};
|
|
128
|
+
case "cancel":
|
|
129
|
+
order.status = "canceled";
|
|
130
|
+
applyTotals(event, order);
|
|
131
|
+
return {};
|
|
132
|
+
case "expire":
|
|
133
|
+
order.status = "expired";
|
|
134
|
+
applyTotals(event, order);
|
|
135
|
+
return {};
|
|
136
|
+
case "modify": {
|
|
137
|
+
order.price = dec(event.px);
|
|
138
|
+
// `sz` is an unsigned magnitude, so the side comes from the order we hold.
|
|
139
|
+
const sign = order.initialSize < 0n ? -1n : 1n;
|
|
140
|
+
order.initialSize = sign * dec(event.sz);
|
|
141
|
+
return {};
|
|
142
|
+
}
|
|
143
|
+
case "fill": {
|
|
144
|
+
applyTotals(event, order);
|
|
145
|
+
// `b`/`q` are this fill alone, and its time is the batch it cleared in — the
|
|
146
|
+
// auction's own timestamp rather than when this client happened to read it.
|
|
147
|
+
const base = dec(event.b);
|
|
148
|
+
const quote = dec(event.q);
|
|
149
|
+
const fill = { base, quote, price: div(quote, base), time: facts.batchMs };
|
|
150
|
+
// A real fill always has size. A zero-size one is the engine flipping status: the
|
|
151
|
+
// cap-to-filled amendment fabricates it so `st: filled` reaches the indexer, which
|
|
152
|
+
// reads status from fills alone. Its totals and status count; adding a
|
|
153
|
+
// `0.0000 @ $0.00` row to the order's fill history would only invent a trade.
|
|
154
|
+
if (base !== 0n)
|
|
155
|
+
order.fills = [...order.fills, fill];
|
|
156
|
+
// A perp fill reports the position it left. The position it started from is
|
|
157
|
+
// that minus what this fill moved it — a buy raises it, a sell lowers it — and
|
|
158
|
+
// the transition is what says whether the order opened, added to, reduced,
|
|
159
|
+
// closed or flipped. Without it a client can only guess from the order's own
|
|
160
|
+
// side and `reduceOnly`, which calls a plain sell that closed a long an
|
|
161
|
+
// "Open Short".
|
|
162
|
+
if (event.pa !== undefined) {
|
|
163
|
+
const after = dec(event.pa);
|
|
164
|
+
const before = after - (order.initialSize < 0n ? -base : base);
|
|
165
|
+
// A forced close is labelled by how it came about, not by the transition it
|
|
166
|
+
// made — `order_direction_for_response` overrides the classifier the same way,
|
|
167
|
+
// and without this a liquidation reads `close_long` here and `liquidation`
|
|
168
|
+
// after a REST refetch.
|
|
169
|
+
order.direction = order.kind === "liquidation" ? "liquidation" : classifyPerpDirection(before, after);
|
|
170
|
+
}
|
|
171
|
+
// Present only on the fill that closed the order.
|
|
172
|
+
if (event.st)
|
|
173
|
+
order.status = event.st;
|
|
174
|
+
// Copied rather than shared: the same object is in `order.fills`, and attaching a
|
|
175
|
+
// per-event field to it would leak the event into the order's fill history.
|
|
176
|
+
return {
|
|
177
|
+
fill: { ...fill, totalBase: dec(event.tb), closedAs: event.st },
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
case "modify_reject":
|
|
181
|
+
// Reported, not applied: this answers an amendment that did not happen, so the order
|
|
182
|
+
// is left exactly as it was — which is also why it belongs to the event and not to
|
|
183
|
+
// the order. Without it a refused price change looks like one still in flight.
|
|
184
|
+
// `by` is the requester, not the owner — on `not_order_owner` it is precisely who
|
|
185
|
+
// does not own the order — so it is resolved separately from `a`.
|
|
186
|
+
return {
|
|
187
|
+
amendRejection: {
|
|
188
|
+
requestedPrice: dec(event.req_px),
|
|
189
|
+
requestedSize: dec(event.req_sz),
|
|
190
|
+
code: (event.code ?? "unspecified"),
|
|
191
|
+
message: event.why,
|
|
192
|
+
requestedBy: event.by !== undefined ? facts.accts?.[event.by] : undefined,
|
|
193
|
+
batchMs: facts.batchMs,
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
// ADR 0029 §6: kinds are open, so an unrecognised one falls through to
|
|
197
|
+
// `undefined` — applied to nothing, reported to nobody.
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=orders-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orders-v2.js","sourceRoot":"","sources":["../../src/codec/orders-v2.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,EAAE;AACF,6EAA6E;AAC7E,kFAAkF;AAClF,8EAA8E;AAC9E,kFAAkF;AAClF,oEAAoE;AAOpE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAavD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAsB,EAAE,IAAwB,EAAE,GAAuB;IACxG,6EAA6E;IAC7E,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,KAAK,GAAe,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IAC1D,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAEtF,MAAM,OAAO,GA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CAAC,CAAC,qBAAqB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACxG,CAAC;YACD,kDAAkD;YAClD,IAAI,KAAK,CAAC,EAAE;gBAAE,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,EAAiB,CAAC;YACrD,kFAAkF;YAClF,4EAA4E;YAC5E,OAAO;gBACL,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAgC,EAAE;aAC9F,CAAC;QACJ,CAAC;QACD,KAAK,eAAe;YAClB,qFAAqF;YACrF,mFAAmF;YACnF,+EAA+E;YAC/E,kFAAkF;YAClF,kEAAkE;YAClE,OAAO;gBACL,cAAc,EAAE;oBACd,cAAc,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC;oBACjC,aAAa,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC;oBAChC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,IAAI,aAAa,CAAe;oBACjD,OAAO,EAAE,KAAK,CAAC,GAAG;oBAClB,WAAW,EAAE,KAAK,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;oBACzE,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB;aACF,CAAC;QACJ,uEAAuE;QACvE,wDAAwD;IAC1D,CAAC;AACH,CAAC"}
|
package/dist/codec/units.d.ts
CHANGED
|
@@ -11,6 +11,16 @@ export declare function decOpt(value: string | null | undefined): bigint | undef
|
|
|
11
11
|
/** Microseconds (number) -> milliseconds (number). */
|
|
12
12
|
export declare function usToMs(us: number | string): number;
|
|
13
13
|
export declare function usToMsOpt(us: number | string | null | undefined): number | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* An order's TTL expiry: microseconds -> milliseconds, or undefined when it never
|
|
16
|
+
* expires.
|
|
17
|
+
*
|
|
18
|
+
* "Never" has two spellings on the wire. `pod_orders_v2` omits the field; REST
|
|
19
|
+
* sends the engine's `Timestamp::MAX` sentinel, a u128 that arrives as a 39-digit
|
|
20
|
+
* number no JS number can hold exactly. Anything past `Number.MAX_SAFE_INTEGER`
|
|
21
|
+
* micros — the year 2255 — is that sentinel rather than a TTL someone signed.
|
|
22
|
+
*/
|
|
23
|
+
export declare function endMsFromUs(us: number | string | null | undefined): number | undefined;
|
|
14
24
|
/** Milliseconds -> microseconds (for request params that take micros). */
|
|
15
25
|
export declare function msToUs(ms: number): number;
|
|
16
26
|
/** Milliseconds -> unix seconds (REST candle/orders/stats query params). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/codec/units.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/codec/units.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,GAAG,uBAA6B,CAAC;AAC9C,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAO5D;AAED,0EAA0E;AAC1E,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAE3E;AAED,sDAAsD;AACtD,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAGlD;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEpF;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAKtF;AAED,0EAA0E;AAC1E,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAID;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,QAAQ,GAAE,MAAqB,EAC/B,SAAS,CAAC,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GACxB,MAAM,CAWR;AAED,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAExE;AAED,+EAA+E;AAC/E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAqB,GAAG,MAAM,CAE/E;AAED,8DAA8D;AAC9D,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAqB,GAAG,MAAM,CASlF"}
|
package/dist/codec/units.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// Unit conversions at the SDK boundary. Wire numerics are 1e18-scaled decimal
|
|
2
2
|
// strings; wire timestamps are microseconds. Public surface uses `bigint`
|
|
3
3
|
// (1e18-scaled) and millisecond `number` timestamps.
|
|
4
|
+
// "wad" is the DappHub/MakerDAO name for a fixed-point number carrying 18
|
|
5
|
+
// digits of precision, which is the scale every pod amount is in. Spelled out
|
|
6
|
+
// because the term is only obvious if you have met it before, and code that
|
|
7
|
+
// mixes scales — bridge withdrawals settle in the claim-chain token's decimals,
|
|
8
|
+
// not pod's — reads very differently depending on whether you know that.
|
|
4
9
|
export const WAD = 1000000000000000000n; // 1e18
|
|
5
10
|
export const WAD_DECIMALS = 18;
|
|
6
11
|
/**
|
|
@@ -29,6 +34,22 @@ export function usToMs(us) {
|
|
|
29
34
|
export function usToMsOpt(us) {
|
|
30
35
|
return us === null || us === undefined ? undefined : usToMs(us);
|
|
31
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* An order's TTL expiry: microseconds -> milliseconds, or undefined when it never
|
|
39
|
+
* expires.
|
|
40
|
+
*
|
|
41
|
+
* "Never" has two spellings on the wire. `pod_orders_v2` omits the field; REST
|
|
42
|
+
* sends the engine's `Timestamp::MAX` sentinel, a u128 that arrives as a 39-digit
|
|
43
|
+
* number no JS number can hold exactly. Anything past `Number.MAX_SAFE_INTEGER`
|
|
44
|
+
* micros — the year 2255 — is that sentinel rather than a TTL someone signed.
|
|
45
|
+
*/
|
|
46
|
+
export function endMsFromUs(us) {
|
|
47
|
+
if (us === null || us === undefined)
|
|
48
|
+
return undefined;
|
|
49
|
+
const n = typeof us === "string" ? Number(us) : us;
|
|
50
|
+
// `NaN` and `Infinity` both fail this comparison, so it is the whole guard.
|
|
51
|
+
return n <= Number.MAX_SAFE_INTEGER ? usToMs(n) : undefined;
|
|
52
|
+
}
|
|
32
53
|
/** Milliseconds -> microseconds (for request params that take micros). */
|
|
33
54
|
export function msToUs(ms) {
|
|
34
55
|
return ms * 1000;
|
|
@@ -79,8 +100,11 @@ export function parseAmount(value, decimals = WAD_DECIMALS) {
|
|
|
79
100
|
const neg = value.trim().startsWith("-");
|
|
80
101
|
const clean = neg ? value.trim().slice(1) : value.trim();
|
|
81
102
|
const [whole = "0", frac = ""] = clean.split(".");
|
|
103
|
+
if (whole === "" && frac === "")
|
|
104
|
+
throw new SyntaxError("Cannot convert empty amount to a BigInt");
|
|
82
105
|
const fracPadded = (frac + "0".repeat(decimals)).slice(0, decimals);
|
|
83
|
-
const
|
|
106
|
+
const wholePart = whole === "" && frac !== "" ? "0" : whole;
|
|
107
|
+
const scaled = BigInt(wholePart) * 10n ** BigInt(decimals) + BigInt(fracPadded || "0");
|
|
84
108
|
return neg ? -scaled : scaled;
|
|
85
109
|
}
|
|
86
110
|
//# sourceMappingURL=units.js.map
|
package/dist/codec/units.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"units.js","sourceRoot":"","sources":["../../src/codec/units.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,0EAA0E;AAC1E,qDAAqD;AAErD,MAAM,CAAC,MAAM,GAAG,GAAG,oBAA0B,CAAC,CAAC,OAAO;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAC,KAAgC;IAClD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IACrE,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;IAC7B,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IACzD,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,MAAM,CAAC,KAAgC;IACrD,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC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AC,CAAC;IAClG,MAAM,UAAU,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IACpE,MAAM,SAAS,GAAG,KAAK,KAAK,EAAE,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5D,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC;IACvF,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;AAChC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,4 +17,7 @@ export { createPodDatafeed } from "./datafeed.js";
|
|
|
17
17
|
export * from "./types/public.js";
|
|
18
18
|
export { formatAmount, formatPrice, decimalsForTick, toNumber, parseAmount, dec, WAD, WAD_DECIMALS, } from "./codec/units.js";
|
|
19
19
|
export { RESOLUTION_SECONDS, RESOLUTION_PAGE_BUCKETS, RESOLUTIONS, isResolution, } from "./codec/resolution.js";
|
|
20
|
+
export { withdrawStep, quantizeWithdrawAmount, toClaimAmount, toPodAmount, maxWithdrawable, checkWithdrawAmount, type WithdrawRejection, bridgeTokenFor, } from "./codec/bridge.js";
|
|
21
|
+
export { fetchClaimStatus, waitForClaim, watchClaims, CLAIM_TOPIC, type ClaimStatus, type ClaimOutcome, type WaitForClaimOptions, type ClaimWatcher, type WatchClaimsOptions, } from "./transport/claim.js";
|
|
22
|
+
export type { RpcOptions } from "./transport/jsonrpc.js";
|
|
20
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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AAE,KAAK,gBAAgB,EACrC,eAAe,GAChB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EACL,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,EAAE,YAAY,GAC1F,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,kBAAkB,EAAE,uBAAuB,EAAE,WAAW,EAAE,YAAY,GACvE,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EACL,YAAY,EAAE,sBAAsB,EAAE,aAAa,EAAE,WAAW,EAChE,eAAe,EAAE,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,cAAc,GAC7E,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EACxD,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAC7D,KAAK,YAAY,EAAE,KAAK,kBAAkB,GAC3C,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -16,4 +16,9 @@ export * from "./types/public.js";
|
|
|
16
16
|
// Codec helpers
|
|
17
17
|
export { formatAmount, formatPrice, decimalsForTick, toNumber, parseAmount, dec, WAD, WAD_DECIMALS, } from "./codec/units.js";
|
|
18
18
|
export { RESOLUTION_SECONDS, RESOLUTION_PAGE_BUCKETS, RESOLUTIONS, isResolution, } from "./codec/resolution.js";
|
|
19
|
+
// Withdrawal amount arithmetic (ADR 0033). Read-side, so a UI can size and
|
|
20
|
+
// validate a withdrawal without pulling the signing entry.
|
|
21
|
+
export { withdrawStep, quantizeWithdrawAmount, toClaimAmount, toPodAmount, maxWithdrawable, checkWithdrawAmount, bridgeTokenFor, } from "./codec/bridge.js";
|
|
22
|
+
// Following a withdrawal onto the claim chain.
|
|
23
|
+
export { fetchClaimStatus, waitForClaim, watchClaims, CLAIM_TOPIC, } from "./transport/claim.js";
|
|
19
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAE5E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAI7C,0EAA0E;AAC1E,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAKlE,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAQ5E,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EACL,cAAc,EACd,kBAAkB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,8EAA8E;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,oBAAoB;AACpB,cAAc,mBAAmB,CAAC;AAElC,gBAAgB;AAChB,OAAO,EACL,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,EAAE,YAAY,GAC1F,MAAM,kBAAkB,CAAC;AAC1B,OAAO,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CAAC;AAC3B,+CAA+C;AAC/C,OAAO,EACL,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,GAGzD,MAAM,sBAAsB,CAAC"}
|
package/dist/sync/orders.d.ts
CHANGED
|
@@ -1,29 +1,53 @@
|
|
|
1
|
-
import type { Address,
|
|
1
|
+
import type { Address, Order, OrderEvent, OrdersQuery } from "../types/public.js";
|
|
2
|
+
import { type SubParams } from "../transport/ws.js";
|
|
2
3
|
import type { SeriesResource } from "./candles.js";
|
|
3
4
|
import type { SyncContext } from "./sources.js";
|
|
5
|
+
/**
|
|
6
|
+
* Order two positions in the stream, the way the server does.
|
|
7
|
+
*
|
|
8
|
+
* A batch is delivered as one frame per book, so a position is the pair
|
|
9
|
+
* `(batch, book)` — and an absent book means the whole batch, which sorts *above*
|
|
10
|
+
* every book in it. This mirrors `already_delivered` in
|
|
11
|
+
* `node/src/rpc/orders_v2.rs`: `(frame_batch, frame_book) <= (since,
|
|
12
|
+
* since_book.unwrap_or(0xff…))`. Getting the absent case wrong turns "all of batch
|
|
13
|
+
* N" into "up to book B of batch N", which asks the server to re-send the rest.
|
|
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;
|
|
4
19
|
export declare class OrderHistory implements SeriesResource<Order> {
|
|
5
20
|
private readonly ctx;
|
|
6
21
|
private readonly account;
|
|
7
22
|
private readonly query;
|
|
8
|
-
/** Maps a WS order's token pair to its orderbook id (see rebuild). */
|
|
9
|
-
private readonly resolveOrderbookId?;
|
|
10
23
|
private readonly base;
|
|
11
24
|
private handle;
|
|
12
25
|
private readonly byId;
|
|
13
26
|
private nextCursor;
|
|
14
27
|
private sub;
|
|
15
|
-
private watermarkUs;
|
|
16
28
|
private alive;
|
|
17
29
|
private _hasMore;
|
|
18
30
|
private _loading;
|
|
19
31
|
private subRetries;
|
|
32
|
+
private fastResumes;
|
|
20
33
|
private retryTimer?;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
private readonly eventListeners;
|
|
35
|
+
/**
|
|
36
|
+
* Where the stream is: the last frame accepted, as the `(batch, book)` pair the
|
|
37
|
+
* channel resumes from. Replaced whole rather than patched half at a time —
|
|
38
|
+
* `sinceBook` names a book *within* `since`, so the two are one fact and a
|
|
39
|
+
* mismatched pair asks the server to skip books we never saw.
|
|
40
|
+
*/
|
|
41
|
+
private cursor;
|
|
42
|
+
/**
|
|
43
|
+
* Push the cursor to the transport, both halves.
|
|
44
|
+
*
|
|
45
|
+
* `update` merges, so sending `{ since }` alone would leave whatever `sinceBook` was
|
|
46
|
+
* there before — a book from an older batch beside a newer `since`, which asks the
|
|
47
|
+
* server to skip less than it should and re-send the difference.
|
|
48
|
+
*/
|
|
49
|
+
private pushCursor;
|
|
50
|
+
constructor(ctx: SyncContext, account: Address, query?: OrdersQuery);
|
|
27
51
|
get(): Order[] | undefined;
|
|
28
52
|
subscribe(listener: () => void): () => void;
|
|
29
53
|
ready(): Promise<Order[]>;
|
|
@@ -31,19 +55,50 @@ export declare class OrderHistory implements SeriesResource<Order> {
|
|
|
31
55
|
hasMore(): boolean;
|
|
32
56
|
loading(): boolean;
|
|
33
57
|
destroy(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Observe the transitions the stream reports, as they arrive — a frame at a time, in
|
|
60
|
+
* the order the engine caused them.
|
|
61
|
+
*
|
|
62
|
+
* The snapshot (`get`/`subscribe`) is what to render; this is what *happened*, which
|
|
63
|
+
* a snapshot cannot express: two fills in one batch are one state change, and a
|
|
64
|
+
* refused amendment is none at all. Nothing is emitted for the REST seed, so a
|
|
65
|
+
* consumer never has to filter out a backlog of history as if it were live.
|
|
66
|
+
*/
|
|
67
|
+
onEvent(listener: (events: OrderEvent[]) => void): () => void;
|
|
34
68
|
setWindow(): void;
|
|
35
69
|
loadOlder(): Promise<void>;
|
|
36
70
|
private fetchFirstPage;
|
|
37
71
|
private seed;
|
|
38
72
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
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`).
|
|
43
88
|
*/
|
|
44
89
|
private onSubError;
|
|
45
|
-
|
|
46
|
-
|
|
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
|
+
/** One frame: everything that happened to one book in one auction batch. */
|
|
101
|
+
private onFrame;
|
|
47
102
|
private rebuild;
|
|
48
103
|
}
|
|
49
104
|
//# sourceMappingURL=orders.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orders.d.ts","sourceRoot":"","sources":["../../src/sync/orders.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"orders.d.ts","sourceRoot":"","sources":["../../src/sync/orders.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,OAAO,EAAY,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAI5F,OAAO,EAA8B,KAAK,SAAS,EAAqB,MAAM,oBAAoB,CAAC;AACnG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAmBhD;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,MAAM,CAOhE;AAED,qBAAa,YAAa,YAAW,cAAc,CAAC,KAAK,CAAC;IAiCtD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAlCxB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAwB;IAC7C,OAAO,CAAC,MAAM,CAAsC;IACpD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA4B;IACjD,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,GAAG,CAA2B;IACtC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,UAAU,CAAC,CAAgC;IACnD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAC5E;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAiD;IAE/D;;;;;;OAMG;IACH,OAAO,CAAC,UAAU;gBAKC,GAAG,EAAE,WAAW,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