@mysten/deepbook-v3 2.6.4 → 2.8.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/CHANGELOG.md +153 -0
- package/PREDICT.md +389 -61
- package/dist/contracts/account/account.d.mts +23 -23
- package/dist/contracts/account/account.d.mts.map +1 -1
- package/dist/contracts/account/account_registry.d.mts +13 -13
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook_predict/admin.d.mts +4 -4
- package/dist/contracts/deepbook_predict/builder_code.d.mts +11 -11
- package/dist/contracts/deepbook_predict/builder_code_events.d.mts +10 -10
- package/dist/contracts/deepbook_predict/config_events.d.mts +93 -68
- package/dist/contracts/deepbook_predict/config_events.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/config_events.mjs +45 -1
- package/dist/contracts/deepbook_predict/config_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/deps/std/type_name.mjs +17 -0
- package/dist/contracts/deepbook_predict/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_market.d.mts +652 -235
- package/dist/contracts/deepbook_predict/expiry_market.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/expiry_market.mjs +652 -186
- package/dist/contracts/deepbook_predict/expiry_market.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/lp_book.mjs +1 -1
- package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/market_manager.d.mts +27 -27
- package/dist/contracts/deepbook_predict/order_events.d.mts +50 -50
- package/dist/contracts/deepbook_predict/order_events.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/order_events.mjs +3 -1
- package/dist/contracts/deepbook_predict/order_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pause_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/plp.d.mts +184 -82
- package/dist/contracts/deepbook_predict/plp.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/plp.mjs +126 -7
- package/dist/contracts/deepbook_predict/plp.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pool_accounting.mjs +1 -1
- package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/predict_account.d.mts +14 -14
- package/dist/contracts/deepbook_predict/pricing.d.mts +91 -58
- package/dist/contracts/deepbook_predict/pricing.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/pricing.mjs +30 -3
- package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pricing_config.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/protocol_config.d.mts +400 -92
- package/dist/contracts/deepbook_predict/protocol_config.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/protocol_config.mjs +451 -61
- package/dist/contracts/deepbook_predict/protocol_config.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/range_codec.d.mts +2 -2
- package/dist/contracts/deepbook_predict/registry.d.mts +28 -28
- package/dist/contracts/deepbook_predict/strike_exposure.mjs +1 -1
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs +17 -12
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/vault_events.d.mts +154 -106
- package/dist/contracts/deepbook_predict/vault_events.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/vault_events.mjs +57 -1
- package/dist/contracts/deepbook_predict/vault_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict_math/config-arguments.d.mts +10 -0
- package/dist/contracts/deepbook_predict_math/config-arguments.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.d.mts +106 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.mjs +125 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_math/math.d.mts +284 -0
- package/dist/contracts/deepbook_predict_math/math.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_math/math.mjs +364 -0
- package/dist/contracts/deepbook_predict_math/math.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/config-arguments.d.mts +13 -0
- package/dist/contracts/deepbook_predict_orders/config-arguments.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.d.mts +215 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.mjs +215 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.mjs +87 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/pricing.mjs +52 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/pricing.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/fixed_math/i64.mjs +25 -0
- package/dist/contracts/deepbook_predict_orders/deps/fixed_math/i64.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/balance.mjs +21 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/table.mjs +39 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/desk.d.mts +187 -0
- package/dist/contracts/deepbook_predict_orders/desk.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/desk.mjs +261 -0
- package/dist/contracts/deepbook_predict_orders/desk.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.d.mts +1042 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.mjs +849 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue.d.mts +683 -0
- package/dist/contracts/deepbook_predict_orders/queue.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue.mjs +912 -0
- package/dist/contracts/deepbook_predict_orders/queue.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.d.mts +195 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.mjs +187 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.mjs.map +1 -0
- package/dist/contracts/deepbook_sessions/session_config.d.mts +8 -8
- package/dist/contracts/deepbook_sessions/sessions.d.mts +163 -28
- package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -1
- package/dist/contracts/deepbook_sessions/sessions.mjs +234 -5
- package/dist/contracts/deepbook_sessions/sessions.mjs.map +1 -1
- package/dist/deployments/mainnet.mjs +7 -4
- package/dist/deployments/mainnet.mjs.map +1 -1
- package/dist/deployments/testnet.mjs +7 -4
- package/dist/deployments/testnet.mjs.map +1 -1
- package/dist/predict/bindings/expiry-market.d.mts +77 -0
- package/dist/predict/bindings/expiry-market.d.mts.map +1 -0
- package/dist/predict/bindings/expiry-market.mjs +139 -0
- package/dist/predict/bindings/expiry-market.mjs.map +1 -0
- package/dist/predict/bindings/protocol-config.d.mts +39 -0
- package/dist/predict/bindings/protocol-config.d.mts.map +1 -0
- package/dist/predict/bindings/protocol-config.mjs +90 -0
- package/dist/predict/bindings/protocol-config.mjs.map +1 -0
- package/dist/predict/bindings/rename.mjs +9 -0
- package/dist/predict/bindings/rename.mjs.map +1 -0
- package/dist/predict/client.d.mts +595 -16
- package/dist/predict/client.d.mts.map +1 -1
- package/dist/predict/client.mjs +986 -10
- package/dist/predict/client.mjs.map +1 -1
- package/dist/predict/config/generated.d.mts +22 -1
- package/dist/predict/config/generated.d.mts.map +1 -1
- package/dist/predict/config/generated.mjs +30 -1
- package/dist/predict/config/generated.mjs.map +1 -1
- package/dist/predict/config/mainnet.mjs +11 -3
- package/dist/predict/config/mainnet.mjs.map +1 -1
- package/dist/predict/config/testnet.mjs +11 -3
- package/dist/predict/config/testnet.mjs.map +1 -1
- package/dist/predict/config/types.d.mts +50 -1
- package/dist/predict/config/types.d.mts.map +1 -1
- package/dist/predict/cost.d.mts +38 -11
- package/dist/predict/cost.d.mts.map +1 -1
- package/dist/predict/cost.mjs +37 -11
- package/dist/predict/cost.mjs.map +1 -1
- package/dist/predict/decode.d.mts +251 -1
- package/dist/predict/decode.d.mts.map +1 -1
- package/dist/predict/decode.mjs +342 -4
- package/dist/predict/decode.mjs.map +1 -1
- package/dist/predict/errors.d.mts +69 -6
- package/dist/predict/errors.d.mts.map +1 -1
- package/dist/predict/errors.mjs +277 -4
- package/dist/predict/errors.mjs.map +1 -1
- package/dist/predict/index.d.mts +21 -10
- package/dist/predict/index.mjs +24 -12
- package/dist/predict/queue-id.d.mts +13 -0
- package/dist/predict/queue-id.d.mts.map +1 -0
- package/dist/predict/queue-id.mjs +19 -0
- package/dist/predict/queue-id.mjs.map +1 -0
- package/dist/predict/queue.d.mts +505 -0
- package/dist/predict/queue.d.mts.map +1 -0
- package/dist/predict/queue.mjs +774 -0
- package/dist/predict/queue.mjs.map +1 -0
- package/dist/predict/reads/balances.mjs +1 -1
- package/dist/predict/reads/markets.mjs +46 -5
- package/dist/predict/reads/markets.mjs.map +1 -1
- package/dist/predict/reads/pool.mjs +1 -1
- package/dist/predict/reads/pricing.d.mts +1 -1
- package/dist/predict/reads/queue.d.mts +105 -0
- package/dist/predict/reads/queue.d.mts.map +1 -0
- package/dist/predict/reads/queue.mjs +445 -0
- package/dist/predict/reads/queue.mjs.map +1 -0
- package/dist/predict/ticks.d.mts +9 -1
- package/dist/predict/ticks.d.mts.map +1 -1
- package/dist/predict/ticks.mjs +18 -1
- package/dist/predict/ticks.mjs.map +1 -1
- package/dist/predict/tx/authed.mjs +1 -1
- package/dist/predict/tx/common.d.mts.map +1 -1
- package/dist/predict/tx/common.mjs +12 -1
- package/dist/predict/tx/common.mjs.map +1 -1
- package/dist/predict/tx/queue.d.mts +220 -0
- package/dist/predict/tx/queue.d.mts.map +1 -0
- package/dist/predict/tx/queue.mjs +399 -0
- package/dist/predict/tx/queue.mjs.map +1 -0
- package/dist/predict/tx/trade.d.mts.map +1 -1
- package/dist/predict/tx/trade.mjs +61 -43
- package/dist/predict/tx/trade.mjs.map +1 -1
- package/dist/sessions.d.mts +90 -2
- package/dist/sessions.d.mts.map +1 -1
- package/dist/sessions.mjs +107 -2
- package/dist/sessions.mjs.map +1 -1
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/balanceManager.d.mts.map +1 -1
- package/dist/transactions/deepbook.d.mts +20 -20
- package/dist/transactions/deepbook.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.d.mts +4 -4
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +7 -7
- package/dist/transactions/marginAdmin.d.mts.map +1 -1
- package/dist/transactions/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginMaintainer.d.mts.map +1 -1
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginRegistry.d.mts +16 -16
- package/dist/transactions/marginTPSL.d.mts +10 -10
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/poolProxy.d.mts +8 -8
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/package.json +4 -4
- package/src/contracts/deepbook_predict/config_events.ts +39 -0
- package/src/contracts/deepbook_predict/deps/std/type_name.ts +24 -0
- package/src/contracts/deepbook_predict/expiry_market.ts +960 -169
- package/src/contracts/deepbook_predict/order_events.ts +3 -1
- package/src/contracts/deepbook_predict/plp.ts +150 -9
- package/src/contracts/deepbook_predict/pricing.ts +46 -7
- package/src/contracts/deepbook_predict/pricing_config.ts +3 -1
- package/src/contracts/deepbook_predict/protocol_config.ts +648 -33
- package/src/contracts/deepbook_predict/strike_payout_tree.ts +25 -21
- package/src/contracts/deepbook_predict/vault_events.ts +65 -0
- package/src/contracts/deepbook_predict_math/config-arguments.ts +6 -0
- package/src/contracts/deepbook_predict_math/lazer_price.ts +196 -0
- package/src/contracts/deepbook_predict_math/math.ts +553 -0
- package/src/contracts/deepbook_predict_orders/config-arguments.ts +11 -0
- package/src/contracts/deepbook_predict_orders/delayed_execution_config.ts +430 -0
- package/src/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.ts +108 -0
- package/src/contracts/deepbook_predict_orders/deps/deepbook_predict/pricing.ts +58 -0
- package/src/contracts/deepbook_predict_orders/deps/fixed_math/i64.ts +21 -0
- package/src/contracts/deepbook_predict_orders/deps/sui/balance.ts +19 -0
- package/src/contracts/deepbook_predict_orders/deps/sui/table.ts +37 -0
- package/src/contracts/deepbook_predict_orders/desk.ts +419 -0
- package/src/contracts/deepbook_predict_orders/order_flow.ts +19 -0
- package/src/contracts/deepbook_predict_orders/order_queue.ts +1670 -0
- package/src/contracts/deepbook_predict_orders/queue.ts +1394 -0
- package/src/contracts/deepbook_predict_orders/queue_events.ts +189 -0
- package/src/contracts/deepbook_sessions/sessions.ts +355 -4
- package/src/deployments/mainnet.ts +7 -2
- package/src/deployments/testnet.ts +7 -2
- package/src/deployments/types.ts +14 -1
- package/src/predict/bindings/expiry-market.ts +127 -0
- package/src/predict/bindings/protocol-config.ts +59 -0
- package/src/predict/bindings/rename.ts +14 -0
- package/src/predict/client.ts +2076 -13
- package/src/predict/config/generated.ts +50 -0
- package/src/predict/config/mainnet.ts +16 -2
- package/src/predict/config/testnet.ts +16 -2
- package/src/predict/config/types.ts +51 -1
- package/src/predict/cost.ts +62 -14
- package/src/predict/decode.ts +691 -2
- package/src/predict/errors.ts +391 -14
- package/src/predict/index.ts +87 -6
- package/src/predict/queue-id.ts +22 -0
- package/src/predict/queue.ts +1231 -0
- package/src/predict/reads/markets.ts +30 -0
- package/src/predict/reads/queue.ts +606 -0
- package/src/predict/ticks.ts +35 -0
- package/src/predict/tx/common.ts +25 -1
- package/src/predict/tx/queue.ts +525 -0
- package/src/predict/tx/trade.ts +80 -49
- package/src/sessions.ts +206 -1
package/src/predict/errors.ts
CHANGED
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
// Two failure kinds cross the SDK boundary:
|
|
6
6
|
// - PredictInputError — a caller gave us something we rejected before touching
|
|
7
7
|
// the chain (unknown underlying, malformed argument, …).
|
|
8
|
-
// - PredictMoveError — a Move `abort` surfaced by a read/simulate.
|
|
9
|
-
//
|
|
10
|
-
// `
|
|
11
|
-
//
|
|
12
|
-
// of maintaining a module→code→name table that goes stale on every redeploy.
|
|
8
|
+
// - PredictMoveError — a Move `abort` surfaced by a read/simulate. Predict's error
|
|
9
|
+
// constants are plain `u64` codes, not clever errors, so the fullnode can't name
|
|
10
|
+
// them: `decodeMoveAbort` maps `(module, code)` to the constant name with
|
|
11
|
+
// ABORT_NAMES below. A clever-error name the fullnode does decode takes precedence.
|
|
13
12
|
|
|
14
13
|
/** A caller-supplied argument the SDK rejected before building/sending a tx. */
|
|
15
14
|
export class PredictInputError extends Error {
|
|
@@ -25,9 +24,9 @@ export class PredictMoveError extends Error {
|
|
|
25
24
|
/** Exact u64 abort code — bigint because clever-error encodings pack data
|
|
26
25
|
* into the high bits, which Number would silently truncate. */
|
|
27
26
|
readonly code: bigint;
|
|
28
|
-
/** The `E…` constant name
|
|
29
|
-
*
|
|
30
|
-
*
|
|
27
|
+
/** The `E…` constant name: the fullnode's clever-error name when it decodes
|
|
28
|
+
* one, else the name {@link ABORT_NAMES} gives the module's plain code, or null
|
|
29
|
+
* when neither knows the abort. */
|
|
31
30
|
readonly abortName: string | null;
|
|
32
31
|
|
|
33
32
|
constructor(module: string, code: bigint, abortName: string | null) {
|
|
@@ -52,9 +51,9 @@ export class PredictMoveError extends Error {
|
|
|
52
51
|
// - `MoveAbort.location.module` → the aborting module's short name.
|
|
53
52
|
// - `MoveAbort.cleverError.constantName` → the `E…` error constant, decoded by the
|
|
54
53
|
// fullnode from the clever-error bits of the abort code and surfaced by the gRPC
|
|
55
|
-
// (`grpc/core.ts` parseMoveAbort) and GraphQL transports.
|
|
56
|
-
//
|
|
57
|
-
//
|
|
54
|
+
// (`grpc/core.ts` parseMoveAbort) and GraphQL transports. Only a clever-error abort
|
|
55
|
+
// carries one, and Predict's plain `u64` constants never do, so ABORT_NAMES names
|
|
56
|
+
// those. JSON-RPC surfaces no `constantName` at all.
|
|
58
57
|
export interface MoveAbortError {
|
|
59
58
|
MoveAbort?: {
|
|
60
59
|
abortCode?: string | number | bigint;
|
|
@@ -63,13 +62,210 @@ export interface MoveAbortError {
|
|
|
63
62
|
};
|
|
64
63
|
}
|
|
65
64
|
|
|
65
|
+
/**
|
|
66
|
+
* The error constants of the Predict modules the SDK's flows abort in, by module, as an array
|
|
67
|
+
* indexed by the plain `u64` abort code (each module numbers its constants from 0 with no gaps).
|
|
68
|
+
* Generated from the Move sources at deepbookv3 29117434. A published code never changes meaning:
|
|
69
|
+
* new codes only append, so an older package version's codes are a prefix of its module's list.
|
|
70
|
+
* Keyed by module name only, as the abort location reports it, so a same-named module in an
|
|
71
|
+
* unrelated package would be named from this table too.
|
|
72
|
+
*/
|
|
73
|
+
export const ABORT_NAMES: Readonly<Record<string, readonly string[]>> = Object.freeze({
|
|
74
|
+
// Predict (`deepbook_predict`). Append-only since v1, so older package versions use a prefix.
|
|
75
|
+
expiry_market: [
|
|
76
|
+
'EMintPaused',
|
|
77
|
+
'EMarketNotSettled',
|
|
78
|
+
'EMintCostAboveMax',
|
|
79
|
+
'EMintProbabilityAboveMax',
|
|
80
|
+
'EWrongPricer',
|
|
81
|
+
'EReferenceTickObservationMissing',
|
|
82
|
+
'EMintRedeemSameTimestamp',
|
|
83
|
+
'ERedeemProbabilityBelowMin',
|
|
84
|
+
'ERedeemProceedsBelowMin',
|
|
85
|
+
'EMintCostCapRequired',
|
|
86
|
+
'EMarketNotPendingValuation',
|
|
87
|
+
'EMintCostAboveMaxPayout',
|
|
88
|
+
'ENotSettledRedeemKeeper',
|
|
89
|
+
'EDelayedExecutionRequired',
|
|
90
|
+
'EOrderFailsLimits',
|
|
91
|
+
'EInsufficientMarketCash',
|
|
92
|
+
'EInvalidOrderTiming',
|
|
93
|
+
'EInvalidOrderTerms',
|
|
94
|
+
'EWrongMarket',
|
|
95
|
+
'EWrongStage',
|
|
96
|
+
'ENotRecordOwner',
|
|
97
|
+
'EEscrowMismatch',
|
|
98
|
+
'EWrongPrice',
|
|
99
|
+
],
|
|
100
|
+
protocol_config: [
|
|
101
|
+
'ETradingPaused',
|
|
102
|
+
'EValuationInProgress',
|
|
103
|
+
'EValuationNotInProgress',
|
|
104
|
+
'EPackageVersionDisabled',
|
|
105
|
+
'EVersionWatermarkNotAdvanced',
|
|
106
|
+
'EProtocolFrozen',
|
|
107
|
+
'ESnapshotInProgress',
|
|
108
|
+
'ETradeWindowClosed',
|
|
109
|
+
'ESettledRedeemKeeperAlreadyAdded',
|
|
110
|
+
'ESettledRedeemKeeperNotFound',
|
|
111
|
+
'EFlushOperatorAlreadyAdded',
|
|
112
|
+
'EFlushOperatorNotFound',
|
|
113
|
+
'ENotFlushOperator',
|
|
114
|
+
'ECutoverNotReached',
|
|
115
|
+
'EEwmaRetired',
|
|
116
|
+
'EOrderFlowNotAllowed',
|
|
117
|
+
],
|
|
118
|
+
// Predict's live pricer, which every quote, plan and enqueue loads.
|
|
119
|
+
pricing: [
|
|
120
|
+
'EZeroForward',
|
|
121
|
+
'ECannotBeNegative',
|
|
122
|
+
'ENonPositiveVariance',
|
|
123
|
+
'EInvalidRange',
|
|
124
|
+
'EBlockScholesPriceStale',
|
|
125
|
+
'EBlockScholesInputsInvalid',
|
|
126
|
+
'EPythSpotInvalid',
|
|
127
|
+
'EWrongPythFeed',
|
|
128
|
+
'EWrongBlockScholesValueStore',
|
|
129
|
+
'ELivePricingExpired',
|
|
130
|
+
'EBlockScholesSVIStale',
|
|
131
|
+
'EWrongBlockScholesSVIStore',
|
|
132
|
+
'EBlockScholesPriceUnavailable',
|
|
133
|
+
'EBlockScholesSVIUnavailable',
|
|
134
|
+
'EBlockScholesMinVarianceInvalid',
|
|
135
|
+
'EOracleWrittenInThisTransaction',
|
|
136
|
+
'EBlockScholesInputTooWide',
|
|
137
|
+
'EPythSpotUnavailable',
|
|
138
|
+
'EPythSpotStale',
|
|
139
|
+
'EPythForwardRequired',
|
|
140
|
+
],
|
|
141
|
+
// Admission, positions and the LP pool. `order` and `registry` are left out: DeepBook's core
|
|
142
|
+
// package has modules of the same names, which this table would misname.
|
|
143
|
+
strike_exposure: [
|
|
144
|
+
'EInvalidCloseQuantity',
|
|
145
|
+
'EInvalidAdmissionTick',
|
|
146
|
+
'EInvalidReferenceTick',
|
|
147
|
+
'EReferenceTickAlreadySet',
|
|
148
|
+
'ETermsExposureMismatch',
|
|
149
|
+
'EMintQuantityBelowMin',
|
|
150
|
+
'EInvalidInventoryImpactScale',
|
|
151
|
+
],
|
|
152
|
+
strike_exposure_config: [
|
|
153
|
+
'EEntryProbabilityOutOfBounds',
|
|
154
|
+
'EInvalidEntryProbabilityBound',
|
|
155
|
+
'EInvalidFeeProbability',
|
|
156
|
+
'EPremiumBelowMinimum',
|
|
157
|
+
],
|
|
158
|
+
strike_payout_tree: [
|
|
159
|
+
'EInsufficientPayoutQuantity',
|
|
160
|
+
'EMaxPayoutTreeNodes',
|
|
161
|
+
'ENonMonotonePrice',
|
|
162
|
+
'EStaleValuationSnapshot',
|
|
163
|
+
'ESnapshotSeqNotIncreasing',
|
|
164
|
+
'ENodeMissing',
|
|
165
|
+
],
|
|
166
|
+
expiry_cash: ['EInsufficientCash', 'EInventoryImpactRebateExceedsReserve'],
|
|
167
|
+
predict_account: ['EPositionAlreadyExists', 'EPositionNotFound'],
|
|
168
|
+
builder_code: ['ENotOwner'],
|
|
169
|
+
plp: [
|
|
170
|
+
'EMissingExpiryValuation',
|
|
171
|
+
'ENotBootstrapped',
|
|
172
|
+
'EAlreadyBootstrapped',
|
|
173
|
+
'EBelowMinBootstrapLiquidity',
|
|
174
|
+
'EBelowMinFeeIncentiveSponsorship',
|
|
175
|
+
'EMaxLiveExpiryMarketsExceeded',
|
|
176
|
+
'EValuationSnapshotNotSealed',
|
|
177
|
+
'EExpiryPricerAlreadySnapshotted',
|
|
178
|
+
'EIncompleteValuationSnapshot',
|
|
179
|
+
'EExpiredMarketNotSettled',
|
|
180
|
+
'EValuationWindowExpired',
|
|
181
|
+
'ESnapshotStageOpen',
|
|
182
|
+
'EBelowMinUsdcContribution',
|
|
183
|
+
'EContributionExceedsPriceCeiling',
|
|
184
|
+
'EInsufficientFeeIncentiveReserve',
|
|
185
|
+
],
|
|
186
|
+
lp_book: [
|
|
187
|
+
'ERequestNotFound',
|
|
188
|
+
'EBelowMinSupplyRequest',
|
|
189
|
+
'EBelowMinWithdrawRequest',
|
|
190
|
+
'ENotRequestOwner',
|
|
191
|
+
],
|
|
192
|
+
pool_accounting: [
|
|
193
|
+
'EUnknownRegisteredExpiry',
|
|
194
|
+
'ERegisteredExpiryAlreadyExists',
|
|
195
|
+
'EMaxExpiryFundingExceeded',
|
|
196
|
+
'ETerminalAccountingStarted',
|
|
197
|
+
],
|
|
198
|
+
// The order-flow package (`deepbook_predict_orders`).
|
|
199
|
+
queue: [
|
|
200
|
+
'EWrongDesk',
|
|
201
|
+
'EWrongMarket',
|
|
202
|
+
'EQueueStuck',
|
|
203
|
+
'EQueueFull',
|
|
204
|
+
'EAccountOrderCap',
|
|
205
|
+
'EPastCutoff',
|
|
206
|
+
'EMintCostCapRequired',
|
|
207
|
+
'EFeeNotCovered',
|
|
208
|
+
'EBelowMinSell',
|
|
209
|
+
'ERecordNotOpen',
|
|
210
|
+
'ENotRecordOwner',
|
|
211
|
+
'EMarketNotSettled',
|
|
212
|
+
'EMarketNotExpired',
|
|
213
|
+
],
|
|
214
|
+
desk: ['EPackageVersionDisabled', 'EVersionWatermarkNotAdvanced', 'EProtocolFrozen'],
|
|
215
|
+
order_queue: ['ERecordNotOpen'],
|
|
216
|
+
delayed_execution_config: [
|
|
217
|
+
'EInvalidDelayMs',
|
|
218
|
+
'EInvalidStallTimeoutMs',
|
|
219
|
+
'EInvalidStuckThresholdMs',
|
|
220
|
+
'EInvalidGapWaitMs',
|
|
221
|
+
'EInvalidPythPriceBufferMs',
|
|
222
|
+
'EInvalidSviMaxAgeMs',
|
|
223
|
+
'EInvalidMintCapacity',
|
|
224
|
+
'EInvalidSellCapacity',
|
|
225
|
+
'EInvalidPerAccountCap',
|
|
226
|
+
'EInvalidMinSellQuantity',
|
|
227
|
+
'EInvalidOrderFee',
|
|
228
|
+
'EInvalidSettleRefundBatch',
|
|
229
|
+
'EInvalidSettlePayoutBatch',
|
|
230
|
+
'EUnsupportedPythChannel',
|
|
231
|
+
'EInvalidTiming',
|
|
232
|
+
'EInvalidLimits',
|
|
233
|
+
],
|
|
234
|
+
// The math library (`deepbook_predict_math`).
|
|
235
|
+
lazer_price: ['EPropertyNotRequested', 'EGenerationAfterEnvelope', 'EFeedMissing'],
|
|
236
|
+
// Sessions (`deepbook_sessions`), which the `/sessions` Predict wrappers abort in.
|
|
237
|
+
sessions: ['EInvalidSessionDuration', 'ESessionNotAuthorized', 'ESessionLimitExceeded'],
|
|
238
|
+
session_config: ['EPackageVersionDisabled', 'EVersionWatermarkNotAdvanced'],
|
|
239
|
+
// The shared account (`deepbook_account`).
|
|
240
|
+
account_registry: ['EAppAlreadyAuthorized', 'EAppNotAuthorized', 'EAccountAlreadyExists'],
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
/** `std::option::EOPTION_NOT_SET`. */
|
|
244
|
+
const OPTION_NOT_SET = 0x40001n;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* The constant name of a plain `u64` abort `code` in `module`, from {@link ABORT_NAMES}, or null
|
|
248
|
+
* when the module or the code is unknown.
|
|
249
|
+
*/
|
|
250
|
+
export function abortNameFor(module: string, code: bigint): string | null {
|
|
251
|
+
// The order-fee guard (`queueTx.assertOrderFeeAtMost`) aborts in the standard library's
|
|
252
|
+
// `option`, whose constant isn't an index.
|
|
253
|
+
if (module === 'option' && code === OPTION_NOT_SET) return 'EOPTION_NOT_SET';
|
|
254
|
+
// Own keys only: a module named like an `Object.prototype` member is simply unknown.
|
|
255
|
+
if (!Object.hasOwn(ABORT_NAMES, module)) return null;
|
|
256
|
+
const names = ABORT_NAMES[module];
|
|
257
|
+
if (code < 0n || code >= BigInt(names.length)) return null;
|
|
258
|
+
return names[Number(code)];
|
|
259
|
+
}
|
|
260
|
+
|
|
66
261
|
/**
|
|
67
262
|
* Decode a `@mysten/sui` MoveAbort execution error into a {@link PredictMoveError}.
|
|
68
263
|
* Returns null when `error` carries no MoveAbort (InsufficientGas, a size error, any
|
|
69
264
|
* non-abort failure), so callers can fall back to a plain Error.
|
|
70
265
|
*
|
|
71
|
-
* `abortName` is
|
|
72
|
-
*
|
|
266
|
+
* `abortName` is the chain-decoded clever-error constant when the fullnode surfaces one, and
|
|
267
|
+
* otherwise the name {@link ABORT_NAMES} gives the module's plain code (Predict's constants are
|
|
268
|
+
* plain codes, so this is the usual path). It is null when neither knows the abort.
|
|
73
269
|
* `code` stays a bigint — a clever-error abort code packs the module, line, and
|
|
74
270
|
* constant index into the high bits of the u64 and would lose precision as a Number.
|
|
75
271
|
*/
|
|
@@ -78,6 +274,187 @@ export function decodeMoveAbort(error: MoveAbortError | null | undefined): Predi
|
|
|
78
274
|
if (!abort) return null;
|
|
79
275
|
const module = abort.location?.module ?? '';
|
|
80
276
|
const code = abort.abortCode != null ? BigInt(abort.abortCode) : 0n;
|
|
81
|
-
const abortName = abort.cleverError?.constantName ??
|
|
277
|
+
const abortName = abort.cleverError?.constantName ?? abortNameFor(module, code);
|
|
82
278
|
return new PredictMoveError(module, code, abortName);
|
|
83
279
|
}
|
|
280
|
+
|
|
281
|
+
// === Delayed execution (DBU-885) ===
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Why a queued-order builder refused to add an enqueue. The builder reads the market first and
|
|
285
|
+
* throws this instead of building a transaction the queue or protocol gates would abort, so a
|
|
286
|
+
* refused order never fails the rest of a transaction. Each code mirrors one on-chain refusal. The
|
|
287
|
+
* order's own limits at the current price are checked only on chain (`EOrderFailsLimits`).
|
|
288
|
+
*/
|
|
289
|
+
export type PredictPreflightCode =
|
|
290
|
+
/**
|
|
291
|
+
* Delayed execution isn't live: Predict's version watermark isn't raised
|
|
292
|
+
* (`ECutoverNotReached`), or Predict doesn't allowlist the order-flow package yet
|
|
293
|
+
* (`EOrderFlowNotAllowed`).
|
|
294
|
+
*/
|
|
295
|
+
| 'not-live'
|
|
296
|
+
/** The market has no `MarketQueue` yet: `queue::create_and_share` hasn't run for it. */
|
|
297
|
+
| 'no-queue'
|
|
298
|
+
/**
|
|
299
|
+
* A version floor retired code this SDK calls: Predict's watermark is above the Predict
|
|
300
|
+
* version it was built for (`protocol_config::EPackageVersionDisabled`), or the order desk's
|
|
301
|
+
* floor is above its order-flow package (`desk::EPackageVersionDisabled`). Update the SDK.
|
|
302
|
+
*/
|
|
303
|
+
| 'retired'
|
|
304
|
+
/** Trading is paused, the protocol is frozen, or minting is paused on this market. */
|
|
305
|
+
| 'paused'
|
|
306
|
+
/** The market's pricing is delayed (`queue_stuck`). Enqueue aborts `EQueueStuck`. */
|
|
307
|
+
| 'stuck'
|
|
308
|
+
/**
|
|
309
|
+
* The order's τ would land at or after the market's order cutoff (`EPastCutoff`). A
|
|
310
|
+
* `read.planMint` or `read.planSell` plan on a market past its expiry throws it too, since the
|
|
311
|
+
* chain has no live price to quote (`ELivePricingExpired`).
|
|
312
|
+
*/
|
|
313
|
+
| 'past-cutoff'
|
|
314
|
+
/** The market has its maximum unfinished mints or sells (`EQueueFull`). */
|
|
315
|
+
| 'queue-full'
|
|
316
|
+
/** The account has its maximum unfinished orders in this market (`EAccountOrderCap`). */
|
|
317
|
+
| 'account-cap'
|
|
318
|
+
/**
|
|
319
|
+
* The account balance doesn't cover the order fee (`EFeeNotCovered`). A `read.planMint` plan
|
|
320
|
+
* also reports it when the balance doesn't cover the plan's `totalDebit`, since its limits assume
|
|
321
|
+
* the whole budget, or when the owner has no account yet. Prompt a top-up.
|
|
322
|
+
*/
|
|
323
|
+
| 'fee'
|
|
324
|
+
/** A mint's cash need is above the market's spare cash (`EInsufficientMarketCash`). */
|
|
325
|
+
| 'market-cash'
|
|
326
|
+
/**
|
|
327
|
+
* The escrowed budget, or an exact-amount mint's premium cap, can't buy the minimum premium,
|
|
328
|
+
* so the order fails its limits. A budget `read.planMint` plan also reports it when what the
|
|
329
|
+
* budget buys without the fee subsidy, as admission prices it, has a premium below the minimum,
|
|
330
|
+
* and throws it for a budget below the minimum premium or one no fill clears it with.
|
|
331
|
+
*/
|
|
332
|
+
| 'min-premium'
|
|
333
|
+
/**
|
|
334
|
+
* The strike's entry probability is outside the market's entry band, so the chain refuses to
|
|
335
|
+
* quote or admit it (`EOrderFailsLimits`). Pick a strike nearer the money. Only `read.planMint`
|
|
336
|
+
* reports it, and the probability can still leave the band between plan and placement.
|
|
337
|
+
*/
|
|
338
|
+
| 'entry-band'
|
|
339
|
+
/**
|
|
340
|
+
* The order's all-in cost without the fee subsidy is above its payout, so admission refuses it
|
|
341
|
+
* at any slippage (`EOrderFailsLimits`), or for a budget, the fill costs about its payout, where
|
|
342
|
+
* admission's sizing can't be previewed. Only `read.planMint` reports it, near a certain outcome.
|
|
343
|
+
*/
|
|
344
|
+
| 'cost-above-payout'
|
|
345
|
+
/** A sell is below the policy minimum, or leaves a remainder below it (`EBelowMinSell`). */
|
|
346
|
+
| 'below-min-sell'
|
|
347
|
+
/** The record to sell is missing or not Open (`ERecordNotOpen`). */
|
|
348
|
+
| 'record-not-open'
|
|
349
|
+
/** The record to sell belongs to another account (`ENotRecordOwner`). */
|
|
350
|
+
| 'not-record-owner';
|
|
351
|
+
|
|
352
|
+
/** A queued-order builder's refusal, raised before any transaction is built. */
|
|
353
|
+
export class PredictPreflightError extends Error {
|
|
354
|
+
readonly code: PredictPreflightCode;
|
|
355
|
+
|
|
356
|
+
constructor(code: PredictPreflightCode, message: string) {
|
|
357
|
+
super(message);
|
|
358
|
+
this.name = 'PredictPreflightError';
|
|
359
|
+
this.code = code;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// Readable text for the aborts a trader, an app or a filler meets on the delayed-execution
|
|
364
|
+
// paths, keyed by `module::EName` as `decodeMoveAbort` names it. The queue's own
|
|
365
|
+
// checks are in the order-flow companion's `queue` and `desk` modules; Predict's admission, fill
|
|
366
|
+
// and quote checks stay in `expiry_market` and `protocol_config`; the Lazer decode is in the math
|
|
367
|
+
// library's `lazer_price`.
|
|
368
|
+
const PREDICT_ERROR_TEXT: Readonly<Record<string, string>> = Object.freeze({
|
|
369
|
+
// Placement (`queue::enqueue_*`).
|
|
370
|
+
'queue::EQueueStuck': 'Pricing is delayed for this market. Try again shortly.',
|
|
371
|
+
'queue::EQueueFull': "This market's order queue is full. Try again shortly.",
|
|
372
|
+
'queue::EAccountOrderCap': 'You already have the most waiting orders this market allows.',
|
|
373
|
+
'queue::EPastCutoff': 'This market no longer takes orders before its expiry.',
|
|
374
|
+
'queue::EFeeNotCovered': "Your balance doesn't cover the order fee. Top up and retry.",
|
|
375
|
+
'queue::EBelowMinSell': 'The sell is below the minimum size, or leaves a remainder below it.',
|
|
376
|
+
'queue::ERecordNotOpen': "That position isn't open in this market anymore.",
|
|
377
|
+
'queue::ENotRecordOwner': 'That position belongs to another account.',
|
|
378
|
+
'queue::EMintCostCapRequired': 'Set a maximum cost for the order.',
|
|
379
|
+
'queue::EWrongDesk': 'That order queue belongs to another order desk.',
|
|
380
|
+
'queue::EWrongMarket': "That order queue doesn't belong to this market.",
|
|
381
|
+
'queue::EMarketNotSettled': "The market hasn't settled yet.",
|
|
382
|
+
'queue::EMarketNotExpired': "The market hasn't expired yet.",
|
|
383
|
+
'desk::EPackageVersionDisabled':
|
|
384
|
+
'This order-flow package version is retired. Update to an SDK that calls the current package.',
|
|
385
|
+
'desk::EProtocolFrozen': 'The protocol is frozen.',
|
|
386
|
+
// The order-fee guard every SDK enqueue starts with. Predict's own `option` unwraps can abort the
|
|
387
|
+
// same way, so the text hedges.
|
|
388
|
+
'option::EOPTION_NOT_SET':
|
|
389
|
+
"This order wasn't placed: most likely the order fee rose after it was built. Build it again.",
|
|
390
|
+
// Predict's admission and quotes.
|
|
391
|
+
'expiry_market::EDelayedExecutionRequired':
|
|
392
|
+
'Immediate trades are retired on this market. Place a queued order instead.',
|
|
393
|
+
'expiry_market::EOrderFailsLimits':
|
|
394
|
+
"The market can't take this order at the current price: it misses its price limits, its price is outside the market's entry range, or its premium is below the minimum.",
|
|
395
|
+
'expiry_market::EInsufficientMarketCash': "This market can't take an order this size right now.",
|
|
396
|
+
'expiry_market::EMintCostCapRequired': 'Set a maximum cost for the order.',
|
|
397
|
+
'expiry_market::EMintPaused': 'Minting is paused on this market.',
|
|
398
|
+
'expiry_market::EInvalidOrderTiming': 'This market no longer takes orders before its expiry.',
|
|
399
|
+
'expiry_market::EMarketNotSettled': "The market hasn't settled yet.",
|
|
400
|
+
'strike_exposure_config::EEntryProbabilityOutOfBounds':
|
|
401
|
+
"This strike's price is outside the market's entry range. Pick a strike nearer the money.",
|
|
402
|
+
'strike_exposure_config::EPremiumBelowMinimum':
|
|
403
|
+
"The order's premium is below the 1 USDC minimum.",
|
|
404
|
+
'strike_exposure::EMintQuantityBelowMin':
|
|
405
|
+
'The price moved, so the budget buys fewer contracts than the order asks for.',
|
|
406
|
+
'strike_payout_tree::EMaxPayoutTreeNodes':
|
|
407
|
+
'This market has no room for a new strike right now. Pick a strike that already has positions.',
|
|
408
|
+
'expiry_cash::EInsufficientCash': "This market can't take an order this size right now.",
|
|
409
|
+
// The LP pool.
|
|
410
|
+
'lp_book::EBelowMinSupplyRequest': 'The deposit is below the minimum supply request.',
|
|
411
|
+
'lp_book::EBelowMinWithdrawRequest': 'The withdrawal is below the minimum withdraw request.',
|
|
412
|
+
// Live pricing. The unavailable and stale aborts clear once the oracles write again.
|
|
413
|
+
'pricing::EBlockScholesPriceUnavailable':
|
|
414
|
+
'Pricing is briefly unavailable for this market. Try again in a moment.',
|
|
415
|
+
'pricing::EBlockScholesSVIUnavailable':
|
|
416
|
+
'Pricing is briefly unavailable for this market. Try again in a moment.',
|
|
417
|
+
'pricing::EBlockScholesPriceStale': "This market's price feed is behind. Try again shortly.",
|
|
418
|
+
'pricing::EBlockScholesSVIStale': "This market's price feed is behind. Try again shortly.",
|
|
419
|
+
'pricing::EPythSpotUnavailable': "This market's live price is unavailable. Try again shortly.",
|
|
420
|
+
'pricing::EPythSpotStale': "This market's live price is behind. Try again shortly.",
|
|
421
|
+
'pricing::ELivePricingExpired': 'This market has reached its expiry.',
|
|
422
|
+
// Filler (`queue::commit`, decoding the Lazer update).
|
|
423
|
+
'lazer_price::EGenerationAfterEnvelope':
|
|
424
|
+
'The Pyth update was generated after its own timestamp envelope.',
|
|
425
|
+
'lazer_price::EFeedMissing': "The Pyth update doesn't carry this market's feed.",
|
|
426
|
+
'lazer_price::EPropertyNotRequested':
|
|
427
|
+
"The Pyth update doesn't carry the price property commit needs.",
|
|
428
|
+
// Sessions and the shared account.
|
|
429
|
+
'sessions::ESessionNotAuthorized':
|
|
430
|
+
"This session key isn't authorized for the account, or its grant has expired.",
|
|
431
|
+
'sessions::ESessionLimitExceeded':
|
|
432
|
+
'The account holds the most session keys it can. Revoke expired ones, then grant again.',
|
|
433
|
+
'sessions::EInvalidSessionDuration': 'A session must last more than 0 ms and at most 30 days.',
|
|
434
|
+
'session_config::EPackageVersionDisabled':
|
|
435
|
+
'This sessions package version is retired. Update to an SDK that calls the current package.',
|
|
436
|
+
'account_registry::EAppNotAuthorized':
|
|
437
|
+
"Trading through this app (such as Sessions) isn't enabled for accounts yet.",
|
|
438
|
+
'account_registry::EAccountAlreadyExists': 'This address already has an account.',
|
|
439
|
+
// Protocol gates.
|
|
440
|
+
'protocol_config::ECutoverNotReached':
|
|
441
|
+
"Queued orders aren't live yet: the protocol's version watermark hasn't been raised.",
|
|
442
|
+
'protocol_config::EOrderFlowNotAllowed':
|
|
443
|
+
"Queued orders aren't live yet: the protocol hasn't enabled the order-flow package.",
|
|
444
|
+
'protocol_config::EPackageVersionDisabled':
|
|
445
|
+
'This package version is retired. Update to an SDK that calls the current package.',
|
|
446
|
+
'protocol_config::EProtocolFrozen': 'The protocol is frozen.',
|
|
447
|
+
'protocol_config::ETradingPaused': 'Trading is paused.',
|
|
448
|
+
'protocol_config::ESnapshotInProgress': 'A pool valuation is running. Try again in a moment.',
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Readable text for a decoded Move abort on the Predict paths, or `null` when the abort isn't
|
|
453
|
+
* one this SDK describes (an unknown name, or an abort `decodeMoveAbort` couldn't name). Callers
|
|
454
|
+
* fall back to `e.message` on `null`, so new contract errors degrade to the raw abort rather
|
|
455
|
+
* than to a wrong message.
|
|
456
|
+
*/
|
|
457
|
+
export function describePredictError(e: PredictMoveError): string | null {
|
|
458
|
+
if (!e.abortName) return null;
|
|
459
|
+
return PREDICT_ERROR_TEXT[`${e.module}::${e.abortName}`] ?? null;
|
|
460
|
+
}
|
package/src/predict/index.ts
CHANGED
|
@@ -10,17 +10,35 @@ export { POSITION_LOT_SIZE, PredictClient, predict } from './client.js';
|
|
|
10
10
|
export type { PredictCompatibleClient } from './client.js';
|
|
11
11
|
export type {
|
|
12
12
|
ActiveMarket,
|
|
13
|
+
AppliedSlippage,
|
|
13
14
|
CloseOptions,
|
|
15
|
+
EnqueueMintAmountOptions,
|
|
16
|
+
EnqueueMintCostOptions,
|
|
17
|
+
EnqueueMintOptions,
|
|
18
|
+
EnqueueSellOptions,
|
|
19
|
+
MarketCoordinates,
|
|
14
20
|
MarketDescriptor,
|
|
21
|
+
MarketQueueView,
|
|
22
|
+
MarketSettlement,
|
|
15
23
|
MarketSummary,
|
|
16
24
|
MintAmountOptions,
|
|
17
25
|
MintCostOptions,
|
|
18
26
|
MintOptions,
|
|
27
|
+
MintPlan,
|
|
19
28
|
MintQuote,
|
|
29
|
+
PlanMintOptions,
|
|
30
|
+
PlanSellOptions,
|
|
20
31
|
PlpSupplyOptions,
|
|
21
32
|
PlpWithdrawOptions,
|
|
22
33
|
PoolSummary,
|
|
34
|
+
QueuedOrderOutcome,
|
|
35
|
+
QueuedOrderPlan,
|
|
36
|
+
QueuedOrderPreview,
|
|
37
|
+
QueuedOrderView,
|
|
23
38
|
RedeemQuote,
|
|
39
|
+
SellPlan,
|
|
40
|
+
SellQuote,
|
|
41
|
+
SlippageOptions,
|
|
24
42
|
} from './client.js';
|
|
25
43
|
|
|
26
44
|
// === Composition with foreign packages === auth + deterministic account addressing
|
|
@@ -39,7 +57,7 @@ export { deriveAccountWrapperId, generateAuth } from './tx/common.js';
|
|
|
39
57
|
// structs; the `*Events` namespaces are event layouts only.
|
|
40
58
|
export * as adminMoveCalls from '../contracts/deepbook_predict/admin.js';
|
|
41
59
|
export * as builderCodeMoveCalls from '../contracts/deepbook_predict/builder_code.js';
|
|
42
|
-
export * as expiryMarketMoveCalls from '
|
|
60
|
+
export * as expiryMarketMoveCalls from './bindings/expiry-market.js';
|
|
43
61
|
export * as marketLifecycleCapMoveCalls from '../contracts/deepbook_predict/market_lifecycle_cap.js';
|
|
44
62
|
export * as marketManagerMoveCalls from '../contracts/deepbook_predict/market_manager.js';
|
|
45
63
|
export * as pauseCapMoveCalls from '../contracts/deepbook_predict/pause_cap.js';
|
|
@@ -47,7 +65,7 @@ export * as plpMoveCalls from '../contracts/deepbook_predict/plp.js';
|
|
|
47
65
|
export * as poolValuationCapMoveCalls from '../contracts/deepbook_predict/pool_valuation_cap.js';
|
|
48
66
|
export * as predictAccountMoveCalls from '../contracts/deepbook_predict/predict_account.js';
|
|
49
67
|
export * as pricingMoveCalls from '../contracts/deepbook_predict/pricing.js';
|
|
50
|
-
export * as protocolConfigMoveCalls from '
|
|
68
|
+
export * as protocolConfigMoveCalls from './bindings/protocol-config.js';
|
|
51
69
|
export * as rangeCodecMoveCalls from '../contracts/deepbook_predict/range_codec.js';
|
|
52
70
|
export * as registryMoveCalls from '../contracts/deepbook_predict/registry.js';
|
|
53
71
|
export * as builderCodeEvents from '../contracts/deepbook_predict/builder_code_events.js';
|
|
@@ -55,6 +73,22 @@ export * as configEvents from '../contracts/deepbook_predict/config_events.js';
|
|
|
55
73
|
export * as orderEvents from '../contracts/deepbook_predict/order_events.js';
|
|
56
74
|
export * as vaultEvents from '../contracts/deepbook_predict/vault_events.js';
|
|
57
75
|
|
|
76
|
+
// === Order-flow companion and math library bindings (delayed execution, DBU-885) ===
|
|
77
|
+
// `deepbook_predict_orders` holds the queued-order flow: each market's `MarketQueue` and every
|
|
78
|
+
// queued-order entry point and queue read (`queueMoveCalls`), the shared `OrderDesk` with its
|
|
79
|
+
// policy setters (`deskMoveCalls`), the record layouts (`orderQueueMoveCalls`), the policy layout
|
|
80
|
+
// (`delayedExecutionConfigMoveCalls`) and the queue events (`queueEvents`). Pass
|
|
81
|
+
// `config: toOrdersConfig(cfg)`, which adds the companion package and the desk to the projected
|
|
82
|
+
// config. `deepbook_predict_math` is the pure math library (`predictMathMoveCalls`) and the
|
|
83
|
+
// `LazerPrice` a verified Pyth Lazer update decodes to (`lazerPriceMoveCalls`).
|
|
84
|
+
export * as queueMoveCalls from '../contracts/deepbook_predict_orders/queue.js';
|
|
85
|
+
export * as deskMoveCalls from '../contracts/deepbook_predict_orders/desk.js';
|
|
86
|
+
export * as orderQueueMoveCalls from '../contracts/deepbook_predict_orders/order_queue.js';
|
|
87
|
+
export * as delayedExecutionConfigMoveCalls from '../contracts/deepbook_predict_orders/delayed_execution_config.js';
|
|
88
|
+
export * as queueEvents from '../contracts/deepbook_predict_orders/queue_events.js';
|
|
89
|
+
export * as predictMathMoveCalls from '../contracts/deepbook_predict_math/math.js';
|
|
90
|
+
export * as lazerPriceMoveCalls from '../contracts/deepbook_predict_math/lazer_price.js';
|
|
91
|
+
|
|
58
92
|
// === Config ===
|
|
59
93
|
export {
|
|
60
94
|
MAINNET_CONFIG,
|
|
@@ -82,7 +116,7 @@ export {
|
|
|
82
116
|
} from './units.js';
|
|
83
117
|
|
|
84
118
|
// === Ticks ===
|
|
85
|
-
export { POS_INF_TICK, binaryRangeTicks } from './ticks.js';
|
|
119
|
+
export { POS_INF_TICK, binaryRangeTicks, snapStrike } from './ticks.js';
|
|
86
120
|
export type { Side } from './ticks.js';
|
|
87
121
|
|
|
88
122
|
// === Client-side pricing === the deployed SVI digital math (skew-corrected, signed
|
|
@@ -101,9 +135,34 @@ export type { PricerSnapshot } from './reads/pricing.js';
|
|
|
101
135
|
// `cost.SHIPPED_FEE_POLICY` as the shipped template.
|
|
102
136
|
export * as cost from './cost.js';
|
|
103
137
|
|
|
138
|
+
// === Delayed execution === the queued-order codes, cash-need math, timing previews and
|
|
139
|
+
// order-state views as pure functions over raw bigints: `queue.ORDER_STATUS`,
|
|
140
|
+
// `queue.REFUND_REASONS`, `queue.cashNeedExactQuantity`, `queue.maxMintNow`,
|
|
141
|
+
// `queue.previewTiming`, `queue.orderView`, `queue.reduceOrderEvents`, `queue.slippageBand`. The
|
|
142
|
+
// facade's `tx.enqueue*` / `read.queue` / `decode.queueEvents` drive them.
|
|
143
|
+
export * as queue from './queue.js';
|
|
144
|
+
// The queued-order thunks, for composing an enqueue, a refund, the filler or the keeper's
|
|
145
|
+
// settlement steps into a PTB you are building: `queueTx.enqueueExactCost(toOrdersConfig(cfg),
|
|
146
|
+
// …)`. Each addresses the market's queue at `deriveQueueId(registry, market)` unless given a
|
|
147
|
+
// `queueId`. They run the static checks (a real `max_cost` cap, explicit sell floors) but not
|
|
148
|
+
// the facade's chain preflight. `commit` and `fill` compose Pyth Lazer's verifier, a package
|
|
149
|
+
// this SDK doesn't generate.
|
|
150
|
+
export * as queueTx from './tx/queue.js';
|
|
151
|
+
export type { ExecutionMode, MarketQueueState } from './reads/queue.js';
|
|
152
|
+
// The ID of a market's `MarketQueue` under an order desk, as `queue::queue_id` derives it, and
|
|
153
|
+
// the companion's `OrderFlow` witness type that Predict's order-flow allowlist names.
|
|
154
|
+
export { deriveQueueId } from './queue-id.js';
|
|
155
|
+
export { orderFlowWitnessType } from './reads/queue.js';
|
|
156
|
+
|
|
104
157
|
// === Errors ===
|
|
105
|
-
export {
|
|
106
|
-
|
|
158
|
+
export {
|
|
159
|
+
PredictInputError,
|
|
160
|
+
PredictMoveError,
|
|
161
|
+
PredictPreflightError,
|
|
162
|
+
decodeMoveAbort,
|
|
163
|
+
describePredictError,
|
|
164
|
+
} from './errors.js';
|
|
165
|
+
export type { MoveAbortError, PredictPreflightCode } from './errors.js';
|
|
107
166
|
|
|
108
167
|
// === Client seam + position type used in public read signatures ===
|
|
109
168
|
export type { ReadClient } from './reads/inspect.js';
|
|
@@ -122,11 +181,33 @@ export type {
|
|
|
122
181
|
PlpCancelReceipt,
|
|
123
182
|
PlpRequestReceipt,
|
|
124
183
|
RedeemReceipt,
|
|
184
|
+
// Delayed execution.
|
|
185
|
+
CohortCommitReceipt,
|
|
186
|
+
EnqueueReceipt,
|
|
187
|
+
MarketPayoutsCompletedReceipt,
|
|
188
|
+
OpenRecordPayoutReceipt,
|
|
189
|
+
PolicyUpdateReceipt,
|
|
190
|
+
QueueCashFigures,
|
|
191
|
+
QueueEvent,
|
|
192
|
+
QueueOpsReceipt,
|
|
193
|
+
QueuedFillReceipt,
|
|
194
|
+
RecordFundsReceipt,
|
|
195
|
+
QueuedRefundReceipt,
|
|
196
|
+
ExpiryPnlRealizedReceipt,
|
|
125
197
|
} from './decode.js';
|
|
198
|
+
// The signed sum of `decode.expiryPnlRealized` receipts: the pool's gross realized P&L, raw.
|
|
199
|
+
export { realizedPnlRaw } from './decode.js';
|
|
126
200
|
|
|
127
201
|
// The `/sessions` Predict wrappers take `pricer` as a PTB result of this call, so it has to
|
|
128
202
|
// be reachable from the published surface for those builders to be composable at all.
|
|
129
203
|
export { loadLivePricer, type MarketFeeds } from './tx/trade.js';
|
|
130
204
|
// `loadLivePricer` takes the projected config, so the projection and its type have to be
|
|
131
205
|
// reachable too — without them the `/sessions` Predict wrappers cannot be composed at all.
|
|
132
|
-
|
|
206
|
+
// `toOrdersConfig` adds the order-flow companion and its desk, for `queueTx` and the companion
|
|
207
|
+
// bindings; it throws while the config doesn't record delayed execution.
|
|
208
|
+
export {
|
|
209
|
+
toGeneratedConfig,
|
|
210
|
+
toOrdersConfig,
|
|
211
|
+
type GeneratedConfig,
|
|
212
|
+
type OrdersGeneratedConfig,
|
|
213
|
+
} from './config/generated.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// A leaf module with no SDK imports, so `/sessions` can derive queue IDs without pulling the
|
|
4
|
+
// `/predict` module graph in.
|
|
5
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
6
|
+
import { deriveObjectID } from '@mysten/sui/utils';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The ID of `expiryMarketId`'s `MarketQueue` under the queue registry `registryId`, whether or not
|
|
10
|
+
* the queue exists yet: Sui's `derived_object::derive_address(registry_id, expiry_market_id)`, as
|
|
11
|
+
* `queue::queue_id` computes it on chain. The parent is the order-flow package's `QueueRegistry`,
|
|
12
|
+
* not its `OrderDesk`. The key is the market's `0x2::object::ID`, whose BCS is the bare 32-byte
|
|
13
|
+
* address. Each market has exactly one queue, created once by the permissionless
|
|
14
|
+
* `queue::create_and_share`.
|
|
15
|
+
*/
|
|
16
|
+
export function deriveQueueId(registryId: string, expiryMarketId: string): string {
|
|
17
|
+
return deriveObjectID(
|
|
18
|
+
registryId,
|
|
19
|
+
'0x2::object::ID',
|
|
20
|
+
bcs.Address.serialize(expiryMarketId).toBytes(),
|
|
21
|
+
);
|
|
22
|
+
}
|