@waterx/predict-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +67 -0
- package/dist/src/account.d.ts +64 -0
- package/dist/src/account.js +134 -0
- package/dist/src/admin.d.ts +47 -0
- package/dist/src/admin.js +104 -0
- package/dist/src/bcs.d.ts +20 -0
- package/dist/src/bcs.js +209 -0
- package/dist/src/client.d.ts +60 -0
- package/dist/src/client.js +59 -0
- package/dist/src/constants.d.ts +61 -0
- package/dist/src/constants.js +62 -0
- package/dist/src/fetch.d.ts +53 -0
- package/dist/src/fetch.js +187 -0
- package/dist/src/generated/bucket_v2_framework/account.d.ts +100 -0
- package/dist/src/generated/bucket_v2_framework/account.js +129 -0
- package/dist/src/generated/bucket_v2_framework/deps/std/type_name.d.ts +6 -0
- package/dist/src/generated/bucket_v2_framework/deps/std/type_name.js +19 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/balance.d.ts +10 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/balance.js +14 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/bucket_v2_framework/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/bucket_v2_framework/double.d.ts +382 -0
- package/dist/src/generated/bucket_v2_framework/double.js +466 -0
- package/dist/src/generated/bucket_v2_framework/float.d.ts +362 -0
- package/dist/src/generated/bucket_v2_framework/float.js +440 -0
- package/dist/src/generated/bucket_v2_framework/liability.d.ts +193 -0
- package/dist/src/generated/bucket_v2_framework/liability.js +205 -0
- package/dist/src/generated/bucket_v2_framework/linked_table.d.ts +384 -0
- package/dist/src/generated/bucket_v2_framework/linked_table.js +382 -0
- package/dist/src/generated/bucket_v2_framework/sheet.d.ts +344 -0
- package/dist/src/generated/bucket_v2_framework/sheet.js +344 -0
- package/dist/src/generated/utils/index.d.ts +30 -0
- package/dist/src/generated/utils/index.js +157 -0
- package/dist/src/generated/waterx_account/account.d.ts +1326 -0
- package/dist/src/generated/waterx_account/account.js +1487 -0
- package/dist/src/generated/waterx_account/deps/std/type_name.d.ts +6 -0
- package/dist/src/generated/waterx_account/deps/std/type_name.js +19 -0
- package/dist/src/generated/waterx_account/deps/sui/balance.d.ts +10 -0
- package/dist/src/generated/waterx_account/deps/sui/balance.js +14 -0
- package/dist/src/generated/waterx_account/deps/sui/table.d.ts +24 -0
- package/dist/src/generated/waterx_account/deps/sui/table.js +31 -0
- package/dist/src/generated/waterx_account/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_account/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_account/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/waterx_account/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/waterx_account/direct_rule.d.ts +72 -0
- package/dist/src/generated/waterx_account/direct_rule.js +75 -0
- package/dist/src/generated/waterx_account/events.d.ts +30 -0
- package/dist/src/generated/waterx_account/events.js +145 -0
- package/dist/src/generated/waterx_account/version.d.ts +10 -0
- package/dist/src/generated/waterx_account/version.js +8 -0
- package/dist/src/generated/waterx_prediction/account_data.d.ts +321 -0
- package/dist/src/generated/waterx_prediction/account_data.js +399 -0
- package/dist/src/generated/waterx_prediction/admin.d.ts +5 -0
- package/dist/src/generated/waterx_prediction/admin.js +9 -0
- package/dist/src/generated/waterx_prediction/deps/bucket_v2_framework/linked_table.d.ts +8 -0
- package/dist/src/generated/waterx_prediction/deps/bucket_v2_framework/linked_table.js +18 -0
- package/dist/src/generated/waterx_prediction/deps/sui/balance.d.ts +10 -0
- package/dist/src/generated/waterx_prediction/deps/sui/balance.js +14 -0
- package/dist/src/generated/waterx_prediction/deps/sui/table.d.ts +24 -0
- package/dist/src/generated/waterx_prediction/deps/sui/table.js +31 -0
- package/dist/src/generated/waterx_prediction/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/generated/waterx_prediction/deps/sui/vec_set.js +19 -0
- package/dist/src/generated/waterx_prediction/events.d.ts +19 -0
- package/dist/src/generated/waterx_prediction/events.js +99 -0
- package/dist/src/generated/waterx_prediction/global_config.d.ts +68 -0
- package/dist/src/generated/waterx_prediction/global_config.js +83 -0
- package/dist/src/generated/waterx_prediction/order.d.ts +170 -0
- package/dist/src/generated/waterx_prediction/order.js +237 -0
- package/dist/src/generated/waterx_prediction/outcome.d.ts +58 -0
- package/dist/src/generated/waterx_prediction/outcome.js +73 -0
- package/dist/src/generated/waterx_prediction/position.d.ts +150 -0
- package/dist/src/generated/waterx_prediction/position.js +200 -0
- package/dist/src/generated/waterx_prediction/view.d.ts +353 -0
- package/dist/src/generated/waterx_prediction/view.js +426 -0
- package/dist/src/generated/waterx_prediction/waterx_prediction.d.ts +1520 -0
- package/dist/src/generated/waterx_prediction/waterx_prediction.js +1550 -0
- package/dist/src/index.d.ts +22 -0
- package/dist/src/index.js +17 -0
- package/dist/src/prediction.d.ts +81 -0
- package/dist/src/prediction.js +220 -0
- package/dist/src/types.d.ts +81 -0
- package/dist/src/types.js +1 -0
- package/dist/src/user/account.d.ts +2 -0
- package/dist/src/user/account.js +1 -0
- package/dist/src/user/admin.d.ts +4 -0
- package/dist/src/user/admin.js +2 -0
- package/dist/src/user/index.d.ts +4 -0
- package/dist/src/user/index.js +2 -0
- package/dist/src/user/keeper.d.ts +2 -0
- package/dist/src/user/keeper.js +1 -0
- package/dist/src/user/order.d.ts +2 -0
- package/dist/src/user/order.js +1 -0
- package/dist/src/user/position.d.ts +2 -0
- package/dist/src/user/position.js +1 -0
- package/dist/src/utils/bcs.d.ts +1 -0
- package/dist/src/utils/bcs.js +1 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +1 -0
- package/dist/src/utils.d.ts +29 -0
- package/dist/src/utils.js +170 -0
- package/package.json +62 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { PredictClient, createTestnetConfig } from "./client.ts";
|
|
2
|
+
export type { PredictConfig, TestnetConfigParams } from "./client.ts";
|
|
3
|
+
export * from "./constants.ts";
|
|
4
|
+
export * from "./types.ts";
|
|
5
|
+
export * as user from "./user/index.ts";
|
|
6
|
+
export * as utils from "./utils/index.ts";
|
|
7
|
+
export { addDelegate, createAccount, removeDelegate, requestDeposit, requestDepositFromReceivings, requestWithdraw, setDelegatePredictionPermission, transferCoinToAccount, whitelistPredictionProtocol, } from "./account.ts";
|
|
8
|
+
export type { AddDelegateParams, CreateAccountParams, RemoveDelegateParams, RequestDepositFromReceivingsParams, RequestDepositParams, RequestWithdrawParams, SetDelegatePredictionPermissionParams, TransferCoinToAccountParams, WhitelistPredictionProtocolParams, } from "./account.ts";
|
|
9
|
+
export { addKeeper, adminWithdraw, createMarketRegistry, depositSettlement, pauseMarket, removeKeeper, setMinReserve, setOrderCancelCooldownMs, unpauseMarket, } from "./admin.ts";
|
|
10
|
+
export type { AdminWithdrawParams, CreateMarketRegistryParams, DepositSettlementParams, KeeperAdminParams, MarketPauseParams, SetMinReserveParams, SetOrderCancelCooldownParams, } from "./admin.ts";
|
|
11
|
+
export { adminPlaceOrderFor, cancelClose, cancelOrder, claim, confirmClose, fillOrder, forceClaim, outcomeArg, placeOrder, requestClose, resolveMarket, selectionArg, selfCancelClose, selfCancelOrder, } from "./prediction.ts";
|
|
12
|
+
export type { AdminPlaceOrderForParams, CancelCloseParams, CancelOrderParams, ClaimParams, ConfirmCloseParams, FillOrderParams, ForceClaimParams, PlaceOrderParams, RequestCloseParams, ResolveMarketParams, SelfCancelCloseParams, SelfCancelOrderParams, } from "./prediction.ts";
|
|
13
|
+
export { getAccountData, getAccountOrderIds, getAccountOrderIdsByMarketId, getAccountPositionIds, getAccountPositionIdsByMarketId, getKeeperAddresses, getMarketById, getMarketByKey, getOrder, getOrderCursor, getPosition, getPositionCursor, getRegistry, getResolvedMarketCursor, getUnresolvedMarketCursor, isKeeper, } from "./fetch.ts";
|
|
14
|
+
export type { ViewBaseParams } from "./fetch.ts";
|
|
15
|
+
export * as bucketFrameworkAccountCalls from "./generated/bucket_v2_framework/account.ts";
|
|
16
|
+
export * as waterxAccountCalls from "./generated/waterx_account/account.ts";
|
|
17
|
+
export * as predictionAccountDataCalls from "./generated/waterx_prediction/account_data.ts";
|
|
18
|
+
export * as predictionGlobalConfigCalls from "./generated/waterx_prediction/global_config.ts";
|
|
19
|
+
export * as predictionOutcomeCalls from "./generated/waterx_prediction/outcome.ts";
|
|
20
|
+
export * as predictionPositionCalls from "./generated/waterx_prediction/position.ts";
|
|
21
|
+
export * as predictionViewCalls from "./generated/waterx_prediction/view.ts";
|
|
22
|
+
export * as predictionCalls from "./generated/waterx_prediction/waterx_prediction.ts";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { PredictClient, createTestnetConfig } from "./client.js";
|
|
2
|
+
export * from "./constants.js";
|
|
3
|
+
export * from "./types.js";
|
|
4
|
+
export * as user from "./user/index.js";
|
|
5
|
+
export * as utils from "./utils/index.js";
|
|
6
|
+
export { addDelegate, createAccount, removeDelegate, requestDeposit, requestDepositFromReceivings, requestWithdraw, setDelegatePredictionPermission, transferCoinToAccount, whitelistPredictionProtocol, } from "./account.js";
|
|
7
|
+
export { addKeeper, adminWithdraw, createMarketRegistry, depositSettlement, pauseMarket, removeKeeper, setMinReserve, setOrderCancelCooldownMs, unpauseMarket, } from "./admin.js";
|
|
8
|
+
export { adminPlaceOrderFor, cancelClose, cancelOrder, claim, confirmClose, fillOrder, forceClaim, outcomeArg, placeOrder, requestClose, resolveMarket, selectionArg, selfCancelClose, selfCancelOrder, } from "./prediction.js";
|
|
9
|
+
export { getAccountData, getAccountOrderIds, getAccountOrderIdsByMarketId, getAccountPositionIds, getAccountPositionIdsByMarketId, getKeeperAddresses, getMarketById, getMarketByKey, getOrder, getOrderCursor, getPosition, getPositionCursor, getRegistry, getResolvedMarketCursor, getUnresolvedMarketCursor, isKeeper, } from "./fetch.js";
|
|
10
|
+
export * as bucketFrameworkAccountCalls from "./generated/bucket_v2_framework/account.js";
|
|
11
|
+
export * as waterxAccountCalls from "./generated/waterx_account/account.js";
|
|
12
|
+
export * as predictionAccountDataCalls from "./generated/waterx_prediction/account_data.js";
|
|
13
|
+
export * as predictionGlobalConfigCalls from "./generated/waterx_prediction/global_config.js";
|
|
14
|
+
export * as predictionOutcomeCalls from "./generated/waterx_prediction/outcome.js";
|
|
15
|
+
export * as predictionPositionCalls from "./generated/waterx_prediction/position.js";
|
|
16
|
+
export * as predictionViewCalls from "./generated/waterx_prediction/view.js";
|
|
17
|
+
export * as predictionCalls from "./generated/waterx_prediction/waterx_prediction.js";
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Transaction, type TransactionArgument } from "@mysten/sui/transactions";
|
|
2
|
+
import type { PredictClient } from "./client.ts";
|
|
3
|
+
import type { AccountIdentityParams, IdArgument, MarketIdInput, ObjectArgument, Outcome, Selection } from "./types.ts";
|
|
4
|
+
export interface BasePredictionParams {
|
|
5
|
+
packageId?: string;
|
|
6
|
+
marketRegistry?: string;
|
|
7
|
+
accountRegistry?: string;
|
|
8
|
+
settlementCoinType?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function selectionArg(client: PredictClient, tx: Transaction, selection: Selection | TransactionArgument, packageId?: string): TransactionArgument;
|
|
11
|
+
export declare function outcomeArg(client: PredictClient, tx: Transaction, outcome: Outcome | TransactionArgument, packageId?: string): TransactionArgument;
|
|
12
|
+
export interface PlaceOrderParams extends BasePredictionParams, AccountIdentityParams {
|
|
13
|
+
accountId: IdArgument;
|
|
14
|
+
maxSpend: bigint | number | string;
|
|
15
|
+
marketId: MarketIdInput;
|
|
16
|
+
selection: Selection | TransactionArgument;
|
|
17
|
+
minShares: bigint | number | string;
|
|
18
|
+
priceCapBps: bigint | number | string;
|
|
19
|
+
expiryTs: bigint | number | string;
|
|
20
|
+
}
|
|
21
|
+
export declare function placeOrder(client: PredictClient, tx: Transaction, params: PlaceOrderParams): Transaction;
|
|
22
|
+
export interface SelfCancelOrderParams extends BasePredictionParams, AccountIdentityParams {
|
|
23
|
+
orderId: bigint | number | string;
|
|
24
|
+
}
|
|
25
|
+
export declare function selfCancelOrder(client: PredictClient, tx: Transaction, params: SelfCancelOrderParams): Transaction;
|
|
26
|
+
export interface ClaimParams extends BasePredictionParams, AccountIdentityParams {
|
|
27
|
+
positionId: bigint | number | string;
|
|
28
|
+
}
|
|
29
|
+
export declare function claim(client: PredictClient, tx: Transaction, params: ClaimParams): Transaction;
|
|
30
|
+
export interface RequestCloseParams extends BasePredictionParams, AccountIdentityParams {
|
|
31
|
+
positionId: bigint | number | string;
|
|
32
|
+
minProceeds: bigint | number | string;
|
|
33
|
+
expiryTs: bigint | number | string;
|
|
34
|
+
}
|
|
35
|
+
export declare function requestClose(client: PredictClient, tx: Transaction, params: RequestCloseParams): Transaction;
|
|
36
|
+
export interface SelfCancelCloseParams extends BasePredictionParams, AccountIdentityParams {
|
|
37
|
+
positionId: bigint | number | string;
|
|
38
|
+
}
|
|
39
|
+
export declare function selfCancelClose(client: PredictClient, tx: Transaction, params: SelfCancelCloseParams): Transaction;
|
|
40
|
+
export interface KeeperBaseParams extends BasePredictionParams, AccountIdentityParams {
|
|
41
|
+
globalConfig?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface FillOrderParams extends KeeperBaseParams {
|
|
44
|
+
orderId: bigint | number | string;
|
|
45
|
+
filledShares: bigint | number | string;
|
|
46
|
+
filledCost: bigint | number | string;
|
|
47
|
+
}
|
|
48
|
+
export declare function fillOrder(client: PredictClient, tx: Transaction, params: FillOrderParams): Transaction;
|
|
49
|
+
export interface CancelOrderParams extends KeeperBaseParams {
|
|
50
|
+
orderId: bigint | number | string;
|
|
51
|
+
}
|
|
52
|
+
export declare function cancelOrder(client: PredictClient, tx: Transaction, params: CancelOrderParams): Transaction;
|
|
53
|
+
export interface ConfirmCloseParams extends KeeperBaseParams {
|
|
54
|
+
positionId: bigint | number | string;
|
|
55
|
+
proceeds: bigint | number | string;
|
|
56
|
+
}
|
|
57
|
+
export declare function confirmClose(client: PredictClient, tx: Transaction, params: ConfirmCloseParams): Transaction;
|
|
58
|
+
export interface CancelCloseParams extends KeeperBaseParams {
|
|
59
|
+
positionId: bigint | number | string;
|
|
60
|
+
}
|
|
61
|
+
export declare function cancelClose(client: PredictClient, tx: Transaction, params: CancelCloseParams): Transaction;
|
|
62
|
+
export interface ForceClaimParams extends KeeperBaseParams {
|
|
63
|
+
positionId: bigint | number | string;
|
|
64
|
+
}
|
|
65
|
+
export declare function forceClaim(client: PredictClient, tx: Transaction, params: ForceClaimParams): Transaction;
|
|
66
|
+
export interface ResolveMarketParams extends KeeperBaseParams {
|
|
67
|
+
marketId: MarketIdInput;
|
|
68
|
+
outcome: Outcome | TransactionArgument;
|
|
69
|
+
}
|
|
70
|
+
export declare function resolveMarket(client: PredictClient, tx: Transaction, params: ResolveMarketParams): Transaction;
|
|
71
|
+
export interface AdminPlaceOrderForParams extends BasePredictionParams {
|
|
72
|
+
adminCap: ObjectArgument;
|
|
73
|
+
payment: ObjectArgument;
|
|
74
|
+
accountId: IdArgument;
|
|
75
|
+
marketId: MarketIdInput;
|
|
76
|
+
selection: Selection | TransactionArgument;
|
|
77
|
+
minShares: bigint | number | string;
|
|
78
|
+
priceCapBps: bigint | number | string;
|
|
79
|
+
expiryTs: bigint | number | string;
|
|
80
|
+
}
|
|
81
|
+
export declare function adminPlaceOrderFor(client: PredictClient, tx: Transaction, params: AdminPlaceOrderForParams): Transaction;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { assertOutcome, assertSelection, clockArg, createAccountRequest, idArg, marketIdArg, objectArg, resolveAccountRegistry, resolveGlobalConfig, resolveMarketRegistry, resolvePackageId, resolveSettlementCoinType, toBigInt, } from "./utils.js";
|
|
2
|
+
export function selectionArg(client, tx, selection, packageId) {
|
|
3
|
+
if (typeof selection !== "string")
|
|
4
|
+
return selection;
|
|
5
|
+
const validated = assertSelection(selection);
|
|
6
|
+
const fn = validated === "YES" ? "selection_yes" : "selection_no";
|
|
7
|
+
const [arg] = tx.moveCall({
|
|
8
|
+
target: `${resolvePackageId(client, packageId)}::position::${fn}`,
|
|
9
|
+
});
|
|
10
|
+
return arg;
|
|
11
|
+
}
|
|
12
|
+
export function outcomeArg(client, tx, outcome, packageId) {
|
|
13
|
+
if (typeof outcome !== "string")
|
|
14
|
+
return outcome;
|
|
15
|
+
const validated = assertOutcome(outcome);
|
|
16
|
+
const fn = validated === "YES" ? "yes" : validated === "NO" ? "no" : "invalid";
|
|
17
|
+
const [arg] = tx.moveCall({
|
|
18
|
+
target: `${resolvePackageId(client, packageId)}::outcome::${fn}`,
|
|
19
|
+
});
|
|
20
|
+
return arg;
|
|
21
|
+
}
|
|
22
|
+
export function placeOrder(client, tx, params) {
|
|
23
|
+
const pkg = resolvePackageId(client, params.packageId);
|
|
24
|
+
const senderRequest = createAccountRequest(client, tx, params);
|
|
25
|
+
tx.moveCall({
|
|
26
|
+
target: `${pkg}::waterx_prediction::place_order`,
|
|
27
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
28
|
+
arguments: [
|
|
29
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
30
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
31
|
+
senderRequest,
|
|
32
|
+
idArg(tx, params.accountId),
|
|
33
|
+
tx.pure.u64(toBigInt(params.maxSpend)),
|
|
34
|
+
marketIdArg(tx, params.marketId),
|
|
35
|
+
selectionArg(client, tx, params.selection, params.packageId),
|
|
36
|
+
tx.pure.u64(toBigInt(params.minShares)),
|
|
37
|
+
tx.pure.u64(toBigInt(params.priceCapBps)),
|
|
38
|
+
tx.pure.u64(toBigInt(params.expiryTs)),
|
|
39
|
+
clockArg(tx),
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
return tx;
|
|
43
|
+
}
|
|
44
|
+
export function selfCancelOrder(client, tx, params) {
|
|
45
|
+
const senderRequest = createAccountRequest(client, tx, params);
|
|
46
|
+
tx.moveCall({
|
|
47
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::self_cancel_order`,
|
|
48
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
49
|
+
arguments: [
|
|
50
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
51
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
52
|
+
senderRequest,
|
|
53
|
+
tx.pure.u64(toBigInt(params.orderId)),
|
|
54
|
+
clockArg(tx),
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
return tx;
|
|
58
|
+
}
|
|
59
|
+
export function claim(client, tx, params) {
|
|
60
|
+
const senderRequest = createAccountRequest(client, tx, params);
|
|
61
|
+
tx.moveCall({
|
|
62
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::claim`,
|
|
63
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
64
|
+
arguments: [
|
|
65
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
66
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
67
|
+
senderRequest,
|
|
68
|
+
tx.pure.u64(toBigInt(params.positionId)),
|
|
69
|
+
clockArg(tx),
|
|
70
|
+
],
|
|
71
|
+
});
|
|
72
|
+
return tx;
|
|
73
|
+
}
|
|
74
|
+
export function requestClose(client, tx, params) {
|
|
75
|
+
const senderRequest = createAccountRequest(client, tx, params);
|
|
76
|
+
tx.moveCall({
|
|
77
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::request_close`,
|
|
78
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
79
|
+
arguments: [
|
|
80
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
81
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
82
|
+
senderRequest,
|
|
83
|
+
tx.pure.u64(toBigInt(params.positionId)),
|
|
84
|
+
tx.pure.u64(toBigInt(params.minProceeds)),
|
|
85
|
+
tx.pure.u64(toBigInt(params.expiryTs)),
|
|
86
|
+
clockArg(tx),
|
|
87
|
+
],
|
|
88
|
+
});
|
|
89
|
+
return tx;
|
|
90
|
+
}
|
|
91
|
+
export function selfCancelClose(client, tx, params) {
|
|
92
|
+
const senderRequest = createAccountRequest(client, tx, params);
|
|
93
|
+
tx.moveCall({
|
|
94
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::self_cancel_close`,
|
|
95
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
96
|
+
arguments: [
|
|
97
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
98
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
99
|
+
senderRequest,
|
|
100
|
+
tx.pure.u64(toBigInt(params.positionId)),
|
|
101
|
+
clockArg(tx),
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
return tx;
|
|
105
|
+
}
|
|
106
|
+
export function fillOrder(client, tx, params) {
|
|
107
|
+
const keeperRequest = createAccountRequest(client, tx, params);
|
|
108
|
+
tx.moveCall({
|
|
109
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::fill_order`,
|
|
110
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
111
|
+
arguments: [
|
|
112
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
113
|
+
keeperRequest,
|
|
114
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
115
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
116
|
+
tx.pure.u64(toBigInt(params.orderId)),
|
|
117
|
+
tx.pure.u64(toBigInt(params.filledShares)),
|
|
118
|
+
tx.pure.u64(toBigInt(params.filledCost)),
|
|
119
|
+
clockArg(tx),
|
|
120
|
+
],
|
|
121
|
+
});
|
|
122
|
+
return tx;
|
|
123
|
+
}
|
|
124
|
+
export function cancelOrder(client, tx, params) {
|
|
125
|
+
const keeperRequest = createAccountRequest(client, tx, params);
|
|
126
|
+
tx.moveCall({
|
|
127
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::cancel_order`,
|
|
128
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
129
|
+
arguments: [
|
|
130
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
131
|
+
keeperRequest,
|
|
132
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
133
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
134
|
+
tx.pure.u64(toBigInt(params.orderId)),
|
|
135
|
+
],
|
|
136
|
+
});
|
|
137
|
+
return tx;
|
|
138
|
+
}
|
|
139
|
+
export function confirmClose(client, tx, params) {
|
|
140
|
+
const keeperRequest = createAccountRequest(client, tx, params);
|
|
141
|
+
tx.moveCall({
|
|
142
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::confirm_close`,
|
|
143
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
144
|
+
arguments: [
|
|
145
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
146
|
+
keeperRequest,
|
|
147
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
148
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
149
|
+
tx.pure.u64(toBigInt(params.positionId)),
|
|
150
|
+
tx.pure.u64(toBigInt(params.proceeds)),
|
|
151
|
+
clockArg(tx),
|
|
152
|
+
],
|
|
153
|
+
});
|
|
154
|
+
return tx;
|
|
155
|
+
}
|
|
156
|
+
export function cancelClose(client, tx, params) {
|
|
157
|
+
const keeperRequest = createAccountRequest(client, tx, params);
|
|
158
|
+
tx.moveCall({
|
|
159
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::cancel_close`,
|
|
160
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
161
|
+
arguments: [
|
|
162
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
163
|
+
keeperRequest,
|
|
164
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
165
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
166
|
+
tx.pure.u64(toBigInt(params.positionId)),
|
|
167
|
+
],
|
|
168
|
+
});
|
|
169
|
+
return tx;
|
|
170
|
+
}
|
|
171
|
+
export function forceClaim(client, tx, params) {
|
|
172
|
+
const keeperRequest = createAccountRequest(client, tx, params);
|
|
173
|
+
tx.moveCall({
|
|
174
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::force_claim`,
|
|
175
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
176
|
+
arguments: [
|
|
177
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
178
|
+
keeperRequest,
|
|
179
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
180
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
181
|
+
tx.pure.u64(toBigInt(params.positionId)),
|
|
182
|
+
],
|
|
183
|
+
});
|
|
184
|
+
return tx;
|
|
185
|
+
}
|
|
186
|
+
export function resolveMarket(client, tx, params) {
|
|
187
|
+
const keeperRequest = createAccountRequest(client, tx, params);
|
|
188
|
+
tx.moveCall({
|
|
189
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::resolve_market`,
|
|
190
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
191
|
+
arguments: [
|
|
192
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
193
|
+
keeperRequest,
|
|
194
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
195
|
+
marketIdArg(tx, params.marketId),
|
|
196
|
+
outcomeArg(client, tx, params.outcome, params.packageId),
|
|
197
|
+
],
|
|
198
|
+
});
|
|
199
|
+
return tx;
|
|
200
|
+
}
|
|
201
|
+
export function adminPlaceOrderFor(client, tx, params) {
|
|
202
|
+
tx.moveCall({
|
|
203
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::admin_place_order_for`,
|
|
204
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
205
|
+
arguments: [
|
|
206
|
+
objectArg(tx, params.adminCap),
|
|
207
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
208
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
209
|
+
objectArg(tx, params.payment),
|
|
210
|
+
idArg(tx, params.accountId),
|
|
211
|
+
marketIdArg(tx, params.marketId),
|
|
212
|
+
selectionArg(client, tx, params.selection, params.packageId),
|
|
213
|
+
tx.pure.u64(toBigInt(params.minShares)),
|
|
214
|
+
tx.pure.u64(toBigInt(params.priceCapBps)),
|
|
215
|
+
tx.pure.u64(toBigInt(params.expiryTs)),
|
|
216
|
+
clockArg(tx),
|
|
217
|
+
],
|
|
218
|
+
});
|
|
219
|
+
return tx;
|
|
220
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { TransactionArgument } from "@mysten/sui/transactions";
|
|
2
|
+
export type ObjectArgument = string | TransactionArgument;
|
|
3
|
+
export type IdArgument = string | TransactionArgument;
|
|
4
|
+
export type Selection = "NO" | "YES";
|
|
5
|
+
export type Outcome = "NO" | "YES" | "INVALID";
|
|
6
|
+
export type OrderKind = "OPEN" | "CLOSE";
|
|
7
|
+
export type PositionStatus = "OPEN" | "PENDING_CLOSE";
|
|
8
|
+
export type MarketIdInput = string | Uint8Array | number[];
|
|
9
|
+
export interface AccountIdentityParams {
|
|
10
|
+
bucketAccount?: ObjectArgument;
|
|
11
|
+
}
|
|
12
|
+
export interface RegistryView {
|
|
13
|
+
balance: bigint;
|
|
14
|
+
minReserve: bigint;
|
|
15
|
+
orderCancelCooldownMs: bigint;
|
|
16
|
+
nextOrderId: bigint;
|
|
17
|
+
orderCount: bigint;
|
|
18
|
+
positionCount: bigint;
|
|
19
|
+
unresolvedMarketCount: bigint;
|
|
20
|
+
resolvedMarketCount: bigint;
|
|
21
|
+
}
|
|
22
|
+
export interface OrderView {
|
|
23
|
+
orderId: bigint;
|
|
24
|
+
kind: OrderKind;
|
|
25
|
+
accountId: string;
|
|
26
|
+
marketId: Uint8Array;
|
|
27
|
+
marketIdHex: string;
|
|
28
|
+
selection: Selection;
|
|
29
|
+
positionId: bigint | null;
|
|
30
|
+
maxSpend: bigint;
|
|
31
|
+
minShares: bigint;
|
|
32
|
+
priceCapBps: bigint;
|
|
33
|
+
minProceeds: bigint;
|
|
34
|
+
expiryTs: bigint;
|
|
35
|
+
selfCancelAfterTs: bigint;
|
|
36
|
+
byAdmin: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface PositionView {
|
|
39
|
+
positionId: bigint;
|
|
40
|
+
accountId: string;
|
|
41
|
+
marketId: Uint8Array;
|
|
42
|
+
marketIdHex: string;
|
|
43
|
+
selection: Selection;
|
|
44
|
+
status: PositionStatus;
|
|
45
|
+
filledShares: bigint;
|
|
46
|
+
filledCost: bigint;
|
|
47
|
+
payout: bigint;
|
|
48
|
+
closeOrderId: bigint | null;
|
|
49
|
+
closeMinProceeds: bigint;
|
|
50
|
+
closeExpiryTs: bigint;
|
|
51
|
+
closeSelfCancelAfterTs: bigint;
|
|
52
|
+
}
|
|
53
|
+
export interface MarketView {
|
|
54
|
+
marketKey: bigint;
|
|
55
|
+
marketId: Uint8Array;
|
|
56
|
+
marketIdHex: string;
|
|
57
|
+
resolved: boolean;
|
|
58
|
+
paused: boolean;
|
|
59
|
+
outcome: Outcome | null;
|
|
60
|
+
unclaimedCount: bigint;
|
|
61
|
+
}
|
|
62
|
+
export interface AccountDataView {
|
|
63
|
+
accountId: string;
|
|
64
|
+
hasData: boolean;
|
|
65
|
+
orderCount: bigint;
|
|
66
|
+
positionCount: bigint;
|
|
67
|
+
orderFront: bigint | null;
|
|
68
|
+
orderBack: bigint | null;
|
|
69
|
+
positionFront: bigint | null;
|
|
70
|
+
positionBack: bigint | null;
|
|
71
|
+
}
|
|
72
|
+
export interface CursorView {
|
|
73
|
+
count: bigint;
|
|
74
|
+
front: bigint | null;
|
|
75
|
+
back: bigint | null;
|
|
76
|
+
}
|
|
77
|
+
export interface CoinRef {
|
|
78
|
+
objectId: string;
|
|
79
|
+
version: string | bigint | number;
|
|
80
|
+
digest: string;
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { addDelegate, createAccount, removeDelegate, requestDeposit, requestDepositFromReceivings, requestWithdraw, setDelegatePredictionPermission, transferCoinToAccount, whitelistPredictionProtocol, } from "../account.ts";
|
|
2
|
+
export type { AddDelegateParams, CreateAccountParams, RemoveDelegateParams, RequestDepositFromReceivingsParams, RequestDepositParams, RequestWithdrawParams, SetDelegatePredictionPermissionParams, TransferCoinToAccountParams, WhitelistPredictionProtocolParams, } from "../account.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { addDelegate, createAccount, removeDelegate, requestDeposit, requestDepositFromReceivings, requestWithdraw, setDelegatePredictionPermission, transferCoinToAccount, whitelistPredictionProtocol, } from "../account.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { adminPlaceOrderFor } from "../prediction.ts";
|
|
2
|
+
export type { AdminPlaceOrderForParams } from "../prediction.ts";
|
|
3
|
+
export { addKeeper, adminWithdraw, createMarketRegistry, depositSettlement, pauseMarket, removeKeeper, setMinReserve, setOrderCancelCooldownMs, unpauseMarket, } from "../admin.ts";
|
|
4
|
+
export type { AdminWithdrawParams, CreateMarketRegistryParams, DepositSettlementParams, KeeperAdminParams, MarketPauseParams, SetMinReserveParams, SetOrderCancelCooldownParams, } from "../admin.ts";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { addDelegate, createAccount, removeDelegate, requestDeposit, requestDepositFromReceivings, requestWithdraw, setDelegatePredictionPermission, transferCoinToAccount, whitelistPredictionProtocol, } from "../account.ts";
|
|
2
|
+
export type { AddDelegateParams, CreateAccountParams, RemoveDelegateParams, RequestDepositFromReceivingsParams, RequestDepositParams, RequestWithdrawParams, SetDelegatePredictionPermissionParams, TransferCoinToAccountParams, WhitelistPredictionProtocolParams, } from "../account.ts";
|
|
3
|
+
export { claim, placeOrder, requestClose, selectionArg, selfCancelClose, selfCancelOrder, } from "../prediction.ts";
|
|
4
|
+
export type { ClaimParams, PlaceOrderParams, RequestCloseParams, SelfCancelCloseParams, SelfCancelOrderParams, } from "../prediction.ts";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { addDelegate, createAccount, removeDelegate, requestDeposit, requestDepositFromReceivings, requestWithdraw, setDelegatePredictionPermission, transferCoinToAccount, whitelistPredictionProtocol, } from "../account.js";
|
|
2
|
+
export { claim, placeOrder, requestClose, selectionArg, selfCancelClose, selfCancelOrder, } from "../prediction.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { cancelClose, cancelOrder, confirmClose, fillOrder, forceClaim, outcomeArg, resolveMarket, } from "../prediction.ts";
|
|
2
|
+
export type { CancelCloseParams, CancelOrderParams, ConfirmCloseParams, FillOrderParams, ForceClaimParams, ResolveMarketParams, } from "../prediction.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cancelClose, cancelOrder, confirmClose, fillOrder, forceClaim, outcomeArg, resolveMarket, } from "../prediction.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { placeOrder, selfCancelOrder } from "../prediction.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { claim, requestClose, selfCancelClose } from "../prediction.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AccountDataViewBcs, MarketViewBcs, OrderKindBcs, OrderViewBcs, OutcomeBcs, PositionViewBcs, RegistryViewBcs, SelectionBcs, StatusBcs, mapAccountDataView, mapCursorView, mapMarketView, mapOrderKind, mapOrderView, mapOutcome, mapPositionView, mapRegistryView, mapSelection, mapStatus, } from "../bcs.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AccountDataViewBcs, MarketViewBcs, OrderKindBcs, OrderViewBcs, OutcomeBcs, PositionViewBcs, RegistryViewBcs, SelectionBcs, StatusBcs, mapAccountDataView, mapCursorView, mapMarketView, mapOrderKind, mapOrderView, mapOutcome, mapPositionView, mapRegistryView, mapSelection, mapStatus, } from "../bcs.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { assertOutcome, assertSelection, assertU64, bytesToHex, clockArg, createAccountRequest, marketIdArg, marketIdBytesFromUnknown, normalizeMarketId, objectArg, optionU64, receivingCoinArg, requireConfig, resolveAccountRegistry, resolveGlobalConfig, resolveMarketRegistry, resolvePackageId, resolveSettlementCoinType, toBigInt, } from "../utils.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { assertOutcome, assertSelection, assertU64, bytesToHex, clockArg, createAccountRequest, marketIdArg, marketIdBytesFromUnknown, normalizeMarketId, objectArg, optionU64, receivingCoinArg, requireConfig, resolveAccountRegistry, resolveGlobalConfig, resolveMarketRegistry, resolvePackageId, resolveSettlementCoinType, toBigInt, } from "../utils.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Transaction, type TransactionArgument, type TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
2
|
+
import type { PredictClient } from "./client.ts";
|
|
3
|
+
import type { AccountIdentityParams, IdArgument, MarketIdInput, ObjectArgument, Outcome, Selection } from "./types.ts";
|
|
4
|
+
export declare function assertSelection(value: string): Selection;
|
|
5
|
+
export declare function assertOutcome(value: string): Outcome;
|
|
6
|
+
export declare function requireConfig<T>(value: T | undefined, name: string): T;
|
|
7
|
+
export declare function resolvePackageId(client: PredictClient, packageId?: string): string;
|
|
8
|
+
export declare function resolveSettlementCoinType(client: PredictClient, coinType?: string): string;
|
|
9
|
+
export declare function resolveMarketRegistry(client: PredictClient, marketRegistry?: string): string;
|
|
10
|
+
export declare function resolveAccountRegistry(client: PredictClient, accountRegistry?: string): string;
|
|
11
|
+
export declare function resolveGlobalConfig(client: PredictClient, globalConfig?: string): string;
|
|
12
|
+
/** Ensures `value` is a valid unsigned 64-bit integer. */
|
|
13
|
+
export declare function assertU64(value: bigint, name?: string): bigint;
|
|
14
|
+
export declare function toBigInt(value: bigint | number | string): bigint;
|
|
15
|
+
export declare function objectArg(tx: Transaction, value: ObjectArgument): TransactionArgument;
|
|
16
|
+
export declare function idArg(tx: Transaction, value: IdArgument): TransactionArgument;
|
|
17
|
+
export declare function clockArg(tx: Transaction): TransactionArgument;
|
|
18
|
+
export declare function createAccountRequest(client: PredictClient, tx: Transaction, params?: AccountIdentityParams): TransactionArgument;
|
|
19
|
+
/** Coerces on-chain `vector<u8>` shapes used in view decoding. */
|
|
20
|
+
export declare function marketIdBytesFromUnknown(raw: unknown): Uint8Array;
|
|
21
|
+
export declare function normalizeMarketId(marketId: MarketIdInput): Uint8Array;
|
|
22
|
+
export declare function marketIdArg(tx: Transaction, marketId: MarketIdInput): TransactionArgument;
|
|
23
|
+
export declare function bytesToHex(bytes: Uint8Array | number[]): string;
|
|
24
|
+
export declare function optionU64(value: bigint | number | string | null | undefined): TransactionArgument;
|
|
25
|
+
export declare function receivingCoinArg(tx: Transaction, coin: {
|
|
26
|
+
objectId: string;
|
|
27
|
+
version: string | bigint | number;
|
|
28
|
+
digest: string;
|
|
29
|
+
}): TransactionObjectArgument;
|