@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.
Files changed (145) hide show
  1. package/.claude/skills/waterx-sdk-integration/SKILL.md +41 -35
  2. package/README.md +81 -77
  3. package/dist/cjs/src/account/config.d.ts +3 -5
  4. package/dist/cjs/src/account/funding/wormhole.d.ts +1 -2
  5. package/dist/cjs/src/account/funding/wormhole.js +1 -2
  6. package/dist/cjs/src/oracle/aggregate.d.ts +45 -61
  7. package/dist/cjs/src/oracle/aggregate.js +138 -138
  8. package/dist/cjs/src/oracle/config.d.ts +35 -49
  9. package/dist/cjs/src/oracle/config.js +1 -1
  10. package/dist/cjs/src/oracle/host.d.ts +14 -19
  11. package/dist/cjs/src/oracle/host.js +3 -3
  12. package/dist/cjs/src/oracle/index.d.ts +25 -16
  13. package/dist/cjs/src/oracle/index.js +79 -66
  14. package/dist/cjs/src/oracle/price-update-rule.d.ts +104 -66
  15. package/dist/cjs/src/oracle/price-update-rule.js +24 -16
  16. package/dist/cjs/src/oracle/pyth-pro-history.d.ts +36 -0
  17. package/dist/cjs/src/oracle/pyth-pro-history.js +41 -0
  18. package/dist/cjs/src/oracle/read-plane.d.ts +35 -53
  19. package/dist/cjs/src/oracle/read-plane.js +26 -48
  20. package/dist/cjs/src/oracle/read-prices.d.ts +105 -0
  21. package/dist/cjs/src/oracle/read-prices.js +162 -0
  22. package/dist/cjs/src/oracle/rule-registry.d.ts +12 -12
  23. package/dist/cjs/src/oracle/rule-registry.js +12 -14
  24. package/dist/cjs/src/oracle/rules/pyth-lazer-rule.d.ts +24 -3
  25. package/dist/cjs/src/oracle/rules/pyth-lazer-rule.js +40 -20
  26. package/dist/cjs/src/oracle/rules/waterx-rule.d.ts +137 -12
  27. package/dist/cjs/src/oracle/rules/waterx-rule.js +318 -55
  28. package/dist/cjs/src/oracle/schedule.d.ts +109 -0
  29. package/dist/cjs/src/oracle/schedule.js +991 -0
  30. package/dist/cjs/src/oracle/source-list.d.ts +31 -27
  31. package/dist/cjs/src/oracle/source-list.js +43 -45
  32. package/dist/cjs/src/oracle/symbol-catalog.d.ts +54 -0
  33. package/dist/cjs/src/oracle/symbol-catalog.js +69 -0
  34. package/dist/cjs/src/oracle/update-fetch.d.ts +11 -15
  35. package/dist/cjs/src/oracle/update-fetch.js +12 -19
  36. package/dist/cjs/src/oracle/validate.d.ts +105 -0
  37. package/dist/cjs/src/oracle/validate.js +185 -0
  38. package/dist/cjs/src/oracle/weight-coverage.d.ts +79 -0
  39. package/dist/cjs/src/oracle/weight-coverage.js +173 -0
  40. package/dist/cjs/src/perp/client.d.ts +35 -52
  41. package/dist/cjs/src/perp/client.js +44 -17
  42. package/dist/cjs/src/perp/config-view.d.ts +5 -14
  43. package/dist/cjs/src/perp/config-view.js +5 -16
  44. package/dist/cjs/src/perp/config.d.ts +3 -3
  45. package/dist/cjs/src/perp/config.js +11 -13
  46. package/dist/cjs/src/perp/index.d.ts +4 -6
  47. package/dist/cjs/src/perp/index.js +35 -18
  48. package/dist/cjs/src/perp/tx-builders/common.d.ts +86 -48
  49. package/dist/cjs/src/perp/tx-builders/common.js +115 -47
  50. package/dist/cjs/src/perp/tx-builders/wlp.d.ts +3 -14
  51. package/dist/cjs/src/perp/tx-builders/wlp.js +6 -35
  52. package/dist/cjs/src/perp/tx-builders.d.ts +6 -5
  53. package/dist/cjs/src/perp/tx-builders.js +16 -10
  54. package/dist/cjs/src/unified-client.d.ts +8 -34
  55. package/dist/cjs/src/unified-client.js +3 -4
  56. package/dist/cjs/src/utils/config.d.ts +0 -8
  57. package/dist/cjs/src/utils/config.js +5 -13
  58. package/dist/src/account/config.d.ts +3 -5
  59. package/dist/src/account/funding/wormhole.d.ts +1 -2
  60. package/dist/src/account/funding/wormhole.js +1 -2
  61. package/dist/src/oracle/aggregate.d.ts +45 -61
  62. package/dist/src/oracle/aggregate.js +138 -137
  63. package/dist/src/oracle/config.d.ts +35 -49
  64. package/dist/src/oracle/config.js +1 -1
  65. package/dist/src/oracle/host.d.ts +14 -19
  66. package/dist/src/oracle/host.js +3 -3
  67. package/dist/src/oracle/index.d.ts +25 -16
  68. package/dist/src/oracle/index.js +55 -50
  69. package/dist/src/oracle/price-update-rule.d.ts +104 -66
  70. package/dist/src/oracle/price-update-rule.js +23 -16
  71. package/dist/src/oracle/pyth-pro-history.d.ts +36 -0
  72. package/dist/src/oracle/pyth-pro-history.js +38 -0
  73. package/dist/src/oracle/read-plane.d.ts +35 -53
  74. package/dist/src/oracle/read-plane.js +25 -47
  75. package/dist/src/oracle/read-prices.d.ts +105 -0
  76. package/dist/src/oracle/read-prices.js +156 -0
  77. package/dist/src/oracle/rule-registry.d.ts +12 -12
  78. package/dist/src/oracle/rule-registry.js +12 -14
  79. package/dist/src/oracle/rules/pyth-lazer-rule.d.ts +24 -3
  80. package/dist/src/oracle/rules/pyth-lazer-rule.js +39 -20
  81. package/dist/src/oracle/rules/waterx-rule.d.ts +137 -12
  82. package/dist/src/oracle/rules/waterx-rule.js +314 -56
  83. package/dist/src/oracle/schedule.d.ts +109 -0
  84. package/dist/src/oracle/schedule.js +985 -0
  85. package/dist/src/oracle/source-list.d.ts +31 -27
  86. package/dist/src/oracle/source-list.js +42 -43
  87. package/dist/src/oracle/symbol-catalog.d.ts +54 -0
  88. package/dist/src/oracle/symbol-catalog.js +65 -0
  89. package/dist/src/oracle/update-fetch.d.ts +11 -15
  90. package/dist/src/oracle/update-fetch.js +12 -18
  91. package/dist/src/oracle/validate.d.ts +105 -0
  92. package/dist/src/oracle/validate.js +177 -0
  93. package/dist/src/oracle/weight-coverage.d.ts +79 -0
  94. package/dist/src/oracle/weight-coverage.js +166 -0
  95. package/dist/src/perp/client.d.ts +35 -52
  96. package/dist/src/perp/client.js +45 -18
  97. package/dist/src/perp/config-view.d.ts +5 -14
  98. package/dist/src/perp/config-view.js +5 -16
  99. package/dist/src/perp/config.d.ts +3 -3
  100. package/dist/src/perp/config.js +11 -13
  101. package/dist/src/perp/index.d.ts +4 -6
  102. package/dist/src/perp/index.js +11 -5
  103. package/dist/src/perp/tx-builders/common.d.ts +86 -48
  104. package/dist/src/perp/tx-builders/common.js +114 -48
  105. package/dist/src/perp/tx-builders/wlp.d.ts +3 -14
  106. package/dist/src/perp/tx-builders/wlp.js +6 -35
  107. package/dist/src/perp/tx-builders.d.ts +6 -5
  108. package/dist/src/perp/tx-builders.js +15 -6
  109. package/dist/src/unified-client.d.ts +8 -34
  110. package/dist/src/unified-client.js +3 -4
  111. package/dist/src/utils/config.d.ts +0 -8
  112. package/dist/src/utils/config.js +5 -12
  113. package/package.json +1 -1
  114. package/dist/cjs/src/generated/pyth_sponsor_rule/deps/sui/balance.d.ts +0 -12
  115. package/dist/cjs/src/generated/pyth_sponsor_rule/deps/sui/balance.js +0 -17
  116. package/dist/cjs/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +0 -68
  117. package/dist/cjs/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +0 -113
  118. package/dist/cjs/src/generated/waterx_pyth_rule/deps/sui/vec_map.d.ts +0 -36
  119. package/dist/cjs/src/generated/waterx_pyth_rule/deps/sui/vec_map.js +0 -31
  120. package/dist/cjs/src/generated/waterx_pyth_rule/pyth_rule.d.ts +0 -192
  121. package/dist/cjs/src/generated/waterx_pyth_rule/pyth_rule.js +0 -214
  122. package/dist/cjs/src/oracle/pyth.d.ts +0 -227
  123. package/dist/cjs/src/oracle/pyth.js +0 -652
  124. package/dist/cjs/src/oracle/rules/pyth-core-rule.d.ts +0 -15
  125. package/dist/cjs/src/oracle/rules/pyth-core-rule.js +0 -100
  126. package/dist/cjs/src/oracle/rules/pyth-rule.d.ts +0 -11
  127. package/dist/cjs/src/oracle/rules/pyth-rule.js +0 -29
  128. package/dist/cjs/src/oracle/rules/sponsor.d.ts +0 -32
  129. package/dist/cjs/src/oracle/rules/sponsor.js +0 -56
  130. package/dist/src/generated/pyth_sponsor_rule/deps/sui/balance.d.ts +0 -12
  131. package/dist/src/generated/pyth_sponsor_rule/deps/sui/balance.js +0 -14
  132. package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +0 -68
  133. package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +0 -73
  134. package/dist/src/generated/waterx_pyth_rule/deps/sui/vec_map.d.ts +0 -36
  135. package/dist/src/generated/waterx_pyth_rule/deps/sui/vec_map.js +0 -27
  136. package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +0 -192
  137. package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +0 -170
  138. package/dist/src/oracle/pyth.d.ts +0 -227
  139. package/dist/src/oracle/pyth.js +0 -638
  140. package/dist/src/oracle/rules/pyth-core-rule.d.ts +0 -15
  141. package/dist/src/oracle/rules/pyth-core-rule.js +0 -97
  142. package/dist/src/oracle/rules/pyth-rule.d.ts +0 -11
  143. package/dist/src/oracle/rules/pyth-rule.js +0 -26
  144. package/dist/src/oracle/rules/sponsor.d.ts +0 -32
  145. package/dist/src/oracle/rules/sponsor.js +0 -52
@@ -15,17 +15,8 @@ export interface BuildMintWlpParams extends MintWlpParams, CommonBuildOpts {
15
15
  * Mints WLP from a deposit asset already in the wxa account's stored
16
16
  * balance. Refreshes every pool-token oracle + bumps each pool token's
17
17
  * `last_price_refresh_timestamp` so `assert_prices_fresh` inside
18
- * `mint_wlp` passes.
19
- *
20
- * Never uses the pyth_sponsor flow — `mint_wlp` produces no
21
- * `TradingRequest`, so there's nothing for the sponsor to attach its
22
- * witness to, and `pyth_sponsor_rule::reimburse` cannot consume a Fund
23
- * without one. So when `skipOraclePriceRefresh` is `false` (the refresh
24
- * actually runs), the caller MUST pass `allowGasFee: true` — the Pyth
25
- * update fee is drawn from `tx.gas`, which Enoki-sponsored transactions
26
- * reject; a sponsored caller should keep `skipOraclePriceRefresh: true`
27
- * instead and rely on freshness from other trade traffic (see
28
- * `OracleFeeSourceUnavailable` in `oracle/pyth.ts`).
18
+ * `mint_wlp` passes. The refresh is fee-free (no update leg charges one),
19
+ * so this composes into Enoki-sponsored transactions as-is.
29
20
  */
30
21
  export declare function buildMintWlpTx(client: PerpClient, params: BuildMintWlpParams): Promise<Transaction>;
31
22
  export interface BuildMintAndStakeWlpParams extends BuildMintWlpParams {
@@ -68,9 +59,7 @@ export interface BuildUnstakeAndRequestRedeemWlpParams extends Omit<RequestRedee
68
59
  * Refreshes every WLP pool-token oracle by default — `request_redeem` runs
69
60
  * `assert_prices_fresh` internally, so a stale oracle would abort the PTB.
70
61
  * Pass `skipOraclePriceRefresh: true` only when the caller is composing this
71
- * into a larger PTB that already pre-pumps prices. Like `buildMintWlpTx`,
72
- * `request_redeem` produces no `TradingRequest`, so a non-skipped refresh
73
- * requires `allowGasFee: true` (see `buildMintWlpTx`'s doc comment).
62
+ * into a larger PTB that already pre-pumps prices.
74
63
  */
75
64
  export declare function buildUnstakeAndRequestRedeemWlpTx(client: PerpClient, params: BuildUnstakeAndRequestRedeemWlpParams): Promise<Transaction>;
76
65
  export interface BuildCancelRedeemAndStakeWlpParams extends CancelRedeemWlpParams, CommonBuildOpts {
@@ -10,31 +10,16 @@ import { maybeConsolidate, newTx, refreshWlpPoolOracles } from "./common.js";
10
10
  * Mints WLP from a deposit asset already in the wxa account's stored
11
11
  * balance. Refreshes every pool-token oracle + bumps each pool token's
12
12
  * `last_price_refresh_timestamp` so `assert_prices_fresh` inside
13
- * `mint_wlp` passes.
14
- *
15
- * Never uses the pyth_sponsor flow — `mint_wlp` produces no
16
- * `TradingRequest`, so there's nothing for the sponsor to attach its
17
- * witness to, and `pyth_sponsor_rule::reimburse` cannot consume a Fund
18
- * without one. So when `skipOraclePriceRefresh` is `false` (the refresh
19
- * actually runs), the caller MUST pass `allowGasFee: true` — the Pyth
20
- * update fee is drawn from `tx.gas`, which Enoki-sponsored transactions
21
- * reject; a sponsored caller should keep `skipOraclePriceRefresh: true`
22
- * instead and rely on freshness from other trade traffic (see
23
- * `OracleFeeSourceUnavailable` in `oracle/pyth.ts`).
13
+ * `mint_wlp` passes. The refresh is fee-free (no update leg charges one),
14
+ * so this composes into Enoki-sponsored transactions as-is.
24
15
  */
25
16
  export async function buildMintWlpTx(client, params) {
26
17
  const tx = newTx(params);
27
18
  await maybeConsolidate(client, tx, params.accountId, params);
28
- // `mint_wlp` has no sponsor flow to resolve against (see the doc comment
29
- // above) — the only candidate source at this edge is the caller's
30
- // ergonomic `allowGasFee` opt-in.
31
- const feeSource = params.allowGasFee ? { kind: "gas" } : undefined;
32
19
  if (!params.skipOraclePriceRefresh) {
33
20
  await refreshWlpPoolOracles(tx, client, [params.depositTicker], {
34
- cache: params.pythCache,
21
+ ...params,
35
22
  lpType: params.lpType,
36
- feeSource,
37
- updateDataProvider: params.updateDataProvider,
38
23
  });
39
24
  }
40
25
  mintWlp(client, tx, params);
@@ -52,16 +37,10 @@ export async function buildMintWlpTx(client, params) {
52
37
  export async function buildMintAndStakeWlpTx(client, params) {
53
38
  const tx = newTx(params);
54
39
  await maybeConsolidate(client, tx, params.accountId, params);
55
- // `mint_wlp` has no sponsor flow to resolve against (see `buildMintWlpTx`'s
56
- // doc comment) — the only candidate source at this edge is the caller's
57
- // ergonomic `allowGasFee` opt-in.
58
- const feeSource = params.allowGasFee ? { kind: "gas" } : undefined;
59
40
  if (!params.skipOraclePriceRefresh) {
60
41
  await refreshWlpPoolOracles(tx, client, [params.depositTicker], {
61
- cache: params.pythCache,
42
+ ...params,
62
43
  lpType: params.lpType,
63
- feeSource,
64
- updateDataProvider: params.updateDataProvider,
65
44
  });
66
45
  }
67
46
  const stakeAlias = params.stakeAlias ?? "WLP";
@@ -83,24 +62,16 @@ export async function buildMintAndStakeWlpTx(client, params) {
83
62
  * Refreshes every WLP pool-token oracle by default — `request_redeem` runs
84
63
  * `assert_prices_fresh` internally, so a stale oracle would abort the PTB.
85
64
  * Pass `skipOraclePriceRefresh: true` only when the caller is composing this
86
- * into a larger PTB that already pre-pumps prices. Like `buildMintWlpTx`,
87
- * `request_redeem` produces no `TradingRequest`, so a non-skipped refresh
88
- * requires `allowGasFee: true` (see `buildMintWlpTx`'s doc comment).
65
+ * into a larger PTB that already pre-pumps prices.
89
66
  */
90
67
  export async function buildUnstakeAndRequestRedeemWlpTx(client, params) {
91
68
  const tx = newTx(params);
92
69
  const stakeAlias = params.stakeAlias ?? "WLP";
93
70
  await maybeConsolidate(client, tx, params.accountId, params);
94
- // `request_redeem` has no sponsor flow to resolve against (see
95
- // `buildMintWlpTx`'s doc comment) — the only candidate source at this edge
96
- // is the caller's ergonomic `allowGasFee` opt-in.
97
- const feeSource = params.allowGasFee ? { kind: "gas" } : undefined;
98
71
  if (!params.skipOraclePriceRefresh) {
99
72
  await refreshWlpPoolOracles(tx, client, [], {
100
- cache: params.pythCache,
73
+ ...params,
101
74
  lpType: params.lpType,
102
- feeSource,
103
- updateDataProvider: params.updateDataProvider,
104
75
  });
105
76
  }
106
77
  unstake(client, tx, {
@@ -2,10 +2,10 @@
2
2
  * High-level perp transaction builders — barrel.
3
3
  *
4
4
  * Each `build*Tx` composer creates (or appends to) a `Transaction`, refreshes
5
- * the on-chain `Oracle` via Pyth, optionally pre-sweeps parked balances
6
- * (`consolidateToUsd`), wires the `pyth_sponsor_rule` flow when deployed in
7
- * config, and calls the matching `*_request` + `execute`. Implementations are
8
- * split by domain under `tx-builders/`:
5
+ * the on-chain `Oracle` via the client's derived fed set, optionally
6
+ * pre-sweeps parked balances (`consolidateToUsd`), and calls the matching
7
+ * `*_request` + `execute`. Implementations are split by domain under
8
+ * `tx-builders/`:
9
9
  *
10
10
  * common.ts CommonBuildOpts + request/execute envelope + oracle refresh
11
11
  * consolidate.ts parked-balance → wxUSD pre-sweep (appendConsolidate*)
@@ -20,4 +20,5 @@ export * from "./tx-builders/trading.ts";
20
20
  export * from "./tx-builders/wlp.ts";
21
21
  export * from "./tx-builders/rewards.ts";
22
22
  export * from "./tx-builders/credit.ts";
23
- export { openPythSponsorFund, PythCache, refreshOraclePrices, reimbursePythSponsor, updatePythPrices, } from "../oracle/index.ts";
23
+ export { refreshOraclePrices } from "../oracle/index.ts";
24
+ export { refreshWlpPoolOracles } from "./tx-builders/common.ts";
@@ -2,10 +2,10 @@
2
2
  * High-level perp transaction builders — barrel.
3
3
  *
4
4
  * Each `build*Tx` composer creates (or appends to) a `Transaction`, refreshes
5
- * the on-chain `Oracle` via Pyth, optionally pre-sweeps parked balances
6
- * (`consolidateToUsd`), wires the `pyth_sponsor_rule` flow when deployed in
7
- * config, and calls the matching `*_request` + `execute`. Implementations are
8
- * split by domain under `tx-builders/`:
5
+ * the on-chain `Oracle` via the client's derived fed set, optionally
6
+ * pre-sweeps parked balances (`consolidateToUsd`), and calls the matching
7
+ * `*_request` + `execute`. Implementations are split by domain under
8
+ * `tx-builders/`:
9
9
  *
10
10
  * common.ts CommonBuildOpts + request/execute envelope + oracle refresh
11
11
  * consolidate.ts parked-balance → wxUSD pre-sweep (appendConsolidate*)
@@ -19,5 +19,14 @@ export * from "./tx-builders/trading.js";
19
19
  export * from "./tx-builders/wlp.js";
20
20
  export * from "./tx-builders/rewards.js";
21
21
  export * from "./tx-builders/credit.js";
22
- // Oracle helpers re-exported for callers composing custom PTBs.
23
- export { openPythSponsorFund, PythCache, refreshOraclePrices, reimbursePythSponsor, updatePythPrices, } from "../oracle/index.js";
22
+ // Oracle helpers re-exported for callers composing custom PTBs (the
23
+ // shared-refresh composition see `CommonBuildOpts.skipOraclePriceRefresh`).
24
+ export { refreshOraclePrices } from "../oracle/index.js";
25
+ // The WLP pool-freshness leg. Public because any custom WLP PTB needs it and
26
+ // hand-rolling it is a trap: the refresh set and the `update_token_value` set
27
+ // must be IDENTICAL and must cover the WHOLE pool. Pre-filtering either one to
28
+ // what the fed set can price silently drops an asset from both halves, and
29
+ // nothing on chain objects — `assert_prices_fresh` only checks each token's
30
+ // timestamp against a threshold, so a recent-enough stale price passes and
31
+ // `mint_wlp` values the payout off it.
32
+ export { refreshWlpPoolOracles } from "./tx-builders/common.js";
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Exposes three namespaces over the two product-line sub-clients:
5
5
  *
6
- * const client = await WaterXClient.create({ network: "TESTNET", oracleSource: "pyth_rule" });
6
+ * const client = await WaterXClient.create({ network: "TESTNET" });
7
7
  * client.account.createAccount(tx, { alias }); // -> shared waterx_account + funding
8
8
  * client.perp.placeOrderRequest(tx, params); // -> perp builder
9
9
  * client.predict.placeOrder(tx, params); // -> prediction builder
@@ -25,15 +25,14 @@
25
25
  *
26
26
  * Each namespace method forwards to the existing free-function builder with the
27
27
  * line's client pre-bound as the first argument; builders are build-only (they
28
- * return / mutate a `Transaction`), so frontend wallet flows and multi-step Pyth
29
- * injection keep working.
28
+ * return / mutate a `Transaction`), so frontend wallet flows and multi-step
29
+ * oracle injection keep working.
30
30
  */
31
31
  import { Transaction } from "@mysten/sui/transactions";
32
32
  import * as accountOps from "./account/index.ts";
33
33
  import * as perpReferral from "./account/referral.ts";
34
34
  import type { Network } from "./constants.ts";
35
35
  import type { PythFetchPolicy } from "./oracle/config.ts";
36
- import type { OracleSource } from "./oracle/price-update-rule.ts";
37
36
  import type { FetchPolicy } from "./oracle/update-fetch.ts";
38
37
  import { PerpClient, type CreateClientOptions as PerpCreateOptions } from "./perp/client.ts";
39
38
  import * as perpFetch from "./perp/fetch.ts";
@@ -151,11 +150,8 @@ declare const perpOps: {
151
150
  amount: bigint | number;
152
151
  creditType?: string;
153
152
  }): Promise<perpFetch.BridgeFeeView>;
154
- openPythSponsorFund: typeof perpTx.openPythSponsorFund;
155
- PythCache: typeof perpTx.PythCache;
156
153
  refreshOraclePrices: typeof perpTx.refreshOraclePrices;
157
- reimbursePythSponsor: typeof perpTx.reimbursePythSponsor;
158
- updatePythPrices: typeof perpTx.updatePythPrices;
154
+ refreshWlpPoolOracles: typeof perpTx.refreshWlpPoolOracles;
159
155
  appendConsolidateToUsd(client: import("./account/client.ts").AccountClientLike, tx: Transaction, accountId: string): Promise<number>;
160
156
  appendConsolidateAddressCredit(client: import("./account/client.ts").AccountClientLike, tx: Transaction, accountId: string): Promise<number>;
161
157
  appendConsolidateForSpend(client: import("./account/client.ts").AccountClientLike, tx: Transaction, accountId: string): Promise<number>;
@@ -368,30 +364,8 @@ export interface ClientCreateOptions {
368
364
  /** Memoize the fetched config JSON. */
369
365
  cache?: boolean;
370
366
  /**
371
- * The perp line's oracle price-update source (perp-line only the
372
- * prediction line has no oracle leg), forwarded to `PerpClient.create`.
373
- * REQUIRED — there is NO default source: every deployment names its source
374
- * explicitly (wire it from your own env var, e.g. `ORACLE_SOURCE`).
375
- * Source-neutral by design: a source need not be Pyth (see `'waterx_rule'`).
376
- *
377
- * - `'pyth_rule'` — Pyth Core updates; infra in the source's own
378
- * `PYTH_CORE_INFRA` table.
379
- * - `'pyth_lazer_rule'` — Pyth Lazer signed updates (pair with `pythApiKey`
380
- * and a config carrying `packages.pyth_lazer_rule`); infra in the
381
- * source's own `LAZER_INFRA` table.
382
- * - `'waterx_rule'` — the first-party WaterX quote-center (Nautilus-TEE,
383
- * ed25519 signed batches; no credential, no per-update fee); infra in the
384
- * source's own `WATERX_INFRA` table. Pair with `waterxEndpoint` /
385
- * `waterxFetch` when the browser needs a proxy.
386
- *
387
- * Each source is self-contained with no cross-source fallback; selecting a
388
- * source whose feed for a ticker is absent fails at tx-build (not at init).
389
- * See perp `CreateClientOptions.oracleSource` for the full note.
390
- */
391
- oracleSource: OracleSource | OracleSource[];
392
- /**
393
- * Pyth Lazer access token, forwarded to the perp line. Required under
394
- * `oracleSource: 'pyth_lazer_rule'`, unused by `'pyth_rule'`. A SECRET —
367
+ * Pyth Lazer access token, forwarded to the perp line. Required when the
368
+ * deployment's config wires `pyth_lazer_rule`, unused otherwise. A SECRET
395
369
  * pass it at init from your own env var; it is never read from the config
396
370
  * JSON or `process.env`.
397
371
  */
@@ -399,8 +373,8 @@ export interface ClientCreateOptions {
399
373
  /** Retry/timeout policy for the perp line's off-chain oracle fetches. */
400
374
  pythFetch?: PythFetchPolicy;
401
375
  /**
402
- * Quote-center base URL for `oracleSource: 'waterx_rule'`, forwarded to the
403
- * perp line — overrides the source's own per-network `WATERX_INFRA` default.
376
+ * Quote-center base URL for `waterx_rule`, forwarded to the perp line —
377
+ * overrides the source's own per-network `WATERX_INFRA` default.
404
378
  *
405
379
  * `waterx_rule` is the one source a BROWSER fetches itself, so it is bound by
406
380
  * the quote-center deployment's CORS allowlist: a front end whose origin is
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Exposes three namespaces over the two product-line sub-clients:
5
5
  *
6
- * const client = await WaterXClient.create({ network: "TESTNET", oracleSource: "pyth_rule" });
6
+ * const client = await WaterXClient.create({ network: "TESTNET" });
7
7
  * client.account.createAccount(tx, { alias }); // -> shared waterx_account + funding
8
8
  * client.perp.placeOrderRequest(tx, params); // -> perp builder
9
9
  * client.predict.placeOrder(tx, params); // -> prediction builder
@@ -25,8 +25,8 @@
25
25
  *
26
26
  * Each namespace method forwards to the existing free-function builder with the
27
27
  * line's client pre-bound as the first argument; builders are build-only (they
28
- * return / mutate a `Transaction`), so frontend wallet flows and multi-step Pyth
29
- * injection keep working.
28
+ * return / mutate a `Transaction`), so frontend wallet flows and multi-step
29
+ * oracle injection keep working.
30
30
  */
31
31
  // Unified account namespace: generic waterx_account framework + funding (credit + custody).
32
32
  import * as accountOps from "./account/index.js";
@@ -168,7 +168,6 @@ export class WaterXClient {
168
168
  grpcUrl: opts.grpcUrl,
169
169
  waterxConfigUrl: opts.waterxConfigUrl,
170
170
  cache: opts.cache,
171
- oracleSource: opts.oracleSource,
172
171
  pythApiKey: opts.pythApiKey,
173
172
  pythFetch: opts.pythFetch,
174
173
  waterxEndpoint: opts.waterxEndpoint,
@@ -1,11 +1,3 @@
1
1
  import type { WaterXConfig } from "../perp/config.ts";
2
2
  /** Returns all registered market tickers (e.g. "BTCUSD") from waterx-config. */
3
3
  export declare function getMarketTickers(config: WaterXConfig): string[];
4
- /**
5
- * Returns WLP pool-token tickers that also have a registered pyth_rule feed —
6
- * the canonical testnet config keys `pool_tokens` by coin symbol (e.g. `"USD"`)
7
- * while `pyth_rule.feeds` is keyed by oracle ticker (e.g. `"USDCUSD"`), so a
8
- * naive `Object.keys(pool_tokens)` blows up at `refreshOraclePrices` for any
9
- * key without a feed. Filter so the auto-refresh path stays tolerant.
10
- */
11
- export declare function getCollateralAssets(config: WaterXConfig): string[];
@@ -1,16 +1,9 @@
1
- import { ownEntry } from "./record.js";
2
1
  /** Returns all registered market tickers (e.g. "BTCUSD") from waterx-config. */
3
2
  export function getMarketTickers(config) {
4
3
  return Object.keys(config.packages.waterx_perp.markets);
5
4
  }
6
- /**
7
- * Returns WLP pool-token tickers that also have a registered pyth_rule feed
8
- * the canonical testnet config keys `pool_tokens` by coin symbol (e.g. `"USD"`)
9
- * while `pyth_rule.feeds` is keyed by oracle ticker (e.g. `"USDCUSD"`), so a
10
- * naive `Object.keys(pool_tokens)` blows up at `refreshOraclePrices` for any
11
- * key without a feed. Filter so the auto-refresh path stays tolerant.
12
- */
13
- export function getCollateralAssets(config) {
14
- const feeds = config.packages.pyth_rule?.feeds ?? {};
15
- return Object.keys(config.packages.wlp.pool_tokens).filter((t) => ownEntry(feeds, t) !== undefined);
16
- }
5
+ // "Which WLP pool tokens can this deployment PRICE" is an oracle-coverage
6
+ // question, not a config read: it depends on the client's fed set, not just
7
+ // the JSON. It lives on `PerpClient.pricedPoolTickers()` (over
8
+ // `oracle/validate.ts`'s `servableTickers`) `utils/` is the shared base and
9
+ // must not import `oracle/`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waterx/sdk",
3
- "version": "4.3.3",
3
+ "version": "5.0.0",
4
4
  "description": "WaterX SDK — perpetuals and prediction markets on Sui",
5
5
  "license": "MIT",
6
6
  "author": "WaterX",
@@ -1,12 +0,0 @@
1
- /**************************************************************
2
- * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
3
- **************************************************************/
4
- /**
5
- * A storable handler for Balances in general. Is used in the `Coin` module to
6
- * allow balance operations and can be used to implement custom coins with `Supply`
7
- * and `Balance`s.
8
- */
9
- import { MoveStruct } from '../../../utils/index.ts';
10
- export declare const Balance: MoveStruct<{
11
- value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
12
- }, "0x2::balance::Balance<phantom T>">;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- /**************************************************************
3
- * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
4
- **************************************************************/
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Balance = void 0;
7
- /**
8
- * A storable handler for Balances in general. Is used in the `Coin` module to
9
- * allow balance operations and can be used to implement custom coins with `Supply`
10
- * and `Balance`s.
11
- */
12
- const index_ts_1 = require("../../../utils/index.js");
13
- const bcs_1 = require("@mysten/sui/bcs");
14
- const $moduleName = '0x2::balance';
15
- exports.Balance = new index_ts_1.MoveStruct({ name: `${$moduleName}::Balance<phantom T>`, fields: {
16
- value: bcs_1.bcs.u64()
17
- } });
@@ -1,68 +0,0 @@
1
- /**************************************************************
2
- * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
3
- **************************************************************/
4
- import { MoveStruct, type RawTransactionArgument } from '../utils/index.ts';
5
- import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
6
- export declare const PythSponsorRule: MoveStruct<{
7
- dummy_field: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
8
- }, "@waterx/pyth-sponsor-rule::pyth_sponsor_rule::PythSponsorRule">;
9
- export declare const PythSponsor: MoveStruct<{
10
- id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
11
- balance: MoveStruct<{
12
- value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
13
- }, "0x2::balance::Balance<phantom T>">;
14
- }, "@waterx/pyth-sponsor-rule::pyth_sponsor_rule::PythSponsor">;
15
- export declare const Fund: MoveStruct<{
16
- balance: MoveStruct<{
17
- value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
18
- }, "0x2::balance::Balance<phantom T>">;
19
- }, "@waterx/pyth-sponsor-rule::pyth_sponsor_rule::Fund">;
20
- export interface RequestArguments {
21
- self: RawTransactionArgument<string>;
22
- }
23
- export interface RequestOptions {
24
- package?: string;
25
- arguments: RequestArguments | [
26
- self: RawTransactionArgument<string>
27
- ];
28
- }
29
- export declare function request(options: RequestOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
30
- export interface SplitArguments {
31
- fund: TransactionArgument;
32
- }
33
- export interface SplitOptions {
34
- package?: string;
35
- arguments: SplitArguments | [
36
- fund: TransactionArgument
37
- ];
38
- }
39
- export declare function split(options: SplitOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
40
- export interface ReimburseArguments {
41
- self: RawTransactionArgument<string>;
42
- fund: TransactionArgument;
43
- tradingReq: TransactionArgument;
44
- }
45
- export interface ReimburseOptions {
46
- package?: string;
47
- arguments: ReimburseArguments | [
48
- self: RawTransactionArgument<string>,
49
- fund: TransactionArgument,
50
- tradingReq: TransactionArgument
51
- ];
52
- typeArguments: [
53
- string
54
- ];
55
- }
56
- export declare function reimburse(options: ReimburseOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
57
- export interface SupplyArguments {
58
- self: RawTransactionArgument<string>;
59
- coin: RawTransactionArgument<string>;
60
- }
61
- export interface SupplyOptions {
62
- package?: string;
63
- arguments: SupplyArguments | [
64
- self: RawTransactionArgument<string>,
65
- coin: RawTransactionArgument<string>
66
- ];
67
- }
68
- export declare function supply(options: SupplyOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
@@ -1,113 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.Fund = exports.PythSponsor = exports.PythSponsorRule = void 0;
37
- exports.request = request;
38
- exports.split = split;
39
- exports.reimburse = reimburse;
40
- exports.supply = supply;
41
- /**************************************************************
42
- * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
43
- **************************************************************/
44
- const index_ts_1 = require("../utils/index.js");
45
- const bcs_1 = require("@mysten/sui/bcs");
46
- const balance = __importStar(require("./deps/sui/balance.js"));
47
- const $moduleName = '@waterx/pyth-sponsor-rule::pyth_sponsor_rule';
48
- exports.PythSponsorRule = new index_ts_1.MoveStruct({ name: `${$moduleName}::PythSponsorRule`, fields: {
49
- dummy_field: bcs_1.bcs.bool()
50
- } });
51
- exports.PythSponsor = new index_ts_1.MoveStruct({ name: `${$moduleName}::PythSponsor`, fields: {
52
- id: bcs_1.bcs.Address,
53
- balance: balance.Balance
54
- } });
55
- exports.Fund = new index_ts_1.MoveStruct({ name: `${$moduleName}::Fund`, fields: {
56
- balance: balance.Balance
57
- } });
58
- function request(options) {
59
- const packageAddress = options.package ?? '@waterx/pyth-sponsor-rule';
60
- const argumentsTypes = [
61
- null
62
- ];
63
- const parameterNames = ["self"];
64
- return (tx) => tx.moveCall({
65
- package: packageAddress,
66
- module: 'pyth_sponsor_rule',
67
- function: 'request',
68
- arguments: (0, index_ts_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
69
- });
70
- }
71
- function split(options) {
72
- const packageAddress = options.package ?? '@waterx/pyth-sponsor-rule';
73
- const argumentsTypes = [
74
- null
75
- ];
76
- const parameterNames = ["fund"];
77
- return (tx) => tx.moveCall({
78
- package: packageAddress,
79
- module: 'pyth_sponsor_rule',
80
- function: 'split',
81
- arguments: (0, index_ts_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
82
- });
83
- }
84
- function reimburse(options) {
85
- const packageAddress = options.package ?? '@waterx/pyth-sponsor-rule';
86
- const argumentsTypes = [
87
- null,
88
- null,
89
- null
90
- ];
91
- const parameterNames = ["self", "fund", "tradingReq"];
92
- return (tx) => tx.moveCall({
93
- package: packageAddress,
94
- module: 'pyth_sponsor_rule',
95
- function: 'reimburse',
96
- arguments: (0, index_ts_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
97
- typeArguments: options.typeArguments
98
- });
99
- }
100
- function supply(options) {
101
- const packageAddress = options.package ?? '@waterx/pyth-sponsor-rule';
102
- const argumentsTypes = [
103
- null,
104
- null
105
- ];
106
- const parameterNames = ["self", "coin"];
107
- return (tx) => tx.moveCall({
108
- package: packageAddress,
109
- module: 'pyth_sponsor_rule',
110
- function: 'supply',
111
- arguments: (0, index_ts_1.normalizeMoveArguments)(options.arguments, argumentsTypes, parameterNames),
112
- });
113
- }
@@ -1,36 +0,0 @@
1
- /**************************************************************
2
- * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
3
- **************************************************************/
4
- import { type BcsType } from '@mysten/sui/bcs';
5
- import { MoveStruct } from '../../../utils/index.ts';
6
- /** An entry in the map */
7
- export declare function Entry<K extends BcsType<any>, V extends BcsType<any>>(...typeParameters: [
8
- K,
9
- V
10
- ]): MoveStruct<{
11
- key: K;
12
- value: V;
13
- }, `0x2::vec_map::Entry<${K["name"]}, ${V["name"]}>`>;
14
- /**
15
- * A map data structure backed by a vector. The map is guaranteed not to contain
16
- * duplicate keys, but entries are _not_ sorted by key--entries are included in
17
- * insertion order. All operations are O(N) in the size of the map--the intention
18
- * of this data structure is only to provide the convenience of programming against
19
- * a map API. Large maps should use handwritten parent/child relationships instead.
20
- * Maps that need sorted iteration rather than insertion order iteration should
21
- * also be handwritten.
22
- */
23
- export declare function VecMap<K extends BcsType<any>, V extends BcsType<any>>(...typeParameters: [
24
- K,
25
- V
26
- ]): MoveStruct<{
27
- contents: BcsType<{
28
- key: K extends BcsType<infer U, any, string> ? U : never;
29
- value: V extends BcsType<infer U, any, string> ? U : never;
30
- }[], Iterable<{
31
- key: K extends BcsType<any, infer U_1, string> ? U_1 : never;
32
- value: V extends BcsType<any, infer U_1, string> ? U_1 : never;
33
- }> & {
34
- length: number;
35
- }, string>;
36
- }, `0x2::vec_map::VecMap<${K["name"]}, ${V["name"]}>`>;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Entry = Entry;
4
- exports.VecMap = VecMap;
5
- /**************************************************************
6
- * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
7
- **************************************************************/
8
- const bcs_1 = require("@mysten/sui/bcs");
9
- const index_ts_1 = require("../../../utils/index.js");
10
- const $moduleName = '0x2::vec_map';
11
- /** An entry in the map */
12
- function Entry(...typeParameters) {
13
- return new index_ts_1.MoveStruct({ name: `${$moduleName}::Entry<${typeParameters[0].name}, ${typeParameters[1].name}>`, fields: {
14
- key: typeParameters[0],
15
- value: typeParameters[1]
16
- } });
17
- }
18
- /**
19
- * A map data structure backed by a vector. The map is guaranteed not to contain
20
- * duplicate keys, but entries are _not_ sorted by key--entries are included in
21
- * insertion order. All operations are O(N) in the size of the map--the intention
22
- * of this data structure is only to provide the convenience of programming against
23
- * a map API. Large maps should use handwritten parent/child relationships instead.
24
- * Maps that need sorted iteration rather than insertion order iteration should
25
- * also be handwritten.
26
- */
27
- function VecMap(...typeParameters) {
28
- return new index_ts_1.MoveStruct({ name: `${$moduleName}::VecMap<${typeParameters[0].name}, ${typeParameters[1].name}>`, fields: {
29
- contents: bcs_1.bcs.vector(Entry(typeParameters[0], typeParameters[1]))
30
- } });
31
- }