@waterx/sdk 4.3.3 → 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/.claude/skills/waterx-sdk-integration/SKILL.md +41 -35
- package/README.md +81 -77
- package/dist/cjs/src/account/config.d.ts +3 -5
- package/dist/cjs/src/account/funding/wormhole.d.ts +1 -2
- package/dist/cjs/src/account/funding/wormhole.js +1 -2
- package/dist/cjs/src/oracle/aggregate.d.ts +45 -61
- package/dist/cjs/src/oracle/aggregate.js +138 -138
- package/dist/cjs/src/oracle/config.d.ts +35 -49
- package/dist/cjs/src/oracle/config.js +1 -1
- package/dist/cjs/src/oracle/host.d.ts +14 -19
- package/dist/cjs/src/oracle/host.js +3 -3
- package/dist/cjs/src/oracle/index.d.ts +25 -16
- package/dist/cjs/src/oracle/index.js +79 -66
- package/dist/cjs/src/oracle/price-update-rule.d.ts +104 -66
- package/dist/cjs/src/oracle/price-update-rule.js +24 -16
- package/dist/cjs/src/oracle/pyth-pro-history.d.ts +36 -0
- package/dist/cjs/src/oracle/pyth-pro-history.js +41 -0
- package/dist/cjs/src/oracle/read-plane.d.ts +35 -53
- package/dist/cjs/src/oracle/read-plane.js +26 -48
- package/dist/cjs/src/oracle/read-prices.d.ts +105 -0
- package/dist/cjs/src/oracle/read-prices.js +162 -0
- package/dist/cjs/src/oracle/rule-registry.d.ts +12 -12
- package/dist/cjs/src/oracle/rule-registry.js +12 -14
- package/dist/cjs/src/oracle/rules/pyth-lazer-rule.d.ts +24 -3
- package/dist/cjs/src/oracle/rules/pyth-lazer-rule.js +40 -20
- package/dist/cjs/src/oracle/rules/waterx-rule.d.ts +137 -12
- package/dist/cjs/src/oracle/rules/waterx-rule.js +318 -55
- package/dist/cjs/src/oracle/schedule.d.ts +109 -0
- package/dist/cjs/src/oracle/schedule.js +991 -0
- package/dist/cjs/src/oracle/source-list.d.ts +31 -27
- package/dist/cjs/src/oracle/source-list.js +43 -45
- package/dist/cjs/src/oracle/symbol-catalog.d.ts +54 -0
- package/dist/cjs/src/oracle/symbol-catalog.js +69 -0
- package/dist/cjs/src/oracle/update-fetch.d.ts +11 -15
- package/dist/cjs/src/oracle/update-fetch.js +12 -19
- package/dist/cjs/src/oracle/validate.d.ts +105 -0
- package/dist/cjs/src/oracle/validate.js +185 -0
- package/dist/cjs/src/oracle/weight-coverage.d.ts +79 -0
- package/dist/cjs/src/oracle/weight-coverage.js +173 -0
- package/dist/cjs/src/perp/client.d.ts +35 -52
- package/dist/cjs/src/perp/client.js +44 -17
- package/dist/cjs/src/perp/config-view.d.ts +5 -14
- package/dist/cjs/src/perp/config-view.js +5 -16
- package/dist/cjs/src/perp/config.d.ts +3 -3
- package/dist/cjs/src/perp/config.js +11 -13
- package/dist/cjs/src/perp/index.d.ts +4 -6
- package/dist/cjs/src/perp/index.js +35 -18
- package/dist/cjs/src/perp/tx-builders/common.d.ts +86 -48
- package/dist/cjs/src/perp/tx-builders/common.js +115 -47
- package/dist/cjs/src/perp/tx-builders/wlp.d.ts +3 -14
- package/dist/cjs/src/perp/tx-builders/wlp.js +6 -35
- package/dist/cjs/src/perp/tx-builders.d.ts +6 -5
- package/dist/cjs/src/perp/tx-builders.js +16 -10
- package/dist/cjs/src/unified-client.d.ts +8 -34
- package/dist/cjs/src/unified-client.js +3 -4
- package/dist/cjs/src/utils/config.d.ts +0 -8
- package/dist/cjs/src/utils/config.js +5 -13
- package/dist/src/account/config.d.ts +3 -5
- package/dist/src/account/funding/wormhole.d.ts +1 -2
- package/dist/src/account/funding/wormhole.js +1 -2
- package/dist/src/oracle/aggregate.d.ts +45 -61
- package/dist/src/oracle/aggregate.js +138 -137
- package/dist/src/oracle/config.d.ts +35 -49
- package/dist/src/oracle/config.js +1 -1
- package/dist/src/oracle/host.d.ts +14 -19
- package/dist/src/oracle/host.js +3 -3
- package/dist/src/oracle/index.d.ts +25 -16
- package/dist/src/oracle/index.js +55 -50
- package/dist/src/oracle/price-update-rule.d.ts +104 -66
- package/dist/src/oracle/price-update-rule.js +23 -16
- package/dist/src/oracle/pyth-pro-history.d.ts +36 -0
- package/dist/src/oracle/pyth-pro-history.js +38 -0
- package/dist/src/oracle/read-plane.d.ts +35 -53
- package/dist/src/oracle/read-plane.js +25 -47
- package/dist/src/oracle/read-prices.d.ts +105 -0
- package/dist/src/oracle/read-prices.js +156 -0
- package/dist/src/oracle/rule-registry.d.ts +12 -12
- package/dist/src/oracle/rule-registry.js +12 -14
- package/dist/src/oracle/rules/pyth-lazer-rule.d.ts +24 -3
- package/dist/src/oracle/rules/pyth-lazer-rule.js +39 -20
- package/dist/src/oracle/rules/waterx-rule.d.ts +137 -12
- package/dist/src/oracle/rules/waterx-rule.js +314 -56
- package/dist/src/oracle/schedule.d.ts +109 -0
- package/dist/src/oracle/schedule.js +985 -0
- package/dist/src/oracle/source-list.d.ts +31 -27
- package/dist/src/oracle/source-list.js +42 -43
- package/dist/src/oracle/symbol-catalog.d.ts +54 -0
- package/dist/src/oracle/symbol-catalog.js +65 -0
- package/dist/src/oracle/update-fetch.d.ts +11 -15
- package/dist/src/oracle/update-fetch.js +12 -18
- package/dist/src/oracle/validate.d.ts +105 -0
- package/dist/src/oracle/validate.js +177 -0
- package/dist/src/oracle/weight-coverage.d.ts +79 -0
- package/dist/src/oracle/weight-coverage.js +166 -0
- package/dist/src/perp/client.d.ts +35 -52
- package/dist/src/perp/client.js +45 -18
- package/dist/src/perp/config-view.d.ts +5 -14
- package/dist/src/perp/config-view.js +5 -16
- package/dist/src/perp/config.d.ts +3 -3
- package/dist/src/perp/config.js +11 -13
- package/dist/src/perp/index.d.ts +4 -6
- package/dist/src/perp/index.js +11 -5
- package/dist/src/perp/tx-builders/common.d.ts +86 -48
- package/dist/src/perp/tx-builders/common.js +114 -48
- package/dist/src/perp/tx-builders/wlp.d.ts +3 -14
- package/dist/src/perp/tx-builders/wlp.js +6 -35
- package/dist/src/perp/tx-builders.d.ts +6 -5
- package/dist/src/perp/tx-builders.js +15 -6
- package/dist/src/unified-client.d.ts +8 -34
- package/dist/src/unified-client.js +3 -4
- package/dist/src/utils/config.d.ts +0 -8
- package/dist/src/utils/config.js +5 -12
- package/package.json +1 -1
- package/dist/cjs/src/generated/pyth_sponsor_rule/deps/sui/balance.d.ts +0 -12
- package/dist/cjs/src/generated/pyth_sponsor_rule/deps/sui/balance.js +0 -17
- package/dist/cjs/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +0 -68
- package/dist/cjs/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +0 -113
- package/dist/cjs/src/generated/waterx_pyth_rule/deps/sui/vec_map.d.ts +0 -36
- package/dist/cjs/src/generated/waterx_pyth_rule/deps/sui/vec_map.js +0 -31
- package/dist/cjs/src/generated/waterx_pyth_rule/pyth_rule.d.ts +0 -192
- package/dist/cjs/src/generated/waterx_pyth_rule/pyth_rule.js +0 -214
- package/dist/cjs/src/oracle/pyth.d.ts +0 -227
- package/dist/cjs/src/oracle/pyth.js +0 -652
- package/dist/cjs/src/oracle/rules/pyth-core-rule.d.ts +0 -15
- package/dist/cjs/src/oracle/rules/pyth-core-rule.js +0 -100
- package/dist/cjs/src/oracle/rules/pyth-rule.d.ts +0 -11
- package/dist/cjs/src/oracle/rules/pyth-rule.js +0 -29
- package/dist/cjs/src/oracle/rules/sponsor.d.ts +0 -32
- package/dist/cjs/src/oracle/rules/sponsor.js +0 -56
- package/dist/src/generated/pyth_sponsor_rule/deps/sui/balance.d.ts +0 -12
- package/dist/src/generated/pyth_sponsor_rule/deps/sui/balance.js +0 -14
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +0 -68
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +0 -73
- package/dist/src/generated/waterx_pyth_rule/deps/sui/vec_map.d.ts +0 -36
- package/dist/src/generated/waterx_pyth_rule/deps/sui/vec_map.js +0 -27
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +0 -192
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +0 -170
- package/dist/src/oracle/pyth.d.ts +0 -227
- package/dist/src/oracle/pyth.js +0 -638
- package/dist/src/oracle/rules/pyth-core-rule.d.ts +0 -15
- package/dist/src/oracle/rules/pyth-core-rule.js +0 -97
- package/dist/src/oracle/rules/pyth-rule.d.ts +0 -11
- package/dist/src/oracle/rules/pyth-rule.js +0 -26
- package/dist/src/oracle/rules/sponsor.d.ts +0 -32
- package/dist/src/oracle/rules/sponsor.js +0 -52
|
@@ -40,9 +40,14 @@ import type { Transaction, TransactionArgument } from "@mysten/sui/transactions"
|
|
|
40
40
|
import type { Network } from "../../constants.ts";
|
|
41
41
|
import type { OracleHost } from "../host.ts";
|
|
42
42
|
import { type PriceUpdateRule, type RuleUpdateData } from "../price-update-rule.ts";
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
import type { OraclePriceEntry } from "../read-prices.ts";
|
|
44
|
+
import { type FetchPolicy } from "../update-fetch.ts";
|
|
45
|
+
/** Intent the quote-center signs a whole BATCH payload under. Exported to NAME
|
|
46
|
+
* the signing scheme only — consumers no longer mirror the intent gate
|
|
47
|
+
* themselves: every quote-center pull (tx-build fetch, read executor, BE
|
|
48
|
+
* prefetch) goes through {@link fetchWaterxSignedUpdate} /
|
|
49
|
+
* {@link fetchWaterxSignedLeaves}, which enforce it, so a mispointed endpoint
|
|
50
|
+
* is rejected identically on every path. */
|
|
46
51
|
export declare const BATCH_PRICE_INTENT = 1;
|
|
47
52
|
/**
|
|
48
53
|
* Intent the quote-center signs a snapshot's Merkle ROOT under
|
|
@@ -56,12 +61,11 @@ export declare const BATCH_PRICE_INTENT = 1;
|
|
|
56
61
|
export declare const MERKLE_ROOT_INTENT = 2;
|
|
57
62
|
/**
|
|
58
63
|
* WaterX quote-center external infra — owned by THIS source, by network.
|
|
59
|
-
* Mirrors `
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* appends the path.
|
|
64
|
+
* Mirrors `LAZER_INFRA` (rules/pyth-lazer-rule.ts): per-network constants for
|
|
65
|
+
* infrastructure the source's operator runs, co-located with the only rule
|
|
66
|
+
* that reads them — no other oracle source ever touches a quote-center
|
|
67
|
+
* endpoint. Public read (no auth), so there is no api_key. `endpoint` has no
|
|
68
|
+
* trailing slash — the rule appends the path.
|
|
65
69
|
*
|
|
66
70
|
* These are the DEFAULTS behind the caller's `client.waterx` access slice
|
|
67
71
|
* (`waterxEndpoint` / `waterxFetch` create options) — the browser-CORS proxy
|
|
@@ -73,11 +77,32 @@ export declare const WATERX_INFRA: Record<Network, {
|
|
|
73
77
|
/**
|
|
74
78
|
* The waterx source's quote-center base for `network` — the ONE accessor
|
|
75
79
|
* consumers (BE/FE read planes) use when, and only when, their own
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* source's own configuration — never this one.
|
|
80
|
+
* the config wires `waterx_rule`. Under any other source the
|
|
81
|
+
* read endpoint is that source's own configuration — never this one.
|
|
79
82
|
*/
|
|
80
83
|
export declare function waterxQuoteCenterEndpoint(network: Network): string;
|
|
84
|
+
/**
|
|
85
|
+
* Off-chain mirror of the on-chain `waterx_rule` `FeedConfig.max_age` DEFAULT
|
|
86
|
+
* (90s): a price older than this ABSTAINS on-chain, so a read plane serving it
|
|
87
|
+
* as live would show a price no trade could execute against. The single
|
|
88
|
+
* source of truth for consumers' post-cache freshness filters — import this,
|
|
89
|
+
* never re-declare the number. (A deployment that overrides `max_age`
|
|
90
|
+
* per-feed on-chain diverges from this mirror; none does today.)
|
|
91
|
+
*/
|
|
92
|
+
export declare const WATERX_MAX_PRICE_AGE_MS = 90000;
|
|
93
|
+
/**
|
|
94
|
+
* `true` iff a quote-center read entry is still within
|
|
95
|
+
* {@link WATERX_MAX_PRICE_AGE_MS} of `nowMs` — the freshness predicate
|
|
96
|
+
* consumers apply to `readQuoteCenterPrices` output (post-cache), matching
|
|
97
|
+
* the on-chain abstain boundary instead of each inventing a policy.
|
|
98
|
+
*/
|
|
99
|
+
export declare function isFreshWaterxEntry(entry: OraclePriceEntry, nowMs: number): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* How far ahead of the reader's clock a quote-center timestamp may sit before
|
|
102
|
+
* it is treated as broken rather than merely skewed. Two independent clocks
|
|
103
|
+
* drift; a price minutes in the future does not.
|
|
104
|
+
*/
|
|
105
|
+
export declare const WATERX_CLOCK_SKEW_TOLERANCE_MS = 5000;
|
|
81
106
|
/**
|
|
82
107
|
* One item inside a signed batch payload, mirroring the quote-center
|
|
83
108
|
* `/v1/quotes/update` JSON 1:1 (snake_case). The u64 integer fields are the
|
|
@@ -165,6 +190,56 @@ export declare function parseSignedEnvelope(text: string): WaterxSignedEnvelope;
|
|
|
165
190
|
* leaf or proof element on the wire — before any PTB is touched.
|
|
166
191
|
*/
|
|
167
192
|
export declare function parseSignedLeaves(text: string): WaterxSignedLeaf[];
|
|
193
|
+
/**
|
|
194
|
+
* Pull one enclave-signed batch envelope covering `symbols` — the fallback
|
|
195
|
+
* update shape AND the read executor's transport
|
|
196
|
+
* (`readQuoteCenterPrices` in `../read-prices.ts`). Public seam (WL-2345):
|
|
197
|
+
* consumers that need the raw envelope (BE prefetch caches, read planes)
|
|
198
|
+
* call this instead of re-rolling the fetch + intent/shape gate.
|
|
199
|
+
* `fellBackFrom`, when set, names the leaf-route failure that sent us here,
|
|
200
|
+
* so a deployment whose quote-center serves NEITHER route reports both
|
|
201
|
+
* statuses instead of only the second one.
|
|
202
|
+
*/
|
|
203
|
+
export declare function fetchWaterxSignedUpdate(endpoint: string, symbols: string[], fetchOpts?: FetchPolicy, fellBackFrom?: string): Promise<WaterxSignedEnvelope>;
|
|
204
|
+
/** A leaf pull either produced leaves, or the route isn't there to pull from. */
|
|
205
|
+
export type LeafPull = {
|
|
206
|
+
leaves: WaterxSignedLeaf[];
|
|
207
|
+
} | {
|
|
208
|
+
unavailable: string;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Pull per-symbol signed Merkle leaves — the DEFAULT update-data shape (see the
|
|
212
|
+
* module header for why it beats the indivisible batch envelope on a trade path).
|
|
213
|
+
*
|
|
214
|
+
* Returns `{ unavailable }` on `404` — and ONLY on 404, the one status that
|
|
215
|
+
* means "this route isn't here": a quote-center older than `/v1/quotes/leaves`
|
|
216
|
+
* has no handler registered for the path. That is the version-skew case the
|
|
217
|
+
* caller answers by falling back to the batch envelope, so the SDK and the
|
|
218
|
+
* quote-center can be deployed in either order.
|
|
219
|
+
*
|
|
220
|
+
* Everything else THROWS rather than falling back, INCLUDING 5xx (`501` among
|
|
221
|
+
* them — `fetchWithPolicy` classifies every 5xx as retryable and has already
|
|
222
|
+
* spent its retry budget by the time one surfaces here). A degraded or
|
|
223
|
+
* unreachable quote-center would fail the envelope route the same way — same
|
|
224
|
+
* service, same enclave behind it — so falling back would only double the
|
|
225
|
+
* latency of an already-failing money-path build, and would report an outage as
|
|
226
|
+
* a version skew.
|
|
227
|
+
*
|
|
228
|
+
* A 404 can ALSO mean "unknown symbol" (the quote-center 404s a symbol missing
|
|
229
|
+
* from its feed registry). That is config drift between this SDK's `feeds` and
|
|
230
|
+
* the quote-center's registry, and the fallback surfaces it honestly: the
|
|
231
|
+
* envelope route 404s on the same symbol, and its error names both attempts.
|
|
232
|
+
*
|
|
233
|
+
* Public seam (WL-2345): consumers holding per-symbol leaves (BE prefetch
|
|
234
|
+
* caches) pull through this instead of re-rolling the fetch + parse gate.
|
|
235
|
+
*/
|
|
236
|
+
export declare function fetchWaterxSignedLeaves(endpoint: string, symbols: string[], fetchOpts?: FetchPolicy): Promise<LeafPull>;
|
|
237
|
+
/**
|
|
238
|
+
* The quote-center enclave signs at most this many symbols per request
|
|
239
|
+
* (`MAX_BATCH_SIZE` in `quote-service`). Over the cap it answers a
|
|
240
|
+
* non-retryable 400.
|
|
241
|
+
*/
|
|
242
|
+
export declare const WATERX_MAX_BATCH_SYMBOLS = 32;
|
|
168
243
|
/**
|
|
169
244
|
* Narrow a `RuleUpdateData` to its per-symbol {@link WaterxSignedLeaf}s, or
|
|
170
245
|
* `null` when it carries a batch envelope instead (the fallback shape).
|
|
@@ -212,4 +287,54 @@ export declare function feedWaterxRuleWithProof(tx: Transaction, host: OracleHos
|
|
|
212
287
|
* signature, a signed timestamp ahead of the `Clock`, or a config mismatch.
|
|
213
288
|
*/
|
|
214
289
|
export declare function feedWaterxRule(tx: Transaction, host: OracleHost, collector: TransactionArgument, envelope: WaterxSignedEnvelope): void;
|
|
290
|
+
/**
|
|
291
|
+
* THE quote-center route ladder, owned by the rule that owns the protocol:
|
|
292
|
+
* pull per-symbol Merkle leaves (the default), and fall back to one batch
|
|
293
|
+
* envelope only when this quote-center has no leaf route (see
|
|
294
|
+
* {@link fetchWaterxSignedLeaves} for exactly which statuses mean that, and
|
|
295
|
+
* why nothing else falls back).
|
|
296
|
+
*
|
|
297
|
+
* Both the write path ({@link pullWaterxData}, which layers coverage policy on
|
|
298
|
+
* top) and the READ executor (`readQuoteCenterPrices` in `../read-prices.ts`,
|
|
299
|
+
* which only decodes prices) go through here, so which route wins, which
|
|
300
|
+
* status falls back, and how the fallback context is threaded are stated once.
|
|
301
|
+
* `items` is the flat symbol-bearing view both callers actually want —
|
|
302
|
+
* `WaterxSignedLeaf extends WaterxBatchItem`, so leaves widen to it for free —
|
|
303
|
+
* while `payload` keeps the shape-specific form the on-chain feed leg needs.
|
|
304
|
+
*/
|
|
305
|
+
export declare function pullWaterxQuotes(endpoint: string, symbols: string[], fetchOpts?: FetchPolicy): Promise<{
|
|
306
|
+
route: "leaves" | "envelope";
|
|
307
|
+
payload: WaterxUpdatePayload;
|
|
308
|
+
items: readonly WaterxBatchItem[];
|
|
309
|
+
}>;
|
|
215
310
|
export declare const WaterxRule: PriceUpdateRule;
|
|
311
|
+
/**
|
|
312
|
+
* Coverage-policy seam over the rule's quote-center pull (WL-2345): fetch
|
|
313
|
+
* signed waterx update data for `tickers` with the caller choosing what a
|
|
314
|
+
* coverage gap means.
|
|
315
|
+
*
|
|
316
|
+
* - `coverage: "strict"` (default) — exactly `WaterxRule.fetchUpdateData`:
|
|
317
|
+
* every requested ticker must be config-listed AND served, or the fetch
|
|
318
|
+
* THROWS (`assertCoverage`); `missing` is always `[]`. Trade-path semantics
|
|
319
|
+
* — `refreshOraclePrices` keeps consuming the rule's own strict fetch, so
|
|
320
|
+
* `aggregate.ts`'s uncarried-ticker throw (04117a1) still can't be reached
|
|
321
|
+
* by a payload that under-covers its group.
|
|
322
|
+
* - `coverage: "partial"` — universe-prefetch semantics (a BE cache warming
|
|
323
|
+
* every known ticker at once): a ticker with no `waterx_rule.feeds` entry,
|
|
324
|
+
* or one the quote-center response does not serve, lands in `missing`
|
|
325
|
+
* instead of throwing, and `data` covers the rest. On the leaf route the
|
|
326
|
+
* payload is the covering leaf SUBSET; on the envelope route the envelope
|
|
327
|
+
* is kept iff it covers ≥1 requested ticker (it is indivisible — an
|
|
328
|
+
* envelope serving none is `data: null`). `data: null` + all-missing when
|
|
329
|
+
* nothing is servable.
|
|
330
|
+
*
|
|
331
|
+
* Consumers must not hand a partial payload to a build for tickers in
|
|
332
|
+
* `missing` — those tickers are simply not servable by waterx right now (log
|
|
333
|
+
* the gap; the chain's weight tables decide whether that starves anything).
|
|
334
|
+
*/
|
|
335
|
+
export declare function fetchWaterxUpdateData(host: OracleHost, tickers: string[], opts?: {
|
|
336
|
+
coverage?: "strict" | "partial";
|
|
337
|
+
}): Promise<{
|
|
338
|
+
data: RuleUpdateData;
|
|
339
|
+
missing: string[];
|
|
340
|
+
}>;
|