@waterx/sdk 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -7
- package/dist/cjs/src/perp/config.d.ts +6 -16
- package/dist/cjs/src/perp/config.js +4 -12
- package/dist/cjs/src/perp/index.d.ts +1 -1
- package/dist/cjs/src/perp/index.js +3 -4
- package/dist/cjs/src/prediction/config.d.ts +5 -15
- package/dist/cjs/src/prediction/config.js +4 -12
- package/dist/cjs/src/prediction/fetch.d.ts +6 -1
- package/dist/cjs/src/prediction/fetch.js +64 -0
- package/dist/cjs/src/prediction/index.d.ts +2 -2
- package/dist/cjs/src/prediction/index.js +7 -4
- package/dist/cjs/src/prediction/types.d.ts +19 -0
- package/dist/cjs/src/unified-client.d.ts +9 -4
- package/dist/cjs/src/unified-client.js +2 -2
- package/dist/src/perp/config.d.ts +6 -16
- package/dist/src/perp/config.js +4 -11
- package/dist/src/perp/index.d.ts +1 -1
- package/dist/src/perp/index.js +1 -1
- package/dist/src/prediction/config.d.ts +5 -15
- package/dist/src/prediction/config.js +4 -11
- package/dist/src/prediction/fetch.d.ts +6 -1
- package/dist/src/prediction/fetch.js +60 -0
- package/dist/src/prediction/index.d.ts +2 -2
- package/dist/src/prediction/index.js +2 -2
- package/dist/src/prediction/types.d.ts +19 -0
- package/dist/src/unified-client.d.ts +9 -4
- package/dist/src/unified-client.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,13 +11,18 @@ The perp and prediction lines expose builder functions with **colliding names**
|
|
|
11
11
|
```ts
|
|
12
12
|
import { WaterXClient } from "@waterx/sdk";
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
// waterxConfigUrl is REQUIRED — the SDK has no built-in default and never reads env.
|
|
15
|
+
const client = await WaterXClient.create({
|
|
16
|
+
network: "TESTNET",
|
|
17
|
+
waterxConfigUrl: "https://raw.githubusercontent.com/WaterXProtocol/waterx-config/main/testnet.json",
|
|
18
|
+
});
|
|
15
19
|
client.account.createAccount(tx, { alias }); // shared waterx_account + funding (credit/custody)
|
|
16
20
|
client.perp.buildPlaceOrderTx(params); // perpetuals
|
|
17
21
|
client.predict.placeOrder(tx, params); // prediction markets
|
|
18
22
|
// client.perp / client.predict ARE the line clients — sign/execute on them directly:
|
|
19
23
|
// await client.perp.signAndExecuteTransaction({ transaction: tx, signer })
|
|
20
|
-
// each line can target a different network
|
|
24
|
+
// each line can target a different network + URL:
|
|
25
|
+
// WaterXClient.create({ perp: { network: "MAINNET", waterxConfigUrl: mainnetUrl }, predict: { network: "TESTNET", waterxConfigUrl: testnetUrl } })
|
|
21
26
|
```
|
|
22
27
|
|
|
23
28
|
> `WaterXClient` is the umbrella entry point. `Client` is kept as a **deprecated alias** for one major cycle.
|
|
@@ -41,13 +46,16 @@ Consumers: `pnpm add @waterx/sdk @mysten/sui`
|
|
|
41
46
|
|
|
42
47
|
## Quickstart (unified client)
|
|
43
48
|
|
|
44
|
-
`WaterXClient.create()` loads each line's deployment config from the canonical `waterx-config` JSON and returns a ready client. Builders are **build-only** — they return / mutate a `Transaction`; signing & execution stay with the caller (`client.perp` / `client.predict` are the line clients, or a frontend wallet), so multi-step Pyth injection and wallet flows keep working.
|
|
49
|
+
`WaterXClient.create()` loads each line's deployment config from the canonical `waterx-config` JSON (its URL passed via the **required** `waterxConfigUrl` option — the SDK has no default and never reads env) and returns a ready client. Builders are **build-only** — they return / mutate a `Transaction`; signing & execution stay with the caller (`client.perp` / `client.predict` are the line clients, or a frontend wallet), so multi-step Pyth injection and wallet flows keep working.
|
|
45
50
|
|
|
46
51
|
```ts
|
|
47
52
|
import { WaterXClient, rawPrice } from "@waterx/sdk";
|
|
48
53
|
import { Transaction } from "@mysten/sui/transactions";
|
|
49
54
|
|
|
50
|
-
const client = await WaterXClient.create({
|
|
55
|
+
const client = await WaterXClient.create({
|
|
56
|
+
network: "TESTNET",
|
|
57
|
+
waterxConfigUrl: "https://raw.githubusercontent.com/WaterXProtocol/waterx-config/main/testnet.json",
|
|
58
|
+
});
|
|
51
59
|
const signer = /* your Ed25519Keypair or wallet Signer */;
|
|
52
60
|
|
|
53
61
|
// --- Perp: place a market order ---
|
|
@@ -77,14 +85,16 @@ await client.predict.signAndExecuteTransaction({ transaction: ptx, signer });
|
|
|
77
85
|
|
|
78
86
|
## Per-line clients
|
|
79
87
|
|
|
80
|
-
If you only need one line, construct it directly (both factories are **async** — they fetch deployment config):
|
|
88
|
+
If you only need one line, construct it directly (both factories are **async** — they fetch deployment config; `waterxConfigUrl` is **required**):
|
|
81
89
|
|
|
82
90
|
```ts
|
|
83
91
|
import { PerpClient } from "@waterx/sdk/perp";
|
|
84
92
|
import { PredictClient } from "@waterx/sdk/prediction";
|
|
85
93
|
|
|
86
|
-
const
|
|
87
|
-
|
|
94
|
+
const waterxConfigUrl =
|
|
95
|
+
"https://raw.githubusercontent.com/WaterXProtocol/waterx-config/main/testnet.json";
|
|
96
|
+
const perp = await PerpClient.create("TESTNET", { waterxConfigUrl }); // or PerpClient.testnet({ waterxConfigUrl })
|
|
97
|
+
const predict = await PredictClient.create("TESTNET", { waterxConfigUrl }); // or PredictClient.testnet({ waterxConfigUrl })
|
|
88
98
|
```
|
|
89
99
|
|
|
90
100
|
Read-only queries use gRPC `simulateTransaction` (no signer) — the `getX` view helpers, e.g. `await perp.simulate(tx)` or `getMarketData(perp, …)`.
|
|
@@ -95,18 +95,13 @@ export interface WaterXConfig {
|
|
|
95
95
|
}
|
|
96
96
|
export interface LoadConfigOptions {
|
|
97
97
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
98
|
+
* Canonical `waterx-config` JSON URL to fetch, **as-is** (no `<network>.json`
|
|
99
|
+
* / git ref appended). Required — {@link loadConfig} reads the URL only from
|
|
100
|
+
* this option (there is no env-var fallback and no built-in default) and
|
|
101
|
+
* throws when it is unset. Point it at a staging deployment or local mirror
|
|
102
|
+
* as needed.
|
|
101
103
|
*/
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Pin the canonical config to a specific git ref — a commit SHA, branch,
|
|
105
|
-
* or tag — instead of the default `main` branch. Resolves to
|
|
106
|
-
* `https://raw.githubusercontent.com/WaterXProtocol/waterx-config/<ref>/<network>.json`.
|
|
107
|
-
* Ignored when {@link configUrl} is set.
|
|
108
|
-
*/
|
|
109
|
-
configRef?: string;
|
|
104
|
+
waterxConfigUrl?: string;
|
|
110
105
|
/**
|
|
111
106
|
* Reuse a previously-fetched config from the in-memory cache (keyed by
|
|
112
107
|
* the effective URL). Default: false (always fetch fresh).
|
|
@@ -117,10 +112,5 @@ export interface LoadConfigOptions {
|
|
|
117
112
|
/** Optional request timeout in ms. Default 10_000. */
|
|
118
113
|
timeoutMs?: number;
|
|
119
114
|
}
|
|
120
|
-
/**
|
|
121
|
-
* Build the canonical config URL for `network`, optionally pinned to a
|
|
122
|
-
* specific git `ref` (commit SHA, branch, or tag). Defaults to `main`.
|
|
123
|
-
*/
|
|
124
|
-
export declare function defaultConfigUrl(network: Network, ref?: string): string;
|
|
125
115
|
export declare function clearConfigCache(): void;
|
|
126
116
|
export declare function loadConfig(network: Network, opts?: LoadConfigOptions): Promise<WaterXConfig>;
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.WORMHOLE_DEFAULTS = exports.PYTH_DEFAULTS = void 0;
|
|
14
|
-
exports.defaultConfigUrl = defaultConfigUrl;
|
|
15
14
|
exports.clearConfigCache = clearConfigCache;
|
|
16
15
|
exports.loadConfig = loadConfig;
|
|
17
16
|
var config_ts_1 = require("../oracle/config.js");
|
|
@@ -40,22 +39,15 @@ exports.WORMHOLE_DEFAULTS = {
|
|
|
40
39
|
wormholescan_api: "https://api.testnet.wormholescan.io/api/v1",
|
|
41
40
|
},
|
|
42
41
|
};
|
|
43
|
-
const CONFIG_REPO_RAW_BASE = "https://raw.githubusercontent.com/WaterXProtocol/waterx-config";
|
|
44
|
-
/** Default git ref for the canonical config when none is pinned. */
|
|
45
|
-
const DEFAULT_CONFIG_REF = "main";
|
|
46
|
-
/**
|
|
47
|
-
* Build the canonical config URL for `network`, optionally pinned to a
|
|
48
|
-
* specific git `ref` (commit SHA, branch, or tag). Defaults to `main`.
|
|
49
|
-
*/
|
|
50
|
-
function defaultConfigUrl(network, ref = DEFAULT_CONFIG_REF) {
|
|
51
|
-
return `${CONFIG_REPO_RAW_BASE}/${ref}/${network.toLowerCase()}.json`;
|
|
52
|
-
}
|
|
53
42
|
const cache = new Map();
|
|
54
43
|
function clearConfigCache() {
|
|
55
44
|
cache.clear();
|
|
56
45
|
}
|
|
57
46
|
async function loadConfig(network, opts = {}) {
|
|
58
|
-
const url = opts.
|
|
47
|
+
const url = opts.waterxConfigUrl;
|
|
48
|
+
if (!url) {
|
|
49
|
+
throw new Error("loadConfig: no config URL — pass opts.waterxConfigUrl");
|
|
50
|
+
}
|
|
59
51
|
if (opts.cache && cache.has(url)) {
|
|
60
52
|
return cache.get(url);
|
|
61
53
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { PerpClient } from "./client.ts";
|
|
2
2
|
export type { CreateClientOptions } from "./client.ts";
|
|
3
|
-
export { PYTH_DEFAULTS, WORMHOLE_DEFAULTS, clearConfigCache,
|
|
3
|
+
export { PYTH_DEFAULTS, WORMHOLE_DEFAULTS, clearConfigCache, loadConfig } from "./config.ts";
|
|
4
4
|
export type { BasePackageEntry, ConstantFeedEntry, WaterxReferralPackage, LoadConfigOptions, NativeCustodyAsset, NativeCustodyPackage, PythInfraConfig, PythRulePackage, PythSponsorRulePackage, SupraFeedEntry, SupraRulePackage, TestnetFaucetPackage, TrustedEmitterRow, WaterXConfig, WaterXPackages, WaterxCreditPackage, WaterxOraclePackage, WaterxPerpMarketEntry, WaterxPerpPackage, WaterxStakingPackage, WithdrawalQueuePackage, WlpPackage, WormholeBridgePackage, WormholeInfraConfig, WxaAccountPackage, } from "./config.ts";
|
|
5
5
|
export { ACTION_ADD_PRE_ORDER, ACTION_CANCEL_ORDER, ACTION_CANCEL_PRE_ORDER, ACTION_CLOSE_POSITION, ACTION_DECREASE_POSITION, ACTION_DEPOSIT_COLLATERAL, ACTION_INCREASE_POSITION, ACTION_LIQUIDATE, ACTION_OPEN_POSITION, ACTION_PLACE_ORDER, ACTION_UPDATE_ORDER, ACTION_WITHDRAW_COLLATERAL, BPS_SCALE, CRYPTO_FEE_RATE, DOUBLE_SCALE, DRY_RUN_SENDER, FLOAT_SCALE, MAINTENANCE_MARGIN_RATE, ORDER_LIMIT_BUY, ORDER_LIMIT_SELL, ORDER_STOP_BUY, ORDER_STOP_SELL, ORDER_TAG_WILDCARD, PERM_ALL, PERM_ALL_TRADING, PERM_CANCEL_ORDER, PERM_CLOSE_POSITION, PERM_DECREASE_POSITION, PERM_DEPOSIT_COLLATERAL, PERM_INCREASE_POSITION, PERM_MINT_WLP, PERM_OPEN_POSITION, PERM_PLACE_ORDER, PERM_REDEEM_WLP, PERM_WITHDRAW_COLLATERAL, STAKING_PERM_DEPOSIT_STAKE, STAKING_PERM_REDEEM_STAKE, STAKING_PERM_CLAIM_REWARD, STAKING_PERM_ALL, STOCK_FEE_RATE, MS_PER_YEAR, SUI_DECIMALS, WLP_DECIMALS, COLLATERAL_DECIMALS, TOKEN_DECIMALS, } from "./constants.ts";
|
|
6
6
|
export type { Network } from "./constants.ts";
|
|
@@ -36,9 +36,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.COLLATERAL_DECIMALS = exports.WLP_DECIMALS = exports.SUI_DECIMALS = exports.MS_PER_YEAR = exports.STOCK_FEE_RATE = exports.STAKING_PERM_ALL = exports.STAKING_PERM_CLAIM_REWARD = exports.STAKING_PERM_REDEEM_STAKE = exports.STAKING_PERM_DEPOSIT_STAKE = exports.PERM_WITHDRAW_COLLATERAL = exports.PERM_REDEEM_WLP = exports.PERM_PLACE_ORDER = exports.PERM_OPEN_POSITION = exports.PERM_MINT_WLP = exports.PERM_INCREASE_POSITION = exports.PERM_DEPOSIT_COLLATERAL = exports.PERM_DECREASE_POSITION = exports.PERM_CLOSE_POSITION = exports.PERM_CANCEL_ORDER = exports.PERM_ALL_TRADING = exports.PERM_ALL = exports.ORDER_TAG_WILDCARD = exports.ORDER_STOP_SELL = exports.ORDER_STOP_BUY = exports.ORDER_LIMIT_SELL = exports.ORDER_LIMIT_BUY = exports.MAINTENANCE_MARGIN_RATE = exports.FLOAT_SCALE = exports.DRY_RUN_SENDER = exports.DOUBLE_SCALE = exports.CRYPTO_FEE_RATE = exports.BPS_SCALE = exports.ACTION_WITHDRAW_COLLATERAL = exports.ACTION_UPDATE_ORDER = exports.ACTION_PLACE_ORDER = exports.ACTION_OPEN_POSITION = exports.ACTION_LIQUIDATE = exports.ACTION_INCREASE_POSITION = exports.ACTION_DEPOSIT_COLLATERAL = exports.ACTION_DECREASE_POSITION = exports.ACTION_CLOSE_POSITION = exports.ACTION_CANCEL_PRE_ORDER = exports.ACTION_CANCEL_ORDER = exports.ACTION_ADD_PRE_ORDER = exports.loadConfig = exports.
|
|
40
|
-
exports.PoolDataBcs = exports.OrderDataBcs = exports.MarketDataBcs = exports.GlobalConfigDataBcs = exports.AccountDataBcs = exports.waitForVaa = exports.vaaBytesToBase64 = exports.vaaBase64ToHex = exports.vaaBase64ToBytes = exports.toWormholescanEmitter = exports.padEvmEmitter = exports.listVaasByEmitter = exports.listBridgeWithdrawalVaas = exports.fetchVaa = exports.fetchDepositVaa = exports.updatePythPrices = exports.refreshOraclePrices = exports.fetchPriceFeedsUpdateData = exports.buildPythPriceUpdateCalls = exports.aggregateTickerWithPyth = exports.aggregateTickerWithConstant = exports.aggregateTicker = exports.PythCache = exports.rawPrice = exports.decodeFundingIndexDelta = exports.calcWlpRedeemOut = exports.calcWlpPrice = exports.calcWlpMintOut = exports.calcWlpIncentiveApy = exports.calcUnrealizedPnl = exports.calcTotalTradingFeeRate = exports.calcTokenUtilizationBps = exports.calcPositionBorrowFee = exports.calcNotional = exports.calcMaxReducibleCollateralUsd = exports.calcLeverage = exports.calcImpactFeeRate = exports.calcFundingRate = exports.calcFundingFeeUsd = exports.calcFee = exports.calcEstLiqPrice = exports.calcEffectiveCollateralUsd = exports.calcDynamicFeeBps = exports.calcBorrowRateAccrual = exports.calcBorrowRate = exports.annualizeFundingRate = exports.annualizedApyFromRatio = exports.getCollateralAssets = exports.getMarketTickers =
|
|
41
|
-
exports.withdrawalQueueCalls = exports.nativeCustodyCalls = exports.referralCalls = exports.pythSponsorRuleCalls = exports.pythRuleCalls = exports.oracleCalls = exports.stakingCalls = exports.wxaAccountCalls = exports.viewCalls = exports.lpPoolCalls = exports.tradingCalls = exports.MarketConfigBcs = exports.MarketBcs = exports.OrderBcs = exports.PositionBcs = exports.TokenPoolDataBcs = exports.RedeemRequestDataBcs =
|
|
39
|
+
exports.TOKEN_DECIMALS = exports.COLLATERAL_DECIMALS = exports.WLP_DECIMALS = exports.SUI_DECIMALS = exports.MS_PER_YEAR = exports.STOCK_FEE_RATE = exports.STAKING_PERM_ALL = exports.STAKING_PERM_CLAIM_REWARD = exports.STAKING_PERM_REDEEM_STAKE = exports.STAKING_PERM_DEPOSIT_STAKE = exports.PERM_WITHDRAW_COLLATERAL = exports.PERM_REDEEM_WLP = exports.PERM_PLACE_ORDER = exports.PERM_OPEN_POSITION = exports.PERM_MINT_WLP = exports.PERM_INCREASE_POSITION = exports.PERM_DEPOSIT_COLLATERAL = exports.PERM_DECREASE_POSITION = exports.PERM_CLOSE_POSITION = exports.PERM_CANCEL_ORDER = exports.PERM_ALL_TRADING = exports.PERM_ALL = exports.ORDER_TAG_WILDCARD = exports.ORDER_STOP_SELL = exports.ORDER_STOP_BUY = exports.ORDER_LIMIT_SELL = exports.ORDER_LIMIT_BUY = exports.MAINTENANCE_MARGIN_RATE = exports.FLOAT_SCALE = exports.DRY_RUN_SENDER = exports.DOUBLE_SCALE = exports.CRYPTO_FEE_RATE = exports.BPS_SCALE = exports.ACTION_WITHDRAW_COLLATERAL = exports.ACTION_UPDATE_ORDER = exports.ACTION_PLACE_ORDER = exports.ACTION_OPEN_POSITION = exports.ACTION_LIQUIDATE = exports.ACTION_INCREASE_POSITION = exports.ACTION_DEPOSIT_COLLATERAL = exports.ACTION_DECREASE_POSITION = exports.ACTION_CLOSE_POSITION = exports.ACTION_CANCEL_PRE_ORDER = exports.ACTION_CANCEL_ORDER = exports.ACTION_ADD_PRE_ORDER = exports.loadConfig = exports.clearConfigCache = exports.WORMHOLE_DEFAULTS = exports.PYTH_DEFAULTS = exports.PerpClient = void 0;
|
|
40
|
+
exports.PositionDataBcs = exports.PoolDataBcs = exports.OrderDataBcs = exports.MarketDataBcs = exports.GlobalConfigDataBcs = exports.AccountDataBcs = exports.waitForVaa = exports.vaaBytesToBase64 = exports.vaaBase64ToHex = exports.vaaBase64ToBytes = exports.toWormholescanEmitter = exports.padEvmEmitter = exports.listVaasByEmitter = exports.listBridgeWithdrawalVaas = exports.fetchVaa = exports.fetchDepositVaa = exports.updatePythPrices = exports.refreshOraclePrices = exports.fetchPriceFeedsUpdateData = exports.buildPythPriceUpdateCalls = exports.aggregateTickerWithPyth = exports.aggregateTickerWithConstant = exports.aggregateTicker = exports.PythCache = exports.rawPrice = exports.decodeFundingIndexDelta = exports.calcWlpRedeemOut = exports.calcWlpPrice = exports.calcWlpMintOut = exports.calcWlpIncentiveApy = exports.calcUnrealizedPnl = exports.calcTotalTradingFeeRate = exports.calcTokenUtilizationBps = exports.calcPositionBorrowFee = exports.calcNotional = exports.calcMaxReducibleCollateralUsd = exports.calcLeverage = exports.calcImpactFeeRate = exports.calcFundingRate = exports.calcFundingFeeUsd = exports.calcFee = exports.calcEstLiqPrice = exports.calcEffectiveCollateralUsd = exports.calcDynamicFeeBps = exports.calcBorrowRateAccrual = exports.calcBorrowRate = exports.annualizeFundingRate = exports.annualizedApyFromRatio = exports.getCollateralAssets = exports.getMarketTickers = void 0;
|
|
41
|
+
exports.withdrawalQueueCalls = exports.nativeCustodyCalls = exports.referralCalls = exports.pythSponsorRuleCalls = exports.pythRuleCalls = exports.oracleCalls = exports.stakingCalls = exports.wxaAccountCalls = exports.viewCalls = exports.lpPoolCalls = exports.tradingCalls = exports.MarketConfigBcs = exports.MarketBcs = exports.OrderBcs = exports.PositionBcs = exports.TokenPoolDataBcs = exports.RedeemRequestDataBcs = void 0;
|
|
42
42
|
// ======== Core ========
|
|
43
43
|
var client_ts_1 = require("./client.js");
|
|
44
44
|
Object.defineProperty(exports, "PerpClient", { enumerable: true, get: function () { return client_ts_1.PerpClient; } });
|
|
@@ -46,7 +46,6 @@ var config_ts_1 = require("./config.js");
|
|
|
46
46
|
Object.defineProperty(exports, "PYTH_DEFAULTS", { enumerable: true, get: function () { return config_ts_1.PYTH_DEFAULTS; } });
|
|
47
47
|
Object.defineProperty(exports, "WORMHOLE_DEFAULTS", { enumerable: true, get: function () { return config_ts_1.WORMHOLE_DEFAULTS; } });
|
|
48
48
|
Object.defineProperty(exports, "clearConfigCache", { enumerable: true, get: function () { return config_ts_1.clearConfigCache; } });
|
|
49
|
-
Object.defineProperty(exports, "defaultConfigUrl", { enumerable: true, get: function () { return config_ts_1.defaultConfigUrl; } });
|
|
50
49
|
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return config_ts_1.loadConfig; } });
|
|
51
50
|
// ======== Constants & enums ========
|
|
52
51
|
var constants_ts_1 = require("./constants.js");
|
|
@@ -47,17 +47,12 @@ export interface WaterxPredictionConfig {
|
|
|
47
47
|
}
|
|
48
48
|
export interface LoadConfigOptions {
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
50
|
+
* Canonical `waterx-config` JSON URL to fetch, **as-is** (no `<network>.json`
|
|
51
|
+
* / git ref appended). Required — {@link loadConfig} reads the URL only from
|
|
52
|
+
* this option (there is no env-var fallback and no built-in default) and
|
|
53
|
+
* throws when it is unset.
|
|
52
54
|
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Pin the canonical config to a specific git ref — a commit SHA, branch, or
|
|
56
|
-
* tag — instead of the default `main` branch. Resolves to
|
|
57
|
-
* `https://raw.githubusercontent.com/WaterXProtocol/waterx-config/<ref>/<network>.json`.
|
|
58
|
-
* Ignored when {@link configUrl} is set.
|
|
59
|
-
*/
|
|
60
|
-
configRef?: string;
|
|
55
|
+
waterxConfigUrl?: string;
|
|
61
56
|
/** Reuse a previously fetched config in memory. Default: false. */
|
|
62
57
|
cache?: boolean;
|
|
63
58
|
/** Optional fetch implementation for tests or runtimes without global fetch. */
|
|
@@ -65,10 +60,5 @@ export interface LoadConfigOptions {
|
|
|
65
60
|
/** Request timeout in ms. Default: 10_000. */
|
|
66
61
|
timeoutMs?: number;
|
|
67
62
|
}
|
|
68
|
-
/**
|
|
69
|
-
* Build the canonical config URL for `network`, optionally pinned to a
|
|
70
|
-
* specific git `ref` (commit SHA, branch, or tag). Defaults to `main`.
|
|
71
|
-
*/
|
|
72
|
-
export declare function defaultConfigUrl(network: Network, ref?: string): string;
|
|
73
63
|
export declare function clearConfigCache(): void;
|
|
74
64
|
export declare function loadConfig(network: Network, opts?: LoadConfigOptions): Promise<WaterxPredictionConfig>;
|
|
@@ -6,25 +6,17 @@
|
|
|
6
6
|
* and fetches it from GitHub raw by default.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.defaultConfigUrl = defaultConfigUrl;
|
|
10
9
|
exports.clearConfigCache = clearConfigCache;
|
|
11
10
|
exports.loadConfig = loadConfig;
|
|
12
|
-
const CONFIG_REPO_RAW_BASE = "https://raw.githubusercontent.com/WaterXProtocol/waterx-config";
|
|
13
|
-
/** Default git ref for the canonical config when none is pinned. */
|
|
14
|
-
const DEFAULT_CONFIG_REF = "main";
|
|
15
|
-
/**
|
|
16
|
-
* Build the canonical config URL for `network`, optionally pinned to a
|
|
17
|
-
* specific git `ref` (commit SHA, branch, or tag). Defaults to `main`.
|
|
18
|
-
*/
|
|
19
|
-
function defaultConfigUrl(network, ref = DEFAULT_CONFIG_REF) {
|
|
20
|
-
return `${CONFIG_REPO_RAW_BASE}/${ref}/${network.toLowerCase()}.json`;
|
|
21
|
-
}
|
|
22
11
|
const configCache = new Map();
|
|
23
12
|
function clearConfigCache() {
|
|
24
13
|
configCache.clear();
|
|
25
14
|
}
|
|
26
15
|
async function loadConfig(network, opts = {}) {
|
|
27
|
-
const url = opts.
|
|
16
|
+
const url = opts.waterxConfigUrl;
|
|
17
|
+
if (!url) {
|
|
18
|
+
throw new Error("loadConfig: no config URL — pass opts.waterxConfigUrl");
|
|
19
|
+
}
|
|
28
20
|
if (opts.cache && configCache.has(url)) {
|
|
29
21
|
return configCache.get(url);
|
|
30
22
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PredictClient } from "./client.ts";
|
|
2
|
-
import type { AccountDataView, CursorView, MarketExposure, MarketIdInput, MarketView, OrderView, PositionView, RegistryView } from "./types.ts";
|
|
2
|
+
import type { AccountDataView, CursorView, MarketExposure, MarketIdInput, MarketPage, MarketView, OrderView, PageParams, PositionPage, PositionView, RegistryView } from "./types.ts";
|
|
3
3
|
export declare function extractReturnBytes(result: any, commandIndex?: number, returnIndex?: number): Uint8Array;
|
|
4
4
|
export interface ViewBaseParams {
|
|
5
5
|
packageId?: string;
|
|
@@ -30,6 +30,11 @@ export declare function getOrderCursor(client: PredictClient, params?: ViewBaseP
|
|
|
30
30
|
export declare function getPositionCursor(client: PredictClient, params?: ViewBaseParams): Promise<CursorView>;
|
|
31
31
|
export declare function getUnresolvedMarketCursor(client: PredictClient, params?: ViewBaseParams): Promise<CursorView>;
|
|
32
32
|
export declare function getResolvedMarketCursor(client: PredictClient, params?: ViewBaseParams): Promise<CursorView>;
|
|
33
|
+
/** Every unresolved (active) market in one call. Prefer `getUnresolvedMarketsPage` when the table is large. */
|
|
34
|
+
export declare function getUnresolvedMarkets(client: PredictClient, params?: ViewBaseParams): Promise<MarketView[]>;
|
|
35
|
+
export declare function getUnresolvedMarketsPage(client: PredictClient, params?: PageParams): Promise<MarketPage>;
|
|
36
|
+
export declare function getResolvedMarketsPage(client: PredictClient, params?: PageParams): Promise<MarketPage>;
|
|
37
|
+
export declare function getPositionsPage(client: PredictClient, params?: PageParams): Promise<PositionPage>;
|
|
33
38
|
export interface GetAccountIdsParams {
|
|
34
39
|
/** Wallet address that owns sub-accounts in the registry. */
|
|
35
40
|
owner: string;
|
|
@@ -12,6 +12,10 @@ exports.getOrderCursor = getOrderCursor;
|
|
|
12
12
|
exports.getPositionCursor = getPositionCursor;
|
|
13
13
|
exports.getUnresolvedMarketCursor = getUnresolvedMarketCursor;
|
|
14
14
|
exports.getResolvedMarketCursor = getResolvedMarketCursor;
|
|
15
|
+
exports.getUnresolvedMarkets = getUnresolvedMarkets;
|
|
16
|
+
exports.getUnresolvedMarketsPage = getUnresolvedMarketsPage;
|
|
17
|
+
exports.getResolvedMarketsPage = getResolvedMarketsPage;
|
|
18
|
+
exports.getPositionsPage = getPositionsPage;
|
|
15
19
|
exports.getAccountIds = getAccountIds;
|
|
16
20
|
exports.getAccountData = getAccountData;
|
|
17
21
|
exports.getAccountOrderIds = getAccountOrderIds;
|
|
@@ -149,6 +153,66 @@ function getUnresolvedMarketCursor(client, params = {}) {
|
|
|
149
153
|
function getResolvedMarketCursor(client, params = {}) {
|
|
150
154
|
return readCursor(client, "resolved_market_cursor", params);
|
|
151
155
|
}
|
|
156
|
+
const DEFAULT_PAGE_LIMIT = 100n;
|
|
157
|
+
/** Encode an optional cursor key as a Move `Option<u64>` pure arg (`undefined` → none / from front). */
|
|
158
|
+
function startArg(tx, start) {
|
|
159
|
+
return tx.pure(bcs_1.bcs.option(bcs_1.bcs.u64()).serialize(start === undefined ? null : (0, utils_ts_1.toBigInt)(start)));
|
|
160
|
+
}
|
|
161
|
+
/** Every unresolved (active) market in one call. Prefer `getUnresolvedMarketsPage` when the table is large. */
|
|
162
|
+
async function getUnresolvedMarkets(client, params = {}) {
|
|
163
|
+
const tx = new transactions_1.Transaction();
|
|
164
|
+
tx.moveCall({
|
|
165
|
+
target: `${(0, utils_ts_1.resolvePackageId)(client, params.packageId)}::view::unresolved_markets`,
|
|
166
|
+
typeArguments: [(0, utils_ts_1.resolveSettlementCoinType)(client, params.settlementCoinType)],
|
|
167
|
+
arguments: [tx.object((0, utils_ts_1.resolveMarketRegistry)(client, params.marketRegistry))],
|
|
168
|
+
});
|
|
169
|
+
const result = await client.simulate(tx);
|
|
170
|
+
return bcs_1.bcs.vector(bcs_ts_1.MarketViewBcs).parse(extractReturnBytes(result)).map(bcs_ts_1.mapMarketView);
|
|
171
|
+
}
|
|
172
|
+
async function readMarketsPage(client, functionName, params = {}) {
|
|
173
|
+
const tx = new transactions_1.Transaction();
|
|
174
|
+
tx.moveCall({
|
|
175
|
+
target: `${(0, utils_ts_1.resolvePackageId)(client, params.packageId)}::view::${functionName}`,
|
|
176
|
+
typeArguments: [(0, utils_ts_1.resolveSettlementCoinType)(client, params.settlementCoinType)],
|
|
177
|
+
arguments: [
|
|
178
|
+
tx.object((0, utils_ts_1.resolveMarketRegistry)(client, params.marketRegistry)),
|
|
179
|
+
startArg(tx, params.start),
|
|
180
|
+
tx.pure.u64(params.limit === undefined ? DEFAULT_PAGE_LIMIT : (0, utils_ts_1.toBigInt)(params.limit)),
|
|
181
|
+
],
|
|
182
|
+
});
|
|
183
|
+
const result = await client.simulate(tx);
|
|
184
|
+
const markets = bcs_1.bcs
|
|
185
|
+
.vector(bcs_ts_1.MarketViewBcs)
|
|
186
|
+
.parse(extractReturnBytes(result, 0, 0))
|
|
187
|
+
.map(bcs_ts_1.mapMarketView);
|
|
188
|
+
const next = bcs_1.bcs.option(bcs_1.bcs.u64()).parse(extractReturnBytes(result, 0, 1));
|
|
189
|
+
return { markets, nextCursor: next == null ? null : BigInt(next) };
|
|
190
|
+
}
|
|
191
|
+
function getUnresolvedMarketsPage(client, params = {}) {
|
|
192
|
+
return readMarketsPage(client, "unresolved_markets_page", params);
|
|
193
|
+
}
|
|
194
|
+
function getResolvedMarketsPage(client, params = {}) {
|
|
195
|
+
return readMarketsPage(client, "resolved_markets_page", params);
|
|
196
|
+
}
|
|
197
|
+
async function getPositionsPage(client, params = {}) {
|
|
198
|
+
const tx = new transactions_1.Transaction();
|
|
199
|
+
tx.moveCall({
|
|
200
|
+
target: `${(0, utils_ts_1.resolvePackageId)(client, params.packageId)}::view::positions_page`,
|
|
201
|
+
typeArguments: [(0, utils_ts_1.resolveSettlementCoinType)(client, params.settlementCoinType)],
|
|
202
|
+
arguments: [
|
|
203
|
+
tx.object((0, utils_ts_1.resolveMarketRegistry)(client, params.marketRegistry)),
|
|
204
|
+
startArg(tx, params.start),
|
|
205
|
+
tx.pure.u64(params.limit === undefined ? DEFAULT_PAGE_LIMIT : (0, utils_ts_1.toBigInt)(params.limit)),
|
|
206
|
+
],
|
|
207
|
+
});
|
|
208
|
+
const result = await client.simulate(tx);
|
|
209
|
+
const positions = bcs_1.bcs
|
|
210
|
+
.vector(bcs_ts_1.PositionViewBcs)
|
|
211
|
+
.parse(extractReturnBytes(result, 0, 0))
|
|
212
|
+
.map(bcs_ts_1.mapPositionView);
|
|
213
|
+
const next = bcs_1.bcs.option(bcs_1.bcs.u64()).parse(extractReturnBytes(result, 0, 1));
|
|
214
|
+
return { positions, nextCursor: next == null ? null : BigInt(next) };
|
|
215
|
+
}
|
|
152
216
|
/**
|
|
153
217
|
* Registry account ids (`0x2::object::ID`) for an owner via `waterx_account::account::account_ids`.
|
|
154
218
|
* Use these ids with `getAccountData`, `deposit`, and `placeOrder` — not Suiscan "Account" object addresses.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { PredictClient } from "./client.ts";
|
|
2
2
|
export type { CreateClientOptions } from "./client.ts";
|
|
3
|
-
export { clearConfigCache,
|
|
3
|
+
export { clearConfigCache, loadConfig } from "./config.ts";
|
|
4
4
|
export type { LoadConfigOptions, WaterxAccountPackage, WaterxConfigPackageBase, WaterxPredictionConfig, WaterxPredictionConfigPackages, WaterxPredictionGiftPackage, WaterxPredictionPackage, WaterxReferralPackage, } from "./config.ts";
|
|
5
5
|
export * from "./constants.ts";
|
|
6
6
|
export * from "./types.ts";
|
|
@@ -14,7 +14,7 @@ export { adminPlaceOrderFor, batchClaim, batchForceClaim, buildBatchForceClaimTr
|
|
|
14
14
|
export type { AdminPlaceOrderForParams, BatchClaimParams, BatchForceClaimParams, BuildBatchForceClaimTransactionsParams, CancelCloseParams, CancelOrderParams, ClaimParams, ConfirmCloseParams, FillOrderParams, ForceClaimParams, PlaceOrderParams, RequestCloseParams, RequestPartialCloseParams, ResolveMarketParams, SelfCancelCloseParams, SelfCancelOrderParams, SplitPositionParams, TransferPositionParams, } from "./prediction.ts";
|
|
15
15
|
export { buildBatchClaimTx, buildPlaceOrderTx } from "./tx-builders.ts";
|
|
16
16
|
export type { BuildBatchClaimTxParams, BuildPlaceOrderTxParams, PredictCommonBuildOpts, } from "./tx-builders.ts";
|
|
17
|
-
export { getAccountData, getAccountIds, getAccountOrderIds, getAccountOrderIdsByMarketId, getAccountPositionIds, getAccountPositionIdsByMarketId, getKeeperAddresses, getAllowedVersions, getMarketExposure, getMarketExposureByKey, getMarketById, getMarketByKey, getOrder, getOrderCursor, getPosition, getPositionCursor, getRegistry, getResolvedMarketCursor, getUnresolvedMarketCursor, isKeeper, isPredictionProtocolAssetAllowed, } from "./fetch.ts";
|
|
17
|
+
export { getAccountData, getAccountIds, getAccountOrderIds, getAccountOrderIdsByMarketId, getAccountPositionIds, getAccountPositionIdsByMarketId, getKeeperAddresses, getAllowedVersions, getMarketExposure, getMarketExposureByKey, getMarketById, getMarketByKey, getOrder, getOrderCursor, getPosition, getPositionCursor, getPositionsPage, getRegistry, getResolvedMarketCursor, getResolvedMarketsPage, getUnresolvedMarketCursor, getUnresolvedMarkets, getUnresolvedMarketsPage, isKeeper, isPredictionProtocolAssetAllowed, } from "./fetch.ts";
|
|
18
18
|
export type { GetAccountIdsParams, ViewBaseParams } from "./fetch.ts";
|
|
19
19
|
export { base64UrlNoPadDecode, base64UrlNoPadEncode, buildClaimShareFlow, buildCreateGiftFlow, buildGiftClaimMessage, claimShare, createGift, deleteGift, deriveGiftAddress, deriveGiftKeypair, encodeGiftUrl, generateGiftSeed, getCreatorGiftCount, getCreatorGiftIds, getGift, getGiftConfigPaused, getGiftControllerAddress, getGiftHasClaimed, parseGiftUrl, signGiftClaim, } from "./gift.ts";
|
|
20
20
|
export type { BuildClaimShareFlowParams, BuildClaimShareFlowResult, BuildCreateGiftFlowResult, ClaimShareParams, CreateGiftParams, DeleteGiftParams, GiftBaseParams, GiftReferralParams, GiftUrlParts, GiftView, } from "./gift.ts";
|
|
@@ -36,14 +36,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.splitPosition = exports.selfCancelOrder = exports.selfCancelClose = exports.selectionArg = exports.resolveMarket = exports.requestPartialClose = exports.requestClose = exports.placeOrder = exports.outcomeArg = exports.forceClaim = exports.fillOrder = exports.confirmClose = exports.claim = exports.cancelOrder = exports.cancelClose = exports.buildBatchForceClaimTransactions = exports.batchForceClaim = exports.batchClaim = exports.adminPlaceOrderFor = exports.unpauseMarket = exports.setOrderCancelCooldownMs = exports.setMinReserve = exports.removeKeeper = exports.pauseMarket = exports.depositSettlement = exports.createMarketRegistry = exports.adminWithdraw = exports.addKeeper = exports.withdraw = exports.whitelistPredictionProtocol = exports.transferCoinToAccount = exports.setDelegatePredictionPermission = exports.requestWithdraw = exports.requestDepositFromReceivings = exports.requestDeposit = exports.resolveRegistryAccountId = exports.removeDelegate = exports.disallowPredictionProtocolAsset = exports.deposit = exports.createAccount = exports.consumeWithdrawDirect = exports.consumeDepositDirect = exports.allowPredictionProtocolAsset = exports.addDelegate = exports.utils = exports.user = exports.loadConfig = exports.
|
|
40
|
-
exports.
|
|
41
|
-
exports.predictionCalls = exports.predictionViewCalls = exports.predictionVersionCalls = void 0;
|
|
39
|
+
exports.transferPosition = exports.splitPosition = exports.selfCancelOrder = exports.selfCancelClose = exports.selectionArg = exports.resolveMarket = exports.requestPartialClose = exports.requestClose = exports.placeOrder = exports.outcomeArg = exports.forceClaim = exports.fillOrder = exports.confirmClose = exports.claim = exports.cancelOrder = exports.cancelClose = exports.buildBatchForceClaimTransactions = exports.batchForceClaim = exports.batchClaim = exports.adminPlaceOrderFor = exports.unpauseMarket = exports.setOrderCancelCooldownMs = exports.setMinReserve = exports.removeKeeper = exports.pauseMarket = exports.depositSettlement = exports.createMarketRegistry = exports.adminWithdraw = exports.addKeeper = exports.withdraw = exports.whitelistPredictionProtocol = exports.transferCoinToAccount = exports.setDelegatePredictionPermission = exports.requestWithdraw = exports.requestDepositFromReceivings = exports.requestDeposit = exports.resolveRegistryAccountId = exports.removeDelegate = exports.disallowPredictionProtocolAsset = exports.deposit = exports.createAccount = exports.consumeWithdrawDirect = exports.consumeDepositDirect = exports.allowPredictionProtocolAsset = exports.addDelegate = exports.utils = exports.user = exports.loadConfig = exports.clearConfigCache = exports.PredictClient = void 0;
|
|
40
|
+
exports.predictionAccountDataCalls = exports.waterxAccountCalls = exports.bucketFrameworkAccountCalls = exports.signGiftClaim = exports.parseGiftUrl = exports.getGiftHasClaimed = exports.getGiftControllerAddress = exports.getGiftConfigPaused = exports.getGift = exports.getCreatorGiftIds = exports.getCreatorGiftCount = exports.generateGiftSeed = exports.encodeGiftUrl = exports.deriveGiftKeypair = exports.deriveGiftAddress = exports.deleteGift = exports.createGift = exports.claimShare = exports.buildGiftClaimMessage = exports.buildCreateGiftFlow = exports.buildClaimShareFlow = exports.base64UrlNoPadEncode = exports.base64UrlNoPadDecode = exports.isPredictionProtocolAssetAllowed = exports.isKeeper = exports.getUnresolvedMarketsPage = exports.getUnresolvedMarkets = exports.getUnresolvedMarketCursor = exports.getResolvedMarketsPage = exports.getResolvedMarketCursor = exports.getRegistry = exports.getPositionsPage = exports.getPositionCursor = exports.getPosition = exports.getOrderCursor = exports.getOrder = exports.getMarketByKey = exports.getMarketById = exports.getMarketExposureByKey = exports.getMarketExposure = exports.getAllowedVersions = exports.getKeeperAddresses = exports.getAccountPositionIdsByMarketId = exports.getAccountPositionIds = exports.getAccountOrderIdsByMarketId = exports.getAccountOrderIds = exports.getAccountIds = exports.getAccountData = exports.buildPlaceOrderTx = exports.buildBatchClaimTx = void 0;
|
|
41
|
+
exports.predictionCalls = exports.predictionViewCalls = exports.predictionVersionCalls = exports.predictionPositionCalls = exports.predictionOutcomeCalls = exports.predictionGlobalConfigCalls = void 0;
|
|
42
42
|
var client_ts_1 = require("./client.js");
|
|
43
43
|
Object.defineProperty(exports, "PredictClient", { enumerable: true, get: function () { return client_ts_1.PredictClient; } });
|
|
44
44
|
var config_ts_1 = require("./config.js");
|
|
45
45
|
Object.defineProperty(exports, "clearConfigCache", { enumerable: true, get: function () { return config_ts_1.clearConfigCache; } });
|
|
46
|
-
Object.defineProperty(exports, "defaultConfigUrl", { enumerable: true, get: function () { return config_ts_1.defaultConfigUrl; } });
|
|
47
46
|
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return config_ts_1.loadConfig; } });
|
|
48
47
|
__exportStar(require("./constants.js"), exports);
|
|
49
48
|
__exportStar(require("./types.js"), exports);
|
|
@@ -117,9 +116,13 @@ Object.defineProperty(exports, "getOrder", { enumerable: true, get: function ()
|
|
|
117
116
|
Object.defineProperty(exports, "getOrderCursor", { enumerable: true, get: function () { return fetch_ts_1.getOrderCursor; } });
|
|
118
117
|
Object.defineProperty(exports, "getPosition", { enumerable: true, get: function () { return fetch_ts_1.getPosition; } });
|
|
119
118
|
Object.defineProperty(exports, "getPositionCursor", { enumerable: true, get: function () { return fetch_ts_1.getPositionCursor; } });
|
|
119
|
+
Object.defineProperty(exports, "getPositionsPage", { enumerable: true, get: function () { return fetch_ts_1.getPositionsPage; } });
|
|
120
120
|
Object.defineProperty(exports, "getRegistry", { enumerable: true, get: function () { return fetch_ts_1.getRegistry; } });
|
|
121
121
|
Object.defineProperty(exports, "getResolvedMarketCursor", { enumerable: true, get: function () { return fetch_ts_1.getResolvedMarketCursor; } });
|
|
122
|
+
Object.defineProperty(exports, "getResolvedMarketsPage", { enumerable: true, get: function () { return fetch_ts_1.getResolvedMarketsPage; } });
|
|
122
123
|
Object.defineProperty(exports, "getUnresolvedMarketCursor", { enumerable: true, get: function () { return fetch_ts_1.getUnresolvedMarketCursor; } });
|
|
124
|
+
Object.defineProperty(exports, "getUnresolvedMarkets", { enumerable: true, get: function () { return fetch_ts_1.getUnresolvedMarkets; } });
|
|
125
|
+
Object.defineProperty(exports, "getUnresolvedMarketsPage", { enumerable: true, get: function () { return fetch_ts_1.getUnresolvedMarketsPage; } });
|
|
123
126
|
Object.defineProperty(exports, "isKeeper", { enumerable: true, get: function () { return fetch_ts_1.isKeeper; } });
|
|
124
127
|
Object.defineProperty(exports, "isPredictionProtocolAssetAllowed", { enumerable: true, get: function () { return fetch_ts_1.isPredictionProtocolAssetAllowed; } });
|
|
125
128
|
var gift_ts_1 = require("./gift.js");
|
|
@@ -88,6 +88,25 @@ export interface CursorView {
|
|
|
88
88
|
front: bigint | null;
|
|
89
89
|
back: bigint | null;
|
|
90
90
|
}
|
|
91
|
+
export interface PageParams {
|
|
92
|
+
packageId?: string;
|
|
93
|
+
marketRegistry?: string;
|
|
94
|
+
settlementCoinType?: string;
|
|
95
|
+
/** Cursor key to resume from; omit to start at the front of the table. */
|
|
96
|
+
start?: bigint | number | string;
|
|
97
|
+
/** Max entries in this page (default 100). */
|
|
98
|
+
limit?: bigint | number | string;
|
|
99
|
+
}
|
|
100
|
+
export interface MarketPage {
|
|
101
|
+
markets: MarketView[];
|
|
102
|
+
/** Pass as `start` for the next page; `null` when the table is exhausted. */
|
|
103
|
+
nextCursor: bigint | null;
|
|
104
|
+
}
|
|
105
|
+
export interface PositionPage {
|
|
106
|
+
positions: PositionView[];
|
|
107
|
+
/** Pass as `start` for the next page; `null` when the table is exhausted. */
|
|
108
|
+
nextCursor: bigint | null;
|
|
109
|
+
}
|
|
91
110
|
export interface CoinRef {
|
|
92
111
|
objectId: string;
|
|
93
112
|
version: string | bigint | number;
|
|
@@ -263,6 +263,10 @@ declare const predictOps: {
|
|
|
263
263
|
getPositionCursor(client: PredictClient, params?: predFetch.ViewBaseParams): Promise<import("./prediction/types.ts").CursorView>;
|
|
264
264
|
getUnresolvedMarketCursor(client: PredictClient, params?: predFetch.ViewBaseParams): Promise<import("./prediction/types.ts").CursorView>;
|
|
265
265
|
getResolvedMarketCursor(client: PredictClient, params?: predFetch.ViewBaseParams): Promise<import("./prediction/types.ts").CursorView>;
|
|
266
|
+
getUnresolvedMarkets(client: PredictClient, params?: predFetch.ViewBaseParams): Promise<import("./prediction/types.ts").MarketView[]>;
|
|
267
|
+
getUnresolvedMarketsPage(client: PredictClient, params?: import("./prediction/types.ts").PageParams): Promise<import("./prediction/types.ts").MarketPage>;
|
|
268
|
+
getResolvedMarketsPage(client: PredictClient, params?: import("./prediction/types.ts").PageParams): Promise<import("./prediction/types.ts").MarketPage>;
|
|
269
|
+
getPositionsPage(client: PredictClient, params?: import("./prediction/types.ts").PageParams): Promise<import("./prediction/types.ts").PositionPage>;
|
|
266
270
|
getAccountIds(client: PredictClient, params: predFetch.GetAccountIdsParams): Promise<string[]>;
|
|
267
271
|
getAccountData(client: PredictClient, params: predFetch.ViewBaseParams & {
|
|
268
272
|
accountId: string;
|
|
@@ -354,13 +358,14 @@ export interface ClientCreateOptions {
|
|
|
354
358
|
network?: Network;
|
|
355
359
|
/** Default gRPC URL for both lines. */
|
|
356
360
|
grpcUrl?: string;
|
|
357
|
-
/** Default `waterx-config` JSON URL for both lines.
|
|
358
|
-
|
|
361
|
+
/** Default `waterx-config` JSON URL for both lines (fetched as-is). Required
|
|
362
|
+
* unless supplied per-line via `perp` / `predict`. */
|
|
363
|
+
waterxConfigUrl?: string;
|
|
359
364
|
/** Memoize the fetched config JSON. */
|
|
360
365
|
cache?: boolean;
|
|
361
|
-
/** Perp-line overrides (network, grpcUrl,
|
|
366
|
+
/** Perp-line overrides (network, grpcUrl, waterxConfigUrl, cache, …). */
|
|
362
367
|
perp?: PerpLineOptions;
|
|
363
|
-
/** Prediction-line overrides (network, grpcUrl,
|
|
368
|
+
/** Prediction-line overrides (network, grpcUrl, waterxConfigUrl, cache, settlement, …). */
|
|
364
369
|
predict?: PredictLineOptions;
|
|
365
370
|
}
|
|
366
371
|
export declare class WaterXClient {
|
|
@@ -202,13 +202,13 @@ class WaterXClient {
|
|
|
202
202
|
}
|
|
203
203
|
const perpClient = await client_ts_1.PerpClient.create(resolvedPerpNetwork, {
|
|
204
204
|
grpcUrl: opts.grpcUrl,
|
|
205
|
-
|
|
205
|
+
waterxConfigUrl: opts.waterxConfigUrl,
|
|
206
206
|
cache: opts.cache,
|
|
207
207
|
...perpRest,
|
|
208
208
|
});
|
|
209
209
|
const predictClient = await client_ts_2.PredictClient.create(resolvedPredictNetwork, {
|
|
210
210
|
grpcUrl: opts.grpcUrl,
|
|
211
|
-
|
|
211
|
+
waterxConfigUrl: opts.waterxConfigUrl,
|
|
212
212
|
cache: opts.cache,
|
|
213
213
|
...predictRest,
|
|
214
214
|
});
|
|
@@ -95,18 +95,13 @@ export interface WaterXConfig {
|
|
|
95
95
|
}
|
|
96
96
|
export interface LoadConfigOptions {
|
|
97
97
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
98
|
+
* Canonical `waterx-config` JSON URL to fetch, **as-is** (no `<network>.json`
|
|
99
|
+
* / git ref appended). Required — {@link loadConfig} reads the URL only from
|
|
100
|
+
* this option (there is no env-var fallback and no built-in default) and
|
|
101
|
+
* throws when it is unset. Point it at a staging deployment or local mirror
|
|
102
|
+
* as needed.
|
|
101
103
|
*/
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Pin the canonical config to a specific git ref — a commit SHA, branch,
|
|
105
|
-
* or tag — instead of the default `main` branch. Resolves to
|
|
106
|
-
* `https://raw.githubusercontent.com/WaterXProtocol/waterx-config/<ref>/<network>.json`.
|
|
107
|
-
* Ignored when {@link configUrl} is set.
|
|
108
|
-
*/
|
|
109
|
-
configRef?: string;
|
|
104
|
+
waterxConfigUrl?: string;
|
|
110
105
|
/**
|
|
111
106
|
* Reuse a previously-fetched config from the in-memory cache (keyed by
|
|
112
107
|
* the effective URL). Default: false (always fetch fresh).
|
|
@@ -117,10 +112,5 @@ export interface LoadConfigOptions {
|
|
|
117
112
|
/** Optional request timeout in ms. Default 10_000. */
|
|
118
113
|
timeoutMs?: number;
|
|
119
114
|
}
|
|
120
|
-
/**
|
|
121
|
-
* Build the canonical config URL for `network`, optionally pinned to a
|
|
122
|
-
* specific git `ref` (commit SHA, branch, or tag). Defaults to `main`.
|
|
123
|
-
*/
|
|
124
|
-
export declare function defaultConfigUrl(network: Network, ref?: string): string;
|
|
125
115
|
export declare function clearConfigCache(): void;
|
|
126
116
|
export declare function loadConfig(network: Network, opts?: LoadConfigOptions): Promise<WaterXConfig>;
|
package/dist/src/perp/config.js
CHANGED
|
@@ -33,22 +33,15 @@ export const WORMHOLE_DEFAULTS = {
|
|
|
33
33
|
wormholescan_api: "https://api.testnet.wormholescan.io/api/v1",
|
|
34
34
|
},
|
|
35
35
|
};
|
|
36
|
-
const CONFIG_REPO_RAW_BASE = "https://raw.githubusercontent.com/WaterXProtocol/waterx-config";
|
|
37
|
-
/** Default git ref for the canonical config when none is pinned. */
|
|
38
|
-
const DEFAULT_CONFIG_REF = "main";
|
|
39
|
-
/**
|
|
40
|
-
* Build the canonical config URL for `network`, optionally pinned to a
|
|
41
|
-
* specific git `ref` (commit SHA, branch, or tag). Defaults to `main`.
|
|
42
|
-
*/
|
|
43
|
-
export function defaultConfigUrl(network, ref = DEFAULT_CONFIG_REF) {
|
|
44
|
-
return `${CONFIG_REPO_RAW_BASE}/${ref}/${network.toLowerCase()}.json`;
|
|
45
|
-
}
|
|
46
36
|
const cache = new Map();
|
|
47
37
|
export function clearConfigCache() {
|
|
48
38
|
cache.clear();
|
|
49
39
|
}
|
|
50
40
|
export async function loadConfig(network, opts = {}) {
|
|
51
|
-
const url = opts.
|
|
41
|
+
const url = opts.waterxConfigUrl;
|
|
42
|
+
if (!url) {
|
|
43
|
+
throw new Error("loadConfig: no config URL — pass opts.waterxConfigUrl");
|
|
44
|
+
}
|
|
52
45
|
if (opts.cache && cache.has(url)) {
|
|
53
46
|
return cache.get(url);
|
|
54
47
|
}
|
package/dist/src/perp/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { PerpClient } from "./client.ts";
|
|
2
2
|
export type { CreateClientOptions } from "./client.ts";
|
|
3
|
-
export { PYTH_DEFAULTS, WORMHOLE_DEFAULTS, clearConfigCache,
|
|
3
|
+
export { PYTH_DEFAULTS, WORMHOLE_DEFAULTS, clearConfigCache, loadConfig } from "./config.ts";
|
|
4
4
|
export type { BasePackageEntry, ConstantFeedEntry, WaterxReferralPackage, LoadConfigOptions, NativeCustodyAsset, NativeCustodyPackage, PythInfraConfig, PythRulePackage, PythSponsorRulePackage, SupraFeedEntry, SupraRulePackage, TestnetFaucetPackage, TrustedEmitterRow, WaterXConfig, WaterXPackages, WaterxCreditPackage, WaterxOraclePackage, WaterxPerpMarketEntry, WaterxPerpPackage, WaterxStakingPackage, WithdrawalQueuePackage, WlpPackage, WormholeBridgePackage, WormholeInfraConfig, WxaAccountPackage, } from "./config.ts";
|
|
5
5
|
export { ACTION_ADD_PRE_ORDER, ACTION_CANCEL_ORDER, ACTION_CANCEL_PRE_ORDER, ACTION_CLOSE_POSITION, ACTION_DECREASE_POSITION, ACTION_DEPOSIT_COLLATERAL, ACTION_INCREASE_POSITION, ACTION_LIQUIDATE, ACTION_OPEN_POSITION, ACTION_PLACE_ORDER, ACTION_UPDATE_ORDER, ACTION_WITHDRAW_COLLATERAL, BPS_SCALE, CRYPTO_FEE_RATE, DOUBLE_SCALE, DRY_RUN_SENDER, FLOAT_SCALE, MAINTENANCE_MARGIN_RATE, ORDER_LIMIT_BUY, ORDER_LIMIT_SELL, ORDER_STOP_BUY, ORDER_STOP_SELL, ORDER_TAG_WILDCARD, PERM_ALL, PERM_ALL_TRADING, PERM_CANCEL_ORDER, PERM_CLOSE_POSITION, PERM_DECREASE_POSITION, PERM_DEPOSIT_COLLATERAL, PERM_INCREASE_POSITION, PERM_MINT_WLP, PERM_OPEN_POSITION, PERM_PLACE_ORDER, PERM_REDEEM_WLP, PERM_WITHDRAW_COLLATERAL, STAKING_PERM_DEPOSIT_STAKE, STAKING_PERM_REDEEM_STAKE, STAKING_PERM_CLAIM_REWARD, STAKING_PERM_ALL, STOCK_FEE_RATE, MS_PER_YEAR, SUI_DECIMALS, WLP_DECIMALS, COLLATERAL_DECIMALS, TOKEN_DECIMALS, } from "./constants.ts";
|
|
6
6
|
export type { Network } from "./constants.ts";
|
package/dist/src/perp/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// ======== Core ========
|
|
2
2
|
export { PerpClient } from "./client.js";
|
|
3
|
-
export { PYTH_DEFAULTS, WORMHOLE_DEFAULTS, clearConfigCache,
|
|
3
|
+
export { PYTH_DEFAULTS, WORMHOLE_DEFAULTS, clearConfigCache, loadConfig } from "./config.js";
|
|
4
4
|
// ======== Constants & enums ========
|
|
5
5
|
export { ACTION_ADD_PRE_ORDER, ACTION_CANCEL_ORDER, ACTION_CANCEL_PRE_ORDER, ACTION_CLOSE_POSITION, ACTION_DECREASE_POSITION, ACTION_DEPOSIT_COLLATERAL, ACTION_INCREASE_POSITION, ACTION_LIQUIDATE, ACTION_OPEN_POSITION, ACTION_PLACE_ORDER, ACTION_UPDATE_ORDER, ACTION_WITHDRAW_COLLATERAL, BPS_SCALE, CRYPTO_FEE_RATE, DOUBLE_SCALE, DRY_RUN_SENDER, FLOAT_SCALE, MAINTENANCE_MARGIN_RATE, ORDER_LIMIT_BUY, ORDER_LIMIT_SELL, ORDER_STOP_BUY, ORDER_STOP_SELL, ORDER_TAG_WILDCARD, PERM_ALL, PERM_ALL_TRADING, PERM_CANCEL_ORDER, PERM_CLOSE_POSITION, PERM_DECREASE_POSITION, PERM_DEPOSIT_COLLATERAL, PERM_INCREASE_POSITION, PERM_MINT_WLP, PERM_OPEN_POSITION, PERM_PLACE_ORDER, PERM_REDEEM_WLP, PERM_WITHDRAW_COLLATERAL, STAKING_PERM_DEPOSIT_STAKE, STAKING_PERM_REDEEM_STAKE, STAKING_PERM_CLAIM_REWARD, STAKING_PERM_ALL, STOCK_FEE_RATE, MS_PER_YEAR, SUI_DECIMALS, WLP_DECIMALS, COLLATERAL_DECIMALS, TOKEN_DECIMALS, } from "./constants.js";
|
|
6
6
|
// ======== Utilities ========
|
|
@@ -47,17 +47,12 @@ export interface WaterxPredictionConfig {
|
|
|
47
47
|
}
|
|
48
48
|
export interface LoadConfigOptions {
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
50
|
+
* Canonical `waterx-config` JSON URL to fetch, **as-is** (no `<network>.json`
|
|
51
|
+
* / git ref appended). Required — {@link loadConfig} reads the URL only from
|
|
52
|
+
* this option (there is no env-var fallback and no built-in default) and
|
|
53
|
+
* throws when it is unset.
|
|
52
54
|
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Pin the canonical config to a specific git ref — a commit SHA, branch, or
|
|
56
|
-
* tag — instead of the default `main` branch. Resolves to
|
|
57
|
-
* `https://raw.githubusercontent.com/WaterXProtocol/waterx-config/<ref>/<network>.json`.
|
|
58
|
-
* Ignored when {@link configUrl} is set.
|
|
59
|
-
*/
|
|
60
|
-
configRef?: string;
|
|
55
|
+
waterxConfigUrl?: string;
|
|
61
56
|
/** Reuse a previously fetched config in memory. Default: false. */
|
|
62
57
|
cache?: boolean;
|
|
63
58
|
/** Optional fetch implementation for tests or runtimes without global fetch. */
|
|
@@ -65,10 +60,5 @@ export interface LoadConfigOptions {
|
|
|
65
60
|
/** Request timeout in ms. Default: 10_000. */
|
|
66
61
|
timeoutMs?: number;
|
|
67
62
|
}
|
|
68
|
-
/**
|
|
69
|
-
* Build the canonical config URL for `network`, optionally pinned to a
|
|
70
|
-
* specific git `ref` (commit SHA, branch, or tag). Defaults to `main`.
|
|
71
|
-
*/
|
|
72
|
-
export declare function defaultConfigUrl(network: Network, ref?: string): string;
|
|
73
63
|
export declare function clearConfigCache(): void;
|
|
74
64
|
export declare function loadConfig(network: Network, opts?: LoadConfigOptions): Promise<WaterxPredictionConfig>;
|
|
@@ -4,22 +4,15 @@
|
|
|
4
4
|
* Mirrors the canonical `waterx-config` JSON for the packages used by this SDK
|
|
5
5
|
* and fetches it from GitHub raw by default.
|
|
6
6
|
*/
|
|
7
|
-
const CONFIG_REPO_RAW_BASE = "https://raw.githubusercontent.com/WaterXProtocol/waterx-config";
|
|
8
|
-
/** Default git ref for the canonical config when none is pinned. */
|
|
9
|
-
const DEFAULT_CONFIG_REF = "main";
|
|
10
|
-
/**
|
|
11
|
-
* Build the canonical config URL for `network`, optionally pinned to a
|
|
12
|
-
* specific git `ref` (commit SHA, branch, or tag). Defaults to `main`.
|
|
13
|
-
*/
|
|
14
|
-
export function defaultConfigUrl(network, ref = DEFAULT_CONFIG_REF) {
|
|
15
|
-
return `${CONFIG_REPO_RAW_BASE}/${ref}/${network.toLowerCase()}.json`;
|
|
16
|
-
}
|
|
17
7
|
const configCache = new Map();
|
|
18
8
|
export function clearConfigCache() {
|
|
19
9
|
configCache.clear();
|
|
20
10
|
}
|
|
21
11
|
export async function loadConfig(network, opts = {}) {
|
|
22
|
-
const url = opts.
|
|
12
|
+
const url = opts.waterxConfigUrl;
|
|
13
|
+
if (!url) {
|
|
14
|
+
throw new Error("loadConfig: no config URL — pass opts.waterxConfigUrl");
|
|
15
|
+
}
|
|
23
16
|
if (opts.cache && configCache.has(url)) {
|
|
24
17
|
return configCache.get(url);
|
|
25
18
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PredictClient } from "./client.ts";
|
|
2
|
-
import type { AccountDataView, CursorView, MarketExposure, MarketIdInput, MarketView, OrderView, PositionView, RegistryView } from "./types.ts";
|
|
2
|
+
import type { AccountDataView, CursorView, MarketExposure, MarketIdInput, MarketPage, MarketView, OrderView, PageParams, PositionPage, PositionView, RegistryView } from "./types.ts";
|
|
3
3
|
export declare function extractReturnBytes(result: any, commandIndex?: number, returnIndex?: number): Uint8Array;
|
|
4
4
|
export interface ViewBaseParams {
|
|
5
5
|
packageId?: string;
|
|
@@ -30,6 +30,11 @@ export declare function getOrderCursor(client: PredictClient, params?: ViewBaseP
|
|
|
30
30
|
export declare function getPositionCursor(client: PredictClient, params?: ViewBaseParams): Promise<CursorView>;
|
|
31
31
|
export declare function getUnresolvedMarketCursor(client: PredictClient, params?: ViewBaseParams): Promise<CursorView>;
|
|
32
32
|
export declare function getResolvedMarketCursor(client: PredictClient, params?: ViewBaseParams): Promise<CursorView>;
|
|
33
|
+
/** Every unresolved (active) market in one call. Prefer `getUnresolvedMarketsPage` when the table is large. */
|
|
34
|
+
export declare function getUnresolvedMarkets(client: PredictClient, params?: ViewBaseParams): Promise<MarketView[]>;
|
|
35
|
+
export declare function getUnresolvedMarketsPage(client: PredictClient, params?: PageParams): Promise<MarketPage>;
|
|
36
|
+
export declare function getResolvedMarketsPage(client: PredictClient, params?: PageParams): Promise<MarketPage>;
|
|
37
|
+
export declare function getPositionsPage(client: PredictClient, params?: PageParams): Promise<PositionPage>;
|
|
33
38
|
export interface GetAccountIdsParams {
|
|
34
39
|
/** Wallet address that owns sub-accounts in the registry. */
|
|
35
40
|
owner: string;
|
|
@@ -125,6 +125,66 @@ export function getUnresolvedMarketCursor(client, params = {}) {
|
|
|
125
125
|
export function getResolvedMarketCursor(client, params = {}) {
|
|
126
126
|
return readCursor(client, "resolved_market_cursor", params);
|
|
127
127
|
}
|
|
128
|
+
const DEFAULT_PAGE_LIMIT = 100n;
|
|
129
|
+
/** Encode an optional cursor key as a Move `Option<u64>` pure arg (`undefined` → none / from front). */
|
|
130
|
+
function startArg(tx, start) {
|
|
131
|
+
return tx.pure(bcs.option(bcs.u64()).serialize(start === undefined ? null : toBigInt(start)));
|
|
132
|
+
}
|
|
133
|
+
/** Every unresolved (active) market in one call. Prefer `getUnresolvedMarketsPage` when the table is large. */
|
|
134
|
+
export async function getUnresolvedMarkets(client, params = {}) {
|
|
135
|
+
const tx = new Transaction();
|
|
136
|
+
tx.moveCall({
|
|
137
|
+
target: `${resolvePackageId(client, params.packageId)}::view::unresolved_markets`,
|
|
138
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
139
|
+
arguments: [tx.object(resolveMarketRegistry(client, params.marketRegistry))],
|
|
140
|
+
});
|
|
141
|
+
const result = await client.simulate(tx);
|
|
142
|
+
return bcs.vector(MarketViewBcs).parse(extractReturnBytes(result)).map(mapMarketView);
|
|
143
|
+
}
|
|
144
|
+
async function readMarketsPage(client, functionName, params = {}) {
|
|
145
|
+
const tx = new Transaction();
|
|
146
|
+
tx.moveCall({
|
|
147
|
+
target: `${resolvePackageId(client, params.packageId)}::view::${functionName}`,
|
|
148
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
149
|
+
arguments: [
|
|
150
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
151
|
+
startArg(tx, params.start),
|
|
152
|
+
tx.pure.u64(params.limit === undefined ? DEFAULT_PAGE_LIMIT : toBigInt(params.limit)),
|
|
153
|
+
],
|
|
154
|
+
});
|
|
155
|
+
const result = await client.simulate(tx);
|
|
156
|
+
const markets = bcs
|
|
157
|
+
.vector(MarketViewBcs)
|
|
158
|
+
.parse(extractReturnBytes(result, 0, 0))
|
|
159
|
+
.map(mapMarketView);
|
|
160
|
+
const next = bcs.option(bcs.u64()).parse(extractReturnBytes(result, 0, 1));
|
|
161
|
+
return { markets, nextCursor: next == null ? null : BigInt(next) };
|
|
162
|
+
}
|
|
163
|
+
export function getUnresolvedMarketsPage(client, params = {}) {
|
|
164
|
+
return readMarketsPage(client, "unresolved_markets_page", params);
|
|
165
|
+
}
|
|
166
|
+
export function getResolvedMarketsPage(client, params = {}) {
|
|
167
|
+
return readMarketsPage(client, "resolved_markets_page", params);
|
|
168
|
+
}
|
|
169
|
+
export async function getPositionsPage(client, params = {}) {
|
|
170
|
+
const tx = new Transaction();
|
|
171
|
+
tx.moveCall({
|
|
172
|
+
target: `${resolvePackageId(client, params.packageId)}::view::positions_page`,
|
|
173
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
174
|
+
arguments: [
|
|
175
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
176
|
+
startArg(tx, params.start),
|
|
177
|
+
tx.pure.u64(params.limit === undefined ? DEFAULT_PAGE_LIMIT : toBigInt(params.limit)),
|
|
178
|
+
],
|
|
179
|
+
});
|
|
180
|
+
const result = await client.simulate(tx);
|
|
181
|
+
const positions = bcs
|
|
182
|
+
.vector(PositionViewBcs)
|
|
183
|
+
.parse(extractReturnBytes(result, 0, 0))
|
|
184
|
+
.map(mapPositionView);
|
|
185
|
+
const next = bcs.option(bcs.u64()).parse(extractReturnBytes(result, 0, 1));
|
|
186
|
+
return { positions, nextCursor: next == null ? null : BigInt(next) };
|
|
187
|
+
}
|
|
128
188
|
/**
|
|
129
189
|
* Registry account ids (`0x2::object::ID`) for an owner via `waterx_account::account::account_ids`.
|
|
130
190
|
* Use these ids with `getAccountData`, `deposit`, and `placeOrder` — not Suiscan "Account" object addresses.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { PredictClient } from "./client.ts";
|
|
2
2
|
export type { CreateClientOptions } from "./client.ts";
|
|
3
|
-
export { clearConfigCache,
|
|
3
|
+
export { clearConfigCache, loadConfig } from "./config.ts";
|
|
4
4
|
export type { LoadConfigOptions, WaterxAccountPackage, WaterxConfigPackageBase, WaterxPredictionConfig, WaterxPredictionConfigPackages, WaterxPredictionGiftPackage, WaterxPredictionPackage, WaterxReferralPackage, } from "./config.ts";
|
|
5
5
|
export * from "./constants.ts";
|
|
6
6
|
export * from "./types.ts";
|
|
@@ -14,7 +14,7 @@ export { adminPlaceOrderFor, batchClaim, batchForceClaim, buildBatchForceClaimTr
|
|
|
14
14
|
export type { AdminPlaceOrderForParams, BatchClaimParams, BatchForceClaimParams, BuildBatchForceClaimTransactionsParams, CancelCloseParams, CancelOrderParams, ClaimParams, ConfirmCloseParams, FillOrderParams, ForceClaimParams, PlaceOrderParams, RequestCloseParams, RequestPartialCloseParams, ResolveMarketParams, SelfCancelCloseParams, SelfCancelOrderParams, SplitPositionParams, TransferPositionParams, } from "./prediction.ts";
|
|
15
15
|
export { buildBatchClaimTx, buildPlaceOrderTx } from "./tx-builders.ts";
|
|
16
16
|
export type { BuildBatchClaimTxParams, BuildPlaceOrderTxParams, PredictCommonBuildOpts, } from "./tx-builders.ts";
|
|
17
|
-
export { getAccountData, getAccountIds, getAccountOrderIds, getAccountOrderIdsByMarketId, getAccountPositionIds, getAccountPositionIdsByMarketId, getKeeperAddresses, getAllowedVersions, getMarketExposure, getMarketExposureByKey, getMarketById, getMarketByKey, getOrder, getOrderCursor, getPosition, getPositionCursor, getRegistry, getResolvedMarketCursor, getUnresolvedMarketCursor, isKeeper, isPredictionProtocolAssetAllowed, } from "./fetch.ts";
|
|
17
|
+
export { getAccountData, getAccountIds, getAccountOrderIds, getAccountOrderIdsByMarketId, getAccountPositionIds, getAccountPositionIdsByMarketId, getKeeperAddresses, getAllowedVersions, getMarketExposure, getMarketExposureByKey, getMarketById, getMarketByKey, getOrder, getOrderCursor, getPosition, getPositionCursor, getPositionsPage, getRegistry, getResolvedMarketCursor, getResolvedMarketsPage, getUnresolvedMarketCursor, getUnresolvedMarkets, getUnresolvedMarketsPage, isKeeper, isPredictionProtocolAssetAllowed, } from "./fetch.ts";
|
|
18
18
|
export type { GetAccountIdsParams, ViewBaseParams } from "./fetch.ts";
|
|
19
19
|
export { base64UrlNoPadDecode, base64UrlNoPadEncode, buildClaimShareFlow, buildCreateGiftFlow, buildGiftClaimMessage, claimShare, createGift, deleteGift, deriveGiftAddress, deriveGiftKeypair, encodeGiftUrl, generateGiftSeed, getCreatorGiftCount, getCreatorGiftIds, getGift, getGiftConfigPaused, getGiftControllerAddress, getGiftHasClaimed, parseGiftUrl, signGiftClaim, } from "./gift.ts";
|
|
20
20
|
export type { BuildClaimShareFlowParams, BuildClaimShareFlowResult, BuildCreateGiftFlowResult, ClaimShareParams, CreateGiftParams, DeleteGiftParams, GiftBaseParams, GiftReferralParams, GiftUrlParts, GiftView, } from "./gift.ts";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { PredictClient } from "./client.js";
|
|
2
|
-
export { clearConfigCache,
|
|
2
|
+
export { clearConfigCache, loadConfig } from "./config.js";
|
|
3
3
|
export * from "./constants.js";
|
|
4
4
|
export * from "./types.js";
|
|
5
5
|
export * as user from "./user/index.js";
|
|
@@ -8,7 +8,7 @@ export { addDelegate, allowPredictionProtocolAsset, consumeDepositDirect, consum
|
|
|
8
8
|
export { addKeeper, adminWithdraw, createMarketRegistry, depositSettlement, pauseMarket, removeKeeper, setMinReserve, setOrderCancelCooldownMs, unpauseMarket, } from "./admin.js";
|
|
9
9
|
export { adminPlaceOrderFor, batchClaim, batchForceClaim, buildBatchForceClaimTransactions, cancelClose, cancelOrder, claim, confirmClose, fillOrder, forceClaim, outcomeArg, placeOrder, requestClose, requestPartialClose, resolveMarket, selectionArg, selfCancelClose, selfCancelOrder, splitPosition, transferPosition, } from "./prediction.js";
|
|
10
10
|
export { buildBatchClaimTx, buildPlaceOrderTx } from "./tx-builders.js";
|
|
11
|
-
export { getAccountData, getAccountIds, getAccountOrderIds, getAccountOrderIdsByMarketId, getAccountPositionIds, getAccountPositionIdsByMarketId, getKeeperAddresses, getAllowedVersions, getMarketExposure, getMarketExposureByKey, getMarketById, getMarketByKey, getOrder, getOrderCursor, getPosition, getPositionCursor, getRegistry, getResolvedMarketCursor, getUnresolvedMarketCursor, isKeeper, isPredictionProtocolAssetAllowed, } from "./fetch.js";
|
|
11
|
+
export { getAccountData, getAccountIds, getAccountOrderIds, getAccountOrderIdsByMarketId, getAccountPositionIds, getAccountPositionIdsByMarketId, getKeeperAddresses, getAllowedVersions, getMarketExposure, getMarketExposureByKey, getMarketById, getMarketByKey, getOrder, getOrderCursor, getPosition, getPositionCursor, getPositionsPage, getRegistry, getResolvedMarketCursor, getResolvedMarketsPage, getUnresolvedMarketCursor, getUnresolvedMarkets, getUnresolvedMarketsPage, isKeeper, isPredictionProtocolAssetAllowed, } from "./fetch.js";
|
|
12
12
|
export { base64UrlNoPadDecode, base64UrlNoPadEncode, buildClaimShareFlow, buildCreateGiftFlow, buildGiftClaimMessage, claimShare, createGift, deleteGift, deriveGiftAddress, deriveGiftKeypair, encodeGiftUrl, generateGiftSeed, getCreatorGiftCount, getCreatorGiftIds, getGift, getGiftConfigPaused, getGiftControllerAddress, getGiftHasClaimed, parseGiftUrl, signGiftClaim, } from "./gift.js";
|
|
13
13
|
export * as bucketFrameworkAccountCalls from "../generated/bucket_v2_framework/account.js";
|
|
14
14
|
export * as waterxAccountCalls from "../generated/waterx_account/account.js";
|
|
@@ -88,6 +88,25 @@ export interface CursorView {
|
|
|
88
88
|
front: bigint | null;
|
|
89
89
|
back: bigint | null;
|
|
90
90
|
}
|
|
91
|
+
export interface PageParams {
|
|
92
|
+
packageId?: string;
|
|
93
|
+
marketRegistry?: string;
|
|
94
|
+
settlementCoinType?: string;
|
|
95
|
+
/** Cursor key to resume from; omit to start at the front of the table. */
|
|
96
|
+
start?: bigint | number | string;
|
|
97
|
+
/** Max entries in this page (default 100). */
|
|
98
|
+
limit?: bigint | number | string;
|
|
99
|
+
}
|
|
100
|
+
export interface MarketPage {
|
|
101
|
+
markets: MarketView[];
|
|
102
|
+
/** Pass as `start` for the next page; `null` when the table is exhausted. */
|
|
103
|
+
nextCursor: bigint | null;
|
|
104
|
+
}
|
|
105
|
+
export interface PositionPage {
|
|
106
|
+
positions: PositionView[];
|
|
107
|
+
/** Pass as `start` for the next page; `null` when the table is exhausted. */
|
|
108
|
+
nextCursor: bigint | null;
|
|
109
|
+
}
|
|
91
110
|
export interface CoinRef {
|
|
92
111
|
objectId: string;
|
|
93
112
|
version: string | bigint | number;
|
|
@@ -263,6 +263,10 @@ declare const predictOps: {
|
|
|
263
263
|
getPositionCursor(client: PredictClient, params?: predFetch.ViewBaseParams): Promise<import("./prediction/types.ts").CursorView>;
|
|
264
264
|
getUnresolvedMarketCursor(client: PredictClient, params?: predFetch.ViewBaseParams): Promise<import("./prediction/types.ts").CursorView>;
|
|
265
265
|
getResolvedMarketCursor(client: PredictClient, params?: predFetch.ViewBaseParams): Promise<import("./prediction/types.ts").CursorView>;
|
|
266
|
+
getUnresolvedMarkets(client: PredictClient, params?: predFetch.ViewBaseParams): Promise<import("./prediction/types.ts").MarketView[]>;
|
|
267
|
+
getUnresolvedMarketsPage(client: PredictClient, params?: import("./prediction/types.ts").PageParams): Promise<import("./prediction/types.ts").MarketPage>;
|
|
268
|
+
getResolvedMarketsPage(client: PredictClient, params?: import("./prediction/types.ts").PageParams): Promise<import("./prediction/types.ts").MarketPage>;
|
|
269
|
+
getPositionsPage(client: PredictClient, params?: import("./prediction/types.ts").PageParams): Promise<import("./prediction/types.ts").PositionPage>;
|
|
266
270
|
getAccountIds(client: PredictClient, params: predFetch.GetAccountIdsParams): Promise<string[]>;
|
|
267
271
|
getAccountData(client: PredictClient, params: predFetch.ViewBaseParams & {
|
|
268
272
|
accountId: string;
|
|
@@ -354,13 +358,14 @@ export interface ClientCreateOptions {
|
|
|
354
358
|
network?: Network;
|
|
355
359
|
/** Default gRPC URL for both lines. */
|
|
356
360
|
grpcUrl?: string;
|
|
357
|
-
/** Default `waterx-config` JSON URL for both lines.
|
|
358
|
-
|
|
361
|
+
/** Default `waterx-config` JSON URL for both lines (fetched as-is). Required
|
|
362
|
+
* unless supplied per-line via `perp` / `predict`. */
|
|
363
|
+
waterxConfigUrl?: string;
|
|
359
364
|
/** Memoize the fetched config JSON. */
|
|
360
365
|
cache?: boolean;
|
|
361
|
-
/** Perp-line overrides (network, grpcUrl,
|
|
366
|
+
/** Perp-line overrides (network, grpcUrl, waterxConfigUrl, cache, …). */
|
|
362
367
|
perp?: PerpLineOptions;
|
|
363
|
-
/** Prediction-line overrides (network, grpcUrl,
|
|
368
|
+
/** Prediction-line overrides (network, grpcUrl, waterxConfigUrl, cache, settlement, …). */
|
|
364
369
|
predict?: PredictLineOptions;
|
|
365
370
|
}
|
|
366
371
|
export declare class WaterXClient {
|
|
@@ -166,13 +166,13 @@ export class WaterXClient {
|
|
|
166
166
|
}
|
|
167
167
|
const perpClient = await PerpClient.create(resolvedPerpNetwork, {
|
|
168
168
|
grpcUrl: opts.grpcUrl,
|
|
169
|
-
|
|
169
|
+
waterxConfigUrl: opts.waterxConfigUrl,
|
|
170
170
|
cache: opts.cache,
|
|
171
171
|
...perpRest,
|
|
172
172
|
});
|
|
173
173
|
const predictClient = await PredictClient.create(resolvedPredictNetwork, {
|
|
174
174
|
grpcUrl: opts.grpcUrl,
|
|
175
|
-
|
|
175
|
+
waterxConfigUrl: opts.waterxConfigUrl,
|
|
176
176
|
cache: opts.cache,
|
|
177
177
|
...predictRest,
|
|
178
178
|
});
|