@waterx/sdk 4.3.2 → 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.
Files changed (150) hide show
  1. package/.claude/skills/waterx-sdk-integration/SKILL.md +225 -0
  2. package/README.md +216 -45
  3. package/SKILLS.md +34 -0
  4. package/dist/cjs/src/account/config.d.ts +3 -5
  5. package/dist/cjs/src/account/funding/wormhole.d.ts +1 -2
  6. package/dist/cjs/src/account/funding/wormhole.js +1 -2
  7. package/dist/cjs/src/generated/waterx_rule/waterx_rule.d.ts +140 -7
  8. package/dist/cjs/src/generated/waterx_rule/waterx_rule.js +163 -8
  9. package/dist/cjs/src/oracle/aggregate.d.ts +49 -62
  10. package/dist/cjs/src/oracle/aggregate.js +208 -164
  11. package/dist/cjs/src/oracle/config.d.ts +38 -51
  12. package/dist/cjs/src/oracle/config.js +1 -1
  13. package/dist/cjs/src/oracle/host.d.ts +14 -19
  14. package/dist/cjs/src/oracle/host.js +3 -3
  15. package/dist/cjs/src/oracle/index.d.ts +25 -16
  16. package/dist/cjs/src/oracle/index.js +87 -69
  17. package/dist/cjs/src/oracle/price-update-rule.d.ts +104 -66
  18. package/dist/cjs/src/oracle/price-update-rule.js +24 -16
  19. package/dist/cjs/src/oracle/pyth-pro-history.d.ts +36 -0
  20. package/dist/cjs/src/oracle/pyth-pro-history.js +41 -0
  21. package/dist/cjs/src/oracle/read-plane.d.ts +35 -53
  22. package/dist/cjs/src/oracle/read-plane.js +26 -48
  23. package/dist/cjs/src/oracle/read-prices.d.ts +105 -0
  24. package/dist/cjs/src/oracle/read-prices.js +162 -0
  25. package/dist/cjs/src/oracle/rule-registry.d.ts +12 -12
  26. package/dist/cjs/src/oracle/rule-registry.js +12 -14
  27. package/dist/cjs/src/oracle/rules/pyth-lazer-rule.d.ts +24 -3
  28. package/dist/cjs/src/oracle/rules/pyth-lazer-rule.js +40 -20
  29. package/dist/cjs/src/oracle/rules/waterx-rule.d.ts +271 -57
  30. package/dist/cjs/src/oracle/rules/waterx-rule.js +743 -144
  31. package/dist/cjs/src/oracle/schedule.d.ts +109 -0
  32. package/dist/cjs/src/oracle/schedule.js +991 -0
  33. package/dist/cjs/src/oracle/source-list.d.ts +31 -27
  34. package/dist/cjs/src/oracle/source-list.js +43 -45
  35. package/dist/cjs/src/oracle/symbol-catalog.d.ts +54 -0
  36. package/dist/cjs/src/oracle/symbol-catalog.js +69 -0
  37. package/dist/cjs/src/oracle/update-fetch.d.ts +11 -15
  38. package/dist/cjs/src/oracle/update-fetch.js +12 -19
  39. package/dist/cjs/src/oracle/validate.d.ts +105 -0
  40. package/dist/cjs/src/oracle/validate.js +185 -0
  41. package/dist/cjs/src/oracle/weight-coverage.d.ts +79 -0
  42. package/dist/cjs/src/oracle/weight-coverage.js +173 -0
  43. package/dist/cjs/src/perp/client.d.ts +40 -55
  44. package/dist/cjs/src/perp/client.js +44 -17
  45. package/dist/cjs/src/perp/config-view.d.ts +5 -14
  46. package/dist/cjs/src/perp/config-view.js +5 -16
  47. package/dist/cjs/src/perp/config.d.ts +3 -3
  48. package/dist/cjs/src/perp/config.js +11 -13
  49. package/dist/cjs/src/perp/index.d.ts +4 -6
  50. package/dist/cjs/src/perp/index.js +43 -18
  51. package/dist/cjs/src/perp/tx-builders/common.d.ts +86 -48
  52. package/dist/cjs/src/perp/tx-builders/common.js +115 -47
  53. package/dist/cjs/src/perp/tx-builders/wlp.d.ts +3 -14
  54. package/dist/cjs/src/perp/tx-builders/wlp.js +6 -35
  55. package/dist/cjs/src/perp/tx-builders.d.ts +6 -5
  56. package/dist/cjs/src/perp/tx-builders.js +16 -10
  57. package/dist/cjs/src/unified-client.d.ts +9 -35
  58. package/dist/cjs/src/unified-client.js +3 -4
  59. package/dist/cjs/src/utils/config.d.ts +0 -8
  60. package/dist/cjs/src/utils/config.js +5 -13
  61. package/dist/src/account/config.d.ts +3 -5
  62. package/dist/src/account/funding/wormhole.d.ts +1 -2
  63. package/dist/src/account/funding/wormhole.js +1 -2
  64. package/dist/src/generated/waterx_rule/waterx_rule.d.ts +140 -7
  65. package/dist/src/generated/waterx_rule/waterx_rule.js +151 -7
  66. package/dist/src/oracle/aggregate.d.ts +49 -62
  67. package/dist/src/oracle/aggregate.js +209 -164
  68. package/dist/src/oracle/config.d.ts +38 -51
  69. package/dist/src/oracle/config.js +1 -1
  70. package/dist/src/oracle/host.d.ts +14 -19
  71. package/dist/src/oracle/host.js +3 -3
  72. package/dist/src/oracle/index.d.ts +25 -16
  73. package/dist/src/oracle/index.js +61 -54
  74. package/dist/src/oracle/price-update-rule.d.ts +104 -66
  75. package/dist/src/oracle/price-update-rule.js +23 -16
  76. package/dist/src/oracle/pyth-pro-history.d.ts +36 -0
  77. package/dist/src/oracle/pyth-pro-history.js +38 -0
  78. package/dist/src/oracle/read-plane.d.ts +35 -53
  79. package/dist/src/oracle/read-plane.js +25 -47
  80. package/dist/src/oracle/read-prices.d.ts +105 -0
  81. package/dist/src/oracle/read-prices.js +156 -0
  82. package/dist/src/oracle/rule-registry.d.ts +12 -12
  83. package/dist/src/oracle/rule-registry.js +12 -14
  84. package/dist/src/oracle/rules/pyth-lazer-rule.d.ts +24 -3
  85. package/dist/src/oracle/rules/pyth-lazer-rule.js +39 -20
  86. package/dist/src/oracle/rules/waterx-rule.d.ts +271 -57
  87. package/dist/src/oracle/rules/waterx-rule.js +735 -144
  88. package/dist/src/oracle/schedule.d.ts +109 -0
  89. package/dist/src/oracle/schedule.js +985 -0
  90. package/dist/src/oracle/source-list.d.ts +31 -27
  91. package/dist/src/oracle/source-list.js +42 -43
  92. package/dist/src/oracle/symbol-catalog.d.ts +54 -0
  93. package/dist/src/oracle/symbol-catalog.js +65 -0
  94. package/dist/src/oracle/update-fetch.d.ts +11 -15
  95. package/dist/src/oracle/update-fetch.js +12 -18
  96. package/dist/src/oracle/validate.d.ts +105 -0
  97. package/dist/src/oracle/validate.js +177 -0
  98. package/dist/src/oracle/weight-coverage.d.ts +79 -0
  99. package/dist/src/oracle/weight-coverage.js +166 -0
  100. package/dist/src/perp/client.d.ts +40 -55
  101. package/dist/src/perp/client.js +45 -18
  102. package/dist/src/perp/config-view.d.ts +5 -14
  103. package/dist/src/perp/config-view.js +5 -16
  104. package/dist/src/perp/config.d.ts +3 -3
  105. package/dist/src/perp/config.js +11 -13
  106. package/dist/src/perp/index.d.ts +4 -6
  107. package/dist/src/perp/index.js +17 -5
  108. package/dist/src/perp/tx-builders/common.d.ts +86 -48
  109. package/dist/src/perp/tx-builders/common.js +114 -48
  110. package/dist/src/perp/tx-builders/wlp.d.ts +3 -14
  111. package/dist/src/perp/tx-builders/wlp.js +6 -35
  112. package/dist/src/perp/tx-builders.d.ts +6 -5
  113. package/dist/src/perp/tx-builders.js +15 -6
  114. package/dist/src/unified-client.d.ts +9 -35
  115. package/dist/src/unified-client.js +3 -4
  116. package/dist/src/utils/config.d.ts +0 -8
  117. package/dist/src/utils/config.js +5 -12
  118. package/package.json +8 -2
  119. package/dist/cjs/src/generated/pyth_sponsor_rule/deps/sui/balance.d.ts +0 -12
  120. package/dist/cjs/src/generated/pyth_sponsor_rule/deps/sui/balance.js +0 -17
  121. package/dist/cjs/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +0 -68
  122. package/dist/cjs/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +0 -113
  123. package/dist/cjs/src/generated/waterx_pyth_rule/deps/sui/vec_map.d.ts +0 -36
  124. package/dist/cjs/src/generated/waterx_pyth_rule/deps/sui/vec_map.js +0 -31
  125. package/dist/cjs/src/generated/waterx_pyth_rule/pyth_rule.d.ts +0 -192
  126. package/dist/cjs/src/generated/waterx_pyth_rule/pyth_rule.js +0 -214
  127. package/dist/cjs/src/oracle/pyth.d.ts +0 -227
  128. package/dist/cjs/src/oracle/pyth.js +0 -652
  129. package/dist/cjs/src/oracle/rules/pyth-core-rule.d.ts +0 -15
  130. package/dist/cjs/src/oracle/rules/pyth-core-rule.js +0 -100
  131. package/dist/cjs/src/oracle/rules/pyth-rule.d.ts +0 -11
  132. package/dist/cjs/src/oracle/rules/pyth-rule.js +0 -29
  133. package/dist/cjs/src/oracle/rules/sponsor.d.ts +0 -32
  134. package/dist/cjs/src/oracle/rules/sponsor.js +0 -56
  135. package/dist/src/generated/pyth_sponsor_rule/deps/sui/balance.d.ts +0 -12
  136. package/dist/src/generated/pyth_sponsor_rule/deps/sui/balance.js +0 -14
  137. package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +0 -68
  138. package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +0 -73
  139. package/dist/src/generated/waterx_pyth_rule/deps/sui/vec_map.d.ts +0 -36
  140. package/dist/src/generated/waterx_pyth_rule/deps/sui/vec_map.js +0 -27
  141. package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +0 -192
  142. package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +0 -170
  143. package/dist/src/oracle/pyth.d.ts +0 -227
  144. package/dist/src/oracle/pyth.js +0 -638
  145. package/dist/src/oracle/rules/pyth-core-rule.d.ts +0 -15
  146. package/dist/src/oracle/rules/pyth-core-rule.js +0 -97
  147. package/dist/src/oracle/rules/pyth-rule.d.ts +0 -11
  148. package/dist/src/oracle/rules/pyth-rule.js +0 -26
  149. package/dist/src/oracle/rules/sponsor.d.ts +0 -32
  150. package/dist/src/oracle/rules/sponsor.js +0 -52
@@ -1,170 +0,0 @@
1
- /**************************************************************
2
- * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
3
- **************************************************************/
4
- import { MoveStruct, normalizeMoveArguments } from "../utils/index.js";
5
- import { bcs } from '@mysten/sui/bcs';
6
- import * as vec_map from "./deps/sui/vec_map.js";
7
- const $moduleName = '@waterx/pyth-rule::pyth_rule';
8
- export const PythRule = new MoveStruct({ name: `${$moduleName}::PythRule`, fields: {
9
- dummy_field: bcs.bool()
10
- } });
11
- export const Config = new MoveStruct({ name: `${$moduleName}::Config`, fields: {
12
- id: bcs.Address,
13
- /** Ticker (e.g. `b"BTC_USD".to_string()`) → Pyth feed identifier bytes. */
14
- identifier_map: vec_map.VecMap(bcs.string(), bcs.vector(bcs.u8())),
15
- /** Per-ticker timestamp tolerance in seconds. Falls back to DEFAULT_TOLERANCE_SEC. */
16
- tolerance_sec_map: vec_map.VecMap(bcs.string(), bcs.u64())
17
- } });
18
- export const MaxConfBpsKey = new MoveStruct({ name: `${$moduleName}::MaxConfBpsKey`, fields: {
19
- dummy_field: bcs.bool()
20
- } });
21
- export const MaxConfBpsConfig = new MoveStruct({ name: `${$moduleName}::MaxConfBpsConfig`, fields: {
22
- /** Default max confidence band (bps of price) for symbols without an override. */
23
- default_bps: bcs.u64(),
24
- /** Per-symbol overrides. */
25
- by_symbol: vec_map.VecMap(bcs.string(), bcs.u64())
26
- } });
27
- /**
28
- * Reads a Pyth price for `collector.symbol()` and feeds it. Drops the value
29
- * (records `none`) if the on-chain timestamp diverges from the Pyth feed timestamp
30
- * by more than the configured tolerance.
31
- */
32
- export function feed(options) {
33
- const packageAddress = options.package ?? '@waterx/pyth-rule';
34
- const argumentsTypes = [
35
- null,
36
- null,
37
- '0x2::clock::Clock',
38
- null,
39
- null
40
- ];
41
- const parameterNames = ["collector", "config", "pythState", "pythPriceInfo"];
42
- return (tx) => tx.moveCall({
43
- package: packageAddress,
44
- module: 'pyth_rule',
45
- function: 'feed',
46
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
47
- });
48
- }
49
- export function setIdentifier(options) {
50
- const packageAddress = options.package ?? '@waterx/pyth-rule';
51
- const argumentsTypes = [
52
- null,
53
- null,
54
- '0x1::string::String',
55
- 'vector<u8>'
56
- ];
57
- const parameterNames = ["config", "Cap", "symbol", "identifier"];
58
- return (tx) => tx.moveCall({
59
- package: packageAddress,
60
- module: 'pyth_rule',
61
- function: 'set_identifier',
62
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
63
- });
64
- }
65
- export function setToleranceSec(options) {
66
- const packageAddress = options.package ?? '@waterx/pyth-rule';
67
- const argumentsTypes = [
68
- null,
69
- null,
70
- '0x1::string::String',
71
- 'u64'
72
- ];
73
- const parameterNames = ["config", "Cap", "symbol", "toleranceSec"];
74
- return (tx) => tx.moveCall({
75
- package: packageAddress,
76
- module: 'pyth_rule',
77
- function: 'set_tolerance_sec',
78
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
79
- });
80
- }
81
- /**
82
- * Sets the default confidence gate (bps of price) applied to symbols without an
83
- * explicit override. `10_000` = 100%. Lazily creates the confidence-gate DF.
84
- */
85
- export function setDefaultMaxConfidenceBps(options) {
86
- const packageAddress = options.package ?? '@waterx/pyth-rule';
87
- const argumentsTypes = [
88
- null,
89
- null,
90
- 'u64'
91
- ];
92
- const parameterNames = ["config", "Cap", "defaultBps"];
93
- return (tx) => tx.moveCall({
94
- package: packageAddress,
95
- module: 'pyth_rule',
96
- function: 'set_default_max_confidence_bps',
97
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
98
- });
99
- }
100
- /** Sets a per-symbol confidence gate (bps of price), overriding the default. */
101
- export function setSymbolMaxConfidenceBps(options) {
102
- const packageAddress = options.package ?? '@waterx/pyth-rule';
103
- const argumentsTypes = [
104
- null,
105
- null,
106
- '0x1::string::String',
107
- 'u64'
108
- ];
109
- const parameterNames = ["config", "Cap", "symbol", "bps"];
110
- return (tx) => tx.moveCall({
111
- package: packageAddress,
112
- module: 'pyth_rule',
113
- function: 'set_symbol_max_confidence_bps',
114
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
115
- });
116
- }
117
- /**
118
- * Removes a per-symbol confidence override (no-op if absent); the symbol then
119
- * falls back to the default.
120
- */
121
- export function unsetSymbolMaxConfidenceBps(options) {
122
- const packageAddress = options.package ?? '@waterx/pyth-rule';
123
- const argumentsTypes = [
124
- null,
125
- null,
126
- '0x1::string::String'
127
- ];
128
- const parameterNames = ["config", "Cap", "symbol"];
129
- return (tx) => tx.moveCall({
130
- package: packageAddress,
131
- module: 'pyth_rule',
132
- function: 'unset_symbol_max_confidence_bps',
133
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
134
- });
135
- }
136
- /**
137
- * The effective confidence gate (bps of price) `feed` applies for `symbol`:
138
- * per-symbol override → default → `DEFAULT_MAX_CONFIDENCE_BPS`.
139
- */
140
- export function maxConfidenceBps(options) {
141
- const packageAddress = options.package ?? '@waterx/pyth-rule';
142
- const argumentsTypes = [
143
- null,
144
- '0x1::string::String'
145
- ];
146
- const parameterNames = ["config", "symbol"];
147
- return (tx) => tx.moveCall({
148
- package: packageAddress,
149
- module: 'pyth_rule',
150
- function: 'max_confidence_bps',
151
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
152
- });
153
- }
154
- /**
155
- * The configured default confidence gate, or `DEFAULT_MAX_CONFIDENCE_BPS` if
156
- * unset.
157
- */
158
- export function defaultMaxConfidenceBps(options) {
159
- const packageAddress = options.package ?? '@waterx/pyth-rule';
160
- const argumentsTypes = [
161
- null
162
- ];
163
- const parameterNames = ["config"];
164
- return (tx) => tx.moveCall({
165
- package: packageAddress,
166
- module: 'pyth_rule',
167
- function: 'default_max_confidence_bps',
168
- arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
169
- });
170
- }
@@ -1,227 +0,0 @@
1
- /**
2
- * Pyth as a price *source*: Hermes REST + the on-chain Pyth update PTB.
3
- *
4
- * This file knows nothing about oracle *rules* (pyth_rule / supra_rule /
5
- * constant_rule / sponsor) — it only fetches price update VAAs from Hermes and
6
- * appends the Pyth on-chain update block, returning the refreshed
7
- * `PriceInfoObject` IDs. Feeding rules into a collector and aggregating lives in
8
- * `aggregate.ts`; the rule wrappers live in `rules/`.
9
- *
10
- * On-chain a single PTB:
11
- * 1. wormhole::vaa::parse_and_verify
12
- * 2. pyth::create_authenticated_price_infos_using_accumulator
13
- * 3. pyth::update_single_price_feed (one per feed)
14
- * 4. hot_potato_vector::destroy
15
- */
16
- import type { Transaction, TransactionArgument } from "@mysten/sui/transactions";
17
- import type { Network } from "../constants.ts";
18
- import type { PythFetchPolicy } from "./config.ts";
19
- import type { OracleHost } from "./host.ts";
20
- /**
21
- * Everything the Core source needs that is not in the canonical
22
- * `waterx-config` JSON lives HERE, in the source that consumes it —
23
- * `client.pyth` carries only the caller's credential/fetch policy
24
- * (see `PythAccessConfig`). No other oracle source reads this table:
25
- * selecting `pyth_lazer_rule` (or any future source) must never touch a Core
26
- * endpoint or Core state object, so nothing Core-shaped stays on the shared
27
- * client to leak across sources.
28
- *
29
- * - `state_id` / `wormhole_state_id` — the Core Pyth + Wormhole state objects
30
- * the on-chain update PTB reads (below).
31
- * - `hermes_endpoint` — the Core Hermes REST base for
32
- * `fetchPriceFeedsUpdateData`. Keyless today; auth-first after the Pyth Pro
33
- * migration (post-2026-08-18) via `client.pyth.api_key`.
34
- */
35
- export interface PythCoreInfra {
36
- state_id: string;
37
- wormhole_state_id: string;
38
- hermes_endpoint: string;
39
- }
40
- export declare const PYTH_CORE_INFRA: Record<Network, PythCoreInfra>;
41
- /**
42
- * The Core source's Hermes REST base for `network` — for consumers (BE/FE
43
- * read planes) whose `ORACLE_SOURCE` fed set includes `'pyth_rule'`. A fed
44
- * set WITHOUT `pyth_rule` reads the keyed Pyth Pro base instead — resolve
45
- * through `resolveHermesReadEndpoint` (`oracle/read-plane.ts`) rather than
46
- * branching by hand.
47
- */
48
- export declare function pythCoreHermesEndpoint(network: Network): string;
49
- /**
50
- * The Pyth Pro Hermes-compatible REST base — the documented drop-in
51
- * replacement for the Core endpoint (`https://pyth.dourolabs.app/hermes/…`),
52
- * IDENTICAL for every subscriber: only the `Authorization: Bearer` key
53
- * (`client.pyth.api_key` / the `pythApiKey` create option) is
54
- * account-specific, so the URL is SDK infra, not deployment config. One base
55
- * for both networks — Pro has no testnet variant (Pyth feed ids are
56
- * chain-agnostic; `hermes-beta` is a Core-testnet concern). Consumers with a
57
- * proxy/self-hosted mirror override it per deployment via
58
- * `resolveHermesReadEndpoint`'s `override` param.
59
- */
60
- export declare const PYTH_PRO_HERMES_ENDPOINT = "https://pyth.dourolabs.app/hermes";
61
- /** Accessor mirror of {@link pythCoreHermesEndpoint} for the Pro base. */
62
- export declare function pythProHermesEndpoint(): string;
63
- type PriceTableInfo = {
64
- id: string;
65
- fieldType: string;
66
- };
67
- type PythStateInfo = {
68
- packageId: string;
69
- baseUpdateFee: bigint;
70
- };
71
- export declare class PythCache {
72
- pythStateInfo?: PythStateInfo;
73
- wormholePackageId?: string;
74
- priceTableInfo?: PriceTableInfo;
75
- priceFeedObjectIdCache: Map<string, string | undefined>;
76
- }
77
- type FetchOpts = {
78
- apiKey?: string;
79
- fetch?: PythFetchPolicy;
80
- };
81
- /**
82
- * How long a "this endpoint lacks feed X" verdict stays memoized. The verdict
83
- * is a claim about *someone else's* deployment — a feed can be added to the
84
- * catalog, an entitlement can be granted, a Pro plan can be upgraded — so it
85
- * must expire rather than bind the whole process lifetime. Long enough that a
86
- * genuinely-absent feed costs one discovery per window instead of one per
87
- * build; short enough that a recovered endpoint self-heals without a restart.
88
- */
89
- export declare const MISSING_FEED_MEMO_TTL_MS: number;
90
- /**
91
- * Thrown when discovery concludes that an endpoint rejects EVERY requested
92
- * feed id without a catalog vouching for that verdict. `instanceof`-able
93
- * (mirrors `FetchPolicyError` / {@link OracleFeeSourceUnavailableError}).
94
- *
95
- * "All of them are missing" is the signature of an endpoint/credential fault —
96
- * a wrong base path (the Pyth Pro `/hermes` prefix dropped), a changed route,
97
- * a revoked or downgraded entitlement — not of N individually-absent feeds.
98
- * Memoizing it would convert a loud, fixable misconfiguration into a silent
99
- * permanent one: every id marked missing ⇒ `fetchPriceFeedsUpdateData` returns
100
- * `[]` ⇒ `buildPythPriceUpdateCalls` throws "Hermes returned empty results",
101
- * blaming Hermes for having no data, for the rest of the process's life. So
102
- * this case writes NOTHING to the memo and throws instead; the next call
103
- * re-probes and recovers on its own once the endpoint does.
104
- *
105
- * The message keeps the `Hermes price fetch failed: <status>` prefix on its
106
- * first line — the documented contract downstream consumers string-match (see
107
- * {@link fetchPriceFeedsUpdateData} and the e2e transient detector).
108
- */
109
- export declare class HermesEndpointRejectedAllFeedsError extends Error {
110
- readonly endpoint: string;
111
- readonly requestedCount: number;
112
- constructor(endpoint: string, requestedCount: number, catalogState: "unreadable" | "empty");
113
- }
114
- /**
115
- * The subset of `feedIds` this `endpoint` is known to serve — i.e. minus any
116
- * discovered to be absent within the last {@link MISSING_FEED_MEMO_TTL_MS}
117
- * (see {@link fetchPriceFeedsUpdateData}). Callers building a
118
- * `{ updates, feedIds }` payload use this to keep `feedIds` aligned with the
119
- * feeds the fetch actually returned data for, so `buildPythPriceUpdateCalls`
120
- * (one moveCall per feed id) never references a feed the accumulator blob
121
- * doesn't cover.
122
- *
123
- * Expired entries are pruned here rather than on a timer: the memo is only
124
- * ever consulted through this function, so a lazy sweep is both sufficient and
125
- * free of a dangling interval in a library.
126
- */
127
- export declare function endpointSupportedFeedIds(endpoint: string, feedIds: string[], apiKey?: string): string[];
128
- /** Test-only: forget everything learned about which feeds an endpoint lacks. */
129
- export declare function __resetMissingFeedCacheForTest(): void;
130
- /**
131
- * Discovery-only entry for consumers that fetch Hermes THEMSELVES (e.g. a
132
- * parsed latest-price reader) and just observed a whole-batch 404: resolves
133
- * which ids the endpoint lacks, memoizes them (see {@link
134
- * endpointSupportedFeedIds}), fetches NO survivor data. Without this, such a
135
- * consumer's only way to populate the memo was calling {@link
136
- * fetchPriceFeedsUpdateData} and discarding its accumulator blob — two full
137
- * redundant transfers per cold discovery.
138
- *
139
- * @throws HermesEndpointRejectedAllFeedsError when the rejection looks
140
- * endpoint-wide rather than per-feed — the caller's own 404 is then a
141
- * misconfiguration to surface, not a set of feeds to quietly drop.
142
- */
143
- export declare function probeMissingFeeds(endpoint: string, ids: string[], opts?: FetchOpts): Promise<void>;
144
- export declare function fetchPriceFeedsUpdateData(endpoint: string, priceIds: string[], opts?: FetchOpts): Promise<Uint8Array[]>;
145
- /**
146
- * Resolved source for the Pyth Core on-chain update fee. Deliberately a
147
- * closed two-variant union, not a `{ sponsorFund?, allowGasFee? }` pair — a
148
- * caller can no longer construct the "both supplied" or "neither supplied
149
- * but some other truthy flag" shapes that used to require a priority rule to
150
- * disambiguate.
151
- *
152
- * Resolved exactly ONCE, at the edges (`wrapRequestAndExecute` and the WLP
153
- * builders' equivalent in `perp/tx-builders/`) from config presence
154
- * (`pyth_sponsor_rule` deployed → open a fund → `'sponsor'`) and the
155
- * caller's ergonomic `allowGasFee` opt-in (→ `'gas'`), then threaded
156
- * verbatim through `refreshOraclePrices` → `BuildUpdateOpts` →
157
- * `PythCoreRule` → {@link buildPythPriceUpdateCalls}. The sponsor-beats-gas
158
- * priority from the old two-flag design is now structural — whichever edge
159
- * resolves this value decides once; no downstream layer re-derives or
160
- * re-documents a priority because none of them ever see more than one
161
- * candidate source.
162
- */
163
- export type OracleFeeSource = {
164
- readonly kind: "sponsor";
165
- readonly fund: TransactionArgument;
166
- readonly packageId: string;
167
- } | {
168
- readonly kind: "gas";
169
- };
170
- /**
171
- * Thrown when no {@link OracleFeeSource} is available for the Pyth update fee
172
- * — from `buildPythPriceUpdateCalls`'s own per-call guard, or `aggregate.ts`'s
173
- * hoisted `refreshOraclePrices` pre-check (see its docblock). `instanceof`-able
174
- * (mirrors `FetchPolicyError` in `update-fetch.ts`) so a consumer — e.g. a BE
175
- * integration wiring its own `allowGasFee` decision — can branch on the error
176
- * type directly instead of string-matching `error.message`.
177
- */
178
- export declare class OracleFeeSourceUnavailableError extends Error {
179
- constructor();
180
- }
181
- /**
182
- * Append the on-chain Pyth update PTB block. Returns `PriceInfoObject` IDs
183
- * (one per `feedIds`, same order). After this you can feed `pyth_rule` per
184
- * ticker against the matching `PriceInfoObject` (see `rules/pyth-rule.ts`).
185
- *
186
- * `opts.feeSource` is resolved BEFORE any PTB mutation and is never silently
187
- * defaulted — this function trusts whatever single {@link OracleFeeSource}
188
- * it's handed, it does not choose between competing candidates:
189
- * - `{ kind: 'sponsor' }` → the per-feed update fee is drawn from the
190
- * sponsor pool (`pyth_sponsor_rule::split`) instead of `tx.gas`. Opening
191
- * and reimbursing that fund is the caller's job (`rules/sponsor.ts` /
192
- * `wrapRequestAndExecute`, which opens it whenever the client's config
193
- * has `pyth_sponsor_rule` deployed) — this function only draws a fee
194
- * coin from the already-open `fund` hot potato.
195
- * - `{ kind: 'gas' }` → the fee is drawn from `tx.gas` via `tx.splitCoins`.
196
- * Only safe in a non-sponsored context — Enoki-sponsored transactions
197
- * reject any `tx.gas` draw.
198
- * - `undefined` → throws `OracleFeeSourceUnavailable` instead of silently
199
- * drawing from `tx.gas` (the old default), which broke under Enoki and,
200
- * worse, could fail ON-CHAIN when the market's `request_checklist`
201
- * requires the `PythSponsorRule` witness that only a real sponsor fund
202
- * attaches.
203
- *
204
- * This function's own check runs AFTER `updates`/`feedIds` are already in
205
- * hand, so for `updatePythPrices` (which fetches from Hermes, then calls
206
- * straight into this function) the off-chain fetch has already completed by
207
- * the time this throws — a wasted network call, never a stray PTB command.
208
- * `refreshOraclePrices` avoids that waste entirely: it hoists an EQUIVALENT
209
- * check ABOVE its off-chain fetch AND its per-group build loop (see its
210
- * docblock in `aggregate.ts`), keyed on `PriceUpdateRule.requiresFeeSource`
211
- * rather than waiting for a specific rule's fetch to complete — so for that
212
- * route neither the network call NOR any PTB command happens before the
213
- * throw. This function's own (later, per-call) guard alone could not
214
- * provide that "before any group builds" guarantee in a mixed shape (e.g. a
215
- * fee-free Lazer group ordered ahead of a Pyth Core fallback group in the
216
- * same PTB) — `refreshOraclePrices`'s pre-check is what closes it.
217
- */
218
- export declare function buildPythPriceUpdateCalls(tx: Transaction, host: OracleHost, updates: Uint8Array[], feedIds: string[], opts?: {
219
- cache?: PythCache;
220
- feeSource?: OracleFeeSource;
221
- }): Promise<string[]>;
222
- /** All-in-one: fetch from Hermes, append update calls. Returns PriceInfoObject IDs. */
223
- export declare function updatePythPrices(tx: Transaction, host: OracleHost, feedIds: string[], opts?: {
224
- cache?: PythCache;
225
- feeSource?: OracleFeeSource;
226
- }): Promise<string[]>;
227
- export {};