@waterx/sdk 2.1.0 → 2.4.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 (231) hide show
  1. package/README.md +75 -169
  2. package/dist/src/client.d.ts +40 -2
  3. package/dist/src/client.js +55 -6
  4. package/dist/src/config.d.ts +66 -3
  5. package/dist/src/config.js +10 -4
  6. package/dist/src/constants.d.ts +6 -0
  7. package/dist/src/constants.js +6 -0
  8. package/dist/src/core/waterx-account.d.ts +31 -0
  9. package/dist/src/core/waterx-account.js +26 -0
  10. package/dist/src/fetch.d.ts +110 -0
  11. package/dist/src/fetch.js +149 -4
  12. package/dist/src/generated/bucket_v2_framework/account.d.ts +5 -5
  13. package/dist/src/generated/bucket_v2_framework/double.d.ts +77 -77
  14. package/dist/src/generated/bucket_v2_framework/float.d.ts +73 -73
  15. package/dist/src/generated/bucket_v2_framework/liability.d.ts +33 -33
  16. package/dist/src/generated/bucket_v2_framework/linked_table.d.ts +5 -5
  17. package/dist/src/generated/bucket_v2_framework/linked_table.js +2 -2
  18. package/dist/src/generated/bucket_v2_framework/sheet.d.ts +57 -57
  19. package/dist/src/generated/bucket_v2_framework/sheet.js +5 -11
  20. package/dist/src/generated/native_custody/custody_vault.d.ts +46 -32
  21. package/dist/src/generated/native_custody/custody_vault.js +19 -10
  22. package/dist/src/generated/native_custody/deps/bucket_v2_framework/sheet.js +1 -3
  23. package/dist/src/generated/native_custody/events.js +1 -2
  24. package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +7 -7
  25. package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +1 -2
  26. package/dist/src/generated/utils/index.d.ts +7 -7
  27. package/dist/src/generated/utils/index.js +9 -6
  28. package/dist/src/generated/waterx_account/account.d.ts +124 -71
  29. package/dist/src/generated/waterx_account/account.js +64 -29
  30. package/dist/src/generated/waterx_account/deps/bucket_v2_framework/sheet.js +1 -3
  31. package/dist/src/generated/waterx_account/direct_rule.d.ts +5 -5
  32. package/dist/src/generated/waterx_account/events.d.ts +10 -0
  33. package/dist/src/generated/waterx_account/events.js +31 -50
  34. package/dist/src/generated/waterx_constant_rule/constant_rule.d.ts +68 -0
  35. package/dist/src/generated/waterx_constant_rule/constant_rule.js +59 -0
  36. package/dist/src/generated/waterx_constant_rule/deps/bucket_v2_framework/float.d.ts +8 -0
  37. package/dist/src/generated/waterx_constant_rule/deps/bucket_v2_framework/float.js +10 -0
  38. package/dist/src/generated/waterx_constant_rule/deps/sui/vec_map.d.ts +36 -0
  39. package/dist/src/generated/waterx_constant_rule/deps/sui/vec_map.js +27 -0
  40. package/dist/src/generated/waterx_credit/credit_registry.d.ts +9 -9
  41. package/dist/src/generated/waterx_credit/credit_registry.js +1 -2
  42. package/dist/src/generated/waterx_credit/limited_supply.d.ts +17 -17
  43. package/dist/src/generated/waterx_oracle/aggregator.js +1 -2
  44. package/dist/src/generated/waterx_oracle/collector.d.ts +17 -17
  45. package/dist/src/generated/waterx_oracle/collector.js +1 -1
  46. package/dist/src/generated/waterx_oracle/oracle.d.ts +5 -5
  47. package/dist/src/generated/waterx_perp/account_data.d.ts +5 -5
  48. package/dist/src/generated/waterx_perp/account_data.js +1 -2
  49. package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/sheet.js +1 -3
  50. package/dist/src/generated/waterx_perp/events.d.ts +181 -181
  51. package/dist/src/generated/waterx_perp/events.js +87 -173
  52. package/dist/src/generated/waterx_perp/global_config.d.ts +3 -3
  53. package/dist/src/generated/waterx_perp/global_config.js +6 -12
  54. package/dist/src/generated/waterx_perp/keyed_big_vector.d.ts +9 -9
  55. package/dist/src/generated/waterx_perp/keyed_big_vector.js +1 -2
  56. package/dist/src/generated/waterx_perp/lp_pool.d.ts +115 -115
  57. package/dist/src/generated/waterx_perp/lp_pool.js +11 -22
  58. package/dist/src/generated/waterx_perp/market_config.d.ts +61 -43
  59. package/dist/src/generated/waterx_perp/market_config.js +29 -22
  60. package/dist/src/generated/waterx_perp/math.d.ts +7 -7
  61. package/dist/src/generated/waterx_perp/order_book.d.ts +47 -47
  62. package/dist/src/generated/waterx_perp/position.d.ts +99 -99
  63. package/dist/src/generated/waterx_perp/position.js +6 -12
  64. package/dist/src/generated/waterx_perp/request.d.ts +67 -67
  65. package/dist/src/generated/waterx_perp/request.js +2 -3
  66. package/dist/src/generated/waterx_perp/response.d.ts +35 -35
  67. package/dist/src/generated/waterx_perp/response.js +1 -2
  68. package/dist/src/generated/waterx_perp/trading.d.ts +303 -179
  69. package/dist/src/generated/waterx_perp/trading.js +99 -14
  70. package/dist/src/generated/waterx_perp_view/view.js +5 -10
  71. package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +5 -5
  72. package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +1 -2
  73. package/dist/src/generated/waterx_referral/referral_table.d.ts +5 -5
  74. package/dist/src/generated/waterx_referral/referral_table.js +1 -2
  75. package/dist/src/generated/waterx_staking/waterx_staking.d.ts +19 -19
  76. package/dist/src/generated/waterx_staking/waterx_staking.js +10 -20
  77. package/dist/src/generated/waterx_supra_rule/deps/sui/vec_map.d.ts +36 -0
  78. package/dist/src/generated/waterx_supra_rule/deps/sui/vec_map.js +27 -0
  79. package/dist/src/generated/waterx_supra_rule/supra_rule.d.ts +158 -0
  80. package/dist/src/generated/waterx_supra_rule/supra_rule.js +148 -0
  81. package/dist/src/generated/withdrawal_queue/deps/bucket_v2_framework/float.d.ts +8 -0
  82. package/dist/src/generated/withdrawal_queue/deps/bucket_v2_framework/float.js +10 -0
  83. package/dist/src/generated/withdrawal_queue/deps/sui/vec_map.d.ts +36 -0
  84. package/dist/src/generated/withdrawal_queue/deps/sui/vec_map.js +27 -0
  85. package/dist/src/generated/withdrawal_queue/withdrawal_queue.d.ts +444 -4
  86. package/dist/src/generated/withdrawal_queue/withdrawal_queue.js +417 -4
  87. package/dist/src/generated/wormhole_bridge/wormhole_bridge.d.ts +214 -74
  88. package/dist/src/generated/wormhole_bridge/wormhole_bridge.js +158 -29
  89. package/dist/src/index.d.ts +4 -3
  90. package/dist/src/index.js +3 -2
  91. package/dist/src/prediction/account.d.ts +96 -0
  92. package/dist/src/prediction/account.js +230 -0
  93. package/dist/src/prediction/admin.d.ts +47 -0
  94. package/dist/src/prediction/admin.js +105 -0
  95. package/dist/src/prediction/bcs.d.ts +22 -0
  96. package/dist/src/prediction/bcs.js +240 -0
  97. package/dist/src/prediction/client.d.ts +75 -0
  98. package/dist/src/prediction/client.js +164 -0
  99. package/dist/src/prediction/config.d.ts +60 -0
  100. package/dist/src/prediction/config.js +75 -0
  101. package/dist/src/prediction/constants.d.ts +44 -0
  102. package/dist/src/prediction/constants.js +46 -0
  103. package/dist/src/prediction/fetch.d.ts +82 -0
  104. package/dist/src/prediction/fetch.js +270 -0
  105. package/dist/src/prediction/generated/bucket_v2_framework/account.d.ts +100 -0
  106. package/dist/src/prediction/generated/bucket_v2_framework/account.js +129 -0
  107. package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.d.ts +6 -0
  108. package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.js +19 -0
  109. package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.d.ts +10 -0
  110. package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.js +14 -0
  111. package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.d.ts +36 -0
  112. package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.js +27 -0
  113. package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_set.d.ts +16 -0
  114. package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_set.js +19 -0
  115. package/dist/src/prediction/generated/bucket_v2_framework/double.d.ts +382 -0
  116. package/dist/src/prediction/generated/bucket_v2_framework/double.js +466 -0
  117. package/dist/src/prediction/generated/bucket_v2_framework/float.d.ts +362 -0
  118. package/dist/src/prediction/generated/bucket_v2_framework/float.js +440 -0
  119. package/dist/src/prediction/generated/bucket_v2_framework/liability.d.ts +193 -0
  120. package/dist/src/prediction/generated/bucket_v2_framework/liability.js +205 -0
  121. package/dist/src/prediction/generated/bucket_v2_framework/linked_table.d.ts +384 -0
  122. package/dist/src/prediction/generated/bucket_v2_framework/linked_table.js +382 -0
  123. package/dist/src/prediction/generated/bucket_v2_framework/sheet.d.ts +344 -0
  124. package/dist/src/prediction/generated/bucket_v2_framework/sheet.js +338 -0
  125. package/dist/src/prediction/generated/utils/index.d.ts +30 -0
  126. package/dist/src/prediction/generated/utils/index.js +160 -0
  127. package/dist/src/prediction/generated/waterx_account/account.d.ts +1589 -0
  128. package/dist/src/prediction/generated/waterx_account/account.js +1758 -0
  129. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.d.ts +7 -0
  130. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.js +13 -0
  131. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.d.ts +7 -0
  132. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.js +16 -0
  133. package/dist/src/prediction/generated/waterx_account/deps/std/type_name.d.ts +6 -0
  134. package/dist/src/prediction/generated/waterx_account/deps/std/type_name.js +19 -0
  135. package/dist/src/prediction/generated/waterx_account/deps/sui/balance.d.ts +10 -0
  136. package/dist/src/prediction/generated/waterx_account/deps/sui/balance.js +14 -0
  137. package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.d.ts +12 -0
  138. package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.js +19 -0
  139. package/dist/src/prediction/generated/waterx_account/deps/sui/table.d.ts +24 -0
  140. package/dist/src/prediction/generated/waterx_account/deps/sui/table.js +31 -0
  141. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.d.ts +36 -0
  142. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.js +27 -0
  143. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.d.ts +16 -0
  144. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.js +19 -0
  145. package/dist/src/prediction/generated/waterx_account/direct_rule.d.ts +75 -0
  146. package/dist/src/prediction/generated/waterx_account/direct_rule.js +78 -0
  147. package/dist/src/prediction/generated/waterx_account/events.d.ts +33 -0
  148. package/dist/src/prediction/generated/waterx_account/events.js +137 -0
  149. package/dist/src/prediction/generated/waterx_account/version.d.ts +10 -0
  150. package/dist/src/prediction/generated/waterx_account/version.js +8 -0
  151. package/dist/src/prediction/generated/waterx_prediction/account_data.d.ts +327 -0
  152. package/dist/src/prediction/generated/waterx_prediction/account_data.js +405 -0
  153. package/dist/src/prediction/generated/waterx_prediction/admin.d.ts +5 -0
  154. package/dist/src/prediction/generated/waterx_prediction/admin.js +9 -0
  155. package/dist/src/prediction/generated/waterx_prediction/bet_sharing.d.ts +60 -0
  156. package/dist/src/prediction/generated/waterx_prediction/bet_sharing.js +83 -0
  157. package/dist/src/prediction/generated/waterx_prediction/deps/bucket_v2_framework/linked_table.d.ts +8 -0
  158. package/dist/src/prediction/generated/waterx_prediction/deps/bucket_v2_framework/linked_table.js +18 -0
  159. package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.d.ts +10 -0
  160. package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.js +14 -0
  161. package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.d.ts +24 -0
  162. package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.js +31 -0
  163. package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.d.ts +16 -0
  164. package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.js +19 -0
  165. package/dist/src/prediction/generated/waterx_prediction/events.d.ts +22 -0
  166. package/dist/src/prediction/generated/waterx_prediction/events.js +179 -0
  167. package/dist/src/prediction/generated/waterx_prediction/global_config.d.ts +116 -0
  168. package/dist/src/prediction/generated/waterx_prediction/global_config.js +141 -0
  169. package/dist/src/prediction/generated/waterx_prediction/order.d.ts +200 -0
  170. package/dist/src/prediction/generated/waterx_prediction/order.js +284 -0
  171. package/dist/src/prediction/generated/waterx_prediction/outcome.d.ts +58 -0
  172. package/dist/src/prediction/generated/waterx_prediction/outcome.js +73 -0
  173. package/dist/src/prediction/generated/waterx_prediction/position.d.ts +160 -0
  174. package/dist/src/prediction/generated/waterx_prediction/position.js +214 -0
  175. package/dist/src/prediction/generated/waterx_prediction/version.d.ts +10 -0
  176. package/dist/src/prediction/generated/waterx_prediction/version.js +8 -0
  177. package/dist/src/prediction/generated/waterx_prediction/view.d.ts +353 -0
  178. package/dist/src/prediction/generated/waterx_prediction/view.js +432 -0
  179. package/dist/src/prediction/generated/waterx_prediction/waterx_prediction.d.ts +1698 -0
  180. package/dist/src/prediction/generated/waterx_prediction/waterx_prediction.js +1733 -0
  181. package/dist/src/prediction/gift-link.d.ts +6 -0
  182. package/dist/src/prediction/gift-link.js +5 -0
  183. package/dist/src/prediction/gift.d.ts +223 -0
  184. package/dist/src/prediction/gift.js +451 -0
  185. package/dist/src/prediction/index.d.ts +29 -0
  186. package/dist/src/prediction/index.js +21 -0
  187. package/dist/src/prediction/prediction.d.ts +104 -0
  188. package/dist/src/prediction/prediction.js +317 -0
  189. package/dist/src/prediction/tx-builders.d.ts +44 -0
  190. package/dist/src/prediction/tx-builders.js +52 -0
  191. package/dist/src/prediction/types.d.ts +93 -0
  192. package/dist/src/prediction/types.js +1 -0
  193. package/dist/src/prediction/user/account.d.ts +2 -0
  194. package/dist/src/prediction/user/account.js +1 -0
  195. package/dist/src/prediction/user/admin.d.ts +6 -0
  196. package/dist/src/prediction/user/admin.js +3 -0
  197. package/dist/src/prediction/user/gift.d.ts +2 -0
  198. package/dist/src/prediction/user/gift.js +1 -0
  199. package/dist/src/prediction/user/index.d.ts +5 -0
  200. package/dist/src/prediction/user/index.js +3 -0
  201. package/dist/src/prediction/user/keeper.d.ts +2 -0
  202. package/dist/src/prediction/user/keeper.js +1 -0
  203. package/dist/src/prediction/user/order.d.ts +2 -0
  204. package/dist/src/prediction/user/order.js +1 -0
  205. package/dist/src/prediction/user/position.d.ts +2 -0
  206. package/dist/src/prediction/user/position.js +1 -0
  207. package/dist/src/prediction/utils/bcs.d.ts +1 -0
  208. package/dist/src/prediction/utils/bcs.js +1 -0
  209. package/dist/src/prediction/utils/index.d.ts +1 -0
  210. package/dist/src/prediction/utils/index.js +1 -0
  211. package/dist/src/prediction/utils.d.ts +30 -0
  212. package/dist/src/prediction/utils.js +177 -0
  213. package/dist/src/sdk.d.ts +18 -0
  214. package/dist/src/sdk.js +17 -0
  215. package/dist/src/tx-builders.d.ts +54 -0
  216. package/dist/src/tx-builders.js +141 -0
  217. package/dist/src/unified-client.d.ts +407 -0
  218. package/dist/src/unified-client.js +123 -0
  219. package/dist/src/user/account.d.ts +27 -0
  220. package/dist/src/user/account.js +34 -8
  221. package/dist/src/user/credit.d.ts +8 -14
  222. package/dist/src/user/credit.js +9 -23
  223. package/dist/src/user/custody.d.ts +4 -18
  224. package/dist/src/user/custody.js +14 -25
  225. package/dist/src/utils/consolidate-balance.d.ts +37 -0
  226. package/dist/src/utils/consolidate-balance.js +89 -0
  227. package/dist/src/utils/math.d.ts +86 -0
  228. package/dist/src/utils/math.js +100 -0
  229. package/dist/src/utils/pyth.d.ts +42 -7
  230. package/dist/src/utils/pyth.js +107 -31
  231. package/package.json +129 -34
@@ -0,0 +1,407 @@
1
+ /**
2
+ * Unified WaterX SDK client.
3
+ *
4
+ * Wraps the two product-line clients (`WaterXClient` for perp, `PredictClient`
5
+ * for prediction) behind a single object with namespaced modules, so the
6
+ * colliding builder names (`placeOrder`, `createAccount`, `deposit`, …) can be
7
+ * called unambiguously:
8
+ *
9
+ * const client = await Client.create({ network: "TESTNET" });
10
+ * client.perp.openPosition(tx, params); // -> perp builder
11
+ * client.predict.placeOrder(tx, params); // -> prediction builder
12
+ *
13
+ * The modules are thin: each method forwards to the existing free-function
14
+ * builder with the line's client pre-bound as the first argument. Builders are
15
+ * build-only (they return / mutate a `Transaction`); signing & execution stay
16
+ * with the caller (`client.perpClient` / `client.predictClient`, or a wallet),
17
+ * so frontend wallet flows and multi-step Pyth injection keep working.
18
+ */
19
+ import { Transaction } from "@mysten/sui/transactions";
20
+ import { WaterXClient, type CreateClientOptions as PerpCreateOptions } from "./client.ts";
21
+ import type { Network } from "./constants.ts";
22
+ import * as perpFetch from "./fetch.ts";
23
+ import * as predAccount from "./prediction/account.ts";
24
+ import * as predAdmin from "./prediction/admin.ts";
25
+ import { PredictClient, type CreateClientOptions as PredictCreateOptions } from "./prediction/client.ts";
26
+ import * as predFetch from "./prediction/fetch.ts";
27
+ import * as predGift from "./prediction/gift.ts";
28
+ import * as predOps from "./prediction/prediction.ts";
29
+ import { type BuildBatchClaimTxParams, type BuildPlaceOrderTxParams } from "./prediction/tx-builders.ts";
30
+ import * as perpTx from "./tx-builders.ts";
31
+ import * as perpUser from "./user/index.ts";
32
+ /**
33
+ * Exports from the spread builder/view modules that are NOT client-first — their
34
+ * first argument is not the line client, so they must not become bound facade
35
+ * methods (binding would pass the client where a value is expected). This is the
36
+ * single source of truth shared by the runtime (skip) and the type (`Omit`).
37
+ * Keep in sync by auditing `export function` first-params across the spread modules.
38
+ */
39
+ declare const NON_CLIENT_FIRST: readonly ["extractReturnBytes", "base64UrlNoPadEncode", "base64UrlNoPadDecode", "generateGiftSeed", "encodeGiftUrl", "parseGiftUrl", "deriveGiftKeypair", "buildGiftClaimMessage", "signGiftClaim"];
40
+ type NonClientFirstKey = (typeof NON_CLIENT_FIRST)[number];
41
+ /**
42
+ * Map a namespace of `(client, ...args) => R` free functions to the same surface
43
+ * with the client pre-bound: `(...args) => R`. Non-client-first helpers (see
44
+ * `NON_CLIENT_FIRST`) are dropped, so the static type and the runtime agree.
45
+ */
46
+ type ClientBound<NS, C> = {
47
+ [K in keyof Omit<NS, NonClientFirstKey>]: NS[K] extends (client: C, ...args: infer A) => infer R ? (...args: A) => R : NS[K];
48
+ };
49
+ declare const perpOps: {
50
+ getAccountData(client: WaterXClient, accountId: string): Promise<perpFetch.AccountDataView | undefined>;
51
+ getMarketData(client: WaterXClient, args: {
52
+ ticker: string;
53
+ lpType?: string;
54
+ }): Promise<perpFetch.MarketDataView>;
55
+ getPoolData(client: WaterXClient, args?: {
56
+ lpType?: string;
57
+ }): Promise<perpFetch.PoolDataView>;
58
+ getTokenPoolData(client: WaterXClient, args: {
59
+ tokenIndex: bigint | number;
60
+ lpType?: string;
61
+ }): Promise<perpFetch.TokenPoolDataView>;
62
+ getGlobalConfigData(client: WaterXClient): Promise<perpFetch.GlobalConfigDataView>;
63
+ positionExists(client: WaterXClient, args: {
64
+ ticker: string;
65
+ positionId: bigint | number;
66
+ lpType?: string;
67
+ }): Promise<boolean>;
68
+ getPosition(client: WaterXClient, args: {
69
+ ticker: string;
70
+ positionId: bigint | number;
71
+ basePriceUsd: bigint | number;
72
+ collateralPriceUsd: bigint | number;
73
+ lpType?: string;
74
+ }): Promise<perpFetch.PositionDataView>;
75
+ getOrder(client: WaterXClient, args: {
76
+ ticker: string;
77
+ orderId: bigint | number;
78
+ orderTypeTag: number;
79
+ triggerPrice: bigint | number;
80
+ basePriceUsd: bigint | number;
81
+ lpType?: string;
82
+ }): Promise<perpFetch.OrderDataView>;
83
+ getMarketOrders(client: WaterXClient, args: {
84
+ ticker: string;
85
+ basePriceUsd?: bigint | number;
86
+ lpType?: string;
87
+ } & perpFetch.PageOpts): Promise<{
88
+ orders: perpFetch.OrderDataView[];
89
+ nextCursor?: bigint;
90
+ }>;
91
+ getMarketPositions(client: WaterXClient, args: {
92
+ ticker: string;
93
+ basePriceUsd: bigint | number;
94
+ collateralPriceUsd?: bigint | number;
95
+ lpType?: string;
96
+ } & perpFetch.PageOpts): Promise<{
97
+ positions: perpFetch.PositionDataView[];
98
+ nextCursor?: bigint;
99
+ }>;
100
+ getAccountPositions(client: WaterXClient, args: {
101
+ ticker: string;
102
+ accountObjectAddress: string;
103
+ basePriceUsd: bigint | number;
104
+ collateralPriceUsd?: bigint | number;
105
+ lpType?: string;
106
+ }): Promise<perpFetch.PositionDataView[]>;
107
+ getAccountOrders(client: WaterXClient, args: {
108
+ ticker: string;
109
+ accountObjectAddress: string;
110
+ basePriceUsd?: bigint | number;
111
+ lpType?: string;
112
+ }): Promise<perpFetch.OrderDataView[]>;
113
+ getRedeemRequests(client: WaterXClient, args?: {
114
+ lpType?: string;
115
+ } & perpFetch.PageOpts): Promise<{
116
+ requests: perpFetch.RedeemRequestDataView[];
117
+ nextCursor?: bigint;
118
+ }>;
119
+ getRefererFor(client: WaterXClient, referee: string): Promise<string | undefined>;
120
+ isValidReferralCode(client: WaterXClient, code: string): Promise<boolean>;
121
+ referralCodeExists(client: WaterXClient, code: string): Promise<boolean>;
122
+ getAccountsByOwner(client: WaterXClient, owner: string): Promise<string[]>;
123
+ getAccountBalance(client: WaterXClient, accountId: string, coinType?: string): Promise<bigint>;
124
+ getSpendableCreditBalance(client: WaterXClient, accountId: string): Promise<perpFetch.SpendableCreditBalance>;
125
+ getCustodyVaultData(client: WaterXClient): Promise<perpFetch.CustodyVaultData>;
126
+ getCustodyAssetData(client: WaterXClient, assetType: string): Promise<perpFetch.CustodyAssetData>;
127
+ getBridgeLimits(client: WaterXClient, args?: perpFetch.BridgeLimitsArgs): Promise<perpFetch.BridgeLimitsView>;
128
+ getBridgeFee(client: WaterXClient, args: {
129
+ evmDestinationChain: number;
130
+ amount: bigint | number;
131
+ creditType?: string;
132
+ }): Promise<perpFetch.BridgeFeeView>;
133
+ appendConsolidateToUsd(client: WaterXClient, tx: Transaction, accountId: string): Promise<number>;
134
+ appendConsolidateAddressCredit(client: WaterXClient, tx: Transaction, accountId: string): Promise<number>;
135
+ appendConsolidateForSpend(client: WaterXClient, tx: Transaction, accountId: string): Promise<number>;
136
+ buildConsolidateToUsdTx(client: WaterXClient, accountId: string, tx?: Transaction): Promise<Transaction>;
137
+ buildClosePositionTx(client: WaterXClient, params: perpTx.BuildClosePositionParams): Promise<Transaction>;
138
+ buildIncreasePositionTx(client: WaterXClient, params: perpTx.BuildIncreasePositionParams): Promise<Transaction>;
139
+ buildDecreasePositionTx(client: WaterXClient, params: perpTx.BuildDecreasePositionParams): Promise<Transaction>;
140
+ buildDepositCollateralTx(client: WaterXClient, params: perpTx.BuildDepositCollateralParams): Promise<Transaction>;
141
+ buildWithdrawCollateralTx(client: WaterXClient, params: perpTx.BuildWithdrawCollateralParams): Promise<Transaction>;
142
+ buildPlaceOrderTx(client: WaterXClient, params: perpTx.BuildPlaceOrderParams): Promise<Transaction>;
143
+ buildCancelOrderTx(client: WaterXClient, params: perpTx.BuildCancelOrderParams): Promise<Transaction>;
144
+ buildUpdateOrderTx(client: WaterXClient, params: perpTx.BuildUpdateOrderParams): Promise<Transaction>;
145
+ buildCancelPreOrderTx(client: WaterXClient, params: perpTx.BuildCancelPreOrderParams): Promise<Transaction>;
146
+ buildAddPreOrderTx(client: WaterXClient, params: perpTx.BuildAddPreOrderParams): Promise<Transaction>;
147
+ buildMintWlpTx(client: WaterXClient, params: perpTx.BuildMintWlpParams): Promise<Transaction>;
148
+ buildMintAndStakeWlpTx(client: WaterXClient, params: perpTx.BuildMintAndStakeWlpParams): Promise<Transaction>;
149
+ buildUnstakeAndRequestRedeemWlpTx(client: WaterXClient, params: perpTx.BuildUnstakeAndRequestRedeemWlpParams): Promise<Transaction>;
150
+ buildCancelRedeemAndStakeWlpTx(client: WaterXClient, params: perpTx.BuildCancelRedeemAndStakeWlpParams): Transaction;
151
+ buildClaimRewardsToAccountTx(client: WaterXClient, params: perpTx.BuildClaimRewardsToAccountParams): Transaction;
152
+ buildRedeemVaaTx(client: WaterXClient, params: perpTx.BuildRedeemVaaParams): Transaction;
153
+ buildRequestCreditWithdrawTx(client: WaterXClient, params: perpTx.BuildRequestCreditWithdrawParams): Transaction;
154
+ buildExecuteWithdrawalTx(client: WaterXClient, params: perpTx.BuildExecuteWithdrawalParams): Transaction;
155
+ openPythSponsorFund: typeof perpTx.openPythSponsorFund;
156
+ PythCache: typeof perpTx.PythCache;
157
+ refreshOraclePrices: typeof perpTx.refreshOraclePrices;
158
+ reimbursePythSponsor: typeof perpTx.reimbursePythSponsor;
159
+ updatePythPrices: typeof perpTx.updatePythPrices;
160
+ createAccount(client: WaterXClient, tx: Transaction, params: perpUser.CreateAccountParams): void;
161
+ setAlias(client: WaterXClient, tx: Transaction, params: perpUser.SetAliasParams): void;
162
+ addDelegate(client: WaterXClient, tx: Transaction, params: perpUser.AddDelegateParams): void;
163
+ removeDelegate(client: WaterXClient, tx: Transaction, params: perpUser.RemoveDelegateParams): void;
164
+ setDelegateProtocolPermission(client: WaterXClient, tx: Transaction, params: perpUser.SetDelegateProtocolPermissionParams): void;
165
+ requestDeposit(client: WaterXClient, tx: Transaction, params: perpUser.RequestDepositParams): import("@mysten/sui/transactions").TransactionArgument;
166
+ requestDepositFromReceivings(client: WaterXClient, tx: Transaction, params: perpUser.RequestDepositFromReceivingsParams): import("@mysten/sui/transactions").TransactionArgument;
167
+ requestDepositFromFunds(client: WaterXClient, tx: Transaction, params: perpUser.RequestDepositFromFundsParams): import("@mysten/sui/transactions").TransactionArgument;
168
+ requestWithdraw(client: WaterXClient, tx: Transaction, params: perpUser.RequestWithdrawParams): import("@mysten/sui/transactions").TransactionArgument;
169
+ transferToAccount(client: WaterXClient, tx: Transaction, params: perpUser.TransferToAccountParams): void;
170
+ receive(client: WaterXClient, tx: Transaction, params: perpUser.ReceiveParams): import("@mysten/sui/transactions").TransactionArgument;
171
+ redeemVaa(client: WaterXClient, tx: Transaction, params: perpUser.RedeemVaaParams): import("@mysten/sui/transactions").TransactionArgument;
172
+ consumeCreditDeposit(client: WaterXClient, tx: Transaction, params: perpUser.ConsumeCreditDepositParams): void;
173
+ routeWormhole(client: WaterXClient, tx: Transaction, params: perpUser.RouteWormholeParams): import("@mysten/sui/transactions").TransactionArgument;
174
+ routeNative(client: WaterXClient, tx: Transaction, params: perpUser.RouteNativeParams): import("@mysten/sui/transactions").TransactionArgument;
175
+ requestCreditWithdraw(client: WaterXClient, tx: Transaction, params: perpUser.RequestCreditWithdrawParams): import("@mysten/sui/transactions").TransactionArgument;
176
+ enqueueWithdrawal(client: WaterXClient, tx: Transaction, params: perpUser.EnqueueWithdrawalParams): import("@mysten/sui/transactions").TransactionArgument;
177
+ executeWithdrawalWormhole(client: WaterXClient, tx: Transaction, params: perpUser.ExecuteWithdrawalWormholeParams): void;
178
+ executeWithdrawalNative(client: WaterXClient, tx: Transaction, params: perpUser.ExecuteWithdrawalNativeParams): void;
179
+ custodyMint(client: WaterXClient, tx: Transaction, params: perpUser.CustodyMintParams): import("@mysten/sui/transactions").TransactionArgument;
180
+ mintCredit(client: WaterXClient, tx: Transaction, params: perpUser.MintCreditParams): import("@mysten/sui/transactions").TransactionArgument;
181
+ mintCreditFromRequest(client: WaterXClient, tx: Transaction, params: perpUser.MintCreditFromRequestParams): import("@mysten/sui/transactions").TransactionArgument;
182
+ mintCreditToAccount(client: WaterXClient, tx: Transaction, params: perpUser.MintCreditParams): void;
183
+ buildPlaceOrderArgument(client: WaterXClient, tx: Transaction, p: perpUser.PlaceOrderArgumentParams): import("@mysten/sui/transactions").TransactionArgument;
184
+ placeOrderRequest(client: WaterXClient, tx: Transaction, params: perpUser.PlaceOrderRequestParams): import("@mysten/sui/transactions").TransactionArgument;
185
+ cancelOrderRequest(client: WaterXClient, tx: Transaction, params: perpUser.CancelOrderRequestParams): import("@mysten/sui/transactions").TransactionArgument;
186
+ updateOrderRequest(client: WaterXClient, tx: Transaction, params: perpUser.UpdateOrderRequestParams): import("@mysten/sui/transactions").TransactionArgument;
187
+ cancelPreOrderRequest(client: WaterXClient, tx: Transaction, params: perpUser.CancelPreOrderRequestParams): import("@mysten/sui/transactions").TransactionArgument;
188
+ addPreOrderRequest(client: WaterXClient, tx: Transaction, params: perpUser.AddPreOrderRequestParams): import("@mysten/sui/transactions").TransactionArgument;
189
+ setReferralCode(client: WaterXClient, tx: Transaction, params: perpUser.SetReferralCodeParams): void;
190
+ useReferralCode(client: WaterXClient, tx: Transaction, params: perpUser.UseReferralCodeParams): void;
191
+ stake(client: WaterXClient, tx: Transaction, params: perpUser.StakeParams): void;
192
+ unstake(client: WaterXClient, tx: Transaction, params: perpUser.UnstakeParams): void;
193
+ claimReward(client: WaterXClient, tx: Transaction, params: perpUser.ClaimRewardParams): void;
194
+ closePositionRequest(client: WaterXClient, tx: Transaction, params: perpUser.ClosePositionRequestParams): import("@mysten/sui/transactions").TransactionArgument;
195
+ increasePositionRequest(client: WaterXClient, tx: Transaction, params: perpUser.IncreasePositionRequestParams): import("@mysten/sui/transactions").TransactionArgument;
196
+ decreasePositionRequest(client: WaterXClient, tx: Transaction, params: perpUser.DecreasePositionRequestParams): import("@mysten/sui/transactions").TransactionArgument;
197
+ depositCollateralRequest(client: WaterXClient, tx: Transaction, params: perpUser.DepositCollateralRequestParams): import("@mysten/sui/transactions").TransactionArgument;
198
+ withdrawCollateralRequest(client: WaterXClient, tx: Transaction, params: perpUser.WithdrawCollateralRequestParams): import("@mysten/sui/transactions").TransactionArgument;
199
+ executeTrading(client: WaterXClient, tx: Transaction, params: perpUser.ExecuteTradingParams): void;
200
+ liquidate(client: WaterXClient, tx: Transaction, params: perpUser.LiquidateParams): void;
201
+ batchLiquidate(client: WaterXClient, tx: Transaction, params: perpUser.BatchLiquidateParams): void;
202
+ matchOrders(client: WaterXClient, tx: Transaction, params: perpUser.MatchOrdersParams): void;
203
+ updateFundingRate(client: WaterXClient, tx: Transaction, params: perpUser.UpdateFundingRateParams): void;
204
+ openPositionByKeeper(client: WaterXClient, tx: Transaction, params: perpUser.OpenPositionByKeeperParams): void;
205
+ closePositionByKeeper(client: WaterXClient, tx: Transaction, params: perpUser.ClosePositionByKeeperParams): void;
206
+ ORDER_TAG_WILDCARD_VALUE: 255;
207
+ mintWlp(client: WaterXClient, tx: Transaction, params: perpUser.MintWlpParams): import("@mysten/sui/transactions").TransactionArgument;
208
+ requestRedeemWlp(client: WaterXClient, tx: Transaction, params: perpUser.RequestRedeemWlpParams): void;
209
+ cancelRedeemWlp(client: WaterXClient, tx: Transaction, params: perpUser.CancelRedeemWlpParams): void;
210
+ settleRedeemWlp(client: WaterXClient, tx: Transaction, params: perpUser.SettleRedeemWlpParams): void;
211
+ updateTokenValue(client: WaterXClient, tx: Transaction, args: {
212
+ tokenType: string;
213
+ lpType?: string;
214
+ }): void;
215
+ };
216
+ declare const predictOps: {
217
+ base64UrlNoPadEncode(bytes: Uint8Array): string;
218
+ base64UrlNoPadDecode(value: string): Uint8Array;
219
+ generateGiftSeed(): Uint8Array;
220
+ encodeGiftUrl(seed: Uint8Array, parts?: predGift.GiftUrlParts): string;
221
+ parseGiftUrl(url: string): {
222
+ seed: Uint8Array;
223
+ };
224
+ deriveGiftKeypair(seed: Uint8Array): import("@mysten/sui/keypairs/ed25519").Ed25519Keypair;
225
+ buildGiftClaimMessage(giftId: string, sender: string): Uint8Array;
226
+ signGiftClaim(giftKeypair: import("@mysten/sui/keypairs/ed25519").Ed25519Keypair, giftId: string, sender: string): Promise<Uint8Array>;
227
+ deriveGiftAddress(client: PredictClient, pubkey: Uint8Array, params?: predGift.GiftBaseParams): string;
228
+ createGift(client: PredictClient, tx: Transaction, params: predGift.CreateGiftParams): Transaction;
229
+ claimShare(client: PredictClient, tx: Transaction, params: predGift.ClaimShareParams): Transaction;
230
+ deleteGift(client: PredictClient, tx: Transaction, params: predGift.DeleteGiftParams): Transaction;
231
+ getGift(client: PredictClient, params: predGift.GiftBaseParams & {
232
+ giftId: string;
233
+ }): Promise<predGift.GiftView>;
234
+ getCreatorGiftIds(client: PredictClient, params: predGift.GiftBaseParams & {
235
+ creator: string;
236
+ }): Promise<string[]>;
237
+ getCreatorGiftCount(client: PredictClient, params: predGift.GiftBaseParams & {
238
+ creator: string;
239
+ }): Promise<bigint>;
240
+ getGiftControllerAddress(client: PredictClient, params?: predGift.GiftBaseParams): Promise<string>;
241
+ getGiftConfigPaused(client: PredictClient, params?: predGift.GiftBaseParams): Promise<boolean>;
242
+ getGiftHasClaimed(client: PredictClient, params: predGift.GiftBaseParams & {
243
+ giftId: string;
244
+ addr: string;
245
+ }): Promise<boolean>;
246
+ buildCreateGiftFlow(client: PredictClient, tx: Transaction, params: Omit<predGift.CreateGiftParams, "pubkey">): predGift.BuildCreateGiftFlowResult;
247
+ buildClaimShareFlow(client: PredictClient, tx: Transaction, params: predGift.BuildClaimShareFlowParams): Promise<predGift.BuildClaimShareFlowResult>;
248
+ extractReturnBytes(result: any, commandIndex?: number, returnIndex?: number): Uint8Array;
249
+ getRegistry(client: PredictClient, params?: predFetch.ViewBaseParams): Promise<import("./prediction/types.ts").RegistryView>;
250
+ getOrder(client: PredictClient, params: predFetch.ViewBaseParams & {
251
+ orderId: bigint | number | string;
252
+ }): Promise<import("./prediction/types.ts").OrderView>;
253
+ getPosition(client: PredictClient, params: predFetch.ViewBaseParams & {
254
+ positionId: bigint | number | string;
255
+ }): Promise<import("./prediction/types.ts").PositionView>;
256
+ getMarketById(client: PredictClient, params: predFetch.ViewBaseParams & {
257
+ marketId: import("./prediction/types.ts").MarketIdInput;
258
+ }): Promise<import("./prediction/types.ts").MarketView>;
259
+ getMarketByKey(client: PredictClient, params: predFetch.ViewBaseParams & {
260
+ marketKey: bigint | number | string;
261
+ }): Promise<import("./prediction/types.ts").MarketView>;
262
+ getMarketExposure(client: PredictClient, params: predFetch.ViewBaseParams & {
263
+ marketId: import("./prediction/types.ts").MarketIdInput;
264
+ }): Promise<import("./prediction/types.ts").MarketExposure>;
265
+ getMarketExposureByKey(client: PredictClient, params: predFetch.ViewBaseParams & {
266
+ marketKey: bigint | number | string;
267
+ }): Promise<import("./prediction/types.ts").MarketExposure>;
268
+ getOrderCursor(client: PredictClient, params?: predFetch.ViewBaseParams): Promise<import("./prediction/types.ts").CursorView>;
269
+ getPositionCursor(client: PredictClient, params?: predFetch.ViewBaseParams): Promise<import("./prediction/types.ts").CursorView>;
270
+ getUnresolvedMarketCursor(client: PredictClient, params?: predFetch.ViewBaseParams): Promise<import("./prediction/types.ts").CursorView>;
271
+ getResolvedMarketCursor(client: PredictClient, params?: predFetch.ViewBaseParams): Promise<import("./prediction/types.ts").CursorView>;
272
+ getAccountIds(client: PredictClient, params: predFetch.GetAccountIdsParams): Promise<string[]>;
273
+ getAccountData(client: PredictClient, params: predFetch.ViewBaseParams & {
274
+ accountId: string;
275
+ }): Promise<import("./prediction/types.ts").AccountDataView>;
276
+ getAccountOrderIds(client: PredictClient, params: predFetch.ViewBaseParams & {
277
+ accountId: string;
278
+ marketKey: bigint | number | string;
279
+ }): Promise<bigint[]>;
280
+ getAccountPositionIds(client: PredictClient, params: predFetch.ViewBaseParams & {
281
+ accountId: string;
282
+ marketKey: bigint | number | string;
283
+ }): Promise<bigint[]>;
284
+ getAccountOrderIdsByMarketId(client: PredictClient, params: predFetch.ViewBaseParams & {
285
+ accountId: string;
286
+ marketId: import("./prediction/types.ts").MarketIdInput;
287
+ }): Promise<bigint[]>;
288
+ getAccountPositionIdsByMarketId(client: PredictClient, params: predFetch.ViewBaseParams & {
289
+ accountId: string;
290
+ marketId: import("./prediction/types.ts").MarketIdInput;
291
+ }): Promise<bigint[]>;
292
+ isKeeper(client: PredictClient, params: {
293
+ packageId?: string;
294
+ globalConfig?: string;
295
+ keeper: string;
296
+ }): Promise<boolean>;
297
+ getKeeperAddresses(client: PredictClient, params?: {
298
+ packageId?: string;
299
+ globalConfig?: string;
300
+ }): Promise<string[]>;
301
+ getAllowedVersions(client: PredictClient, params?: {
302
+ packageId?: string;
303
+ globalConfig?: string;
304
+ }): Promise<number[]>;
305
+ isPredictionProtocolAssetAllowed(client: PredictClient, params?: {
306
+ accountPackageId?: string;
307
+ accountRegistry?: string;
308
+ predictionPackageId?: string;
309
+ coinType?: string;
310
+ }): Promise<boolean>;
311
+ selectionArg(client: PredictClient, tx: Transaction, selection: import("./prediction/types.ts").Selection | import("@mysten/sui/transactions").TransactionArgument, packageId?: string): import("@mysten/sui/transactions").TransactionArgument;
312
+ outcomeArg(client: PredictClient, tx: Transaction, outcome: import("./prediction/types.ts").Outcome | import("@mysten/sui/transactions").TransactionArgument, packageId?: string): import("@mysten/sui/transactions").TransactionArgument;
313
+ placeOrder(client: PredictClient, tx: Transaction, params: predOps.PlaceOrderParams): Transaction;
314
+ selfCancelOrder(client: PredictClient, tx: Transaction, params: predOps.SelfCancelOrderParams): Transaction;
315
+ claim(client: PredictClient, tx: Transaction, params: predOps.ClaimParams): Transaction;
316
+ batchClaim(client: PredictClient, tx: Transaction, params: predOps.BatchClaimParams): Transaction;
317
+ requestClose(client: PredictClient, tx: Transaction, params: predOps.RequestCloseParams): Transaction;
318
+ selfCancelClose(client: PredictClient, tx: Transaction, params: predOps.SelfCancelCloseParams): Transaction;
319
+ fillOrder(client: PredictClient, tx: Transaction, params: predOps.FillOrderParams): Transaction;
320
+ cancelOrder(client: PredictClient, tx: Transaction, params: predOps.CancelOrderParams): Transaction;
321
+ confirmClose(client: PredictClient, tx: Transaction, params: predOps.ConfirmCloseParams): Transaction;
322
+ cancelClose(client: PredictClient, tx: Transaction, params: predOps.CancelCloseParams): Transaction;
323
+ forceClaim(client: PredictClient, tx: Transaction, params: predOps.ForceClaimParams): Transaction;
324
+ batchForceClaim(client: PredictClient, tx: Transaction, params: predOps.BatchForceClaimParams): Transaction;
325
+ buildBatchForceClaimTransactions(client: PredictClient, params: predOps.BuildBatchForceClaimTransactionsParams): Transaction[];
326
+ resolveMarket(client: PredictClient, tx: Transaction, params: predOps.ResolveMarketParams): Transaction;
327
+ adminPlaceOrderFor(client: PredictClient, tx: Transaction, params: predOps.AdminPlaceOrderForParams): Transaction;
328
+ createMarketRegistry(client: PredictClient, tx: Transaction, params: predAdmin.CreateMarketRegistryParams): Transaction;
329
+ depositSettlement(client: PredictClient, tx: Transaction, params: predAdmin.DepositSettlementParams): Transaction;
330
+ adminWithdraw(client: PredictClient, tx: Transaction, params: predAdmin.AdminWithdrawParams): Transaction;
331
+ setMinReserve(client: PredictClient, tx: Transaction, params: predAdmin.SetMinReserveParams): Transaction;
332
+ setOrderCancelCooldownMs(client: PredictClient, tx: Transaction, params: predAdmin.SetOrderCancelCooldownParams): Transaction;
333
+ pauseMarket(client: PredictClient, tx: Transaction, params: predAdmin.MarketPauseParams): Transaction;
334
+ unpauseMarket(client: PredictClient, tx: Transaction, params: predAdmin.MarketPauseParams): Transaction;
335
+ addKeeper(client: PredictClient, tx: Transaction, params: predAdmin.KeeperAdminParams): Transaction;
336
+ removeKeeper(client: PredictClient, tx: Transaction, params: predAdmin.KeeperAdminParams): Transaction;
337
+ resolveRegistryAccountId(client: PredictClient, accountObjectId: string, params?: predAccount.AccountBaseParams): Promise<string>;
338
+ createAccount(client: PredictClient, tx: Transaction, params: predAccount.CreateAccountParams): import("@mysten/sui/transactions").TransactionArgument;
339
+ transferCoinToAccount(client: PredictClient, tx: Transaction, params: predAccount.TransferCoinToAccountParams): Transaction;
340
+ requestDeposit(client: PredictClient, tx: Transaction, params: predAccount.RequestDepositParams): import("@mysten/sui/transactions").TransactionArgument;
341
+ consumeDepositDirect(client: PredictClient, tx: Transaction, params: predAccount.ConsumeDepositDirectParams): Transaction;
342
+ deposit(client: PredictClient, tx: Transaction, params: predAccount.RequestDepositParams): Transaction;
343
+ requestDepositFromReceivings(client: PredictClient, tx: Transaction, params: predAccount.RequestDepositFromReceivingsParams): import("@mysten/sui/transactions").TransactionArgument;
344
+ requestWithdraw(client: PredictClient, tx: Transaction, params: predAccount.RequestWithdrawParams): import("@mysten/sui/transactions").TransactionArgument;
345
+ consumeWithdrawDirect(client: PredictClient, tx: Transaction, params: predAccount.ConsumeWithdrawDirectParams): Transaction;
346
+ withdraw(client: PredictClient, tx: Transaction, params: predAccount.RequestWithdrawParams): Transaction;
347
+ addDelegate(client: PredictClient, tx: Transaction, params: predAccount.AddDelegateParams): Transaction;
348
+ removeDelegate(client: PredictClient, tx: Transaction, params: predAccount.RemoveDelegateParams): Transaction;
349
+ setDelegatePredictionPermission(client: PredictClient, tx: Transaction, params: predAccount.SetDelegatePredictionPermissionParams): Transaction;
350
+ whitelistPredictionProtocol(client: PredictClient, tx: Transaction, params: predAccount.WhitelistPredictionProtocolParams): Transaction;
351
+ allowPredictionProtocolAsset(client: PredictClient, tx: Transaction, params: predAccount.PredictionProtocolAssetParams): Transaction;
352
+ disallowPredictionProtocolAsset(client: PredictClient, tx: Transaction, params: predAccount.PredictionProtocolAssetParams): Transaction;
353
+ };
354
+ /** Perp namespace exposed as `client.perp` — builder/view methods, client pre-bound. */
355
+ export type PerpModule = ClientBound<typeof perpOps, WaterXClient>;
356
+ /** Prediction namespace exposed as `client.predict` — builder/view methods, client pre-bound. */
357
+ export type PredictModule = ClientBound<typeof predictOps, PredictClient>;
358
+ /** Per-line network/config override. Falls back to the shared top-level options. */
359
+ type PerpLineOptions = Partial<PerpCreateOptions> & {
360
+ network?: Network;
361
+ };
362
+ type PredictLineOptions = Partial<PredictCreateOptions> & {
363
+ network?: Network;
364
+ };
365
+ export interface ClientCreateOptions {
366
+ /** Default network for both lines (per-line `network` overrides). Default: `"TESTNET"`. */
367
+ network?: Network;
368
+ /** Default gRPC URL for both lines. */
369
+ grpcUrl?: string;
370
+ /** Default `waterx-config` JSON URL for both lines. */
371
+ configUrl?: string;
372
+ /** Memoize the fetched config JSON. */
373
+ cache?: boolean;
374
+ /** Perp-line overrides (network, grpcUrl, configUrl, cache, …). */
375
+ perp?: PerpLineOptions;
376
+ /** Prediction-line overrides (network, grpcUrl, configUrl, cache, settlement, …). */
377
+ predict?: PredictLineOptions;
378
+ }
379
+ export declare class Client {
380
+ /** Underlying perp client — use for signing/executing perp transactions. */
381
+ readonly perpClient: WaterXClient;
382
+ /** Underlying prediction client — use for signing/executing prediction transactions. */
383
+ readonly predictClient: PredictClient;
384
+ /** Perp builders & views (`client.perp.openPosition(tx, params)`). */
385
+ readonly perp: PerpModule;
386
+ /** Prediction builders & views (`client.predict.placeOrder(tx, params)`). */
387
+ readonly predict: PredictModule;
388
+ /**
389
+ * Async prediction builder: optional consolidate + `placeOrder`.
390
+ * Uses `perpClient` for the sweep and `predictClient` for the bet leg.
391
+ */
392
+ buildPredictPlaceOrderTx(params: BuildPlaceOrderTxParams): Promise<Transaction>;
393
+ /**
394
+ * Async prediction builder: optional consolidate + `batchClaim`.
395
+ */
396
+ buildPredictBatchClaimTx(params: BuildBatchClaimTxParams): Promise<Transaction>;
397
+ private constructor();
398
+ /** Combine two pre-built line clients (advanced — full control over each). */
399
+ static fromClients(perpClient: WaterXClient, predictClient: PredictClient): Client;
400
+ /**
401
+ * Async factory — loads each line's deployment config (from the canonical
402
+ * `waterx-config` JSON) and returns a ready client. Each line can target a
403
+ * different network via `opts.perp.network` / `opts.predict.network`.
404
+ */
405
+ static create(opts?: ClientCreateOptions): Promise<Client>;
406
+ }
407
+ export {};
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Unified WaterX SDK client.
3
+ *
4
+ * Wraps the two product-line clients (`WaterXClient` for perp, `PredictClient`
5
+ * for prediction) behind a single object with namespaced modules, so the
6
+ * colliding builder names (`placeOrder`, `createAccount`, `deposit`, …) can be
7
+ * called unambiguously:
8
+ *
9
+ * const client = await Client.create({ network: "TESTNET" });
10
+ * client.perp.openPosition(tx, params); // -> perp builder
11
+ * client.predict.placeOrder(tx, params); // -> prediction builder
12
+ *
13
+ * The modules are thin: each method forwards to the existing free-function
14
+ * builder with the line's client pre-bound as the first argument. Builders are
15
+ * build-only (they return / mutate a `Transaction`); signing & execution stay
16
+ * with the caller (`client.perpClient` / `client.predictClient`, or a wallet),
17
+ * so frontend wallet flows and multi-step Pyth injection keep working.
18
+ */
19
+ import { WaterXClient } from "./client.js";
20
+ // Perp builder/view modules (every export takes the client as its first arg).
21
+ import * as perpFetch from "./fetch.js";
22
+ // Prediction builder/view modules (every export takes the client as its first arg).
23
+ import * as predAccount from "./prediction/account.js";
24
+ import * as predAdmin from "./prediction/admin.js";
25
+ import { PredictClient, } from "./prediction/client.js";
26
+ import * as predFetch from "./prediction/fetch.js";
27
+ import * as predGift from "./prediction/gift.js";
28
+ import * as predOps from "./prediction/prediction.js";
29
+ import { buildBatchClaimTx as buildPredictBatchClaimTx, buildPlaceOrderTx as buildPredictPlaceOrderTx, } from "./prediction/tx-builders.js";
30
+ import * as perpTx from "./tx-builders.js";
31
+ import * as perpUser from "./user/index.js";
32
+ /**
33
+ * Exports from the spread builder/view modules that are NOT client-first — their
34
+ * first argument is not the line client, so they must not become bound facade
35
+ * methods (binding would pass the client where a value is expected). This is the
36
+ * single source of truth shared by the runtime (skip) and the type (`Omit`).
37
+ * Keep in sync by auditing `export function` first-params across the spread modules.
38
+ */
39
+ const NON_CLIENT_FIRST = [
40
+ "extractReturnBytes",
41
+ // gift.ts — pure crypto / URL helpers (first arg is not PredictClient)
42
+ "base64UrlNoPadEncode",
43
+ "base64UrlNoPadDecode",
44
+ "generateGiftSeed",
45
+ "encodeGiftUrl",
46
+ "parseGiftUrl",
47
+ "deriveGiftKeypair",
48
+ "buildGiftClaimMessage",
49
+ "signGiftClaim",
50
+ ];
51
+ const NON_CLIENT_FIRST_SET = new Set(NON_CLIENT_FIRST);
52
+ function bindClient(client, ns) {
53
+ const out = {};
54
+ for (const key of Object.keys(ns)) {
55
+ if (NON_CLIENT_FIRST_SET.has(key))
56
+ continue; // not client-first → not a facade method
57
+ const value = ns[key];
58
+ out[key] =
59
+ typeof value === "function"
60
+ ? (...args) => value(client, ...args)
61
+ : value;
62
+ }
63
+ return out;
64
+ }
65
+ // Frozen, reused for both the runtime binding and the public module types.
66
+ const perpOps = { ...perpUser, ...perpTx, ...perpFetch };
67
+ const predictOps = { ...predAccount, ...predAdmin, ...predOps, ...predFetch, ...predGift };
68
+ export class Client {
69
+ /** Underlying perp client — use for signing/executing perp transactions. */
70
+ perpClient;
71
+ /** Underlying prediction client — use for signing/executing prediction transactions. */
72
+ predictClient;
73
+ /** Perp builders & views (`client.perp.openPosition(tx, params)`). */
74
+ perp;
75
+ /** Prediction builders & views (`client.predict.placeOrder(tx, params)`). */
76
+ predict;
77
+ /**
78
+ * Async prediction builder: optional consolidate + `placeOrder`.
79
+ * Uses `perpClient` for the sweep and `predictClient` for the bet leg.
80
+ */
81
+ buildPredictPlaceOrderTx(params) {
82
+ return buildPredictPlaceOrderTx(this.perpClient, this.predictClient, params);
83
+ }
84
+ /**
85
+ * Async prediction builder: optional consolidate + `batchClaim`.
86
+ */
87
+ buildPredictBatchClaimTx(params) {
88
+ return buildPredictBatchClaimTx(this.perpClient, this.predictClient, params);
89
+ }
90
+ constructor(perpClient, predictClient) {
91
+ this.perpClient = perpClient;
92
+ this.predictClient = predictClient;
93
+ this.perp = bindClient(perpClient, perpOps);
94
+ this.predict = bindClient(predictClient, predictOps);
95
+ }
96
+ /** Combine two pre-built line clients (advanced — full control over each). */
97
+ static fromClients(perpClient, predictClient) {
98
+ return new Client(perpClient, predictClient);
99
+ }
100
+ /**
101
+ * Async factory — loads each line's deployment config (from the canonical
102
+ * `waterx-config` JSON) and returns a ready client. Each line can target a
103
+ * different network via `opts.perp.network` / `opts.predict.network`.
104
+ */
105
+ static async create(opts = {}) {
106
+ const baseNetwork = opts.network ?? "TESTNET";
107
+ const { network: perpNetwork, ...perpRest } = opts.perp ?? {};
108
+ const { network: predictNetwork, ...predictRest } = opts.predict ?? {};
109
+ const perpClient = await WaterXClient.create(perpNetwork ?? baseNetwork, {
110
+ grpcUrl: opts.grpcUrl,
111
+ configUrl: opts.configUrl,
112
+ cache: opts.cache,
113
+ ...perpRest,
114
+ });
115
+ const predictClient = await PredictClient.create(predictNetwork ?? baseNetwork, {
116
+ grpcUrl: opts.grpcUrl,
117
+ configUrl: opts.configUrl,
118
+ cache: opts.cache,
119
+ ...predictRest,
120
+ });
121
+ return new Client(perpClient, predictClient);
122
+ }
123
+ }
@@ -86,6 +86,33 @@ export interface RequestDepositFromReceivingsParams {
86
86
  * `DepositRequest<T>` argument.
87
87
  */
88
88
  export declare function requestDepositFromReceivings(client: WaterXClient, tx: Transaction, params: RequestDepositFromReceivingsParams): TransactionArgument;
89
+ export interface RequestDepositFromFundsParams {
90
+ /** wxa account ID receiving the deposit. */
91
+ accountId: string;
92
+ /** Fully-qualified coin type `T`. */
93
+ coinType: string;
94
+ /**
95
+ * Sui native funds-accumulator root shared object. Defaults to the
96
+ * well-known `ACCUMULATOR_ROOT` (`0xacc`); override only for a custom
97
+ * deployment.
98
+ */
99
+ accumulatorRoot?: string | TransactionArgument;
100
+ /** Optional opaque extra data forwarded to the policy. */
101
+ extraData?: Uint8Array;
102
+ }
103
+ /**
104
+ * Build `account::request_deposit_from_funds<T>` — drains every `Balance<T>`
105
+ * parked at the account's address in Sui's native funds accumulator (the
106
+ * path taken by `transfer_coin` / `0x2::balance::send_funds<T>`) into a
107
+ * single `DepositRequest<T>`. Returns the `DepositRequest<T>` argument.
108
+ *
109
+ * The drained total reflects the balance as of the last consensus commit,
110
+ * so the value isn't readable within the same PTB — treat it as a
111
+ * between-tx drain. Returns a zero-balance request when the address holds
112
+ * no `T`, so check `settled_funds_value<T>` off-chain first if you want to
113
+ * skip empty drains.
114
+ */
115
+ export declare function requestDepositFromFunds(client: WaterXClient, tx: Transaction, params: RequestDepositFromFundsParams): TransactionArgument;
89
116
  export interface RequestWithdrawParams {
90
117
  accountId: string;
91
118
  amount: bigint | number;
@@ -10,19 +10,17 @@
10
10
  * a Bucket `Account` object, pass `bucketAccount` (an object ID string
11
11
  * or a `TransactionArgument`).
12
12
  */
13
+ import { ACCUMULATOR_ROOT } from "../constants.js";
14
+ import { createAccountCall } from "../core/waterx-account.js";
13
15
  import * as wxa from "../generated/waterx_account/account.js";
14
16
  import { makeSenderRequest } from "../utils/account-request.js";
15
17
  /** Build `waterx_account::create_account`. Returns the new account ID via Move return value. */
16
18
  export function createAccount(client, tx, params) {
17
19
  const req = makeSenderRequest(client, tx, params.bucketAccount);
18
- wxa.createAccount({
19
- package: client.config.packages.waterx_account.published_at,
20
- arguments: {
21
- registry: tx.object(client.config.packages.waterx_account.account_registry),
22
- senderRequest: req,
23
- alias: params.alias,
24
- },
25
- })(tx);
20
+ createAccountCall(tx, {
21
+ packageId: client.config.packages.waterx_account.published_at,
22
+ registry: client.config.packages.waterx_account.account_registry,
23
+ }, { senderRequest: req, alias: params.alias });
26
24
  }
27
25
  export function setAlias(client, tx, params) {
28
26
  const req = makeSenderRequest(client, tx, params.bucketAccount);
@@ -114,6 +112,34 @@ export function requestDepositFromReceivings(client, tx, params) {
114
112
  })(tx);
115
113
  return req;
116
114
  }
115
+ /**
116
+ * Build `account::request_deposit_from_funds<T>` — drains every `Balance<T>`
117
+ * parked at the account's address in Sui's native funds accumulator (the
118
+ * path taken by `transfer_coin` / `0x2::balance::send_funds<T>`) into a
119
+ * single `DepositRequest<T>`. Returns the `DepositRequest<T>` argument.
120
+ *
121
+ * The drained total reflects the balance as of the last consensus commit,
122
+ * so the value isn't readable within the same PTB — treat it as a
123
+ * between-tx drain. Returns a zero-balance request when the address holds
124
+ * no `T`, so check `settled_funds_value<T>` off-chain first if you want to
125
+ * skip empty drains.
126
+ */
127
+ export function requestDepositFromFunds(client, tx, params) {
128
+ const root = params.accumulatorRoot ?? ACCUMULATOR_ROOT;
129
+ const [req] = wxa.requestDepositFromFunds({
130
+ package: client.config.packages.waterx_account.published_at,
131
+ arguments: {
132
+ registry: tx.object(client.config.packages.waterx_account.account_registry),
133
+ accountId: params.accountId,
134
+ accumulatorRoot: (typeof root === "string"
135
+ ? tx.object(root)
136
+ : root),
137
+ extraData: Array.from(params.extraData ?? new Uint8Array()),
138
+ },
139
+ typeArguments: [params.coinType],
140
+ })(tx);
141
+ return req;
142
+ }
117
143
  /** Build `account::request_withdraw<T>`. Returns the `WithdrawRequest<T>` argument. */
118
144
  export function requestWithdraw(client, tx, params) {
119
145
  const req = makeSenderRequest(client, tx, params.bucketAccount);