@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
@@ -1,254 +0,0 @@
1
- /**
2
- * Read-only queries built on top of `waterx_perp_view`.
3
- *
4
- * Each helper builds a one-shot PTB, runs `client.simulate(tx)`, and
5
- * decodes the first command's return values into the matching generated
6
- * BCS struct. The simulated sender is the zero address.
7
- */
8
- import type { WaterXClient } from "./client.ts";
9
- import { AccountData, GlobalConfigData, MarketData, OrderData, PoolData, PositionData, RedeemRequestData, TokenPoolData } from "./generated/waterx_perp_view/view.ts";
10
- import { type ParkedBackingAssetBalance } from "./utils/consolidate-balance.ts";
11
- export type AccountDataView = ReturnType<typeof AccountData.parse>;
12
- /**
13
- * Look up the registered AccountData for a given wxa account ID.
14
- * Returns `undefined` if the account has no perp data slot installed yet
15
- * (the slot auto-installs on the first `add_position` / `add_order`).
16
- * The underlying view fn returns `Option<AccountData>`.
17
- */
18
- export declare function getAccountData(client: WaterXClient, accountId: string): Promise<AccountDataView | undefined>;
19
- export type MarketDataView = ReturnType<typeof MarketData.parse>;
20
- export type PoolDataView = ReturnType<typeof PoolData.parse>;
21
- export type TokenPoolDataView = ReturnType<typeof TokenPoolData.parse>;
22
- export type GlobalConfigDataView = ReturnType<typeof GlobalConfigData.parse>;
23
- export declare function getMarketData(client: WaterXClient, args: {
24
- ticker: string;
25
- lpType?: string;
26
- }): Promise<MarketDataView>;
27
- export declare function getPoolData(client: WaterXClient, args?: {
28
- lpType?: string;
29
- }): Promise<PoolDataView>;
30
- export declare function getTokenPoolData(client: WaterXClient, args: {
31
- tokenIndex: bigint | number;
32
- lpType?: string;
33
- }): Promise<TokenPoolDataView>;
34
- export declare function getGlobalConfigData(client: WaterXClient): Promise<GlobalConfigDataView>;
35
- export type PositionDataView = ReturnType<typeof PositionData.parse>;
36
- export declare function positionExists(client: WaterXClient, args: {
37
- ticker: string;
38
- positionId: bigint | number;
39
- lpType?: string;
40
- }): Promise<boolean>;
41
- export declare function getPosition(client: WaterXClient, args: {
42
- ticker: string;
43
- positionId: bigint | number;
44
- /** Human-readable USD prices for Pnl / liq price calc; pass 0n if unsure. */
45
- basePriceUsd: bigint | number;
46
- collateralPriceUsd: bigint | number;
47
- lpType?: string;
48
- }): Promise<PositionDataView>;
49
- export type OrderDataView = ReturnType<typeof OrderData.parse>;
50
- export declare function getOrder(client: WaterXClient, args: {
51
- ticker: string;
52
- orderId: bigint | number;
53
- orderTypeTag: number;
54
- triggerPrice: bigint | number;
55
- basePriceUsd: bigint | number;
56
- lpType?: string;
57
- }): Promise<OrderDataView>;
58
- export interface PageOpts {
59
- cursor?: bigint | number;
60
- pageSize?: bigint | number;
61
- }
62
- export declare function getMarketOrders(client: WaterXClient, args: {
63
- ticker: string;
64
- basePriceUsd?: bigint | number;
65
- lpType?: string;
66
- } & PageOpts): Promise<{
67
- orders: OrderDataView[];
68
- nextCursor?: bigint;
69
- }>;
70
- export declare function getMarketPositions(client: WaterXClient, args: {
71
- ticker: string;
72
- basePriceUsd: bigint | number;
73
- collateralPriceUsd?: bigint | number;
74
- lpType?: string;
75
- } & PageOpts): Promise<{
76
- positions: PositionDataView[];
77
- nextCursor?: bigint;
78
- }>;
79
- export declare function getAccountPositions(client: WaterXClient, args: {
80
- ticker: string;
81
- accountObjectAddress: string;
82
- basePriceUsd: bigint | number;
83
- collateralPriceUsd?: bigint | number;
84
- lpType?: string;
85
- }): Promise<PositionDataView[]>;
86
- export declare function getAccountOrders(client: WaterXClient, args: {
87
- ticker: string;
88
- accountObjectAddress: string;
89
- basePriceUsd?: bigint | number;
90
- lpType?: string;
91
- }): Promise<OrderDataView[]>;
92
- export type RedeemRequestDataView = ReturnType<typeof RedeemRequestData.parse>;
93
- export declare function getRedeemRequests(client: WaterXClient, args?: {
94
- lpType?: string;
95
- } & PageOpts): Promise<{
96
- requests: RedeemRequestDataView[];
97
- nextCursor?: bigint;
98
- }>;
99
- /** Returns the referrer address bound to `referee`, or `undefined` if none. */
100
- export declare function getRefererFor(client: WaterXClient, referee: string): Promise<string | undefined>;
101
- /** True if `code` is a syntactically valid referral code (matches the contract's char rules). */
102
- export declare function isValidReferralCode(client: WaterXClient, code: string): Promise<boolean>;
103
- /** True if `code` is already claimed in the on-chain ReferralTable. */
104
- export declare function referralCodeExists(client: WaterXClient, code: string): Promise<boolean>;
105
- /**
106
- * List the wxa account IDs owned by `owner` (`account::account_ids`).
107
- * Returns `[]` when the owner has never created an account. Use this to
108
- * resolve the `account_id` a cross-chain deposit must target before
109
- * filling the EVM `suiRecipient` field.
110
- */
111
- export declare function getAccountsByOwner(client: WaterXClient, owner: string): Promise<string[]>;
112
- /**
113
- * A wxa account's stored `Balance<T>` (`account::account_balance<T>`).
114
- * `coinType` defaults to the deployment's CREDIT type — i.e. the bridged
115
- * balance available to withdraw. Returns `0n` for an unknown coin type.
116
- */
117
- export declare function getAccountBalance(client: WaterXClient, accountId: string, coinType?: string): Promise<bigint>;
118
- /**
119
- * Inclusive wxUSD credit an account can spend after the default async tx-builder
120
- * pre-sweep ({@link appendConsolidateForSpend}).
121
- *
122
- * - `internalRaw` — stored `Balance<CREDIT>` (`getAccountBalance`).
123
- * - `pendingBackingRaw` — native-custody backing assets (USDC, USDSUI, …)
124
- * parked at the account's Sui address, rescaled to CREDIT decimals at the
125
- * 1:1 PSM peg (same probe as {@link appendConsolidateToUsd}).
126
- * - `pendingCreditAtAddressRaw` — CREDIT at the account address (accumulator +
127
- * owned coins). Swept into the internal slot by
128
- * {@link appendConsolidateAddressCredit} via `consumeDepositDirect`.
129
- * - `totalRaw` — sum of the three components; matches post-
130
- * {@link appendConsolidateForSpend} spendable balance for predict / perp
131
- * builders with `consolidateToUsd: true` (default).
132
- */
133
- export interface SpendableCreditBalance {
134
- internalRaw: bigint;
135
- pendingBackingRaw: bigint;
136
- pendingCreditAtAddressRaw: bigint;
137
- totalRaw: bigint;
138
- /** Per-asset breakdown for the backing-asset probe (empty when nothing parked). */
139
- parkedBacking: ParkedBackingAssetBalance[];
140
- }
141
- export declare function getSpendableCreditBalance(client: WaterXClient, accountId: string): Promise<SpendableCreditBalance>;
142
- /** Vault-wide native-custody state. */
143
- export interface CustodyVaultData {
144
- /** Total CREDIT minted by the custody vault (`credit_supply`). */
145
- creditSupply: bigint;
146
- }
147
- /** Reads vault-wide native-custody state via `custody_vault::credit_supply`. */
148
- export declare function getCustodyVaultData(client: WaterXClient): Promise<CustodyVaultData>;
149
- /** Per-asset native-custody state for one backing asset. */
150
- export interface CustodyAssetData {
151
- /** Whether the asset is registered as a `SingleVault` on the custody vault. */
152
- registered: boolean;
153
- /** 1e9-scaled default mint fee rate (`0n` when the asset is not registered). */
154
- mintFeeRate: bigint;
155
- /** 1e9-scaled default burn fee rate (`0n` when the asset is not registered). */
156
- burnFeeRate: bigint;
157
- }
158
- /**
159
- * Reads per-asset native-custody state for backing asset `assetType`.
160
- *
161
- * Fee rates are the vault's default config — queried with the zero address as
162
- * caller, so no partner discount is applied — as 1e9-scaled `Float` values.
163
- * When the asset is not registered, returns `registered: false` with `0n` rates.
164
- *
165
- * Note: the `SingleVault` balance / decimal / backing / min-burn / deprecated
166
- * fields are not exposed here — the contract's getters for those return a
167
- * `&SingleVault<T>` reference, which a PTB simulate cannot read.
168
- */
169
- export declare function getCustodyAssetData(client: WaterXClient, assetType: string): Promise<CustodyAssetData>;
170
- /**
171
- * Live rate-limit / cap snapshot read from the `wormhole_bridge::Bridge`
172
- * shared object. All amounts are raw base units of the bridged credit coin.
173
- *
174
- * `dailyMinted` / `dailyBurned` are the sliding-window sums as the on-chain
175
- * `daily_minted` / `daily_burned` views report them — buckets that rotated
176
- * out of the trailing window are evicted lazily on the next mint/burn, so
177
- * these can read slightly high until then (conservative).
178
- */
179
- export interface BridgeLimitsView {
180
- paused: boolean;
181
- dailyMintLimit: bigint;
182
- dailyMinted: bigint;
183
- maxMintPerTx: bigint;
184
- dailyBurnLimit: bigint;
185
- dailyBurned: bigint;
186
- maxBurnPerTx: bigint;
187
- /** Per-account 24h burn cap; 0n means the gate is disabled. */
188
- personalBurnCapAmount: bigint;
189
- /** Present only when `accountId` is supplied — burn counted in that
190
- * account's current window (the per-account cap key is the account id). */
191
- personalBurned?: bigint;
192
- /** Present only when `backing` is supplied — `minted_for(chainId, token)`,
193
- * the amount currently withdrawable to that EVM (chain, token). */
194
- backingMinted?: bigint;
195
- }
196
- export interface BridgeLimitsArgs {
197
- /** wxa trading account id — enables the per-account `personalBurned` read. */
198
- accountId?: string;
199
- /** Wormhole destination chain id + 20-byte EVM token — enables the
200
- * `mintedFor` backing read. */
201
- backing?: {
202
- wormholeChainId: number;
203
- token: Uint8Array | number[];
204
- };
205
- }
206
- /**
207
- * Batched read of the bridge's rate-limit / cap state in a single simulate.
208
- * Pass `accountId` to also fetch the per-account burn usage, and `backing`
209
- * to also fetch the destination-chain backing (`minted_for`).
210
- *
211
- * Throws if `wormhole_bridge` (or its `Bridge` object id) is absent from the
212
- * canonical config — e.g. on a network where the Sui bridge isn't published.
213
- */
214
- export declare function getBridgeLimits(client: WaterXClient, args?: BridgeLimitsArgs): Promise<BridgeLimitsView>;
215
- export interface BridgeFeeView {
216
- /** Raw fee charged on a wormhole (Sui → EVM) exit of `amount`:
217
- * `max(ceil(effectiveRate * amount), effectiveMinFee)`. */
218
- feeAmount: bigint;
219
- /** Whether the exit clears the on-chain net-zero guard — i.e. a strictly
220
- * positive amount remains after the fee. Gate "estimated fee" UI on THIS,
221
- * not `feeAmount` alone: a dust `amount`, or a min-fee floor ≥ `amount`,
222
- * makes `feeAmount >= amount` and the exit would abort (audit L1). */
223
- wouldExecute: boolean;
224
- /** Effective % rate for the chain (per-chain override → default → 0),
225
- * 1e9-scaled (the `Float`-as-`u128` ABI convention). */
226
- effectiveRate: bigint;
227
- /** Effective minimum-fee floor for the chain (override → default → 0),
228
- * in CREDIT base units. */
229
- effectiveMinFee: bigint;
230
- /** Net CREDIT the recipient receives after the fee; `0n` when the exit
231
- * wouldn't execute (`wouldExecute === false`). */
232
- netAmount: bigint;
233
- }
234
- /**
235
- * Estimate the bridge fee for a wormhole (Sui → EVM) CREDIT exit of `amount`
236
- * to `evmDestinationChain`, read in a single simulate from the on-chain
237
- * `withdrawal_queue` views. The charged fee is
238
- * `max(ceil(effectiveRate * amount), effectiveMinFee)`.
239
- *
240
- * Surface UI off `wouldExecute`, NOT `feeAmount` alone — `feeAmount` is the raw
241
- * fee and can equal/exceed `amount` (ceil rounding on a dust entry, or a min-fee
242
- * floor larger than the entry), in which case the on-chain exit aborts its
243
- * net-zero guard (audit L1). `netAmount` is `0n` whenever `wouldExecute` is
244
- * false.
245
- *
246
- * @param args.amount CREDIT base units (the bridged coin's smallest unit).
247
- * @param args.evmDestinationChain WORMHOLE chain id of the destination EVM.
248
- * @param args.creditType CREDIT coin type; defaults to `client.creditType()`.
249
- */
250
- export declare function getBridgeFee(client: WaterXClient, args: {
251
- evmDestinationChain: number;
252
- amount: bigint | number;
253
- creditType?: string;
254
- }): Promise<BridgeFeeView>;