@waterx/sdk 2.4.1 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/README.md +25 -21
  2. package/dist/src/{utils → account}/account-request.d.ts +2 -2
  3. package/dist/src/{user → account}/account.d.ts +23 -21
  4. package/dist/src/{user → account}/account.js +5 -5
  5. package/dist/src/account/client.d.ts +42 -0
  6. package/dist/src/account/client.js +17 -0
  7. package/dist/src/account/config.d.ts +151 -0
  8. package/dist/src/account/config.js +8 -0
  9. package/dist/src/account/constants.d.ts +5 -0
  10. package/dist/src/account/constants.js +5 -0
  11. package/dist/src/account/fetch/referral.d.ts +15 -0
  12. package/dist/src/account/fetch/referral.js +51 -0
  13. package/dist/src/account/fetch/simulate.d.ts +34 -0
  14. package/dist/src/account/fetch/simulate.js +43 -0
  15. package/dist/src/{utils/consolidate-balance.d.ts → account/funding/balance.d.ts} +3 -8
  16. package/dist/src/{utils/consolidate-balance.js → account/funding/balance.js} +6 -1
  17. package/dist/src/account/funding/consolidate.d.ts +46 -0
  18. package/dist/src/account/funding/consolidate.js +137 -0
  19. package/dist/src/{user → account/funding}/credit.d.ts +10 -10
  20. package/dist/src/{user → account/funding}/credit.js +6 -6
  21. package/dist/src/{user → account/funding}/custody.d.ts +4 -4
  22. package/dist/src/{user → account/funding}/custody.js +2 -2
  23. package/dist/src/{utils → account/funding}/wormhole.d.ts +4 -4
  24. package/dist/src/{utils → account/funding}/wormhole.js +1 -1
  25. package/dist/src/account/index.d.ts +29 -0
  26. package/dist/src/account/index.js +29 -0
  27. package/dist/src/{user → account}/referral.d.ts +3 -3
  28. package/dist/src/{user → account}/referral.js +1 -1
  29. package/dist/src/base-client.d.ts +74 -0
  30. package/dist/src/base-client.js +97 -0
  31. package/dist/src/constants.d.ts +4 -46
  32. package/dist/src/constants.js +8 -52
  33. package/dist/src/generated/bucket_v2_framework/liability.d.ts +0 -26
  34. package/dist/src/generated/bucket_v2_framework/liability.js +0 -28
  35. package/dist/src/generated/waterx_account/account.d.ts +50 -15
  36. package/dist/src/generated/waterx_account/account.js +51 -15
  37. package/dist/src/generated/waterx_oracle/oracle.d.ts +7 -1
  38. package/dist/src/generated/waterx_oracle/oracle.js +7 -2
  39. package/dist/src/{prediction/generated → generated}/waterx_prediction/account_data.d.ts +19 -2
  40. package/dist/src/{prediction/generated → generated}/waterx_prediction/admin.d.ts +3 -1
  41. package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/sui/balance.d.ts +3 -1
  42. package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/deps/sui/table.d.ts +6 -1
  43. package/dist/src/generated/waterx_prediction/events.d.ts +288 -0
  44. package/dist/src/{prediction/generated → generated}/waterx_prediction/events.js +39 -0
  45. package/dist/src/{prediction/generated → generated}/waterx_prediction/global_config.d.ts +6 -1
  46. package/dist/src/{prediction/generated → generated}/waterx_prediction/order.d.ts +34 -1
  47. package/dist/src/{prediction/generated → generated}/waterx_prediction/position.d.ts +16 -1
  48. package/dist/src/{prediction/generated → generated}/waterx_prediction/view.d.ts +69 -4
  49. package/dist/src/{prediction/generated → generated}/waterx_prediction/waterx_prediction.d.ts +162 -2
  50. package/dist/src/{prediction/generated → generated}/waterx_prediction/waterx_prediction.js +99 -0
  51. package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +102 -0
  52. package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +99 -0
  53. package/dist/src/generated/waterx_supra_rule/supra_rule.d.ts +5 -5
  54. package/dist/src/generated/waterx_supra_rule/supra_rule.js +1 -2
  55. package/dist/src/generated/withdrawal_queue/withdrawal_queue.d.ts +23 -23
  56. package/dist/src/generated/withdrawal_queue/withdrawal_queue.js +3 -6
  57. package/dist/src/oracle/aggregate.d.ts +74 -0
  58. package/dist/src/oracle/aggregate.js +112 -0
  59. package/dist/src/oracle/config.d.ts +99 -0
  60. package/dist/src/oracle/config.js +23 -0
  61. package/dist/src/oracle/host.d.ts +32 -0
  62. package/dist/src/oracle/host.js +10 -0
  63. package/dist/src/oracle/index.d.ts +16 -0
  64. package/dist/src/oracle/index.js +18 -0
  65. package/dist/src/oracle/pyth.d.ts +52 -0
  66. package/dist/src/oracle/pyth.js +220 -0
  67. package/dist/src/oracle/rules/constant-rule.d.ts +9 -0
  68. package/dist/src/oracle/rules/constant-rule.js +14 -0
  69. package/dist/src/oracle/rules/pyth-rule.d.ts +11 -0
  70. package/dist/src/oracle/rules/pyth-rule.js +20 -0
  71. package/dist/src/oracle/rules/sponsor.d.ts +28 -0
  72. package/dist/src/oracle/rules/sponsor.js +48 -0
  73. package/dist/src/oracle/rules/supra-rule.d.ts +11 -0
  74. package/dist/src/oracle/rules/supra-rule.js +22 -0
  75. package/dist/src/perp/client.d.ts +78 -0
  76. package/dist/src/perp/client.js +108 -0
  77. package/dist/src/{client.d.ts → perp/config-view.d.ts} +15 -60
  78. package/dist/src/{client.js → perp/config-view.js} +23 -95
  79. package/dist/src/perp/config.d.ts +126 -0
  80. package/dist/src/{config.js → perp/config.js} +11 -12
  81. package/dist/src/perp/constants.d.ts +49 -0
  82. package/dist/src/perp/constants.js +61 -0
  83. package/dist/src/perp/fetch/account.d.ts +43 -0
  84. package/dist/src/perp/fetch/account.js +64 -0
  85. package/dist/src/perp/fetch/bridge.d.ts +90 -0
  86. package/dist/src/perp/fetch/bridge.js +127 -0
  87. package/dist/src/perp/fetch/custody.d.ts +32 -0
  88. package/dist/src/perp/fetch/custody.js +62 -0
  89. package/dist/src/perp/fetch/market.d.ts +30 -0
  90. package/dist/src/perp/fetch/market.js +68 -0
  91. package/dist/src/perp/fetch/positions.d.ts +70 -0
  92. package/dist/src/perp/fetch/positions.js +185 -0
  93. package/dist/src/perp/fetch/simulate.d.ts +12 -0
  94. package/dist/src/perp/fetch/simulate.js +13 -0
  95. package/dist/src/perp/fetch.d.ts +23 -0
  96. package/dist/src/perp/fetch.js +23 -0
  97. package/dist/src/{index.d.ts → perp/index.d.ts} +21 -21
  98. package/dist/src/{index.js → perp/index.js} +21 -21
  99. package/dist/src/perp/tx-builders/common.d.ts +83 -0
  100. package/dist/src/perp/tx-builders/common.js +70 -0
  101. package/dist/src/perp/tx-builders/credit.d.ts +65 -0
  102. package/dist/src/perp/tx-builders/credit.js +62 -0
  103. package/dist/src/perp/tx-builders/rewards.d.ts +30 -0
  104. package/dist/src/perp/tx-builders/rewards.js +34 -0
  105. package/dist/src/perp/tx-builders/trading.d.ts +51 -0
  106. package/dist/src/perp/tx-builders/trading.js +59 -0
  107. package/dist/src/perp/tx-builders/wlp.d.ts +90 -0
  108. package/dist/src/perp/tx-builders/wlp.js +120 -0
  109. package/dist/src/perp/tx-builders.d.ts +23 -0
  110. package/dist/src/perp/tx-builders.js +23 -0
  111. package/dist/src/perp/user/index.d.ts +8 -0
  112. package/dist/src/perp/user/index.js +8 -0
  113. package/dist/src/{user → perp/user}/order.d.ts +7 -7
  114. package/dist/src/{user → perp/user}/order.js +3 -3
  115. package/dist/src/{user → perp/user}/staking.d.ts +4 -4
  116. package/dist/src/{user → perp/user}/staking.js +2 -2
  117. package/dist/src/{user → perp/user}/trading.d.ts +13 -13
  118. package/dist/src/{user → perp/user}/trading.js +2 -2
  119. package/dist/src/{user → perp/user}/wlp.d.ts +7 -7
  120. package/dist/src/{user → perp/user}/wlp.js +3 -3
  121. package/dist/src/prediction/account.js +40 -76
  122. package/dist/src/prediction/bcs.d.ts +15 -9
  123. package/dist/src/prediction/bcs.js +17 -81
  124. package/dist/src/prediction/client.d.ts +8 -38
  125. package/dist/src/prediction/client.js +11 -67
  126. package/dist/src/prediction/config.d.ts +16 -2
  127. package/dist/src/prediction/config.js +10 -4
  128. package/dist/src/prediction/gift.js +2 -10
  129. package/dist/src/prediction/index.d.ts +11 -11
  130. package/dist/src/prediction/index.js +10 -10
  131. package/dist/src/prediction/prediction.d.ts +45 -0
  132. package/dist/src/prediction/prediction.js +71 -0
  133. package/dist/src/prediction/tx-builders.d.ts +4 -4
  134. package/dist/src/prediction/tx-builders.js +2 -2
  135. package/dist/src/prediction/types.d.ts +2 -0
  136. package/dist/src/prediction/user/index.d.ts +2 -2
  137. package/dist/src/prediction/user/index.js +1 -1
  138. package/dist/src/prediction/user/position.d.ts +2 -2
  139. package/dist/src/prediction/user/position.js +1 -1
  140. package/dist/src/prediction/utils/bcs.d.ts +5 -0
  141. package/dist/src/prediction/utils/bcs.js +5 -0
  142. package/dist/src/prediction/utils/index.d.ts +7 -0
  143. package/dist/src/prediction/utils/index.js +7 -0
  144. package/dist/src/sdk.d.ts +10 -6
  145. package/dist/src/sdk.js +9 -5
  146. package/dist/src/unified-client.d.ts +140 -145
  147. package/dist/src/unified-client.js +98 -40
  148. package/dist/src/utils/config.d.ts +1 -1
  149. package/package.json +22 -5
  150. package/dist/src/config.d.ts +0 -292
  151. package/dist/src/fetch.d.ts +0 -254
  152. package/dist/src/fetch.js +0 -564
  153. package/dist/src/prediction/generated/bucket_v2_framework/account.d.ts +0 -100
  154. package/dist/src/prediction/generated/bucket_v2_framework/account.js +0 -129
  155. package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.d.ts +0 -6
  156. package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.js +0 -19
  157. package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.d.ts +0 -10
  158. package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.d.ts +0 -36
  159. package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.js +0 -27
  160. package/dist/src/prediction/generated/bucket_v2_framework/double.d.ts +0 -382
  161. package/dist/src/prediction/generated/bucket_v2_framework/double.js +0 -466
  162. package/dist/src/prediction/generated/bucket_v2_framework/float.d.ts +0 -362
  163. package/dist/src/prediction/generated/bucket_v2_framework/float.js +0 -440
  164. package/dist/src/prediction/generated/bucket_v2_framework/liability.d.ts +0 -193
  165. package/dist/src/prediction/generated/bucket_v2_framework/liability.js +0 -205
  166. package/dist/src/prediction/generated/bucket_v2_framework/linked_table.d.ts +0 -384
  167. package/dist/src/prediction/generated/bucket_v2_framework/linked_table.js +0 -382
  168. package/dist/src/prediction/generated/bucket_v2_framework/sheet.d.ts +0 -344
  169. package/dist/src/prediction/generated/bucket_v2_framework/sheet.js +0 -338
  170. package/dist/src/prediction/generated/utils/index.d.ts +0 -30
  171. package/dist/src/prediction/generated/utils/index.js +0 -160
  172. package/dist/src/prediction/generated/waterx_account/account.d.ts +0 -1589
  173. package/dist/src/prediction/generated/waterx_account/account.js +0 -1758
  174. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.d.ts +0 -7
  175. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.js +0 -13
  176. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.d.ts +0 -7
  177. package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.js +0 -16
  178. package/dist/src/prediction/generated/waterx_account/deps/std/type_name.d.ts +0 -6
  179. package/dist/src/prediction/generated/waterx_account/deps/std/type_name.js +0 -19
  180. package/dist/src/prediction/generated/waterx_account/deps/sui/balance.d.ts +0 -10
  181. package/dist/src/prediction/generated/waterx_account/deps/sui/balance.js +0 -14
  182. package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.d.ts +0 -12
  183. package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.js +0 -19
  184. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.d.ts +0 -36
  185. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.js +0 -27
  186. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.d.ts +0 -16
  187. package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.js +0 -19
  188. package/dist/src/prediction/generated/waterx_account/direct_rule.d.ts +0 -75
  189. package/dist/src/prediction/generated/waterx_account/direct_rule.js +0 -78
  190. package/dist/src/prediction/generated/waterx_account/events.d.ts +0 -33
  191. package/dist/src/prediction/generated/waterx_account/events.js +0 -137
  192. package/dist/src/prediction/generated/waterx_account/version.js +0 -8
  193. package/dist/src/prediction/generated/waterx_prediction/bet_sharing.d.ts +0 -60
  194. package/dist/src/prediction/generated/waterx_prediction/bet_sharing.js +0 -83
  195. package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.js +0 -14
  196. package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.d.ts +0 -24
  197. package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.js +0 -31
  198. package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.d.ts +0 -16
  199. package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.js +0 -19
  200. package/dist/src/prediction/generated/waterx_prediction/events.d.ts +0 -22
  201. package/dist/src/prediction/generated/waterx_prediction/version.d.ts +0 -10
  202. package/dist/src/tx-builders.d.ts +0 -296
  203. package/dist/src/tx-builders.js +0 -461
  204. package/dist/src/user/index.d.ts +0 -8
  205. package/dist/src/user/index.js +0 -8
  206. package/dist/src/utils/pyth.d.ts +0 -124
  207. package/dist/src/utils/pyth.js +0 -392
  208. /package/dist/src/{utils → account}/account-request.js +0 -0
  209. /package/dist/src/{core → account}/waterx-account.d.ts +0 -0
  210. /package/dist/src/{core → account}/waterx-account.js +0 -0
  211. /package/dist/src/{prediction/generated → generated}/waterx_prediction/account_data.js +0 -0
  212. /package/dist/src/{prediction/generated → generated}/waterx_prediction/admin.js +0 -0
  213. /package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/bucket_v2_framework/linked_table.d.ts +0 -0
  214. /package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/bucket_v2_framework/linked_table.js +0 -0
  215. /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/balance.js +0 -0
  216. /package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/deps/sui/table.js +0 -0
  217. /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/vec_set.d.ts +0 -0
  218. /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/vec_set.js +0 -0
  219. /package/dist/src/{prediction/generated → generated}/waterx_prediction/global_config.js +0 -0
  220. /package/dist/src/{prediction/generated → generated}/waterx_prediction/order.js +0 -0
  221. /package/dist/src/{prediction/generated → generated}/waterx_prediction/outcome.d.ts +0 -0
  222. /package/dist/src/{prediction/generated → generated}/waterx_prediction/outcome.js +0 -0
  223. /package/dist/src/{prediction/generated → generated}/waterx_prediction/position.js +0 -0
  224. /package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/version.d.ts +0 -0
  225. /package/dist/src/{prediction/generated → generated}/waterx_prediction/version.js +0 -0
  226. /package/dist/src/{prediction/generated → generated}/waterx_prediction/view.js +0 -0
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Bridge reads: `wormhole_bridge` rate-limit / cap snapshot and the
3
+ * `withdrawal_queue` (Sui → EVM) fee estimate.
4
+ */
5
+ import { bcs } from "@mysten/sui/bcs";
6
+ import { Transaction } from "@mysten/sui/transactions";
7
+ import { bridgeFeeAmount as bridgeFeeAmountCall, bridgeFeeRate as bridgeFeeRateCall, bridgeMinFee as bridgeMinFeeCall, wouldExecuteWormhole as wouldExecuteWormholeCall, } from "../../generated/withdrawal_queue/withdrawal_queue.js";
8
+ import { dailyBurned as dailyBurnedCall, dailyBurnLimit as dailyBurnLimitCall, dailyMinted as dailyMintedCall, dailyMintLimit as dailyMintLimitCall, maxBurnPerTx as maxBurnPerTxCall, maxMintPerTx as maxMintPerTxCall, mintedFor as mintedForCall, paused as pausedCall, personalBurnCapAmount as personalBurnCapAmountCall, personalBurned as personalBurnedCall, } from "../../generated/wormhole_bridge/wormhole_bridge.js";
9
+ import { extractAt, simulateRaw } from "./simulate.js";
10
+ /**
11
+ * Batched read of the bridge's rate-limit / cap state in a single simulate.
12
+ * Pass `accountId` to also fetch the per-account burn usage, and `backing`
13
+ * to also fetch the destination-chain backing (`minted_for`).
14
+ *
15
+ * Throws if `wormhole_bridge` (or its `Bridge` object id) is absent from the
16
+ * canonical config — e.g. on a network where the Sui bridge isn't published.
17
+ */
18
+ export async function getBridgeLimits(client, args = {}) {
19
+ const pkg = client.config.packages.wormhole_bridge;
20
+ if (!pkg?.bridge) {
21
+ throw new Error("wormhole_bridge is not deployed on this network (no `bridge` object id in config)");
22
+ }
23
+ const packageId = pkg.published_at;
24
+ const bridge = pkg.bridge;
25
+ const tx = new Transaction();
26
+ // Fixed-order view calls; indices tracked below.
27
+ pausedCall({ package: packageId, arguments: { bridge } })(tx); // 0
28
+ dailyMintLimitCall({ package: packageId, arguments: { bridge } })(tx); // 1
29
+ dailyMintedCall({ package: packageId, arguments: { bridge } })(tx); // 2
30
+ maxMintPerTxCall({ package: packageId, arguments: { bridge } })(tx); // 3
31
+ dailyBurnLimitCall({ package: packageId, arguments: { bridge } })(tx); // 4
32
+ dailyBurnedCall({ package: packageId, arguments: { bridge } })(tx); // 5
33
+ maxBurnPerTxCall({ package: packageId, arguments: { bridge } })(tx); // 6
34
+ personalBurnCapAmountCall({ package: packageId, arguments: { bridge } })(tx); // 7
35
+ let backingIdx = -1;
36
+ if (args.backing) {
37
+ backingIdx = 8;
38
+ mintedForCall({
39
+ package: packageId,
40
+ arguments: {
41
+ bridge,
42
+ chainId: args.backing.wormholeChainId,
43
+ token: Array.from(args.backing.token),
44
+ },
45
+ })(tx);
46
+ }
47
+ let personalIdx = -1;
48
+ if (args.accountId) {
49
+ personalIdx = backingIdx === -1 ? 8 : 9;
50
+ // Clock (0x6) is auto-injected by the generated wrapper.
51
+ personalBurnedCall({
52
+ package: packageId,
53
+ arguments: { bridge, user: args.accountId },
54
+ })(tx);
55
+ }
56
+ const sim = await simulateRaw(client, tx);
57
+ const u64At = (i) => BigInt(bcs.u64().parse(extractAt(sim, i)));
58
+ const view = {
59
+ paused: bcs.bool().parse(extractAt(sim, 0)),
60
+ dailyMintLimit: u64At(1),
61
+ dailyMinted: u64At(2),
62
+ maxMintPerTx: u64At(3),
63
+ dailyBurnLimit: u64At(4),
64
+ dailyBurned: u64At(5),
65
+ maxBurnPerTx: u64At(6),
66
+ personalBurnCapAmount: u64At(7),
67
+ };
68
+ if (backingIdx >= 0)
69
+ view.backingMinted = u64At(backingIdx);
70
+ if (personalIdx >= 0)
71
+ view.personalBurned = u64At(personalIdx);
72
+ return view;
73
+ }
74
+ function requireWithdrawalQueue(client) {
75
+ const wq = client.config.packages.withdrawal_queue;
76
+ if (!wq?.queue) {
77
+ throw new Error("withdrawal_queue is not deployed on this network (no `queue` object id in config)");
78
+ }
79
+ return { pkg: wq.published_at, queue: wq.queue };
80
+ }
81
+ /**
82
+ * Estimate the bridge fee for a wormhole (Sui → EVM) CREDIT exit of `amount`
83
+ * to `evmDestinationChain`, read in a single simulate from the on-chain
84
+ * `withdrawal_queue` views. The charged fee is
85
+ * `max(ceil(effectiveRate * amount), effectiveMinFee)`.
86
+ *
87
+ * Surface UI off `wouldExecute`, NOT `feeAmount` alone — `feeAmount` is the raw
88
+ * fee and can equal/exceed `amount` (ceil rounding on a dust entry, or a min-fee
89
+ * floor larger than the entry), in which case the on-chain exit aborts its
90
+ * net-zero guard (audit L1). `netAmount` is `0n` whenever `wouldExecute` is
91
+ * false.
92
+ *
93
+ * @param args.amount CREDIT base units (the bridged coin's smallest unit).
94
+ * @param args.evmDestinationChain WORMHOLE chain id of the destination EVM.
95
+ * @param args.creditType CREDIT coin type; defaults to `client.creditType()`.
96
+ */
97
+ export async function getBridgeFee(client, args) {
98
+ const { pkg, queue } = requireWithdrawalQueue(client);
99
+ const amount = BigInt(args.amount);
100
+ const common = {
101
+ package: pkg,
102
+ typeArguments: [args.creditType ?? client.creditType()],
103
+ };
104
+ const chain = args.evmDestinationChain;
105
+ const tx = new Transaction();
106
+ // Fixed-order view calls; indices tracked below.
107
+ bridgeFeeAmountCall({
108
+ ...common,
109
+ arguments: { queue, evmDestinationChain: chain, amount },
110
+ })(tx); // 0
111
+ wouldExecuteWormholeCall({
112
+ ...common,
113
+ arguments: { queue, evmDestinationChain: chain, amount },
114
+ })(tx); // 1
115
+ bridgeFeeRateCall({ ...common, arguments: { queue, evmDestinationChain: chain } })(tx); // 2
116
+ bridgeMinFeeCall({ ...common, arguments: { queue, evmDestinationChain: chain } })(tx); // 3
117
+ const sim = await simulateRaw(client, tx);
118
+ const feeAmount = BigInt(bcs.u64().parse(extractAt(sim, 0)));
119
+ const wouldExecute = bcs.bool().parse(extractAt(sim, 1));
120
+ return {
121
+ feeAmount,
122
+ wouldExecute,
123
+ effectiveRate: BigInt(bcs.u128().parse(extractAt(sim, 2))),
124
+ effectiveMinFee: BigInt(bcs.u64().parse(extractAt(sim, 3))),
125
+ netAmount: wouldExecute ? amount - feeAmount : 0n,
126
+ };
127
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Native-custody PSM reads (`custody_vault`).
3
+ */
4
+ import type { PerpClient } from "../client.ts";
5
+ /** Vault-wide native-custody state. */
6
+ export interface CustodyVaultData {
7
+ /** Total CREDIT minted by the custody vault (`credit_supply`). */
8
+ creditSupply: bigint;
9
+ }
10
+ /** Reads vault-wide native-custody state via `custody_vault::credit_supply`. */
11
+ export declare function getCustodyVaultData(client: PerpClient): Promise<CustodyVaultData>;
12
+ /** Per-asset native-custody state for one backing asset. */
13
+ export interface CustodyAssetData {
14
+ /** Whether the asset is registered as a `SingleVault` on the custody vault. */
15
+ registered: boolean;
16
+ /** 1e9-scaled default mint fee rate (`0n` when the asset is not registered). */
17
+ mintFeeRate: bigint;
18
+ /** 1e9-scaled default burn fee rate (`0n` when the asset is not registered). */
19
+ burnFeeRate: bigint;
20
+ }
21
+ /**
22
+ * Reads per-asset native-custody state for backing asset `assetType`.
23
+ *
24
+ * Fee rates are the vault's default config — queried with the zero address as
25
+ * caller, so no partner discount is applied — as 1e9-scaled `Float` values.
26
+ * When the asset is not registered, returns `registered: false` with `0n` rates.
27
+ *
28
+ * Note: the `SingleVault` balance / decimal / backing / min-burn / deprecated
29
+ * fields are not exposed here — the contract's getters for those return a
30
+ * `&SingleVault<T>` reference, which a PTB simulate cannot read.
31
+ */
32
+ export declare function getCustodyAssetData(client: PerpClient, assetType: string): Promise<CustodyAssetData>;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Native-custody PSM reads (`custody_vault`).
3
+ */
4
+ import { bcs } from "@mysten/sui/bcs";
5
+ import { Transaction } from "@mysten/sui/transactions";
6
+ import { burnFeeRate as burnFeeRateCall, creditSupply as creditSupplyCall, hasAsset as hasAssetCall, mintFeeRate as mintFeeRateCall, } from "../../generated/native_custody/custody_vault.js";
7
+ import { DRY_RUN_SENDER } from "../constants.js";
8
+ import { simulateAndExtract } from "./simulate.js";
9
+ function requireCustody(client) {
10
+ const nc = client.config.packages.native_custody;
11
+ if (!nc?.vault) {
12
+ throw new Error("native_custody not configured — set config.packages.native_custody.vault");
13
+ }
14
+ return { pkg: nc.published_at, vault: nc.vault, creditType: client.creditType() };
15
+ }
16
+ /** Reads vault-wide native-custody state via `custody_vault::credit_supply`. */
17
+ export async function getCustodyVaultData(client) {
18
+ const { pkg, vault, creditType } = requireCustody(client);
19
+ const tx = new Transaction();
20
+ creditSupplyCall({
21
+ package: pkg,
22
+ arguments: { vault: tx.object(vault) },
23
+ typeArguments: [creditType],
24
+ })(tx);
25
+ const bytes = await simulateAndExtract(client, tx);
26
+ return { creditSupply: BigInt(bcs.u64().parse(bytes)) };
27
+ }
28
+ /**
29
+ * Reads per-asset native-custody state for backing asset `assetType`.
30
+ *
31
+ * Fee rates are the vault's default config — queried with the zero address as
32
+ * caller, so no partner discount is applied — as 1e9-scaled `Float` values.
33
+ * When the asset is not registered, returns `registered: false` with `0n` rates.
34
+ *
35
+ * Note: the `SingleVault` balance / decimal / backing / min-burn / deprecated
36
+ * fields are not exposed here — the contract's getters for those return a
37
+ * `&SingleVault<T>` reference, which a PTB simulate cannot read.
38
+ */
39
+ export async function getCustodyAssetData(client, assetType) {
40
+ const { pkg, vault, creditType } = requireCustody(client);
41
+ const typeArguments = [assetType, creditType];
42
+ const hasTx = new Transaction();
43
+ hasAssetCall({ package: pkg, arguments: { vault: hasTx.object(vault) }, typeArguments })(hasTx);
44
+ const registered = bcs.bool().parse(await simulateAndExtract(client, hasTx));
45
+ if (!registered)
46
+ return { registered: false, mintFeeRate: 0n, burnFeeRate: 0n };
47
+ const mintTx = new Transaction();
48
+ mintFeeRateCall({
49
+ package: pkg,
50
+ arguments: { vault: mintTx.object(vault), caller: DRY_RUN_SENDER },
51
+ typeArguments,
52
+ })(mintTx);
53
+ const mintFeeRate = BigInt(bcs.u128().parse(await simulateAndExtract(client, mintTx)));
54
+ const burnTx = new Transaction();
55
+ burnFeeRateCall({
56
+ package: pkg,
57
+ arguments: { vault: burnTx.object(vault), caller: DRY_RUN_SENDER },
58
+ typeArguments,
59
+ })(burnTx);
60
+ const burnFeeRate = BigInt(bcs.u128().parse(await simulateAndExtract(client, burnTx)));
61
+ return { registered: true, mintFeeRate, burnFeeRate };
62
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Market / pool / token-pool / global-config + account-data reads
3
+ * (`waterx_perp_view`).
4
+ */
5
+ import { AccountData, GlobalConfigData, MarketData, PoolData, TokenPoolData } from "../../generated/waterx_perp_view/view.ts";
6
+ import type { PerpClient } from "../client.ts";
7
+ export type AccountDataView = ReturnType<typeof AccountData.parse>;
8
+ /**
9
+ * Look up the registered AccountData for a given wxa account ID.
10
+ * Returns `undefined` if the account has no perp data slot installed yet
11
+ * (the slot auto-installs on the first `add_position` / `add_order`).
12
+ * The underlying view fn returns `Option<AccountData>`.
13
+ */
14
+ export declare function getAccountData(client: PerpClient, accountId: string): Promise<AccountDataView | undefined>;
15
+ export type MarketDataView = ReturnType<typeof MarketData.parse>;
16
+ export type PoolDataView = ReturnType<typeof PoolData.parse>;
17
+ export type TokenPoolDataView = ReturnType<typeof TokenPoolData.parse>;
18
+ export type GlobalConfigDataView = ReturnType<typeof GlobalConfigData.parse>;
19
+ export declare function getMarketData(client: PerpClient, args: {
20
+ ticker: string;
21
+ lpType?: string;
22
+ }): Promise<MarketDataView>;
23
+ export declare function getPoolData(client: PerpClient, args?: {
24
+ lpType?: string;
25
+ }): Promise<PoolDataView>;
26
+ export declare function getTokenPoolData(client: PerpClient, args: {
27
+ tokenIndex: bigint | number;
28
+ lpType?: string;
29
+ }): Promise<TokenPoolDataView>;
30
+ export declare function getGlobalConfigData(client: PerpClient): Promise<GlobalConfigDataView>;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Market / pool / token-pool / global-config + account-data reads
3
+ * (`waterx_perp_view`).
4
+ */
5
+ import { bcs } from "@mysten/sui/bcs";
6
+ import { Transaction } from "@mysten/sui/transactions";
7
+ import { AccountData, accountData as accountDataCall, GlobalConfigData, globalConfigData as globalConfigDataCall, MarketData, marketData as marketDataCall, PoolData, poolData as poolDataCall, TokenPoolData, tokenPoolData as tokenPoolDataCall, } from "../../generated/waterx_perp_view/view.js";
8
+ import { simulateAndExtract, withLp } from "./simulate.js";
9
+ /**
10
+ * Look up the registered AccountData for a given wxa account ID.
11
+ * Returns `undefined` if the account has no perp data slot installed yet
12
+ * (the slot auto-installs on the first `add_position` / `add_order`).
13
+ * The underlying view fn returns `Option<AccountData>`.
14
+ */
15
+ export async function getAccountData(client, accountId) {
16
+ const tx = new Transaction();
17
+ accountDataCall({
18
+ package: client.config.packages.waterx_perp_view.published_at,
19
+ arguments: {
20
+ wxaRegistry: tx.object(client.config.packages.waterx_account.account_registry),
21
+ accountId,
22
+ },
23
+ })(tx);
24
+ const bytes = await simulateAndExtract(client, tx);
25
+ const opt = bcs.option(AccountData).parse(bytes);
26
+ return opt ?? undefined;
27
+ }
28
+ export async function getMarketData(client, args) {
29
+ const tx = new Transaction();
30
+ marketDataCall({
31
+ package: client.config.packages.waterx_perp_view.published_at,
32
+ arguments: {
33
+ marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
34
+ ticker: args.ticker,
35
+ },
36
+ typeArguments: [withLp(client, args.lpType)],
37
+ })(tx);
38
+ return MarketData.parse(await simulateAndExtract(client, tx));
39
+ }
40
+ export async function getPoolData(client, args = {}) {
41
+ const tx = new Transaction();
42
+ poolDataCall({
43
+ package: client.config.packages.waterx_perp_view.published_at,
44
+ arguments: { pool: tx.object(client.config.packages.wlp.wlp_pool) },
45
+ typeArguments: [withLp(client, args.lpType)],
46
+ })(tx);
47
+ return PoolData.parse(await simulateAndExtract(client, tx));
48
+ }
49
+ export async function getTokenPoolData(client, args) {
50
+ const tx = new Transaction();
51
+ tokenPoolDataCall({
52
+ package: client.config.packages.waterx_perp_view.published_at,
53
+ arguments: {
54
+ pool: tx.object(client.config.packages.wlp.wlp_pool),
55
+ tokenIndex: args.tokenIndex,
56
+ },
57
+ typeArguments: [withLp(client, args.lpType)],
58
+ })(tx);
59
+ return TokenPoolData.parse(await simulateAndExtract(client, tx));
60
+ }
61
+ export async function getGlobalConfigData(client) {
62
+ const tx = new Transaction();
63
+ globalConfigDataCall({
64
+ package: client.config.packages.waterx_perp_view.published_at,
65
+ arguments: { cfg: tx.object(client.config.packages.waterx_perp.global_config) },
66
+ })(tx);
67
+ return GlobalConfigData.parse(await simulateAndExtract(client, tx));
68
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Position / order reads + paginated market & account lists + redeem-request
3
+ * list (`waterx_perp_view`).
4
+ */
5
+ import { OrderData, PositionData, RedeemRequestData } from "../../generated/waterx_perp_view/view.ts";
6
+ import type { PerpClient } from "../client.ts";
7
+ export type PositionDataView = ReturnType<typeof PositionData.parse>;
8
+ export declare function positionExists(client: PerpClient, args: {
9
+ ticker: string;
10
+ positionId: bigint | number;
11
+ lpType?: string;
12
+ }): Promise<boolean>;
13
+ export declare function getPosition(client: PerpClient, args: {
14
+ ticker: string;
15
+ positionId: bigint | number;
16
+ /** Human-readable USD prices for Pnl / liq price calc; pass 0n if unsure. */
17
+ basePriceUsd: bigint | number;
18
+ collateralPriceUsd: bigint | number;
19
+ lpType?: string;
20
+ }): Promise<PositionDataView>;
21
+ export type OrderDataView = ReturnType<typeof OrderData.parse>;
22
+ export declare function getOrder(client: PerpClient, args: {
23
+ ticker: string;
24
+ orderId: bigint | number;
25
+ orderTypeTag: number;
26
+ triggerPrice: bigint | number;
27
+ basePriceUsd: bigint | number;
28
+ lpType?: string;
29
+ }): Promise<OrderDataView>;
30
+ export interface PageOpts {
31
+ cursor?: bigint | number;
32
+ pageSize?: bigint | number;
33
+ }
34
+ export declare function getMarketOrders(client: PerpClient, args: {
35
+ ticker: string;
36
+ basePriceUsd?: bigint | number;
37
+ lpType?: string;
38
+ } & PageOpts): Promise<{
39
+ orders: OrderDataView[];
40
+ nextCursor?: bigint;
41
+ }>;
42
+ export declare function getMarketPositions(client: PerpClient, args: {
43
+ ticker: string;
44
+ basePriceUsd: bigint | number;
45
+ collateralPriceUsd?: bigint | number;
46
+ lpType?: string;
47
+ } & PageOpts): Promise<{
48
+ positions: PositionDataView[];
49
+ nextCursor?: bigint;
50
+ }>;
51
+ export declare function getAccountPositions(client: PerpClient, args: {
52
+ ticker: string;
53
+ accountObjectAddress: string;
54
+ basePriceUsd: bigint | number;
55
+ collateralPriceUsd?: bigint | number;
56
+ lpType?: string;
57
+ }): Promise<PositionDataView[]>;
58
+ export declare function getAccountOrders(client: PerpClient, args: {
59
+ ticker: string;
60
+ accountObjectAddress: string;
61
+ basePriceUsd?: bigint | number;
62
+ lpType?: string;
63
+ }): Promise<OrderDataView[]>;
64
+ export type RedeemRequestDataView = ReturnType<typeof RedeemRequestData.parse>;
65
+ export declare function getRedeemRequests(client: PerpClient, args?: {
66
+ lpType?: string;
67
+ } & PageOpts): Promise<{
68
+ requests: RedeemRequestDataView[];
69
+ nextCursor?: bigint;
70
+ }>;
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Position / order reads + paginated market & account lists + redeem-request
3
+ * list (`waterx_perp_view`).
4
+ */
5
+ import { bcs } from "@mysten/sui/bcs";
6
+ import { Transaction } from "@mysten/sui/transactions";
7
+ import { getAccountOrders as getAccountOrdersCall, getAccountPositions as getAccountPositionsCall, getMarketOrders as getMarketOrdersCall, getMarketPositions as getMarketPositionsCall, getRedeemRequests as getRedeemRequestsCall, OrderData, orderData as orderDataCall, PositionData, positionData as positionDataCall, positionExists as positionExistsCall, RedeemRequestData, } from "../../generated/waterx_perp_view/view.js";
8
+ import { DRY_RUN_SENDER } from "../constants.js";
9
+ import { simulateAndExtract, toBytes, withLp } from "./simulate.js";
10
+ export async function positionExists(client, args) {
11
+ const tx = new Transaction();
12
+ positionExistsCall({
13
+ package: client.config.packages.waterx_perp_view.published_at,
14
+ arguments: {
15
+ marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
16
+ ticker: args.ticker,
17
+ positionId: args.positionId,
18
+ },
19
+ typeArguments: [withLp(client, args.lpType)],
20
+ })(tx);
21
+ const bytes = await simulateAndExtract(client, tx);
22
+ return bcs.bool().parse(bytes);
23
+ }
24
+ export async function getPosition(client, args) {
25
+ const tx = new Transaction();
26
+ positionDataCall({
27
+ package: client.config.packages.waterx_perp_view.published_at,
28
+ arguments: {
29
+ marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
30
+ ticker: args.ticker,
31
+ pool: tx.object(client.config.packages.wlp.wlp_pool),
32
+ basePriceUsd: args.basePriceUsd,
33
+ collateralPriceUsd: args.collateralPriceUsd,
34
+ positionId: args.positionId,
35
+ },
36
+ typeArguments: [withLp(client, args.lpType)],
37
+ })(tx);
38
+ return PositionData.parse(await simulateAndExtract(client, tx));
39
+ }
40
+ export async function getOrder(client, args) {
41
+ const tx = new Transaction();
42
+ orderDataCall({
43
+ package: client.config.packages.waterx_perp_view.published_at,
44
+ arguments: {
45
+ marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
46
+ ticker: args.ticker,
47
+ basePriceUsd: args.basePriceUsd,
48
+ orderTypeTag: args.orderTypeTag,
49
+ triggerPrice: args.triggerPrice,
50
+ orderId: args.orderId,
51
+ },
52
+ typeArguments: [withLp(client, args.lpType)],
53
+ })(tx);
54
+ return OrderData.parse(await simulateAndExtract(client, tx));
55
+ }
56
+ export async function getMarketOrders(client, args) {
57
+ const tx = new Transaction();
58
+ getMarketOrdersCall({
59
+ package: client.config.packages.waterx_perp_view.published_at,
60
+ arguments: {
61
+ marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
62
+ ticker: args.ticker,
63
+ basePriceUsd: args.basePriceUsd ?? 0n,
64
+ cursor: args.cursor ?? 0n,
65
+ pageSize: args.pageSize ?? 100n,
66
+ },
67
+ typeArguments: [withLp(client, args.lpType)],
68
+ })(tx);
69
+ tx.setSender(DRY_RUN_SENDER);
70
+ const sim = (await client.simulate(tx));
71
+ const ret = sim.commandResults?.[0]?.returnValues;
72
+ if (!ret)
73
+ return { orders: [] };
74
+ const ordersBytes = toBytes(ret[0]?.bcs) ?? toBytes(ret[0]?.value?.bcs);
75
+ const cursorBytes = toBytes(ret[1]?.bcs) ?? toBytes(ret[1]?.value?.bcs);
76
+ if (!ordersBytes)
77
+ return { orders: [] };
78
+ const ordersBuf = ordersBytes;
79
+ const orders = bcs.vector(OrderData).parse(ordersBuf);
80
+ let nextCursor;
81
+ if (cursorBytes) {
82
+ const cb = cursorBytes;
83
+ const opt = bcs.option(bcs.u64()).parse(cb);
84
+ if (opt)
85
+ nextCursor = BigInt(opt);
86
+ }
87
+ return { orders, nextCursor };
88
+ }
89
+ export async function getMarketPositions(client, args) {
90
+ const tx = new Transaction();
91
+ getMarketPositionsCall({
92
+ package: client.config.packages.waterx_perp_view.published_at,
93
+ arguments: {
94
+ marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
95
+ ticker: args.ticker,
96
+ pool: tx.object(client.config.packages.wlp.wlp_pool),
97
+ basePriceUsd: args.basePriceUsd,
98
+ collateralPriceUsd: args.collateralPriceUsd ?? 0n,
99
+ cursor: args.cursor ?? 0n,
100
+ pageSize: args.pageSize ?? 100n,
101
+ },
102
+ typeArguments: [withLp(client, args.lpType)],
103
+ })(tx);
104
+ tx.setSender(DRY_RUN_SENDER);
105
+ const sim = (await client.simulate(tx));
106
+ const ret = sim.commandResults?.[0]?.returnValues;
107
+ if (!ret)
108
+ return { positions: [] };
109
+ const positionsBytes = toBytes(ret[0]?.bcs) ?? toBytes(ret[0]?.value?.bcs);
110
+ const cursorBytes = toBytes(ret[1]?.bcs) ?? toBytes(ret[1]?.value?.bcs);
111
+ if (!positionsBytes)
112
+ return { positions: [] };
113
+ const buf = positionsBytes;
114
+ const positions = bcs.vector(PositionData).parse(buf);
115
+ let nextCursor;
116
+ if (cursorBytes) {
117
+ const cb = cursorBytes;
118
+ const opt = bcs.option(bcs.u64()).parse(cb);
119
+ if (opt)
120
+ nextCursor = BigInt(opt);
121
+ }
122
+ return { positions, nextCursor };
123
+ }
124
+ export async function getAccountPositions(client, args) {
125
+ const tx = new Transaction();
126
+ getAccountPositionsCall({
127
+ package: client.config.packages.waterx_perp_view.published_at,
128
+ arguments: {
129
+ marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
130
+ ticker: args.ticker,
131
+ pool: tx.object(client.config.packages.wlp.wlp_pool),
132
+ wxaRegistry: tx.object(client.config.packages.waterx_account.account_registry),
133
+ basePriceUsd: args.basePriceUsd,
134
+ collateralPriceUsd: args.collateralPriceUsd ?? 0n,
135
+ accountObjectAddress: args.accountObjectAddress,
136
+ },
137
+ typeArguments: [withLp(client, args.lpType)],
138
+ })(tx);
139
+ return bcs.vector(PositionData).parse(await simulateAndExtract(client, tx));
140
+ }
141
+ export async function getAccountOrders(client, args) {
142
+ const tx = new Transaction();
143
+ getAccountOrdersCall({
144
+ package: client.config.packages.waterx_perp_view.published_at,
145
+ arguments: {
146
+ marketRegistry: tx.object(client.config.packages.waterx_perp.market_registry_wlp),
147
+ ticker: args.ticker,
148
+ basePriceUsd: args.basePriceUsd ?? 0n,
149
+ accountObjectAddress: args.accountObjectAddress,
150
+ },
151
+ typeArguments: [withLp(client, args.lpType)],
152
+ })(tx);
153
+ return bcs.vector(OrderData).parse(await simulateAndExtract(client, tx));
154
+ }
155
+ export async function getRedeemRequests(client, args = {}) {
156
+ const tx = new Transaction();
157
+ getRedeemRequestsCall({
158
+ package: client.config.packages.waterx_perp_view.published_at,
159
+ arguments: {
160
+ pool: tx.object(client.config.packages.wlp.wlp_pool),
161
+ cursor: args.cursor ?? 0n,
162
+ pageSize: args.pageSize ?? 100n,
163
+ },
164
+ typeArguments: [withLp(client, args.lpType)],
165
+ })(tx);
166
+ tx.setSender(DRY_RUN_SENDER);
167
+ const sim = (await client.simulate(tx));
168
+ const ret = sim.commandResults?.[0]?.returnValues;
169
+ if (!ret)
170
+ return { requests: [] };
171
+ const reqBytes = toBytes(ret[0]?.bcs) ?? toBytes(ret[0]?.value?.bcs);
172
+ const cursorBytes = toBytes(ret[1]?.bcs) ?? toBytes(ret[1]?.value?.bcs);
173
+ if (!reqBytes)
174
+ return { requests: [] };
175
+ const buf = reqBytes;
176
+ const requests = bcs.vector(RedeemRequestData).parse(buf);
177
+ let nextCursor;
178
+ if (cursorBytes) {
179
+ const cb = cursorBytes;
180
+ const opt = bcs.option(bcs.u64()).parse(cb);
181
+ if (opt)
182
+ nextCursor = BigInt(opt);
183
+ }
184
+ return { requests, nextCursor };
185
+ }
@@ -0,0 +1,12 @@
1
+ import type { PerpClient } from "../client.ts";
2
+ /**
3
+ * Perp `fetch/` simulate plumbing.
4
+ *
5
+ * The generic simulate/decode core (build one-shot PTB → `client.simulate(tx)`
6
+ * with the zero-address sender → decode BCS) lives in the account base
7
+ * (`account/fetch/simulate.ts`) so it isn't duplicated per line; re-exported
8
+ * here unchanged. Only `withLp` (perp's WLP-type default) is perp-specific.
9
+ * Internal to `fetch/` — not part of the public surface.
10
+ */
11
+ export { type SimulationCommandResult, type SimulationResult, extractAt, simulateAndExtract, simulateRaw, toBytes, } from "../../account/fetch/simulate.ts";
12
+ export declare function withLp(client: PerpClient, lpType?: string): string;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Perp `fetch/` simulate plumbing.
3
+ *
4
+ * The generic simulate/decode core (build one-shot PTB → `client.simulate(tx)`
5
+ * with the zero-address sender → decode BCS) lives in the account base
6
+ * (`account/fetch/simulate.ts`) so it isn't duplicated per line; re-exported
7
+ * here unchanged. Only `withLp` (perp's WLP-type default) is perp-specific.
8
+ * Internal to `fetch/` — not part of the public surface.
9
+ */
10
+ export { extractAt, simulateAndExtract, simulateRaw, toBytes, } from "../../account/fetch/simulate.js";
11
+ export function withLp(client, lpType) {
12
+ return lpType ?? client.wlpType();
13
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Read-only perp queries — barrel.
3
+ *
4
+ * Each helper builds a one-shot PTB, runs `client.simulate(tx)` (zero-address
5
+ * sender), and decodes the BCS return values. Implementations are split by
6
+ * domain under `fetch/`:
7
+ *
8
+ * simulate.ts simulate/decode plumbing (internal; core in account/fetch/)
9
+ * market.ts account data + market / pool / token-pool / global-config
10
+ * positions.ts position / order reads + paginated lists + redeem requests
11
+ * account.ts wxa account reads + inclusive spendable-credit balance
12
+ * custody.ts native-custody PSM reads
13
+ * bridge.ts wormhole_bridge limits + withdrawal_queue fee estimate
14
+ *
15
+ * Referral reads (`waterx_referral`) live in the account base
16
+ * (`account/fetch/referral.ts`) and are re-exported here for the perp surface.
17
+ */
18
+ export * from "../account/fetch/referral.ts";
19
+ export * from "./fetch/market.ts";
20
+ export * from "./fetch/positions.ts";
21
+ export * from "./fetch/account.ts";
22
+ export * from "./fetch/custody.ts";
23
+ export * from "./fetch/bridge.ts";
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Read-only perp queries — barrel.
3
+ *
4
+ * Each helper builds a one-shot PTB, runs `client.simulate(tx)` (zero-address
5
+ * sender), and decodes the BCS return values. Implementations are split by
6
+ * domain under `fetch/`:
7
+ *
8
+ * simulate.ts simulate/decode plumbing (internal; core in account/fetch/)
9
+ * market.ts account data + market / pool / token-pool / global-config
10
+ * positions.ts position / order reads + paginated lists + redeem requests
11
+ * account.ts wxa account reads + inclusive spendable-credit balance
12
+ * custody.ts native-custody PSM reads
13
+ * bridge.ts wormhole_bridge limits + withdrawal_queue fee estimate
14
+ *
15
+ * Referral reads (`waterx_referral`) live in the account base
16
+ * (`account/fetch/referral.ts`) and are re-exported here for the perp surface.
17
+ */
18
+ export * from "../account/fetch/referral.js";
19
+ export * from "./fetch/market.js";
20
+ export * from "./fetch/positions.js";
21
+ export * from "./fetch/account.js";
22
+ export * from "./fetch/custody.js";
23
+ export * from "./fetch/bridge.js";