@waterx/sdk 2.1.0 → 2.3.1-dev.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 +75 -169
- package/dist/src/client.d.ts +52 -2
- package/dist/src/client.js +76 -6
- package/dist/src/config.d.ts +57 -3
- package/dist/src/config.js +10 -4
- package/dist/src/constants.d.ts +6 -0
- package/dist/src/constants.js +6 -0
- package/dist/src/core/waterx-account.d.ts +31 -0
- package/dist/src/core/waterx-account.js +26 -0
- package/dist/src/fetch.d.ts +110 -0
- package/dist/src/fetch.js +149 -4
- package/dist/src/generated/bucket_v2_framework/account.d.ts +5 -5
- package/dist/src/generated/bucket_v2_framework/double.d.ts +77 -77
- package/dist/src/generated/bucket_v2_framework/float.d.ts +73 -73
- package/dist/src/generated/bucket_v2_framework/liability.d.ts +33 -33
- package/dist/src/generated/bucket_v2_framework/linked_table.d.ts +5 -5
- package/dist/src/generated/bucket_v2_framework/linked_table.js +2 -2
- package/dist/src/generated/bucket_v2_framework/sheet.d.ts +57 -57
- package/dist/src/generated/bucket_v2_framework/sheet.js +5 -11
- package/dist/src/generated/native_custody/custody_vault.d.ts +46 -32
- package/dist/src/generated/native_custody/custody_vault.js +19 -10
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/sheet.js +1 -3
- package/dist/src/generated/native_custody/events.js +1 -2
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +7 -7
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +1 -2
- package/dist/src/generated/utils/index.d.ts +7 -7
- package/dist/src/generated/utils/index.js +9 -6
- package/dist/src/generated/waterx_account/account.d.ts +124 -71
- package/dist/src/generated/waterx_account/account.js +64 -29
- package/dist/src/generated/waterx_account/deps/bucket_v2_framework/sheet.js +1 -3
- package/dist/src/generated/waterx_account/direct_rule.d.ts +5 -5
- package/dist/src/generated/waterx_account/events.d.ts +10 -0
- package/dist/src/generated/waterx_account/events.js +31 -50
- package/dist/src/generated/waterx_constant_rule/constant_rule.d.ts +68 -0
- package/dist/src/generated/waterx_constant_rule/constant_rule.js +59 -0
- package/dist/src/generated/waterx_constant_rule/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/src/generated/waterx_constant_rule/deps/bucket_v2_framework/float.js +10 -0
- package/dist/src/generated/waterx_constant_rule/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_constant_rule/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_credit/credit_registry.d.ts +9 -9
- package/dist/src/generated/waterx_credit/credit_registry.js +1 -2
- package/dist/src/generated/waterx_credit/limited_supply.d.ts +17 -17
- package/dist/src/generated/waterx_oracle/aggregator.js +1 -2
- package/dist/src/generated/waterx_oracle/collector.d.ts +17 -17
- package/dist/src/generated/waterx_oracle/collector.js +1 -1
- package/dist/src/generated/waterx_oracle/oracle.d.ts +5 -5
- package/dist/src/generated/waterx_perp/account_data.d.ts +5 -5
- package/dist/src/generated/waterx_perp/account_data.js +1 -2
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/sheet.js +1 -3
- package/dist/src/generated/waterx_perp/events.d.ts +181 -181
- package/dist/src/generated/waterx_perp/events.js +87 -173
- package/dist/src/generated/waterx_perp/global_config.d.ts +3 -3
- package/dist/src/generated/waterx_perp/global_config.js +6 -12
- package/dist/src/generated/waterx_perp/keyed_big_vector.d.ts +9 -9
- package/dist/src/generated/waterx_perp/keyed_big_vector.js +1 -2
- package/dist/src/generated/waterx_perp/lp_pool.d.ts +115 -115
- package/dist/src/generated/waterx_perp/lp_pool.js +11 -22
- package/dist/src/generated/waterx_perp/market_config.d.ts +61 -43
- package/dist/src/generated/waterx_perp/market_config.js +29 -22
- package/dist/src/generated/waterx_perp/math.d.ts +7 -7
- package/dist/src/generated/waterx_perp/order_book.d.ts +47 -47
- package/dist/src/generated/waterx_perp/position.d.ts +99 -99
- package/dist/src/generated/waterx_perp/position.js +6 -12
- package/dist/src/generated/waterx_perp/request.d.ts +67 -67
- package/dist/src/generated/waterx_perp/request.js +2 -3
- package/dist/src/generated/waterx_perp/response.d.ts +35 -35
- package/dist/src/generated/waterx_perp/response.js +1 -2
- package/dist/src/generated/waterx_perp/trading.d.ts +303 -179
- package/dist/src/generated/waterx_perp/trading.js +99 -14
- package/dist/src/generated/waterx_perp_view/view.js +5 -10
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +5 -5
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +1 -2
- package/dist/src/generated/waterx_referral/referral_table.d.ts +5 -5
- package/dist/src/generated/waterx_referral/referral_table.js +1 -2
- package/dist/src/generated/waterx_staking/waterx_staking.d.ts +19 -19
- package/dist/src/generated/waterx_staking/waterx_staking.js +10 -20
- package/dist/src/generated/waterx_supra_rule/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_supra_rule/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_supra_rule/supra_rule.d.ts +158 -0
- package/dist/src/generated/waterx_supra_rule/supra_rule.js +148 -0
- package/dist/src/generated/withdrawal_queue/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/src/generated/withdrawal_queue/deps/bucket_v2_framework/float.js +10 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.d.ts +444 -4
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.js +417 -4
- package/dist/src/generated/wormhole_bridge/wormhole_bridge.d.ts +214 -74
- package/dist/src/generated/wormhole_bridge/wormhole_bridge.js +158 -29
- package/dist/src/index.d.ts +4 -3
- package/dist/src/index.js +3 -2
- package/dist/src/prediction/account.d.ts +96 -0
- package/dist/src/prediction/account.js +230 -0
- package/dist/src/prediction/admin.d.ts +47 -0
- package/dist/src/prediction/admin.js +105 -0
- package/dist/src/prediction/bcs.d.ts +22 -0
- package/dist/src/prediction/bcs.js +240 -0
- package/dist/src/prediction/client.d.ts +75 -0
- package/dist/src/prediction/client.js +164 -0
- package/dist/src/prediction/config.d.ts +60 -0
- package/dist/src/prediction/config.js +75 -0
- package/dist/src/prediction/constants.d.ts +44 -0
- package/dist/src/prediction/constants.js +46 -0
- package/dist/src/prediction/fetch.d.ts +82 -0
- package/dist/src/prediction/fetch.js +270 -0
- package/dist/src/prediction/generated/bucket_v2_framework/account.d.ts +100 -0
- package/dist/src/prediction/generated/bucket_v2_framework/account.js +129 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.d.ts +6 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.js +19 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.d.ts +10 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.js +14 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.js +27 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_set.js +19 -0
- package/dist/src/prediction/generated/bucket_v2_framework/double.d.ts +382 -0
- package/dist/src/prediction/generated/bucket_v2_framework/double.js +466 -0
- package/dist/src/prediction/generated/bucket_v2_framework/float.d.ts +362 -0
- package/dist/src/prediction/generated/bucket_v2_framework/float.js +440 -0
- package/dist/src/prediction/generated/bucket_v2_framework/liability.d.ts +193 -0
- package/dist/src/prediction/generated/bucket_v2_framework/liability.js +205 -0
- package/dist/src/prediction/generated/bucket_v2_framework/linked_table.d.ts +384 -0
- package/dist/src/prediction/generated/bucket_v2_framework/linked_table.js +382 -0
- package/dist/src/prediction/generated/bucket_v2_framework/sheet.d.ts +344 -0
- package/dist/src/prediction/generated/bucket_v2_framework/sheet.js +338 -0
- package/dist/src/prediction/generated/utils/index.d.ts +30 -0
- package/dist/src/prediction/generated/utils/index.js +160 -0
- package/dist/src/prediction/generated/waterx_account/account.d.ts +1589 -0
- package/dist/src/prediction/generated/waterx_account/account.js +1758 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.d.ts +7 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.js +13 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.d.ts +7 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.js +16 -0
- package/dist/src/prediction/generated/waterx_account/deps/std/type_name.d.ts +6 -0
- package/dist/src/prediction/generated/waterx_account/deps/std/type_name.js +19 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/balance.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/balance.js +14 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.d.ts +12 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.js +19 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/table.d.ts +24 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/table.js +31 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.js +27 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.js +19 -0
- package/dist/src/prediction/generated/waterx_account/direct_rule.d.ts +75 -0
- package/dist/src/prediction/generated/waterx_account/direct_rule.js +78 -0
- package/dist/src/prediction/generated/waterx_account/events.d.ts +33 -0
- package/dist/src/prediction/generated/waterx_account/events.js +137 -0
- package/dist/src/prediction/generated/waterx_account/version.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_account/version.js +8 -0
- package/dist/src/prediction/generated/waterx_prediction/account_data.d.ts +327 -0
- package/dist/src/prediction/generated/waterx_prediction/account_data.js +405 -0
- package/dist/src/prediction/generated/waterx_prediction/admin.d.ts +5 -0
- package/dist/src/prediction/generated/waterx_prediction/admin.js +9 -0
- package/dist/src/prediction/generated/waterx_prediction/bet_sharing.d.ts +60 -0
- package/dist/src/prediction/generated/waterx_prediction/bet_sharing.js +83 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/bucket_v2_framework/linked_table.d.ts +8 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/bucket_v2_framework/linked_table.js +18 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.js +14 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.d.ts +24 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.js +31 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.js +19 -0
- package/dist/src/prediction/generated/waterx_prediction/events.d.ts +22 -0
- package/dist/src/prediction/generated/waterx_prediction/events.js +179 -0
- package/dist/src/prediction/generated/waterx_prediction/global_config.d.ts +116 -0
- package/dist/src/prediction/generated/waterx_prediction/global_config.js +141 -0
- package/dist/src/prediction/generated/waterx_prediction/order.d.ts +200 -0
- package/dist/src/prediction/generated/waterx_prediction/order.js +284 -0
- package/dist/src/prediction/generated/waterx_prediction/outcome.d.ts +58 -0
- package/dist/src/prediction/generated/waterx_prediction/outcome.js +73 -0
- package/dist/src/prediction/generated/waterx_prediction/position.d.ts +160 -0
- package/dist/src/prediction/generated/waterx_prediction/position.js +214 -0
- package/dist/src/prediction/generated/waterx_prediction/version.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_prediction/version.js +8 -0
- package/dist/src/prediction/generated/waterx_prediction/view.d.ts +353 -0
- package/dist/src/prediction/generated/waterx_prediction/view.js +432 -0
- package/dist/src/prediction/generated/waterx_prediction/waterx_prediction.d.ts +1698 -0
- package/dist/src/prediction/generated/waterx_prediction/waterx_prediction.js +1733 -0
- package/dist/src/prediction/gift-link.d.ts +6 -0
- package/dist/src/prediction/gift-link.js +5 -0
- package/dist/src/prediction/gift.d.ts +223 -0
- package/dist/src/prediction/gift.js +451 -0
- package/dist/src/prediction/index.d.ts +29 -0
- package/dist/src/prediction/index.js +21 -0
- package/dist/src/prediction/prediction.d.ts +104 -0
- package/dist/src/prediction/prediction.js +317 -0
- package/dist/src/prediction/tx-builders.d.ts +44 -0
- package/dist/src/prediction/tx-builders.js +52 -0
- package/dist/src/prediction/types.d.ts +93 -0
- package/dist/src/prediction/types.js +1 -0
- package/dist/src/prediction/user/account.d.ts +2 -0
- package/dist/src/prediction/user/account.js +1 -0
- package/dist/src/prediction/user/admin.d.ts +6 -0
- package/dist/src/prediction/user/admin.js +3 -0
- package/dist/src/prediction/user/gift.d.ts +2 -0
- package/dist/src/prediction/user/gift.js +1 -0
- package/dist/src/prediction/user/index.d.ts +5 -0
- package/dist/src/prediction/user/index.js +3 -0
- package/dist/src/prediction/user/keeper.d.ts +2 -0
- package/dist/src/prediction/user/keeper.js +1 -0
- package/dist/src/prediction/user/order.d.ts +2 -0
- package/dist/src/prediction/user/order.js +1 -0
- package/dist/src/prediction/user/position.d.ts +2 -0
- package/dist/src/prediction/user/position.js +1 -0
- package/dist/src/prediction/utils/bcs.d.ts +1 -0
- package/dist/src/prediction/utils/bcs.js +1 -0
- package/dist/src/prediction/utils/index.d.ts +1 -0
- package/dist/src/prediction/utils/index.js +1 -0
- package/dist/src/prediction/utils.d.ts +30 -0
- package/dist/src/prediction/utils.js +177 -0
- package/dist/src/sdk.d.ts +18 -0
- package/dist/src/sdk.js +17 -0
- package/dist/src/tx-builders.d.ts +54 -0
- package/dist/src/tx-builders.js +141 -0
- package/dist/src/unified-client.d.ts +407 -0
- package/dist/src/unified-client.js +123 -0
- package/dist/src/user/account.d.ts +27 -0
- package/dist/src/user/account.js +34 -8
- package/dist/src/user/credit.d.ts +8 -14
- package/dist/src/user/credit.js +9 -23
- package/dist/src/user/custody.d.ts +4 -18
- package/dist/src/user/custody.js +14 -25
- package/dist/src/utils/consolidate-balance.d.ts +37 -0
- package/dist/src/utils/consolidate-balance.js +89 -0
- package/dist/src/utils/math.d.ts +86 -0
- package/dist/src/utils/math.js +100 -0
- package/dist/src/utils/pyth.d.ts +35 -3
- package/dist/src/utils/pyth.js +145 -14
- package/package.json +129 -34
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { SuiClientTypes } from "@mysten/sui/client";
|
|
2
|
+
import type { Signer } from "@mysten/sui/cryptography";
|
|
3
|
+
import { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
4
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
5
|
+
import { type LoadConfigOptions, type WaterxPredictionConfig } from "./config.ts";
|
|
6
|
+
import type { Network } from "./constants.ts";
|
|
7
|
+
export interface CreateClientOptions extends LoadConfigOptions {
|
|
8
|
+
grpcUrl?: string;
|
|
9
|
+
/** Settlement alias in `packages.waterx_prediction.*` maps. Default: "USD". */
|
|
10
|
+
settlement?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class PredictClient {
|
|
13
|
+
/** gRPC client - all RPC including `simulateTransaction`. */
|
|
14
|
+
grpcClient: SuiGrpcClient;
|
|
15
|
+
/** Network identifier in upper case (`MAINNET` / `TESTNET`). */
|
|
16
|
+
network: Network;
|
|
17
|
+
/** Parsed canonical `waterx-config` JSON. */
|
|
18
|
+
config: WaterxPredictionConfig;
|
|
19
|
+
/** Default settlement alias for prediction registry lookups. */
|
|
20
|
+
settlement: string;
|
|
21
|
+
constructor(network: Network, config: WaterxPredictionConfig, opts?: {
|
|
22
|
+
grpcUrl?: string;
|
|
23
|
+
settlement?: string;
|
|
24
|
+
});
|
|
25
|
+
static testnet(params?: CreateClientOptions): Promise<PredictClient>;
|
|
26
|
+
static mainnet(params?: CreateClientOptions): Promise<PredictClient>;
|
|
27
|
+
/**
|
|
28
|
+
* Async factory: fetches the deployment config for `network` and returns
|
|
29
|
+
* a ready-to-use client. Pass `opts.cache=true` to memoize the JSON.
|
|
30
|
+
*/
|
|
31
|
+
static create(network?: Network, opts?: CreateClientOptions): Promise<PredictClient>;
|
|
32
|
+
getObject(objectId: string): Promise<SuiClientTypes.GetObjectResponse<{}>>;
|
|
33
|
+
getObjects(objectIds: string[]): Promise<SuiClientTypes.GetObjectsResponse<{}>>;
|
|
34
|
+
listOwnedObjects(owner: string): Promise<SuiClientTypes.ListOwnedObjectsResponse<{}>>;
|
|
35
|
+
listCoins(params: {
|
|
36
|
+
owner: string;
|
|
37
|
+
coinType?: string;
|
|
38
|
+
}): Promise<SuiClientTypes.ListCoinsResponse>;
|
|
39
|
+
getBalance(params: {
|
|
40
|
+
owner: string;
|
|
41
|
+
coinType?: string;
|
|
42
|
+
}): Promise<SuiClientTypes.GetBalanceResponse>;
|
|
43
|
+
listDynamicFields(parentId: string): ReturnType<SuiGrpcClient["listDynamicFields"]>;
|
|
44
|
+
getDynamicField(parentId: string, name: {
|
|
45
|
+
type: string;
|
|
46
|
+
bcs: Uint8Array;
|
|
47
|
+
}): Promise<SuiClientTypes.GetDynamicFieldResponse>;
|
|
48
|
+
waitForTransaction(digest: string): Promise<SuiClientTypes.TransactionResult<{}>>;
|
|
49
|
+
simulate(tx: Transaction): Promise<SuiClientTypes.SimulateTransactionResult<{
|
|
50
|
+
commandResults: true;
|
|
51
|
+
}>>;
|
|
52
|
+
signAndExecuteTransaction<Include extends SuiClientTypes.TransactionInclude = object>(params: {
|
|
53
|
+
signer: {
|
|
54
|
+
toSuiAddress: () => string;
|
|
55
|
+
} & Signer;
|
|
56
|
+
transaction: Transaction | Uint8Array;
|
|
57
|
+
additionalSignatures?: string[];
|
|
58
|
+
include?: Include & SuiClientTypes.TransactionInclude;
|
|
59
|
+
}): Promise<SuiClientTypes.TransactionResult<Include & SuiClientTypes.TransactionInclude>>;
|
|
60
|
+
/** All package IDs (`published_at`) keyed by package name. */
|
|
61
|
+
packageIds(): Record<string, string>;
|
|
62
|
+
packageId(): string;
|
|
63
|
+
bucketFrameworkPackageId(): string;
|
|
64
|
+
waterxAccountPackageId(): string;
|
|
65
|
+
globalConfigId(): string;
|
|
66
|
+
marketRegistry(settlement?: string): string;
|
|
67
|
+
accountRegistry(): string;
|
|
68
|
+
settlementCoinType(settlement?: string): string;
|
|
69
|
+
predictionAdminCap(): string;
|
|
70
|
+
waterxAccountAdminCap(): string;
|
|
71
|
+
waterxPredictionGiftPackageId(): string;
|
|
72
|
+
claimableLinkConfigId(): string;
|
|
73
|
+
waterxReferralPackageId(): string;
|
|
74
|
+
referralTableId(): string;
|
|
75
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
2
|
+
import { loadConfig, } from "./config.js";
|
|
3
|
+
const GRPC_URLS = {
|
|
4
|
+
MAINNET: "https://fullnode.mainnet.sui.io:443",
|
|
5
|
+
TESTNET: "https://fullnode.testnet.sui.io:443",
|
|
6
|
+
};
|
|
7
|
+
export class PredictClient {
|
|
8
|
+
/** gRPC client - all RPC including `simulateTransaction`. */
|
|
9
|
+
grpcClient;
|
|
10
|
+
/** Network identifier in upper case (`MAINNET` / `TESTNET`). */
|
|
11
|
+
network;
|
|
12
|
+
/** Parsed canonical `waterx-config` JSON. */
|
|
13
|
+
config;
|
|
14
|
+
/** Default settlement alias for prediction registry lookups. */
|
|
15
|
+
settlement;
|
|
16
|
+
constructor(network, config, opts = {}) {
|
|
17
|
+
this.network = network;
|
|
18
|
+
this.config = config;
|
|
19
|
+
this.settlement = opts.settlement ?? "USD";
|
|
20
|
+
const baseUrl = opts.grpcUrl ?? config.grpcUrl ?? GRPC_URLS[network];
|
|
21
|
+
this.grpcClient = new SuiGrpcClient({
|
|
22
|
+
baseUrl,
|
|
23
|
+
network: network.toLowerCase(),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
static testnet(params = {}) {
|
|
27
|
+
return PredictClient.create("TESTNET", params);
|
|
28
|
+
}
|
|
29
|
+
static mainnet(params = {}) {
|
|
30
|
+
return PredictClient.create("MAINNET", params);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Async factory: fetches the deployment config for `network` and returns
|
|
34
|
+
* a ready-to-use client. Pass `opts.cache=true` to memoize the JSON.
|
|
35
|
+
*/
|
|
36
|
+
static async create(network = "TESTNET", opts = {}) {
|
|
37
|
+
const config = await loadConfig(network, opts);
|
|
38
|
+
return new PredictClient(network, config, {
|
|
39
|
+
grpcUrl: opts.grpcUrl,
|
|
40
|
+
settlement: opts.settlement,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
getObject(objectId) {
|
|
44
|
+
return this.grpcClient.getObject({ objectId });
|
|
45
|
+
}
|
|
46
|
+
getObjects(objectIds) {
|
|
47
|
+
return this.grpcClient.getObjects({ objectIds });
|
|
48
|
+
}
|
|
49
|
+
listOwnedObjects(owner) {
|
|
50
|
+
return this.grpcClient.listOwnedObjects({ owner });
|
|
51
|
+
}
|
|
52
|
+
listCoins(params) {
|
|
53
|
+
return this.grpcClient.listCoins(params);
|
|
54
|
+
}
|
|
55
|
+
getBalance(params) {
|
|
56
|
+
return this.grpcClient.getBalance(params);
|
|
57
|
+
}
|
|
58
|
+
listDynamicFields(parentId) {
|
|
59
|
+
return this.grpcClient.listDynamicFields({ parentId });
|
|
60
|
+
}
|
|
61
|
+
getDynamicField(parentId, name) {
|
|
62
|
+
return this.grpcClient.getDynamicField({ parentId, name });
|
|
63
|
+
}
|
|
64
|
+
waitForTransaction(digest) {
|
|
65
|
+
return this.grpcClient.waitForTransaction({ digest });
|
|
66
|
+
}
|
|
67
|
+
async simulate(tx) {
|
|
68
|
+
return withRpcRetry(() => this.grpcClient.simulateTransaction({
|
|
69
|
+
transaction: tx,
|
|
70
|
+
include: { commandResults: true },
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
async signAndExecuteTransaction(params) {
|
|
74
|
+
return this.grpcClient.signAndExecuteTransaction(params);
|
|
75
|
+
}
|
|
76
|
+
// ========================================================
|
|
77
|
+
// Shorthand accessors (canonical-schema lookups)
|
|
78
|
+
// ========================================================
|
|
79
|
+
/** All package IDs (`published_at`) keyed by package name. */
|
|
80
|
+
packageIds() {
|
|
81
|
+
const out = {};
|
|
82
|
+
for (const [name, pkg] of Object.entries(this.config.packages)) {
|
|
83
|
+
if (isPublishedPackage(pkg))
|
|
84
|
+
out[name] = pkg.published_at;
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
packageId() {
|
|
89
|
+
return this.config.packages.waterx_prediction.published_at;
|
|
90
|
+
}
|
|
91
|
+
bucketFrameworkPackageId() {
|
|
92
|
+
return this.config.packages.bucket_framework.published_at;
|
|
93
|
+
}
|
|
94
|
+
waterxAccountPackageId() {
|
|
95
|
+
return this.config.packages.waterx_account.published_at;
|
|
96
|
+
}
|
|
97
|
+
globalConfigId() {
|
|
98
|
+
return this.config.packages.waterx_prediction.global_config;
|
|
99
|
+
}
|
|
100
|
+
marketRegistry(settlement = this.settlement) {
|
|
101
|
+
return requireConfigValue(this.config.packages.waterx_prediction.market_registries, settlement, `packages.waterx_prediction.market_registries.${settlement}`);
|
|
102
|
+
}
|
|
103
|
+
accountRegistry() {
|
|
104
|
+
return this.config.packages.waterx_account.account_registry;
|
|
105
|
+
}
|
|
106
|
+
settlementCoinType(settlement = this.settlement) {
|
|
107
|
+
return requireConfigValue(this.config.packages.waterx_prediction.settlement_coin_types, settlement, `packages.waterx_prediction.settlement_coin_types.${settlement}`);
|
|
108
|
+
}
|
|
109
|
+
predictionAdminCap() {
|
|
110
|
+
return requireConfigValue(this.config.packages.waterx_prediction, "admin_cap", "packages.waterx_prediction.admin_cap");
|
|
111
|
+
}
|
|
112
|
+
waterxAccountAdminCap() {
|
|
113
|
+
return requireConfigValue(this.config.packages.waterx_account, "admin_cap", "packages.waterx_account.admin_cap");
|
|
114
|
+
}
|
|
115
|
+
waterxPredictionGiftPackageId() {
|
|
116
|
+
return requireConfigValue(this.config.packages.waterx_prediction_gift, "published_at", "packages.waterx_prediction_gift.published_at");
|
|
117
|
+
}
|
|
118
|
+
claimableLinkConfigId() {
|
|
119
|
+
return requireConfigValue(this.config.packages.waterx_prediction_gift, "claimable_link_config", "packages.waterx_prediction_gift.claimable_link_config");
|
|
120
|
+
}
|
|
121
|
+
waterxReferralPackageId() {
|
|
122
|
+
return requireConfigValue(this.config.packages.waterx_referral, "published_at", "packages.waterx_referral.published_at");
|
|
123
|
+
}
|
|
124
|
+
referralTableId() {
|
|
125
|
+
return requireConfigValue(this.config.packages.waterx_referral, "referral_table", "packages.waterx_referral.referral_table");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function isPublishedPackage(value) {
|
|
129
|
+
return (!!value &&
|
|
130
|
+
typeof value === "object" &&
|
|
131
|
+
"published_at" in value &&
|
|
132
|
+
typeof value.published_at === "string");
|
|
133
|
+
}
|
|
134
|
+
function requireConfigValue(map, key, path) {
|
|
135
|
+
const value = map?.[key];
|
|
136
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
137
|
+
throw new Error(`waterx-config missing ${path}`);
|
|
138
|
+
}
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Retry a grpc call on transient `RESOURCE_EXHAUSTED` (HTTP 429) responses from the public
|
|
143
|
+
* testnet RPC. Uses exponential backoff with jitter; bails on the first non-rate-limit error.
|
|
144
|
+
*/
|
|
145
|
+
async function withRpcRetry(fn, maxAttempts = 4) {
|
|
146
|
+
let lastErr;
|
|
147
|
+
for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
|
|
148
|
+
try {
|
|
149
|
+
return await fn();
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
lastErr = err;
|
|
153
|
+
const code = err?.code;
|
|
154
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
155
|
+
const isRateLimit = code === "RESOURCE_EXHAUSTED" || /too many requests|rate.?limit/i.test(msg);
|
|
156
|
+
if (!isRateLimit || attempt === maxAttempts - 1)
|
|
157
|
+
throw err;
|
|
158
|
+
const baseMs = 400 * 2 ** attempt; // 400, 800, 1600, ...
|
|
159
|
+
const jitter = Math.floor(Math.random() * 200);
|
|
160
|
+
await new Promise((r) => setTimeout(r, baseMs + jitter));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
throw lastErr;
|
|
164
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WaterX prediction deployment config loader.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the canonical `waterx-config` JSON for the packages used by this SDK
|
|
5
|
+
* and fetches it from GitHub raw by default.
|
|
6
|
+
*/
|
|
7
|
+
import type { Network } from "./constants.ts";
|
|
8
|
+
export interface WaterxConfigPackageBase {
|
|
9
|
+
published_at: string;
|
|
10
|
+
original_id?: string;
|
|
11
|
+
version?: number;
|
|
12
|
+
upgrade_capability?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface WaterxAccountPackage extends WaterxConfigPackageBase {
|
|
15
|
+
admin_cap?: string;
|
|
16
|
+
account_registry: string;
|
|
17
|
+
}
|
|
18
|
+
export interface WaterxPredictionPackage extends WaterxConfigPackageBase {
|
|
19
|
+
admin_cap?: string;
|
|
20
|
+
global_config: string;
|
|
21
|
+
market_registries: Record<string, string>;
|
|
22
|
+
settlement_coin_types?: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
export interface WaterxPredictionGiftPackage extends WaterxConfigPackageBase {
|
|
25
|
+
admin_cap?: string;
|
|
26
|
+
/** `ClaimableLinkConfig` shared object id. */
|
|
27
|
+
claimable_link_config: string;
|
|
28
|
+
}
|
|
29
|
+
export interface WaterxReferralPackage extends WaterxConfigPackageBase {
|
|
30
|
+
admin_cap?: string;
|
|
31
|
+
/** `ReferralTable` shared object id. */
|
|
32
|
+
referral_table: string;
|
|
33
|
+
}
|
|
34
|
+
export interface WaterxPredictionConfigPackages {
|
|
35
|
+
bucket_framework: WaterxConfigPackageBase;
|
|
36
|
+
waterx_account: WaterxAccountPackage;
|
|
37
|
+
waterx_prediction: WaterxPredictionPackage;
|
|
38
|
+
waterx_prediction_gift?: WaterxPredictionGiftPackage;
|
|
39
|
+
waterx_referral?: WaterxReferralPackage;
|
|
40
|
+
[name: string]: unknown;
|
|
41
|
+
}
|
|
42
|
+
export interface WaterxPredictionConfig {
|
|
43
|
+
network?: string;
|
|
44
|
+
chain_id?: string | number | null;
|
|
45
|
+
grpcUrl?: string;
|
|
46
|
+
packages: WaterxPredictionConfigPackages;
|
|
47
|
+
}
|
|
48
|
+
export interface LoadConfigOptions {
|
|
49
|
+
/** Override the default waterx-config raw JSON URL. */
|
|
50
|
+
configUrl?: string;
|
|
51
|
+
/** Reuse a previously fetched config in memory. Default: false. */
|
|
52
|
+
cache?: boolean;
|
|
53
|
+
/** Optional fetch implementation for tests or runtimes without global fetch. */
|
|
54
|
+
fetchImpl?: typeof fetch;
|
|
55
|
+
/** Request timeout in ms. Default: 10_000. */
|
|
56
|
+
timeoutMs?: number;
|
|
57
|
+
}
|
|
58
|
+
export declare function defaultConfigUrl(network: Network): string;
|
|
59
|
+
export declare function clearConfigCache(): void;
|
|
60
|
+
export declare function loadConfig(network: Network, opts?: LoadConfigOptions): Promise<WaterxPredictionConfig>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WaterX prediction deployment config loader.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the canonical `waterx-config` JSON for the packages used by this SDK
|
|
5
|
+
* and fetches it from GitHub raw by default.
|
|
6
|
+
*/
|
|
7
|
+
const DEFAULT_CONFIG_URL_BASE = "https://raw.githubusercontent.com/WaterXProtocol/waterx-config/main";
|
|
8
|
+
export function defaultConfigUrl(network) {
|
|
9
|
+
return `${DEFAULT_CONFIG_URL_BASE}/${network.toLowerCase()}.json`;
|
|
10
|
+
}
|
|
11
|
+
const configCache = new Map();
|
|
12
|
+
export function clearConfigCache() {
|
|
13
|
+
configCache.clear();
|
|
14
|
+
}
|
|
15
|
+
export async function loadConfig(network, opts = {}) {
|
|
16
|
+
const url = opts.configUrl ?? defaultConfigUrl(network);
|
|
17
|
+
if (opts.cache && configCache.has(url)) {
|
|
18
|
+
return configCache.get(url);
|
|
19
|
+
}
|
|
20
|
+
const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
|
|
21
|
+
if (!fetchImpl) {
|
|
22
|
+
throw new Error("loadConfig: no global fetch available; pass opts.fetchImpl");
|
|
23
|
+
}
|
|
24
|
+
const controller = new AbortController();
|
|
25
|
+
const timer = setTimeout(() => controller.abort(), opts.timeoutMs ?? 10_000);
|
|
26
|
+
let response;
|
|
27
|
+
try {
|
|
28
|
+
response = await fetchImpl(url, { signal: controller.signal });
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
clearTimeout(timer);
|
|
32
|
+
}
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
throw new Error(`loadConfig: HTTP ${response.status} fetching ${url}`);
|
|
35
|
+
}
|
|
36
|
+
const raw = (await response.json());
|
|
37
|
+
validateConfig(raw, network, url);
|
|
38
|
+
if (opts.cache) {
|
|
39
|
+
configCache.set(url, raw);
|
|
40
|
+
}
|
|
41
|
+
return raw;
|
|
42
|
+
}
|
|
43
|
+
function validateConfig(cfg, expected, url) {
|
|
44
|
+
if (cfg.network !== undefined && cfg.network.toUpperCase() !== expected) {
|
|
45
|
+
throw new Error(`loadConfig: config at ${url} declares network=${cfg.network} but caller asked for ${expected}`);
|
|
46
|
+
}
|
|
47
|
+
if (!isRecord(cfg.packages)) {
|
|
48
|
+
throw new Error(`loadConfig: config at ${url} has no packages object`);
|
|
49
|
+
}
|
|
50
|
+
const packages = cfg.packages;
|
|
51
|
+
requirePublishedPackage(packages.bucket_framework, "bucket_framework", url);
|
|
52
|
+
const account = requirePublishedPackage(packages.waterx_account, "waterx_account", url);
|
|
53
|
+
const prediction = requirePublishedPackage(packages.waterx_prediction, "waterx_prediction", url);
|
|
54
|
+
if (!isNonEmptyString(account.account_registry)) {
|
|
55
|
+
throw new Error(`loadConfig: config at ${url} missing packages.waterx_account.account_registry`);
|
|
56
|
+
}
|
|
57
|
+
if (!isNonEmptyString(prediction.global_config)) {
|
|
58
|
+
throw new Error(`loadConfig: config at ${url} missing packages.waterx_prediction.global_config`);
|
|
59
|
+
}
|
|
60
|
+
if (!isRecord(prediction.market_registries)) {
|
|
61
|
+
throw new Error(`loadConfig: config at ${url} missing packages.waterx_prediction.market_registries`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function requirePublishedPackage(value, name, url) {
|
|
65
|
+
if (!isRecord(value) || !isNonEmptyString(value.published_at)) {
|
|
66
|
+
throw new Error(`loadConfig: config at ${url} missing packages.${name}.published_at`);
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
function isRecord(value) {
|
|
71
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
72
|
+
}
|
|
73
|
+
function isNonEmptyString(value) {
|
|
74
|
+
return typeof value === "string" && value.length > 0;
|
|
75
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type Network = "MAINNET" | "TESTNET";
|
|
2
|
+
export declare const CLOCK_OBJECT_ID = "0x6";
|
|
3
|
+
export declare const PREDICTION_PERM_PLACE_ORDER: number;
|
|
4
|
+
export declare const PREDICTION_PERM_CANCEL_ORDER: number;
|
|
5
|
+
export declare const PREDICTION_PERM_CLAIM: number;
|
|
6
|
+
export declare const PREDICTION_PERM_REQUEST_CLOSE: number;
|
|
7
|
+
/** Default chunk size for `buildBatchForceClaimTransactions` (1 request + N claims; Sui max ~1024 commands). */
|
|
8
|
+
export declare const DEFAULT_FORCE_CLAIM_CHUNK_SIZE = 1000;
|
|
9
|
+
export declare const PREDICTION_PERM_ALL: number;
|
|
10
|
+
export declare const ACCOUNT_PERM_WITHDRAW: number;
|
|
11
|
+
export declare const ACCOUNT_PERM_MANAGE_DELEGATES: number;
|
|
12
|
+
export declare const ACCOUNT_PERM_RECEIVE: number;
|
|
13
|
+
export declare const ACCOUNT_PERM_ALL = 4294967295;
|
|
14
|
+
/**
|
|
15
|
+
* Gift KDF / signed-message constants. Mirror `waterx_prediction_gift::claimable_link`.
|
|
16
|
+
* Stable across package upgrades — outstanding URLs must keep working.
|
|
17
|
+
*/
|
|
18
|
+
export declare const GIFT_KDF_DOMAIN: Uint8Array<ArrayBuffer>;
|
|
19
|
+
export declare const GIFT_DOMAIN_CLAIM: Uint8Array<ArrayBuffer>;
|
|
20
|
+
export declare const GIFT_URL_SEED_BYTES = 16;
|
|
21
|
+
export declare const GIFT_PUBKEY_LEN = 32;
|
|
22
|
+
export declare const GIFT_SIG_LEN = 64;
|
|
23
|
+
export declare const GIFT_CONTROLLER_DELEGATE_ALIAS = "waterx_gift_controller";
|
|
24
|
+
export declare const GIFT_AUTO_MAIN_ACCOUNT_ALIAS = "main";
|
|
25
|
+
export declare const GIFT_MAX_SHARES_PER_GIFT = 500;
|
|
26
|
+
export declare const PREDICTION_ERROR_CODES: {
|
|
27
|
+
readonly EBadStatus: 1;
|
|
28
|
+
readonly EMarketNotResolved: 3;
|
|
29
|
+
readonly EAlreadyResolved: 4;
|
|
30
|
+
readonly EBadPriceCap: 5;
|
|
31
|
+
readonly EFillExceedsMax: 6;
|
|
32
|
+
readonly EFillBelowMin: 7;
|
|
33
|
+
readonly EBadExpiry: 8;
|
|
34
|
+
readonly EBadPayment: 9;
|
|
35
|
+
readonly EMarketPaused: 10;
|
|
36
|
+
readonly EBelowMinReserve: 11;
|
|
37
|
+
readonly EMarketAlreadyResolved: 12;
|
|
38
|
+
readonly ECloseProceedsBelowMin: 13;
|
|
39
|
+
readonly EUnauthorized: 14;
|
|
40
|
+
readonly ENotAccountPosition: 16;
|
|
41
|
+
readonly EOrderInCooldown: 17;
|
|
42
|
+
readonly EOrderExpired: 18;
|
|
43
|
+
readonly EOrderNotExpired: 19;
|
|
44
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const CLOCK_OBJECT_ID = "0x6";
|
|
2
|
+
export const PREDICTION_PERM_PLACE_ORDER = 1 << 0;
|
|
3
|
+
export const PREDICTION_PERM_CANCEL_ORDER = 1 << 1;
|
|
4
|
+
export const PREDICTION_PERM_CLAIM = 1 << 2;
|
|
5
|
+
export const PREDICTION_PERM_REQUEST_CLOSE = 1 << 3;
|
|
6
|
+
/** Default chunk size for `buildBatchForceClaimTransactions` (1 request + N claims; Sui max ~1024 commands). */
|
|
7
|
+
export const DEFAULT_FORCE_CLAIM_CHUNK_SIZE = 1000;
|
|
8
|
+
export const PREDICTION_PERM_ALL = PREDICTION_PERM_PLACE_ORDER |
|
|
9
|
+
PREDICTION_PERM_CANCEL_ORDER |
|
|
10
|
+
PREDICTION_PERM_CLAIM |
|
|
11
|
+
PREDICTION_PERM_REQUEST_CLOSE;
|
|
12
|
+
export const ACCOUNT_PERM_WITHDRAW = 1 << 0;
|
|
13
|
+
export const ACCOUNT_PERM_MANAGE_DELEGATES = 1 << 1;
|
|
14
|
+
export const ACCOUNT_PERM_RECEIVE = 1 << 2;
|
|
15
|
+
export const ACCOUNT_PERM_ALL = 0xffffffff;
|
|
16
|
+
/**
|
|
17
|
+
* Gift KDF / signed-message constants. Mirror `waterx_prediction_gift::claimable_link`.
|
|
18
|
+
* Stable across package upgrades — outstanding URLs must keep working.
|
|
19
|
+
*/
|
|
20
|
+
export const GIFT_KDF_DOMAIN = new TextEncoder().encode("waterx_prediction_gift/kdf");
|
|
21
|
+
export const GIFT_DOMAIN_CLAIM = new TextEncoder().encode("waterx_prediction_gift/claim");
|
|
22
|
+
export const GIFT_URL_SEED_BYTES = 16;
|
|
23
|
+
export const GIFT_PUBKEY_LEN = 32;
|
|
24
|
+
export const GIFT_SIG_LEN = 64;
|
|
25
|
+
export const GIFT_CONTROLLER_DELEGATE_ALIAS = "waterx_gift_controller";
|
|
26
|
+
export const GIFT_AUTO_MAIN_ACCOUNT_ALIAS = "main";
|
|
27
|
+
export const GIFT_MAX_SHARES_PER_GIFT = 500;
|
|
28
|
+
export const PREDICTION_ERROR_CODES = {
|
|
29
|
+
EBadStatus: 1,
|
|
30
|
+
EMarketNotResolved: 3,
|
|
31
|
+
EAlreadyResolved: 4,
|
|
32
|
+
EBadPriceCap: 5,
|
|
33
|
+
EFillExceedsMax: 6,
|
|
34
|
+
EFillBelowMin: 7,
|
|
35
|
+
EBadExpiry: 8,
|
|
36
|
+
EBadPayment: 9,
|
|
37
|
+
EMarketPaused: 10,
|
|
38
|
+
EBelowMinReserve: 11,
|
|
39
|
+
EMarketAlreadyResolved: 12,
|
|
40
|
+
ECloseProceedsBelowMin: 13,
|
|
41
|
+
EUnauthorized: 14,
|
|
42
|
+
ENotAccountPosition: 16,
|
|
43
|
+
EOrderInCooldown: 17,
|
|
44
|
+
EOrderExpired: 18,
|
|
45
|
+
EOrderNotExpired: 19,
|
|
46
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { PredictClient } from "./client.ts";
|
|
2
|
+
import type { AccountDataView, CursorView, MarketExposure, MarketIdInput, MarketView, OrderView, PositionView, RegistryView } from "./types.ts";
|
|
3
|
+
export declare function extractReturnBytes(result: any, commandIndex?: number, returnIndex?: number): Uint8Array;
|
|
4
|
+
export interface ViewBaseParams {
|
|
5
|
+
packageId?: string;
|
|
6
|
+
marketRegistry?: string;
|
|
7
|
+
accountRegistry?: string;
|
|
8
|
+
settlementCoinType?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function getRegistry(client: PredictClient, params?: ViewBaseParams): Promise<RegistryView>;
|
|
11
|
+
export declare function getOrder(client: PredictClient, params: ViewBaseParams & {
|
|
12
|
+
orderId: bigint | number | string;
|
|
13
|
+
}): Promise<OrderView>;
|
|
14
|
+
export declare function getPosition(client: PredictClient, params: ViewBaseParams & {
|
|
15
|
+
positionId: bigint | number | string;
|
|
16
|
+
}): Promise<PositionView>;
|
|
17
|
+
export declare function getMarketById(client: PredictClient, params: ViewBaseParams & {
|
|
18
|
+
marketId: MarketIdInput;
|
|
19
|
+
}): Promise<MarketView>;
|
|
20
|
+
export declare function getMarketByKey(client: PredictClient, params: ViewBaseParams & {
|
|
21
|
+
marketKey: bigint | number | string;
|
|
22
|
+
}): Promise<MarketView>;
|
|
23
|
+
export declare function getMarketExposure(client: PredictClient, params: ViewBaseParams & {
|
|
24
|
+
marketId: MarketIdInput;
|
|
25
|
+
}): Promise<MarketExposure>;
|
|
26
|
+
export declare function getMarketExposureByKey(client: PredictClient, params: ViewBaseParams & {
|
|
27
|
+
marketKey: bigint | number | string;
|
|
28
|
+
}): Promise<MarketExposure>;
|
|
29
|
+
export declare function getOrderCursor(client: PredictClient, params?: ViewBaseParams): Promise<CursorView>;
|
|
30
|
+
export declare function getPositionCursor(client: PredictClient, params?: ViewBaseParams): Promise<CursorView>;
|
|
31
|
+
export declare function getUnresolvedMarketCursor(client: PredictClient, params?: ViewBaseParams): Promise<CursorView>;
|
|
32
|
+
export declare function getResolvedMarketCursor(client: PredictClient, params?: ViewBaseParams): Promise<CursorView>;
|
|
33
|
+
export interface GetAccountIdsParams {
|
|
34
|
+
/** Wallet address that owns sub-accounts in the registry. */
|
|
35
|
+
owner: string;
|
|
36
|
+
accountRegistry?: string;
|
|
37
|
+
/** `waterx_account` package id (defaults to `client.waterxAccountPackageId()`). */
|
|
38
|
+
accountPackageId?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Registry account ids (`0x2::object::ID`) for an owner via `waterx_account::account::account_ids`.
|
|
42
|
+
* Use these ids with `getAccountData`, `deposit`, and `placeOrder` — not Suiscan "Account" object addresses.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getAccountIds(client: PredictClient, params: GetAccountIdsParams): Promise<string[]>;
|
|
45
|
+
export declare function getAccountData(client: PredictClient, params: ViewBaseParams & {
|
|
46
|
+
accountId: string;
|
|
47
|
+
}): Promise<AccountDataView>;
|
|
48
|
+
export declare function getAccountOrderIds(client: PredictClient, params: ViewBaseParams & {
|
|
49
|
+
accountId: string;
|
|
50
|
+
marketKey: bigint | number | string;
|
|
51
|
+
}): Promise<bigint[]>;
|
|
52
|
+
export declare function getAccountPositionIds(client: PredictClient, params: ViewBaseParams & {
|
|
53
|
+
accountId: string;
|
|
54
|
+
marketKey: bigint | number | string;
|
|
55
|
+
}): Promise<bigint[]>;
|
|
56
|
+
export declare function getAccountOrderIdsByMarketId(client: PredictClient, params: ViewBaseParams & {
|
|
57
|
+
accountId: string;
|
|
58
|
+
marketId: MarketIdInput;
|
|
59
|
+
}): Promise<bigint[]>;
|
|
60
|
+
export declare function getAccountPositionIdsByMarketId(client: PredictClient, params: ViewBaseParams & {
|
|
61
|
+
accountId: string;
|
|
62
|
+
marketId: MarketIdInput;
|
|
63
|
+
}): Promise<bigint[]>;
|
|
64
|
+
export declare function isKeeper(client: PredictClient, params: {
|
|
65
|
+
packageId?: string;
|
|
66
|
+
globalConfig?: string;
|
|
67
|
+
keeper: string;
|
|
68
|
+
}): Promise<boolean>;
|
|
69
|
+
export declare function getKeeperAddresses(client: PredictClient, params?: {
|
|
70
|
+
packageId?: string;
|
|
71
|
+
globalConfig?: string;
|
|
72
|
+
}): Promise<string[]>;
|
|
73
|
+
export declare function getAllowedVersions(client: PredictClient, params?: {
|
|
74
|
+
packageId?: string;
|
|
75
|
+
globalConfig?: string;
|
|
76
|
+
}): Promise<number[]>;
|
|
77
|
+
export declare function isPredictionProtocolAssetAllowed(client: PredictClient, params?: {
|
|
78
|
+
accountPackageId?: string;
|
|
79
|
+
accountRegistry?: string;
|
|
80
|
+
predictionPackageId?: string;
|
|
81
|
+
coinType?: string;
|
|
82
|
+
}): Promise<boolean>;
|