@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
@@ -16,20 +16,21 @@ exports.PerpClient = void 0;
16
16
  const base_client_ts_1 = require("../base-client.js");
17
17
  const price_update_rule_ts_1 = require("../oracle/price-update-rule.js");
18
18
  const source_list_ts_1 = require("../oracle/source-list.js");
19
+ const validate_ts_1 = require("../oracle/validate.js");
19
20
  const config_view_ts_1 = require("./config-view.js");
20
21
  const config_ts_1 = require("./config.js");
21
22
  class PerpClient extends base_client_ts_1.BaseLineClient {
22
23
  /** Caller-supplied Pyth credential + fetch policy — NO infra; each source owns its own tables. */
23
24
  pyth;
24
25
  /**
25
- * Caller-supplied quote-center overrides for `oracleSource: 'waterx_rule'`
26
+ * Caller-supplied quote-center overrides for `waterx_rule`
26
27
  * (`waterxEndpoint` / `waterxFetch` create options) — access-only, mirroring
27
28
  * `pyth` above; unset fields resolve against the rule's own `WATERX_INFRA`.
28
29
  */
29
30
  waterx;
30
31
  /** Wormhole infra for the credit bridge (network defaults unless overridden). */
31
32
  wormhole;
32
- /** The fed set: `oracleSource` create option normalized to a non-empty, deduped list. */
33
+ /** The fed set, derived from the config see {@link deriveOracleSources}. */
33
34
  oracleSources;
34
35
  /** Canonical-schema lookups (delegated to below); no transport. */
35
36
  view;
@@ -51,18 +52,17 @@ class PerpClient extends base_client_ts_1.BaseLineClient {
51
52
  ...(opts.waterxEndpoint !== undefined ? { endpoint: opts.waterxEndpoint } : {}),
52
53
  ...(opts.waterxFetch !== undefined ? { fetch: opts.waterxFetch } : {}),
53
54
  };
54
- // Normalize single-or-list to a deduped, order-preserving list, gated by
55
- // `isOracleSource` the SAME predicate `parseOracleSourceList` uses. An
56
- // empty list, a nullish entry (an untyped caller omitting the REQUIRED
57
- // option), or an unregistered value (`'core'`, `'pyth'`, ) fails
58
- // construction loudly instead of booting green and surfacing as
59
- // `OracleSourceNotImplemented` at the first tx-build.
60
- const sources = Array.isArray(opts.oracleSource) ? opts.oracleSource : [opts.oracleSource];
61
- this.oracleSources = [...new Set(sources)];
62
- if (this.oracleSources.length === 0 ||
63
- this.oracleSources.some((source) => !(0, source_list_ts_1.isOracleSource)(source))) {
64
- throw new Error(`oracleSource is REQUIRED and must name at least one of ${price_update_rule_ts_1.ORACLE_SOURCES.join(" | ")} ` +
65
- `(got ${JSON.stringify(sources)})`);
55
+ // The fed set is a property of the DEPLOYMENT, read off the same config
56
+ // that wires the rules never a create option and never an env var.
57
+ this.oracleSources = (0, source_list_ts_1.deriveOracleSources)(config);
58
+ if (this.oracleSources.length === 0) {
59
+ // Not a per-ticker coverage question (that is left to tx-build, on
60
+ // purpose): a config wiring NO price-update source at all cannot price
61
+ // anything, so every build would skip every ticker and every trade would
62
+ // abort on chain. Fail at construction, where the config is in hand.
63
+ throw new Error(`this deployment's config wires no price-update source — expected a published ` +
64
+ `package with a non-empty feeds map for at least one of ` +
65
+ `${price_update_rule_ts_1.ORACLE_SOURCES.join(" | ")}.`);
66
66
  }
67
67
  this.view = new config_view_ts_1.PerpConfigView(() => this.config, () => this.wormhole);
68
68
  }
@@ -97,9 +97,36 @@ class PerpClient extends base_client_ts_1.BaseLineClient {
97
97
  getAggregator(ticker) {
98
98
  return this.view.getAggregator(ticker);
99
99
  }
100
- /** @see PerpConfigView.getPythFeed */
101
- getPythFeed(ticker) {
102
- return this.view.getPythFeed(ticker);
100
+ /**
101
+ * WLP pool-token tickers THIS client's fed set can actually price — the
102
+ * ticker set the WLP builders refresh before `assert_prices_fresh`.
103
+ *
104
+ * Filtered, not raw `Object.keys(pool_tokens)`: a token only an UNLISTED
105
+ * source serves is not priceable by this client. The predicate is
106
+ * `refreshOraclePrices`'s own (`servableTickers`), so this list is exactly
107
+ * what a refresh would accept.
108
+ *
109
+ * NOTE this is a QUERY, not what the WLP builders use — they deliberately
110
+ * refresh and bump the WHOLE pool, because dropping an unpriceable asset
111
+ * from both halves is silent (see `assertWlpPoolRefreshed`).
112
+ */
113
+ pricedPoolTickers() {
114
+ return (0, validate_ts_1.servableTickers)(this, Object.keys(this.config.packages.wlp?.pool_tokens ?? {}));
115
+ }
116
+ /**
117
+ * {@link pricedPoolTickers} already joined to each token's Move type.
118
+ *
119
+ * A query, not a build primitive: the WLP builders deliberately refresh and
120
+ * bump the WHOLE pool (`refreshWlpPoolOracles`), because pre-filtering to
121
+ * what this client can price silently drops an asset from both halves. Use
122
+ * this to ASK what a fed set covers — e.g. a dashboard, or a boot assert
123
+ * pairing it with `assertOracleWriteCoverage`.
124
+ */
125
+ pricedPoolTokens() {
126
+ return this.pricedPoolTickers().map((ticker) => ({
127
+ ticker,
128
+ tokenType: this.getPoolTokenType(ticker),
129
+ }));
103
130
  }
104
131
  /** @see PerpConfigView.isConstantTicker */
105
132
  isConstantTicker(ticker) {
@@ -19,27 +19,18 @@ export declare class PerpConfigView {
19
19
  getMarket(ticker: string): import("./config.ts").WaterxPerpMarketEntry;
20
20
  /** `waterx_oracle.aggregators[ticker]`, throws if unknown. */
21
21
  getAggregator(ticker: string): string;
22
- /** `pyth_rule.feeds[ticker]`, throws if unknown. */
23
- getPythFeed(ticker: string): {
24
- feed_id: string;
25
- price_info_object: string;
26
- };
27
22
  /**
28
23
  * True when `ticker` is priced by `constant_rule` (a constant pin,
29
- * e.g. `USDCUSD → $1`) rather than Pyth. Such tickers are fed via
30
- * `constant_rule::feed` and need no Pyth update; see {@link refreshOraclePrices}.
24
+ * e.g. `USDCUSD → $1`) rather than a live source. Such tickers are fed via
25
+ * `constant_rule::feed` and need no source update leg; see
26
+ * {@link refreshOraclePrices}.
31
27
  *
32
28
  * All-or-nothing, mirroring {@link getSupraRule} and the keeper: only routes a
33
29
  * ticker to the constant rule when the rule is FULLY wired (`published_at` +
34
30
  * `config` present). A half-populated block — a `feeds` entry listed before the
35
31
  * rule is deployed, a realistic mid-rollout state — would otherwise make this
36
- * true while {@link aggregateTicker} throws, aborting the whole price-refresh PTB
37
- * instead of safely falling back to Pyth.
38
- *
39
- * Whether a constant ticker is *also* Pyth-fed (the dual-feed transition state)
40
- * or constant-only is not a separate flag — it falls out of whether the ticker
41
- * still has a `pyth_rule.feeds` entry. {@link aggregateTicker} feeds each rule the
42
- * ticker is configured for, so no `isDualFeed` / `isConstantOnly` predicate is needed.
32
+ * true while {@link aggregateTicker} throws, aborting the whole price-refresh
33
+ * PTB instead of leaving the ticker to its live sources.
43
34
  */
44
35
  isConstantTicker(ticker: string): boolean;
45
36
  /**
@@ -42,29 +42,18 @@ class PerpConfigView {
42
42
  throw new Error(`No aggregator listed for ticker: ${ticker}`);
43
43
  return a;
44
44
  }
45
- /** `pyth_rule.feeds[ticker]`, throws if unknown. */
46
- getPythFeed(ticker) {
47
- const f = (0, record_ts_1.ownEntry)(this.config.packages.pyth_rule?.feeds, ticker);
48
- if (!f)
49
- throw new Error(`No pyth feed listed for ticker: ${ticker}`);
50
- return f;
51
- }
52
45
  /**
53
46
  * True when `ticker` is priced by `constant_rule` (a constant pin,
54
- * e.g. `USDCUSD → $1`) rather than Pyth. Such tickers are fed via
55
- * `constant_rule::feed` and need no Pyth update; see {@link refreshOraclePrices}.
47
+ * e.g. `USDCUSD → $1`) rather than a live source. Such tickers are fed via
48
+ * `constant_rule::feed` and need no source update leg; see
49
+ * {@link refreshOraclePrices}.
56
50
  *
57
51
  * All-or-nothing, mirroring {@link getSupraRule} and the keeper: only routes a
58
52
  * ticker to the constant rule when the rule is FULLY wired (`published_at` +
59
53
  * `config` present). A half-populated block — a `feeds` entry listed before the
60
54
  * rule is deployed, a realistic mid-rollout state — would otherwise make this
61
- * true while {@link aggregateTicker} throws, aborting the whole price-refresh PTB
62
- * instead of safely falling back to Pyth.
63
- *
64
- * Whether a constant ticker is *also* Pyth-fed (the dual-feed transition state)
65
- * or constant-only is not a separate flag — it falls out of whether the ticker
66
- * still has a `pyth_rule.feeds` entry. {@link aggregateTicker} feeds each rule the
67
- * ticker is configured for, so no `isDualFeed` / `isConstantOnly` predicate is needed.
55
+ * true while {@link aggregateTicker} throws, aborting the whole price-refresh
56
+ * PTB instead of leaving the ticker to its live sources.
68
57
  */
69
58
  isConstantTicker(ticker) {
70
59
  const c = this.config.packages.constant_rule;
@@ -5,15 +5,15 @@
5
5
  * The schema mirrors the canonical JSON layout one-to-one (each package
6
6
  * groups its own object IDs + per-ticker maps). External chain infra is
7
7
  * **not** in the JSON — each oracle source owns its own per-network table
8
- * (`PYTH_CORE_INFRA` in `oracle/pyth.ts`, `LAZER_INFRA` in
9
- * `oracle/rules/pyth-lazer-rule.ts`); Wormhole bridge infra lives in
8
+ * (`LAZER_INFRA` in `oracle/rules/pyth-lazer-rule.ts`, `WATERX_INFRA` in
9
+ * `oracle/rules/waterx-rule.ts`); Wormhole bridge infra lives in
10
10
  * `WORMHOLE_DEFAULTS` below.
11
11
  */
12
12
  import type { AccountPackages, BasePackageEntry, WormholeInfraConfig } from "../account/config.ts";
13
13
  import type { OraclePackages } from "../oracle/config.ts";
14
14
  import type { Network } from "./constants.ts";
15
15
  export type { AccountConfig, AccountPackages, BasePackageEntry, NativeCustodyAsset, NativeCustodyPackage, WaterxCreditPackage, WaterxReferralPackage, WithdrawalQueuePackage, WormholeBridgePackage, WormholeInfraConfig, WxaAccountPackage, } from "../account/config.ts";
16
- export type { ConstantFeedEntry, OracleConfig, OraclePackages, PythAccessConfig, PythFetchPolicy, PythLazerRulePackage, PythRulePackage, PythSponsorRulePackage, SupraFeedEntry, SupraRulePackage, WaterxConstantRulePackage, WaterxAccessConfig, WaterxOraclePackage, WaterxRulePackage, } from "../oracle/config.ts";
16
+ export type { ConstantFeedEntry, OracleConfig, OraclePackages, PythAccessConfig, PythFetchPolicy, PythLazerRulePackage, SupraFeedEntry, SupraRulePackage, WaterxConstantRulePackage, WaterxAccessConfig, WaterxOraclePackage, WaterxRulePackage, } from "../oracle/config.ts";
17
17
  export interface WaterxPerpMarketEntry {
18
18
  market: string;
19
19
  config: string;
@@ -6,8 +6,8 @@
6
6
  * The schema mirrors the canonical JSON layout one-to-one (each package
7
7
  * groups its own object IDs + per-ticker maps). External chain infra is
8
8
  * **not** in the JSON — each oracle source owns its own per-network table
9
- * (`PYTH_CORE_INFRA` in `oracle/pyth.ts`, `LAZER_INFRA` in
10
- * `oracle/rules/pyth-lazer-rule.ts`); Wormhole bridge infra lives in
9
+ * (`LAZER_INFRA` in `oracle/rules/pyth-lazer-rule.ts`, `WATERX_INFRA` in
10
+ * `oracle/rules/waterx-rule.ts`); Wormhole bridge infra lives in
11
11
  * `WORMHOLE_DEFAULTS` below.
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -19,14 +19,12 @@ const update_fetch_ts_1 = require("../oracle/update-fetch.js");
19
19
  // Wormhole — external chain infra, defaults by network
20
20
  // ============================================================================
21
21
  //
22
- // Oracle-source infra lives with each source (`PYTH_CORE_INFRA` in
23
- // `oracle/pyth.ts`, `LAZER_INFRA` in `oracle/rules/pyth-lazer-rule.ts`);
24
- // `client.pyth` is the caller-supplied access slice only (`PythAccessConfig`,
25
- // re-exported at the top of this file).
22
+ // Oracle-source infra lives with each source (`LAZER_INFRA` in
23
+ // `oracle/rules/pyth-lazer-rule.ts`, `WATERX_INFRA` in
24
+ // `oracle/rules/waterx-rule.ts`); `client.pyth` is the caller-supplied access
25
+ // slice only (`PythAccessConfig`, re-exported at the top of this file).
26
26
  // `WormholeInfraConfig` is defined in `account/config.ts` (funding base) and
27
- // re-exported at the top of this file. `state_id` is the same shared Sui
28
- // Wormhole `State` object Pyth uses (kept in sync with
29
- // `PYTH_CORE_INFRA[*].wormhole_state_id`).
27
+ // re-exported at the top of this file.
30
28
  exports.WORMHOLE_DEFAULTS = {
31
29
  MAINNET: {
32
30
  state_id: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c",
@@ -146,15 +144,15 @@ function validateConfig(cfg, expected, url) {
146
144
  };
147
145
  // Validate by deployment kind. A perp config must carry the perp set; a
148
146
  // credit config the credit set. `waterx_account` is common to both.
149
- // `pyth_lazer_rule` is intentionally NOT required (and never will be by
150
- // presence alone) it's an optional/experimental package selected only via
151
- // a client's `oracleSource` option, never by its presence in the config.
147
+ // NO oracle-rule package is required by presence which rules run is the
148
+ // client's derived fed set, never a hand-declared list (and
149
+ // `pyth_rule`, once required here, was retired in 5.0.0 a config may
150
+ // carry or omit its block freely).
152
151
  const isPerp = "waterx_perp" in cfg.packages;
153
152
  const isCredit = "waterx_credit" in cfg.packages || "wormhole_bridge" in cfg.packages;
154
153
  const required = isPerp
155
154
  ? [
156
155
  "bucket_framework",
157
- "pyth_rule",
158
156
  "waterx_account",
159
157
  "waterx_oracle",
160
158
  "waterx_perp",
@@ -1,10 +1,10 @@
1
1
  export { PerpClient } from "./client.ts";
2
2
  export type { CreateClientOptions } from "./client.ts";
3
3
  export { WORMHOLE_DEFAULTS, clearConfigCache, loadConfig } from "./config.ts";
4
- export type { BasePackageEntry, ConstantFeedEntry, WaterxReferralPackage, LoadConfigOptions, NativeCustodyAsset, NativeCustodyPackage, PythAccessConfig, PythFetchPolicy, PythLazerRulePackage, PythRulePackage, PythSponsorRulePackage, SupraFeedEntry, SupraRulePackage, TestnetFaucetPackage, WaterXConfig, WaterXPackages, WaterxCreditPackage, WaterxOraclePackage, WaterxPerpMarketEntry, WaterxPerpPackage, WaterxStakingPackage, WithdrawalQueuePackage, WlpPackage, WormholeBridgePackage, WormholeInfraConfig, WxaAccountPackage, } from "./config.ts";
4
+ export type { BasePackageEntry, ConstantFeedEntry, WaterxReferralPackage, LoadConfigOptions, NativeCustodyAsset, NativeCustodyPackage, PythAccessConfig, PythFetchPolicy, PythLazerRulePackage, SupraFeedEntry, SupraRulePackage, TestnetFaucetPackage, WaterXConfig, WaterXPackages, WaterxCreditPackage, WaterxOraclePackage, WaterxPerpMarketEntry, WaterxPerpPackage, WaterxStakingPackage, WithdrawalQueuePackage, WlpPackage, WormholeBridgePackage, WormholeInfraConfig, WxaAccountPackage, } from "./config.ts";
5
5
  export { ACTION_ADD_PRE_ORDER, ACTION_CANCEL_ORDER, ACTION_CANCEL_PRE_ORDER, ACTION_CLOSE_POSITION, ACTION_DECREASE_POSITION, ACTION_DEPOSIT_COLLATERAL, ACTION_INCREASE_POSITION, ACTION_LIQUIDATE, ACTION_OPEN_POSITION, ACTION_PLACE_ORDER, ACTION_UPDATE_ORDER, ACTION_WITHDRAW_COLLATERAL, BPS_SCALE, DOUBLE_SCALE, DRY_RUN_SENDER, FLOAT_SCALE, ORDER_LIMIT_BUY, ORDER_LIMIT_SELL, ORDER_STOP_BUY, ORDER_STOP_SELL, ORDER_TAG_WILDCARD, PERM_ALL, PERM_ALL_TRADING, PERM_CANCEL_ORDER, PERM_CLOSE_POSITION, PERM_DECREASE_POSITION, PERM_DEPOSIT_COLLATERAL, PERM_INCREASE_POSITION, PERM_MINT_WLP, PERM_OPEN_POSITION, PERM_PLACE_ORDER, PERM_REDEEM_WLP, PERM_WITHDRAW_COLLATERAL, STAKING_PERM_DEPOSIT_STAKE, STAKING_PERM_REDEEM_STAKE, STAKING_PERM_CLAIM_REWARD, STAKING_PERM_ALL, MS_PER_MINUTE, MS_PER_HOUR, MS_PER_YEAR, SUI_DECIMALS, WLP_DECIMALS, COLLATERAL_DECIMALS, TOKEN_DECIMALS, } from "./constants.ts";
6
6
  export type { Network } from "./constants.ts";
7
- export { getMarketTickers, getCollateralAssets } from "../utils/config.ts";
7
+ export { getMarketTickers } from "../utils/config.ts";
8
8
  export { annualizedApyFromRatio, annualizeFundingRate, calcBorrowRate, calcBorrowRateAccrual, calcDynamicFeeBps, calcEffectiveCollateralUsd, calcEstLiqPrice, calcEstLiqPriceRaw, calcFee, calcFundingFeeUsd, calcFundingRate, calcImpactFeeRate, calcLeverage, calcMaxReducibleCollateralUsd, calcNotional, calcPositionBorrowFee, calcRealLiqNetCostUsd, calcTokenUtilizationBps, calcTotalTradingFeeRate, calcUnrealizedPnl, calcViewEstLiqFeesUsd, calcWlpIncentiveApy, calcWlpMintOut, calcWlpPrice, calcWlpRedeemOut, decodeFundingIndexDelta, rawPrice, } from "../utils/math.ts";
9
9
  export type { ExactDecimalUsd, LiqFeeBundle, RawPriceInput } from "../utils/math.ts";
10
10
  export { formatFundingInterval } from "../utils/format.ts";
@@ -13,8 +13,8 @@ export type { EstLiqPriceViewOpts } from "./liq-view.ts";
13
13
  export * from "./user/index.ts";
14
14
  export * from "./tx-builders.ts";
15
15
  export * from "./fetch.ts";
16
- export { FetchPolicyError, LazerApiKeyMissingError, OracleFeeSourceUnavailableError, OracleSourceNotImplementedError, PythCache, aggregateTicker, aggregateTickerWithConstant, aggregateTickerWithPyth, ORACLE_SOURCES, buildPythPriceUpdateCalls, fetchPriceFeedsUpdateData, isOracleSource, parseOracleSourceList, pythCoreHermesEndpoint, pythProHermesEndpoint, refreshOraclePrices, resolveHermesReadEndpoint, updatePythPrices, waterxEnvelopeOf, waterxQuoteCenterEndpoint, } from "../oracle/index.ts";
17
- export type { FetchPolicy, OracleFeeSource, OracleSource, UpdateDataProvider, } from "../oracle/index.ts";
16
+ export { FetchPolicyError, LazerApiKeyMissingError, LazerNotEntitledError, OracleTickerUnservedError, OracleWeightCoverageError, OracleWeightUnreadableError, OracleSourceNotImplementedError, aggregateTicker, aggregateTickerWithConstant, ORACLE_SOURCES, assertOracleWeightCoverage, assertOracleWriteCoverage, fetchPythProHistory, fetchPythSymbolCatalog, fetchWaterxSignedLeaves, fetchWaterxSignedUpdate, fetchWaterxUpdateData, getMarketStatus, isFreshWaterxEntry, deriveOracleSources, missingOracleCredentials, parsePythSchedule, PythScheduleParseError, pullWaterxQuotes, readLazerPrices, readPlanTickers, readQuoteCenterPrices, refreshOraclePrices, resolveOracleReadPlan, resolveOracleRule, servableTickers, WATERX_MAX_PRICE_AGE_MS, waterxEnvelopeOf, waterxLeavesOf, parseSignedLeaves, MERKLE_ROOT_INTENT, waterxQuoteCenterEndpoint, } from "../oracle/index.ts";
17
+ export type { FetchPolicy, HolidayDate, MarketStatusResult, OracleCredentialKind, OraclePriceEntry, OracleRefreshSummary, OracleReadPlan, OracleSource, ParsedPythSchedule, PythSymbolRecord, TradingHours, TradingSession, UpdateDataProvider, WaterxBatchItem, WaterxEnvelopePayload, WaterxLeafPayload, WaterxSignedEnvelope, WaterxSignedLeaf, WaterxUpdatePayload, } from "../oracle/index.ts";
18
18
  export { fetchDepositVaa, fetchVaa, listBridgeWithdrawalVaas, listVaasByEmitter, padEvmEmitter, toWormholescanEmitter, vaaBase64ToBytes, vaaBase64ToHex, vaaBytesToBase64, waitForVaa, } from "../account/funding/wormhole.ts";
19
19
  export type { VaaListItem, VaaResponse, WormholescanOptions } from "../account/funding/wormhole.ts";
20
20
  export { AccountData as AccountDataBcs, GlobalConfigData as GlobalConfigDataBcs, MarketData as MarketDataBcs, OrderData as OrderDataBcs, PoolData as PoolDataBcs, PositionData as PositionDataBcs, RedeemRequestData as RedeemRequestDataBcs, TokenPoolData as TokenPoolDataBcs, } from "../generated/waterx_perp_view/view.ts";
@@ -27,8 +27,6 @@ export * as viewCalls from "../generated/waterx_perp_view/view.ts";
27
27
  export * as wxaAccountCalls from "../generated/waterx_account/account.ts";
28
28
  export * as stakingCalls from "../generated/waterx_staking/waterx_staking.ts";
29
29
  export * as oracleCalls from "../generated/waterx_oracle/oracle.ts";
30
- export * as pythRuleCalls from "../generated/waterx_pyth_rule/pyth_rule.ts";
31
- export * as pythSponsorRuleCalls from "../generated/pyth_sponsor_rule/pyth_sponsor_rule.ts";
32
30
  export * as referralCalls from "../generated/waterx_referral/referral_table.ts";
33
31
  export * as nativeCustodyCalls from "../generated/native_custody/custody_vault.ts";
34
32
  export * as withdrawalQueueCalls from "../generated/withdrawal_queue/withdrawal_queue.ts";
@@ -36,9 +36,9 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.getCollateralAssets = exports.getMarketTickers = exports.TOKEN_DECIMALS = exports.COLLATERAL_DECIMALS = exports.WLP_DECIMALS = exports.SUI_DECIMALS = exports.MS_PER_YEAR = exports.MS_PER_HOUR = exports.MS_PER_MINUTE = exports.STAKING_PERM_ALL = exports.STAKING_PERM_CLAIM_REWARD = exports.STAKING_PERM_REDEEM_STAKE = exports.STAKING_PERM_DEPOSIT_STAKE = exports.PERM_WITHDRAW_COLLATERAL = exports.PERM_REDEEM_WLP = exports.PERM_PLACE_ORDER = exports.PERM_OPEN_POSITION = exports.PERM_MINT_WLP = exports.PERM_INCREASE_POSITION = exports.PERM_DEPOSIT_COLLATERAL = exports.PERM_DECREASE_POSITION = exports.PERM_CLOSE_POSITION = exports.PERM_CANCEL_ORDER = exports.PERM_ALL_TRADING = exports.PERM_ALL = exports.ORDER_TAG_WILDCARD = exports.ORDER_STOP_SELL = exports.ORDER_STOP_BUY = exports.ORDER_LIMIT_SELL = exports.ORDER_LIMIT_BUY = exports.FLOAT_SCALE = exports.DRY_RUN_SENDER = exports.DOUBLE_SCALE = exports.BPS_SCALE = exports.ACTION_WITHDRAW_COLLATERAL = exports.ACTION_UPDATE_ORDER = exports.ACTION_PLACE_ORDER = exports.ACTION_OPEN_POSITION = exports.ACTION_LIQUIDATE = exports.ACTION_INCREASE_POSITION = exports.ACTION_DEPOSIT_COLLATERAL = exports.ACTION_DECREASE_POSITION = exports.ACTION_CLOSE_POSITION = exports.ACTION_CANCEL_PRE_ORDER = exports.ACTION_CANCEL_ORDER = exports.ACTION_ADD_PRE_ORDER = exports.loadConfig = exports.clearConfigCache = exports.WORMHOLE_DEFAULTS = exports.PerpClient = void 0;
40
- exports.fetchDepositVaa = exports.waterxQuoteCenterEndpoint = exports.waterxEnvelopeOf = exports.updatePythPrices = exports.resolveHermesReadEndpoint = exports.refreshOraclePrices = exports.pythProHermesEndpoint = exports.pythCoreHermesEndpoint = exports.parseOracleSourceList = exports.isOracleSource = exports.fetchPriceFeedsUpdateData = exports.buildPythPriceUpdateCalls = exports.ORACLE_SOURCES = exports.aggregateTickerWithPyth = exports.aggregateTickerWithConstant = exports.aggregateTicker = exports.PythCache = exports.OracleSourceNotImplementedError = exports.OracleFeeSourceUnavailableError = exports.LazerApiKeyMissingError = exports.FetchPolicyError = exports.calcEstLiqPriceRawFromView = exports.formatFundingInterval = exports.rawPrice = exports.decodeFundingIndexDelta = exports.calcWlpRedeemOut = exports.calcWlpPrice = exports.calcWlpMintOut = exports.calcWlpIncentiveApy = exports.calcViewEstLiqFeesUsd = exports.calcUnrealizedPnl = exports.calcTotalTradingFeeRate = exports.calcTokenUtilizationBps = exports.calcRealLiqNetCostUsd = exports.calcPositionBorrowFee = exports.calcNotional = exports.calcMaxReducibleCollateralUsd = exports.calcLeverage = exports.calcImpactFeeRate = exports.calcFundingRate = exports.calcFundingFeeUsd = exports.calcFee = exports.calcEstLiqPriceRaw = exports.calcEstLiqPrice = exports.calcEffectiveCollateralUsd = exports.calcDynamicFeeBps = exports.calcBorrowRateAccrual = exports.calcBorrowRate = exports.annualizeFundingRate = exports.annualizedApyFromRatio = void 0;
41
- exports.withdrawalQueueCalls = exports.nativeCustodyCalls = exports.referralCalls = exports.pythSponsorRuleCalls = exports.pythRuleCalls = exports.oracleCalls = exports.stakingCalls = exports.wxaAccountCalls = exports.viewCalls = exports.lpPoolCalls = exports.tradingCalls = exports.MarketConfigBcs = exports.MarketBcs = exports.OrderBcs = exports.PositionBcs = exports.TokenPoolDataBcs = exports.RedeemRequestDataBcs = exports.PositionDataBcs = exports.PoolDataBcs = exports.OrderDataBcs = exports.MarketDataBcs = exports.GlobalConfigDataBcs = exports.AccountDataBcs = exports.waitForVaa = exports.vaaBytesToBase64 = exports.vaaBase64ToHex = exports.vaaBase64ToBytes = exports.toWormholescanEmitter = exports.padEvmEmitter = exports.listVaasByEmitter = exports.listBridgeWithdrawalVaas = exports.fetchVaa = void 0;
39
+ exports.annualizedApyFromRatio = exports.getMarketTickers = exports.TOKEN_DECIMALS = exports.COLLATERAL_DECIMALS = exports.WLP_DECIMALS = exports.SUI_DECIMALS = exports.MS_PER_YEAR = exports.MS_PER_HOUR = exports.MS_PER_MINUTE = exports.STAKING_PERM_ALL = exports.STAKING_PERM_CLAIM_REWARD = exports.STAKING_PERM_REDEEM_STAKE = exports.STAKING_PERM_DEPOSIT_STAKE = exports.PERM_WITHDRAW_COLLATERAL = exports.PERM_REDEEM_WLP = exports.PERM_PLACE_ORDER = exports.PERM_OPEN_POSITION = exports.PERM_MINT_WLP = exports.PERM_INCREASE_POSITION = exports.PERM_DEPOSIT_COLLATERAL = exports.PERM_DECREASE_POSITION = exports.PERM_CLOSE_POSITION = exports.PERM_CANCEL_ORDER = exports.PERM_ALL_TRADING = exports.PERM_ALL = exports.ORDER_TAG_WILDCARD = exports.ORDER_STOP_SELL = exports.ORDER_STOP_BUY = exports.ORDER_LIMIT_SELL = exports.ORDER_LIMIT_BUY = exports.FLOAT_SCALE = exports.DRY_RUN_SENDER = exports.DOUBLE_SCALE = exports.BPS_SCALE = exports.ACTION_WITHDRAW_COLLATERAL = exports.ACTION_UPDATE_ORDER = exports.ACTION_PLACE_ORDER = exports.ACTION_OPEN_POSITION = exports.ACTION_LIQUIDATE = exports.ACTION_INCREASE_POSITION = exports.ACTION_DEPOSIT_COLLATERAL = exports.ACTION_DECREASE_POSITION = exports.ACTION_CLOSE_POSITION = exports.ACTION_CANCEL_PRE_ORDER = exports.ACTION_CANCEL_ORDER = exports.ACTION_ADD_PRE_ORDER = exports.loadConfig = exports.clearConfigCache = exports.WORMHOLE_DEFAULTS = exports.PerpClient = void 0;
40
+ exports.parsePythSchedule = exports.missingOracleCredentials = exports.deriveOracleSources = exports.isFreshWaterxEntry = exports.getMarketStatus = exports.fetchWaterxUpdateData = exports.fetchWaterxSignedUpdate = exports.fetchWaterxSignedLeaves = exports.fetchPythSymbolCatalog = exports.fetchPythProHistory = exports.assertOracleWriteCoverage = exports.assertOracleWeightCoverage = exports.ORACLE_SOURCES = exports.aggregateTickerWithConstant = exports.aggregateTicker = exports.OracleSourceNotImplementedError = exports.OracleWeightUnreadableError = exports.OracleWeightCoverageError = exports.OracleTickerUnservedError = exports.LazerNotEntitledError = exports.LazerApiKeyMissingError = exports.FetchPolicyError = exports.calcEstLiqPriceRawFromView = exports.formatFundingInterval = exports.rawPrice = exports.decodeFundingIndexDelta = exports.calcWlpRedeemOut = exports.calcWlpPrice = exports.calcWlpMintOut = exports.calcWlpIncentiveApy = exports.calcViewEstLiqFeesUsd = exports.calcUnrealizedPnl = exports.calcTotalTradingFeeRate = exports.calcTokenUtilizationBps = exports.calcRealLiqNetCostUsd = exports.calcPositionBorrowFee = exports.calcNotional = exports.calcMaxReducibleCollateralUsd = exports.calcLeverage = exports.calcImpactFeeRate = exports.calcFundingRate = exports.calcFundingFeeUsd = exports.calcFee = exports.calcEstLiqPriceRaw = exports.calcEstLiqPrice = exports.calcEffectiveCollateralUsd = exports.calcDynamicFeeBps = exports.calcBorrowRateAccrual = exports.calcBorrowRate = exports.annualizeFundingRate = void 0;
41
+ exports.withdrawalQueueCalls = exports.nativeCustodyCalls = exports.referralCalls = exports.oracleCalls = exports.stakingCalls = exports.wxaAccountCalls = exports.viewCalls = exports.lpPoolCalls = exports.tradingCalls = exports.MarketConfigBcs = exports.MarketBcs = exports.OrderBcs = exports.PositionBcs = exports.TokenPoolDataBcs = exports.RedeemRequestDataBcs = exports.PositionDataBcs = exports.PoolDataBcs = exports.OrderDataBcs = exports.MarketDataBcs = exports.GlobalConfigDataBcs = exports.AccountDataBcs = exports.waitForVaa = exports.vaaBytesToBase64 = exports.vaaBase64ToHex = exports.vaaBase64ToBytes = exports.toWormholescanEmitter = exports.padEvmEmitter = exports.listVaasByEmitter = exports.listBridgeWithdrawalVaas = exports.fetchVaa = exports.fetchDepositVaa = exports.waterxQuoteCenterEndpoint = exports.MERKLE_ROOT_INTENT = exports.parseSignedLeaves = exports.waterxLeavesOf = exports.waterxEnvelopeOf = exports.WATERX_MAX_PRICE_AGE_MS = exports.servableTickers = exports.resolveOracleRule = exports.resolveOracleReadPlan = exports.refreshOraclePrices = exports.readQuoteCenterPrices = exports.readPlanTickers = exports.readLazerPrices = exports.pullWaterxQuotes = exports.PythScheduleParseError = void 0;
42
42
  // ======== Core ========
43
43
  var client_ts_1 = require("./client.js");
44
44
  Object.defineProperty(exports, "PerpClient", { enumerable: true, get: function () { return client_ts_1.PerpClient; } });
@@ -95,7 +95,6 @@ Object.defineProperty(exports, "TOKEN_DECIMALS", { enumerable: true, get: functi
95
95
  // ======== Utilities ========
96
96
  var config_ts_2 = require("../utils/config.js");
97
97
  Object.defineProperty(exports, "getMarketTickers", { enumerable: true, get: function () { return config_ts_2.getMarketTickers; } });
98
- Object.defineProperty(exports, "getCollateralAssets", { enumerable: true, get: function () { return config_ts_2.getCollateralAssets; } });
99
98
  var math_ts_1 = require("../utils/math.js");
100
99
  Object.defineProperty(exports, "annualizedApyFromRatio", { enumerable: true, get: function () { return math_ts_1.annualizedApyFromRatio; } });
101
100
  Object.defineProperty(exports, "annualizeFundingRate", { enumerable: true, get: function () { return math_ts_1.annualizeFundingRate; } });
@@ -134,27 +133,55 @@ __exportStar(require("./user/index.js"), exports);
134
133
  __exportStar(require("./tx-builders.js"), exports);
135
134
  // ======== Read-only queries ========
136
135
  __exportStar(require("./fetch.js"), exports);
137
- // ======== Oracle utilities (Pyth source + rule aggregation) ========
136
+ // ======== Oracle utilities (sources + rule aggregation + read planes) ========
138
137
  var index_ts_1 = require("../oracle/index.js");
139
138
  Object.defineProperty(exports, "FetchPolicyError", { enumerable: true, get: function () { return index_ts_1.FetchPolicyError; } });
140
139
  Object.defineProperty(exports, "LazerApiKeyMissingError", { enumerable: true, get: function () { return index_ts_1.LazerApiKeyMissingError; } });
141
- Object.defineProperty(exports, "OracleFeeSourceUnavailableError", { enumerable: true, get: function () { return index_ts_1.OracleFeeSourceUnavailableError; } });
140
+ Object.defineProperty(exports, "LazerNotEntitledError", { enumerable: true, get: function () { return index_ts_1.LazerNotEntitledError; } });
141
+ Object.defineProperty(exports, "OracleTickerUnservedError", { enumerable: true, get: function () { return index_ts_1.OracleTickerUnservedError; } });
142
+ Object.defineProperty(exports, "OracleWeightCoverageError", { enumerable: true, get: function () { return index_ts_1.OracleWeightCoverageError; } });
143
+ Object.defineProperty(exports, "OracleWeightUnreadableError", { enumerable: true, get: function () { return index_ts_1.OracleWeightUnreadableError; } });
142
144
  Object.defineProperty(exports, "OracleSourceNotImplementedError", { enumerable: true, get: function () { return index_ts_1.OracleSourceNotImplementedError; } });
143
- Object.defineProperty(exports, "PythCache", { enumerable: true, get: function () { return index_ts_1.PythCache; } });
144
145
  Object.defineProperty(exports, "aggregateTicker", { enumerable: true, get: function () { return index_ts_1.aggregateTicker; } });
145
146
  Object.defineProperty(exports, "aggregateTickerWithConstant", { enumerable: true, get: function () { return index_ts_1.aggregateTickerWithConstant; } });
146
- Object.defineProperty(exports, "aggregateTickerWithPyth", { enumerable: true, get: function () { return index_ts_1.aggregateTickerWithPyth; } });
147
147
  Object.defineProperty(exports, "ORACLE_SOURCES", { enumerable: true, get: function () { return index_ts_1.ORACLE_SOURCES; } });
148
- Object.defineProperty(exports, "buildPythPriceUpdateCalls", { enumerable: true, get: function () { return index_ts_1.buildPythPriceUpdateCalls; } });
149
- Object.defineProperty(exports, "fetchPriceFeedsUpdateData", { enumerable: true, get: function () { return index_ts_1.fetchPriceFeedsUpdateData; } });
150
- Object.defineProperty(exports, "isOracleSource", { enumerable: true, get: function () { return index_ts_1.isOracleSource; } });
151
- Object.defineProperty(exports, "parseOracleSourceList", { enumerable: true, get: function () { return index_ts_1.parseOracleSourceList; } });
152
- Object.defineProperty(exports, "pythCoreHermesEndpoint", { enumerable: true, get: function () { return index_ts_1.pythCoreHermesEndpoint; } });
153
- Object.defineProperty(exports, "pythProHermesEndpoint", { enumerable: true, get: function () { return index_ts_1.pythProHermesEndpoint; } });
148
+ Object.defineProperty(exports, "assertOracleWeightCoverage", { enumerable: true, get: function () { return index_ts_1.assertOracleWeightCoverage; } });
149
+ Object.defineProperty(exports, "assertOracleWriteCoverage", { enumerable: true, get: function () { return index_ts_1.assertOracleWriteCoverage; } });
150
+ Object.defineProperty(exports, "fetchPythProHistory", { enumerable: true, get: function () { return index_ts_1.fetchPythProHistory; } });
151
+ Object.defineProperty(exports, "fetchPythSymbolCatalog", { enumerable: true, get: function () { return index_ts_1.fetchPythSymbolCatalog; } });
152
+ Object.defineProperty(exports, "fetchWaterxSignedLeaves", { enumerable: true, get: function () { return index_ts_1.fetchWaterxSignedLeaves; } });
153
+ Object.defineProperty(exports, "fetchWaterxSignedUpdate", { enumerable: true, get: function () { return index_ts_1.fetchWaterxSignedUpdate; } });
154
+ Object.defineProperty(exports, "fetchWaterxUpdateData", { enumerable: true, get: function () { return index_ts_1.fetchWaterxUpdateData; } });
155
+ Object.defineProperty(exports, "getMarketStatus", { enumerable: true, get: function () { return index_ts_1.getMarketStatus; } });
156
+ Object.defineProperty(exports, "isFreshWaterxEntry", { enumerable: true, get: function () { return index_ts_1.isFreshWaterxEntry; } });
157
+ Object.defineProperty(exports, "deriveOracleSources", { enumerable: true, get: function () { return index_ts_1.deriveOracleSources; } });
158
+ Object.defineProperty(exports, "missingOracleCredentials", { enumerable: true, get: function () { return index_ts_1.missingOracleCredentials; } });
159
+ Object.defineProperty(exports, "parsePythSchedule", { enumerable: true, get: function () { return index_ts_1.parsePythSchedule; } });
160
+ Object.defineProperty(exports, "PythScheduleParseError", { enumerable: true, get: function () { return index_ts_1.PythScheduleParseError; } });
161
+ // THE quote-center route ladder (leaves-first, envelope only where there is
162
+ // no leaf route). Both SDK planes go through it, so a consumer running its
163
+ // own prefetch reaches for the same one rather than re-deriving the ladder.
164
+ Object.defineProperty(exports, "pullWaterxQuotes", { enumerable: true, get: function () { return index_ts_1.pullWaterxQuotes; } });
165
+ Object.defineProperty(exports, "readLazerPrices", { enumerable: true, get: function () { return index_ts_1.readLazerPrices; } });
166
+ Object.defineProperty(exports, "readPlanTickers", { enumerable: true, get: function () { return index_ts_1.readPlanTickers; } });
167
+ Object.defineProperty(exports, "readQuoteCenterPrices", { enumerable: true, get: function () { return index_ts_1.readQuoteCenterPrices; } });
154
168
  Object.defineProperty(exports, "refreshOraclePrices", { enumerable: true, get: function () { return index_ts_1.refreshOraclePrices; } });
155
- Object.defineProperty(exports, "resolveHermesReadEndpoint", { enumerable: true, get: function () { return index_ts_1.resolveHermesReadEndpoint; } });
156
- Object.defineProperty(exports, "updatePythPrices", { enumerable: true, get: function () { return index_ts_1.updatePythPrices; } });
169
+ Object.defineProperty(exports, "resolveOracleReadPlan", { enumerable: true, get: function () { return index_ts_1.resolveOracleReadPlan; } });
170
+ Object.defineProperty(exports, "resolveOracleRule", { enumerable: true, get: function () { return index_ts_1.resolveOracleRule; } });
171
+ // `refreshOraclePrices`' OWN acceptance predicate. Consumers filtering a
172
+ // ticker list before a build must use this rather than re-deriving "some
173
+ // listed source carries it", or they drift from what the build accepts.
174
+ Object.defineProperty(exports, "servableTickers", { enumerable: true, get: function () { return index_ts_1.servableTickers; } });
175
+ Object.defineProperty(exports, "WATERX_MAX_PRICE_AGE_MS", { enumerable: true, get: function () { return index_ts_1.WATERX_MAX_PRICE_AGE_MS; } });
157
176
  Object.defineProperty(exports, "waterxEnvelopeOf", { enumerable: true, get: function () { return index_ts_1.waterxEnvelopeOf; } });
177
+ // Leaves are the DEFAULT waterx wire shape, so their accessor + parser belong
178
+ // on the same surface as `waterxEnvelopeOf` (and on the root, which re-exports
179
+ // this file). A prefetch cache written against the envelope-only surface would
180
+ // otherwise get `null` from its only accessor on the normal path and have to
181
+ // discover `@waterx/sdk/oracle` to fix it.
182
+ Object.defineProperty(exports, "waterxLeavesOf", { enumerable: true, get: function () { return index_ts_1.waterxLeavesOf; } });
183
+ Object.defineProperty(exports, "parseSignedLeaves", { enumerable: true, get: function () { return index_ts_1.parseSignedLeaves; } });
184
+ Object.defineProperty(exports, "MERKLE_ROOT_INTENT", { enumerable: true, get: function () { return index_ts_1.MERKLE_ROOT_INTENT; } });
158
185
  Object.defineProperty(exports, "waterxQuoteCenterEndpoint", { enumerable: true, get: function () { return index_ts_1.waterxQuoteCenterEndpoint; } });
159
186
  // ======== Wormhole / Wormholescan utilities (credit bridge) ========
160
187
  var wormhole_ts_1 = require("../account/funding/wormhole.js");
@@ -192,8 +219,6 @@ exports.viewCalls = __importStar(require("../generated/waterx_perp_view/view.js"
192
219
  exports.wxaAccountCalls = __importStar(require("../generated/waterx_account/account.js"));
193
220
  exports.stakingCalls = __importStar(require("../generated/waterx_staking/waterx_staking.js"));
194
221
  exports.oracleCalls = __importStar(require("../generated/waterx_oracle/oracle.js"));
195
- exports.pythRuleCalls = __importStar(require("../generated/waterx_pyth_rule/pyth_rule.js"));
196
- exports.pythSponsorRuleCalls = __importStar(require("../generated/pyth_sponsor_rule/pyth_sponsor_rule.js"));
197
222
  exports.referralCalls = __importStar(require("../generated/waterx_referral/referral_table.js"));
198
223
  exports.nativeCustodyCalls = __importStar(require("../generated/native_custody/custody_vault.js"));
199
224
  exports.withdrawalQueueCalls = __importStar(require("../generated/withdrawal_queue/withdrawal_queue.js"));
@@ -1,44 +1,58 @@
1
1
  /**
2
2
  * Shared scaffolding for the high-level perp `build*Tx` composers:
3
3
  * `CommonBuildOpts`, the new-or-reuse PTB helper, the WLP pool-oracle refresh,
4
- * and the request+execute envelope (optional Pyth-sponsor flow + pre-sweep).
4
+ * and the request+execute envelope (optional pre-sweep).
5
5
  */
6
6
  import { Transaction, type TransactionArgument } from "@mysten/sui/transactions";
7
- import { PythCache, type OracleFeeSource, type UpdateDataProvider } from "../../oracle/index.ts";
7
+ import { type OracleRefreshSummary, type UpdateDataProvider } from "../../oracle/index.ts";
8
8
  import type { PerpClient } from "../client.ts";
9
9
  export interface CommonBuildOpts {
10
10
  /** Append to an existing PTB instead of creating a new one. */
11
11
  tx?: Transaction;
12
- /** Skip oracle refresh entirely (caller manages freshness). Default: false. */
13
- skipOraclePriceRefresh?: boolean;
14
- /** Share a `PythCache` across builders to avoid redundant pyth_state reads. */
15
- pythCache?: PythCache;
16
12
  /**
17
- * @deprecated No longer a fee-source decision. `wrapRequestAndExecute` now
18
- * opens (and reimburses) the `pyth_sponsor_rule` Fund purely from config
19
- * presence whenever `client.config.packages.pyth_sponsor_rule` is
20
- * deployed, the fund is ALWAYS opened, regardless of this flag (see
21
- * `OracleFeeSourceUnavailable` in `oracle/pyth.ts`). This closes the gap
22
- * where a market whose checklist required `PythSponsorRule`, or a caller
23
- * that mis-set this flag, silently drew from `tx.gas` and failed
24
- * ON-CHAIN instead of at build time. Use `allowGasFee` for the
25
- * non-sponsored case instead. Kept accepted (as a no-op) only so existing
26
- * callers keep compiling; will be removed in a future major version.
13
+ * Skip oracle refresh entirely (caller manages freshness). Default: false.
14
+ *
15
+ * This is the SHARED-REFRESH composition lever: a caller batching several
16
+ * builders into one PTB refreshes once, up front, then passes the same `tx`
17
+ * to each builder with this flag set —
18
+ *
19
+ * const tx = new Transaction();
20
+ * await refreshOraclePrices(tx, client.perp, allTickers);
21
+ * await buildIncreasePositionTx(client.perp, { ...a, tx, skipOraclePriceRefresh: true });
22
+ * await buildPlaceOrderTx(client.perp, { ...b, tx, skipOraclePriceRefresh: true });
23
+ *
24
+ * — one refresh covering `allTickers` (every builder's market + collateral
25
+ * tickers + the WLP pool tokens) instead of N. This is not just a gas
26
+ * saving: under `waterx_rule` a repeated per-builder refresh would submit
27
+ * the same signed timestamp twice per symbol in one PTB, paying full
28
+ * verification for an on-chain abstain (the F-014 per-symbol replay
29
+ * high-water mark).
30
+ *
31
+ * Sharing one fetched waterx snapshot across CONCURRENT builds is safe on
32
+ * these paths: every builder here feeds through `collect_*`, where a
33
+ * replayed per-symbol timestamp ABSTAINS rather than aborting — the chain
34
+ * already holds a price at least that fresh. `EReplayedSignature` is raised
35
+ * only by the single-rule `feed_*` entries, which no `build*Tx` uses. The
36
+ * cost of sharing is a contribution that does not count, not a failed
37
+ * transaction.
27
38
  */
28
- useSponsor?: boolean;
39
+ skipOraclePriceRefresh?: boolean;
29
40
  /**
30
- * Explicit opt-in to draw the Pyth update fee from `tx.gas` when this
31
- * client's config has no `pyth_sponsor_rule` deployed. Ignored whenever a
32
- * sponsor fund IS available the sponsor pool always wins over `tx.gas`
33
- * when one can be opened (see `useSponsor`'s deprecation note above).
34
- * Required for flows with no `TradingRequest` to reimburse a sponsor fund
35
- * against (e.g. `buildMintWlpTx` see its doc comment). Building an
36
- * oracle refresh with neither a sponsor fund nor this flag throws
37
- * `OracleFeeSourceUnavailable` instead of silently drawing from `tx.gas`
38
- * (Enoki-sponsored transactions reject any `tx.gas` draw). Default:
39
- * `false`.
41
+ * Build even when a ticker this action depends on could not be refreshed.
42
+ *
43
+ * `refreshOraclePrices` SKIPS tickers no listed source serves (it is a broad
44
+ * primitive losing 29 tickers because the 30th is unconfigured is the wrong
45
+ * trade). The composers then fail closed on the subset their specific action
46
+ * actually depends on. This opts out of that check, building against whatever
47
+ * price the chain already holds.
48
+ *
49
+ * Rarely correct. The on-chain guards do NOT cover for it: `mint_wlp` sizes
50
+ * the payout off `pool.tvl_usd`, and `assert_prices_fresh` only compares each
51
+ * token's `last_price_refresh_timestamp` against
52
+ * `price_refresh_threshold_ms` — so a pool asset last refreshed by SOMEONE
53
+ * ELSE minutes ago passes, and the mint is valued off that stale price.
40
54
  */
41
- allowGasFee?: boolean;
55
+ allowUnrefreshedPrices?: boolean;
42
56
  /**
43
57
  * Pre-sweep parked backing assets (USDC, USDsui, …) at the wxa account's
44
58
  * address into USD credit, plus any CREDIT coins/funds at the address into
@@ -73,36 +87,63 @@ interface RequestParams {
73
87
  lpType?: string;
74
88
  }
75
89
  export declare function newTx(opts?: CommonBuildOpts): Transaction;
90
+ /**
91
+ * Fail the build when a ticker THIS action depends on went unrefreshed.
92
+ *
93
+ * The split of responsibility: `refreshOraclePrices` skips (it cannot know
94
+ * which of its tickers were load-bearing), the composer asserts (it does).
95
+ */
96
+ export declare function assertTickersRefreshed(client: PerpClient, summary: OracleRefreshSummary, required: string[], opts: CommonBuildOpts | undefined,
97
+ /** Appended to the error, to say why THESE tickers were load-bearing. */
98
+ why?: string): void;
99
+ /**
100
+ * Fail the build when ANY WLP pool asset went unpriced — stricter than
101
+ * {@link assertTickersRefreshed}, and deliberately so.
102
+ *
103
+ * `mint_wlp` / `settle_redeem` take `&WlpAum` and size the payout against the
104
+ * pool's WHOLE `tvl_usd`, so a stale price on any pool asset mis-values the
105
+ * trade — not just a stale price on the deposit ticker.
106
+ *
107
+ * Nothing on chain catches the gap. Two paths, neither of which fails:
108
+ * - the asset IS bumped: `update_token_value` calls `oracle::get_price`,
109
+ * which aborts `EStalePrice` unless this PTB aggregated it — loud, safe;
110
+ * - the asset is NOT bumped (it was skipped, so no leg was emitted): its
111
+ * `last_price_refresh_timestamp` keeps whatever a previous transaction
112
+ * left, and `assert_prices_fresh` only asks that it be within
113
+ * `price_refresh_threshold_ms`. A recent-enough stale price PASSES.
114
+ *
115
+ * So the silent case is exactly the skipped one, and the build is the only
116
+ * place it can be caught.
117
+ */
118
+ export declare function assertWlpPoolRefreshed(client: PerpClient, summary: OracleRefreshSummary, opts: CommonBuildOpts | undefined): void;
76
119
  /**
77
120
  * Refresh every WLP pool-token oracle (+ caller-supplied extra tickers) and
78
121
  * bump each pool token's `last_price_refresh_timestamp` so the pool's
79
122
  * `assert_prices_fresh` passes when the next `mint_wlp` / `request_redeem` /
80
123
  * trading `execute` runs in the same PTB.
124
+ *
125
+ * Fails closed via {@link assertWlpPoolRefreshed} — see there for why a gap is
126
+ * otherwise silent rather than an on-chain abort.
81
127
  */
82
- export declare function refreshWlpPoolOracles(tx: Transaction, client: PerpClient, extraTickers: string[], opts: {
83
- cache?: PythCache;
84
- /** Forwarded to `refreshOraclePrices` — already resolved by the caller (see `OracleFeeSource`). */
85
- feeSource?: OracleFeeSource;
128
+ export declare function refreshWlpPoolOracles(tx: Transaction, client: PerpClient, extraTickers: string[],
129
+ /** The build's options — `lpType`, plus `allowUnrefreshedPrices` / `updateDataProvider`. */
130
+ opts: CommonBuildOpts & {
86
131
  lpType?: string;
87
- updateDataProvider?: UpdateDataProvider;
88
- }): Promise<void>;
132
+ }): Promise<OracleRefreshSummary>;
89
133
  /**
90
- * Build the *Request + execute envelope with the config-driven Pyth sponsor flow:
134
+ * Build the *Request + execute envelope:
91
135
  *
92
136
  * [maybeConsolidate(tx)]
93
- * [fund = sponsor.request()]
94
- * refreshOraclePrices(..., feeSource?)
137
+ * refreshOraclePrices(...)
95
138
  * req = buildRequest()
96
- * [sponsor.reimburse(fund, req)]
97
139
  * trading::execute(req)
98
140
  *
99
141
  * Accepted ordering caveat: `maybeConsolidate` runs FIRST and can itself
100
- * append PTB commands (the consolidation sweep) before the fee-source check
101
- * inside `refreshOraclePrices` ever runs — so an `OracleFeeSourceUnavailable`
102
- * throw here is NOT the "zero commands appended" guarantee
103
- * `refreshOraclePrices` gives its own callers (see its docblock in
104
- * `aggregate.ts`); `tx` can already carry the sweep. This is the same
105
- * discard-tx-on-throw contract every `build*Tx` composer already has for
142
+ * append PTB commands (the consolidation sweep) before the refresh's own
143
+ * pre-checks run — so a throw out of `refreshOraclePrices` here is NOT the
144
+ * "zero commands appended" guarantee it gives its own callers (see its
145
+ * docblock in `aggregate.ts`); `tx` can already carry the sweep. This is the
146
+ * same discard-tx-on-throw contract every `build*Tx` composer already has for
106
147
  * mid-build on-chain-read failures — not a new hole. It matters only for a
107
148
  * caller that passed in their OWN `opts.tx` (reusing one `Transaction`
108
149
  * across builder calls, e.g. to compose several actions in one PTB); such a
@@ -111,10 +152,7 @@ export declare function refreshWlpPoolOracles(tx: Transaction, client: PerpClien
111
152
  */
112
153
  export declare function wrapRequestAndExecute(client: PerpClient, tx: Transaction, req: RequestParams & {
113
154
  accountId: string;
114
- }, collateralTicker: string, opts: CommonBuildOpts | undefined, buildRequest: (sponsorFund?: {
115
- fund: TransactionArgument;
116
- packageId: string;
117
- }) => TransactionArgument): Promise<void>;
155
+ }, collateralTicker: string, opts: CommonBuildOpts | undefined, buildRequest: () => TransactionArgument): Promise<void>;
118
156
  /** Run the async sweep iff `consolidateToUsd !== false`. */
119
157
  export declare function maybeConsolidate(client: PerpClient, tx: Transaction, accountId: string, opts: CommonBuildOpts | undefined): Promise<void>;
120
158
  export {};