@waterx/sdk 2.1.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.
- package/LICENSE +21 -0
- package/README.md +204 -0
- package/dist/src/client.d.ts +109 -0
- package/dist/src/client.js +197 -0
- package/dist/src/config.d.ts +229 -0
- package/dist/src/config.js +107 -0
- package/dist/src/constants.d.ts +64 -0
- package/dist/src/constants.js +71 -0
- package/dist/src/fetch.d.ts +144 -0
- package/dist/src/fetch.js +419 -0
- package/dist/src/generated/bucket_v2_framework/account.d.ts +107 -0
- package/dist/src/generated/bucket_v2_framework/account.js +129 -0
- package/dist/src/generated/bucket_v2_framework/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/bucket_v2_framework/deps/std/type_name.js +19 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/balance.d.ts +12 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/balance.js +14 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/bucket_v2_framework/double.d.ts +384 -0
- package/dist/src/generated/bucket_v2_framework/double.js +466 -0
- package/dist/src/generated/bucket_v2_framework/float.d.ts +364 -0
- package/dist/src/generated/bucket_v2_framework/float.js +440 -0
- package/dist/src/generated/bucket_v2_framework/liability.d.ts +197 -0
- package/dist/src/generated/bucket_v2_framework/liability.js +205 -0
- package/dist/src/generated/bucket_v2_framework/linked_table.d.ts +384 -0
- package/dist/src/generated/bucket_v2_framework/linked_table.js +382 -0
- package/dist/src/generated/bucket_v2_framework/sheet.d.ts +424 -0
- package/dist/src/generated/bucket_v2_framework/sheet.js +344 -0
- package/dist/src/generated/native_custody/custody_vault.d.ts +572 -0
- package/dist/src/generated/native_custody/custody_vault.js +483 -0
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/float.js +10 -0
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/liability.d.ts +11 -0
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/liability.js +13 -0
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/sheet.d.ts +49 -0
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/sheet.js +18 -0
- package/dist/src/generated/native_custody/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/native_custody/deps/std/type_name.js +19 -0
- package/dist/src/generated/native_custody/deps/sui/balance.d.ts +12 -0
- package/dist/src/generated/native_custody/deps/sui/balance.js +14 -0
- package/dist/src/generated/native_custody/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/native_custody/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/native_custody/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/native_custody/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/native_custody/events.d.ts +36 -0
- package/dist/src/generated/native_custody/events.js +36 -0
- package/dist/src/generated/pyth_sponsor_rule/deps/sui/balance.d.ts +12 -0
- package/dist/src/generated/pyth_sponsor_rule/deps/sui/balance.js +14 -0
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +68 -0
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +74 -0
- package/dist/src/generated/utils/index.d.ts +30 -0
- package/dist/src/generated/utils/index.js +157 -0
- package/dist/src/generated/waterx_account/account.d.ts +1818 -0
- package/dist/src/generated/waterx_account/account.js +1723 -0
- package/dist/src/generated/waterx_account/deps/bucket_v2_framework/liability.d.ts +11 -0
- package/dist/src/generated/waterx_account/deps/bucket_v2_framework/liability.js +13 -0
- package/dist/src/generated/waterx_account/deps/bucket_v2_framework/sheet.d.ts +49 -0
- package/dist/src/generated/waterx_account/deps/bucket_v2_framework/sheet.js +18 -0
- package/dist/src/generated/waterx_account/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/waterx_account/deps/std/type_name.js +19 -0
- package/dist/src/generated/waterx_account/deps/sui/balance.d.ts +12 -0
- package/dist/src/generated/waterx_account/deps/sui/balance.js +14 -0
- package/dist/src/generated/waterx_account/deps/sui/object_table.d.ts +17 -0
- package/dist/src/generated/waterx_account/deps/sui/object_table.js +19 -0
- package/dist/src/generated/waterx_account/deps/sui/table.d.ts +29 -0
- package/dist/src/generated/waterx_account/deps/sui/table.js +31 -0
- package/dist/src/generated/waterx_account/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_account/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_account/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/waterx_account/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/waterx_account/direct_rule.d.ts +77 -0
- package/dist/src/generated/waterx_account/direct_rule.js +78 -0
- package/dist/src/generated/waterx_account/events.d.ts +180 -0
- package/dist/src/generated/waterx_account/events.js +156 -0
- package/dist/src/generated/waterx_account/version.d.ts +10 -0
- package/dist/src/generated/waterx_account/version.js +8 -0
- package/dist/src/generated/waterx_credit/credit_registry.d.ts +708 -0
- package/dist/src/generated/waterx_credit/credit_registry.js +658 -0
- package/dist/src/generated/waterx_credit/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/waterx_credit/deps/std/type_name.js +19 -0
- package/dist/src/generated/waterx_credit/deps/sui/table.d.ts +29 -0
- package/dist/src/generated/waterx_credit/deps/sui/table.js +31 -0
- package/dist/src/generated/waterx_credit/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_credit/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_credit/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/waterx_credit/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/waterx_credit/limited_supply.d.ts +107 -0
- package/dist/src/generated/waterx_credit/limited_supply.js +131 -0
- package/dist/src/generated/waterx_oracle/aggregator.d.ts +211 -0
- package/dist/src/generated/waterx_oracle/aggregator.js +213 -0
- package/dist/src/generated/waterx_oracle/collector.d.ts +119 -0
- package/dist/src/generated/waterx_oracle/collector.js +105 -0
- package/dist/src/generated/waterx_oracle/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/src/generated/waterx_oracle/deps/bucket_v2_framework/float.js +10 -0
- package/dist/src/generated/waterx_oracle/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/waterx_oracle/deps/std/type_name.js +19 -0
- package/dist/src/generated/waterx_oracle/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_oracle/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_oracle/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/waterx_oracle/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/waterx_oracle/oracle.d.ts +298 -0
- package/dist/src/generated/waterx_oracle/oracle.js +323 -0
- package/dist/src/generated/waterx_oracle/version.d.ts +10 -0
- package/dist/src/generated/waterx_oracle/version.js +8 -0
- package/dist/src/generated/waterx_perp/account_data.d.ts +269 -0
- package/dist/src/generated/waterx_perp/account_data.js +284 -0
- package/dist/src/generated/waterx_perp/admin.d.ts +19 -0
- package/dist/src/generated/waterx_perp/admin.js +22 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/double.d.ts +8 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/double.js +10 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/float.js +10 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/liability.d.ts +11 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/liability.js +13 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/linked_table.d.ts +8 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/linked_table.js +18 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/sheet.d.ts +49 -0
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/sheet.js +18 -0
- package/dist/src/generated/waterx_perp/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/waterx_perp/deps/std/type_name.js +19 -0
- package/dist/src/generated/waterx_perp/deps/sui/balance.d.ts +15 -0
- package/dist/src/generated/waterx_perp/deps/sui/balance.js +17 -0
- package/dist/src/generated/waterx_perp/deps/sui/coin.d.ts +14 -0
- package/dist/src/generated/waterx_perp/deps/sui/coin.js +15 -0
- package/dist/src/generated/waterx_perp/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_perp/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_perp/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/waterx_perp/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/waterx_perp/events.d.ts +1283 -0
- package/dist/src/generated/waterx_perp/events.js +1018 -0
- package/dist/src/generated/waterx_perp/global_config.d.ts +775 -0
- package/dist/src/generated/waterx_perp/global_config.js +836 -0
- package/dist/src/generated/waterx_perp/keyed_big_vector.d.ts +553 -0
- package/dist/src/generated/waterx_perp/keyed_big_vector.js +554 -0
- package/dist/src/generated/waterx_perp/lp_pool.d.ts +1648 -0
- package/dist/src/generated/waterx_perp/lp_pool.js +1521 -0
- package/dist/src/generated/waterx_perp/market_config.d.ts +715 -0
- package/dist/src/generated/waterx_perp/market_config.js +780 -0
- package/dist/src/generated/waterx_perp/math.d.ts +63 -0
- package/dist/src/generated/waterx_perp/math.js +64 -0
- package/dist/src/generated/waterx_perp/memo.d.ts +251 -0
- package/dist/src/generated/waterx_perp/memo.js +323 -0
- package/dist/src/generated/waterx_perp/order_book.d.ts +290 -0
- package/dist/src/generated/waterx_perp/order_book.js +329 -0
- package/dist/src/generated/waterx_perp/position.d.ts +1005 -0
- package/dist/src/generated/waterx_perp/position.js +1103 -0
- package/dist/src/generated/waterx_perp/request.d.ts +544 -0
- package/dist/src/generated/waterx_perp/request.js +541 -0
- package/dist/src/generated/waterx_perp/response.d.ts +247 -0
- package/dist/src/generated/waterx_perp/response.js +280 -0
- package/dist/src/generated/waterx_perp/trading.d.ts +2821 -0
- package/dist/src/generated/waterx_perp/trading.js +2372 -0
- package/dist/src/generated/waterx_perp/version.d.ts +10 -0
- package/dist/src/generated/waterx_perp/version.js +8 -0
- package/dist/src/generated/waterx_perp/witness.d.ts +18 -0
- package/dist/src/generated/waterx_perp/witness.js +21 -0
- package/dist/src/generated/waterx_perp_view/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/waterx_perp_view/deps/std/type_name.js +19 -0
- package/dist/src/generated/waterx_perp_view/view.d.ts +447 -0
- package/dist/src/generated/waterx_perp_view/view.js +414 -0
- package/dist/src/generated/waterx_pyth_rule/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_pyth_rule/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +90 -0
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +72 -0
- package/dist/src/generated/waterx_referral/deps/sui/table.d.ts +29 -0
- package/dist/src/generated/waterx_referral/deps/sui/table.js +31 -0
- package/dist/src/generated/waterx_referral/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/waterx_referral/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/waterx_referral/referral_table.d.ts +171 -0
- package/dist/src/generated/waterx_referral/referral_table.js +192 -0
- package/dist/src/generated/waterx_staking/deps/bucket_v2_framework/double.d.ts +8 -0
- package/dist/src/generated/waterx_staking/deps/bucket_v2_framework/double.js +10 -0
- package/dist/src/generated/waterx_staking/deps/sui/balance.d.ts +12 -0
- package/dist/src/generated/waterx_staking/deps/sui/balance.js +14 -0
- package/dist/src/generated/waterx_staking/deps/sui/table.d.ts +29 -0
- package/dist/src/generated/waterx_staking/deps/sui/table.js +31 -0
- package/dist/src/generated/waterx_staking/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/waterx_staking/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/waterx_staking/waterx_staking.d.ts +746 -0
- package/dist/src/generated/waterx_staking/waterx_staking.js +731 -0
- package/dist/src/generated/waterx_staking/witness.d.ts +16 -0
- package/dist/src/generated/waterx_staking/witness.js +18 -0
- package/dist/src/generated/withdrawal_queue/deps/bucket_v2_framework/linked_table.d.ts +8 -0
- package/dist/src/generated/withdrawal_queue/deps/bucket_v2_framework/linked_table.js +18 -0
- package/dist/src/generated/withdrawal_queue/deps/std/type_name.d.ts +17 -0
- package/dist/src/generated/withdrawal_queue/deps/std/type_name.js +19 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/balance.d.ts +12 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/balance.js +14 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.d.ts +483 -0
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.js +480 -0
- package/dist/src/generated/wlp/wlp.d.ts +28 -0
- package/dist/src/generated/wlp/wlp.js +32 -0
- package/dist/src/generated/wormhole_bridge/deps/sui/table.d.ts +29 -0
- package/dist/src/generated/wormhole_bridge/deps/sui/table.js +31 -0
- package/dist/src/generated/wormhole_bridge/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/wormhole_bridge/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/wormhole_bridge/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/wormhole_bridge/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/wormhole_bridge/deps/wormhole_sdk/consumed_vaas.d.ts +12 -0
- package/dist/src/generated/wormhole_bridge/deps/wormhole_sdk/consumed_vaas.js +9 -0
- package/dist/src/generated/wormhole_bridge/deps/wormhole_sdk/emitter.d.ts +14 -0
- package/dist/src/generated/wormhole_bridge/deps/wormhole_sdk/emitter.js +16 -0
- package/dist/src/generated/wormhole_bridge/deps/wormhole_sdk/set.d.ts +16 -0
- package/dist/src/generated/wormhole_bridge/deps/wormhole_sdk/set.js +15 -0
- package/dist/src/generated/wormhole_bridge/events.d.ts +32 -0
- package/dist/src/generated/wormhole_bridge/events.js +28 -0
- package/dist/src/generated/wormhole_bridge/wormhole_bridge.d.ts +498 -0
- package/dist/src/generated/wormhole_bridge/wormhole_bridge.js +494 -0
- package/dist/src/index.d.ts +28 -0
- package/dist/src/index.js +34 -0
- package/dist/src/tx-builders.d.ts +242 -0
- package/dist/src/tx-builders.js +320 -0
- package/dist/src/user/account.d.ts +129 -0
- package/dist/src/user/account.js +166 -0
- package/dist/src/user/credit.d.ts +135 -0
- package/dist/src/user/credit.js +255 -0
- package/dist/src/user/custody.d.ts +71 -0
- package/dist/src/user/custody.js +112 -0
- package/dist/src/user/index.d.ts +8 -0
- package/dist/src/user/index.js +8 -0
- package/dist/src/user/order.d.ts +89 -0
- package/dist/src/user/order.js +134 -0
- package/dist/src/user/referral.d.ts +21 -0
- package/dist/src/user/referral.js +41 -0
- package/dist/src/user/staking.d.ts +54 -0
- package/dist/src/user/staking.js +109 -0
- package/dist/src/user/trading.d.ts +119 -0
- package/dist/src/user/trading.js +262 -0
- package/dist/src/user/wlp.d.ts +58 -0
- package/dist/src/user/wlp.js +99 -0
- package/dist/src/utils/account-request.d.ts +9 -0
- package/dist/src/utils/account-request.js +17 -0
- package/dist/src/utils/config.d.ts +11 -0
- package/dist/src/utils/config.js +15 -0
- package/dist/src/utils/math.d.ts +201 -0
- package/dist/src/utils/math.js +343 -0
- package/dist/src/utils/pyth.d.ts +89 -0
- package/dist/src/utils/pyth.js +316 -0
- package/dist/src/utils/wormhole.d.ts +86 -0
- package/dist/src/utils/wormhole.js +154 -0
- package/package.json +66 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WaterX deployment config — fetched at client init from the canonical
|
|
3
|
+
* `waterx-config` repo (default: GitHub raw).
|
|
4
|
+
*
|
|
5
|
+
* The schema mirrors the canonical JSON layout one-to-one (each package
|
|
6
|
+
* groups its own object IDs + per-ticker maps). External chain infra
|
|
7
|
+
* (Pyth state, Wormhole state/core, Hermes & Wormholescan endpoints) is
|
|
8
|
+
* **not** in the JSON — it lives in `PYTH_DEFAULTS` / `WORMHOLE_DEFAULTS`
|
|
9
|
+
* below, keyed by network.
|
|
10
|
+
*/
|
|
11
|
+
import type { Network } from "./constants.ts";
|
|
12
|
+
export interface BasePackageEntry {
|
|
13
|
+
published_at: string;
|
|
14
|
+
original_id: string;
|
|
15
|
+
version: number;
|
|
16
|
+
upgrade_capability?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface PythRulePackage extends BasePackageEntry {
|
|
19
|
+
config: string;
|
|
20
|
+
feeds: Record<string, {
|
|
21
|
+
feed_id: string;
|
|
22
|
+
price_info_object: string;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
export interface PythSponsorRulePackage extends BasePackageEntry {
|
|
26
|
+
pyth_sponsor: string;
|
|
27
|
+
}
|
|
28
|
+
export interface WxaAccountPackage extends BasePackageEntry {
|
|
29
|
+
admin_cap: string;
|
|
30
|
+
account_registry: string;
|
|
31
|
+
}
|
|
32
|
+
export interface WaterxOraclePackage extends BasePackageEntry {
|
|
33
|
+
listing_cap: string;
|
|
34
|
+
oracle: string;
|
|
35
|
+
aggregators: Record<string, string>;
|
|
36
|
+
}
|
|
37
|
+
export interface WaterxPerpMarketEntry {
|
|
38
|
+
market: string;
|
|
39
|
+
config: string;
|
|
40
|
+
}
|
|
41
|
+
export interface WaterxPerpPackage extends BasePackageEntry {
|
|
42
|
+
admin_cap: string;
|
|
43
|
+
global_config: string;
|
|
44
|
+
market_registry_wlp: string;
|
|
45
|
+
markets: Record<string, WaterxPerpMarketEntry>;
|
|
46
|
+
}
|
|
47
|
+
export interface RewarderEntry {
|
|
48
|
+
/** `Rewarder<STAKE, R>` shared object ID. */
|
|
49
|
+
rewarder_id: string;
|
|
50
|
+
/** Fully-qualified reward coin Move type (e.g. `0x2::sui::SUI`). */
|
|
51
|
+
coin_type: string;
|
|
52
|
+
/** Reward coin display decimals. */
|
|
53
|
+
decimals: number;
|
|
54
|
+
}
|
|
55
|
+
export interface WaterxStakingPackage extends BasePackageEntry {
|
|
56
|
+
admin_cap?: string;
|
|
57
|
+
/** Map of stake-type alias (e.g. `"WLP"`) → `StakingPool<STAKE>` shared object ID. */
|
|
58
|
+
pools?: Record<string, string>;
|
|
59
|
+
/**
|
|
60
|
+
* Map of stake-type alias → reward-token alias → rewarder metadata.
|
|
61
|
+
* Reward-token alias is display-only (e.g. `"SUI"`, `"MOCK_SUI"`); the
|
|
62
|
+
* fully-qualified coin Move type lives on the {@link RewarderEntry}.
|
|
63
|
+
*/
|
|
64
|
+
rewarders?: Record<string, Record<string, RewarderEntry>>;
|
|
65
|
+
}
|
|
66
|
+
export interface WlpPackage extends BasePackageEntry {
|
|
67
|
+
metadata_cap?: string;
|
|
68
|
+
currency?: string;
|
|
69
|
+
wlp_pool: string;
|
|
70
|
+
/** Optional `WlpAum<LP>` shared object; required by `mint_wlp` / `settle_redeem`. */
|
|
71
|
+
wlp_aum?: string;
|
|
72
|
+
/** Map of oracle ticker → fully-qualified Move type registered via `lp_pool::add_token`. */
|
|
73
|
+
pool_tokens: Record<string, string>;
|
|
74
|
+
}
|
|
75
|
+
export interface WaterxReferralPackage extends BasePackageEntry {
|
|
76
|
+
/** Shared `ReferralTable`. */
|
|
77
|
+
referral_table: string;
|
|
78
|
+
}
|
|
79
|
+
export interface MockCoinPackage extends BasePackageEntry {
|
|
80
|
+
currency?: string;
|
|
81
|
+
treasury_cap?: string;
|
|
82
|
+
metadata_cap?: string;
|
|
83
|
+
}
|
|
84
|
+
export interface WaterxCreditPackage {
|
|
85
|
+
published_at: string;
|
|
86
|
+
/** Shared `CreditRegistry<CREDIT>` (phase-1 output). */
|
|
87
|
+
credit_registry?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Fully-qualified CREDIT coin Move type, e.g. `0x..::usd::USD`. Required
|
|
90
|
+
* for any credit/bridge flow — `client.creditType()` returns it as-is.
|
|
91
|
+
*/
|
|
92
|
+
credit_type?: string;
|
|
93
|
+
}
|
|
94
|
+
/** One backing-asset row on the native custody vault (PSM). */
|
|
95
|
+
export interface NativeCustodyAsset {
|
|
96
|
+
/** Fully-qualified backing asset Move type `T`. */
|
|
97
|
+
type: string;
|
|
98
|
+
decimal: number;
|
|
99
|
+
mint_fee_scaled: string;
|
|
100
|
+
burn_fee_scaled: string;
|
|
101
|
+
min_burn_amount: string;
|
|
102
|
+
}
|
|
103
|
+
export interface NativeCustodyPackage {
|
|
104
|
+
published_at: string;
|
|
105
|
+
/** Shared `CustodyVault<CREDIT>` (phase-4 output). */
|
|
106
|
+
vault?: string;
|
|
107
|
+
/** Backing assets registered via `add_asset` (array, identified by `type`). */
|
|
108
|
+
assets: NativeCustodyAsset[];
|
|
109
|
+
}
|
|
110
|
+
export interface TrustedEmitterRow {
|
|
111
|
+
/** Source EVM chain's Wormhole chain id (e.g. 10002 = Sepolia). */
|
|
112
|
+
chain_id: number;
|
|
113
|
+
/** 32-byte left-padded EVM bridge address (0x form). */
|
|
114
|
+
evm_bridge_address_32b: string;
|
|
115
|
+
/** Whitelisted 20-byte EVM token addresses (0x form). */
|
|
116
|
+
evm_tokens_20b: string[];
|
|
117
|
+
}
|
|
118
|
+
export interface WormholeBridgePackage {
|
|
119
|
+
published_at: string;
|
|
120
|
+
/** Shared Sui Wormhole `State` object id for this deployment. */
|
|
121
|
+
wormhole_state: string;
|
|
122
|
+
hourly_mint_limit?: string;
|
|
123
|
+
max_mint_per_tx?: string;
|
|
124
|
+
hourly_burn_limit?: string;
|
|
125
|
+
max_burn_per_tx?: string;
|
|
126
|
+
trusted_emitters: TrustedEmitterRow[];
|
|
127
|
+
/** Shared `Bridge` (phase-5 output). */
|
|
128
|
+
bridge?: string;
|
|
129
|
+
/**
|
|
130
|
+
* The bridge's `EmitterCap` object id (Sui-side Wormhole emitter address
|
|
131
|
+
* for burn-relay Wormholescan lookups). Not written by the deploy script
|
|
132
|
+
* — resolve from the on-chain `Bridge` object if absent.
|
|
133
|
+
*/
|
|
134
|
+
emitter_cap?: string;
|
|
135
|
+
}
|
|
136
|
+
export interface WithdrawalQueuePackage {
|
|
137
|
+
published_at: string;
|
|
138
|
+
/** Addresses on the queue executor allowlist (keepers). */
|
|
139
|
+
executors?: string[];
|
|
140
|
+
/** Shared `Queue<CREDIT>` (phase-6 output). */
|
|
141
|
+
queue?: string;
|
|
142
|
+
}
|
|
143
|
+
export interface TestnetFaucetPackage {
|
|
144
|
+
published_at: string;
|
|
145
|
+
whitelist?: string[];
|
|
146
|
+
faucet?: string;
|
|
147
|
+
}
|
|
148
|
+
export interface WaterXPackages {
|
|
149
|
+
bucket_framework: BasePackageEntry;
|
|
150
|
+
waterx_referral?: WaterxReferralPackage;
|
|
151
|
+
pyth_rule: PythRulePackage;
|
|
152
|
+
pyth_sponsor_rule?: PythSponsorRulePackage;
|
|
153
|
+
waterx_account: WxaAccountPackage;
|
|
154
|
+
waterx_oracle: WaterxOraclePackage;
|
|
155
|
+
waterx_perp: WaterxPerpPackage;
|
|
156
|
+
waterx_perp_view: BasePackageEntry;
|
|
157
|
+
waterx_staking?: WaterxStakingPackage;
|
|
158
|
+
wlp: WlpPackage;
|
|
159
|
+
waterx_credit?: WaterxCreditPackage;
|
|
160
|
+
wormhole_bridge?: WormholeBridgePackage;
|
|
161
|
+
withdrawal_queue?: WithdrawalQueuePackage;
|
|
162
|
+
native_custody?: NativeCustodyPackage;
|
|
163
|
+
testnet_faucet?: TestnetFaucetPackage;
|
|
164
|
+
mock_usdc?: MockCoinPackage;
|
|
165
|
+
mock_usdsui?: MockCoinPackage;
|
|
166
|
+
mock_sui?: MockCoinPackage;
|
|
167
|
+
waterx_rule?: BasePackageEntry;
|
|
168
|
+
waterx_rule_nautilus_enclave?: BasePackageEntry;
|
|
169
|
+
}
|
|
170
|
+
export interface PythInfraConfig {
|
|
171
|
+
state_id: string;
|
|
172
|
+
wormhole_state_id: string;
|
|
173
|
+
hermes_endpoint: string;
|
|
174
|
+
}
|
|
175
|
+
export declare const PYTH_DEFAULTS: Record<Network, PythInfraConfig>;
|
|
176
|
+
/**
|
|
177
|
+
* Wormhole infra for the cross-chain credit bridge. `state_id` is the same
|
|
178
|
+
* shared Sui Wormhole `State` object Pyth uses (kept in sync with
|
|
179
|
+
* `PYTH_DEFAULTS[*].wormhole_state_id`). Override per-deployment via
|
|
180
|
+
* `WaterXConfig.wormhole` if a deployment ever points elsewhere.
|
|
181
|
+
*/
|
|
182
|
+
export interface WormholeInfraConfig {
|
|
183
|
+
/** Shared Sui Wormhole `State` object. */
|
|
184
|
+
state_id: string;
|
|
185
|
+
/** Wormhole core package id on Sui. */
|
|
186
|
+
core_package: string;
|
|
187
|
+
/** Sui's Wormhole chain id (21 on both mainnet and testnet). */
|
|
188
|
+
sui_chain_id: number;
|
|
189
|
+
/** Wormholescan REST base for VAA lookups (no trailing slash). */
|
|
190
|
+
wormholescan_api: string;
|
|
191
|
+
}
|
|
192
|
+
export declare const WORMHOLE_DEFAULTS: Record<Network, WormholeInfraConfig>;
|
|
193
|
+
export interface WaterXConfig {
|
|
194
|
+
/** Absent on credit-only deployment files. */
|
|
195
|
+
network?: "mainnet" | "testnet";
|
|
196
|
+
chain_id?: string | number | null;
|
|
197
|
+
/** Sui gRPC base URL (default: public Mysten fullnode for the network). */
|
|
198
|
+
grpcUrl?: string;
|
|
199
|
+
packages: WaterXPackages;
|
|
200
|
+
/** Pyth infra override (defaults from `PYTH_DEFAULTS[network]`). */
|
|
201
|
+
pyth?: PythInfraConfig;
|
|
202
|
+
/** Wormhole infra override (defaults from `WORMHOLE_DEFAULTS[network]`). */
|
|
203
|
+
wormhole?: WormholeInfraConfig;
|
|
204
|
+
/** Sui `CoinRegistry` shared object (credit deployments). */
|
|
205
|
+
coin_registry?: string;
|
|
206
|
+
/** Per-module credit supply caps (credit deployments). */
|
|
207
|
+
credit_caps?: Record<string, string>;
|
|
208
|
+
/** Deploy-script phase completion flags (credit deployments). */
|
|
209
|
+
done?: Record<string, boolean>;
|
|
210
|
+
}
|
|
211
|
+
export interface LoadConfigOptions {
|
|
212
|
+
/**
|
|
213
|
+
* Override the default config URL. Use this to point at a staging branch
|
|
214
|
+
* (`?ref=staging`) or a local mirror during development.
|
|
215
|
+
*/
|
|
216
|
+
configUrl?: string;
|
|
217
|
+
/**
|
|
218
|
+
* Reuse a previously-fetched config from the in-memory cache (keyed by
|
|
219
|
+
* the effective URL). Default: false (always fetch fresh).
|
|
220
|
+
*/
|
|
221
|
+
cache?: boolean;
|
|
222
|
+
/** Optional fetch implementation (for tests or environments without global `fetch`). */
|
|
223
|
+
fetchImpl?: typeof fetch;
|
|
224
|
+
/** Optional request timeout in ms. Default 10_000. */
|
|
225
|
+
timeoutMs?: number;
|
|
226
|
+
}
|
|
227
|
+
export declare function defaultConfigUrl(network: Network): string;
|
|
228
|
+
export declare function clearConfigCache(): void;
|
|
229
|
+
export declare function loadConfig(network: Network, opts?: LoadConfigOptions): Promise<WaterXConfig>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WaterX deployment config — fetched at client init from the canonical
|
|
3
|
+
* `waterx-config` repo (default: GitHub raw).
|
|
4
|
+
*
|
|
5
|
+
* The schema mirrors the canonical JSON layout one-to-one (each package
|
|
6
|
+
* groups its own object IDs + per-ticker maps). External chain infra
|
|
7
|
+
* (Pyth state, Wormhole state/core, Hermes & Wormholescan endpoints) is
|
|
8
|
+
* **not** in the JSON — it lives in `PYTH_DEFAULTS` / `WORMHOLE_DEFAULTS`
|
|
9
|
+
* below, keyed by network.
|
|
10
|
+
*/
|
|
11
|
+
export const PYTH_DEFAULTS = {
|
|
12
|
+
MAINNET: {
|
|
13
|
+
state_id: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
|
|
14
|
+
wormhole_state_id: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c",
|
|
15
|
+
hermes_endpoint: "https://hermes.pyth.network",
|
|
16
|
+
},
|
|
17
|
+
TESTNET: {
|
|
18
|
+
state_id: "0x243759059f4c3111179da5878c12f68d612c21a8d54d85edc86164bb18be1c7c",
|
|
19
|
+
wormhole_state_id: "0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790",
|
|
20
|
+
hermes_endpoint: "https://hermes-beta.pyth.network",
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
export const WORMHOLE_DEFAULTS = {
|
|
24
|
+
MAINNET: {
|
|
25
|
+
state_id: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c",
|
|
26
|
+
core_package: "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a",
|
|
27
|
+
sui_chain_id: 21,
|
|
28
|
+
wormholescan_api: "https://api.wormholescan.io/api/v1",
|
|
29
|
+
},
|
|
30
|
+
TESTNET: {
|
|
31
|
+
state_id: "0x31358d198147da50db32eda2562951d53973a0c0ad5ed738e9b17d88b213d790",
|
|
32
|
+
core_package: "0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94",
|
|
33
|
+
sui_chain_id: 21,
|
|
34
|
+
wormholescan_api: "https://api.testnet.wormholescan.io/api/v1",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
const DEFAULT_CONFIG_URL_BASE = "https://raw.githubusercontent.com/WaterXProtocol/waterx-config/main";
|
|
38
|
+
export function defaultConfigUrl(network) {
|
|
39
|
+
return `${DEFAULT_CONFIG_URL_BASE}/${network.toLowerCase()}.json`;
|
|
40
|
+
}
|
|
41
|
+
const cache = new Map();
|
|
42
|
+
export function clearConfigCache() {
|
|
43
|
+
cache.clear();
|
|
44
|
+
}
|
|
45
|
+
export async function loadConfig(network, opts = {}) {
|
|
46
|
+
const url = opts.configUrl ?? defaultConfigUrl(network);
|
|
47
|
+
if (opts.cache && cache.has(url)) {
|
|
48
|
+
return cache.get(url);
|
|
49
|
+
}
|
|
50
|
+
const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
|
|
51
|
+
if (!fetchImpl) {
|
|
52
|
+
throw new Error("loadConfig: no global `fetch` available; pass opts.fetchImpl");
|
|
53
|
+
}
|
|
54
|
+
const controller = new AbortController();
|
|
55
|
+
const timer = setTimeout(() => controller.abort(), opts.timeoutMs ?? 10_000);
|
|
56
|
+
let response;
|
|
57
|
+
try {
|
|
58
|
+
response = await fetchImpl(url, { signal: controller.signal });
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
clearTimeout(timer);
|
|
62
|
+
}
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
throw new Error(`loadConfig: HTTP ${response.status} fetching ${url}`);
|
|
65
|
+
}
|
|
66
|
+
const raw = (await response.json());
|
|
67
|
+
validateConfig(raw, network, url);
|
|
68
|
+
if (opts.cache)
|
|
69
|
+
cache.set(url, raw);
|
|
70
|
+
return raw;
|
|
71
|
+
}
|
|
72
|
+
function validateConfig(cfg, expected, url) {
|
|
73
|
+
// `network` is only present on perp deployment files; credit-only files
|
|
74
|
+
// omit it. Enforce the guard only when the field is present.
|
|
75
|
+
if (cfg.network !== undefined && cfg.network !== expected.toLowerCase()) {
|
|
76
|
+
throw new Error(`loadConfig: config at ${url} declares network=${cfg.network} but caller asked for ${expected}`);
|
|
77
|
+
}
|
|
78
|
+
if (!cfg.packages || typeof cfg.packages !== "object") {
|
|
79
|
+
throw new Error(`loadConfig: config at ${url} has no packages object`);
|
|
80
|
+
}
|
|
81
|
+
const hasPublishedAt = (k) => {
|
|
82
|
+
const entry = cfg.packages[k];
|
|
83
|
+
return !!entry && typeof entry === "object" && !!entry.published_at;
|
|
84
|
+
};
|
|
85
|
+
// Validate by deployment kind. A perp config must carry the perp set; a
|
|
86
|
+
// credit config the credit set. `waterx_account` is common to both.
|
|
87
|
+
const isPerp = "waterx_perp" in cfg.packages;
|
|
88
|
+
const isCredit = "waterx_credit" in cfg.packages || "wormhole_bridge" in cfg.packages;
|
|
89
|
+
const required = isPerp
|
|
90
|
+
? [
|
|
91
|
+
"bucket_framework",
|
|
92
|
+
"pyth_rule",
|
|
93
|
+
"waterx_account",
|
|
94
|
+
"waterx_oracle",
|
|
95
|
+
"waterx_perp",
|
|
96
|
+
"waterx_perp_view",
|
|
97
|
+
"wlp",
|
|
98
|
+
]
|
|
99
|
+
: isCredit
|
|
100
|
+
? ["bucket_framework", "waterx_account", "waterx_credit"]
|
|
101
|
+
: ["bucket_framework", "waterx_account"];
|
|
102
|
+
for (const k of required) {
|
|
103
|
+
if (!hasPublishedAt(k)) {
|
|
104
|
+
throw new Error(`loadConfig: config at ${url} missing packages.${k}.published_at`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export type Network = "MAINNET" | "TESTNET";
|
|
2
|
+
/** Basis-point denominator (10_000). Matches BP_SCALE in the Move contracts. */
|
|
3
|
+
export declare const BPS_SCALE = 10000n;
|
|
4
|
+
/** Float scaling factor (1e9). All `Float` values from `bucket_v2_framework` are 1e9-scaled. */
|
|
5
|
+
export declare const FLOAT_SCALE = 1000000000n;
|
|
6
|
+
/** Double scaling factor (1e18). Used for high-precision intermediate values (e.g. u256 fields). */
|
|
7
|
+
export declare const DOUBLE_SCALE = 1000000000000000000n;
|
|
8
|
+
/** SUI coin decimals (gas + staking rewards). */
|
|
9
|
+
export declare const SUI_DECIMALS = 9;
|
|
10
|
+
/** WLP LP-token decimals. */
|
|
11
|
+
export declare const WLP_DECIMALS = 6;
|
|
12
|
+
/** Shared decimals for trading collateral / WLP backing assets (USDC, USDSUI). */
|
|
13
|
+
export declare const COLLATERAL_DECIMALS = 6;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Import the individual `SUI_DECIMALS` / `WLP_DECIMALS` /
|
|
16
|
+
* `COLLATERAL_DECIMALS` constants instead. Kept as a back-compat shim so
|
|
17
|
+
* downstream code that still does `import { TOKEN_DECIMALS }` keeps working;
|
|
18
|
+
* removed in a future major.
|
|
19
|
+
*/
|
|
20
|
+
export declare const TOKEN_DECIMALS: {
|
|
21
|
+
readonly SUI: 9;
|
|
22
|
+
readonly USDC: 6;
|
|
23
|
+
readonly USDSUI: 6;
|
|
24
|
+
readonly WLP: 6;
|
|
25
|
+
};
|
|
26
|
+
/** Default crypto market trading fee rate (3 bps). Per-market value lives in MarketConfig. */
|
|
27
|
+
export declare const CRYPTO_FEE_RATE = 0.0003;
|
|
28
|
+
/** Default stock / commodity market trading fee rate (5 bps). Per-market value lives in MarketConfig. */
|
|
29
|
+
export declare const STOCK_FEE_RATE = 0.0005;
|
|
30
|
+
/** Default maintenance margin rate (150 bps = 1.5%). Per-market value lives in MarketConfig. */
|
|
31
|
+
export declare const MAINTENANCE_MARGIN_RATE = 0.015;
|
|
32
|
+
export declare const PERM_OPEN_POSITION = 1;
|
|
33
|
+
export declare const PERM_CLOSE_POSITION = 2;
|
|
34
|
+
export declare const PERM_INCREASE_POSITION = 4;
|
|
35
|
+
export declare const PERM_DECREASE_POSITION = 8;
|
|
36
|
+
export declare const PERM_PLACE_ORDER = 16;
|
|
37
|
+
export declare const PERM_CANCEL_ORDER = 32;
|
|
38
|
+
export declare const PERM_DEPOSIT_COLLATERAL = 64;
|
|
39
|
+
export declare const PERM_WITHDRAW_COLLATERAL = 128;
|
|
40
|
+
export declare const PERM_MINT_WLP = 256;
|
|
41
|
+
export declare const PERM_REDEEM_WLP = 512;
|
|
42
|
+
export declare const PERM_ALL_TRADING = 255;
|
|
43
|
+
export declare const PERM_ALL = 65535;
|
|
44
|
+
export declare const ORDER_LIMIT_BUY = 0;
|
|
45
|
+
export declare const ORDER_LIMIT_SELL = 1;
|
|
46
|
+
export declare const ORDER_STOP_BUY = 2;
|
|
47
|
+
export declare const ORDER_STOP_SELL = 3;
|
|
48
|
+
/** Wildcard tag accepted by `cancel_order_request` — scans all 4 books. */
|
|
49
|
+
export declare const ORDER_TAG_WILDCARD = 255;
|
|
50
|
+
export declare const ACTION_OPEN_POSITION = 0;
|
|
51
|
+
export declare const ACTION_CLOSE_POSITION = 1;
|
|
52
|
+
export declare const ACTION_PLACE_ORDER = 2;
|
|
53
|
+
export declare const ACTION_CANCEL_ORDER = 3;
|
|
54
|
+
export declare const ACTION_DEPOSIT_COLLATERAL = 4;
|
|
55
|
+
export declare const ACTION_WITHDRAW_COLLATERAL = 5;
|
|
56
|
+
export declare const ACTION_LIQUIDATE = 6;
|
|
57
|
+
export declare const ACTION_INCREASE_POSITION = 7;
|
|
58
|
+
export declare const ACTION_DECREASE_POSITION = 8;
|
|
59
|
+
export declare const ACTION_UPDATE_ORDER = 9;
|
|
60
|
+
export declare const ACTION_CANCEL_PRE_ORDER = 10;
|
|
61
|
+
export declare const ACTION_ADD_PRE_ORDER = 11;
|
|
62
|
+
export declare const MS_PER_YEAR: number;
|
|
63
|
+
/** Zero-address placeholder used as the sender in dry-run / simulate calls. */
|
|
64
|
+
export declare const DRY_RUN_SENDER = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// ======== Scaling ========
|
|
2
|
+
/** Basis-point denominator (10_000). Matches BP_SCALE in the Move contracts. */
|
|
3
|
+
export const BPS_SCALE = 10000n;
|
|
4
|
+
/** Float scaling factor (1e9). All `Float` values from `bucket_v2_framework` are 1e9-scaled. */
|
|
5
|
+
export const FLOAT_SCALE = 1000000000n;
|
|
6
|
+
/** Double scaling factor (1e18). Used for high-precision intermediate values (e.g. u256 fields). */
|
|
7
|
+
export const DOUBLE_SCALE = 1000000000000000000n;
|
|
8
|
+
// ======== Token decimals ========
|
|
9
|
+
/** SUI coin decimals (gas + staking rewards). */
|
|
10
|
+
export const SUI_DECIMALS = 9;
|
|
11
|
+
/** WLP LP-token decimals. */
|
|
12
|
+
export const WLP_DECIMALS = 6;
|
|
13
|
+
/** Shared decimals for trading collateral / WLP backing assets (USDC, USDSUI). */
|
|
14
|
+
export const COLLATERAL_DECIMALS = 6;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Import the individual `SUI_DECIMALS` / `WLP_DECIMALS` /
|
|
17
|
+
* `COLLATERAL_DECIMALS` constants instead. Kept as a back-compat shim so
|
|
18
|
+
* downstream code that still does `import { TOKEN_DECIMALS }` keeps working;
|
|
19
|
+
* removed in a future major.
|
|
20
|
+
*/
|
|
21
|
+
export const TOKEN_DECIMALS = {
|
|
22
|
+
SUI: SUI_DECIMALS,
|
|
23
|
+
USDC: COLLATERAL_DECIMALS,
|
|
24
|
+
USDSUI: COLLATERAL_DECIMALS,
|
|
25
|
+
WLP: WLP_DECIMALS,
|
|
26
|
+
};
|
|
27
|
+
// ======== Fee rates & risk parameters ========
|
|
28
|
+
/** Default crypto market trading fee rate (3 bps). Per-market value lives in MarketConfig. */
|
|
29
|
+
export const CRYPTO_FEE_RATE = 0.0003;
|
|
30
|
+
/** Default stock / commodity market trading fee rate (5 bps). Per-market value lives in MarketConfig. */
|
|
31
|
+
export const STOCK_FEE_RATE = 0.0005;
|
|
32
|
+
/** Default maintenance margin rate (150 bps = 1.5%). Per-market value lives in MarketConfig. */
|
|
33
|
+
export const MAINTENANCE_MARGIN_RATE = 0.015;
|
|
34
|
+
// ======== Permission Bitmasks (matches account_data.move) ========
|
|
35
|
+
export const PERM_OPEN_POSITION = 1;
|
|
36
|
+
export const PERM_CLOSE_POSITION = 2;
|
|
37
|
+
export const PERM_INCREASE_POSITION = 4;
|
|
38
|
+
export const PERM_DECREASE_POSITION = 8;
|
|
39
|
+
export const PERM_PLACE_ORDER = 16;
|
|
40
|
+
export const PERM_CANCEL_ORDER = 32;
|
|
41
|
+
export const PERM_DEPOSIT_COLLATERAL = 64;
|
|
42
|
+
export const PERM_WITHDRAW_COLLATERAL = 128;
|
|
43
|
+
export const PERM_MINT_WLP = 256;
|
|
44
|
+
export const PERM_REDEEM_WLP = 512;
|
|
45
|
+
export const PERM_ALL_TRADING = 0xff;
|
|
46
|
+
export const PERM_ALL = 0xffff;
|
|
47
|
+
// ======== Order Type Tags ========
|
|
48
|
+
export const ORDER_LIMIT_BUY = 0;
|
|
49
|
+
export const ORDER_LIMIT_SELL = 1;
|
|
50
|
+
export const ORDER_STOP_BUY = 2;
|
|
51
|
+
export const ORDER_STOP_SELL = 3;
|
|
52
|
+
/** Wildcard tag accepted by `cancel_order_request` — scans all 4 books. */
|
|
53
|
+
export const ORDER_TAG_WILDCARD = 255;
|
|
54
|
+
// ======== Action Type Constants (request.move) ========
|
|
55
|
+
export const ACTION_OPEN_POSITION = 0;
|
|
56
|
+
export const ACTION_CLOSE_POSITION = 1;
|
|
57
|
+
export const ACTION_PLACE_ORDER = 2;
|
|
58
|
+
export const ACTION_CANCEL_ORDER = 3;
|
|
59
|
+
export const ACTION_DEPOSIT_COLLATERAL = 4;
|
|
60
|
+
export const ACTION_WITHDRAW_COLLATERAL = 5;
|
|
61
|
+
export const ACTION_LIQUIDATE = 6;
|
|
62
|
+
export const ACTION_INCREASE_POSITION = 7;
|
|
63
|
+
export const ACTION_DECREASE_POSITION = 8;
|
|
64
|
+
export const ACTION_UPDATE_ORDER = 9;
|
|
65
|
+
export const ACTION_CANCEL_PRE_ORDER = 10;
|
|
66
|
+
export const ACTION_ADD_PRE_ORDER = 11;
|
|
67
|
+
// ======== Time ========
|
|
68
|
+
export const MS_PER_YEAR = 365 * 24 * 60 * 60 * 1000;
|
|
69
|
+
// ======== Misc ========
|
|
70
|
+
/** Zero-address placeholder used as the sender in dry-run / simulate calls. */
|
|
71
|
+
export const DRY_RUN_SENDER = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
@@ -0,0 +1,144 @@
|
|
|
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
|
+
export type AccountDataView = ReturnType<typeof AccountData.parse>;
|
|
11
|
+
/**
|
|
12
|
+
* Look up the registered AccountData for a given wxa account ID.
|
|
13
|
+
* Returns `undefined` if the account has no perp data slot installed yet
|
|
14
|
+
* (the slot auto-installs on the first `add_position` / `add_order`).
|
|
15
|
+
* The underlying view fn returns `Option<AccountData>`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getAccountData(client: WaterXClient, accountId: string): Promise<AccountDataView | undefined>;
|
|
18
|
+
export type MarketDataView = ReturnType<typeof MarketData.parse>;
|
|
19
|
+
export type PoolDataView = ReturnType<typeof PoolData.parse>;
|
|
20
|
+
export type TokenPoolDataView = ReturnType<typeof TokenPoolData.parse>;
|
|
21
|
+
export type GlobalConfigDataView = ReturnType<typeof GlobalConfigData.parse>;
|
|
22
|
+
export declare function getMarketData(client: WaterXClient, args: {
|
|
23
|
+
ticker: string;
|
|
24
|
+
lpType?: string;
|
|
25
|
+
}): Promise<MarketDataView>;
|
|
26
|
+
export declare function getPoolData(client: WaterXClient, args?: {
|
|
27
|
+
lpType?: string;
|
|
28
|
+
}): Promise<PoolDataView>;
|
|
29
|
+
export declare function getTokenPoolData(client: WaterXClient, args: {
|
|
30
|
+
tokenIndex: bigint | number;
|
|
31
|
+
lpType?: string;
|
|
32
|
+
}): Promise<TokenPoolDataView>;
|
|
33
|
+
export declare function getGlobalConfigData(client: WaterXClient): Promise<GlobalConfigDataView>;
|
|
34
|
+
export type PositionDataView = ReturnType<typeof PositionData.parse>;
|
|
35
|
+
export declare function positionExists(client: WaterXClient, args: {
|
|
36
|
+
ticker: string;
|
|
37
|
+
positionId: bigint | number;
|
|
38
|
+
lpType?: string;
|
|
39
|
+
}): Promise<boolean>;
|
|
40
|
+
export declare function getPosition(client: WaterXClient, args: {
|
|
41
|
+
ticker: string;
|
|
42
|
+
positionId: bigint | number;
|
|
43
|
+
/** Human-readable USD prices for Pnl / liq price calc; pass 0n if unsure. */
|
|
44
|
+
basePriceUsd: bigint | number;
|
|
45
|
+
collateralPriceUsd: bigint | number;
|
|
46
|
+
lpType?: string;
|
|
47
|
+
}): Promise<PositionDataView>;
|
|
48
|
+
export type OrderDataView = ReturnType<typeof OrderData.parse>;
|
|
49
|
+
export declare function getOrder(client: WaterXClient, args: {
|
|
50
|
+
ticker: string;
|
|
51
|
+
orderId: bigint | number;
|
|
52
|
+
orderTypeTag: number;
|
|
53
|
+
triggerPrice: bigint | number;
|
|
54
|
+
basePriceUsd: bigint | number;
|
|
55
|
+
lpType?: string;
|
|
56
|
+
}): Promise<OrderDataView>;
|
|
57
|
+
export interface PageOpts {
|
|
58
|
+
cursor?: bigint | number;
|
|
59
|
+
pageSize?: bigint | number;
|
|
60
|
+
}
|
|
61
|
+
export declare function getMarketOrders(client: WaterXClient, args: {
|
|
62
|
+
ticker: string;
|
|
63
|
+
basePriceUsd?: bigint | number;
|
|
64
|
+
lpType?: string;
|
|
65
|
+
} & PageOpts): Promise<{
|
|
66
|
+
orders: OrderDataView[];
|
|
67
|
+
nextCursor?: bigint;
|
|
68
|
+
}>;
|
|
69
|
+
export declare function getMarketPositions(client: WaterXClient, args: {
|
|
70
|
+
ticker: string;
|
|
71
|
+
basePriceUsd: bigint | number;
|
|
72
|
+
collateralPriceUsd?: bigint | number;
|
|
73
|
+
lpType?: string;
|
|
74
|
+
} & PageOpts): Promise<{
|
|
75
|
+
positions: PositionDataView[];
|
|
76
|
+
nextCursor?: bigint;
|
|
77
|
+
}>;
|
|
78
|
+
export declare function getAccountPositions(client: WaterXClient, args: {
|
|
79
|
+
ticker: string;
|
|
80
|
+
accountObjectAddress: string;
|
|
81
|
+
basePriceUsd: bigint | number;
|
|
82
|
+
collateralPriceUsd?: bigint | number;
|
|
83
|
+
lpType?: string;
|
|
84
|
+
}): Promise<PositionDataView[]>;
|
|
85
|
+
export declare function getAccountOrders(client: WaterXClient, args: {
|
|
86
|
+
ticker: string;
|
|
87
|
+
accountObjectAddress: string;
|
|
88
|
+
basePriceUsd?: bigint | number;
|
|
89
|
+
lpType?: string;
|
|
90
|
+
}): Promise<OrderDataView[]>;
|
|
91
|
+
export type RedeemRequestDataView = ReturnType<typeof RedeemRequestData.parse>;
|
|
92
|
+
export declare function getRedeemRequests(client: WaterXClient, args?: {
|
|
93
|
+
lpType?: string;
|
|
94
|
+
} & PageOpts): Promise<{
|
|
95
|
+
requests: RedeemRequestDataView[];
|
|
96
|
+
nextCursor?: bigint;
|
|
97
|
+
}>;
|
|
98
|
+
/** Returns the referrer address bound to `referee`, or `undefined` if none. */
|
|
99
|
+
export declare function getRefererFor(client: WaterXClient, referee: string): Promise<string | undefined>;
|
|
100
|
+
/** True if `code` is a syntactically valid referral code (matches the contract's char rules). */
|
|
101
|
+
export declare function isValidReferralCode(client: WaterXClient, code: string): Promise<boolean>;
|
|
102
|
+
/** True if `code` is already claimed in the on-chain ReferralTable. */
|
|
103
|
+
export declare function referralCodeExists(client: WaterXClient, code: string): Promise<boolean>;
|
|
104
|
+
/**
|
|
105
|
+
* List the wxa account IDs owned by `owner` (`account::account_ids`).
|
|
106
|
+
* Returns `[]` when the owner has never created an account. Use this to
|
|
107
|
+
* resolve the `account_id` a cross-chain deposit must target before
|
|
108
|
+
* filling the EVM `suiRecipient` field.
|
|
109
|
+
*/
|
|
110
|
+
export declare function getAccountsByOwner(client: WaterXClient, owner: string): Promise<string[]>;
|
|
111
|
+
/**
|
|
112
|
+
* A wxa account's stored `Balance<T>` (`account::account_balance<T>`).
|
|
113
|
+
* `coinType` defaults to the deployment's CREDIT type — i.e. the bridged
|
|
114
|
+
* balance available to withdraw. Returns `0n` for an unknown coin type.
|
|
115
|
+
*/
|
|
116
|
+
export declare function getAccountBalance(client: WaterXClient, accountId: string, coinType?: string): Promise<bigint>;
|
|
117
|
+
/** Vault-wide native-custody state. */
|
|
118
|
+
export interface CustodyVaultData {
|
|
119
|
+
/** Total CREDIT minted by the custody vault (`credit_supply`). */
|
|
120
|
+
creditSupply: bigint;
|
|
121
|
+
}
|
|
122
|
+
/** Reads vault-wide native-custody state via `custody_vault::credit_supply`. */
|
|
123
|
+
export declare function getCustodyVaultData(client: WaterXClient): Promise<CustodyVaultData>;
|
|
124
|
+
/** Per-asset native-custody state for one backing asset. */
|
|
125
|
+
export interface CustodyAssetData {
|
|
126
|
+
/** Whether the asset is registered as a `SingleVault` on the custody vault. */
|
|
127
|
+
registered: boolean;
|
|
128
|
+
/** 1e9-scaled default mint fee rate (`0n` when the asset is not registered). */
|
|
129
|
+
mintFeeRate: bigint;
|
|
130
|
+
/** 1e9-scaled default burn fee rate (`0n` when the asset is not registered). */
|
|
131
|
+
burnFeeRate: bigint;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Reads per-asset native-custody state for backing asset `assetType`.
|
|
135
|
+
*
|
|
136
|
+
* Fee rates are the vault's default config — queried with the zero address as
|
|
137
|
+
* caller, so no partner discount is applied — as 1e9-scaled `Float` values.
|
|
138
|
+
* When the asset is not registered, returns `registered: false` with `0n` rates.
|
|
139
|
+
*
|
|
140
|
+
* Note: the `SingleVault` balance / decimal / backing / min-burn / deprecated
|
|
141
|
+
* fields are not exposed here — the contract's getters for those return a
|
|
142
|
+
* `&SingleVault<T>` reference, which a PTB simulate cannot read.
|
|
143
|
+
*/
|
|
144
|
+
export declare function getCustodyAssetData(client: WaterXClient, assetType: string): Promise<CustodyAssetData>;
|