@waterx/sdk 2.4.1 → 3.0.1

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 (226) hide show
  1. package/README.md +25 -21
  2. package/dist/src/{utils → account}/account-request.d.ts +2 -2
  3. package/dist/src/{user → account}/account.d.ts +23 -21
  4. package/dist/src/{user → account}/account.js +5 -5
  5. package/dist/src/account/client.d.ts +42 -0
  6. package/dist/src/account/client.js +17 -0
  7. package/dist/src/account/config.d.ts +151 -0
  8. package/dist/src/account/config.js +8 -0
  9. package/dist/src/account/constants.d.ts +5 -0
  10. package/dist/src/account/constants.js +5 -0
  11. package/dist/src/account/fetch/referral.d.ts +15 -0
  12. package/dist/src/account/fetch/referral.js +51 -0
  13. package/dist/src/account/fetch/simulate.d.ts +34 -0
  14. package/dist/src/account/fetch/simulate.js +43 -0
  15. package/dist/src/{utils/consolidate-balance.d.ts → account/funding/balance.d.ts} +3 -8
  16. package/dist/src/{utils/consolidate-balance.js → account/funding/balance.js} +6 -1
  17. package/dist/src/account/funding/consolidate.d.ts +46 -0
  18. package/dist/src/account/funding/consolidate.js +137 -0
  19. package/dist/src/{user → account/funding}/credit.d.ts +10 -10
  20. package/dist/src/{user → account/funding}/credit.js +6 -6
  21. package/dist/src/{user → account/funding}/custody.d.ts +4 -4
  22. package/dist/src/{user → account/funding}/custody.js +2 -2
  23. package/dist/src/{utils → account/funding}/wormhole.d.ts +4 -4
  24. package/dist/src/{utils → account/funding}/wormhole.js +1 -1
  25. package/dist/src/account/index.d.ts +29 -0
  26. package/dist/src/account/index.js +29 -0
  27. package/dist/src/{user → account}/referral.d.ts +3 -3
  28. package/dist/src/{user → account}/referral.js +1 -1
  29. package/dist/src/base-client.d.ts +74 -0
  30. package/dist/src/base-client.js +97 -0
  31. package/dist/src/constants.d.ts +4 -46
  32. package/dist/src/constants.js +8 -52
  33. package/dist/src/generated/bucket_v2_framework/liability.d.ts +0 -26
  34. package/dist/src/generated/bucket_v2_framework/liability.js +0 -28
  35. package/dist/src/generated/waterx_account/account.d.ts +50 -15
  36. package/dist/src/generated/waterx_account/account.js +51 -15
  37. package/dist/src/generated/waterx_oracle/oracle.d.ts +7 -1
  38. package/dist/src/generated/waterx_oracle/oracle.js +7 -2
  39. package/dist/src/{prediction/generated → generated}/waterx_prediction/account_data.d.ts +19 -2
  40. package/dist/src/{prediction/generated → generated}/waterx_prediction/admin.d.ts +3 -1
  41. package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/sui/balance.d.ts +3 -1
  42. package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/deps/sui/table.d.ts +6 -1
  43. package/dist/src/generated/waterx_prediction/events.d.ts +288 -0
  44. package/dist/src/{prediction/generated → generated}/waterx_prediction/events.js +39 -0
  45. package/dist/src/{prediction/generated → generated}/waterx_prediction/global_config.d.ts +6 -1
  46. package/dist/src/{prediction/generated → generated}/waterx_prediction/order.d.ts +34 -1
  47. package/dist/src/{prediction/generated → generated}/waterx_prediction/position.d.ts +16 -1
  48. package/dist/src/{prediction/generated → generated}/waterx_prediction/view.d.ts +69 -4
  49. package/dist/src/{prediction/generated → generated}/waterx_prediction/waterx_prediction.d.ts +162 -2
  50. package/dist/src/{prediction/generated → generated}/waterx_prediction/waterx_prediction.js +99 -0
  51. package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +102 -0
  52. package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +99 -0
  53. package/dist/src/generated/waterx_supra_rule/supra_rule.d.ts +5 -5
  54. package/dist/src/generated/waterx_supra_rule/supra_rule.js +1 -2
  55. package/dist/src/generated/withdrawal_queue/withdrawal_queue.d.ts +23 -23
  56. package/dist/src/generated/withdrawal_queue/withdrawal_queue.js +3 -6
  57. package/dist/src/oracle/aggregate.d.ts +74 -0
  58. package/dist/src/oracle/aggregate.js +112 -0
  59. package/dist/src/oracle/config.d.ts +99 -0
  60. package/dist/src/oracle/config.js +23 -0
  61. package/dist/src/oracle/host.d.ts +32 -0
  62. package/dist/src/oracle/host.js +10 -0
  63. package/dist/src/oracle/index.d.ts +16 -0
  64. package/dist/src/oracle/index.js +18 -0
  65. package/dist/src/oracle/pyth.d.ts +52 -0
  66. package/dist/src/oracle/pyth.js +220 -0
  67. package/dist/src/oracle/rules/constant-rule.d.ts +9 -0
  68. package/dist/src/oracle/rules/constant-rule.js +14 -0
  69. package/dist/src/oracle/rules/pyth-rule.d.ts +11 -0
  70. package/dist/src/oracle/rules/pyth-rule.js +20 -0
  71. package/dist/src/oracle/rules/sponsor.d.ts +28 -0
  72. package/dist/src/oracle/rules/sponsor.js +48 -0
  73. package/dist/src/oracle/rules/supra-rule.d.ts +11 -0
  74. package/dist/src/oracle/rules/supra-rule.js +22 -0
  75. package/dist/src/perp/client.d.ts +78 -0
  76. package/dist/src/perp/client.js +108 -0
  77. package/dist/src/{client.d.ts → perp/config-view.d.ts} +15 -60
  78. package/dist/src/{client.js → perp/config-view.js} +23 -95
  79. package/dist/src/perp/config.d.ts +126 -0
  80. package/dist/src/{config.js → perp/config.js} +11 -12
  81. package/dist/src/perp/constants.d.ts +49 -0
  82. package/dist/src/perp/constants.js +61 -0
  83. package/dist/src/perp/fetch/account.d.ts +43 -0
  84. package/dist/src/perp/fetch/account.js +64 -0
  85. package/dist/src/perp/fetch/bridge.d.ts +90 -0
  86. package/dist/src/perp/fetch/bridge.js +127 -0
  87. package/dist/src/perp/fetch/custody.d.ts +32 -0
  88. package/dist/src/perp/fetch/custody.js +62 -0
  89. package/dist/src/perp/fetch/market.d.ts +30 -0
  90. package/dist/src/perp/fetch/market.js +68 -0
  91. package/dist/src/perp/fetch/positions.d.ts +70 -0
  92. package/dist/src/perp/fetch/positions.js +185 -0
  93. package/dist/src/perp/fetch/simulate.d.ts +12 -0
  94. package/dist/src/perp/fetch/simulate.js +13 -0
  95. package/dist/src/perp/fetch.d.ts +23 -0
  96. package/dist/src/perp/fetch.js +23 -0
  97. package/dist/src/{index.d.ts → perp/index.d.ts} +21 -21
  98. package/dist/src/{index.js → perp/index.js} +21 -21
  99. package/dist/src/perp/tx-builders/common.d.ts +83 -0
  100. package/dist/src/perp/tx-builders/common.js +70 -0
  101. package/dist/src/perp/tx-builders/credit.d.ts +65 -0
  102. package/dist/src/perp/tx-builders/credit.js +62 -0
  103. package/dist/src/perp/tx-builders/rewards.d.ts +30 -0
  104. package/dist/src/perp/tx-builders/rewards.js +34 -0
  105. package/dist/src/perp/tx-builders/trading.d.ts +51 -0
  106. package/dist/src/perp/tx-builders/trading.js +59 -0
  107. package/dist/src/perp/tx-builders/wlp.d.ts +90 -0
  108. package/dist/src/perp/tx-builders/wlp.js +120 -0
  109. package/dist/src/perp/tx-builders.d.ts +23 -0
  110. package/dist/src/perp/tx-builders.js +23 -0
  111. package/dist/src/perp/user/index.d.ts +8 -0
  112. package/dist/src/perp/user/index.js +8 -0
  113. package/dist/src/{user → perp/user}/order.d.ts +7 -7
  114. package/dist/src/{user → perp/user}/order.js +3 -3
  115. package/dist/src/{user → perp/user}/staking.d.ts +4 -4
  116. package/dist/src/{user → perp/user}/staking.js +2 -2
  117. package/dist/src/{user → perp/user}/trading.d.ts +13 -13
  118. package/dist/src/{user → perp/user}/trading.js +2 -2
  119. package/dist/src/{user → perp/user}/wlp.d.ts +7 -7
  120. package/dist/src/{user → perp/user}/wlp.js +3 -3
  121. package/dist/src/prediction/account.js +40 -76
  122. package/dist/src/prediction/bcs.d.ts +15 -9
  123. package/dist/src/prediction/bcs.js +17 -81
  124. package/dist/src/prediction/client.d.ts +8 -38
  125. package/dist/src/prediction/client.js +11 -67
  126. package/dist/src/prediction/config.d.ts +16 -2
  127. package/dist/src/prediction/config.js +10 -4
  128. package/dist/src/prediction/gift.js +2 -10
  129. package/dist/src/prediction/index.d.ts +11 -11
  130. package/dist/src/prediction/index.js +10 -10
  131. package/dist/src/prediction/prediction.d.ts +45 -0
  132. package/dist/src/prediction/prediction.js +71 -0
  133. package/dist/src/prediction/tx-builders.d.ts +4 -4
  134. package/dist/src/prediction/tx-builders.js +2 -2
  135. package/dist/src/prediction/types.d.ts +2 -0
  136. package/dist/src/prediction/user/index.d.ts +2 -2
  137. package/dist/src/prediction/user/index.js +1 -1
  138. package/dist/src/prediction/user/position.d.ts +2 -2
  139. package/dist/src/prediction/user/position.js +1 -1
  140. package/dist/src/prediction/utils/bcs.d.ts +5 -0
  141. package/dist/src/prediction/utils/bcs.js +5 -0
  142. package/dist/src/prediction/utils/index.d.ts +7 -0
  143. package/dist/src/prediction/utils/index.js +7 -0
  144. package/dist/src/sdk.d.ts +10 -6
  145. package/dist/src/sdk.js +9 -5
  146. package/dist/src/unified-client.d.ts +140 -145
  147. package/dist/src/unified-client.js +98 -40
  148. package/dist/src/utils/config.d.ts +1 -1
  149. package/package.json +22 -5
  150. package/dist/src/config.d.ts +0 -292
  151. package/dist/src/fetch.d.ts +0 -254
  152. package/dist/src/fetch.js +0 -564
  153. package/dist/src/prediction/generated/bucket_v2_framework/account.d.ts +0 -100
  154. package/dist/src/prediction/generated/bucket_v2_framework/account.js +0 -129
  155. package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.d.ts +0 -6
  156. package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.js +0 -19
  157. package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.d.ts +0 -10
  158. package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.d.ts +0 -36
  159. package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.js +0 -27
  160. package/dist/src/prediction/generated/bucket_v2_framework/double.d.ts +0 -382
  161. package/dist/src/prediction/generated/bucket_v2_framework/double.js +0 -466
  162. package/dist/src/prediction/generated/bucket_v2_framework/float.d.ts +0 -362
  163. package/dist/src/prediction/generated/bucket_v2_framework/float.js +0 -440
  164. package/dist/src/prediction/generated/bucket_v2_framework/liability.d.ts +0 -193
  165. package/dist/src/prediction/generated/bucket_v2_framework/liability.js +0 -205
  166. package/dist/src/prediction/generated/bucket_v2_framework/linked_table.d.ts +0 -384
  167. package/dist/src/prediction/generated/bucket_v2_framework/linked_table.js +0 -382
  168. package/dist/src/prediction/generated/bucket_v2_framework/sheet.d.ts +0 -344
  169. package/dist/src/prediction/generated/bucket_v2_framework/sheet.js +0 -338
  170. package/dist/src/prediction/generated/utils/index.d.ts +0 -30
  171. package/dist/src/prediction/generated/utils/index.js +0 -160
  172. package/dist/src/prediction/generated/waterx_account/account.d.ts +0 -1589
  173. package/dist/src/prediction/generated/waterx_account/account.js +0 -1758
  174. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.d.ts +0 -7
  175. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.js +0 -13
  176. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.d.ts +0 -7
  177. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.js +0 -16
  178. package/dist/src/prediction/generated/waterx_account/deps/std/type_name.d.ts +0 -6
  179. package/dist/src/prediction/generated/waterx_account/deps/std/type_name.js +0 -19
  180. package/dist/src/prediction/generated/waterx_account/deps/sui/balance.d.ts +0 -10
  181. package/dist/src/prediction/generated/waterx_account/deps/sui/balance.js +0 -14
  182. package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.d.ts +0 -12
  183. package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.js +0 -19
  184. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.d.ts +0 -36
  185. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.js +0 -27
  186. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.d.ts +0 -16
  187. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.js +0 -19
  188. package/dist/src/prediction/generated/waterx_account/direct_rule.d.ts +0 -75
  189. package/dist/src/prediction/generated/waterx_account/direct_rule.js +0 -78
  190. package/dist/src/prediction/generated/waterx_account/events.d.ts +0 -33
  191. package/dist/src/prediction/generated/waterx_account/events.js +0 -137
  192. package/dist/src/prediction/generated/waterx_account/version.js +0 -8
  193. package/dist/src/prediction/generated/waterx_prediction/bet_sharing.d.ts +0 -60
  194. package/dist/src/prediction/generated/waterx_prediction/bet_sharing.js +0 -83
  195. package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.js +0 -14
  196. package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.d.ts +0 -24
  197. package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.js +0 -31
  198. package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.d.ts +0 -16
  199. package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.js +0 -19
  200. package/dist/src/prediction/generated/waterx_prediction/events.d.ts +0 -22
  201. package/dist/src/prediction/generated/waterx_prediction/version.d.ts +0 -10
  202. package/dist/src/tx-builders.d.ts +0 -296
  203. package/dist/src/tx-builders.js +0 -461
  204. package/dist/src/user/index.d.ts +0 -8
  205. package/dist/src/user/index.js +0 -8
  206. package/dist/src/utils/pyth.d.ts +0 -124
  207. package/dist/src/utils/pyth.js +0 -392
  208. /package/dist/src/{utils → account}/account-request.js +0 -0
  209. /package/dist/src/{core → account}/waterx-account.d.ts +0 -0
  210. /package/dist/src/{core → account}/waterx-account.js +0 -0
  211. /package/dist/src/{prediction/generated → generated}/waterx_prediction/account_data.js +0 -0
  212. /package/dist/src/{prediction/generated → generated}/waterx_prediction/admin.js +0 -0
  213. /package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/bucket_v2_framework/linked_table.d.ts +0 -0
  214. /package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/bucket_v2_framework/linked_table.js +0 -0
  215. /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/balance.js +0 -0
  216. /package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/deps/sui/table.js +0 -0
  217. /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/vec_set.d.ts +0 -0
  218. /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/vec_set.js +0 -0
  219. /package/dist/src/{prediction/generated → generated}/waterx_prediction/global_config.js +0 -0
  220. /package/dist/src/{prediction/generated → generated}/waterx_prediction/order.js +0 -0
  221. /package/dist/src/{prediction/generated → generated}/waterx_prediction/outcome.d.ts +0 -0
  222. /package/dist/src/{prediction/generated → generated}/waterx_prediction/outcome.js +0 -0
  223. /package/dist/src/{prediction/generated → generated}/waterx_prediction/position.js +0 -0
  224. /package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/version.d.ts +0 -0
  225. /package/dist/src/{prediction/generated → generated}/waterx_prediction/version.js +0 -0
  226. /package/dist/src/{prediction/generated → generated}/waterx_prediction/view.js +0 -0
@@ -1,34 +1,51 @@
1
1
  /**
2
- * Unified WaterX SDK client.
2
+ * Umbrella WaterX SDK client — the main entry point.
3
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:
4
+ * Exposes three namespaces over the two product-line sub-clients:
8
5
  *
9
- * const client = await Client.create({ network: "TESTNET" });
10
- * client.perp.openPosition(tx, params); // -> perp builder
11
- * client.predict.placeOrder(tx, params); // -> prediction builder
6
+ * const client = await WaterXClient.create({ network: "TESTNET" });
7
+ * client.account.createAccount(tx, { alias }); // -> shared waterx_account + funding
8
+ * client.perp.placeOrderRequest(tx, params); // -> perp builder
9
+ * client.predict.placeOrder(tx, params); // -> prediction builder
12
10
  *
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.
11
+ * `client.perp` **is** the `PerpClient` instance with the perp builder/view
12
+ * methods grafted on, and `client.predict` **is** the `PredictClient` instance
13
+ * likewise so signing & execution live on the same object
14
+ * (`client.perp.signAndExecuteTransaction(...)`) right next to the builders.
15
+ * There are no separate `.perpClient` / `.predictClient` accessors.
16
+ *
17
+ * `client.account` is a thin namespace (no own client) bound to the perp
18
+ * sub-client: the perp config carries the shared `waterx_account` registry plus
19
+ * the bridge / native_custody / withdrawal_queue / credit_registry that the
20
+ * credit & custody builders read. `waterx_account` is one shared on-chain object,
21
+ * so an account created here serves both lines — except when the two lines target
22
+ * different networks (`opts.perp.network !== opts.predict.network`), where
23
+ * `client.account` follows the perp line; split-network callers should reach the
24
+ * predict line's generic account builders via the `prediction` namespace directly.
25
+ *
26
+ * Each namespace method forwards to the existing free-function builder with the
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.
18
30
  */
19
31
  import { Transaction } from "@mysten/sui/transactions";
20
- import { WaterXClient, type CreateClientOptions as PerpCreateOptions } from "./client.ts";
32
+ import * as accountOps from "./account/index.ts";
33
+ import * as perpReferral from "./account/referral.ts";
21
34
  import type { Network } from "./constants.ts";
22
- import * as perpFetch from "./fetch.ts";
23
- import * as predAccount from "./prediction/account.ts";
35
+ import { PerpClient, type CreateClientOptions as PerpCreateOptions } from "./perp/client.ts";
36
+ import * as perpFetch from "./perp/fetch.ts";
37
+ import * as perpTx from "./perp/tx-builders.ts";
38
+ import * as perpOrder from "./perp/user/order.ts";
39
+ import * as perpStaking from "./perp/user/staking.ts";
40
+ import * as perpTrading from "./perp/user/trading.ts";
41
+ import * as perpWlp from "./perp/user/wlp.ts";
42
+ import { allowPredictionProtocolAsset, disallowPredictionProtocolAsset, setDelegatePredictionPermission, whitelistPredictionProtocol } from "./prediction/account.ts";
24
43
  import * as predAdmin from "./prediction/admin.ts";
25
44
  import { PredictClient, type CreateClientOptions as PredictCreateOptions } from "./prediction/client.ts";
26
45
  import * as predFetch from "./prediction/fetch.ts";
27
46
  import * as predGift from "./prediction/gift.ts";
28
47
  import * as predOps from "./prediction/prediction.ts";
29
48
  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
49
  /**
33
50
  * Exports from the spread builder/view modules that are NOT client-first — their
34
51
  * first argument is not the line client, so they must not become bound facade
@@ -47,32 +64,35 @@ type ClientBound<NS, C> = {
47
64
  [K in keyof Omit<NS, NonClientFirstKey>]: NS[K] extends (client: C, ...args: infer A) => infer R ? (...args: A) => R : NS[K];
48
65
  };
49
66
  declare const perpOps: {
50
- getAccountData(client: WaterXClient, accountId: string): Promise<perpFetch.AccountDataView | undefined>;
51
- getMarketData(client: WaterXClient, args: {
67
+ getRefererFor(client: import("./account/client.ts").WxaClientLike, referee: string): Promise<string | undefined>;
68
+ isValidReferralCode(client: import("./account/client.ts").WxaClientLike, code: string): Promise<boolean>;
69
+ referralCodeExists(client: import("./account/client.ts").WxaClientLike, code: string): Promise<boolean>;
70
+ getAccountData(client: PerpClient, accountId: string): Promise<perpFetch.AccountDataView | undefined>;
71
+ getMarketData(client: PerpClient, args: {
52
72
  ticker: string;
53
73
  lpType?: string;
54
74
  }): Promise<perpFetch.MarketDataView>;
55
- getPoolData(client: WaterXClient, args?: {
75
+ getPoolData(client: PerpClient, args?: {
56
76
  lpType?: string;
57
77
  }): Promise<perpFetch.PoolDataView>;
58
- getTokenPoolData(client: WaterXClient, args: {
78
+ getTokenPoolData(client: PerpClient, args: {
59
79
  tokenIndex: bigint | number;
60
80
  lpType?: string;
61
81
  }): Promise<perpFetch.TokenPoolDataView>;
62
- getGlobalConfigData(client: WaterXClient): Promise<perpFetch.GlobalConfigDataView>;
63
- positionExists(client: WaterXClient, args: {
82
+ getGlobalConfigData(client: PerpClient): Promise<perpFetch.GlobalConfigDataView>;
83
+ positionExists(client: PerpClient, args: {
64
84
  ticker: string;
65
85
  positionId: bigint | number;
66
86
  lpType?: string;
67
87
  }): Promise<boolean>;
68
- getPosition(client: WaterXClient, args: {
88
+ getPosition(client: PerpClient, args: {
69
89
  ticker: string;
70
90
  positionId: bigint | number;
71
91
  basePriceUsd: bigint | number;
72
92
  collateralPriceUsd: bigint | number;
73
93
  lpType?: string;
74
94
  }): Promise<perpFetch.PositionDataView>;
75
- getOrder(client: WaterXClient, args: {
95
+ getOrder(client: PerpClient, args: {
76
96
  ticker: string;
77
97
  orderId: bigint | number;
78
98
  orderTypeTag: number;
@@ -80,7 +100,7 @@ declare const perpOps: {
80
100
  basePriceUsd: bigint | number;
81
101
  lpType?: string;
82
102
  }): Promise<perpFetch.OrderDataView>;
83
- getMarketOrders(client: WaterXClient, args: {
103
+ getMarketOrders(client: PerpClient, args: {
84
104
  ticker: string;
85
105
  basePriceUsd?: bigint | number;
86
106
  lpType?: string;
@@ -88,7 +108,7 @@ declare const perpOps: {
88
108
  orders: perpFetch.OrderDataView[];
89
109
  nextCursor?: bigint;
90
110
  }>;
91
- getMarketPositions(client: WaterXClient, args: {
111
+ getMarketPositions(client: PerpClient, args: {
92
112
  ticker: string;
93
113
  basePriceUsd: bigint | number;
94
114
  collateralPriceUsd?: bigint | number;
@@ -97,121 +117,95 @@ declare const perpOps: {
97
117
  positions: perpFetch.PositionDataView[];
98
118
  nextCursor?: bigint;
99
119
  }>;
100
- getAccountPositions(client: WaterXClient, args: {
120
+ getAccountPositions(client: PerpClient, args: {
101
121
  ticker: string;
102
122
  accountObjectAddress: string;
103
123
  basePriceUsd: bigint | number;
104
124
  collateralPriceUsd?: bigint | number;
105
125
  lpType?: string;
106
126
  }): Promise<perpFetch.PositionDataView[]>;
107
- getAccountOrders(client: WaterXClient, args: {
127
+ getAccountOrders(client: PerpClient, args: {
108
128
  ticker: string;
109
129
  accountObjectAddress: string;
110
130
  basePriceUsd?: bigint | number;
111
131
  lpType?: string;
112
132
  }): Promise<perpFetch.OrderDataView[]>;
113
- getRedeemRequests(client: WaterXClient, args?: {
133
+ getRedeemRequests(client: PerpClient, args?: {
114
134
  lpType?: string;
115
135
  } & perpFetch.PageOpts): Promise<{
116
136
  requests: perpFetch.RedeemRequestDataView[];
117
137
  nextCursor?: bigint;
118
138
  }>;
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: {
139
+ getAccountsByOwner(client: PerpClient, owner: string): Promise<string[]>;
140
+ getAccountBalance(client: PerpClient, accountId: string, coinType?: string): Promise<bigint>;
141
+ getSpendableCreditBalance(client: PerpClient, accountId: string): Promise<perpFetch.SpendableCreditBalance>;
142
+ getCustodyVaultData(client: PerpClient): Promise<perpFetch.CustodyVaultData>;
143
+ getCustodyAssetData(client: PerpClient, assetType: string): Promise<perpFetch.CustodyAssetData>;
144
+ getBridgeLimits(client: PerpClient, args?: perpFetch.BridgeLimitsArgs): Promise<perpFetch.BridgeLimitsView>;
145
+ getBridgeFee(client: PerpClient, args: {
129
146
  evmDestinationChain: number;
130
147
  amount: bigint | number;
131
148
  creditType?: string;
132
149
  }): 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
150
  openPythSponsorFund: typeof perpTx.openPythSponsorFund;
156
151
  PythCache: typeof perpTx.PythCache;
157
152
  refreshOraclePrices: typeof perpTx.refreshOraclePrices;
158
153
  reimbursePythSponsor: typeof perpTx.reimbursePythSponsor;
159
154
  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: {
155
+ appendConsolidateToUsd(client: import("./account/client.ts").AccountClientLike, tx: Transaction, accountId: string): Promise<number>;
156
+ appendConsolidateAddressCredit(client: import("./account/client.ts").AccountClientLike, tx: Transaction, accountId: string): Promise<number>;
157
+ appendConsolidateForSpend(client: import("./account/client.ts").AccountClientLike, tx: Transaction, accountId: string): Promise<number>;
158
+ buildConsolidateToUsdTx(client: import("./account/client.ts").AccountClientLike, accountId: string, tx?: Transaction): Promise<Transaction>;
159
+ buildClosePositionTx(client: PerpClient, params: perpTx.BuildClosePositionParams): Promise<Transaction>;
160
+ buildIncreasePositionTx(client: PerpClient, params: perpTx.BuildIncreasePositionParams): Promise<Transaction>;
161
+ buildDecreasePositionTx(client: PerpClient, params: perpTx.BuildDecreasePositionParams): Promise<Transaction>;
162
+ buildDepositCollateralTx(client: PerpClient, params: perpTx.BuildDepositCollateralParams): Promise<Transaction>;
163
+ buildWithdrawCollateralTx(client: PerpClient, params: perpTx.BuildWithdrawCollateralParams): Promise<Transaction>;
164
+ buildPlaceOrderTx(client: PerpClient, params: perpTx.BuildPlaceOrderParams): Promise<Transaction>;
165
+ buildCancelOrderTx(client: PerpClient, params: perpTx.BuildCancelOrderParams): Promise<Transaction>;
166
+ buildUpdateOrderTx(client: PerpClient, params: perpTx.BuildUpdateOrderParams): Promise<Transaction>;
167
+ buildCancelPreOrderTx(client: PerpClient, params: perpTx.BuildCancelPreOrderParams): Promise<Transaction>;
168
+ buildAddPreOrderTx(client: PerpClient, params: perpTx.BuildAddPreOrderParams): Promise<Transaction>;
169
+ buildMintWlpTx(client: PerpClient, params: perpTx.BuildMintWlpParams): Promise<Transaction>;
170
+ buildMintAndStakeWlpTx(client: PerpClient, params: perpTx.BuildMintAndStakeWlpParams): Promise<Transaction>;
171
+ buildUnstakeAndRequestRedeemWlpTx(client: PerpClient, params: perpTx.BuildUnstakeAndRequestRedeemWlpParams): Promise<Transaction>;
172
+ buildCancelRedeemAndStakeWlpTx(client: PerpClient, params: perpTx.BuildCancelRedeemAndStakeWlpParams): Transaction;
173
+ buildClaimRewardsToAccountTx(client: PerpClient, params: perpTx.BuildClaimRewardsToAccountParams): Transaction;
174
+ buildRedeemVaaTx(client: PerpClient, params: perpTx.BuildRedeemVaaParams): Transaction;
175
+ buildRequestCreditWithdrawTx(client: PerpClient, params: perpTx.BuildRequestCreditWithdrawParams): Transaction;
176
+ buildExecuteWithdrawalTx(client: PerpClient, params: perpTx.BuildExecuteWithdrawalParams): Transaction;
177
+ setReferralCode(client: import("./account/client.ts").WxaClientLike, tx: Transaction, params: perpReferral.SetReferralCodeParams): void;
178
+ useReferralCode(client: import("./account/client.ts").WxaClientLike, tx: Transaction, params: perpReferral.UseReferralCodeParams): void;
179
+ stake(client: PerpClient, tx: Transaction, params: perpStaking.StakeParams): void;
180
+ unstake(client: PerpClient, tx: Transaction, params: perpStaking.UnstakeParams): void;
181
+ claimReward(client: PerpClient, tx: Transaction, params: perpStaking.ClaimRewardParams): void;
182
+ mintWlp(client: PerpClient, tx: Transaction, params: perpWlp.MintWlpParams): import("@mysten/sui/transactions").TransactionArgument;
183
+ requestRedeemWlp(client: PerpClient, tx: Transaction, params: perpWlp.RequestRedeemWlpParams): void;
184
+ cancelRedeemWlp(client: PerpClient, tx: Transaction, params: perpWlp.CancelRedeemWlpParams): void;
185
+ settleRedeemWlp(client: PerpClient, tx: Transaction, params: perpWlp.SettleRedeemWlpParams): void;
186
+ updateTokenValue(client: PerpClient, tx: Transaction, args: {
212
187
  tokenType: string;
213
188
  lpType?: string;
214
189
  }): void;
190
+ buildPlaceOrderArgument(client: PerpClient, tx: Transaction, p: perpOrder.PlaceOrderArgumentParams): import("@mysten/sui/transactions").TransactionArgument;
191
+ placeOrderRequest(client: PerpClient, tx: Transaction, params: perpOrder.PlaceOrderRequestParams): import("@mysten/sui/transactions").TransactionArgument;
192
+ cancelOrderRequest(client: PerpClient, tx: Transaction, params: perpOrder.CancelOrderRequestParams): import("@mysten/sui/transactions").TransactionArgument;
193
+ updateOrderRequest(client: PerpClient, tx: Transaction, params: perpOrder.UpdateOrderRequestParams): import("@mysten/sui/transactions").TransactionArgument;
194
+ cancelPreOrderRequest(client: PerpClient, tx: Transaction, params: perpOrder.CancelPreOrderRequestParams): import("@mysten/sui/transactions").TransactionArgument;
195
+ addPreOrderRequest(client: PerpClient, tx: Transaction, params: perpOrder.AddPreOrderRequestParams): import("@mysten/sui/transactions").TransactionArgument;
196
+ closePositionRequest(client: PerpClient, tx: Transaction, params: perpTrading.ClosePositionRequestParams): import("@mysten/sui/transactions").TransactionArgument;
197
+ increasePositionRequest(client: PerpClient, tx: Transaction, params: perpTrading.IncreasePositionRequestParams): import("@mysten/sui/transactions").TransactionArgument;
198
+ decreasePositionRequest(client: PerpClient, tx: Transaction, params: perpTrading.DecreasePositionRequestParams): import("@mysten/sui/transactions").TransactionArgument;
199
+ depositCollateralRequest(client: PerpClient, tx: Transaction, params: perpTrading.DepositCollateralRequestParams): import("@mysten/sui/transactions").TransactionArgument;
200
+ withdrawCollateralRequest(client: PerpClient, tx: Transaction, params: perpTrading.WithdrawCollateralRequestParams): import("@mysten/sui/transactions").TransactionArgument;
201
+ executeTrading(client: PerpClient, tx: Transaction, params: perpTrading.ExecuteTradingParams): void;
202
+ liquidate(client: PerpClient, tx: Transaction, params: perpTrading.LiquidateParams): void;
203
+ batchLiquidate(client: PerpClient, tx: Transaction, params: perpTrading.BatchLiquidateParams): void;
204
+ matchOrders(client: PerpClient, tx: Transaction, params: perpTrading.MatchOrdersParams): void;
205
+ updateFundingRate(client: PerpClient, tx: Transaction, params: perpTrading.UpdateFundingRateParams): void;
206
+ openPositionByKeeper(client: PerpClient, tx: Transaction, params: perpTrading.OpenPositionByKeeperParams): void;
207
+ closePositionByKeeper(client: PerpClient, tx: Transaction, params: perpTrading.ClosePositionByKeeperParams): void;
208
+ ORDER_TAG_WILDCARD_VALUE: 255;
215
209
  };
216
210
  declare const predictOps: {
217
211
  base64UrlNoPadEncode(bytes: Uint8Array): string;
@@ -315,7 +309,10 @@ declare const predictOps: {
315
309
  claim(client: PredictClient, tx: Transaction, params: predOps.ClaimParams): Transaction;
316
310
  batchClaim(client: PredictClient, tx: Transaction, params: predOps.BatchClaimParams): Transaction;
317
311
  requestClose(client: PredictClient, tx: Transaction, params: predOps.RequestCloseParams): Transaction;
312
+ requestPartialClose(client: PredictClient, tx: Transaction, params: predOps.RequestPartialCloseParams): Transaction;
318
313
  selfCancelClose(client: PredictClient, tx: Transaction, params: predOps.SelfCancelCloseParams): Transaction;
314
+ transferPosition(client: PredictClient, tx: Transaction, params: predOps.TransferPositionParams): Transaction;
315
+ splitPosition(client: PredictClient, tx: Transaction, params: predOps.SplitPositionParams): Transaction;
319
316
  fillOrder(client: PredictClient, tx: Transaction, params: predOps.FillOrderParams): Transaction;
320
317
  cancelOrder(client: PredictClient, tx: Transaction, params: predOps.CancelOrderParams): Transaction;
321
318
  confirmClose(client: PredictClient, tx: Transaction, params: predOps.ConfirmCloseParams): Transaction;
@@ -334,25 +331,15 @@ declare const predictOps: {
334
331
  unpauseMarket(client: PredictClient, tx: Transaction, params: predAdmin.MarketPauseParams): Transaction;
335
332
  addKeeper(client: PredictClient, tx: Transaction, params: predAdmin.KeeperAdminParams): Transaction;
336
333
  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;
334
+ setDelegatePredictionPermission: typeof setDelegatePredictionPermission;
335
+ whitelistPredictionProtocol: typeof whitelistPredictionProtocol;
336
+ allowPredictionProtocolAsset: typeof allowPredictionProtocolAsset;
337
+ disallowPredictionProtocolAsset: typeof disallowPredictionProtocolAsset;
353
338
  };
339
+ /** Account namespace exposed as `client.account` — generic wxa + credit + custody, perp-backed. */
340
+ export type AccountModule = ClientBound<typeof accountOps, PerpClient>;
354
341
  /** Perp namespace exposed as `client.perp` — builder/view methods, client pre-bound. */
355
- export type PerpModule = ClientBound<typeof perpOps, WaterXClient>;
342
+ export type PerpModule = ClientBound<typeof perpOps, PerpClient>;
356
343
  /** Prediction namespace exposed as `client.predict` — builder/view methods, client pre-bound. */
357
344
  export type PredictModule = ClientBound<typeof predictOps, PredictClient>;
358
345
  /** Per-line network/config override. Falls back to the shared top-level options. */
@@ -376,18 +363,22 @@ export interface ClientCreateOptions {
376
363
  /** Prediction-line overrides (network, grpcUrl, configUrl, cache, settlement, …). */
377
364
  predict?: PredictLineOptions;
378
365
  }
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;
366
+ export declare class WaterXClient {
367
+ /** Shared account namespace (`client.account.createAccount(tx, params)`) — perp-backed. */
368
+ readonly account: AccountModule;
369
+ /**
370
+ * Perp sub-client **with** the perp builders/views grafted on
371
+ * (`client.perp.placeOrderRequest(...)`, `client.perp.signAndExecuteTransaction(...)`).
372
+ */
373
+ readonly perp: PerpClient & PerpModule;
374
+ /**
375
+ * Prediction sub-client **with** the prediction builders/views grafted on
376
+ * (`client.predict.placeOrder(...)`, `client.predict.signAndExecuteTransaction(...)`).
377
+ */
378
+ readonly predict: PredictClient & PredictModule;
388
379
  /**
389
380
  * Async prediction builder: optional consolidate + `placeOrder`.
390
- * Uses `perpClient` for the sweep and `predictClient` for the bet leg.
381
+ * Uses the perp client for the sweep and the predict client for the bet leg.
391
382
  */
392
383
  buildPredictPlaceOrderTx(params: BuildPlaceOrderTxParams): Promise<Transaction>;
393
384
  /**
@@ -395,13 +386,17 @@ export declare class Client {
395
386
  */
396
387
  buildPredictBatchClaimTx(params: BuildBatchClaimTxParams): Promise<Transaction>;
397
388
  private constructor();
398
- /** Combine two pre-built line clients (advanced — full control over each). */
399
- static fromClients(perpClient: WaterXClient, predictClient: PredictClient): Client;
389
+ /**
390
+ * Combine two pre-built line clients (advanced full control over each).
391
+ * Note: this grafts the bound builder methods onto the provided client
392
+ * instances in place.
393
+ */
394
+ static fromClients(perpClient: PerpClient, predictClient: PredictClient): WaterXClient;
400
395
  /**
401
396
  * Async factory — loads each line's deployment config (from the canonical
402
397
  * `waterx-config` JSON) and returns a ready client. Each line can target a
403
398
  * different network via `opts.perp.network` / `opts.predict.network`.
404
399
  */
405
- static create(opts?: ClientCreateOptions): Promise<Client>;
400
+ static create(opts?: ClientCreateOptions): Promise<WaterXClient>;
406
401
  }
407
402
  export {};
@@ -1,34 +1,54 @@
1
1
  /**
2
- * Unified WaterX SDK client.
2
+ * Umbrella WaterX SDK client — the main entry point.
3
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:
4
+ * Exposes three namespaces over the two product-line sub-clients:
8
5
  *
9
- * const client = await Client.create({ network: "TESTNET" });
10
- * client.perp.openPosition(tx, params); // -> perp builder
11
- * client.predict.placeOrder(tx, params); // -> prediction builder
6
+ * const client = await WaterXClient.create({ network: "TESTNET" });
7
+ * client.account.createAccount(tx, { alias }); // -> shared waterx_account + funding
8
+ * client.perp.placeOrderRequest(tx, params); // -> perp builder
9
+ * client.predict.placeOrder(tx, params); // -> prediction builder
12
10
  *
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.
11
+ * `client.perp` **is** the `PerpClient` instance with the perp builder/view
12
+ * methods grafted on, and `client.predict` **is** the `PredictClient` instance
13
+ * likewise so signing & execution live on the same object
14
+ * (`client.perp.signAndExecuteTransaction(...)`) right next to the builders.
15
+ * There are no separate `.perpClient` / `.predictClient` accessors.
16
+ *
17
+ * `client.account` is a thin namespace (no own client) bound to the perp
18
+ * sub-client: the perp config carries the shared `waterx_account` registry plus
19
+ * the bridge / native_custody / withdrawal_queue / credit_registry that the
20
+ * credit & custody builders read. `waterx_account` is one shared on-chain object,
21
+ * so an account created here serves both lines — except when the two lines target
22
+ * different networks (`opts.perp.network !== opts.predict.network`), where
23
+ * `client.account` follows the perp line; split-network callers should reach the
24
+ * predict line's generic account builders via the `prediction` namespace directly.
25
+ *
26
+ * Each namespace method forwards to the existing free-function builder with the
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.
18
30
  */
19
- import { WaterXClient } from "./client.js";
31
+ // Unified account namespace: generic waterx_account framework + funding (credit + custody).
32
+ import * as accountOps from "./account/index.js";
33
+ import * as perpReferral from "./account/referral.js";
34
+ import { PerpClient } from "./perp/client.js";
20
35
  // 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";
36
+ import * as perpFetch from "./perp/fetch.js";
37
+ import * as perpTx from "./perp/tx-builders.js";
38
+ // Perp-only user builders account/credit/custody are excluded here; they live
39
+ // under `client.account`. trading / order / wlp / staking / referral only.
40
+ import * as perpOrder from "./perp/user/order.js";
41
+ import * as perpStaking from "./perp/user/staking.js";
42
+ import * as perpTrading from "./perp/user/trading.js";
43
+ import * as perpWlp from "./perp/user/wlp.js";
44
+ // Prediction-specific account ops (need the prediction package; NOT generic account).
45
+ import { allowPredictionProtocolAsset, disallowPredictionProtocolAsset, setDelegatePredictionPermission, whitelistPredictionProtocol, } from "./prediction/account.js";
24
46
  import * as predAdmin from "./prediction/admin.js";
25
47
  import { PredictClient, } from "./prediction/client.js";
26
48
  import * as predFetch from "./prediction/fetch.js";
27
49
  import * as predGift from "./prediction/gift.js";
28
50
  import * as predOps from "./prediction/prediction.js";
29
51
  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
52
  /**
33
53
  * Exports from the spread builder/view modules that are NOT client-first — their
34
54
  * first argument is not the line client, so they must not become bound facade
@@ -62,40 +82,68 @@ function bindClient(client, ns) {
62
82
  }
63
83
  return out;
64
84
  }
85
+ // Prediction-specific account ops kept on `client.predict` (generic account ops
86
+ // moved to `client.account`).
87
+ const predAccountSpecific = {
88
+ setDelegatePredictionPermission,
89
+ whitelistPredictionProtocol,
90
+ allowPredictionProtocolAsset,
91
+ disallowPredictionProtocolAsset,
92
+ };
65
93
  // 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)`). */
94
+ const perpOps = {
95
+ ...perpTrading,
96
+ ...perpOrder,
97
+ ...perpWlp,
98
+ ...perpStaking,
99
+ ...perpReferral,
100
+ ...perpTx,
101
+ ...perpFetch,
102
+ };
103
+ const predictOps = { ...predAccountSpecific, ...predAdmin, ...predOps, ...predFetch, ...predGift };
104
+ export class WaterXClient {
105
+ /** Shared account namespace (`client.account.createAccount(tx, params)`) — perp-backed. */
106
+ account;
107
+ /**
108
+ * Perp sub-client **with** the perp builders/views grafted on
109
+ * (`client.perp.placeOrderRequest(...)`, `client.perp.signAndExecuteTransaction(...)`).
110
+ */
74
111
  perp;
75
- /** Prediction builders & views (`client.predict.placeOrder(tx, params)`). */
112
+ /**
113
+ * Prediction sub-client **with** the prediction builders/views grafted on
114
+ * (`client.predict.placeOrder(...)`, `client.predict.signAndExecuteTransaction(...)`).
115
+ */
76
116
  predict;
77
117
  /**
78
118
  * Async prediction builder: optional consolidate + `placeOrder`.
79
- * Uses `perpClient` for the sweep and `predictClient` for the bet leg.
119
+ * Uses the perp client for the sweep and the predict client for the bet leg.
80
120
  */
81
121
  buildPredictPlaceOrderTx(params) {
82
- return buildPredictPlaceOrderTx(this.perpClient, this.predictClient, params);
122
+ return buildPredictPlaceOrderTx(this.perp, this.predict, params);
83
123
  }
84
124
  /**
85
125
  * Async prediction builder: optional consolidate + `batchClaim`.
86
126
  */
87
127
  buildPredictBatchClaimTx(params) {
88
- return buildPredictBatchClaimTx(this.perpClient, this.predictClient, params);
128
+ return buildPredictBatchClaimTx(this.perp, this.predict, params);
89
129
  }
90
130
  constructor(perpClient, predictClient) {
91
- this.perpClient = perpClient;
92
- this.predictClient = predictClient;
93
- this.perp = bindClient(perpClient, perpOps);
94
- this.predict = bindClient(predictClient, predictOps);
131
+ // Graft the bound builders onto the sub-client instances. No builder name
132
+ // collides with the client's own (transport/config) methods — enforced by the
133
+ // "graft guard" unit test (disjoint from the prototype chain), not just a
134
+ // comment. The instances stay `instanceof PerpClient` / `PredictClient`, so
135
+ // signing/config methods work.
136
+ this.perp = Object.assign(perpClient, bindClient(perpClient, perpOps));
137
+ this.predict = Object.assign(predictClient, bindClient(predictClient, predictOps));
138
+ this.account = bindClient(perpClient, accountOps);
95
139
  }
96
- /** Combine two pre-built line clients (advanced — full control over each). */
140
+ /**
141
+ * Combine two pre-built line clients (advanced — full control over each).
142
+ * Note: this grafts the bound builder methods onto the provided client
143
+ * instances in place.
144
+ */
97
145
  static fromClients(perpClient, predictClient) {
98
- return new Client(perpClient, predictClient);
146
+ return new WaterXClient(perpClient, predictClient);
99
147
  }
100
148
  /**
101
149
  * Async factory — loads each line's deployment config (from the canonical
@@ -106,18 +154,28 @@ export class Client {
106
154
  const baseNetwork = opts.network ?? "TESTNET";
107
155
  const { network: perpNetwork, ...perpRest } = opts.perp ?? {};
108
156
  const { network: predictNetwork, ...predictRest } = opts.predict ?? {};
109
- const perpClient = await WaterXClient.create(perpNetwork ?? baseNetwork, {
157
+ const resolvedPerpNetwork = perpNetwork ?? baseNetwork;
158
+ const resolvedPredictNetwork = predictNetwork ?? baseNetwork;
159
+ if (resolvedPerpNetwork !== resolvedPredictNetwork) {
160
+ // `client.account` always follows the perp line (see the class header).
161
+ // On a split-network setup a caller reaching for `client.account.*` would
162
+ // silently build against the perp deployment — warn so it isn't a surprise.
163
+ console.warn(`[WaterXClient] split-network: perp=${resolvedPerpNetwork} predict=${resolvedPredictNetwork}. ` +
164
+ `client.account follows the perp line (${resolvedPerpNetwork}); reach the predict line's ` +
165
+ `generic account builders via the prediction namespace directly.`);
166
+ }
167
+ const perpClient = await PerpClient.create(resolvedPerpNetwork, {
110
168
  grpcUrl: opts.grpcUrl,
111
169
  configUrl: opts.configUrl,
112
170
  cache: opts.cache,
113
171
  ...perpRest,
114
172
  });
115
- const predictClient = await PredictClient.create(predictNetwork ?? baseNetwork, {
173
+ const predictClient = await PredictClient.create(resolvedPredictNetwork, {
116
174
  grpcUrl: opts.grpcUrl,
117
175
  configUrl: opts.configUrl,
118
176
  cache: opts.cache,
119
177
  ...predictRest,
120
178
  });
121
- return new Client(perpClient, predictClient);
179
+ return new WaterXClient(perpClient, predictClient);
122
180
  }
123
181
  }