@proof-labs/trading-sdk 7.3.0 → 8.0.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 +70 -24
- package/dist/account-recovery.d.ts +117 -0
- package/dist/account-recovery.d.ts.map +1 -0
- package/dist/account-recovery.js +330 -0
- package/dist/account-recovery.js.map +1 -0
- package/dist/client.d.ts +42 -54
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +138 -160
- package/dist/client.js.map +1 -1
- package/dist/codec-adapter.d.ts.map +1 -1
- package/dist/codec-adapter.js +13 -0
- package/dist/codec-adapter.js.map +1 -1
- package/dist/errors.d.ts +23 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +73 -2
- package/dist/errors.js.map +1 -1
- package/dist/feed-types.d.ts +22 -0
- package/dist/feed-types.d.ts.map +1 -1
- package/dist/feed.d.ts +52 -0
- package/dist/feed.d.ts.map +1 -1
- package/dist/feed.js +342 -24
- package/dist/feed.js.map +1 -1
- package/dist/financial-state.d.ts.map +1 -1
- package/dist/financial-state.js +16 -4
- package/dist/financial-state.js.map +1 -1
- package/dist/governance-query.d.ts.map +1 -1
- package/dist/governance-query.js +69 -0
- package/dist/governance-query.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/insurance-funding.d.ts +6 -0
- package/dist/insurance-funding.d.ts.map +1 -0
- package/dist/insurance-funding.js +54 -0
- package/dist/insurance-funding.js.map +1 -0
- package/dist/liquidation-config.d.ts +11 -0
- package/dist/liquidation-config.d.ts.map +1 -0
- package/dist/liquidation-config.js +54 -0
- package/dist/liquidation-config.js.map +1 -0
- package/dist/liquidation-events.d.ts +135 -0
- package/dist/liquidation-events.d.ts.map +1 -0
- package/dist/liquidation-events.js +273 -0
- package/dist/liquidation-events.js.map +1 -0
- package/dist/types.d.ts +88 -13
- package/dist/types.d.ts.map +1 -1
- package/dist/wasm/proof_trading_sdk_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GatewayFeed, type GatewayFeedOptions, type AccountFeedAuth } from "./feed.js";
|
|
2
|
-
import type { AccountFrame, OrderbookFrame, TradeFrame } from "./feed-types.js";
|
|
2
|
+
import type { AccountFrame, OrderbookFrame, OrderbookSnapshotFrame, TradeFrame } from "./feed-types.js";
|
|
3
3
|
import { type PortfolioHistoryOptions, type PortfolioHistoryPage } from "./portfolio-history.js";
|
|
4
4
|
import { type OraclePriceHistoryOptions, type OraclePriceHistoryPage } from "./oracle-price-history.js";
|
|
5
5
|
import { GatewayReads, type GatewayFetch } from "./gateway-reads.js";
|
|
6
|
+
import { type AccountRecoveryStatus } from "./account-recovery.js";
|
|
6
7
|
import { type AccountState } from "./account-state.js";
|
|
7
8
|
import { type FinancialState, type FinancialStateSelection } from "./financial-state.js";
|
|
8
9
|
import type { Action, TxResult, PlaceOrder, MarketOrder, AccountInfo, HistoryCashFlow, HistoryFillsPage, HistoryPositionSnapshot, HistoryPositionsPage, HistoryResolution, MarketConfig, OpenOrder, AdlQueueEntry, Orderbook, Ticker, WithdrawalRecord, AdminSignerRegistry, AuthoritiesSnapshot, ProposalPage, EventInfo, SetPositionTriggers, PositionTriggerInfo, TriggerStatus, PositionTriggerHistoryFilters, PositionTriggerHistoryPage, TriggerMarketHistoryFilters, TriggerMarketHistoryPage, TriggerMarketConfigInfo, NodeVersion, UpgradesInfo, AuthorizeWithdrawal, ConfirmWithdrawalReceipt, FailWithdrawalReceipt } from "./types.js";
|
|
@@ -45,8 +46,7 @@ export interface ExchangeClientOptions {
|
|
|
45
46
|
*/
|
|
46
47
|
apiUrl?: string;
|
|
47
48
|
/**
|
|
48
|
-
* WebSocket base URL for the gateway
|
|
49
|
-
* `/orderbook-deltas`). Defaults to `gatewayUrl` (or `rpcUrl` on the
|
|
49
|
+
* WebSocket base URL for the gateway's multiplexed `/ws` feed. Defaults to `gatewayUrl` (or `rpcUrl` on the
|
|
50
50
|
* direct-node path) with the scheme swapped to `ws`/`wss`. The gateway
|
|
51
51
|
* serves its feed on a dedicated listener; for a local stack whose WS
|
|
52
52
|
* port differs from the HTTP port, set this explicitly
|
|
@@ -162,13 +162,17 @@ export declare class ExchangeClient {
|
|
|
162
162
|
private externalSigner;
|
|
163
163
|
private signerRevision;
|
|
164
164
|
private gatewayFeed;
|
|
165
|
+
/** Dedicated feeds behind pending `orderbookSnapshot` calls, so
|
|
166
|
+
* `disconnect()` closes them too. */
|
|
167
|
+
private readonly snapshotFeeds;
|
|
168
|
+
/** Reconnect recoveries of live `subscribeAccount` calls, closed with the feed. */
|
|
169
|
+
private readonly accountRecoveries;
|
|
165
170
|
private publicKey;
|
|
166
171
|
private address;
|
|
167
172
|
private addressHex;
|
|
168
173
|
private lastTimestampNonce;
|
|
169
174
|
/** Unsubscribe handles for every open WebSocket stream, so `disconnect()`
|
|
170
175
|
* can tear them all down at once. */
|
|
171
|
-
private activeStreams;
|
|
172
176
|
/**
|
|
173
177
|
* In-flight DeliverTx verification promises spawned by submitTx. Awaiting
|
|
174
178
|
* this set lets callers serialize against block inclusion when they need to;
|
|
@@ -251,7 +255,8 @@ export declare class ExchangeClient {
|
|
|
251
255
|
signTx(action: Action, opts?: {
|
|
252
256
|
signal?: AbortSignal;
|
|
253
257
|
}): Promise<Uint8Array>;
|
|
254
|
-
/** Sign
|
|
258
|
+
/** Sign the gateway's account-stream auth bytes for an `accountEvents`
|
|
259
|
+
* subscription on `/ws`; call again per reconnect.
|
|
255
260
|
* Direct owner keys only; no delegated-owner authorization is inferred.
|
|
256
261
|
*/
|
|
257
262
|
accountAuth(owner?: string, afterId?: bigint): Promise<AccountFeedAuth>;
|
|
@@ -749,66 +754,49 @@ export declare class ExchangeClient {
|
|
|
749
754
|
getBlock(height?: number): Promise<Record<string, unknown>>;
|
|
750
755
|
getBlockResults(height: number): Promise<Record<string, unknown>>;
|
|
751
756
|
/**
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
* Auth: account streams require auth only when the gateway runs with
|
|
759
|
-
* `--api-key`. A browser `WebSocket` cannot send the `X-Api-Key` header, so
|
|
760
|
-
* the SDK uses the gateway's signed-query auth instead — when a private key or external signer
|
|
761
|
-
* is connected it signs the `ProofExchange-account-events-v1`
|
|
762
|
-
* message and appends `public_key` / `signature` / `timestamp_ms`. Against
|
|
763
|
-
* an unauthenticated gateway (e.g. devnet) the owner alone is enough.
|
|
764
|
-
*
|
|
765
|
-
* Returns an unsubscribe function; `disconnect()` closes all streams.
|
|
766
|
-
*/
|
|
767
|
-
subscribeAccountEvents(owner: Uint8Array | string, onEvent: (event: Record<string, unknown>) => void, opts?: WsStreamOptions & {
|
|
768
|
-
auth?: false;
|
|
769
|
-
}): () => void;
|
|
770
|
-
/**
|
|
771
|
-
* Subscribe to the L2 orderbook delta stream for a market
|
|
772
|
-
* (`/orderbook-deltas`). Mirrors the Python SDK's `OrderbookDeltaStream`:
|
|
773
|
-
* the first frame is a full `l2Book` snapshot, then incremental deltas.
|
|
774
|
-
* Returns an unsubscribe function.
|
|
775
|
-
*/
|
|
776
|
-
subscribeOrderbookDeltas(market: number, onMessage: (msg: Record<string, unknown>) => void, opts?: WsStreamOptions): () => void;
|
|
777
|
-
/**
|
|
778
|
-
* One-shot L2 orderbook snapshot via a temporary delta-stream connection:
|
|
779
|
-
* opens the stream, resolves the first `l2Book` snapshot frame, and closes.
|
|
780
|
-
* Mirrors the Python SDK's `orderbook_snapshot`.
|
|
781
|
-
*/
|
|
782
|
-
orderbookSnapshot(market: number): Promise<Record<string, unknown>>;
|
|
783
|
-
/**
|
|
784
|
-
* Internal: open one self-reconnecting WebSocket. `buildUrl` is re-invoked
|
|
785
|
-
* on every (re)connect so per-connect state (fresh auth timestamp, current
|
|
786
|
-
* `after_id`) is rebuilt each time. Reconnects with exponential backoff and
|
|
787
|
-
* jitter. Returns an unsubscribe that stops reconnecting and closes the
|
|
788
|
-
* socket.
|
|
757
|
+
* One-shot orderbook snapshot from the gateway's `/ws` feed, read over a
|
|
758
|
+
* connection of its own: it never answers from a book an existing
|
|
759
|
+
* `subscribeOrderbook` built, so a stalled shared socket cannot serve stale
|
|
760
|
+
* prices. Resolves the first `snapshot` frame and closes the connection.
|
|
761
|
+
* Rejects with {@link FeedSubscriptionError} when the gateway refuses the
|
|
762
|
+
* subscription, or when no snapshot arrives within `timeoutMs`.
|
|
789
763
|
*/
|
|
790
|
-
|
|
764
|
+
orderbookSnapshot(market: number, timeoutMs?: number): Promise<OrderbookSnapshotFrame>;
|
|
765
|
+
/** A new `/ws` connection with this client's URL, auth and headers. */
|
|
766
|
+
private createFeed;
|
|
791
767
|
/** Shared multiplexed /ws feed. Options apply on first creation only.
|
|
792
768
|
* Reconnect restores snapshots, not missed events. Default auth reads the current signer.
|
|
793
769
|
*/
|
|
794
770
|
feed(opts?: Partial<GatewayFeedOptions>): GatewayFeed;
|
|
795
|
-
/**
|
|
771
|
+
/**
|
|
772
|
+
* Account snapshot plus live stream, with auth renewed per reconnect.
|
|
773
|
+
*
|
|
774
|
+
* By default a reconnect recovers the events missed while disconnected:
|
|
775
|
+
* the SDK reads `/v1/history/account-events` back to the last delivered
|
|
776
|
+
* event (or the previous snapshot's `height`), retrying while
|
|
777
|
+
* `/v1/history/status` shows history behind the new snapshot's `height`,
|
|
778
|
+
* delivers the newer rows in order (marked `backfilled`), buffers live
|
|
779
|
+
* frames meanwhile and drops those a backfilled row already delivered,
|
|
780
|
+
* then resumes live delivery. `onRecovery` reports each reconnect's
|
|
781
|
+
* outcome once: `unverified` when the snapshot has no `height`,
|
|
782
|
+
* `unsupported` when the gateway predates 7.9.0 and sends no history key.
|
|
783
|
+
* `recover: false` turns recovery off.
|
|
784
|
+
*/
|
|
796
785
|
subscribeAccount(onFrame: (frame: AccountFrame) => void, opts?: {
|
|
797
786
|
owner?: string;
|
|
798
787
|
auth?: false;
|
|
788
|
+
recover?: boolean;
|
|
789
|
+
onRecovery?: (status: AccountRecoveryStatus) => void;
|
|
799
790
|
}): () => void;
|
|
791
|
+
/** One newest-first `/v1/history/account-events` page for recovery. */
|
|
792
|
+
private accountHistoryPage;
|
|
793
|
+
/** The newest height history has indexed in full
|
|
794
|
+
* (`/v1/history/status` → `ingest.newest_height`). */
|
|
795
|
+
private historyIndexedHeight;
|
|
800
796
|
subscribeOrderbook(market: number, onFrame: (frame: OrderbookFrame) => void): () => void;
|
|
801
797
|
subscribeTrades(market: number, onFrame: (frame: TradeFrame) => void): () => void;
|
|
802
|
-
/** Close
|
|
798
|
+
/** Close the shared `/ws` feed, any pending `orderbookSnapshot` feed, any
|
|
799
|
+
* account backfill in progress, and stop their reconnect loops. */
|
|
803
800
|
disconnect(): void;
|
|
804
801
|
}
|
|
805
|
-
/** Options common to the WebSocket stream subscriptions. */
|
|
806
|
-
export interface WsStreamOptions {
|
|
807
|
-
/** Called on connect/parse errors. The stream keeps reconnecting; use
|
|
808
|
-
* this for logging or to surface terminal failures. */
|
|
809
|
-
onError?: (err: unknown) => void;
|
|
810
|
-
/** Max reconnect backoff in milliseconds (default 30000). Backoff starts
|
|
811
|
-
* at 500ms and doubles with ±25% jitter up to this cap. */
|
|
812
|
-
reconnectBackoffMaxMs?: number;
|
|
813
|
-
}
|
|
814
802
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,o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|
import { portfolioHistorySearchParams, decodePortfolioHistoryPage, } from "./portfolio-history.js";
|
|
3
3
|
import { queryOraclePriceHistoryPage, } from "./oracle-price-history.js";
|
|
4
4
|
import { GatewayReads } from "./gateway-reads.js";
|
|
5
|
-
import {
|
|
5
|
+
import { recoveringAccountHandler, } from "./account-recovery.js";
|
|
6
|
+
import { FeedSubscriptionError, GatewayHttpError } from "./errors.js";
|
|
6
7
|
import { decodeCashFlowEvents, decodeHistoryPositionsPage, historyOwner, historySearchParams, } from "./history.js";
|
|
7
8
|
import { toWasmFields } from "./codec-adapter.js";
|
|
8
9
|
import { signAndEncode, encodePayloadBytes, encodeSignedTx, rejectFloats, } from "./codec.js";
|
|
@@ -70,13 +71,17 @@ export class ExchangeClient {
|
|
|
70
71
|
externalSigner = null;
|
|
71
72
|
signerRevision = 0;
|
|
72
73
|
gatewayFeed = null;
|
|
74
|
+
/** Dedicated feeds behind pending `orderbookSnapshot` calls, so
|
|
75
|
+
* `disconnect()` closes them too. */
|
|
76
|
+
snapshotFeeds = new Set();
|
|
77
|
+
/** Reconnect recoveries of live `subscribeAccount` calls, closed with the feed. */
|
|
78
|
+
accountRecoveries = new Set();
|
|
73
79
|
publicKey = null;
|
|
74
80
|
address = null;
|
|
75
81
|
addressHex = null;
|
|
76
82
|
lastTimestampNonce = 0n;
|
|
77
83
|
/** Unsubscribe handles for every open WebSocket stream, so `disconnect()`
|
|
78
84
|
* can tear them all down at once. */
|
|
79
|
-
activeStreams = new Set();
|
|
80
85
|
/**
|
|
81
86
|
* In-flight DeliverTx verification promises spawned by submitTx. Awaiting
|
|
82
87
|
* this set lets callers serialize against block inclusion when they need to;
|
|
@@ -111,10 +116,10 @@ export class ExchangeClient {
|
|
|
111
116
|
this.apiUrl = stripTrailingSlash(opts.apiUrl ?? deriveNodeUrl(this.gatewayUrl, "8080"));
|
|
112
117
|
this.apiKey = opts.apiKey ?? null;
|
|
113
118
|
this.httpTransport = opts.httpTransport ?? defaultExchangeHttpTransport;
|
|
114
|
-
// WebSocket base URL (no path)
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
//
|
|
119
|
+
// WebSocket base URL (no path); the feed appends `/ws`. Mirrors the
|
|
120
|
+
// Python SDK, which derives the WS base by swapping the gateway URL's
|
|
121
|
+
// scheme. Local stacks whose WS listener is on a different port must pass
|
|
122
|
+
// `wsUrl`.
|
|
118
123
|
this.wsUrl = stripTrailingSlash(opts.wsUrl ??
|
|
119
124
|
(this.useGateway ? this.gatewayUrl : this.rpcUrl).replace(/^http/, "ws"));
|
|
120
125
|
// Bind chainId eagerly when supplied, else leave null. On the direct
|
|
@@ -283,7 +288,8 @@ export class ExchangeClient {
|
|
|
283
288
|
}
|
|
284
289
|
return encodeSignedTx(snapshot, seq, signer.publicKey, signature);
|
|
285
290
|
}
|
|
286
|
-
/** Sign
|
|
291
|
+
/** Sign the gateway's account-stream auth bytes for an `accountEvents`
|
|
292
|
+
* subscription on `/ws`; call again per reconnect.
|
|
287
293
|
* Direct owner keys only; no delegated-owner authorization is inferred.
|
|
288
294
|
*/
|
|
289
295
|
async accountAuth(owner = this.addressHex ?? "", afterId = 0n) {
|
|
@@ -1664,175 +1670,142 @@ export class ExchangeClient {
|
|
|
1664
1670
|
return json.result;
|
|
1665
1671
|
}
|
|
1666
1672
|
// -----------------------------------------------------------------------
|
|
1667
|
-
// WebSocket streams (gateway
|
|
1673
|
+
// WebSocket streams (the gateway's multiplexed /ws feed)
|
|
1668
1674
|
// -----------------------------------------------------------------------
|
|
1669
1675
|
/**
|
|
1670
|
-
*
|
|
1671
|
-
*
|
|
1672
|
-
*
|
|
1673
|
-
*
|
|
1674
|
-
*
|
|
1675
|
-
*
|
|
1676
|
-
* Auth: account streams require auth only when the gateway runs with
|
|
1677
|
-
* `--api-key`. A browser `WebSocket` cannot send the `X-Api-Key` header, so
|
|
1678
|
-
* the SDK uses the gateway's signed-query auth instead — when a private key or external signer
|
|
1679
|
-
* is connected it signs the `ProofExchange-account-events-v1`
|
|
1680
|
-
* message and appends `public_key` / `signature` / `timestamp_ms`. Against
|
|
1681
|
-
* an unauthenticated gateway (e.g. devnet) the owner alone is enough.
|
|
1682
|
-
*
|
|
1683
|
-
* Returns an unsubscribe function; `disconnect()` closes all streams.
|
|
1684
|
-
*/
|
|
1685
|
-
subscribeAccountEvents(owner, onEvent, opts = {}) {
|
|
1686
|
-
const ownerHex = (owner instanceof Uint8Array ? bytesToHex(owner) : owner.replace(/^0x/, "")).toLowerCase();
|
|
1687
|
-
// Tracked across reconnects for gap recovery. Signed into the auth
|
|
1688
|
-
// message too, so the value we send and the value we sign always match.
|
|
1689
|
-
let afterId = 0n;
|
|
1690
|
-
const buildUrl = async () => {
|
|
1691
|
-
const params = new URLSearchParams({ owner: ownerHex });
|
|
1692
|
-
if (afterId > 0n)
|
|
1693
|
-
params.set("after_id", afterId.toString());
|
|
1694
|
-
if (opts.auth !== false && (this.privateKey || this.externalSigner)) {
|
|
1695
|
-
const auth = await this.accountAuth(ownerHex, afterId);
|
|
1696
|
-
for (const [key, value] of Object.entries(auth))
|
|
1697
|
-
params.set(key, String(value));
|
|
1698
|
-
}
|
|
1699
|
-
return `${this.wsUrl}/account-events?${params.toString()}`;
|
|
1700
|
-
};
|
|
1701
|
-
return this.openStream(buildUrl, (frame) => {
|
|
1702
|
-
const id = frame.event_id;
|
|
1703
|
-
if (typeof id === "number" || typeof id === "bigint") {
|
|
1704
|
-
const big = BigInt(id);
|
|
1705
|
-
if (big > afterId)
|
|
1706
|
-
afterId = big;
|
|
1707
|
-
}
|
|
1708
|
-
onEvent(frame);
|
|
1709
|
-
}, opts);
|
|
1710
|
-
}
|
|
1711
|
-
/**
|
|
1712
|
-
* Subscribe to the L2 orderbook delta stream for a market
|
|
1713
|
-
* (`/orderbook-deltas`). Mirrors the Python SDK's `OrderbookDeltaStream`:
|
|
1714
|
-
* the first frame is a full `l2Book` snapshot, then incremental deltas.
|
|
1715
|
-
* Returns an unsubscribe function.
|
|
1716
|
-
*/
|
|
1717
|
-
subscribeOrderbookDeltas(market, onMessage, opts = {}) {
|
|
1718
|
-
return this.openStream(async () => `${this.wsUrl}/orderbook-deltas?market=${market}`, onMessage, opts);
|
|
1719
|
-
}
|
|
1720
|
-
/**
|
|
1721
|
-
* One-shot L2 orderbook snapshot via a temporary delta-stream connection:
|
|
1722
|
-
* opens the stream, resolves the first `l2Book` snapshot frame, and closes.
|
|
1723
|
-
* Mirrors the Python SDK's `orderbook_snapshot`.
|
|
1676
|
+
* One-shot orderbook snapshot from the gateway's `/ws` feed, read over a
|
|
1677
|
+
* connection of its own: it never answers from a book an existing
|
|
1678
|
+
* `subscribeOrderbook` built, so a stalled shared socket cannot serve stale
|
|
1679
|
+
* prices. Resolves the first `snapshot` frame and closes the connection.
|
|
1680
|
+
* Rejects with {@link FeedSubscriptionError} when the gateway refuses the
|
|
1681
|
+
* subscription, or when no snapshot arrives within `timeoutMs`.
|
|
1724
1682
|
*/
|
|
1725
|
-
orderbookSnapshot(market) {
|
|
1683
|
+
orderbookSnapshot(market, timeoutMs = 10_000) {
|
|
1684
|
+
const feed = this.createFeed({ pingIntervalMs: 0 });
|
|
1685
|
+
this.snapshotFeeds.add(feed);
|
|
1726
1686
|
return new Promise((resolve, reject) => {
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1687
|
+
let settled = false;
|
|
1688
|
+
const finish = () => {
|
|
1689
|
+
settled = true;
|
|
1690
|
+
clearTimeout(timer);
|
|
1691
|
+
this.snapshotFeeds.delete(feed);
|
|
1692
|
+
feed.close();
|
|
1693
|
+
};
|
|
1694
|
+
const timer = setTimeout(() => {
|
|
1695
|
+
finish();
|
|
1696
|
+
reject(new FeedSubscriptionError("orderbook", `orderbook snapshot for market ${market} timed out after ${timeoutMs}ms`));
|
|
1697
|
+
}, timeoutMs);
|
|
1698
|
+
feed.subscribeOrderbook(market, (frame) => {
|
|
1699
|
+
if (settled)
|
|
1700
|
+
return;
|
|
1701
|
+
const raw = frame;
|
|
1702
|
+
if (raw.type === "error") {
|
|
1703
|
+
finish();
|
|
1704
|
+
reject(new FeedSubscriptionError("orderbook", raw.error, raw.code));
|
|
1705
|
+
}
|
|
1706
|
+
else if (raw.type === "snapshot") {
|
|
1707
|
+
finish();
|
|
1708
|
+
resolve(raw);
|
|
1731
1709
|
}
|
|
1732
|
-
}, {
|
|
1733
|
-
onError: (err) => {
|
|
1734
|
-
unsub();
|
|
1735
|
-
reject(err instanceof Error ? err : new Error(String(err)));
|
|
1736
|
-
},
|
|
1737
1710
|
});
|
|
1738
1711
|
});
|
|
1739
1712
|
}
|
|
1740
|
-
/**
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
let timer = null;
|
|
1752
|
-
let backoff = 500;
|
|
1753
|
-
const scheduleReconnect = () => {
|
|
1754
|
-
if (closed)
|
|
1755
|
-
return;
|
|
1756
|
-
const jitter = backoff * (0.75 + Math.random() * 0.5);
|
|
1757
|
-
timer = setTimeout(() => void connect(), jitter);
|
|
1758
|
-
backoff = Math.min(backoff * 2, backoffCapMs);
|
|
1759
|
-
};
|
|
1760
|
-
const connect = async () => {
|
|
1761
|
-
if (closed)
|
|
1762
|
-
return;
|
|
1763
|
-
let url;
|
|
1764
|
-
try {
|
|
1765
|
-
url = await buildUrl();
|
|
1766
|
-
}
|
|
1767
|
-
catch (err) {
|
|
1768
|
-
opts.onError?.(err);
|
|
1769
|
-
scheduleReconnect();
|
|
1770
|
-
return;
|
|
1771
|
-
}
|
|
1772
|
-
if (closed)
|
|
1773
|
-
return;
|
|
1774
|
-
ws = new WebSocket(url);
|
|
1775
|
-
ws.onopen = () => {
|
|
1776
|
-
backoff = 500;
|
|
1777
|
-
};
|
|
1778
|
-
ws.onmessage = (ev) => {
|
|
1779
|
-
try {
|
|
1780
|
-
onMessage(JSON.parse(ev.data));
|
|
1781
|
-
}
|
|
1782
|
-
catch (err) {
|
|
1783
|
-
opts.onError?.(err);
|
|
1784
|
-
}
|
|
1785
|
-
};
|
|
1786
|
-
ws.onerror = (err) => {
|
|
1787
|
-
opts.onError?.(err);
|
|
1788
|
-
};
|
|
1789
|
-
ws.onclose = () => {
|
|
1790
|
-
ws = null;
|
|
1791
|
-
if (!closed)
|
|
1792
|
-
scheduleReconnect();
|
|
1793
|
-
};
|
|
1794
|
-
};
|
|
1795
|
-
const unsubscribe = () => {
|
|
1796
|
-
closed = true;
|
|
1797
|
-
if (timer) {
|
|
1798
|
-
clearTimeout(timer);
|
|
1799
|
-
timer = null;
|
|
1800
|
-
}
|
|
1801
|
-
if (ws) {
|
|
1802
|
-
ws.close();
|
|
1803
|
-
ws = null;
|
|
1804
|
-
}
|
|
1805
|
-
this.activeStreams.delete(unsubscribe);
|
|
1806
|
-
};
|
|
1807
|
-
this.activeStreams.add(unsubscribe);
|
|
1808
|
-
void connect();
|
|
1809
|
-
return unsubscribe;
|
|
1713
|
+
/** A new `/ws` connection with this client's URL, auth and headers. */
|
|
1714
|
+
createFeed(opts = {}) {
|
|
1715
|
+
let base = this.wsUrl;
|
|
1716
|
+
if (!base && typeof globalThis.location !== "undefined")
|
|
1717
|
+
base = globalThis.location.origin.replace(/^http/, "ws");
|
|
1718
|
+
return new GatewayFeed({
|
|
1719
|
+
url: `${base}/ws`,
|
|
1720
|
+
accountAuth: async (owner) => this.privateKey || this.externalSigner ? this.accountAuth(owner) : {},
|
|
1721
|
+
headers: this.apiKey ? { "X-Api-Key": this.apiKey } : undefined,
|
|
1722
|
+
...opts,
|
|
1723
|
+
});
|
|
1810
1724
|
}
|
|
1811
1725
|
/** Shared multiplexed /ws feed. Options apply on first creation only.
|
|
1812
1726
|
* Reconnect restores snapshots, not missed events. Default auth reads the current signer.
|
|
1813
1727
|
*/
|
|
1814
1728
|
feed(opts = {}) {
|
|
1815
|
-
if (!this.gatewayFeed)
|
|
1816
|
-
|
|
1817
|
-
if (!base && typeof globalThis.location !== "undefined")
|
|
1818
|
-
base = globalThis.location.origin.replace(/^http/, "ws");
|
|
1819
|
-
this.gatewayFeed = new GatewayFeed({
|
|
1820
|
-
url: `${base}/ws`,
|
|
1821
|
-
accountAuth: async (owner) => this.privateKey || this.externalSigner ? this.accountAuth(owner) : {},
|
|
1822
|
-
headers: this.apiKey ? { "X-Api-Key": this.apiKey } : undefined,
|
|
1823
|
-
...opts,
|
|
1824
|
-
});
|
|
1825
|
-
}
|
|
1729
|
+
if (!this.gatewayFeed)
|
|
1730
|
+
this.gatewayFeed = this.createFeed(opts);
|
|
1826
1731
|
return this.gatewayFeed;
|
|
1827
1732
|
}
|
|
1828
|
-
/**
|
|
1733
|
+
/**
|
|
1734
|
+
* Account snapshot plus live stream, with auth renewed per reconnect.
|
|
1735
|
+
*
|
|
1736
|
+
* By default a reconnect recovers the events missed while disconnected:
|
|
1737
|
+
* the SDK reads `/v1/history/account-events` back to the last delivered
|
|
1738
|
+
* event (or the previous snapshot's `height`), retrying while
|
|
1739
|
+
* `/v1/history/status` shows history behind the new snapshot's `height`,
|
|
1740
|
+
* delivers the newer rows in order (marked `backfilled`), buffers live
|
|
1741
|
+
* frames meanwhile and drops those a backfilled row already delivered,
|
|
1742
|
+
* then resumes live delivery. `onRecovery` reports each reconnect's
|
|
1743
|
+
* outcome once: `unverified` when the snapshot has no `height`,
|
|
1744
|
+
* `unsupported` when the gateway predates 7.9.0 and sends no history key.
|
|
1745
|
+
* `recover: false` turns recovery off.
|
|
1746
|
+
*/
|
|
1829
1747
|
subscribeAccount(onFrame, opts = {}) {
|
|
1830
|
-
const owner = opts.owner ?? this.addressHex
|
|
1748
|
+
const owner = (opts.owner ?? this.addressHex)
|
|
1749
|
+
?.replace(/^0x/i, "")
|
|
1750
|
+
.toLowerCase();
|
|
1831
1751
|
if (!owner)
|
|
1832
1752
|
throw new Error("No account owner available");
|
|
1833
|
-
|
|
1753
|
+
const auth = async (address) => opts.auth !== false && (this.privateKey || this.externalSigner)
|
|
1834
1754
|
? this.accountAuth(address)
|
|
1835
|
-
: {}
|
|
1755
|
+
: {};
|
|
1756
|
+
if (opts.recover === false)
|
|
1757
|
+
return this.feed().subscribeAccount(owner, onFrame, auth);
|
|
1758
|
+
const recovery = recoveringAccountHandler({
|
|
1759
|
+
owner,
|
|
1760
|
+
onFrame,
|
|
1761
|
+
onRecovery: opts.onRecovery,
|
|
1762
|
+
fetchPage: (cursor, signal) => this.accountHistoryPage(owner, cursor, signal),
|
|
1763
|
+
fetchIndexedHeight: (signal) => this.historyIndexedHeight(signal),
|
|
1764
|
+
});
|
|
1765
|
+
const unsubscribe = this.feed().subscribeAccount(owner, recovery.handle, auth);
|
|
1766
|
+
this.accountRecoveries.add(recovery.close);
|
|
1767
|
+
return () => {
|
|
1768
|
+
this.accountRecoveries.delete(recovery.close);
|
|
1769
|
+
recovery.close();
|
|
1770
|
+
unsubscribe();
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1773
|
+
/** One newest-first `/v1/history/account-events` page for recovery. */
|
|
1774
|
+
async accountHistoryPage(owner, cursor, signal) {
|
|
1775
|
+
const res = await this.reads().accountEvents({
|
|
1776
|
+
owner,
|
|
1777
|
+
order: "desc",
|
|
1778
|
+
limit: 500,
|
|
1779
|
+
...(cursor ? { cursor } : {}),
|
|
1780
|
+
}, { signal });
|
|
1781
|
+
// Status before parse: a gateway error body need not be JSON, and a
|
|
1782
|
+
// SyntaxError from `res.json()` would bury the intended message.
|
|
1783
|
+
if (!res.ok) {
|
|
1784
|
+
let error;
|
|
1785
|
+
try {
|
|
1786
|
+
error = (await res.json()).error;
|
|
1787
|
+
}
|
|
1788
|
+
catch {
|
|
1789
|
+
error = undefined;
|
|
1790
|
+
}
|
|
1791
|
+
throw new Error(`account history read failed: ${error ?? `HTTP ${res.status}`}`);
|
|
1792
|
+
}
|
|
1793
|
+
const body = (await res.json());
|
|
1794
|
+
if (!Array.isArray(body.account_events))
|
|
1795
|
+
throw new Error(`account history read failed: ${body.error ?? `HTTP ${res.status}`}`);
|
|
1796
|
+
return { rows: body.account_events, nextCursor: body.next_cursor ?? null };
|
|
1797
|
+
}
|
|
1798
|
+
/** The newest height history has indexed in full
|
|
1799
|
+
* (`/v1/history/status` → `ingest.newest_height`). */
|
|
1800
|
+
async historyIndexedHeight(signal) {
|
|
1801
|
+
const res = await this.reads().historyStatus({ signal });
|
|
1802
|
+
if (!res.ok)
|
|
1803
|
+
throw new Error(`history status read failed: HTTP ${res.status}`);
|
|
1804
|
+
const body = (await res.json());
|
|
1805
|
+
const height = body.ingest?.newest_height;
|
|
1806
|
+
if (typeof height !== "number")
|
|
1807
|
+
throw new Error(`history status read failed: HTTP ${res.status}`);
|
|
1808
|
+
return height;
|
|
1836
1809
|
}
|
|
1837
1810
|
subscribeOrderbook(market, onFrame) {
|
|
1838
1811
|
return this.feed().subscribeOrderbook(market, onFrame);
|
|
@@ -1840,11 +1813,16 @@ export class ExchangeClient {
|
|
|
1840
1813
|
subscribeTrades(market, onFrame) {
|
|
1841
1814
|
return this.feed().subscribeTrades(market, onFrame);
|
|
1842
1815
|
}
|
|
1843
|
-
/** Close
|
|
1816
|
+
/** Close the shared `/ws` feed, any pending `orderbookSnapshot` feed, any
|
|
1817
|
+
* account backfill in progress, and stop their reconnect loops. */
|
|
1844
1818
|
disconnect() {
|
|
1819
|
+
for (const close of this.accountRecoveries)
|
|
1820
|
+
close();
|
|
1821
|
+
this.accountRecoveries.clear();
|
|
1822
|
+
for (const feed of this.snapshotFeeds)
|
|
1823
|
+
feed.close();
|
|
1824
|
+
this.snapshotFeeds.clear();
|
|
1845
1825
|
this.gatewayFeed?.close();
|
|
1846
|
-
for (const unsub of [...this.activeStreams])
|
|
1847
|
-
unsub();
|
|
1848
1826
|
}
|
|
1849
1827
|
}
|
|
1850
1828
|
// ---------------------------------------------------------------------------
|