@waterx/sdk 2.4.0 → 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 -42
  32. package/dist/src/constants.js +8 -47
  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} +22 -22
  98. package/dist/src/{index.js → perp/index.js} +22 -22
  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
@@ -0,0 +1,90 @@
1
+ /**
2
+ * High-level WLP composers: mint, mint+stake, unstake+request-redeem, and
3
+ * cancel-redeem+re-stake. The staking-coupled variants keep the product
4
+ * invariant that user-held WLP is always staked.
5
+ */
6
+ import type { Transaction } from "@mysten/sui/transactions";
7
+ import type { PerpClient } from "../client.ts";
8
+ import { type CancelRedeemWlpParams, type MintWlpParams, type RequestRedeemWlpParams } from "../user/wlp.ts";
9
+ import { type CommonBuildOpts } from "./common.ts";
10
+ export interface BuildMintWlpParams extends MintWlpParams, CommonBuildOpts {
11
+ /** Oracle ticker for the deposited token (must be a registered pool token). */
12
+ depositTicker: string;
13
+ }
14
+ /**
15
+ * Mints WLP from a deposit asset already in the wxa account's stored
16
+ * balance. Refreshes every pool-token oracle + bumps each pool token's
17
+ * `last_price_refresh_timestamp` so `assert_prices_fresh` inside
18
+ * `mint_wlp` passes.
19
+ *
20
+ * Does NOT use the pyth_sponsor flow — `mint_wlp` produces no
21
+ * `TradingRequest`, so there's nothing for the sponsor to attach its
22
+ * witness to. Pyth update fees come from `tx.gas`.
23
+ */
24
+ export declare function buildMintWlpTx(client: PerpClient, params: BuildMintWlpParams): Promise<Transaction>;
25
+ export interface BuildMintAndStakeWlpParams extends BuildMintWlpParams {
26
+ /**
27
+ * Staking pool alias (key into `waterx_staking.pools`). Defaults to `"WLP"`.
28
+ */
29
+ stakeAlias?: string;
30
+ /**
31
+ * Rewarder coin types to settle on the stake deposit. Order must match the
32
+ * pool's on-chain `rewarder_ids`. Defaults to every rewarder configured for
33
+ * the stake pool in `waterx_staking.rewarders[stakeAlias]`.
34
+ */
35
+ rewarderTypes?: string[];
36
+ }
37
+ /**
38
+ * Mints WLP and immediately stakes the minted amount into the WLP staking pool
39
+ * in the same PTB. The mint's `lp_amount` return is piped directly into the
40
+ * `stake` call so no precision loss / dust can occur.
41
+ *
42
+ * Use this instead of `buildMintWlpTx` when the product flow is "deposit USD
43
+ * and earn rewards" — un-staked WLP sitting in the wxa account's `Balance<WLP>`
44
+ * slot earns nothing.
45
+ */
46
+ export declare function buildMintAndStakeWlpTx(client: PerpClient, params: BuildMintAndStakeWlpParams): Promise<Transaction>;
47
+ export interface BuildUnstakeAndRequestRedeemWlpParams extends Omit<RequestRedeemWlpParams, "lpAmount">, CommonBuildOpts {
48
+ /** Amount of staked WLP to unstake and enqueue for redemption. */
49
+ withdrawalAmount: bigint | number;
50
+ /** Staking pool alias. Defaults to `"WLP"`. */
51
+ stakeAlias?: string;
52
+ /**
53
+ * Rewarder coin types to settle on unstake. Defaults to every rewarder
54
+ * configured for the stake pool in `waterx_staking.rewarders[stakeAlias]`.
55
+ */
56
+ rewarderTypes?: string[];
57
+ }
58
+ /**
59
+ * Unstakes WLP from the staking pool and immediately enqueues a redeem request
60
+ * in the same PTB. Mirror of `buildMintAndStakeWlpTx` for withdrawals.
61
+ *
62
+ * Refreshes every WLP pool-token oracle by default — `request_redeem` runs
63
+ * `assert_prices_fresh` internally, so a stale oracle would abort the PTB.
64
+ * Pass `skipOraclePriceRefresh: true` only when the caller is composing this
65
+ * into a larger PTB that already pre-pumps prices.
66
+ */
67
+ export declare function buildUnstakeAndRequestRedeemWlpTx(client: PerpClient, params: BuildUnstakeAndRequestRedeemWlpParams): Promise<Transaction>;
68
+ export interface BuildCancelRedeemAndStakeWlpParams extends CancelRedeemWlpParams, CommonBuildOpts {
69
+ accountId: string;
70
+ /**
71
+ * WLP amount (base units) that was originally enqueued by `request_redeem`
72
+ * and is being returned to the wxa account by `cancel_redeem` — gets
73
+ * re-staked into the WLP staking pool in the same PTB.
74
+ */
75
+ stakeAmount: bigint | number;
76
+ /** Staking pool alias. Defaults to `"WLP"`. */
77
+ stakeAlias?: string;
78
+ /**
79
+ * Rewarder coin types to settle on stake. Defaults to every rewarder
80
+ * configured for the stake pool in `waterx_staking.rewarders[stakeAlias]`.
81
+ */
82
+ rewarderTypes?: string[];
83
+ }
84
+ /**
85
+ * Cancels a pending WLP redeem request and re-stakes the returned WLP in the
86
+ * same PTB. Third partner of `buildMintAndStakeWlpTx` /
87
+ * `buildUnstakeAndRequestRedeemWlpTx`; together they keep the product
88
+ * invariant that user-held WLP is always staked.
89
+ */
90
+ export declare function buildCancelRedeemAndStakeWlpTx(client: PerpClient, params: BuildCancelRedeemAndStakeWlpParams): Transaction;
@@ -0,0 +1,120 @@
1
+ /**
2
+ * High-level WLP composers: mint, mint+stake, unstake+request-redeem, and
3
+ * cancel-redeem+re-stake. The staking-coupled variants keep the product
4
+ * invariant that user-held WLP is always staked.
5
+ */
6
+ import { stake, unstake } from "../user/staking.js";
7
+ import { cancelRedeemWlp, mintWlp, requestRedeemWlp, } from "../user/wlp.js";
8
+ import { maybeConsolidate, newTx, refreshWlpPoolOracles } from "./common.js";
9
+ /**
10
+ * Mints WLP from a deposit asset already in the wxa account's stored
11
+ * balance. Refreshes every pool-token oracle + bumps each pool token's
12
+ * `last_price_refresh_timestamp` so `assert_prices_fresh` inside
13
+ * `mint_wlp` passes.
14
+ *
15
+ * Does NOT use the pyth_sponsor flow — `mint_wlp` produces no
16
+ * `TradingRequest`, so there's nothing for the sponsor to attach its
17
+ * witness to. Pyth update fees come from `tx.gas`.
18
+ */
19
+ export async function buildMintWlpTx(client, params) {
20
+ const tx = newTx(params);
21
+ await maybeConsolidate(client, tx, params.accountId, params);
22
+ if (!params.skipOraclePriceRefresh) {
23
+ await refreshWlpPoolOracles(tx, client, [params.depositTicker], {
24
+ cache: params.pythCache,
25
+ lpType: params.lpType,
26
+ });
27
+ }
28
+ mintWlp(client, tx, params);
29
+ return tx;
30
+ }
31
+ /**
32
+ * Mints WLP and immediately stakes the minted amount into the WLP staking pool
33
+ * in the same PTB. The mint's `lp_amount` return is piped directly into the
34
+ * `stake` call so no precision loss / dust can occur.
35
+ *
36
+ * Use this instead of `buildMintWlpTx` when the product flow is "deposit USD
37
+ * and earn rewards" — un-staked WLP sitting in the wxa account's `Balance<WLP>`
38
+ * slot earns nothing.
39
+ */
40
+ export async function buildMintAndStakeWlpTx(client, params) {
41
+ const tx = newTx(params);
42
+ await maybeConsolidate(client, tx, params.accountId, params);
43
+ if (!params.skipOraclePriceRefresh) {
44
+ await refreshWlpPoolOracles(tx, client, [params.depositTicker], {
45
+ cache: params.pythCache,
46
+ lpType: params.lpType,
47
+ });
48
+ }
49
+ const stakeAlias = params.stakeAlias ?? "WLP";
50
+ const lpAmount = mintWlp(client, tx, params);
51
+ stake(client, tx, {
52
+ accountId: params.accountId,
53
+ stakeAlias,
54
+ stakeType: params.lpType ?? client.wlpType(),
55
+ stakeAmount: lpAmount,
56
+ rewarderTypes: params.rewarderTypes ?? client.getRewarderTypes(stakeAlias),
57
+ bucketAccount: params.bucketAccount,
58
+ });
59
+ return tx;
60
+ }
61
+ /**
62
+ * Unstakes WLP from the staking pool and immediately enqueues a redeem request
63
+ * in the same PTB. Mirror of `buildMintAndStakeWlpTx` for withdrawals.
64
+ *
65
+ * Refreshes every WLP pool-token oracle by default — `request_redeem` runs
66
+ * `assert_prices_fresh` internally, so a stale oracle would abort the PTB.
67
+ * Pass `skipOraclePriceRefresh: true` only when the caller is composing this
68
+ * into a larger PTB that already pre-pumps prices.
69
+ */
70
+ export async function buildUnstakeAndRequestRedeemWlpTx(client, params) {
71
+ const tx = newTx(params);
72
+ const stakeAlias = params.stakeAlias ?? "WLP";
73
+ await maybeConsolidate(client, tx, params.accountId, params);
74
+ if (!params.skipOraclePriceRefresh) {
75
+ await refreshWlpPoolOracles(tx, client, [], {
76
+ cache: params.pythCache,
77
+ lpType: params.lpType,
78
+ });
79
+ }
80
+ unstake(client, tx, {
81
+ accountId: params.accountId,
82
+ stakeAlias,
83
+ stakeType: params.lpType ?? client.wlpType(),
84
+ withdrawalAmount: params.withdrawalAmount,
85
+ rewarderTypes: params.rewarderTypes ?? client.getRewarderTypes(stakeAlias),
86
+ bucketAccount: params.bucketAccount,
87
+ });
88
+ requestRedeemWlp(client, tx, {
89
+ accountId: params.accountId,
90
+ redeemTokenType: params.redeemTokenType,
91
+ lpAmount: params.withdrawalAmount,
92
+ lpType: params.lpType,
93
+ bucketAccount: params.bucketAccount,
94
+ });
95
+ return tx;
96
+ }
97
+ /**
98
+ * Cancels a pending WLP redeem request and re-stakes the returned WLP in the
99
+ * same PTB. Third partner of `buildMintAndStakeWlpTx` /
100
+ * `buildUnstakeAndRequestRedeemWlpTx`; together they keep the product
101
+ * invariant that user-held WLP is always staked.
102
+ */
103
+ export function buildCancelRedeemAndStakeWlpTx(client, params) {
104
+ const tx = newTx(params);
105
+ const stakeAlias = params.stakeAlias ?? "WLP";
106
+ cancelRedeemWlp(client, tx, {
107
+ requestId: params.requestId,
108
+ lpType: params.lpType,
109
+ bucketAccount: params.bucketAccount,
110
+ });
111
+ stake(client, tx, {
112
+ accountId: params.accountId,
113
+ stakeAlias,
114
+ stakeType: params.lpType ?? client.wlpType(),
115
+ stakeAmount: params.stakeAmount,
116
+ rewarderTypes: params.rewarderTypes ?? client.getRewarderTypes(stakeAlias),
117
+ bucketAccount: params.bucketAccount,
118
+ });
119
+ return tx;
120
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * High-level perp transaction builders — barrel.
3
+ *
4
+ * Each `build*Tx` composer creates (or appends to) a `Transaction`, refreshes
5
+ * the on-chain `Oracle` via Pyth, optionally pre-sweeps parked balances
6
+ * (`consolidateToUsd`), wires the `pyth_sponsor_rule` flow when enabled, and
7
+ * calls the matching `*_request` + `execute`. Implementations are split by
8
+ * domain under `tx-builders/`:
9
+ *
10
+ * common.ts CommonBuildOpts + request/execute envelope + oracle refresh
11
+ * consolidate.ts parked-balance → wxUSD pre-sweep (appendConsolidate*)
12
+ * trading.ts position lifecycle + collateral + order lifecycle
13
+ * wlp.ts mint / mint+stake / unstake+redeem / cancel-redeem+restake
14
+ * rewards.ts claim staking rewards to the wxa account
15
+ * credit.ts cross-chain credit / bridge (redeem VAA, withdraw, drain)
16
+ */
17
+ export type { CommonBuildOpts } from "./tx-builders/common.ts";
18
+ export * from "../account/funding/consolidate.ts";
19
+ export * from "./tx-builders/trading.ts";
20
+ export * from "./tx-builders/wlp.ts";
21
+ export * from "./tx-builders/rewards.ts";
22
+ export * from "./tx-builders/credit.ts";
23
+ export { openPythSponsorFund, PythCache, refreshOraclePrices, reimbursePythSponsor, updatePythPrices, } from "../oracle/index.ts";
@@ -0,0 +1,23 @@
1
+ /**
2
+ * High-level perp transaction builders — barrel.
3
+ *
4
+ * Each `build*Tx` composer creates (or appends to) a `Transaction`, refreshes
5
+ * the on-chain `Oracle` via Pyth, optionally pre-sweeps parked balances
6
+ * (`consolidateToUsd`), wires the `pyth_sponsor_rule` flow when enabled, and
7
+ * calls the matching `*_request` + `execute`. Implementations are split by
8
+ * domain under `tx-builders/`:
9
+ *
10
+ * common.ts CommonBuildOpts + request/execute envelope + oracle refresh
11
+ * consolidate.ts parked-balance → wxUSD pre-sweep (appendConsolidate*)
12
+ * trading.ts position lifecycle + collateral + order lifecycle
13
+ * wlp.ts mint / mint+stake / unstake+redeem / cancel-redeem+restake
14
+ * rewards.ts claim staking rewards to the wxa account
15
+ * credit.ts cross-chain credit / bridge (redeem VAA, withdraw, drain)
16
+ */
17
+ export * from "../account/funding/consolidate.js";
18
+ export * from "./tx-builders/trading.js";
19
+ export * from "./tx-builders/wlp.js";
20
+ export * from "./tx-builders/rewards.js";
21
+ export * from "./tx-builders/credit.js";
22
+ // Oracle helpers re-exported for callers composing custom PTBs.
23
+ export { openPythSponsorFund, PythCache, refreshOraclePrices, reimbursePythSponsor, updatePythPrices, } from "../oracle/index.js";
@@ -0,0 +1,8 @@
1
+ export * from "../../account/account.ts";
2
+ export * from "../../account/funding/credit.ts";
3
+ export * from "../../account/funding/custody.ts";
4
+ export * from "./order.ts";
5
+ export * from "../../account/referral.ts";
6
+ export * from "./staking.ts";
7
+ export * from "./trading.ts";
8
+ export * from "./wlp.ts";
@@ -0,0 +1,8 @@
1
+ export * from "../../account/account.js";
2
+ export * from "../../account/funding/credit.js";
3
+ export * from "../../account/funding/custody.js";
4
+ export * from "./order.js";
5
+ export * from "../../account/referral.js";
6
+ export * from "./staking.js";
7
+ export * from "./trading.js";
8
+ export * from "./wlp.js";
@@ -9,7 +9,7 @@
9
9
  * tick 0 in the limit book; a keeper picks it up via `match_orders`.
10
10
  */
11
11
  import type { Transaction, TransactionArgument } from "@mysten/sui/transactions";
12
- import type { WaterXClient } from "../client.ts";
12
+ import type { PerpClient } from "../client.ts";
13
13
  export interface PlaceOrderArgumentParams {
14
14
  isLong: boolean;
15
15
  isStopOrder: boolean;
@@ -24,7 +24,7 @@ export interface PlaceOrderArgumentParams {
24
24
  collateralAmount: bigint | number;
25
25
  }
26
26
  /** Build a `request::PlaceOrderArgument` Move struct in the PTB. */
27
- export declare function buildPlaceOrderArgument(client: WaterXClient, tx: Transaction, p: PlaceOrderArgumentParams): TransactionArgument;
27
+ export declare function buildPlaceOrderArgument(client: PerpClient, tx: Transaction, p: PlaceOrderArgumentParams): TransactionArgument;
28
28
  export interface PlaceOrderRequestParams {
29
29
  ticker: string;
30
30
  accountId: string;
@@ -37,7 +37,7 @@ export interface PlaceOrderRequestParams {
37
37
  bucketAccount?: string | TransactionArgument;
38
38
  }
39
39
  /** Build `trading::place_order_request`. Returns the `TradingRequest<C_TOKEN>` argument. */
40
- export declare function placeOrderRequest(client: WaterXClient, tx: Transaction, params: PlaceOrderRequestParams): TransactionArgument;
40
+ export declare function placeOrderRequest(client: PerpClient, tx: Transaction, params: PlaceOrderRequestParams): TransactionArgument;
41
41
  export interface CancelOrderRequestParams {
42
42
  ticker: string;
43
43
  accountId: string;
@@ -50,7 +50,7 @@ export interface CancelOrderRequestParams {
50
50
  orderTypeTag?: number;
51
51
  bucketAccount?: string | TransactionArgument;
52
52
  }
53
- export declare function cancelOrderRequest(client: WaterXClient, tx: Transaction, params: CancelOrderRequestParams): TransactionArgument;
53
+ export declare function cancelOrderRequest(client: PerpClient, tx: Transaction, params: CancelOrderRequestParams): TransactionArgument;
54
54
  export interface UpdateOrderRequestParams {
55
55
  ticker: string;
56
56
  accountId: string;
@@ -66,7 +66,7 @@ export interface UpdateOrderRequestParams {
66
66
  newTriggerPrice: bigint | number;
67
67
  bucketAccount?: string | TransactionArgument;
68
68
  }
69
- export declare function updateOrderRequest(client: WaterXClient, tx: Transaction, params: UpdateOrderRequestParams): TransactionArgument;
69
+ export declare function updateOrderRequest(client: PerpClient, tx: Transaction, params: UpdateOrderRequestParams): TransactionArgument;
70
70
  export interface CancelPreOrderRequestParams {
71
71
  ticker: string;
72
72
  accountId: string;
@@ -76,7 +76,7 @@ export interface CancelPreOrderRequestParams {
76
76
  preOrderId: bigint | number;
77
77
  bucketAccount?: string | TransactionArgument;
78
78
  }
79
- export declare function cancelPreOrderRequest(client: WaterXClient, tx: Transaction, params: CancelPreOrderRequestParams): TransactionArgument;
79
+ export declare function cancelPreOrderRequest(client: PerpClient, tx: Transaction, params: CancelPreOrderRequestParams): TransactionArgument;
80
80
  export interface AddPreOrderRequestParams {
81
81
  ticker: string;
82
82
  accountId: string;
@@ -86,4 +86,4 @@ export interface AddPreOrderRequestParams {
86
86
  preOrder: PlaceOrderArgumentParams;
87
87
  bucketAccount?: string | TransactionArgument;
88
88
  }
89
- export declare function addPreOrderRequest(client: WaterXClient, tx: Transaction, params: AddPreOrderRequestParams): TransactionArgument;
89
+ export declare function addPreOrderRequest(client: PerpClient, tx: Transaction, params: AddPreOrderRequestParams): TransactionArgument;
@@ -8,10 +8,10 @@
8
8
  * Use `triggerPrice === undefined` (market form) to park an order at
9
9
  * tick 0 in the limit book; a keeper picks it up via `match_orders`.
10
10
  */
11
+ import { makeSenderRequest } from "../../account/account-request.js";
12
+ import { newPlaceOrderArgument } from "../../generated/waterx_perp/request.js";
13
+ import * as trading from "../../generated/waterx_perp/trading.js";
11
14
  import { ORDER_TAG_WILDCARD } from "../constants.js";
12
- import { newPlaceOrderArgument } from "../generated/waterx_perp/request.js";
13
- import * as trading from "../generated/waterx_perp/trading.js";
14
- import { makeSenderRequest } from "../utils/account-request.js";
15
15
  /** Build a `request::PlaceOrderArgument` Move struct in the PTB. */
16
16
  export function buildPlaceOrderArgument(client, tx, p) {
17
17
  const [arg] = newPlaceOrderArgument({
@@ -16,7 +16,7 @@
16
16
  * `StakingPool<STAKE>` shared object.
17
17
  */
18
18
  import type { Transaction, TransactionArgument } from "@mysten/sui/transactions";
19
- import type { WaterXClient } from "../client.ts";
19
+ import type { PerpClient } from "../client.ts";
20
20
  export interface StakeParams {
21
21
  accountId: string;
22
22
  /** Stake-type alias (key into `waterx_staking.pools`, e.g. `"WLP"`). */
@@ -33,7 +33,7 @@ export interface StakeParams {
33
33
  rewarderTypes?: string[];
34
34
  bucketAccount?: string | TransactionArgument;
35
35
  }
36
- export declare function stake(client: WaterXClient, tx: Transaction, params: StakeParams): void;
36
+ export declare function stake(client: PerpClient, tx: Transaction, params: StakeParams): void;
37
37
  export interface UnstakeParams {
38
38
  accountId: string;
39
39
  stakeAlias: string;
@@ -42,7 +42,7 @@ export interface UnstakeParams {
42
42
  rewarderTypes?: string[];
43
43
  bucketAccount?: string | TransactionArgument;
44
44
  }
45
- export declare function unstake(client: WaterXClient, tx: Transaction, params: UnstakeParams): void;
45
+ export declare function unstake(client: PerpClient, tx: Transaction, params: UnstakeParams): void;
46
46
  export interface ClaimRewardParams {
47
47
  accountId: string;
48
48
  stakeAlias: string;
@@ -51,4 +51,4 @@ export interface ClaimRewardParams {
51
51
  rewardType: string;
52
52
  bucketAccount?: string | TransactionArgument;
53
53
  }
54
- export declare function claimReward(client: WaterXClient, tx: Transaction, params: ClaimRewardParams): void;
54
+ export declare function claimReward(client: PerpClient, tx: Transaction, params: ClaimRewardParams): void;
@@ -15,8 +15,8 @@
15
15
  * `config.packages.waterx_staking.pools` to find the actual
16
16
  * `StakingPool<STAKE>` shared object.
17
17
  */
18
- import * as staking from "../generated/waterx_staking/waterx_staking.js";
19
- import { makeSenderRequest } from "../utils/account-request.js";
18
+ import { makeSenderRequest } from "../../account/account-request.js";
19
+ import * as staking from "../../generated/waterx_staking/waterx_staking.js";
20
20
  function pool(client, stakeAlias) {
21
21
  const id = client.config.packages.waterx_staking?.pools?.[stakeAlias];
22
22
  if (!id) {
@@ -11,7 +11,7 @@
11
11
  * they do the work inline and return `()`.
12
12
  */
13
13
  import type { Transaction, TransactionArgument } from "@mysten/sui/transactions";
14
- import type { WaterXClient } from "../client.ts";
14
+ import type { PerpClient } from "../client.ts";
15
15
  export interface TradingTypeArgs {
16
16
  /** Collateral coin type (e.g. `0x…::usdc::USDC`). */
17
17
  collateralType: string;
@@ -31,7 +31,7 @@ export interface ClosePositionRequestParams extends CommonTradingParams {
31
31
  /** Raw scaled `Float` (1e9). Use `rawPrice(usd)` to convert. */
32
32
  acceptablePrice: bigint | number;
33
33
  }
34
- export declare function closePositionRequest(client: WaterXClient, tx: Transaction, params: ClosePositionRequestParams): TransactionArgument;
34
+ export declare function closePositionRequest(client: PerpClient, tx: Transaction, params: ClosePositionRequestParams): TransactionArgument;
35
35
  export interface IncreasePositionRequestParams extends CommonTradingParams {
36
36
  positionId: bigint | number;
37
37
  collateralAmount: bigint | number;
@@ -42,43 +42,43 @@ export interface IncreasePositionRequestParams extends CommonTradingParams {
42
42
  /** Optional opener order id (rare). */
43
43
  orderId?: bigint | number;
44
44
  }
45
- export declare function increasePositionRequest(client: WaterXClient, tx: Transaction, params: IncreasePositionRequestParams): TransactionArgument;
45
+ export declare function increasePositionRequest(client: PerpClient, tx: Transaction, params: IncreasePositionRequestParams): TransactionArgument;
46
46
  export interface DecreasePositionRequestParams extends CommonTradingParams {
47
47
  positionId: bigint | number;
48
48
  /** Raw 1e9-scaled `Float` size to reduce by. */
49
49
  size: bigint | number;
50
50
  acceptablePrice: bigint | number;
51
51
  }
52
- export declare function decreasePositionRequest(client: WaterXClient, tx: Transaction, params: DecreasePositionRequestParams): TransactionArgument;
52
+ export declare function decreasePositionRequest(client: PerpClient, tx: Transaction, params: DecreasePositionRequestParams): TransactionArgument;
53
53
  export interface DepositCollateralRequestParams extends CommonTradingParams {
54
54
  positionId: bigint | number;
55
55
  collateralAmount: bigint | number;
56
56
  }
57
- export declare function depositCollateralRequest(client: WaterXClient, tx: Transaction, params: DepositCollateralRequestParams): TransactionArgument;
57
+ export declare function depositCollateralRequest(client: PerpClient, tx: Transaction, params: DepositCollateralRequestParams): TransactionArgument;
58
58
  export interface WithdrawCollateralRequestParams extends CommonTradingParams {
59
59
  positionId: bigint | number;
60
60
  amount: bigint | number;
61
61
  }
62
- export declare function withdrawCollateralRequest(client: WaterXClient, tx: Transaction, params: WithdrawCollateralRequestParams): TransactionArgument;
62
+ export declare function withdrawCollateralRequest(client: PerpClient, tx: Transaction, params: WithdrawCollateralRequestParams): TransactionArgument;
63
63
  export interface ExecuteTradingParams extends TradingTypeArgs {
64
64
  ticker: string;
65
65
  request: TransactionArgument;
66
66
  }
67
- export declare function executeTrading(client: WaterXClient, tx: Transaction, params: ExecuteTradingParams): void;
67
+ export declare function executeTrading(client: PerpClient, tx: Transaction, params: ExecuteTradingParams): void;
68
68
  export interface LiquidateParams extends TradingTypeArgs {
69
69
  ticker: string;
70
70
  positionId: bigint | number;
71
71
  /** Optional Bucket Account to act through. */
72
72
  bucketAccount?: string | TransactionArgument;
73
73
  }
74
- export declare function liquidate(client: WaterXClient, tx: Transaction, params: LiquidateParams): void;
74
+ export declare function liquidate(client: PerpClient, tx: Transaction, params: LiquidateParams): void;
75
75
  export interface BatchLiquidateParams extends TradingTypeArgs {
76
76
  ticker: string;
77
77
  pageSize: bigint | number;
78
78
  pageIndex: bigint | number;
79
79
  bucketAccount?: string | TransactionArgument;
80
80
  }
81
- export declare function batchLiquidate(client: WaterXClient, tx: Transaction, params: BatchLiquidateParams): void;
81
+ export declare function batchLiquidate(client: PerpClient, tx: Transaction, params: BatchLiquidateParams): void;
82
82
  export interface MatchOrdersParams extends TradingTypeArgs {
83
83
  ticker: string;
84
84
  /** Order book to scan: `ORDER_LIMIT_BUY` / `ORDER_LIMIT_SELL` / etc. */
@@ -88,14 +88,14 @@ export interface MatchOrdersParams extends TradingTypeArgs {
88
88
  maxFills: bigint | number;
89
89
  bucketAccount?: string | TransactionArgument;
90
90
  }
91
- export declare function matchOrders(client: WaterXClient, tx: Transaction, params: MatchOrdersParams): void;
91
+ export declare function matchOrders(client: PerpClient, tx: Transaction, params: MatchOrdersParams): void;
92
92
  export interface UpdateFundingRateParams {
93
93
  ticker: string;
94
94
  /** Defaults to `client.wlpType()`. */
95
95
  lpType?: string;
96
96
  bucketAccount?: string | TransactionArgument;
97
97
  }
98
- export declare function updateFundingRate(client: WaterXClient, tx: Transaction, params: UpdateFundingRateParams): void;
98
+ export declare function updateFundingRate(client: PerpClient, tx: Transaction, params: UpdateFundingRateParams): void;
99
99
  export interface OpenPositionByKeeperParams extends TradingTypeArgs {
100
100
  ticker: string;
101
101
  /** Address of the user-side account (the position will be owned by this address). */
@@ -108,12 +108,12 @@ export interface OpenPositionByKeeperParams extends TradingTypeArgs {
108
108
  acceptablePrice: bigint | number;
109
109
  bucketAccount?: string | TransactionArgument;
110
110
  }
111
- export declare function openPositionByKeeper(client: WaterXClient, tx: Transaction, params: OpenPositionByKeeperParams): void;
111
+ export declare function openPositionByKeeper(client: PerpClient, tx: Transaction, params: OpenPositionByKeeperParams): void;
112
112
  export interface ClosePositionByKeeperParams extends TradingTypeArgs {
113
113
  ticker: string;
114
114
  positionId: bigint | number;
115
115
  acceptablePrice: bigint | number;
116
116
  bucketAccount?: string | TransactionArgument;
117
117
  }
118
- export declare function closePositionByKeeper(client: WaterXClient, tx: Transaction, params: ClosePositionByKeeperParams): void;
118
+ export declare function closePositionByKeeper(client: PerpClient, tx: Transaction, params: ClosePositionByKeeperParams): void;
119
119
  export declare const ORDER_TAG_WILDCARD_VALUE = 255;
@@ -10,9 +10,9 @@
10
10
  * `updateFundingRate`, `openByKeeper`, `closeByKeeper`) are single-call:
11
11
  * they do the work inline and return `()`.
12
12
  */
13
+ import { makeSenderRequest } from "../../account/account-request.js";
14
+ import * as trading from "../../generated/waterx_perp/trading.js";
13
15
  import { ORDER_TAG_WILDCARD } from "../constants.js";
14
- import * as trading from "../generated/waterx_perp/trading.js";
15
- import { makeSenderRequest } from "../utils/account-request.js";
16
16
  function typeArgs(client, t) {
17
17
  return [t.collateralType, t.lpType ?? client.wlpType()];
18
18
  }
@@ -6,11 +6,11 @@
6
6
  * account (use `requestDeposit` from `./account.ts`).
7
7
  *
8
8
  * `mintWlp` / `settleRedeem` require fresh oracle prices; call
9
- * `refreshOraclePrices` (see `utils/pyth.ts`) for every pool token
9
+ * `refreshOraclePrices` (see `oracle/`) for every pool token
10
10
  * before invoking these builders in the same PTB.
11
11
  */
12
12
  import type { Transaction, TransactionArgument } from "@mysten/sui/transactions";
13
- import type { WaterXClient } from "../client.ts";
13
+ import type { PerpClient } from "../client.ts";
14
14
  export interface MintWlpParams {
15
15
  /** wxa account holding the input balance and receiving the minted WLP. */
16
16
  accountId: string;
@@ -25,7 +25,7 @@ export interface MintWlpParams {
25
25
  bucketAccount?: string | TransactionArgument;
26
26
  }
27
27
  /** Returns the minted `lp_amount` so it can be chained into e.g. `stake`. */
28
- export declare function mintWlp(client: WaterXClient, tx: Transaction, params: MintWlpParams): TransactionArgument;
28
+ export declare function mintWlp(client: PerpClient, tx: Transaction, params: MintWlpParams): TransactionArgument;
29
29
  export interface RequestRedeemWlpParams {
30
30
  accountId: string;
31
31
  /** Defaults to `client.wlpType()`. */
@@ -36,13 +36,13 @@ export interface RequestRedeemWlpParams {
36
36
  lpAmount: bigint | number;
37
37
  bucketAccount?: string | TransactionArgument;
38
38
  }
39
- export declare function requestRedeemWlp(client: WaterXClient, tx: Transaction, params: RequestRedeemWlpParams): void;
39
+ export declare function requestRedeemWlp(client: PerpClient, tx: Transaction, params: RequestRedeemWlpParams): void;
40
40
  export interface CancelRedeemWlpParams {
41
41
  requestId: bigint | number;
42
42
  lpType?: string;
43
43
  bucketAccount?: string | TransactionArgument;
44
44
  }
45
- export declare function cancelRedeemWlp(client: WaterXClient, tx: Transaction, params: CancelRedeemWlpParams): void;
45
+ export declare function cancelRedeemWlp(client: PerpClient, tx: Transaction, params: CancelRedeemWlpParams): void;
46
46
  export interface SettleRedeemWlpParams {
47
47
  requestId: bigint | number;
48
48
  redeemTokenType: string;
@@ -50,9 +50,9 @@ export interface SettleRedeemWlpParams {
50
50
  /** Optional Bucket Account for the operator caller. */
51
51
  bucketAccount?: string | TransactionArgument;
52
52
  }
53
- export declare function settleRedeemWlp(client: WaterXClient, tx: Transaction, params: SettleRedeemWlpParams): void;
53
+ export declare function settleRedeemWlp(client: PerpClient, tx: Transaction, params: SettleRedeemWlpParams): void;
54
54
  /** Recompute one token pool's TVL using the current Oracle price. */
55
- export declare function updateTokenValue(client: WaterXClient, tx: Transaction, args: {
55
+ export declare function updateTokenValue(client: PerpClient, tx: Transaction, args: {
56
56
  tokenType: string;
57
57
  lpType?: string;
58
58
  }): void;
@@ -6,11 +6,11 @@
6
6
  * account (use `requestDeposit` from `./account.ts`).
7
7
  *
8
8
  * `mintWlp` / `settleRedeem` require fresh oracle prices; call
9
- * `refreshOraclePrices` (see `utils/pyth.ts`) for every pool token
9
+ * `refreshOraclePrices` (see `oracle/`) for every pool token
10
10
  * before invoking these builders in the same PTB.
11
11
  */
12
- import * as lp from "../generated/waterx_perp/lp_pool.js";
13
- import { makeSenderRequest } from "../utils/account-request.js";
12
+ import { makeSenderRequest } from "../../account/account-request.js";
13
+ import * as lp from "../../generated/waterx_perp/lp_pool.js";
14
14
  /** Returns the minted `lp_amount` so it can be chained into e.g. `stake`. */
15
15
  export function mintWlp(client, tx, params) {
16
16
  const req = makeSenderRequest(client, tx, params.bucketAccount);