@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.
- package/README.md +25 -21
- package/dist/src/{utils → account}/account-request.d.ts +2 -2
- package/dist/src/{user → account}/account.d.ts +23 -21
- package/dist/src/{user → account}/account.js +5 -5
- package/dist/src/account/client.d.ts +42 -0
- package/dist/src/account/client.js +17 -0
- package/dist/src/account/config.d.ts +151 -0
- package/dist/src/account/config.js +8 -0
- package/dist/src/account/constants.d.ts +5 -0
- package/dist/src/account/constants.js +5 -0
- package/dist/src/account/fetch/referral.d.ts +15 -0
- package/dist/src/account/fetch/referral.js +51 -0
- package/dist/src/account/fetch/simulate.d.ts +34 -0
- package/dist/src/account/fetch/simulate.js +43 -0
- package/dist/src/{utils/consolidate-balance.d.ts → account/funding/balance.d.ts} +3 -8
- package/dist/src/{utils/consolidate-balance.js → account/funding/balance.js} +6 -1
- package/dist/src/account/funding/consolidate.d.ts +46 -0
- package/dist/src/account/funding/consolidate.js +137 -0
- package/dist/src/{user → account/funding}/credit.d.ts +10 -10
- package/dist/src/{user → account/funding}/credit.js +6 -6
- package/dist/src/{user → account/funding}/custody.d.ts +4 -4
- package/dist/src/{user → account/funding}/custody.js +2 -2
- package/dist/src/{utils → account/funding}/wormhole.d.ts +4 -4
- package/dist/src/{utils → account/funding}/wormhole.js +1 -1
- package/dist/src/account/index.d.ts +29 -0
- package/dist/src/account/index.js +29 -0
- package/dist/src/{user → account}/referral.d.ts +3 -3
- package/dist/src/{user → account}/referral.js +1 -1
- package/dist/src/base-client.d.ts +74 -0
- package/dist/src/base-client.js +97 -0
- package/dist/src/constants.d.ts +4 -42
- package/dist/src/constants.js +8 -47
- package/dist/src/generated/bucket_v2_framework/liability.d.ts +0 -26
- package/dist/src/generated/bucket_v2_framework/liability.js +0 -28
- package/dist/src/generated/waterx_account/account.d.ts +50 -15
- package/dist/src/generated/waterx_account/account.js +51 -15
- package/dist/src/generated/waterx_oracle/oracle.d.ts +7 -1
- package/dist/src/generated/waterx_oracle/oracle.js +7 -2
- package/dist/src/{prediction/generated → generated}/waterx_prediction/account_data.d.ts +19 -2
- package/dist/src/{prediction/generated → generated}/waterx_prediction/admin.d.ts +3 -1
- package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/sui/balance.d.ts +3 -1
- package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/deps/sui/table.d.ts +6 -1
- package/dist/src/generated/waterx_prediction/events.d.ts +288 -0
- package/dist/src/{prediction/generated → generated}/waterx_prediction/events.js +39 -0
- package/dist/src/{prediction/generated → generated}/waterx_prediction/global_config.d.ts +6 -1
- package/dist/src/{prediction/generated → generated}/waterx_prediction/order.d.ts +34 -1
- package/dist/src/{prediction/generated → generated}/waterx_prediction/position.d.ts +16 -1
- package/dist/src/{prediction/generated → generated}/waterx_prediction/view.d.ts +69 -4
- package/dist/src/{prediction/generated → generated}/waterx_prediction/waterx_prediction.d.ts +162 -2
- package/dist/src/{prediction/generated → generated}/waterx_prediction/waterx_prediction.js +99 -0
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +102 -0
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +99 -0
- package/dist/src/generated/waterx_supra_rule/supra_rule.d.ts +5 -5
- package/dist/src/generated/waterx_supra_rule/supra_rule.js +1 -2
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.d.ts +23 -23
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.js +3 -6
- package/dist/src/oracle/aggregate.d.ts +74 -0
- package/dist/src/oracle/aggregate.js +112 -0
- package/dist/src/oracle/config.d.ts +99 -0
- package/dist/src/oracle/config.js +23 -0
- package/dist/src/oracle/host.d.ts +32 -0
- package/dist/src/oracle/host.js +10 -0
- package/dist/src/oracle/index.d.ts +16 -0
- package/dist/src/oracle/index.js +18 -0
- package/dist/src/oracle/pyth.d.ts +52 -0
- package/dist/src/oracle/pyth.js +220 -0
- package/dist/src/oracle/rules/constant-rule.d.ts +9 -0
- package/dist/src/oracle/rules/constant-rule.js +14 -0
- package/dist/src/oracle/rules/pyth-rule.d.ts +11 -0
- package/dist/src/oracle/rules/pyth-rule.js +20 -0
- package/dist/src/oracle/rules/sponsor.d.ts +28 -0
- package/dist/src/oracle/rules/sponsor.js +48 -0
- package/dist/src/oracle/rules/supra-rule.d.ts +11 -0
- package/dist/src/oracle/rules/supra-rule.js +22 -0
- package/dist/src/perp/client.d.ts +78 -0
- package/dist/src/perp/client.js +108 -0
- package/dist/src/{client.d.ts → perp/config-view.d.ts} +15 -60
- package/dist/src/{client.js → perp/config-view.js} +23 -95
- package/dist/src/perp/config.d.ts +126 -0
- package/dist/src/{config.js → perp/config.js} +11 -12
- package/dist/src/perp/constants.d.ts +49 -0
- package/dist/src/perp/constants.js +61 -0
- package/dist/src/perp/fetch/account.d.ts +43 -0
- package/dist/src/perp/fetch/account.js +64 -0
- package/dist/src/perp/fetch/bridge.d.ts +90 -0
- package/dist/src/perp/fetch/bridge.js +127 -0
- package/dist/src/perp/fetch/custody.d.ts +32 -0
- package/dist/src/perp/fetch/custody.js +62 -0
- package/dist/src/perp/fetch/market.d.ts +30 -0
- package/dist/src/perp/fetch/market.js +68 -0
- package/dist/src/perp/fetch/positions.d.ts +70 -0
- package/dist/src/perp/fetch/positions.js +185 -0
- package/dist/src/perp/fetch/simulate.d.ts +12 -0
- package/dist/src/perp/fetch/simulate.js +13 -0
- package/dist/src/perp/fetch.d.ts +23 -0
- package/dist/src/perp/fetch.js +23 -0
- package/dist/src/{index.d.ts → perp/index.d.ts} +22 -22
- package/dist/src/{index.js → perp/index.js} +22 -22
- package/dist/src/perp/tx-builders/common.d.ts +83 -0
- package/dist/src/perp/tx-builders/common.js +70 -0
- package/dist/src/perp/tx-builders/credit.d.ts +65 -0
- package/dist/src/perp/tx-builders/credit.js +62 -0
- package/dist/src/perp/tx-builders/rewards.d.ts +30 -0
- package/dist/src/perp/tx-builders/rewards.js +34 -0
- package/dist/src/perp/tx-builders/trading.d.ts +51 -0
- package/dist/src/perp/tx-builders/trading.js +59 -0
- package/dist/src/perp/tx-builders/wlp.d.ts +90 -0
- package/dist/src/perp/tx-builders/wlp.js +120 -0
- package/dist/src/perp/tx-builders.d.ts +23 -0
- package/dist/src/perp/tx-builders.js +23 -0
- package/dist/src/perp/user/index.d.ts +8 -0
- package/dist/src/perp/user/index.js +8 -0
- package/dist/src/{user → perp/user}/order.d.ts +7 -7
- package/dist/src/{user → perp/user}/order.js +3 -3
- package/dist/src/{user → perp/user}/staking.d.ts +4 -4
- package/dist/src/{user → perp/user}/staking.js +2 -2
- package/dist/src/{user → perp/user}/trading.d.ts +13 -13
- package/dist/src/{user → perp/user}/trading.js +2 -2
- package/dist/src/{user → perp/user}/wlp.d.ts +7 -7
- package/dist/src/{user → perp/user}/wlp.js +3 -3
- package/dist/src/prediction/account.js +40 -76
- package/dist/src/prediction/client.d.ts +8 -38
- package/dist/src/prediction/client.js +11 -67
- package/dist/src/prediction/config.d.ts +16 -2
- package/dist/src/prediction/config.js +10 -4
- package/dist/src/prediction/index.d.ts +11 -11
- package/dist/src/prediction/index.js +10 -10
- package/dist/src/prediction/prediction.d.ts +45 -0
- package/dist/src/prediction/prediction.js +71 -0
- package/dist/src/prediction/tx-builders.d.ts +4 -4
- package/dist/src/prediction/tx-builders.js +2 -2
- package/dist/src/prediction/user/index.d.ts +2 -2
- package/dist/src/prediction/user/index.js +1 -1
- package/dist/src/prediction/user/position.d.ts +2 -2
- package/dist/src/prediction/user/position.js +1 -1
- package/dist/src/prediction/utils/bcs.d.ts +5 -0
- package/dist/src/prediction/utils/bcs.js +5 -0
- package/dist/src/prediction/utils/index.d.ts +7 -0
- package/dist/src/prediction/utils/index.js +7 -0
- package/dist/src/sdk.d.ts +10 -6
- package/dist/src/sdk.js +9 -5
- package/dist/src/unified-client.d.ts +140 -145
- package/dist/src/unified-client.js +98 -40
- package/dist/src/utils/config.d.ts +1 -1
- package/package.json +22 -5
- package/dist/src/config.d.ts +0 -292
- package/dist/src/fetch.d.ts +0 -254
- package/dist/src/fetch.js +0 -564
- package/dist/src/prediction/generated/bucket_v2_framework/account.d.ts +0 -100
- package/dist/src/prediction/generated/bucket_v2_framework/account.js +0 -129
- package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.d.ts +0 -6
- package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.js +0 -19
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.d.ts +0 -10
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.d.ts +0 -36
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.js +0 -27
- package/dist/src/prediction/generated/bucket_v2_framework/double.d.ts +0 -382
- package/dist/src/prediction/generated/bucket_v2_framework/double.js +0 -466
- package/dist/src/prediction/generated/bucket_v2_framework/float.d.ts +0 -362
- package/dist/src/prediction/generated/bucket_v2_framework/float.js +0 -440
- package/dist/src/prediction/generated/bucket_v2_framework/liability.d.ts +0 -193
- package/dist/src/prediction/generated/bucket_v2_framework/liability.js +0 -205
- package/dist/src/prediction/generated/bucket_v2_framework/linked_table.d.ts +0 -384
- package/dist/src/prediction/generated/bucket_v2_framework/linked_table.js +0 -382
- package/dist/src/prediction/generated/bucket_v2_framework/sheet.d.ts +0 -344
- package/dist/src/prediction/generated/bucket_v2_framework/sheet.js +0 -338
- package/dist/src/prediction/generated/utils/index.d.ts +0 -30
- package/dist/src/prediction/generated/utils/index.js +0 -160
- package/dist/src/prediction/generated/waterx_account/account.d.ts +0 -1589
- package/dist/src/prediction/generated/waterx_account/account.js +0 -1758
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.d.ts +0 -7
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.js +0 -13
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.d.ts +0 -7
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.js +0 -16
- package/dist/src/prediction/generated/waterx_account/deps/std/type_name.d.ts +0 -6
- package/dist/src/prediction/generated/waterx_account/deps/std/type_name.js +0 -19
- package/dist/src/prediction/generated/waterx_account/deps/sui/balance.d.ts +0 -10
- package/dist/src/prediction/generated/waterx_account/deps/sui/balance.js +0 -14
- package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.d.ts +0 -12
- package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.js +0 -19
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.d.ts +0 -36
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.js +0 -27
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.d.ts +0 -16
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.js +0 -19
- package/dist/src/prediction/generated/waterx_account/direct_rule.d.ts +0 -75
- package/dist/src/prediction/generated/waterx_account/direct_rule.js +0 -78
- package/dist/src/prediction/generated/waterx_account/events.d.ts +0 -33
- package/dist/src/prediction/generated/waterx_account/events.js +0 -137
- package/dist/src/prediction/generated/waterx_account/version.js +0 -8
- package/dist/src/prediction/generated/waterx_prediction/bet_sharing.d.ts +0 -60
- package/dist/src/prediction/generated/waterx_prediction/bet_sharing.js +0 -83
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.js +0 -14
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.d.ts +0 -24
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.js +0 -31
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.d.ts +0 -16
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.js +0 -19
- package/dist/src/prediction/generated/waterx_prediction/events.d.ts +0 -22
- package/dist/src/prediction/generated/waterx_prediction/version.d.ts +0 -10
- package/dist/src/tx-builders.d.ts +0 -296
- package/dist/src/tx-builders.js +0 -461
- package/dist/src/user/index.d.ts +0 -8
- package/dist/src/user/index.js +0 -8
- package/dist/src/utils/pyth.d.ts +0 -124
- package/dist/src/utils/pyth.js +0 -392
- /package/dist/src/{utils → account}/account-request.js +0 -0
- /package/dist/src/{core → account}/waterx-account.d.ts +0 -0
- /package/dist/src/{core → account}/waterx-account.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/account_data.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/admin.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/bucket_v2_framework/linked_table.d.ts +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/deps/bucket_v2_framework/linked_table.js +0 -0
- /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/balance.js +0 -0
- /package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/deps/sui/table.js +0 -0
- /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/vec_set.d.ts +0 -0
- /package/dist/src/{prediction/generated/bucket_v2_framework → generated/waterx_prediction}/deps/sui/vec_set.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/global_config.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/order.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/outcome.d.ts +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/outcome.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/position.js +0 -0
- /package/dist/src/{prediction/generated/waterx_account → generated/waterx_prediction}/version.d.ts +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/version.js +0 -0
- /package/dist/src/{prediction/generated → generated}/waterx_prediction/view.js +0 -0
package/dist/src/fetch.d.ts
DELETED
|
@@ -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>;
|