@waterx/sdk 2.1.0 → 2.3.1-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -169
- package/dist/src/client.d.ts +52 -2
- package/dist/src/client.js +76 -6
- package/dist/src/config.d.ts +57 -3
- package/dist/src/config.js +10 -4
- package/dist/src/constants.d.ts +6 -0
- package/dist/src/constants.js +6 -0
- package/dist/src/core/waterx-account.d.ts +31 -0
- package/dist/src/core/waterx-account.js +26 -0
- package/dist/src/fetch.d.ts +110 -0
- package/dist/src/fetch.js +149 -4
- package/dist/src/generated/bucket_v2_framework/account.d.ts +5 -5
- package/dist/src/generated/bucket_v2_framework/double.d.ts +77 -77
- package/dist/src/generated/bucket_v2_framework/float.d.ts +73 -73
- package/dist/src/generated/bucket_v2_framework/liability.d.ts +33 -33
- package/dist/src/generated/bucket_v2_framework/linked_table.d.ts +5 -5
- package/dist/src/generated/bucket_v2_framework/linked_table.js +2 -2
- package/dist/src/generated/bucket_v2_framework/sheet.d.ts +57 -57
- package/dist/src/generated/bucket_v2_framework/sheet.js +5 -11
- package/dist/src/generated/native_custody/custody_vault.d.ts +46 -32
- package/dist/src/generated/native_custody/custody_vault.js +19 -10
- package/dist/src/generated/native_custody/deps/bucket_v2_framework/sheet.js +1 -3
- package/dist/src/generated/native_custody/events.js +1 -2
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.d.ts +7 -7
- package/dist/src/generated/pyth_sponsor_rule/pyth_sponsor_rule.js +1 -2
- package/dist/src/generated/utils/index.d.ts +7 -7
- package/dist/src/generated/utils/index.js +9 -6
- package/dist/src/generated/waterx_account/account.d.ts +124 -71
- package/dist/src/generated/waterx_account/account.js +64 -29
- package/dist/src/generated/waterx_account/deps/bucket_v2_framework/sheet.js +1 -3
- package/dist/src/generated/waterx_account/direct_rule.d.ts +5 -5
- package/dist/src/generated/waterx_account/events.d.ts +10 -0
- package/dist/src/generated/waterx_account/events.js +31 -50
- package/dist/src/generated/waterx_constant_rule/constant_rule.d.ts +68 -0
- package/dist/src/generated/waterx_constant_rule/constant_rule.js +59 -0
- package/dist/src/generated/waterx_constant_rule/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/src/generated/waterx_constant_rule/deps/bucket_v2_framework/float.js +10 -0
- package/dist/src/generated/waterx_constant_rule/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_constant_rule/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_credit/credit_registry.d.ts +9 -9
- package/dist/src/generated/waterx_credit/credit_registry.js +1 -2
- package/dist/src/generated/waterx_credit/limited_supply.d.ts +17 -17
- package/dist/src/generated/waterx_oracle/aggregator.js +1 -2
- package/dist/src/generated/waterx_oracle/collector.d.ts +17 -17
- package/dist/src/generated/waterx_oracle/collector.js +1 -1
- package/dist/src/generated/waterx_oracle/oracle.d.ts +5 -5
- package/dist/src/generated/waterx_perp/account_data.d.ts +5 -5
- package/dist/src/generated/waterx_perp/account_data.js +1 -2
- package/dist/src/generated/waterx_perp/deps/bucket_v2_framework/sheet.js +1 -3
- package/dist/src/generated/waterx_perp/events.d.ts +181 -181
- package/dist/src/generated/waterx_perp/events.js +87 -173
- package/dist/src/generated/waterx_perp/global_config.d.ts +3 -3
- package/dist/src/generated/waterx_perp/global_config.js +6 -12
- package/dist/src/generated/waterx_perp/keyed_big_vector.d.ts +9 -9
- package/dist/src/generated/waterx_perp/keyed_big_vector.js +1 -2
- package/dist/src/generated/waterx_perp/lp_pool.d.ts +115 -115
- package/dist/src/generated/waterx_perp/lp_pool.js +11 -22
- package/dist/src/generated/waterx_perp/market_config.d.ts +61 -43
- package/dist/src/generated/waterx_perp/market_config.js +29 -22
- package/dist/src/generated/waterx_perp/math.d.ts +7 -7
- package/dist/src/generated/waterx_perp/order_book.d.ts +47 -47
- package/dist/src/generated/waterx_perp/position.d.ts +99 -99
- package/dist/src/generated/waterx_perp/position.js +6 -12
- package/dist/src/generated/waterx_perp/request.d.ts +67 -67
- package/dist/src/generated/waterx_perp/request.js +2 -3
- package/dist/src/generated/waterx_perp/response.d.ts +35 -35
- package/dist/src/generated/waterx_perp/response.js +1 -2
- package/dist/src/generated/waterx_perp/trading.d.ts +303 -179
- package/dist/src/generated/waterx_perp/trading.js +99 -14
- package/dist/src/generated/waterx_perp_view/view.js +5 -10
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.d.ts +5 -5
- package/dist/src/generated/waterx_pyth_rule/pyth_rule.js +1 -2
- package/dist/src/generated/waterx_referral/referral_table.d.ts +5 -5
- package/dist/src/generated/waterx_referral/referral_table.js +1 -2
- package/dist/src/generated/waterx_staking/waterx_staking.d.ts +19 -19
- package/dist/src/generated/waterx_staking/waterx_staking.js +10 -20
- package/dist/src/generated/waterx_supra_rule/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/waterx_supra_rule/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/waterx_supra_rule/supra_rule.d.ts +158 -0
- package/dist/src/generated/waterx_supra_rule/supra_rule.js +148 -0
- package/dist/src/generated/withdrawal_queue/deps/bucket_v2_framework/float.d.ts +8 -0
- package/dist/src/generated/withdrawal_queue/deps/bucket_v2_framework/float.js +10 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/generated/withdrawal_queue/deps/sui/vec_map.js +27 -0
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.d.ts +444 -4
- package/dist/src/generated/withdrawal_queue/withdrawal_queue.js +417 -4
- package/dist/src/generated/wormhole_bridge/wormhole_bridge.d.ts +214 -74
- package/dist/src/generated/wormhole_bridge/wormhole_bridge.js +158 -29
- package/dist/src/index.d.ts +4 -3
- package/dist/src/index.js +3 -2
- package/dist/src/prediction/account.d.ts +96 -0
- package/dist/src/prediction/account.js +230 -0
- package/dist/src/prediction/admin.d.ts +47 -0
- package/dist/src/prediction/admin.js +105 -0
- package/dist/src/prediction/bcs.d.ts +22 -0
- package/dist/src/prediction/bcs.js +240 -0
- package/dist/src/prediction/client.d.ts +75 -0
- package/dist/src/prediction/client.js +164 -0
- package/dist/src/prediction/config.d.ts +60 -0
- package/dist/src/prediction/config.js +75 -0
- package/dist/src/prediction/constants.d.ts +44 -0
- package/dist/src/prediction/constants.js +46 -0
- package/dist/src/prediction/fetch.d.ts +82 -0
- package/dist/src/prediction/fetch.js +270 -0
- package/dist/src/prediction/generated/bucket_v2_framework/account.d.ts +100 -0
- package/dist/src/prediction/generated/bucket_v2_framework/account.js +129 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.d.ts +6 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/std/type_name.js +19 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.d.ts +10 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/balance.js +14 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_map.js +27 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/prediction/generated/bucket_v2_framework/deps/sui/vec_set.js +19 -0
- package/dist/src/prediction/generated/bucket_v2_framework/double.d.ts +382 -0
- package/dist/src/prediction/generated/bucket_v2_framework/double.js +466 -0
- package/dist/src/prediction/generated/bucket_v2_framework/float.d.ts +362 -0
- package/dist/src/prediction/generated/bucket_v2_framework/float.js +440 -0
- package/dist/src/prediction/generated/bucket_v2_framework/liability.d.ts +193 -0
- package/dist/src/prediction/generated/bucket_v2_framework/liability.js +205 -0
- package/dist/src/prediction/generated/bucket_v2_framework/linked_table.d.ts +384 -0
- package/dist/src/prediction/generated/bucket_v2_framework/linked_table.js +382 -0
- package/dist/src/prediction/generated/bucket_v2_framework/sheet.d.ts +344 -0
- package/dist/src/prediction/generated/bucket_v2_framework/sheet.js +338 -0
- package/dist/src/prediction/generated/utils/index.d.ts +30 -0
- package/dist/src/prediction/generated/utils/index.js +160 -0
- package/dist/src/prediction/generated/waterx_account/account.d.ts +1589 -0
- package/dist/src/prediction/generated/waterx_account/account.js +1758 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.d.ts +7 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/liability.js +13 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.d.ts +7 -0
- package/dist/src/prediction/generated/waterx_account/deps/bucket_v2_framework/sheet.js +16 -0
- package/dist/src/prediction/generated/waterx_account/deps/std/type_name.d.ts +6 -0
- package/dist/src/prediction/generated/waterx_account/deps/std/type_name.js +19 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/balance.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/balance.js +14 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.d.ts +12 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/object_table.js +19 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/table.d.ts +24 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/table.js +31 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.d.ts +36 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_map.js +27 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/prediction/generated/waterx_account/deps/sui/vec_set.js +19 -0
- package/dist/src/prediction/generated/waterx_account/direct_rule.d.ts +75 -0
- package/dist/src/prediction/generated/waterx_account/direct_rule.js +78 -0
- package/dist/src/prediction/generated/waterx_account/events.d.ts +33 -0
- package/dist/src/prediction/generated/waterx_account/events.js +137 -0
- package/dist/src/prediction/generated/waterx_account/version.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_account/version.js +8 -0
- package/dist/src/prediction/generated/waterx_prediction/account_data.d.ts +327 -0
- package/dist/src/prediction/generated/waterx_prediction/account_data.js +405 -0
- package/dist/src/prediction/generated/waterx_prediction/admin.d.ts +5 -0
- package/dist/src/prediction/generated/waterx_prediction/admin.js +9 -0
- package/dist/src/prediction/generated/waterx_prediction/bet_sharing.d.ts +60 -0
- package/dist/src/prediction/generated/waterx_prediction/bet_sharing.js +83 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/bucket_v2_framework/linked_table.d.ts +8 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/bucket_v2_framework/linked_table.js +18 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/balance.js +14 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.d.ts +24 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/table.js +31 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.d.ts +16 -0
- package/dist/src/prediction/generated/waterx_prediction/deps/sui/vec_set.js +19 -0
- package/dist/src/prediction/generated/waterx_prediction/events.d.ts +22 -0
- package/dist/src/prediction/generated/waterx_prediction/events.js +179 -0
- package/dist/src/prediction/generated/waterx_prediction/global_config.d.ts +116 -0
- package/dist/src/prediction/generated/waterx_prediction/global_config.js +141 -0
- package/dist/src/prediction/generated/waterx_prediction/order.d.ts +200 -0
- package/dist/src/prediction/generated/waterx_prediction/order.js +284 -0
- package/dist/src/prediction/generated/waterx_prediction/outcome.d.ts +58 -0
- package/dist/src/prediction/generated/waterx_prediction/outcome.js +73 -0
- package/dist/src/prediction/generated/waterx_prediction/position.d.ts +160 -0
- package/dist/src/prediction/generated/waterx_prediction/position.js +214 -0
- package/dist/src/prediction/generated/waterx_prediction/version.d.ts +10 -0
- package/dist/src/prediction/generated/waterx_prediction/version.js +8 -0
- package/dist/src/prediction/generated/waterx_prediction/view.d.ts +353 -0
- package/dist/src/prediction/generated/waterx_prediction/view.js +432 -0
- package/dist/src/prediction/generated/waterx_prediction/waterx_prediction.d.ts +1698 -0
- package/dist/src/prediction/generated/waterx_prediction/waterx_prediction.js +1733 -0
- package/dist/src/prediction/gift-link.d.ts +6 -0
- package/dist/src/prediction/gift-link.js +5 -0
- package/dist/src/prediction/gift.d.ts +223 -0
- package/dist/src/prediction/gift.js +451 -0
- package/dist/src/prediction/index.d.ts +29 -0
- package/dist/src/prediction/index.js +21 -0
- package/dist/src/prediction/prediction.d.ts +104 -0
- package/dist/src/prediction/prediction.js +317 -0
- package/dist/src/prediction/tx-builders.d.ts +44 -0
- package/dist/src/prediction/tx-builders.js +52 -0
- package/dist/src/prediction/types.d.ts +93 -0
- package/dist/src/prediction/types.js +1 -0
- package/dist/src/prediction/user/account.d.ts +2 -0
- package/dist/src/prediction/user/account.js +1 -0
- package/dist/src/prediction/user/admin.d.ts +6 -0
- package/dist/src/prediction/user/admin.js +3 -0
- package/dist/src/prediction/user/gift.d.ts +2 -0
- package/dist/src/prediction/user/gift.js +1 -0
- package/dist/src/prediction/user/index.d.ts +5 -0
- package/dist/src/prediction/user/index.js +3 -0
- package/dist/src/prediction/user/keeper.d.ts +2 -0
- package/dist/src/prediction/user/keeper.js +1 -0
- package/dist/src/prediction/user/order.d.ts +2 -0
- package/dist/src/prediction/user/order.js +1 -0
- package/dist/src/prediction/user/position.d.ts +2 -0
- package/dist/src/prediction/user/position.js +1 -0
- package/dist/src/prediction/utils/bcs.d.ts +1 -0
- package/dist/src/prediction/utils/bcs.js +1 -0
- package/dist/src/prediction/utils/index.d.ts +1 -0
- package/dist/src/prediction/utils/index.js +1 -0
- package/dist/src/prediction/utils.d.ts +30 -0
- package/dist/src/prediction/utils.js +177 -0
- package/dist/src/sdk.d.ts +18 -0
- package/dist/src/sdk.js +17 -0
- package/dist/src/tx-builders.d.ts +54 -0
- package/dist/src/tx-builders.js +141 -0
- package/dist/src/unified-client.d.ts +407 -0
- package/dist/src/unified-client.js +123 -0
- package/dist/src/user/account.d.ts +27 -0
- package/dist/src/user/account.js +34 -8
- package/dist/src/user/credit.d.ts +8 -14
- package/dist/src/user/credit.js +9 -23
- package/dist/src/user/custody.d.ts +4 -18
- package/dist/src/user/custody.js +14 -25
- package/dist/src/utils/consolidate-balance.d.ts +37 -0
- package/dist/src/utils/consolidate-balance.js +89 -0
- package/dist/src/utils/math.d.ts +86 -0
- package/dist/src/utils/math.js +100 -0
- package/dist/src/utils/pyth.d.ts +35 -3
- package/dist/src/utils/pyth.js +145 -14
- package/package.json +129 -34
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { PredictClient } from "./client.ts";
|
|
2
|
+
export type { CreateClientOptions } from "./client.ts";
|
|
3
|
+
export { clearConfigCache, defaultConfigUrl, loadConfig } from "./config.ts";
|
|
4
|
+
export type { LoadConfigOptions, WaterxAccountPackage, WaterxConfigPackageBase, WaterxPredictionConfig, WaterxPredictionConfigPackages, WaterxPredictionGiftPackage, WaterxPredictionPackage, WaterxReferralPackage, } from "./config.ts";
|
|
5
|
+
export * from "./constants.ts";
|
|
6
|
+
export * from "./types.ts";
|
|
7
|
+
export * as user from "./user/index.ts";
|
|
8
|
+
export * as utils from "./utils/index.ts";
|
|
9
|
+
export { addDelegate, allowPredictionProtocolAsset, consumeDepositDirect, consumeWithdrawDirect, createAccount, deposit, disallowPredictionProtocolAsset, removeDelegate, resolveRegistryAccountId, requestDeposit, requestDepositFromReceivings, requestWithdraw, setDelegatePredictionPermission, transferCoinToAccount, whitelistPredictionProtocol, withdraw, } from "./account.ts";
|
|
10
|
+
export type { AddDelegateParams, ConsumeDepositDirectParams, CreateAccountParams, ConsumeWithdrawDirectParams, PredictionProtocolAssetParams, RemoveDelegateParams, RequestDepositFromReceivingsParams, RequestDepositParams, RequestWithdrawParams, SetDelegatePredictionPermissionParams, TransferCoinToAccountParams, WhitelistPredictionProtocolParams, } from "./account.ts";
|
|
11
|
+
export { addKeeper, adminWithdraw, createMarketRegistry, depositSettlement, pauseMarket, removeKeeper, setMinReserve, setOrderCancelCooldownMs, unpauseMarket, } from "./admin.ts";
|
|
12
|
+
export type { AdminWithdrawParams, CreateMarketRegistryParams, DepositSettlementParams, KeeperAdminParams, MarketPauseParams, SetMinReserveParams, SetOrderCancelCooldownParams, } from "./admin.ts";
|
|
13
|
+
export { adminPlaceOrderFor, batchClaim, batchForceClaim, buildBatchForceClaimTransactions, cancelClose, cancelOrder, claim, confirmClose, fillOrder, forceClaim, outcomeArg, placeOrder, requestClose, resolveMarket, selectionArg, selfCancelClose, selfCancelOrder, } from "./prediction.ts";
|
|
14
|
+
export type { AdminPlaceOrderForParams, BatchClaimParams, BatchForceClaimParams, BuildBatchForceClaimTransactionsParams, CancelCloseParams, CancelOrderParams, ClaimParams, ConfirmCloseParams, FillOrderParams, ForceClaimParams, PlaceOrderParams, RequestCloseParams, ResolveMarketParams, SelfCancelCloseParams, SelfCancelOrderParams, } from "./prediction.ts";
|
|
15
|
+
export { buildBatchClaimTx, buildPlaceOrderTx } from "./tx-builders.ts";
|
|
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";
|
|
18
|
+
export type { GetAccountIdsParams, ViewBaseParams } from "./fetch.ts";
|
|
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
|
+
export type { BuildClaimShareFlowParams, BuildClaimShareFlowResult, BuildCreateGiftFlowResult, ClaimShareParams, CreateGiftParams, DeleteGiftParams, GiftBaseParams, GiftReferralParams, GiftUrlParts, GiftView, } from "./gift.ts";
|
|
21
|
+
export * as bucketFrameworkAccountCalls from "./generated/bucket_v2_framework/account.ts";
|
|
22
|
+
export * as waterxAccountCalls from "./generated/waterx_account/account.ts";
|
|
23
|
+
export * as predictionAccountDataCalls from "./generated/waterx_prediction/account_data.ts";
|
|
24
|
+
export * as predictionGlobalConfigCalls from "./generated/waterx_prediction/global_config.ts";
|
|
25
|
+
export * as predictionOutcomeCalls from "./generated/waterx_prediction/outcome.ts";
|
|
26
|
+
export * as predictionPositionCalls from "./generated/waterx_prediction/position.ts";
|
|
27
|
+
export * as predictionVersionCalls from "./generated/waterx_prediction/version.ts";
|
|
28
|
+
export * as predictionViewCalls from "./generated/waterx_prediction/view.ts";
|
|
29
|
+
export * as predictionCalls from "./generated/waterx_prediction/waterx_prediction.ts";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { PredictClient } from "./client.js";
|
|
2
|
+
export { clearConfigCache, defaultConfigUrl, loadConfig } from "./config.js";
|
|
3
|
+
export * from "./constants.js";
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export * as user from "./user/index.js";
|
|
6
|
+
export * as utils from "./utils/index.js";
|
|
7
|
+
export { addDelegate, allowPredictionProtocolAsset, consumeDepositDirect, consumeWithdrawDirect, createAccount, deposit, disallowPredictionProtocolAsset, removeDelegate, resolveRegistryAccountId, requestDeposit, requestDepositFromReceivings, requestWithdraw, setDelegatePredictionPermission, transferCoinToAccount, whitelistPredictionProtocol, withdraw, } from "./account.js";
|
|
8
|
+
export { addKeeper, adminWithdraw, createMarketRegistry, depositSettlement, pauseMarket, removeKeeper, setMinReserve, setOrderCancelCooldownMs, unpauseMarket, } from "./admin.js";
|
|
9
|
+
export { adminPlaceOrderFor, batchClaim, batchForceClaim, buildBatchForceClaimTransactions, cancelClose, cancelOrder, claim, confirmClose, fillOrder, forceClaim, outcomeArg, placeOrder, requestClose, resolveMarket, selectionArg, selfCancelClose, selfCancelOrder, } from "./prediction.js";
|
|
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";
|
|
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
|
+
export * as bucketFrameworkAccountCalls from "./generated/bucket_v2_framework/account.js";
|
|
14
|
+
export * as waterxAccountCalls from "./generated/waterx_account/account.js";
|
|
15
|
+
export * as predictionAccountDataCalls from "./generated/waterx_prediction/account_data.js";
|
|
16
|
+
export * as predictionGlobalConfigCalls from "./generated/waterx_prediction/global_config.js";
|
|
17
|
+
export * as predictionOutcomeCalls from "./generated/waterx_prediction/outcome.js";
|
|
18
|
+
export * as predictionPositionCalls from "./generated/waterx_prediction/position.js";
|
|
19
|
+
export * as predictionVersionCalls from "./generated/waterx_prediction/version.js";
|
|
20
|
+
export * as predictionViewCalls from "./generated/waterx_prediction/view.js";
|
|
21
|
+
export * as predictionCalls from "./generated/waterx_prediction/waterx_prediction.js";
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
globalConfig?: string;
|
|
7
|
+
marketRegistry?: string;
|
|
8
|
+
accountRegistry?: string;
|
|
9
|
+
settlementCoinType?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function selectionArg(client: PredictClient, tx: Transaction, selection: Selection | TransactionArgument, packageId?: string): TransactionArgument;
|
|
12
|
+
export declare function outcomeArg(client: PredictClient, tx: Transaction, outcome: Outcome | TransactionArgument, packageId?: string): TransactionArgument;
|
|
13
|
+
export interface PlaceOrderParams extends BasePredictionParams, AccountIdentityParams {
|
|
14
|
+
accountId: IdArgument;
|
|
15
|
+
/**
|
|
16
|
+
* Registry account that owns the filled position (defaults to `accountId`).
|
|
17
|
+
* Required by on-chain `place_order` since bet-sharing: payer and receiver may differ.
|
|
18
|
+
*/
|
|
19
|
+
receiverAccountId?: IdArgument;
|
|
20
|
+
maxSpend: bigint | number | string;
|
|
21
|
+
marketId: MarketIdInput;
|
|
22
|
+
selection: Selection | TransactionArgument;
|
|
23
|
+
minShares: bigint | number | string;
|
|
24
|
+
priceCapBps: bigint | number | string;
|
|
25
|
+
expiryTs: bigint | number | string;
|
|
26
|
+
}
|
|
27
|
+
export declare function placeOrder(client: PredictClient, tx: Transaction, params: PlaceOrderParams): Transaction;
|
|
28
|
+
export interface SelfCancelOrderParams extends BasePredictionParams, AccountIdentityParams {
|
|
29
|
+
orderId: bigint | number | string;
|
|
30
|
+
}
|
|
31
|
+
export declare function selfCancelOrder(client: PredictClient, tx: Transaction, params: SelfCancelOrderParams): Transaction;
|
|
32
|
+
export interface ClaimParams extends BasePredictionParams, AccountIdentityParams {
|
|
33
|
+
positionId: bigint | number | string;
|
|
34
|
+
}
|
|
35
|
+
export declare function claim(client: PredictClient, tx: Transaction, params: ClaimParams): Transaction;
|
|
36
|
+
export interface BatchClaimParams extends BasePredictionParams, AccountIdentityParams {
|
|
37
|
+
positionIds: readonly (bigint | number | string)[];
|
|
38
|
+
}
|
|
39
|
+
/** Chains multiple `claim` calls in one PTB, reusing a single account request. */
|
|
40
|
+
export declare function batchClaim(client: PredictClient, tx: Transaction, params: BatchClaimParams): Transaction;
|
|
41
|
+
export interface RequestCloseParams extends BasePredictionParams, AccountIdentityParams {
|
|
42
|
+
positionId: bigint | number | string;
|
|
43
|
+
minProceeds: bigint | number | string;
|
|
44
|
+
expiryTs: bigint | number | string;
|
|
45
|
+
}
|
|
46
|
+
export declare function requestClose(client: PredictClient, tx: Transaction, params: RequestCloseParams): Transaction;
|
|
47
|
+
export interface SelfCancelCloseParams extends BasePredictionParams, AccountIdentityParams {
|
|
48
|
+
positionId: bigint | number | string;
|
|
49
|
+
}
|
|
50
|
+
export declare function selfCancelClose(client: PredictClient, tx: Transaction, params: SelfCancelCloseParams): Transaction;
|
|
51
|
+
export interface KeeperBaseParams extends BasePredictionParams, AccountIdentityParams {
|
|
52
|
+
}
|
|
53
|
+
export interface FillOrderParams extends KeeperBaseParams {
|
|
54
|
+
orderId: bigint | number | string;
|
|
55
|
+
filledShares: bigint | number | string;
|
|
56
|
+
filledCost: bigint | number | string;
|
|
57
|
+
}
|
|
58
|
+
export declare function fillOrder(client: PredictClient, tx: Transaction, params: FillOrderParams): Transaction;
|
|
59
|
+
export interface CancelOrderParams extends KeeperBaseParams {
|
|
60
|
+
orderId: bigint | number | string;
|
|
61
|
+
}
|
|
62
|
+
export declare function cancelOrder(client: PredictClient, tx: Transaction, params: CancelOrderParams): Transaction;
|
|
63
|
+
export interface ConfirmCloseParams extends KeeperBaseParams {
|
|
64
|
+
positionId: bigint | number | string;
|
|
65
|
+
proceeds: bigint | number | string;
|
|
66
|
+
}
|
|
67
|
+
export declare function confirmClose(client: PredictClient, tx: Transaction, params: ConfirmCloseParams): Transaction;
|
|
68
|
+
export interface CancelCloseParams extends KeeperBaseParams {
|
|
69
|
+
positionId: bigint | number | string;
|
|
70
|
+
}
|
|
71
|
+
export declare function cancelClose(client: PredictClient, tx: Transaction, params: CancelCloseParams): Transaction;
|
|
72
|
+
export interface ForceClaimParams extends KeeperBaseParams {
|
|
73
|
+
positionId: bigint | number | string;
|
|
74
|
+
}
|
|
75
|
+
export declare function forceClaim(client: PredictClient, tx: Transaction, params: ForceClaimParams): Transaction;
|
|
76
|
+
export interface BatchForceClaimParams extends KeeperBaseParams {
|
|
77
|
+
positionIds: readonly (bigint | number | string)[];
|
|
78
|
+
}
|
|
79
|
+
/** Chains multiple `force_claim` calls in one PTB, reusing a single keeper request. */
|
|
80
|
+
export declare function batchForceClaim(client: PredictClient, tx: Transaction, params: BatchForceClaimParams): Transaction;
|
|
81
|
+
export interface BuildBatchForceClaimTransactionsParams extends BatchForceClaimParams {
|
|
82
|
+
chunkSize?: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Splits `positionIds` into multiple PTBs, each with up to `chunkSize` `force_claim`
|
|
86
|
+
* calls. Returns one unsigned `Transaction` per chunk for keeper signing.
|
|
87
|
+
*/
|
|
88
|
+
export declare function buildBatchForceClaimTransactions(client: PredictClient, params: BuildBatchForceClaimTransactionsParams): Transaction[];
|
|
89
|
+
export interface ResolveMarketParams extends KeeperBaseParams {
|
|
90
|
+
marketId: MarketIdInput;
|
|
91
|
+
outcome: Outcome | TransactionArgument;
|
|
92
|
+
}
|
|
93
|
+
export declare function resolveMarket(client: PredictClient, tx: Transaction, params: ResolveMarketParams): Transaction;
|
|
94
|
+
export interface AdminPlaceOrderForParams extends BasePredictionParams {
|
|
95
|
+
adminCap: ObjectArgument;
|
|
96
|
+
payment: ObjectArgument;
|
|
97
|
+
accountId: IdArgument;
|
|
98
|
+
marketId: MarketIdInput;
|
|
99
|
+
selection: Selection | TransactionArgument;
|
|
100
|
+
minShares: bigint | number | string;
|
|
101
|
+
priceCapBps: bigint | number | string;
|
|
102
|
+
expiryTs: bigint | number | string;
|
|
103
|
+
}
|
|
104
|
+
export declare function adminPlaceOrderFor(client: PredictClient, tx: Transaction, params: AdminPlaceOrderForParams): Transaction;
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
import { DEFAULT_FORCE_CLAIM_CHUNK_SIZE } from "./constants.js";
|
|
3
|
+
import { assertOutcome, assertSelection, clockArg, createAccountRequest, idArg, marketIdArg, objectArg, resolveAccountRegistry, resolveGlobalConfig, resolveMarketRegistry, resolvePackageId, resolveSettlementCoinType, toBigInt, } from "./utils.js";
|
|
4
|
+
export function selectionArg(client, tx, selection, packageId) {
|
|
5
|
+
if (typeof selection !== "string")
|
|
6
|
+
return selection;
|
|
7
|
+
const validated = assertSelection(selection);
|
|
8
|
+
const fn = validated === "YES" ? "selection_yes" : "selection_no";
|
|
9
|
+
const [arg] = tx.moveCall({
|
|
10
|
+
target: `${resolvePackageId(client, packageId)}::position::${fn}`,
|
|
11
|
+
});
|
|
12
|
+
return arg;
|
|
13
|
+
}
|
|
14
|
+
export function outcomeArg(client, tx, outcome, packageId) {
|
|
15
|
+
if (typeof outcome !== "string")
|
|
16
|
+
return outcome;
|
|
17
|
+
const validated = assertOutcome(outcome);
|
|
18
|
+
const fn = validated === "YES" ? "yes" : validated === "NO" ? "no" : "invalid";
|
|
19
|
+
const [arg] = tx.moveCall({
|
|
20
|
+
target: `${resolvePackageId(client, packageId)}::outcome::${fn}`,
|
|
21
|
+
});
|
|
22
|
+
return arg;
|
|
23
|
+
}
|
|
24
|
+
export function placeOrder(client, tx, params) {
|
|
25
|
+
const pkg = resolvePackageId(client, params.packageId);
|
|
26
|
+
const senderRequest = createAccountRequest(client, tx, params);
|
|
27
|
+
const receiverAccountId = params.receiverAccountId ?? params.accountId;
|
|
28
|
+
tx.moveCall({
|
|
29
|
+
target: `${pkg}::waterx_prediction::place_order`,
|
|
30
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
31
|
+
arguments: [
|
|
32
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
33
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
34
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
35
|
+
senderRequest,
|
|
36
|
+
idArg(tx, params.accountId),
|
|
37
|
+
idArg(tx, receiverAccountId),
|
|
38
|
+
tx.pure.u64(toBigInt(params.maxSpend)),
|
|
39
|
+
marketIdArg(tx, params.marketId),
|
|
40
|
+
selectionArg(client, tx, params.selection, params.packageId),
|
|
41
|
+
tx.pure.u64(toBigInt(params.minShares)),
|
|
42
|
+
tx.pure.u64(toBigInt(params.priceCapBps)),
|
|
43
|
+
tx.pure.u64(toBigInt(params.expiryTs)),
|
|
44
|
+
clockArg(tx),
|
|
45
|
+
],
|
|
46
|
+
});
|
|
47
|
+
return tx;
|
|
48
|
+
}
|
|
49
|
+
export function selfCancelOrder(client, tx, params) {
|
|
50
|
+
const senderRequest = createAccountRequest(client, tx, params);
|
|
51
|
+
tx.moveCall({
|
|
52
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::self_cancel_order`,
|
|
53
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
54
|
+
arguments: [
|
|
55
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
56
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
57
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
58
|
+
senderRequest,
|
|
59
|
+
tx.pure.u64(toBigInt(params.orderId)),
|
|
60
|
+
clockArg(tx),
|
|
61
|
+
],
|
|
62
|
+
});
|
|
63
|
+
return tx;
|
|
64
|
+
}
|
|
65
|
+
export function claim(client, tx, params) {
|
|
66
|
+
const senderRequest = createAccountRequest(client, tx, params);
|
|
67
|
+
tx.moveCall({
|
|
68
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::claim`,
|
|
69
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
70
|
+
arguments: [
|
|
71
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
72
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
73
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
74
|
+
senderRequest,
|
|
75
|
+
tx.pure.u64(toBigInt(params.positionId)),
|
|
76
|
+
clockArg(tx),
|
|
77
|
+
],
|
|
78
|
+
});
|
|
79
|
+
return tx;
|
|
80
|
+
}
|
|
81
|
+
/** Chains multiple `claim` calls in one PTB, reusing a single account request. */
|
|
82
|
+
export function batchClaim(client, tx, params) {
|
|
83
|
+
if (params.positionIds.length === 0) {
|
|
84
|
+
throw new Error("batchClaim: positionIds must not be empty");
|
|
85
|
+
}
|
|
86
|
+
const pkg = resolvePackageId(client, params.packageId);
|
|
87
|
+
const coinType = resolveSettlementCoinType(client, params.settlementCoinType);
|
|
88
|
+
const globalConfig = tx.object(resolveGlobalConfig(client, params.globalConfig));
|
|
89
|
+
const marketRegistry = tx.object(resolveMarketRegistry(client, params.marketRegistry));
|
|
90
|
+
const accountRegistry = tx.object(resolveAccountRegistry(client, params.accountRegistry));
|
|
91
|
+
const senderRequest = createAccountRequest(client, tx, params);
|
|
92
|
+
const clock = clockArg(tx);
|
|
93
|
+
for (const positionId of params.positionIds) {
|
|
94
|
+
tx.moveCall({
|
|
95
|
+
target: `${pkg}::waterx_prediction::claim`,
|
|
96
|
+
typeArguments: [coinType],
|
|
97
|
+
arguments: [
|
|
98
|
+
globalConfig,
|
|
99
|
+
marketRegistry,
|
|
100
|
+
accountRegistry,
|
|
101
|
+
senderRequest,
|
|
102
|
+
tx.pure.u64(toBigInt(positionId)),
|
|
103
|
+
clock,
|
|
104
|
+
],
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return tx;
|
|
108
|
+
}
|
|
109
|
+
export function requestClose(client, tx, params) {
|
|
110
|
+
const senderRequest = createAccountRequest(client, tx, params);
|
|
111
|
+
tx.moveCall({
|
|
112
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::request_close`,
|
|
113
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
114
|
+
arguments: [
|
|
115
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
116
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
117
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
118
|
+
senderRequest,
|
|
119
|
+
tx.pure.u64(toBigInt(params.positionId)),
|
|
120
|
+
tx.pure.u64(toBigInt(params.minProceeds)),
|
|
121
|
+
tx.pure.u64(toBigInt(params.expiryTs)),
|
|
122
|
+
clockArg(tx),
|
|
123
|
+
],
|
|
124
|
+
});
|
|
125
|
+
return tx;
|
|
126
|
+
}
|
|
127
|
+
export function selfCancelClose(client, tx, params) {
|
|
128
|
+
const senderRequest = createAccountRequest(client, tx, params);
|
|
129
|
+
tx.moveCall({
|
|
130
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::self_cancel_close`,
|
|
131
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
132
|
+
arguments: [
|
|
133
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
134
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
135
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
136
|
+
senderRequest,
|
|
137
|
+
tx.pure.u64(toBigInt(params.positionId)),
|
|
138
|
+
clockArg(tx),
|
|
139
|
+
],
|
|
140
|
+
});
|
|
141
|
+
return tx;
|
|
142
|
+
}
|
|
143
|
+
export function fillOrder(client, tx, params) {
|
|
144
|
+
const keeperRequest = createAccountRequest(client, tx, params);
|
|
145
|
+
tx.moveCall({
|
|
146
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::fill_order`,
|
|
147
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
148
|
+
arguments: [
|
|
149
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
150
|
+
keeperRequest,
|
|
151
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
152
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
153
|
+
tx.pure.u64(toBigInt(params.orderId)),
|
|
154
|
+
tx.pure.u64(toBigInt(params.filledShares)),
|
|
155
|
+
tx.pure.u64(toBigInt(params.filledCost)),
|
|
156
|
+
clockArg(tx),
|
|
157
|
+
],
|
|
158
|
+
});
|
|
159
|
+
return tx;
|
|
160
|
+
}
|
|
161
|
+
export function cancelOrder(client, tx, params) {
|
|
162
|
+
const keeperRequest = createAccountRequest(client, tx, params);
|
|
163
|
+
tx.moveCall({
|
|
164
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::cancel_order`,
|
|
165
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
166
|
+
arguments: [
|
|
167
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
168
|
+
keeperRequest,
|
|
169
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
170
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
171
|
+
tx.pure.u64(toBigInt(params.orderId)),
|
|
172
|
+
clockArg(tx),
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
return tx;
|
|
176
|
+
}
|
|
177
|
+
export function confirmClose(client, tx, params) {
|
|
178
|
+
const keeperRequest = createAccountRequest(client, tx, params);
|
|
179
|
+
tx.moveCall({
|
|
180
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::confirm_close`,
|
|
181
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
182
|
+
arguments: [
|
|
183
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
184
|
+
keeperRequest,
|
|
185
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
186
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
187
|
+
tx.pure.u64(toBigInt(params.positionId)),
|
|
188
|
+
tx.pure.u64(toBigInt(params.proceeds)),
|
|
189
|
+
clockArg(tx),
|
|
190
|
+
],
|
|
191
|
+
});
|
|
192
|
+
return tx;
|
|
193
|
+
}
|
|
194
|
+
export function cancelClose(client, tx, params) {
|
|
195
|
+
const keeperRequest = createAccountRequest(client, tx, params);
|
|
196
|
+
tx.moveCall({
|
|
197
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::cancel_close`,
|
|
198
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
199
|
+
arguments: [
|
|
200
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
201
|
+
keeperRequest,
|
|
202
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
203
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
204
|
+
tx.pure.u64(toBigInt(params.positionId)),
|
|
205
|
+
clockArg(tx),
|
|
206
|
+
],
|
|
207
|
+
});
|
|
208
|
+
return tx;
|
|
209
|
+
}
|
|
210
|
+
export function forceClaim(client, tx, params) {
|
|
211
|
+
const keeperRequest = createAccountRequest(client, tx, params);
|
|
212
|
+
tx.moveCall({
|
|
213
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::force_claim`,
|
|
214
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
215
|
+
arguments: [
|
|
216
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
217
|
+
keeperRequest,
|
|
218
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
219
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
220
|
+
tx.pure.u64(toBigInt(params.positionId)),
|
|
221
|
+
clockArg(tx),
|
|
222
|
+
],
|
|
223
|
+
});
|
|
224
|
+
return tx;
|
|
225
|
+
}
|
|
226
|
+
/** Chains multiple `force_claim` calls in one PTB, reusing a single keeper request. */
|
|
227
|
+
export function batchForceClaim(client, tx, params) {
|
|
228
|
+
if (params.positionIds.length === 0) {
|
|
229
|
+
throw new Error("batchForceClaim: positionIds must not be empty");
|
|
230
|
+
}
|
|
231
|
+
const pkg = resolvePackageId(client, params.packageId);
|
|
232
|
+
const coinType = resolveSettlementCoinType(client, params.settlementCoinType);
|
|
233
|
+
const globalConfig = tx.object(resolveGlobalConfig(client, params.globalConfig));
|
|
234
|
+
const marketRegistry = tx.object(resolveMarketRegistry(client, params.marketRegistry));
|
|
235
|
+
const accountRegistry = tx.object(resolveAccountRegistry(client, params.accountRegistry));
|
|
236
|
+
const keeperRequest = createAccountRequest(client, tx, params);
|
|
237
|
+
const clock = clockArg(tx);
|
|
238
|
+
for (const positionId of params.positionIds) {
|
|
239
|
+
tx.moveCall({
|
|
240
|
+
target: `${pkg}::waterx_prediction::force_claim`,
|
|
241
|
+
typeArguments: [coinType],
|
|
242
|
+
arguments: [
|
|
243
|
+
globalConfig,
|
|
244
|
+
keeperRequest,
|
|
245
|
+
marketRegistry,
|
|
246
|
+
accountRegistry,
|
|
247
|
+
tx.pure.u64(toBigInt(positionId)),
|
|
248
|
+
clock,
|
|
249
|
+
],
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
return tx;
|
|
253
|
+
}
|
|
254
|
+
function assertPositiveIntegerChunkSize(chunkSize, fn) {
|
|
255
|
+
if (!Number.isInteger(chunkSize) || chunkSize <= 0) {
|
|
256
|
+
throw new Error(`${fn}: chunkSize must be a positive integer`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function chunkPositionIds(items, chunkSize) {
|
|
260
|
+
const chunks = [];
|
|
261
|
+
for (let i = 0; i < items.length; i += chunkSize) {
|
|
262
|
+
chunks.push(items.slice(i, i + chunkSize));
|
|
263
|
+
}
|
|
264
|
+
return chunks;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Splits `positionIds` into multiple PTBs, each with up to `chunkSize` `force_claim`
|
|
268
|
+
* calls. Returns one unsigned `Transaction` per chunk for keeper signing.
|
|
269
|
+
*/
|
|
270
|
+
export function buildBatchForceClaimTransactions(client, params) {
|
|
271
|
+
if (params.positionIds.length === 0) {
|
|
272
|
+
throw new Error("buildBatchForceClaimTransactions: positionIds must not be empty");
|
|
273
|
+
}
|
|
274
|
+
const { positionIds, chunkSize = DEFAULT_FORCE_CLAIM_CHUNK_SIZE, ...batchParams } = params;
|
|
275
|
+
assertPositiveIntegerChunkSize(chunkSize, "buildBatchForceClaimTransactions");
|
|
276
|
+
return chunkPositionIds(positionIds, chunkSize).map((ids) => {
|
|
277
|
+
const tx = new Transaction();
|
|
278
|
+
batchForceClaim(client, tx, { ...batchParams, positionIds: ids });
|
|
279
|
+
return tx;
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
export function resolveMarket(client, tx, params) {
|
|
283
|
+
const keeperRequest = createAccountRequest(client, tx, params);
|
|
284
|
+
tx.moveCall({
|
|
285
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::resolve_market`,
|
|
286
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
287
|
+
arguments: [
|
|
288
|
+
tx.object(resolveGlobalConfig(client, params.globalConfig)),
|
|
289
|
+
keeperRequest,
|
|
290
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
291
|
+
marketIdArg(tx, params.marketId),
|
|
292
|
+
outcomeArg(client, tx, params.outcome, params.packageId),
|
|
293
|
+
clockArg(tx),
|
|
294
|
+
],
|
|
295
|
+
});
|
|
296
|
+
return tx;
|
|
297
|
+
}
|
|
298
|
+
export function adminPlaceOrderFor(client, tx, params) {
|
|
299
|
+
tx.moveCall({
|
|
300
|
+
target: `${resolvePackageId(client, params.packageId)}::waterx_prediction::admin_place_order_for`,
|
|
301
|
+
typeArguments: [resolveSettlementCoinType(client, params.settlementCoinType)],
|
|
302
|
+
arguments: [
|
|
303
|
+
objectArg(tx, params.adminCap),
|
|
304
|
+
tx.object(resolveMarketRegistry(client, params.marketRegistry)),
|
|
305
|
+
tx.object(resolveAccountRegistry(client, params.accountRegistry)),
|
|
306
|
+
objectArg(tx, params.payment),
|
|
307
|
+
idArg(tx, params.accountId),
|
|
308
|
+
marketIdArg(tx, params.marketId),
|
|
309
|
+
selectionArg(client, tx, params.selection, params.packageId),
|
|
310
|
+
tx.pure.u64(toBigInt(params.minShares)),
|
|
311
|
+
tx.pure.u64(toBigInt(params.priceCapBps)),
|
|
312
|
+
tx.pure.u64(toBigInt(params.expiryTs)),
|
|
313
|
+
clockArg(tx),
|
|
314
|
+
],
|
|
315
|
+
});
|
|
316
|
+
return tx;
|
|
317
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async high-level prediction PTB builders with optional pre-sweep of parked
|
|
3
|
+
* backing assets into wxUSD credit ({@link appendConsolidateForSpend}).
|
|
4
|
+
*
|
|
5
|
+
* Takes both `WaterXClient` (native_custody / consolidate) and `PredictClient`
|
|
6
|
+
* because sync prediction builders only target the prediction deployment.
|
|
7
|
+
*
|
|
8
|
+
* FE/BE tx services should call these instead of hand-composing
|
|
9
|
+
* `appendConsolidateForSpend` before `placeOrder` / `batchClaim`.
|
|
10
|
+
*/
|
|
11
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
12
|
+
import type { WaterXClient } from "../client.ts";
|
|
13
|
+
import type { PredictClient } from "./client.ts";
|
|
14
|
+
import { type BatchClaimParams, type PlaceOrderParams } from "./prediction.ts";
|
|
15
|
+
export interface PredictCommonBuildOpts {
|
|
16
|
+
tx?: Transaction;
|
|
17
|
+
/**
|
|
18
|
+
* Pre-sweep parked backing assets (USDC, USDsui, …) and address CREDIT at
|
|
19
|
+
* the wxa account's address into spendable wxUSD before the main action —
|
|
20
|
+
* same semantics as perp {@link CommonBuildOpts.consolidateToUsd}. Default:
|
|
21
|
+
* `true`.
|
|
22
|
+
*
|
|
23
|
+
* Requires `accountId` to be a plain address string (not a PTB argument).
|
|
24
|
+
* When `accountId` is a dynamic `TransactionArgument`, the sweep is skipped.
|
|
25
|
+
*/
|
|
26
|
+
consolidateToUsd?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export type BuildPlaceOrderTxParams = PlaceOrderParams & PredictCommonBuildOpts;
|
|
29
|
+
/** Same as {@link BatchClaimParams} plus `accountId` for the consolidate probe. */
|
|
30
|
+
export interface BuildBatchClaimTxParams extends BatchClaimParams, PredictCommonBuildOpts {
|
|
31
|
+
/** wxa account object id — owner address for the pre-sweep probe. */
|
|
32
|
+
accountId: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Optional pre-sweep + {@link placeOrder} in one PTB.
|
|
36
|
+
*
|
|
37
|
+
* @param perpClient — perp deployment (native_custody probe + PSM mint legs)
|
|
38
|
+
* @param predictClient — prediction deployment (place_order MoveCall)
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildPlaceOrderTx(perpClient: WaterXClient, predictClient: PredictClient, params: BuildPlaceOrderTxParams): Promise<Transaction>;
|
|
41
|
+
/**
|
|
42
|
+
* Optional pre-sweep + {@link batchClaim} in one PTB.
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildBatchClaimTx(perpClient: WaterXClient, predictClient: PredictClient, params: BuildBatchClaimTxParams): Promise<Transaction>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async high-level prediction PTB builders with optional pre-sweep of parked
|
|
3
|
+
* backing assets into wxUSD credit ({@link appendConsolidateForSpend}).
|
|
4
|
+
*
|
|
5
|
+
* Takes both `WaterXClient` (native_custody / consolidate) and `PredictClient`
|
|
6
|
+
* because sync prediction builders only target the prediction deployment.
|
|
7
|
+
*
|
|
8
|
+
* FE/BE tx services should call these instead of hand-composing
|
|
9
|
+
* `appendConsolidateForSpend` before `placeOrder` / `batchClaim`.
|
|
10
|
+
*/
|
|
11
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
12
|
+
import { appendConsolidateForSpend } from "../tx-builders.js";
|
|
13
|
+
import { batchClaim, placeOrder, } from "./prediction.js";
|
|
14
|
+
function newTx(opts) {
|
|
15
|
+
return opts?.tx ?? new Transaction();
|
|
16
|
+
}
|
|
17
|
+
async function maybeConsolidate(perpClient, tx, accountId, opts) {
|
|
18
|
+
if (opts?.consolidateToUsd === false)
|
|
19
|
+
return;
|
|
20
|
+
if (typeof accountId !== "string")
|
|
21
|
+
return;
|
|
22
|
+
await appendConsolidateForSpend(perpClient, tx, accountId);
|
|
23
|
+
}
|
|
24
|
+
function stripPlaceOrderParams(params) {
|
|
25
|
+
const { tx: _tx, consolidateToUsd: _consolidate, ...rest } = params;
|
|
26
|
+
return rest;
|
|
27
|
+
}
|
|
28
|
+
function stripBatchClaimParams(params) {
|
|
29
|
+
const { tx: _tx, consolidateToUsd: _consolidate, accountId: _accountId, ...rest } = params;
|
|
30
|
+
return rest;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Optional pre-sweep + {@link placeOrder} in one PTB.
|
|
34
|
+
*
|
|
35
|
+
* @param perpClient — perp deployment (native_custody probe + PSM mint legs)
|
|
36
|
+
* @param predictClient — prediction deployment (place_order MoveCall)
|
|
37
|
+
*/
|
|
38
|
+
export async function buildPlaceOrderTx(perpClient, predictClient, params) {
|
|
39
|
+
const tx = newTx(params);
|
|
40
|
+
await maybeConsolidate(perpClient, tx, params.accountId, params);
|
|
41
|
+
placeOrder(predictClient, tx, stripPlaceOrderParams(params));
|
|
42
|
+
return tx;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Optional pre-sweep + {@link batchClaim} in one PTB.
|
|
46
|
+
*/
|
|
47
|
+
export async function buildBatchClaimTx(perpClient, predictClient, params) {
|
|
48
|
+
const tx = newTx(params);
|
|
49
|
+
await maybeConsolidate(perpClient, tx, params.accountId, params);
|
|
50
|
+
batchClaim(predictClient, tx, stripBatchClaimParams(params));
|
|
51
|
+
return tx;
|
|
52
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
createdTs: bigint;
|
|
37
|
+
byAdmin: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface PositionView {
|
|
40
|
+
positionId: bigint;
|
|
41
|
+
accountId: string;
|
|
42
|
+
marketId: Uint8Array;
|
|
43
|
+
marketIdHex: string;
|
|
44
|
+
selection: Selection;
|
|
45
|
+
status: PositionStatus;
|
|
46
|
+
filledShares: bigint;
|
|
47
|
+
filledCost: bigint;
|
|
48
|
+
openedTs: bigint;
|
|
49
|
+
payout: bigint;
|
|
50
|
+
closeOrderId: bigint | null;
|
|
51
|
+
closeMinProceeds: bigint;
|
|
52
|
+
closeExpiryTs: bigint;
|
|
53
|
+
closeSelfCancelAfterTs: bigint;
|
|
54
|
+
}
|
|
55
|
+
export interface MarketView {
|
|
56
|
+
marketKey: bigint;
|
|
57
|
+
marketId: Uint8Array;
|
|
58
|
+
marketIdHex: string;
|
|
59
|
+
resolved: boolean;
|
|
60
|
+
paused: boolean;
|
|
61
|
+
outcome: Outcome | null;
|
|
62
|
+
unclaimedCount: bigint;
|
|
63
|
+
yesShares: bigint;
|
|
64
|
+
yesCost: bigint;
|
|
65
|
+
noShares: bigint;
|
|
66
|
+
noCost: bigint;
|
|
67
|
+
}
|
|
68
|
+
export interface MarketExposure {
|
|
69
|
+
yesShares: bigint;
|
|
70
|
+
yesCost: bigint;
|
|
71
|
+
noShares: bigint;
|
|
72
|
+
noCost: bigint;
|
|
73
|
+
}
|
|
74
|
+
export interface AccountDataView {
|
|
75
|
+
accountId: string;
|
|
76
|
+
hasData: boolean;
|
|
77
|
+
orderCount: bigint;
|
|
78
|
+
positionCount: bigint;
|
|
79
|
+
orderFront: bigint | null;
|
|
80
|
+
orderBack: bigint | null;
|
|
81
|
+
positionFront: bigint | null;
|
|
82
|
+
positionBack: bigint | null;
|
|
83
|
+
}
|
|
84
|
+
export interface CursorView {
|
|
85
|
+
count: bigint;
|
|
86
|
+
front: bigint | null;
|
|
87
|
+
back: bigint | null;
|
|
88
|
+
}
|
|
89
|
+
export interface CoinRef {
|
|
90
|
+
objectId: string;
|
|
91
|
+
version: string | bigint | number;
|
|
92
|
+
digest: string;
|
|
93
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|