@proof-labs/trading-sdk 4.0.0 → 5.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 +137 -6
- package/dist/account-state.d.ts +17 -0
- package/dist/account-state.d.ts.map +1 -0
- package/dist/account-state.js +63 -0
- package/dist/account-state.js.map +1 -0
- package/dist/client.d.ts +112 -31
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +472 -188
- package/dist/client.js.map +1 -1
- package/dist/codec-adapter.d.ts.map +1 -1
- package/dist/codec-adapter.js +11 -4
- package/dist/codec-adapter.js.map +1 -1
- package/dist/crypto.d.ts +20 -0
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +39 -0
- package/dist/crypto.js.map +1 -1
- package/dist/errors.d.ts +26 -3
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +111 -15
- package/dist/errors.js.map +1 -1
- package/dist/feed-types.d.ts +76 -0
- package/dist/feed-types.d.ts.map +1 -0
- package/dist/feed-types.js +2 -0
- package/dist/feed-types.js.map +1 -0
- package/dist/feed.d.ts +158 -0
- package/dist/feed.d.ts.map +1 -0
- package/dist/feed.js +474 -0
- package/dist/feed.js.map +1 -0
- package/dist/financial-state.d.ts +65 -0
- package/dist/financial-state.d.ts.map +1 -0
- package/dist/financial-state.js +345 -0
- package/dist/financial-state.js.map +1 -0
- package/dist/gateway-reads.d.ts +74 -0
- package/dist/gateway-reads.d.ts.map +1 -0
- package/dist/gateway-reads.js +91 -0
- package/dist/gateway-reads.js.map +1 -0
- package/dist/governance-query.d.ts +7 -13
- package/dist/governance-query.d.ts.map +1 -1
- package/dist/governance-query.js +131 -70
- package/dist/governance-query.js.map +1 -1
- package/dist/history.d.ts +17 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +150 -0
- package/dist/history.js.map +1 -0
- package/dist/index.d.ts +13 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/market-snapshot.d.ts +11 -0
- package/dist/market-snapshot.d.ts.map +1 -0
- package/dist/market-snapshot.js +325 -0
- package/dist/market-snapshot.js.map +1 -0
- package/dist/oracle-permissions.d.ts +51 -0
- package/dist/oracle-permissions.d.ts.map +1 -0
- package/dist/oracle-permissions.js +191 -0
- package/dist/oracle-permissions.js.map +1 -0
- package/dist/oracle-price-history.d.ts +30 -0
- package/dist/oracle-price-history.d.ts.map +1 -0
- package/dist/oracle-price-history.js +108 -0
- package/dist/oracle-price-history.js.map +1 -0
- package/dist/portfolio-history.d.ts +21 -0
- package/dist/portfolio-history.d.ts.map +1 -0
- package/dist/portfolio-history.js +49 -0
- package/dist/portfolio-history.js.map +1 -0
- package/dist/tx-result.d.ts +6 -0
- package/dist/tx-result.d.ts.map +1 -1
- package/dist/tx-result.js +42 -0
- package/dist/tx-result.js.map +1 -1
- package/dist/types.d.ts +235 -114
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +14 -5
- package/dist/types.js.map +1 -1
- package/dist/wasm/proof_trading_sdk_wasm_bg.wasm +0 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Proof Trading SDK
|
|
2
2
|
|
|
3
|
+
### Atomic financial evidence (TypeScript 4.2)
|
|
4
|
+
|
|
5
|
+
`client.queryFinancialState({ markets: [1], owners: [ownerHex] })` reads one
|
|
6
|
+
finalized-store snapshot through the gateway only. Select 1–8 markets and 1–8
|
|
7
|
+
owners; inputs are copied, sorted and canonicalized, with duplicates rejected.
|
|
8
|
+
The response includes exact selected market fee/funding settings, raw account
|
|
9
|
+
balances and positions, the fee pool, selected markets' insurance pools, and
|
|
10
|
+
optional PLP configuration. The PLP account is automatically included once.
|
|
11
|
+
All integers retain precision and absent stored values remain `null`; at most
|
|
12
|
+
2048 positions total and a one-MiB HTTP response are accepted, within five seconds.
|
|
13
|
+
A framing-only preflight also bounds nesting and aggregate value slots before
|
|
14
|
+
the maintained MessagePack decoder allocates containers; values are not decoded
|
|
15
|
+
by a second codec.
|
|
16
|
+
|
|
17
|
+
This is not equity, accrued-funding valuation, solvency or trading/withdrawal
|
|
18
|
+
authorization. `feesAccrued` is a lifetime fee/rebate counter, not cash.
|
|
19
|
+
`plp.bootstrapBalance` is a historical baseline, not additional PLP funds;
|
|
20
|
+
actual PLP cash is only its account balance. Do not double-count either field.
|
|
21
|
+
Other endpoints must be bracketed at the same `finalizedHeight` for cross-read
|
|
22
|
+
comparisons; the method does not claim a historical-height query parameter.
|
|
23
|
+
|
|
24
|
+
`queryAccountState(ownerHex?)` reads exact finalized settled balance and raw
|
|
25
|
+
positions through the gateway, without oracle valuation. Its bigint values are
|
|
26
|
+
not equity, accrued funding, available collateral or authorization. When
|
|
27
|
+
`queryAccount` fails closed during unsafe oracle conditions, show valuation as
|
|
28
|
+
unavailable; do not substitute this raw cash balance as healthy equity. Match
|
|
29
|
+
`finalizedHeight` across bracketed reads for a coherent economic snapshot.
|
|
30
|
+
|
|
3
31
|
TypeScript SDK for the [Proof Exchange](https://proof.trade): Ed25519 signing,
|
|
4
32
|
MessagePack codec, timestamp-nonce allocation, and gateway/CometBFT submission
|
|
5
33
|
for every exchange action.
|
|
@@ -150,8 +178,10 @@ class ExchangeClient {
|
|
|
150
178
|
queryOrderbook(market: number): Promise<Orderbook>;
|
|
151
179
|
queryOpenOrders(addressHex?: string): Promise<OpenOrder[]>;
|
|
152
180
|
queryMarkets(): Promise<MarketConfig[]>;
|
|
181
|
+
queryMarketsSnapshot(): Promise<MarketsSnapshot>;
|
|
153
182
|
queryAccount(addressHex?: string): Promise<AccountInfo | null>;
|
|
154
183
|
queryHealth(): Promise<{ status: string; height: number }>;
|
|
184
|
+
queryOraclePermissions(market: number): Promise<OraclePermissions>;
|
|
155
185
|
queryWithdrawal(id: bigint): Promise<WithdrawalRecord | null>;
|
|
156
186
|
queryPositionTriggers(addressHex?: string): Promise<PositionTriggerInfo[]>;
|
|
157
187
|
queryTriggerMarketConfigs(): Promise<TriggerMarketConfigInfo[]>;
|
|
@@ -168,6 +198,7 @@ class ExchangeClient {
|
|
|
168
198
|
queryHistoryWithdrawals(...): Promise<HistoryCashFlow[]>;
|
|
169
199
|
queryHistoryResolutions(...): Promise<HistoryResolution[]>;
|
|
170
200
|
queryHistoryPositions(...): Promise<HistoryPositionSnapshot[]>;
|
|
201
|
+
queryHistoryPositionsPage(...): Promise<HistoryPositionsPage>;
|
|
171
202
|
|
|
172
203
|
// Blocks
|
|
173
204
|
getBlock(height?: number): Promise<Record<string, unknown>>;
|
|
@@ -181,6 +212,105 @@ class ExchangeClient {
|
|
|
181
212
|
}
|
|
182
213
|
```
|
|
183
214
|
|
|
215
|
+
For chain-pinned, atomic committed market inventory, see
|
|
216
|
+
[the snapshot guide](docs/market-snapshot.md). The optional Rust `gateway`
|
|
217
|
+
feature additionally provides committed-time and exact-hash receipt reads plus
|
|
218
|
+
one-shot submission of already-signed bytes. It does not manage a caller's
|
|
219
|
+
durable journal, nonce allocation, retries or cutover authority.
|
|
220
|
+
|
|
221
|
+
`queryOraclePermissions(market)` reads one underlying perp's committed oracle
|
|
222
|
+
policy, calendar epoch and verdict at an exact finalized height. It preserves
|
|
223
|
+
u64 values as `bigint`, and returns `Legacy` with no permission claim while the
|
|
224
|
+
new policy is inactive. `Satisfied` covers only this oracle dependency, not all
|
|
225
|
+
portfolio dependencies or other trading checks. It never reads provider/observer
|
|
226
|
+
health; feeder freshness is a separate operational read, described below.
|
|
227
|
+
|
|
228
|
+
### Oracle freshness for trading UIs
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
const response = await client.reads().oracleHealth({ signal });
|
|
232
|
+
const health = await response.json();
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
This forwards `GET /v1/oracle/health` through the configured gateway, preserving
|
|
236
|
+
the response body, HTTP errors and cancellation. The Web-UI uses feeder freshness
|
|
237
|
+
for its existing delay warnings and order guards. Thresholds and display policy
|
|
238
|
+
remain in the application; `status: "ok"` alone does not mean fresh data, and
|
|
239
|
+
`embedded_feeder: false` must remain unavailable. This is operational evidence,
|
|
240
|
+
not trading authorization. Like every other gateway interaction, admin calls
|
|
241
|
+
included, it goes through the SDK
|
|
242
|
+
([ADR 0003](docs/adr/0003-every-gateway-interaction-through-the-sdk.md)).
|
|
243
|
+
|
|
244
|
+
### Optional native Rust gateway transport
|
|
245
|
+
|
|
246
|
+
Rust `proof-trading-sdk` 3.2.0 exposes `gateway::GatewayClient` with the optional
|
|
247
|
+
`gateway` feature. Default codec/WASM builds do not acquire an HTTP transport.
|
|
248
|
+
The four explicit operations are `chain_identity`, `oracle_permissions`,
|
|
249
|
+
`submit_signed_bytes` and `committed_receipt`; they use only the existing gateway
|
|
250
|
+
routes, with no direct-node fallback, signing, nonce allocation or hidden retry.
|
|
251
|
+
|
|
252
|
+
Configure an HTTPS origin (HTTP requires a URL-normalized loopback IP, not a DNS
|
|
253
|
+
name; numeric IPv4 aliases that normalize to loopback are allowed), a
|
|
254
|
+
1ms–60s total request deadline and a response cap no larger than 1MiB. Defaults
|
|
255
|
+
are 10 seconds and 256KiB. Redirects, environment proxies and automatic retries
|
|
256
|
+
are disabled. An optional API key is sent only in `X-Api-Key` and is redacted
|
|
257
|
+
from diagnostics. Signed input is limited to 4096 bytes, fitting the gateway's
|
|
258
|
+
default JSON body cap after base64 encoding. These are client resource bounds,
|
|
259
|
+
not production admission policy.
|
|
260
|
+
|
|
261
|
+
`SubmissionOutcome` distinguishes committed execution, CheckTx rejection,
|
|
262
|
+
pending execution and explicit pre-admission rejection. A transport/error body
|
|
263
|
+
or hash mismatch retains `GatewayError.reconcile_hash`: the transaction may
|
|
264
|
+
have landed, so retain its exact bytes and reconcile rather than re-sign.
|
|
265
|
+
`committed_receipt` requires the requested hash and a positive committed height;
|
|
266
|
+
not-found/not-indexed errors never clear pending state. A code-zero receipt is
|
|
267
|
+
execution success, **not** an oracle permission certificate. Retry-After remains
|
|
268
|
+
an exact delay, an absolute HTTP date, or explicitly `Invalid`; callers must not
|
|
269
|
+
discard an invalid header and retry immediately.
|
|
270
|
+
|
|
271
|
+
`submit_signed_bytes_with_evidence` adds strict **per-attempt** refusal evidence
|
|
272
|
+
without changing the original method's behaviour. It returns
|
|
273
|
+
`SubmissionEvidence`, a `Submission<PreAdmissionRefusal>`: every outcome keeps
|
|
274
|
+
the locally calculated hash, and only `RejectedBeforeAdmission` carries the
|
|
275
|
+
typed `refusal`, so a refusal cannot disagree with its outcome. The original
|
|
276
|
+
method returns `Submission`, whose `RejectedBeforeAdmission` carries
|
|
277
|
+
`refusal: ()`. Only exact source-qualified body/status pairs qualify: authorization,
|
|
278
|
+
rate limiting, maintenance, admission overload/verifier disconnection, and
|
|
279
|
+
specific parse/signature refusals. Generic HTTP errors, unrecognized bodies,
|
|
280
|
+
unknown fields or a hash-bearing 503 remain unresolved. Maintenance requires
|
|
281
|
+
the exact error and `paused` or `cancel-only` mode; substring matching is not
|
|
282
|
+
used. These contracts are checked against
|
|
283
|
+
[`api-gateway@3c711c2`](https://github.com/Proof-labs/api-gateway/tree/3c711c2a3c29ca8f37d2d986fe817d21a9eeebc3)
|
|
284
|
+
(`src/server.rs`, `src/exchange.rs`, `src/types/exchange_response.rs`). Qualify
|
|
285
|
+
the actual deployed gateway image against that contract before using the
|
|
286
|
+
evidence operationally; a loopback fixture is not deployment qualification.
|
|
287
|
+
|
|
288
|
+
A refusal describes **this one request only**. The SDK does not know a
|
|
289
|
+
journal's earlier attempts: preserve any previous ambiguity, and retire an
|
|
290
|
+
entry on this evidence only after independently establishing the sole-attempt
|
|
291
|
+
condition. Neither method retries, re-signs, allocates a nonce or changes live
|
|
292
|
+
state beyond the caller-requested POST. Receipts remain exact-hash reads;
|
|
293
|
+
not-found is never proof that the transaction cannot execute.
|
|
294
|
+
|
|
295
|
+
The evidence method retains a `Retry-After` header even if it is invalid or
|
|
296
|
+
duplicated. Only an absent header uses JSON `retryAfterMs`, rounding **up** to
|
|
297
|
+
the existing whole-second representation without overflow or shortening. Null,
|
|
298
|
+
negative, fractional, non-numeric, duplicate or overflowing JSON delay values
|
|
299
|
+
are invalid, not an absent hint; invalid rate-limit bodies do not qualify as
|
|
300
|
+
pre-admission evidence. The caller owns its quiet period and reconciliation;
|
|
301
|
+
this SDK performs no sleep or automatic resubmission.
|
|
302
|
+
|
|
303
|
+
For a deliberately read-only local contract probe, with no signing/key inputs:
|
|
304
|
+
|
|
305
|
+
```sh
|
|
306
|
+
cargo run -p proof-trading-sdk --features gateway --example gateway_oracle_probe -- \
|
|
307
|
+
http://127.0.0.1:9080 EXPECTED_CHAIN 1
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
It checks chain identity before the permission read and reports both heights;
|
|
311
|
+
sequential reads are not a single atomic snapshot. Neither a successful probe
|
|
312
|
+
nor a committed market permission authorizes a portfolio action or release.
|
|
313
|
+
|
|
184
314
|
Position triggers are exact-position-generation brackets. For an existing
|
|
185
315
|
bracket, `queryPositionTriggers()` returns its epoch; first attach must use the
|
|
186
316
|
epoch on the canonical account position read and must never guess `1`. Submit
|
|
@@ -285,12 +415,13 @@ loop at 9 s+ under load.
|
|
|
285
415
|
|
|
286
416
|
The SDK reads that shape and stops working for it:
|
|
287
417
|
|
|
288
|
-
| Gateway answers
|
|
289
|
-
|
|
|
290
|
-
| `code` + `height`
|
|
291
|
-
| `code`, no `height`
|
|
292
|
-
| `txHash`, no `code`
|
|
293
|
-
|
|
|
418
|
+
| Gateway answers | `TxResult` | Does the SDK poll? |
|
|
419
|
+
| --------------------------------------------------------------------------------- | ------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
420
|
+
| `code` + `height` | `ok` / `engine`, with `height` + `events` | **No** — the tx executed; there is nothing to wait for |
|
|
421
|
+
| `code`, no `height` | `engine` | **No** — a CheckTx reject never enters a block, so no DeliverTx will run |
|
|
422
|
+
| `txHash`, no `code` | `timeout` | **Yes** — the gateway broadcast it but couldn't report the outcome in time (park deadline, duplicate in flight, unreadable result). The tx may still commit, so it is reconciled by hash — **not** reported as a rejection |
|
|
423
|
+
| Structured HTTP 200/503 refusal, a recognized reason, no admission/verdict fields | `transport` (code 1 / 503), original error reason | **No** — the gateway refused admission; an unrecognized message, unknown 5xx, or contradictory fields still reconcile by hash |
|
|
424
|
+
| `{status:"ok"}` only | `ok`, no `height` | **Yes** — a pre-#90 gateway acks CheckTx only, so inclusion is still unknown |
|
|
294
425
|
|
|
295
426
|
That last row is why upgrading the SDK is safe against a gateway that has not been
|
|
296
427
|
upgraded yet: absence of `code`/`height` still means "execution unknown", and the old
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Raw settled ledger facts. Never equity, margin, or withdrawal authorization. */
|
|
2
|
+
export interface RawAccountPosition {
|
|
3
|
+
owner: string;
|
|
4
|
+
market: number;
|
|
5
|
+
side: "Buy" | "Sell";
|
|
6
|
+
entryPrice: bigint;
|
|
7
|
+
size: bigint;
|
|
8
|
+
lastFundingIndex: bigint;
|
|
9
|
+
}
|
|
10
|
+
export interface AccountState {
|
|
11
|
+
owner: string;
|
|
12
|
+
finalizedHeight: bigint;
|
|
13
|
+
balance: bigint;
|
|
14
|
+
positions: RawAccountPosition[];
|
|
15
|
+
}
|
|
16
|
+
export declare function decodeAccountState(raw: unknown, expectedOwner?: string): AccountState;
|
|
17
|
+
//# sourceMappingURL=account-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-state.d.ts","sourceRoot":"","sources":["../src/account-state.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AACD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,kBAAkB,EAAE,CAAC;CACjC;AAkCD,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,OAAO,EACZ,aAAa,CAAC,EAAE,MAAM,GACrB,YAAY,CAgCd"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
function invalid(field) {
|
|
2
|
+
throw new Error(`account state decode: invalid ${field}`);
|
|
3
|
+
}
|
|
4
|
+
function tuple(value, length, field) {
|
|
5
|
+
if (!Array.isArray(value) || value.length !== length)
|
|
6
|
+
return invalid(field);
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
function integer(value, field, signed = false) {
|
|
10
|
+
if (typeof value === "number" && Number.isSafeInteger(value))
|
|
11
|
+
value = BigInt(value);
|
|
12
|
+
const min = signed ? -(1n << 63n) : 0n;
|
|
13
|
+
const max = signed ? (1n << 63n) - 1n : (1n << 64n) - 1n;
|
|
14
|
+
if (typeof value !== "bigint" || value < min || value > max)
|
|
15
|
+
return invalid(field);
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
function owner(value) {
|
|
19
|
+
if (!(value instanceof Uint8Array) && !Array.isArray(value))
|
|
20
|
+
return invalid("owner");
|
|
21
|
+
const bytes = Array.from(value);
|
|
22
|
+
if (bytes.length !== 20 ||
|
|
23
|
+
bytes.some((b) => typeof b !== "number" || !Number.isInteger(b) || b < 0 || b > 255))
|
|
24
|
+
return invalid("owner");
|
|
25
|
+
return bytes
|
|
26
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
27
|
+
.join("");
|
|
28
|
+
}
|
|
29
|
+
export function decodeAccountState(raw, expectedOwner) {
|
|
30
|
+
const fields = tuple(raw, 4, "response");
|
|
31
|
+
const address = owner(fields[0]);
|
|
32
|
+
if (expectedOwner !== undefined && address !== expectedOwner.toLowerCase())
|
|
33
|
+
return invalid("owner binding");
|
|
34
|
+
if (!Array.isArray(fields[3]) || fields[3].length > 2048)
|
|
35
|
+
return invalid("positions");
|
|
36
|
+
let previous = -1n;
|
|
37
|
+
const positions = fields[3].map((rawPosition) => {
|
|
38
|
+
const p = tuple(rawPosition, 6, "position");
|
|
39
|
+
const positionOwner = owner(p[0]);
|
|
40
|
+
const market = integer(p[1], "market");
|
|
41
|
+
if (market > 0xffffffffn || market <= previous || positionOwner !== address)
|
|
42
|
+
return invalid("position binding/order");
|
|
43
|
+
previous = market;
|
|
44
|
+
const side = p[2];
|
|
45
|
+
if (side !== "Buy" && side !== "Sell")
|
|
46
|
+
return invalid("side");
|
|
47
|
+
return {
|
|
48
|
+
owner: positionOwner,
|
|
49
|
+
market: Number(market),
|
|
50
|
+
side,
|
|
51
|
+
entryPrice: integer(p[3], "entry price"),
|
|
52
|
+
size: integer(p[4], "size"),
|
|
53
|
+
lastFundingIndex: integer(p[5], "funding index", true),
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
owner: address,
|
|
58
|
+
finalizedHeight: integer(fields[1], "height"),
|
|
59
|
+
balance: integer(fields[2], "balance"),
|
|
60
|
+
positions,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=account-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-state.js","sourceRoot":"","sources":["../src/account-state.ts"],"names":[],"mappings":"AAgBA,SAAS,OAAO,CAAC,KAAa;IAC5B,MAAM,IAAI,KAAK,CAAC,iCAAiC,KAAK,EAAE,CAAC,CAAC;AAC5D,CAAC;AACD,SAAS,KAAK,CAAC,KAAc,EAAE,MAAc,EAAE,KAAa;IAC1D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5E,OAAO,KAAK,CAAC;AACf,CAAC;AACD,SAAS,OAAO,CAAC,K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M,CAAC,CAAC;QAC9D,OAAO;YACL,KAAK,EAAE,aAAa;YACpB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;YACtB,IAAI;YACJ,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC;YACxC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;YAC3B,gBAAgB,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,CAAC;SACvD,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO;QACL,KAAK,EAAE,OAAO;QACd,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC;QAC7C,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;QACtC,SAAS;KACV,CAAC;AACJ,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { GatewayFeed, type GatewayFeedOptions, type AccountFeedAuth } from "./feed.js";
|
|
2
|
+
import type { AccountFrame, OrderbookFrame, TradeFrame } from "./feed-types.js";
|
|
3
|
+
import { type PortfolioHistoryOptions, type PortfolioHistoryPage } from "./portfolio-history.js";
|
|
4
|
+
import { type OraclePriceHistoryOptions, type OraclePriceHistoryPage } from "./oracle-price-history.js";
|
|
5
|
+
import { GatewayReads, type GatewayFetch } from "./gateway-reads.js";
|
|
6
|
+
import { type AccountState } from "./account-state.js";
|
|
7
|
+
import { type FinancialState, type FinancialStateSelection } from "./financial-state.js";
|
|
8
|
+
import type { Action, TxResult, PlaceOrder, MarketOrder, AccountInfo, HistoryCashFlow, HistoryFillsPage, HistoryPositionSnapshot, HistoryPositionsPage, HistoryResolution, MarketConfig, OpenOrder, AdlQueueEntry, Orderbook, Ticker, WithdrawalRecord, AdminSignerRegistry, ProposalPage, EventInfo, SetPositionTriggers, PositionTriggerInfo, TriggerStatus, PositionTriggerHistoryFilters, PositionTriggerHistoryPage, TriggerMarketHistoryFilters, TriggerMarketHistoryPage, TriggerMarketConfigInfo } from "./types.js";
|
|
9
|
+
import type { MarketsSnapshot } from "./types.js";
|
|
10
|
+
import { type OraclePermissions } from "./oracle-permissions.js";
|
|
2
11
|
/**
|
|
3
12
|
* Fetch the 32-byte chain_id binding from a CometBFT RPC's `/status`
|
|
4
13
|
* endpoint. Hashes `result.node_info.network` via `chainIdFromString`.
|
|
@@ -9,6 +18,11 @@ import type { Action, TxResult, PlaceOrder, MarketOrder, AccountInfo, HistoryCas
|
|
|
9
18
|
* bytes without going through a client instance.
|
|
10
19
|
*/
|
|
11
20
|
export declare function fetchChainId(rpcUrl: string): Promise<Uint8Array>;
|
|
21
|
+
/** Vendor-neutral Ed25519 signer. The SDK owns domain, encoding and nonces. */
|
|
22
|
+
export interface ExternalSigner {
|
|
23
|
+
publicKey: Uint8Array;
|
|
24
|
+
signRaw(message: Uint8Array): Promise<Uint8Array>;
|
|
25
|
+
}
|
|
12
26
|
export interface ExchangeClientOptions {
|
|
13
27
|
/**
|
|
14
28
|
* Override for the CometBFT RPC endpoint on the **internal**
|
|
@@ -128,10 +142,15 @@ export declare class ExchangeClient {
|
|
|
128
142
|
* `/v1/status`, or `${rpcUrl}/status` on the direct path) on first submit.
|
|
129
143
|
*/
|
|
130
144
|
private chainId;
|
|
145
|
+
/** Inventory reconciliation requires the caller's pin, not auto-discovery. */
|
|
146
|
+
private readonly inventoryChainId;
|
|
131
147
|
private allowUnbound;
|
|
132
148
|
/** Single-flight guard so concurrent submits share one /status fetch. */
|
|
133
149
|
private chainIdPromise;
|
|
134
150
|
private privateKey;
|
|
151
|
+
private externalSigner;
|
|
152
|
+
private signerRevision;
|
|
153
|
+
private gatewayFeed;
|
|
135
154
|
private publicKey;
|
|
136
155
|
private address;
|
|
137
156
|
private addressHex;
|
|
@@ -215,6 +234,16 @@ export declare class ExchangeClient {
|
|
|
215
234
|
getChainId(): Uint8Array | null;
|
|
216
235
|
/** Set the private key for signing transactions. */
|
|
217
236
|
setPrivateKey(key: Uint8Array): void;
|
|
237
|
+
/** Replace the signing connection; no private key is retained. */
|
|
238
|
+
setExternalSigner(signer: ExternalSigner): void;
|
|
239
|
+
/** Sign only. Cancellation or a replaced connection prevents submission. */
|
|
240
|
+
signTx(action: Action, opts?: {
|
|
241
|
+
signal?: AbortSignal;
|
|
242
|
+
}): Promise<Uint8Array>;
|
|
243
|
+
/** Sign existing gateway account-events auth bytes; call again per reconnect.
|
|
244
|
+
* Direct owner keys only; no delegated-owner authorization is inferred.
|
|
245
|
+
*/
|
|
246
|
+
accountAuth(owner?: string, afterId?: bigint): Promise<AccountFeedAuth>;
|
|
218
247
|
getAddress(): Uint8Array | null;
|
|
219
248
|
getAddressHex(): string | null;
|
|
220
249
|
getPublicKey(): Uint8Array | null;
|
|
@@ -230,16 +259,18 @@ export declare class ExchangeClient {
|
|
|
230
259
|
/**
|
|
231
260
|
* Allocate the next timestamp nonce.
|
|
232
261
|
*
|
|
233
|
-
* Algorithm: `max(now_ms, last_nonce + 1)
|
|
234
|
-
*
|
|
262
|
+
* Algorithm: `max(now_ms, last_nonce + 1)`. Refuse allocation above
|
|
263
|
+
* `now_ms + 60s` without rewinding or repeating the last nonce.
|
|
235
264
|
*
|
|
236
265
|
* Engine window: `[block_time - 2 days, block_time + 1 day]`. All four
|
|
237
266
|
* rejection modes (too old, too far future, replay, below oldest) map to
|
|
238
267
|
* code 21 `InvalidNonce`. Nonces are burned on success — no rewinding.
|
|
239
268
|
*
|
|
240
|
-
*
|
|
269
|
+
* Concurrent calls on this client reserve distinct nonces synchronously.
|
|
241
270
|
*/
|
|
242
271
|
private nextTimestampNonce;
|
|
272
|
+
/** Highest locally allocated nonce; never rewound after rejection. */
|
|
273
|
+
get currentNonce(): bigint;
|
|
243
274
|
/**
|
|
244
275
|
* Sign and submit a transaction via broadcast_tx_sync.
|
|
245
276
|
*
|
|
@@ -397,6 +428,13 @@ export declare class ExchangeClient {
|
|
|
397
428
|
* unknown.
|
|
398
429
|
*/
|
|
399
430
|
private awaitCommit;
|
|
431
|
+
/** Per-submission finality. Timeout/cancellation retains the hash as unknown.
|
|
432
|
+
* Never resubmits writes. Use setUnsafeFastSubmit(true) to avoid a second poller.
|
|
433
|
+
*/
|
|
434
|
+
waitForDelivery(sync: TxResult, opts?: {
|
|
435
|
+
timeoutMs?: number;
|
|
436
|
+
signal?: AbortSignal;
|
|
437
|
+
}): Promise<TxResult>;
|
|
400
438
|
/**
|
|
401
439
|
* The loaded signer's 20-byte owner address, or throw if no key is set.
|
|
402
440
|
* Every convenience builder needs it, so the guard lives here.
|
|
@@ -445,14 +483,21 @@ export declare class ExchangeClient {
|
|
|
445
483
|
*/
|
|
446
484
|
private queryOwnerScoped;
|
|
447
485
|
queryOrderbook(market: number): Promise<Orderbook>;
|
|
486
|
+
/** One atomic committed inventory. Requires explicit chainId; never falls
|
|
487
|
+
* back to a node or synthesizes inventory from independent list reads. */
|
|
488
|
+
queryMarketsSnapshot(): Promise<MarketsSnapshot>;
|
|
448
489
|
/** List all registered market configs. */
|
|
449
490
|
queryMarkets(): Promise<MarketConfig[]>;
|
|
450
|
-
/**
|
|
451
|
-
*
|
|
452
|
-
* governance reads: a missing envelope or
|
|
453
|
-
*
|
|
454
|
-
|
|
455
|
-
|
|
491
|
+
/** All events: each is two prediction-binary books (EBY/EBN) under one
|
|
492
|
+
* `EventInfo`, plus every conditional attached to it. Fail-closed like the
|
|
493
|
+
* governance reads: a missing envelope or malformed row is a refusal.
|
|
494
|
+
* Decoder pinned to the engine golden vector in governance-query.test.ts. */
|
|
495
|
+
queryEvents(): Promise<EventInfo[]>;
|
|
496
|
+
/** A single event by id, or `null` if it does not exist. The node returns
|
|
497
|
+
* 404 for a missing event (the engine's msgpack-nil), so a raw fetch is used
|
|
498
|
+
* here to map 404 -> null while still throwing on real transport / decode
|
|
499
|
+
* failures. */
|
|
500
|
+
queryEvent(eventId: number): Promise<EventInfo | null>;
|
|
456
501
|
/** Current whole-position trigger brackets for one owner. Immutable
|
|
457
502
|
* lifecycle history is a separate gateway/indexer query below. */
|
|
458
503
|
queryPositionTriggers(addressHex?: string): Promise<PositionTriggerInfo[]>;
|
|
@@ -462,6 +507,8 @@ export declare class ExchangeClient {
|
|
|
462
507
|
/** Read the fail-closed next-height trigger admission predicate. Heights
|
|
463
508
|
* are parsed from raw JSON into bigint without a lossy Number round-trip. */
|
|
464
509
|
queryTriggerStatus(): Promise<TriggerStatus>;
|
|
510
|
+
/** One committed oracle dependency, not provider health or action authorization. */
|
|
511
|
+
queryOraclePermissions(market: number): Promise<OraclePermissions>;
|
|
465
512
|
/** Immutable owner-bearing trigger lifecycle history. This always uses the
|
|
466
513
|
* public gateway, including when the client is configured for direct-node
|
|
467
514
|
* current-state reads; the node does not own indexer history. */
|
|
@@ -504,6 +551,10 @@ export declare class ExchangeClient {
|
|
|
504
551
|
/** Fetch a withdrawal record by id. Returns `null` for unknown ids
|
|
505
552
|
* (the engine encodes "not found" as msgpack `nil`, not HTTP 404). */
|
|
506
553
|
queryWithdrawal(id: bigint): Promise<WithdrawalRecord | null>;
|
|
554
|
+
/** Raw finalized ledger facts, independent of oracle valuation. Not authorization. */
|
|
555
|
+
queryFinancialState(selection: FinancialStateSelection): Promise<FinancialState>;
|
|
556
|
+
/** Raw finalized ledger facts, independent of oracle valuation. Not authorization. */
|
|
557
|
+
queryAccountState(addressHex?: string): Promise<AccountState>;
|
|
507
558
|
queryAccount(addressHex?: string): Promise<AccountInfo | null>;
|
|
508
559
|
/** Convenience: fetch just the USDC balance (microUSDC) for an address. */
|
|
509
560
|
queryBalance(addressHex?: string): Promise<bigint | null>;
|
|
@@ -521,51 +572,68 @@ export declare class ExchangeClient {
|
|
|
521
572
|
* and top-of-book blobs). Returns `null` if the market is unknown. Routes
|
|
522
573
|
* through the gateway's `/v1/ticker`. */
|
|
523
574
|
queryTicker(market: number): Promise<Ticker | null>;
|
|
524
|
-
/**
|
|
525
|
-
*
|
|
526
|
-
* reconstruction (P2 #6). */
|
|
575
|
+
/** Direct relayer deposits and custody-confirmed deposits, newest first.
|
|
576
|
+
* Returns a bounded merged head, not a cursor over the complete history. */
|
|
527
577
|
queryHistoryDeposits(addressHex?: string, opts?: {
|
|
528
578
|
fromMs?: number;
|
|
529
579
|
toMs?: number;
|
|
530
580
|
limit?: number;
|
|
531
581
|
}): Promise<HistoryCashFlow[]>;
|
|
532
|
-
/**
|
|
533
|
-
*
|
|
534
|
-
*
|
|
582
|
+
/** Direct relayer withdrawals and indexed custody events, newest first,
|
|
583
|
+
* capped after merging each kind's first page. This is not withdrawal status:
|
|
584
|
+
* ownerless confirmation events
|
|
585
|
+
* are not indexed for the account. Use queryWithdrawal(id) for status.
|
|
586
|
+
* Request/refund amounts exclude fees; unknown signedDelta stays empty. */
|
|
535
587
|
queryHistoryWithdrawals(addressHex?: string, opts?: {
|
|
536
588
|
fromMs?: number;
|
|
537
589
|
toMs?: number;
|
|
538
590
|
limit?: number;
|
|
539
591
|
}): Promise<HistoryCashFlow[]>;
|
|
540
|
-
/**
|
|
541
|
-
* return identical row shapes (HistoryCashFlow); the difference is
|
|
542
|
-
* which kinds the server includes. */
|
|
592
|
+
/** Owner-filtered indexer events; never the removed node history routes. */
|
|
543
593
|
private queryHistoryCashFlow;
|
|
544
594
|
/** Per-user position-at-resolution log — each row is one settlement or
|
|
545
595
|
* voided-conditional snapshot. Feeds the Portfolio "Resolved" tab
|
|
546
|
-
* (P2 #7). Optional `
|
|
596
|
+
* (P2 #7). Optional `eventId` filter scopes to one event.
|
|
547
597
|
*
|
|
548
598
|
* `fromMs` / `toMs` are unix-ms timestamps; omit for unbounded.
|
|
549
599
|
* `limit` caps at 1000 server-side. Results are newest-first. */
|
|
550
600
|
queryHistoryResolutions(addressHex?: string, opts?: {
|
|
551
|
-
|
|
601
|
+
eventId?: number;
|
|
552
602
|
fromMs?: number;
|
|
553
603
|
toMs?: number;
|
|
554
604
|
limit?: number;
|
|
555
605
|
}): Promise<HistoryResolution[]>;
|
|
556
|
-
/**
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
606
|
+
/** Named gateway responses for HTTP consumers that own body parsing, deadlines
|
|
607
|
+
* and scheduling. Prefer typed query methods when raw response metadata is unnecessary.
|
|
608
|
+
* Uses this client's gateway; never targets a node, even in internal node mode.
|
|
609
|
+
*/
|
|
610
|
+
reads(opts?: {
|
|
611
|
+
fetch?: GatewayFetch;
|
|
612
|
+
}): GatewayReads;
|
|
613
|
+
/** Gateway/indexer portfolio page, including in internal node mode.
|
|
614
|
+
* Keep bounds fixed across opaque cursors. */
|
|
615
|
+
queryPortfolioHistory(owner: string, opts: PortfolioHistoryOptions): Promise<PortfolioHistoryPage>;
|
|
616
|
+
/** One newest-first gateway page of a market's indexed `price_updated`
|
|
617
|
+
* history. Keep market and bounds fixed across opaque cursors. */
|
|
618
|
+
queryOraclePriceHistory(market: number, options: OraclePriceHistoryOptions): Promise<OraclePriceHistoryPage>;
|
|
619
|
+
/** Compatibility array of position snapshots. Absent close fields are empty
|
|
620
|
+
* strings and timestamps are milliseconds. Use queryHistoryPositionsPage for
|
|
621
|
+
* nullable fields, exact block times and opaque cursor continuation. */
|
|
563
622
|
queryHistoryPositions(addressHex?: string, opts?: {
|
|
564
623
|
market?: number;
|
|
565
624
|
fromMs?: number;
|
|
566
625
|
toMs?: number;
|
|
567
626
|
limit?: number;
|
|
568
627
|
}): Promise<HistoryPositionSnapshot[]>;
|
|
628
|
+
/** Gateway/indexer snapshots, newest first. Preserve filters when passing an
|
|
629
|
+
* opaque nextCursor back in opts.cursor. Null close fields stay null. */
|
|
630
|
+
queryHistoryPositionsPage(addressHex?: string, opts?: {
|
|
631
|
+
market?: number;
|
|
632
|
+
fromMs?: number;
|
|
633
|
+
toMs?: number;
|
|
634
|
+
limit?: number;
|
|
635
|
+
cursor?: string;
|
|
636
|
+
}): Promise<HistoryPositionsPage>;
|
|
569
637
|
/**
|
|
570
638
|
* Executed fills for an owner, newest first, keyset-paged. The endpoint
|
|
571
639
|
* returns an envelope rather than a bare array: pass `opts.cursor` from a
|
|
@@ -596,14 +664,16 @@ export declare class ExchangeClient {
|
|
|
596
664
|
*
|
|
597
665
|
* Auth: account streams require auth only when the gateway runs with
|
|
598
666
|
* `--api-key`. A browser `WebSocket` cannot send the `X-Api-Key` header, so
|
|
599
|
-
* the SDK uses the gateway's signed-query auth instead — when a private key
|
|
600
|
-
* is
|
|
667
|
+
* the SDK uses the gateway's signed-query auth instead — when a private key or external signer
|
|
668
|
+
* is connected it signs the `ProofExchange-account-events-v1`
|
|
601
669
|
* message and appends `public_key` / `signature` / `timestamp_ms`. Against
|
|
602
670
|
* an unauthenticated gateway (e.g. devnet) the owner alone is enough.
|
|
603
671
|
*
|
|
604
672
|
* Returns an unsubscribe function; `disconnect()` closes all streams.
|
|
605
673
|
*/
|
|
606
|
-
subscribeAccountEvents(owner: Uint8Array | string, onEvent: (event: Record<string, unknown>) => void, opts?: WsStreamOptions
|
|
674
|
+
subscribeAccountEvents(owner: Uint8Array | string, onEvent: (event: Record<string, unknown>) => void, opts?: WsStreamOptions & {
|
|
675
|
+
auth?: false;
|
|
676
|
+
}): () => void;
|
|
607
677
|
/**
|
|
608
678
|
* Subscribe to the L2 orderbook delta stream for a market
|
|
609
679
|
* (`/orderbook-deltas`). Mirrors the Python SDK's `OrderbookDeltaStream`:
|
|
@@ -625,6 +695,17 @@ export declare class ExchangeClient {
|
|
|
625
695
|
* socket.
|
|
626
696
|
*/
|
|
627
697
|
private openStream;
|
|
698
|
+
/** Shared multiplexed /ws feed. Options apply on first creation only.
|
|
699
|
+
* Reconnect restores snapshots, not missed events. Default auth reads the current signer.
|
|
700
|
+
*/
|
|
701
|
+
feed(opts?: Partial<GatewayFeedOptions>): GatewayFeed;
|
|
702
|
+
/** Account snapshot plus live stream, with auth renewed per reconnect. */
|
|
703
|
+
subscribeAccount(onFrame: (frame: AccountFrame) => void, opts?: {
|
|
704
|
+
owner?: string;
|
|
705
|
+
auth?: false;
|
|
706
|
+
}): () => void;
|
|
707
|
+
subscribeOrderbook(market: number, onFrame: (frame: OrderbookFrame) => void): () => void;
|
|
708
|
+
subscribeTrades(market: number, onFrame: (frame: TradeFrame) => void): () => void;
|
|
628
709
|
/** Close every open WebSocket stream and stop their reconnect loops. */
|
|
629
710
|
disconnect(): void;
|
|
630
711
|
}
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
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,oBAAoB,EAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAUrE,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC7B,MAAM,sBAAsB,CAAC;AAqB9B,OAAO,KAAK,EACV,MAAM,EAEN,QAAQ,EACR,UAAU,EACV,WAAW,EACX,WAAW,EAGX,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EAGZ,SAAS,EACT,aAAa,EACb,SAAS,EAET,MAAM,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