@waterx/sdk 2.4.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) 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/client.d.ts +8 -38
  123. package/dist/src/prediction/client.js +11 -67
  124. package/dist/src/prediction/config.d.ts +16 -2
  125. package/dist/src/prediction/config.js +10 -4
  126. package/dist/src/prediction/index.d.ts +11 -11
  127. package/dist/src/prediction/index.js +10 -10
  128. package/dist/src/prediction/prediction.d.ts +45 -0
  129. package/dist/src/prediction/prediction.js +71 -0
  130. package/dist/src/prediction/tx-builders.d.ts +4 -4
  131. package/dist/src/prediction/tx-builders.js +2 -2
  132. package/dist/src/prediction/user/index.d.ts +2 -2
  133. package/dist/src/prediction/user/index.js +1 -1
  134. package/dist/src/prediction/user/position.d.ts +2 -2
  135. package/dist/src/prediction/user/position.js +1 -1
  136. package/dist/src/prediction/utils/bcs.d.ts +5 -0
  137. package/dist/src/prediction/utils/bcs.js +5 -0
  138. package/dist/src/prediction/utils/index.d.ts +7 -0
  139. package/dist/src/prediction/utils/index.js +7 -0
  140. package/dist/src/sdk.d.ts +10 -6
  141. package/dist/src/sdk.js +9 -5
  142. package/dist/src/unified-client.d.ts +140 -145
  143. package/dist/src/unified-client.js +98 -40
  144. package/dist/src/utils/config.d.ts +1 -1
  145. package/package.json +22 -5
  146. package/dist/src/config.d.ts +0 -292
  147. package/dist/src/fetch.d.ts +0 -254
  148. package/dist/src/fetch.js +0 -564
  149. package/dist/src/prediction/generated/bucket_v2_framework/account.d.ts +0 -100
  150. package/dist/src/prediction/generated/bucket_v2_framework/account.js +0 -129
  151. package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.d.ts +0 -6
  152. package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.js +0 -19
  153. package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.d.ts +0 -10
  154. package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.d.ts +0 -36
  155. package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.js +0 -27
  156. package/dist/src/prediction/generated/bucket_v2_framework/double.d.ts +0 -382
  157. package/dist/src/prediction/generated/bucket_v2_framework/double.js +0 -466
  158. package/dist/src/prediction/generated/bucket_v2_framework/float.d.ts +0 -362
  159. package/dist/src/prediction/generated/bucket_v2_framework/float.js +0 -440
  160. package/dist/src/prediction/generated/bucket_v2_framework/liability.d.ts +0 -193
  161. package/dist/src/prediction/generated/bucket_v2_framework/liability.js +0 -205
  162. package/dist/src/prediction/generated/bucket_v2_framework/linked_table.d.ts +0 -384
  163. package/dist/src/prediction/generated/bucket_v2_framework/linked_table.js +0 -382
  164. package/dist/src/prediction/generated/bucket_v2_framework/sheet.d.ts +0 -344
  165. package/dist/src/prediction/generated/bucket_v2_framework/sheet.js +0 -338
  166. package/dist/src/prediction/generated/utils/index.d.ts +0 -30
  167. package/dist/src/prediction/generated/utils/index.js +0 -160
  168. package/dist/src/prediction/generated/waterx_account/account.d.ts +0 -1589
  169. package/dist/src/prediction/generated/waterx_account/account.js +0 -1758
  170. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.d.ts +0 -7
  171. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.js +0 -13
  172. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.d.ts +0 -7
  173. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.js +0 -16
  174. package/dist/src/prediction/generated/waterx_account/deps/std/type_name.d.ts +0 -6
  175. package/dist/src/prediction/generated/waterx_account/deps/std/type_name.js +0 -19
  176. package/dist/src/prediction/generated/waterx_account/deps/sui/balance.d.ts +0 -10
  177. package/dist/src/prediction/generated/waterx_account/deps/sui/balance.js +0 -14
  178. package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.d.ts +0 -12
  179. package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.js +0 -19
  180. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.d.ts +0 -36
  181. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.js +0 -27
  182. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.d.ts +0 -16
  183. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.js +0 -19
  184. package/dist/src/prediction/generated/waterx_account/direct_rule.d.ts +0 -75
  185. package/dist/src/prediction/generated/waterx_account/direct_rule.js +0 -78
  186. package/dist/src/prediction/generated/waterx_account/events.d.ts +0 -33
  187. package/dist/src/prediction/generated/waterx_account/events.js +0 -137
  188. package/dist/src/prediction/generated/waterx_account/version.js +0 -8
  189. package/dist/src/prediction/generated/waterx_prediction/bet_sharing.d.ts +0 -60
  190. package/dist/src/prediction/generated/waterx_prediction/bet_sharing.js +0 -83
  191. package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.js +0 -14
  192. package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.d.ts +0 -24
  193. package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.js +0 -31
  194. package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.d.ts +0 -16
  195. package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.js +0 -19
  196. package/dist/src/prediction/generated/waterx_prediction/events.d.ts +0 -22
  197. package/dist/src/prediction/generated/waterx_prediction/version.d.ts +0 -10
  198. package/dist/src/tx-builders.d.ts +0 -296
  199. package/dist/src/tx-builders.js +0 -461
  200. package/dist/src/user/index.d.ts +0 -8
  201. package/dist/src/user/index.js +0 -8
  202. package/dist/src/utils/pyth.d.ts +0 -124
  203. package/dist/src/utils/pyth.js +0 -392
  204. /package/dist/src/{utils → account}/account-request.js +0 -0
  205. /package/dist/src/{core → account}/waterx-account.d.ts +0 -0
  206. /package/dist/src/{core → account}/waterx-account.js +0 -0
  207. /package/dist/src/{prediction/generated → generated}/waterx_prediction/account_data.js +0 -0
  208. /package/dist/src/{prediction/generated → generated}/waterx_prediction/admin.js +0 -0
  209. /package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/bucket_v2_framework/linked_table.d.ts +0 -0
  210. /package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/bucket_v2_framework/linked_table.js +0 -0
  211. /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/balance.js +0 -0
  212. /package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/deps/sui/table.js +0 -0
  213. /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/vec_set.d.ts +0 -0
  214. /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/vec_set.js +0 -0
  215. /package/dist/src/{prediction/generated → generated}/waterx_prediction/global_config.js +0 -0
  216. /package/dist/src/{prediction/generated → generated}/waterx_prediction/order.js +0 -0
  217. /package/dist/src/{prediction/generated → generated}/waterx_prediction/outcome.d.ts +0 -0
  218. /package/dist/src/{prediction/generated → generated}/waterx_prediction/outcome.js +0 -0
  219. /package/dist/src/{prediction/generated → generated}/waterx_prediction/position.js +0 -0
  220. /package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/version.d.ts +0 -0
  221. /package/dist/src/{prediction/generated → generated}/waterx_prediction/version.js +0 -0
  222. /package/dist/src/{prediction/generated → generated}/waterx_prediction/view.js +0 -0
@@ -1,6 +1,6 @@
1
1
  import { bcs } from "@mysten/sui/bcs";
2
2
  import { Transaction } from "@mysten/sui/transactions";
3
- import { createAccountCall } from "../core/waterx-account.js";
3
+ import { addDelegate as sharedAddDelegate, createAccount as sharedCreateAccount, removeDelegate as sharedRemoveDelegate, requestDeposit as sharedRequestDeposit, requestDepositFromReceivings as sharedRequestDepositFromReceivings, requestWithdraw as sharedRequestWithdraw, transferToAccount as sharedTransferToAccount, } from "../account/account.js";
4
4
  import { extractReturnBytes } from "./fetch.js";
5
5
  import { clockArg, createAccountRequest, idArg, objectArg, receivingCoinArg, resolveAccountRegistry, resolvePackageId, toBigInt, } from "./utils.js";
6
6
  function accountPackage(client, packageId) {
@@ -20,36 +20,29 @@ export async function resolveRegistryAccountId(client, accountObjectId, params =
20
20
  return bcs.Address.parse(extractReturnBytes(result));
21
21
  }
22
22
  export function createAccount(client, tx, params) {
23
- const senderRequest = createAccountRequest(client, tx, params);
24
- return createAccountCall(tx, {
25
- packageId: accountPackage(client, params.accountPackageId),
26
- registry: resolveAccountRegistry(client, params.accountRegistry),
27
- }, { senderRequest, alias: params.alias });
23
+ // Delegates to the shared account/ builder — `waterx_account` is a single shared
24
+ // contract, so the account id + registry are identical across lines. (The
25
+ // per-call package/registry overrides are moot with one package.)
26
+ return sharedCreateAccount(client, tx, {
27
+ alias: params.alias,
28
+ bucketAccount: params.bucketAccount,
29
+ });
28
30
  }
29
31
  export function transferCoinToAccount(client, tx, params) {
30
- tx.moveCall({
31
- target: `${accountPackage(client, params.accountPackageId)}::account::transfer_coin`,
32
- typeArguments: [params.coinType ?? client.settlementCoinType()],
33
- arguments: [
34
- tx.object(resolveAccountRegistry(client, params.accountRegistry)),
35
- idArg(tx, params.accountId),
36
- objectArg(tx, params.coin),
37
- ],
32
+ sharedTransferToAccount(client, tx, {
33
+ accountId: params.accountId,
34
+ coin: objectArg(tx, params.coin),
35
+ coinType: params.coinType ?? client.settlementCoinType(),
38
36
  });
39
37
  return tx;
40
38
  }
41
39
  export function requestDeposit(client, tx, params) {
42
- const [request] = tx.moveCall({
43
- target: `${accountPackage(client, params.accountPackageId)}::account::request_deposit`,
44
- typeArguments: [params.coinType ?? client.settlementCoinType()],
45
- arguments: [
46
- tx.object(resolveAccountRegistry(client, params.accountRegistry)),
47
- idArg(tx, params.accountId),
48
- objectArg(tx, params.coin),
49
- tx.pure.vector("u8", Array.from(params.extraData ?? [])),
50
- ],
40
+ return sharedRequestDeposit(client, tx, {
41
+ accountId: params.accountId,
42
+ coin: objectArg(tx, params.coin),
43
+ coinType: params.coinType ?? client.settlementCoinType(),
44
+ extraData: params.extraData == null ? undefined : Uint8Array.from(params.extraData),
51
45
  });
52
- return request;
53
46
  }
54
47
  /** Finishes a `request_deposit` hot potato via `direct_rule` (same-coin credit). */
55
48
  export function consumeDepositDirect(client, tx, params) {
@@ -78,39 +71,22 @@ export function deposit(client, tx, params) {
78
71
  return tx;
79
72
  }
80
73
  export function requestDepositFromReceivings(client, tx, params) {
81
- const coinType = params.coinType ?? client.settlementCoinType();
82
- const receivings = params.coins.map((coin) => receivingCoinArg(tx, coin));
83
- const [request] = tx.moveCall({
84
- target: `${accountPackage(client, params.accountPackageId)}::account::request_deposit_from_receivings`,
85
- typeArguments: [coinType],
86
- arguments: [
87
- tx.object(resolveAccountRegistry(client, params.accountRegistry)),
88
- idArg(tx, params.accountId),
89
- tx.makeMoveVec({
90
- type: `0x2::transfer::Receiving<0x2::coin::Coin<${coinType}>>`,
91
- elements: receivings,
92
- }),
93
- tx.pure.vector("u8", Array.from(params.extraData ?? [])),
94
- ],
74
+ return sharedRequestDepositFromReceivings(client, tx, {
75
+ accountId: params.accountId,
76
+ receivings: params.coins.map((coin) => receivingCoinArg(tx, coin)),
77
+ coinType: params.coinType ?? client.settlementCoinType(),
78
+ extraData: params.extraData == null ? undefined : Uint8Array.from(params.extraData),
95
79
  });
96
- return request;
97
80
  }
98
81
  export function requestWithdraw(client, tx, params) {
99
- const senderRequest = createAccountRequest(client, tx, params);
100
- const [request] = tx.moveCall({
101
- target: `${accountPackage(client, params.accountPackageId)}::account::request_withdraw`,
102
- typeArguments: [params.coinType ?? client.settlementCoinType()],
103
- arguments: [
104
- tx.object(resolveAccountRegistry(client, params.accountRegistry)),
105
- senderRequest,
106
- idArg(tx, params.accountId),
107
- tx.pure.u64(toBigInt(params.amount)),
108
- tx.pure.address(params.recipient),
109
- tx.pure.vector("u8", Array.from(params.extraData ?? [])),
110
- clockArg(tx),
111
- ],
82
+ return sharedRequestWithdraw(client, tx, {
83
+ accountId: params.accountId,
84
+ amount: toBigInt(params.amount),
85
+ recipient: params.recipient,
86
+ coinType: params.coinType ?? client.settlementCoinType(),
87
+ extraData: params.extraData == null ? undefined : Uint8Array.from(params.extraData),
88
+ bucketAccount: params.bucketAccount,
112
89
  });
113
- return request;
114
90
  }
115
91
  /** Finishes a `request_withdraw` hot potato via `direct_rule` (same-coin payout). */
116
92
  export function consumeWithdrawDirect(client, tx, params) {
@@ -139,33 +115,21 @@ export function withdraw(client, tx, params) {
139
115
  return tx;
140
116
  }
141
117
  export function addDelegate(client, tx, params) {
142
- const senderRequest = createAccountRequest(client, tx, params);
143
- tx.moveCall({
144
- target: `${accountPackage(client, params.accountPackageId)}::account::add_delegate`,
145
- arguments: [
146
- tx.object(resolveAccountRegistry(client, params.accountRegistry)),
147
- senderRequest,
148
- idArg(tx, params.accountId),
149
- tx.pure.address(params.delegate),
150
- tx.pure.string(params.alias),
151
- tx.pure.u32(params.permissions),
152
- tx.pure.option("u64", params.expiresAtMs == null ? null : toBigInt(params.expiresAtMs)),
153
- clockArg(tx),
154
- ],
118
+ sharedAddDelegate(client, tx, {
119
+ accountId: params.accountId,
120
+ delegateAddress: params.delegate,
121
+ alias: params.alias,
122
+ permissions: params.permissions,
123
+ expiresAtMs: params.expiresAtMs == null ? undefined : toBigInt(params.expiresAtMs),
124
+ bucketAccount: params.bucketAccount,
155
125
  });
156
126
  return tx;
157
127
  }
158
128
  export function removeDelegate(client, tx, params) {
159
- const senderRequest = createAccountRequest(client, tx, params);
160
- tx.moveCall({
161
- target: `${accountPackage(client, params.accountPackageId)}::account::remove_delegate`,
162
- arguments: [
163
- tx.object(resolveAccountRegistry(client, params.accountRegistry)),
164
- senderRequest,
165
- idArg(tx, params.accountId),
166
- tx.pure.address(params.delegate),
167
- clockArg(tx),
168
- ],
129
+ sharedRemoveDelegate(client, tx, {
130
+ accountId: params.accountId,
131
+ delegateAddress: params.delegate,
132
+ bucketAccount: params.bucketAccount,
169
133
  });
170
134
  return tx;
171
135
  }
@@ -1,7 +1,5 @@
1
- import type { SuiClientTypes } from "@mysten/sui/client";
2
- import type { Signer } from "@mysten/sui/cryptography";
3
- import { SuiGrpcClient } from "@mysten/sui/grpc";
4
1
  import type { Transaction } from "@mysten/sui/transactions";
2
+ import { BaseLineClient } from "../base-client.ts";
5
3
  import { type LoadConfigOptions, type WaterxPredictionConfig } from "./config.ts";
6
4
  import type { Network } from "./constants.ts";
7
5
  export interface CreateClientOptions extends LoadConfigOptions {
@@ -9,13 +7,7 @@ export interface CreateClientOptions extends LoadConfigOptions {
9
7
  /** Settlement alias in `packages.waterx_prediction.*` maps. Default: "USD". */
10
8
  settlement?: string;
11
9
  }
12
- export declare class PredictClient {
13
- /** gRPC client - all RPC including `simulateTransaction`. */
14
- grpcClient: SuiGrpcClient;
15
- /** Network identifier in upper case (`MAINNET` / `TESTNET`). */
16
- network: Network;
17
- /** Parsed canonical `waterx-config` JSON. */
18
- config: WaterxPredictionConfig;
10
+ export declare class PredictClient extends BaseLineClient<WaterxPredictionConfig> {
19
11
  /** Default settlement alias for prediction registry lookups. */
20
12
  settlement: string;
21
13
  constructor(network: Network, config: WaterxPredictionConfig, opts?: {
@@ -29,36 +21,14 @@ export declare class PredictClient {
29
21
  * a ready-to-use client. Pass `opts.cache=true` to memoize the JSON.
30
22
  */
31
23
  static create(network?: Network, opts?: CreateClientOptions): Promise<PredictClient>;
32
- getObject(objectId: string): Promise<SuiClientTypes.GetObjectResponse<{}>>;
33
- getObjects(objectIds: string[]): Promise<SuiClientTypes.GetObjectsResponse<{}>>;
34
- listOwnedObjects(owner: string): Promise<SuiClientTypes.ListOwnedObjectsResponse<{}>>;
35
- listCoins(params: {
36
- owner: string;
37
- coinType?: string;
38
- }): Promise<SuiClientTypes.ListCoinsResponse>;
39
- getBalance(params: {
40
- owner: string;
41
- coinType?: string;
42
- }): Promise<SuiClientTypes.GetBalanceResponse>;
43
- listDynamicFields(parentId: string): ReturnType<SuiGrpcClient["listDynamicFields"]>;
44
- getDynamicField(parentId: string, name: {
45
- type: string;
46
- bcs: Uint8Array;
47
- }): Promise<SuiClientTypes.GetDynamicFieldResponse>;
48
- waitForTransaction(digest: string): Promise<SuiClientTypes.TransactionResult<{}>>;
49
- simulate(tx: Transaction): Promise<SuiClientTypes.SimulateTransactionResult<{
24
+ /**
25
+ * Simulate with rate-limit retry — the prediction line hammers the public
26
+ * testnet RPC harder (batch claims / dual-path reads), so it backs off on
27
+ * `RESOURCE_EXHAUSTED` where the base client does not.
28
+ */
29
+ simulate(tx: Transaction): Promise<import("@mysten/sui/client").SuiClientTypes.SimulateTransactionResult<{
50
30
  commandResults: true;
51
31
  }>>;
52
- signAndExecuteTransaction<Include extends SuiClientTypes.TransactionInclude = object>(params: {
53
- signer: {
54
- toSuiAddress: () => string;
55
- } & Signer;
56
- transaction: Transaction | Uint8Array;
57
- additionalSignatures?: string[];
58
- include?: Include & SuiClientTypes.TransactionInclude;
59
- }): Promise<SuiClientTypes.TransactionResult<Include & SuiClientTypes.TransactionInclude>>;
60
- /** All package IDs (`published_at`) keyed by package name. */
61
- packageIds(): Record<string, string>;
62
32
  packageId(): string;
63
33
  bucketFrameworkPackageId(): string;
64
34
  waterxAccountPackageId(): string;
@@ -1,27 +1,11 @@
1
- import { SuiGrpcClient } from "@mysten/sui/grpc";
2
- import { loadConfig, } from "./config.js";
3
- const GRPC_URLS = {
4
- MAINNET: "https://fullnode.mainnet.sui.io:443",
5
- TESTNET: "https://fullnode.testnet.sui.io:443",
6
- };
7
- export class PredictClient {
8
- /** gRPC client - all RPC including `simulateTransaction`. */
9
- grpcClient;
10
- /** Network identifier in upper case (`MAINNET` / `TESTNET`). */
11
- network;
12
- /** Parsed canonical `waterx-config` JSON. */
13
- config;
1
+ import { BaseLineClient } from "../base-client.js";
2
+ import { loadConfig } from "./config.js";
3
+ export class PredictClient extends BaseLineClient {
14
4
  /** Default settlement alias for prediction registry lookups. */
15
5
  settlement;
16
6
  constructor(network, config, opts = {}) {
17
- this.network = network;
18
- this.config = config;
7
+ super(network, config, opts);
19
8
  this.settlement = opts.settlement ?? "USD";
20
- const baseUrl = opts.grpcUrl ?? config.grpcUrl ?? GRPC_URLS[network];
21
- this.grpcClient = new SuiGrpcClient({
22
- baseUrl,
23
- network: network.toLowerCase(),
24
- });
25
9
  }
26
10
  static testnet(params = {}) {
27
11
  return PredictClient.create("TESTNET", params);
@@ -40,51 +24,17 @@ export class PredictClient {
40
24
  settlement: opts.settlement,
41
25
  });
42
26
  }
43
- getObject(objectId) {
44
- return this.grpcClient.getObject({ objectId });
45
- }
46
- getObjects(objectIds) {
47
- return this.grpcClient.getObjects({ objectIds });
48
- }
49
- listOwnedObjects(owner) {
50
- return this.grpcClient.listOwnedObjects({ owner });
51
- }
52
- listCoins(params) {
53
- return this.grpcClient.listCoins(params);
54
- }
55
- getBalance(params) {
56
- return this.grpcClient.getBalance(params);
57
- }
58
- listDynamicFields(parentId) {
59
- return this.grpcClient.listDynamicFields({ parentId });
60
- }
61
- getDynamicField(parentId, name) {
62
- return this.grpcClient.getDynamicField({ parentId, name });
63
- }
64
- waitForTransaction(digest) {
65
- return this.grpcClient.waitForTransaction({ digest });
66
- }
27
+ /**
28
+ * Simulate with rate-limit retry — the prediction line hammers the public
29
+ * testnet RPC harder (batch claims / dual-path reads), so it backs off on
30
+ * `RESOURCE_EXHAUSTED` where the base client does not.
31
+ */
67
32
  async simulate(tx) {
68
- return withRpcRetry(() => this.grpcClient.simulateTransaction({
69
- transaction: tx,
70
- include: { commandResults: true },
71
- }));
72
- }
73
- async signAndExecuteTransaction(params) {
74
- return this.grpcClient.signAndExecuteTransaction(params);
33
+ return withRpcRetry(() => super.simulate(tx));
75
34
  }
76
35
  // ========================================================
77
- // Shorthand accessors (canonical-schema lookups)
36
+ // Config-schema lookups (prediction-specific)
78
37
  // ========================================================
79
- /** All package IDs (`published_at`) keyed by package name. */
80
- packageIds() {
81
- const out = {};
82
- for (const [name, pkg] of Object.entries(this.config.packages)) {
83
- if (isPublishedPackage(pkg))
84
- out[name] = pkg.published_at;
85
- }
86
- return out;
87
- }
88
38
  packageId() {
89
39
  return this.config.packages.waterx_prediction.published_at;
90
40
  }
@@ -125,12 +75,6 @@ export class PredictClient {
125
75
  return requireConfigValue(this.config.packages.waterx_referral, "referral_table", "packages.waterx_referral.referral_table");
126
76
  }
127
77
  }
128
- function isPublishedPackage(value) {
129
- return (!!value &&
130
- typeof value === "object" &&
131
- "published_at" in value &&
132
- typeof value.published_at === "string");
133
- }
134
78
  function requireConfigValue(map, key, path) {
135
79
  const value = map?.[key];
136
80
  if (typeof value !== "string" || value.length === 0) {
@@ -46,8 +46,18 @@ export interface WaterxPredictionConfig {
46
46
  packages: WaterxPredictionConfigPackages;
47
47
  }
48
48
  export interface LoadConfigOptions {
49
- /** Override the default waterx-config raw JSON URL. */
49
+ /**
50
+ * Override the default waterx-config raw JSON URL. Use this to point at a
51
+ * local mirror during development. Takes precedence over {@link configRef}.
52
+ */
50
53
  configUrl?: string;
54
+ /**
55
+ * Pin the canonical config to a specific git ref — a commit SHA, branch, or
56
+ * tag — instead of the default `main` branch. Resolves to
57
+ * `https://raw.githubusercontent.com/WaterXProtocol/waterx-config/<ref>/<network>.json`.
58
+ * Ignored when {@link configUrl} is set.
59
+ */
60
+ configRef?: string;
51
61
  /** Reuse a previously fetched config in memory. Default: false. */
52
62
  cache?: boolean;
53
63
  /** Optional fetch implementation for tests or runtimes without global fetch. */
@@ -55,6 +65,10 @@ export interface LoadConfigOptions {
55
65
  /** Request timeout in ms. Default: 10_000. */
56
66
  timeoutMs?: number;
57
67
  }
58
- export declare function defaultConfigUrl(network: Network): string;
68
+ /**
69
+ * Build the canonical config URL for `network`, optionally pinned to a
70
+ * specific git `ref` (commit SHA, branch, or tag). Defaults to `main`.
71
+ */
72
+ export declare function defaultConfigUrl(network: Network, ref?: string): string;
59
73
  export declare function clearConfigCache(): void;
60
74
  export declare function loadConfig(network: Network, opts?: LoadConfigOptions): Promise<WaterxPredictionConfig>;
@@ -4,16 +4,22 @@
4
4
  * Mirrors the canonical `waterx-config` JSON for the packages used by this SDK
5
5
  * and fetches it from GitHub raw by default.
6
6
  */
7
- const DEFAULT_CONFIG_URL_BASE = "https://raw.githubusercontent.com/WaterXProtocol/waterx-config/main";
8
- export function defaultConfigUrl(network) {
9
- return `${DEFAULT_CONFIG_URL_BASE}/${network.toLowerCase()}.json`;
7
+ const CONFIG_REPO_RAW_BASE = "https://raw.githubusercontent.com/WaterXProtocol/waterx-config";
8
+ /** Default git ref for the canonical config when none is pinned. */
9
+ const DEFAULT_CONFIG_REF = "main";
10
+ /**
11
+ * Build the canonical config URL for `network`, optionally pinned to a
12
+ * specific git `ref` (commit SHA, branch, or tag). Defaults to `main`.
13
+ */
14
+ export function defaultConfigUrl(network, ref = DEFAULT_CONFIG_REF) {
15
+ return `${CONFIG_REPO_RAW_BASE}/${ref}/${network.toLowerCase()}.json`;
10
16
  }
11
17
  const configCache = new Map();
12
18
  export function clearConfigCache() {
13
19
  configCache.clear();
14
20
  }
15
21
  export async function loadConfig(network, opts = {}) {
16
- const url = opts.configUrl ?? defaultConfigUrl(network);
22
+ const url = opts.configUrl ?? defaultConfigUrl(network, opts.configRef);
17
23
  if (opts.cache && configCache.has(url)) {
18
24
  return configCache.get(url);
19
25
  }
@@ -10,20 +10,20 @@ export { addDelegate, allowPredictionProtocolAsset, consumeDepositDirect, consum
10
10
  export type { AddDelegateParams, ConsumeDepositDirectParams, CreateAccountParams, ConsumeWithdrawDirectParams, PredictionProtocolAssetParams, RemoveDelegateParams, RequestDepositFromReceivingsParams, RequestDepositParams, RequestWithdrawParams, SetDelegatePredictionPermissionParams, TransferCoinToAccountParams, WhitelistPredictionProtocolParams, } from "./account.ts";
11
11
  export { addKeeper, adminWithdraw, createMarketRegistry, depositSettlement, pauseMarket, removeKeeper, setMinReserve, setOrderCancelCooldownMs, unpauseMarket, } from "./admin.ts";
12
12
  export type { AdminWithdrawParams, CreateMarketRegistryParams, DepositSettlementParams, KeeperAdminParams, MarketPauseParams, SetMinReserveParams, SetOrderCancelCooldownParams, } from "./admin.ts";
13
- export { adminPlaceOrderFor, batchClaim, batchForceClaim, buildBatchForceClaimTransactions, cancelClose, cancelOrder, claim, confirmClose, fillOrder, forceClaim, outcomeArg, placeOrder, requestClose, resolveMarket, selectionArg, selfCancelClose, selfCancelOrder, } from "./prediction.ts";
14
- export type { AdminPlaceOrderForParams, BatchClaimParams, BatchForceClaimParams, BuildBatchForceClaimTransactionsParams, CancelCloseParams, CancelOrderParams, ClaimParams, ConfirmCloseParams, FillOrderParams, ForceClaimParams, PlaceOrderParams, RequestCloseParams, ResolveMarketParams, SelfCancelCloseParams, SelfCancelOrderParams, } from "./prediction.ts";
13
+ export { adminPlaceOrderFor, batchClaim, batchForceClaim, buildBatchForceClaimTransactions, cancelClose, cancelOrder, claim, confirmClose, fillOrder, forceClaim, outcomeArg, placeOrder, requestClose, requestPartialClose, resolveMarket, selectionArg, selfCancelClose, selfCancelOrder, splitPosition, transferPosition, } from "./prediction.ts";
14
+ export type { AdminPlaceOrderForParams, BatchClaimParams, BatchForceClaimParams, BuildBatchForceClaimTransactionsParams, CancelCloseParams, CancelOrderParams, ClaimParams, ConfirmCloseParams, FillOrderParams, ForceClaimParams, PlaceOrderParams, RequestCloseParams, RequestPartialCloseParams, ResolveMarketParams, SelfCancelCloseParams, SelfCancelOrderParams, SplitPositionParams, TransferPositionParams, } from "./prediction.ts";
15
15
  export { buildBatchClaimTx, buildPlaceOrderTx } from "./tx-builders.ts";
16
16
  export type { BuildBatchClaimTxParams, BuildPlaceOrderTxParams, PredictCommonBuildOpts, } from "./tx-builders.ts";
17
17
  export { getAccountData, getAccountIds, getAccountOrderIds, getAccountOrderIdsByMarketId, getAccountPositionIds, getAccountPositionIdsByMarketId, getKeeperAddresses, getAllowedVersions, getMarketExposure, getMarketExposureByKey, getMarketById, getMarketByKey, getOrder, getOrderCursor, getPosition, getPositionCursor, getRegistry, getResolvedMarketCursor, getUnresolvedMarketCursor, isKeeper, isPredictionProtocolAssetAllowed, } from "./fetch.ts";
18
18
  export type { GetAccountIdsParams, ViewBaseParams } from "./fetch.ts";
19
19
  export { base64UrlNoPadDecode, base64UrlNoPadEncode, buildClaimShareFlow, buildCreateGiftFlow, buildGiftClaimMessage, claimShare, createGift, deleteGift, deriveGiftAddress, deriveGiftKeypair, encodeGiftUrl, generateGiftSeed, getCreatorGiftCount, getCreatorGiftIds, getGift, getGiftConfigPaused, getGiftControllerAddress, getGiftHasClaimed, parseGiftUrl, signGiftClaim, } from "./gift.ts";
20
20
  export type { BuildClaimShareFlowParams, BuildClaimShareFlowResult, BuildCreateGiftFlowResult, ClaimShareParams, CreateGiftParams, DeleteGiftParams, GiftBaseParams, GiftReferralParams, GiftUrlParts, GiftView, } from "./gift.ts";
21
- export * as bucketFrameworkAccountCalls from "./generated/bucket_v2_framework/account.ts";
22
- export * as waterxAccountCalls from "./generated/waterx_account/account.ts";
23
- export * as predictionAccountDataCalls from "./generated/waterx_prediction/account_data.ts";
24
- export * as predictionGlobalConfigCalls from "./generated/waterx_prediction/global_config.ts";
25
- export * as predictionOutcomeCalls from "./generated/waterx_prediction/outcome.ts";
26
- export * as predictionPositionCalls from "./generated/waterx_prediction/position.ts";
27
- export * as predictionVersionCalls from "./generated/waterx_prediction/version.ts";
28
- export * as predictionViewCalls from "./generated/waterx_prediction/view.ts";
29
- export * as predictionCalls from "./generated/waterx_prediction/waterx_prediction.ts";
21
+ export * as bucketFrameworkAccountCalls from "../generated/bucket_v2_framework/account.ts";
22
+ export * as waterxAccountCalls from "../generated/waterx_account/account.ts";
23
+ export * as predictionAccountDataCalls from "../generated/waterx_prediction/account_data.ts";
24
+ export * as predictionGlobalConfigCalls from "../generated/waterx_prediction/global_config.ts";
25
+ export * as predictionOutcomeCalls from "../generated/waterx_prediction/outcome.ts";
26
+ export * as predictionPositionCalls from "../generated/waterx_prediction/position.ts";
27
+ export * as predictionVersionCalls from "../generated/waterx_prediction/version.ts";
28
+ export * as predictionViewCalls from "../generated/waterx_prediction/view.ts";
29
+ export * as predictionCalls from "../generated/waterx_prediction/waterx_prediction.ts";
@@ -6,16 +6,16 @@ export * as user from "./user/index.js";
6
6
  export * as utils from "./utils/index.js";
7
7
  export { addDelegate, allowPredictionProtocolAsset, consumeDepositDirect, consumeWithdrawDirect, createAccount, deposit, disallowPredictionProtocolAsset, removeDelegate, resolveRegistryAccountId, requestDeposit, requestDepositFromReceivings, requestWithdraw, setDelegatePredictionPermission, transferCoinToAccount, whitelistPredictionProtocol, withdraw, } from "./account.js";
8
8
  export { addKeeper, adminWithdraw, createMarketRegistry, depositSettlement, pauseMarket, removeKeeper, setMinReserve, setOrderCancelCooldownMs, unpauseMarket, } from "./admin.js";
9
- export { adminPlaceOrderFor, batchClaim, batchForceClaim, buildBatchForceClaimTransactions, cancelClose, cancelOrder, claim, confirmClose, fillOrder, forceClaim, outcomeArg, placeOrder, requestClose, resolveMarket, selectionArg, selfCancelClose, selfCancelOrder, } from "./prediction.js";
9
+ export { adminPlaceOrderFor, batchClaim, batchForceClaim, buildBatchForceClaimTransactions, cancelClose, cancelOrder, claim, confirmClose, fillOrder, forceClaim, outcomeArg, placeOrder, requestClose, requestPartialClose, resolveMarket, selectionArg, selfCancelClose, selfCancelOrder, splitPosition, transferPosition, } from "./prediction.js";
10
10
  export { buildBatchClaimTx, buildPlaceOrderTx } from "./tx-builders.js";
11
11
  export { getAccountData, getAccountIds, getAccountOrderIds, getAccountOrderIdsByMarketId, getAccountPositionIds, getAccountPositionIdsByMarketId, getKeeperAddresses, getAllowedVersions, getMarketExposure, getMarketExposureByKey, getMarketById, getMarketByKey, getOrder, getOrderCursor, getPosition, getPositionCursor, getRegistry, getResolvedMarketCursor, getUnresolvedMarketCursor, isKeeper, isPredictionProtocolAssetAllowed, } from "./fetch.js";
12
12
  export { base64UrlNoPadDecode, base64UrlNoPadEncode, buildClaimShareFlow, buildCreateGiftFlow, buildGiftClaimMessage, claimShare, createGift, deleteGift, deriveGiftAddress, deriveGiftKeypair, encodeGiftUrl, generateGiftSeed, getCreatorGiftCount, getCreatorGiftIds, getGift, getGiftConfigPaused, getGiftControllerAddress, getGiftHasClaimed, parseGiftUrl, signGiftClaim, } from "./gift.js";
13
- export * as bucketFrameworkAccountCalls from "./generated/bucket_v2_framework/account.js";
14
- export * as waterxAccountCalls from "./generated/waterx_account/account.js";
15
- export * as predictionAccountDataCalls from "./generated/waterx_prediction/account_data.js";
16
- export * as predictionGlobalConfigCalls from "./generated/waterx_prediction/global_config.js";
17
- export * as predictionOutcomeCalls from "./generated/waterx_prediction/outcome.js";
18
- export * as predictionPositionCalls from "./generated/waterx_prediction/position.js";
19
- export * as predictionVersionCalls from "./generated/waterx_prediction/version.js";
20
- export * as predictionViewCalls from "./generated/waterx_prediction/view.js";
21
- export * as predictionCalls from "./generated/waterx_prediction/waterx_prediction.js";
13
+ export * as bucketFrameworkAccountCalls from "../generated/bucket_v2_framework/account.js";
14
+ export * as waterxAccountCalls from "../generated/waterx_account/account.js";
15
+ export * as predictionAccountDataCalls from "../generated/waterx_prediction/account_data.js";
16
+ export * as predictionGlobalConfigCalls from "../generated/waterx_prediction/global_config.js";
17
+ export * as predictionOutcomeCalls from "../generated/waterx_prediction/outcome.js";
18
+ export * as predictionPositionCalls from "../generated/waterx_prediction/position.js";
19
+ export * as predictionVersionCalls from "../generated/waterx_prediction/version.js";
20
+ export * as predictionViewCalls from "../generated/waterx_prediction/view.js";
21
+ export * as predictionCalls from "../generated/waterx_prediction/waterx_prediction.js";
@@ -44,10 +44,55 @@ export interface RequestCloseParams extends BasePredictionParams, AccountIdentit
44
44
  expiryTs: bigint | number | string;
45
45
  }
46
46
  export declare function requestClose(client: PredictClient, tx: Transaction, params: RequestCloseParams): Transaction;
47
+ export interface RequestPartialCloseParams extends BasePredictionParams, AccountIdentityParams {
48
+ positionId: bigint | number | string;
49
+ /**
50
+ * Shares to peel off `positionId` into a new same-account position that is
51
+ * then closed. Must be `0 < closeShares < filled_shares` of the position.
52
+ */
53
+ closeShares: bigint | number | string;
54
+ minProceeds: bigint | number | string;
55
+ expiryTs: bigint | number | string;
56
+ }
57
+ /**
58
+ * Account-backed partial sell. Splits `closeShares` off `positionId` into a new
59
+ * same-account position and runs the close flow on it; the remainder stays
60
+ * `Open` under `positionId`. The on-chain call returns the new PendingClose
61
+ * position id (read it from events / the returned move-call result if needed).
62
+ */
63
+ export declare function requestPartialClose(client: PredictClient, tx: Transaction, params: RequestPartialCloseParams): Transaction;
47
64
  export interface SelfCancelCloseParams extends BasePredictionParams, AccountIdentityParams {
48
65
  positionId: bigint | number | string;
49
66
  }
50
67
  export declare function selfCancelClose(client: PredictClient, tx: Transaction, params: SelfCancelCloseParams): Transaction;
68
+ export interface TransferPositionParams extends BasePredictionParams, AccountIdentityParams {
69
+ positionId: bigint | number | string;
70
+ /** WXA account that receives the position; future close/claim proceeds go there. */
71
+ recipientAccountId: IdArgument;
72
+ }
73
+ /**
74
+ * Account-backed position transfer. The source account owner moves an open
75
+ * prediction position to another WXA account. Aborts if the position has a
76
+ * pending close.
77
+ */
78
+ export declare function transferPosition(client: PredictClient, tx: Transaction, params: TransferPositionParams): Transaction;
79
+ export interface SplitPositionParams extends BasePredictionParams, AccountIdentityParams {
80
+ positionId: bigint | number | string;
81
+ /** WXA account that receives the new independent position. */
82
+ recipientAccountId: IdArgument;
83
+ /**
84
+ * Shares to split into the recipient's new position. Must be
85
+ * `0 < splitShares < filled_shares` of the source position.
86
+ */
87
+ splitShares: bigint | number | string;
88
+ }
89
+ /**
90
+ * Account-backed partial transfer. Splits an open position into two independent
91
+ * positions: the source keeps the remainder and the recipient receives a new
92
+ * position with proportional cost basis. The on-chain call returns the new
93
+ * position id (read it from events / the returned move-call result if needed).
94
+ */
95
+ export declare function splitPosition(client: PredictClient, tx: Transaction, params: SplitPositionParams): Transaction;
51
96
  export interface KeeperBaseParams extends BasePredictionParams, AccountIdentityParams {
52
97
  }
53
98
  export interface FillOrderParams extends KeeperBaseParams {
@@ -124,6 +124,31 @@ export function requestClose(client, tx, params) {
124
124
  });
125
125
  return tx;
126
126
  }
127
+ /**
128
+ * Account-backed partial sell. Splits `closeShares` off `positionId` into a new
129
+ * same-account position and runs the close flow on it; the remainder stays
130
+ * `Open` under `positionId`. The on-chain call returns the new PendingClose
131
+ * position id (read it from events / the returned move-call result if needed).
132
+ */
133
+ export function requestPartialClose(client, tx, params) {
134
+ const senderRequest = createAccountRequest(client, tx, params);
135
+ tx.moveCall({
136
+ target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::request_partial_close`,
137
+ typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
138
+ arguments: [
139
+ tx.object(resolveGlobalConfig(client, params.globalConfig)),
140
+ tx.object(resolveMarketRegistry(client, params.marketRegistry)),
141
+ tx.object(resolveAccountRegistry(client, params.accountRegistry)),
142
+ senderRequest,
143
+ tx.pure.u64(toBigInt(params.positionId)),
144
+ tx.pure.u64(toBigInt(params.closeShares)),
145
+ tx.pure.u64(toBigInt(params.minProceeds)),
146
+ tx.pure.u64(toBigInt(params.expiryTs)),
147
+ clockArg(tx),
148
+ ],
149
+ });
150
+ return tx;
151
+ }
127
152
  export function selfCancelClose(client, tx, params) {
128
153
  const senderRequest = createAccountRequest(client, tx, params);
129
154
  tx.moveCall({
@@ -140,6 +165,52 @@ export function selfCancelClose(client, tx, params) {
140
165
  });
141
166
  return tx;
142
167
  }
168
+ /**
169
+ * Account-backed position transfer. The source account owner moves an open
170
+ * prediction position to another WXA account. Aborts if the position has a
171
+ * pending close.
172
+ */
173
+ export function transferPosition(client, tx, params) {
174
+ const senderRequest = createAccountRequest(client, tx, params);
175
+ tx.moveCall({
176
+ target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::transfer_position`,
177
+ typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
178
+ arguments: [
179
+ tx.object(resolveGlobalConfig(client, params.globalConfig)),
180
+ tx.object(resolveMarketRegistry(client, params.marketRegistry)),
181
+ tx.object(resolveAccountRegistry(client, params.accountRegistry)),
182
+ senderRequest,
183
+ tx.pure.u64(toBigInt(params.positionId)),
184
+ idArg(tx, params.recipientAccountId),
185
+ clockArg(tx),
186
+ ],
187
+ });
188
+ return tx;
189
+ }
190
+ /**
191
+ * Account-backed partial transfer. Splits an open position into two independent
192
+ * positions: the source keeps the remainder and the recipient receives a new
193
+ * position with proportional cost basis. The on-chain call returns the new
194
+ * position id (read it from events / the returned move-call result if needed).
195
+ */
196
+ export function splitPosition(client, tx, params) {
197
+ const senderRequest = createAccountRequest(client, tx, params);
198
+ tx.moveCall({
199
+ target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::split_position`,
200
+ typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
201
+ arguments: [
202
+ tx.object(resolveGlobalConfig(client, params.globalConfig)),
203
+ tx.object(resolveMarketRegistry(client, params.marketRegistry)),
204
+ tx.object(resolveAccountRegistry(client, params.accountRegistry)),
205
+ senderRequest,
206
+ tx.pure.u64(toBigInt(params.positionId)),
207
+ idArg(tx, params.recipientAccountId),
208
+ tx.pure.u64(toBigInt(params.splitShares)),
209
+ clockArg(tx),
210
+ ],
211
+ });
212
+ return tx;
213
+ }
143
214
  export function fillOrder(client, tx, params) {
144
215
  const keeperRequest = createAccountRequest(client, tx, params);
145
216
  tx.moveCall({
@@ -2,14 +2,14 @@
2
2
  * Async high-level prediction PTB builders with optional pre-sweep of parked
3
3
  * backing assets into wxUSD credit ({@link appendConsolidateForSpend}).
4
4
  *
5
- * Takes both `WaterXClient` (native_custody / consolidate) and `PredictClient`
5
+ * Takes both `AccountClientLike` (native_custody / consolidate) and `PredictClient`
6
6
  * because sync prediction builders only target the prediction deployment.
7
7
  *
8
8
  * FE/BE tx services should call these instead of hand-composing
9
9
  * `appendConsolidateForSpend` before `placeOrder` / `batchClaim`.
10
10
  */
11
11
  import { Transaction } from "@mysten/sui/transactions";
12
- import type { WaterXClient } from "../client.ts";
12
+ import type { AccountClientLike } from "../account/client.ts";
13
13
  import type { PredictClient } from "./client.ts";
14
14
  import { type BatchClaimParams, type PlaceOrderParams } from "./prediction.ts";
15
15
  export interface PredictCommonBuildOpts {
@@ -37,8 +37,8 @@ export interface BuildBatchClaimTxParams extends BatchClaimParams, PredictCommon
37
37
  * @param perpClient — perp deployment (native_custody probe + PSM mint legs)
38
38
  * @param predictClient — prediction deployment (place_order MoveCall)
39
39
  */
40
- export declare function buildPlaceOrderTx(perpClient: WaterXClient, predictClient: PredictClient, params: BuildPlaceOrderTxParams): Promise<Transaction>;
40
+ export declare function buildPlaceOrderTx(perpClient: AccountClientLike, predictClient: PredictClient, params: BuildPlaceOrderTxParams): Promise<Transaction>;
41
41
  /**
42
42
  * Optional pre-sweep + {@link batchClaim} in one PTB.
43
43
  */
44
- export declare function buildBatchClaimTx(perpClient: WaterXClient, predictClient: PredictClient, params: BuildBatchClaimTxParams): Promise<Transaction>;
44
+ export declare function buildBatchClaimTx(perpClient: AccountClientLike, predictClient: PredictClient, params: BuildBatchClaimTxParams): Promise<Transaction>;
@@ -2,14 +2,14 @@
2
2
  * Async high-level prediction PTB builders with optional pre-sweep of parked
3
3
  * backing assets into wxUSD credit ({@link appendConsolidateForSpend}).
4
4
  *
5
- * Takes both `WaterXClient` (native_custody / consolidate) and `PredictClient`
5
+ * Takes both `AccountClientLike` (native_custody / consolidate) and `PredictClient`
6
6
  * because sync prediction builders only target the prediction deployment.
7
7
  *
8
8
  * FE/BE tx services should call these instead of hand-composing
9
9
  * `appendConsolidateForSpend` before `placeOrder` / `batchClaim`.
10
10
  */
11
11
  import { Transaction } from "@mysten/sui/transactions";
12
- import { appendConsolidateForSpend } from "../tx-builders.js";
12
+ import { appendConsolidateForSpend } from "../account/funding/consolidate.js";
13
13
  import { batchClaim, placeOrder, } from "./prediction.js";
14
14
  function newTx(opts) {
15
15
  return opts?.tx ?? new Transaction();