@waterx/predict-sdk
v0.1.0
Published
WaterX prediction market SDK
Readme
@waterx/predict-sdk
TypeScript SDK for waterx_prediction, the WaterX prediction market broker on Sui.
The package exposes:
PredictClientfor Sui gRPC, simulation, and execution.- User PTB builders for
placeOrder,requestClose,claim, and self-cancel paths. - Keeper PTB builders for fill/cancel/close/resolve/force-claim paths.
- Admin PTB builders for registry setup, settlement funding, pause controls, and keeper management.
- Generated Move wrappers in
src/generatedviapnpm codegen. - User-facing grouped exports under
src/user. - Shared argument/BCS helpers under
src/utils. - View helpers that read
waterx_prediction::viewviasimulateTransactionand BCS parsing.
import { PredictClient, placeOrder } from "@waterx/predict-sdk";
import { Transaction } from "@mysten/sui/transactions";
const client = PredictClient.testnet();
const tx = new Transaction();
placeOrder(client, tx, {
accountId: "0x...",
maxSpend: 100_000_000n,
marketId: "0x...",
selection: "YES",
minShares: 50_000_000n,
priceCapBps: 7_000n,
expiryTs: 9_999_999_999_999n,
});Testnet package, shared object, registry, and settlement coin defaults are wired from the WaterX config snapshot:
WaterXProtocol/waterx-config.
You can still override any ID when testing a new deployment:
const client = PredictClient.testnet({
packageId: "0x...",
globalConfig: "0x...",
marketRegistry: "0x...",
accountRegistry: "0x...",
settlementCoinType: "0x...::coin::COIN",
});Input validation
- PTB helpers use strict literals for
Selection/Outcome("YES","NO","INVALID"). On-chain view decoding accepts Move enum casing (for example"Yes"). normalizeMarketId()is for PTBvector<u8>arguments. Strings starting with0xare parsed as hex; other strings are UTF-8. View decoding expectsUint8Arrayornumber[]formarket_id, not strings.toBigInt()rejects empty strings, non-integers, negatives, and values aboveu64::MAX.
Development
pnpm codegen
pnpm typecheck
pnpm build
pnpm test:unitpnpm codegen regenerates src/generated from:
../waterx-contract/waterx_prediction../waterx-contract/waterx_account../waterx-contract/bucket_framework
