@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.
Files changed (250) hide show
  1. package/CHANGELOG.md +153 -0
  2. package/PREDICT.md +389 -61
  3. package/dist/contracts/account/account.d.mts +23 -23
  4. package/dist/contracts/account/account.d.mts.map +1 -1
  5. package/dist/contracts/account/account_registry.d.mts +13 -13
  6. package/dist/contracts/deepbook/account.d.mts +18 -18
  7. package/dist/contracts/deepbook/balances.d.mts +4 -4
  8. package/dist/contracts/deepbook/deep_price.d.mts +3 -3
  9. package/dist/contracts/deepbook/order.d.mts +12 -12
  10. package/dist/contracts/deepbook_predict/admin.d.mts +4 -4
  11. package/dist/contracts/deepbook_predict/builder_code.d.mts +11 -11
  12. package/dist/contracts/deepbook_predict/builder_code_events.d.mts +10 -10
  13. package/dist/contracts/deepbook_predict/config_events.d.mts +93 -68
  14. package/dist/contracts/deepbook_predict/config_events.d.mts.map +1 -1
  15. package/dist/contracts/deepbook_predict/config_events.mjs +45 -1
  16. package/dist/contracts/deepbook_predict/config_events.mjs.map +1 -1
  17. package/dist/contracts/deepbook_predict/deps/std/type_name.mjs +17 -0
  18. package/dist/contracts/deepbook_predict/deps/std/type_name.mjs.map +1 -0
  19. package/dist/contracts/deepbook_predict/expiry_market.d.mts +652 -235
  20. package/dist/contracts/deepbook_predict/expiry_market.d.mts.map +1 -1
  21. package/dist/contracts/deepbook_predict/expiry_market.mjs +652 -186
  22. package/dist/contracts/deepbook_predict/expiry_market.mjs.map +1 -1
  23. package/dist/contracts/deepbook_predict/lp_book.mjs +1 -1
  24. package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts +5 -5
  25. package/dist/contracts/deepbook_predict/market_manager.d.mts +27 -27
  26. package/dist/contracts/deepbook_predict/order_events.d.mts +50 -50
  27. package/dist/contracts/deepbook_predict/order_events.d.mts.map +1 -1
  28. package/dist/contracts/deepbook_predict/order_events.mjs +3 -1
  29. package/dist/contracts/deepbook_predict/order_events.mjs.map +1 -1
  30. package/dist/contracts/deepbook_predict/pause_cap.d.mts +5 -5
  31. package/dist/contracts/deepbook_predict/plp.d.mts +184 -82
  32. package/dist/contracts/deepbook_predict/plp.d.mts.map +1 -1
  33. package/dist/contracts/deepbook_predict/plp.mjs +126 -7
  34. package/dist/contracts/deepbook_predict/plp.mjs.map +1 -1
  35. package/dist/contracts/deepbook_predict/pool_accounting.mjs +1 -1
  36. package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts +5 -5
  37. package/dist/contracts/deepbook_predict/predict_account.d.mts +14 -14
  38. package/dist/contracts/deepbook_predict/pricing.d.mts +91 -58
  39. package/dist/contracts/deepbook_predict/pricing.d.mts.map +1 -1
  40. package/dist/contracts/deepbook_predict/pricing.mjs +30 -3
  41. package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -1
  42. package/dist/contracts/deepbook_predict/pricing_config.mjs.map +1 -1
  43. package/dist/contracts/deepbook_predict/protocol_config.d.mts +400 -92
  44. package/dist/contracts/deepbook_predict/protocol_config.d.mts.map +1 -1
  45. package/dist/contracts/deepbook_predict/protocol_config.mjs +451 -61
  46. package/dist/contracts/deepbook_predict/protocol_config.mjs.map +1 -1
  47. package/dist/contracts/deepbook_predict/range_codec.d.mts +2 -2
  48. package/dist/contracts/deepbook_predict/registry.d.mts +28 -28
  49. package/dist/contracts/deepbook_predict/strike_exposure.mjs +1 -1
  50. package/dist/contracts/deepbook_predict/strike_payout_tree.mjs +17 -12
  51. package/dist/contracts/deepbook_predict/strike_payout_tree.mjs.map +1 -1
  52. package/dist/contracts/deepbook_predict/vault_events.d.mts +154 -106
  53. package/dist/contracts/deepbook_predict/vault_events.d.mts.map +1 -1
  54. package/dist/contracts/deepbook_predict/vault_events.mjs +57 -1
  55. package/dist/contracts/deepbook_predict/vault_events.mjs.map +1 -1
  56. package/dist/contracts/deepbook_predict_math/config-arguments.d.mts +10 -0
  57. package/dist/contracts/deepbook_predict_math/config-arguments.d.mts.map +1 -0
  58. package/dist/contracts/deepbook_predict_math/lazer_price.d.mts +106 -0
  59. package/dist/contracts/deepbook_predict_math/lazer_price.d.mts.map +1 -0
  60. package/dist/contracts/deepbook_predict_math/lazer_price.mjs +125 -0
  61. package/dist/contracts/deepbook_predict_math/lazer_price.mjs.map +1 -0
  62. package/dist/contracts/deepbook_predict_math/math.d.mts +284 -0
  63. package/dist/contracts/deepbook_predict_math/math.d.mts.map +1 -0
  64. package/dist/contracts/deepbook_predict_math/math.mjs +364 -0
  65. package/dist/contracts/deepbook_predict_math/math.mjs.map +1 -0
  66. package/dist/contracts/deepbook_predict_orders/config-arguments.d.mts +13 -0
  67. package/dist/contracts/deepbook_predict_orders/config-arguments.d.mts.map +1 -0
  68. package/dist/contracts/deepbook_predict_orders/delayed_execution_config.d.mts +215 -0
  69. package/dist/contracts/deepbook_predict_orders/delayed_execution_config.d.mts.map +1 -0
  70. package/dist/contracts/deepbook_predict_orders/delayed_execution_config.mjs +215 -0
  71. package/dist/contracts/deepbook_predict_orders/delayed_execution_config.mjs.map +1 -0
  72. package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.mjs +87 -0
  73. package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.mjs.map +1 -0
  74. package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/pricing.mjs +52 -0
  75. package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/pricing.mjs.map +1 -0
  76. package/dist/contracts/deepbook_predict_orders/deps/fixed_math/i64.mjs +25 -0
  77. package/dist/contracts/deepbook_predict_orders/deps/fixed_math/i64.mjs.map +1 -0
  78. package/dist/contracts/deepbook_predict_orders/deps/sui/balance.mjs +21 -0
  79. package/dist/contracts/deepbook_predict_orders/deps/sui/balance.mjs.map +1 -0
  80. package/dist/contracts/deepbook_predict_orders/deps/sui/table.mjs +39 -0
  81. package/dist/contracts/deepbook_predict_orders/deps/sui/table.mjs.map +1 -0
  82. package/dist/contracts/deepbook_predict_orders/desk.d.mts +187 -0
  83. package/dist/contracts/deepbook_predict_orders/desk.d.mts.map +1 -0
  84. package/dist/contracts/deepbook_predict_orders/desk.mjs +261 -0
  85. package/dist/contracts/deepbook_predict_orders/desk.mjs.map +1 -0
  86. package/dist/contracts/deepbook_predict_orders/order_queue.d.mts +1042 -0
  87. package/dist/contracts/deepbook_predict_orders/order_queue.d.mts.map +1 -0
  88. package/dist/contracts/deepbook_predict_orders/order_queue.mjs +849 -0
  89. package/dist/contracts/deepbook_predict_orders/order_queue.mjs.map +1 -0
  90. package/dist/contracts/deepbook_predict_orders/queue.d.mts +683 -0
  91. package/dist/contracts/deepbook_predict_orders/queue.d.mts.map +1 -0
  92. package/dist/contracts/deepbook_predict_orders/queue.mjs +912 -0
  93. package/dist/contracts/deepbook_predict_orders/queue.mjs.map +1 -0
  94. package/dist/contracts/deepbook_predict_orders/queue_events.d.mts +195 -0
  95. package/dist/contracts/deepbook_predict_orders/queue_events.d.mts.map +1 -0
  96. package/dist/contracts/deepbook_predict_orders/queue_events.mjs +187 -0
  97. package/dist/contracts/deepbook_predict_orders/queue_events.mjs.map +1 -0
  98. package/dist/contracts/deepbook_sessions/session_config.d.mts +8 -8
  99. package/dist/contracts/deepbook_sessions/sessions.d.mts +163 -28
  100. package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -1
  101. package/dist/contracts/deepbook_sessions/sessions.mjs +234 -5
  102. package/dist/contracts/deepbook_sessions/sessions.mjs.map +1 -1
  103. package/dist/deployments/mainnet.mjs +7 -4
  104. package/dist/deployments/mainnet.mjs.map +1 -1
  105. package/dist/deployments/testnet.mjs +7 -4
  106. package/dist/deployments/testnet.mjs.map +1 -1
  107. package/dist/predict/bindings/expiry-market.d.mts +77 -0
  108. package/dist/predict/bindings/expiry-market.d.mts.map +1 -0
  109. package/dist/predict/bindings/expiry-market.mjs +139 -0
  110. package/dist/predict/bindings/expiry-market.mjs.map +1 -0
  111. package/dist/predict/bindings/protocol-config.d.mts +39 -0
  112. package/dist/predict/bindings/protocol-config.d.mts.map +1 -0
  113. package/dist/predict/bindings/protocol-config.mjs +90 -0
  114. package/dist/predict/bindings/protocol-config.mjs.map +1 -0
  115. package/dist/predict/bindings/rename.mjs +9 -0
  116. package/dist/predict/bindings/rename.mjs.map +1 -0
  117. package/dist/predict/client.d.mts +595 -16
  118. package/dist/predict/client.d.mts.map +1 -1
  119. package/dist/predict/client.mjs +986 -10
  120. package/dist/predict/client.mjs.map +1 -1
  121. package/dist/predict/config/generated.d.mts +22 -1
  122. package/dist/predict/config/generated.d.mts.map +1 -1
  123. package/dist/predict/config/generated.mjs +30 -1
  124. package/dist/predict/config/generated.mjs.map +1 -1
  125. package/dist/predict/config/mainnet.mjs +11 -3
  126. package/dist/predict/config/mainnet.mjs.map +1 -1
  127. package/dist/predict/config/testnet.mjs +11 -3
  128. package/dist/predict/config/testnet.mjs.map +1 -1
  129. package/dist/predict/config/types.d.mts +50 -1
  130. package/dist/predict/config/types.d.mts.map +1 -1
  131. package/dist/predict/cost.d.mts +38 -11
  132. package/dist/predict/cost.d.mts.map +1 -1
  133. package/dist/predict/cost.mjs +37 -11
  134. package/dist/predict/cost.mjs.map +1 -1
  135. package/dist/predict/decode.d.mts +251 -1
  136. package/dist/predict/decode.d.mts.map +1 -1
  137. package/dist/predict/decode.mjs +342 -4
  138. package/dist/predict/decode.mjs.map +1 -1
  139. package/dist/predict/errors.d.mts +69 -6
  140. package/dist/predict/errors.d.mts.map +1 -1
  141. package/dist/predict/errors.mjs +277 -4
  142. package/dist/predict/errors.mjs.map +1 -1
  143. package/dist/predict/index.d.mts +21 -10
  144. package/dist/predict/index.mjs +24 -12
  145. package/dist/predict/queue-id.d.mts +13 -0
  146. package/dist/predict/queue-id.d.mts.map +1 -0
  147. package/dist/predict/queue-id.mjs +19 -0
  148. package/dist/predict/queue-id.mjs.map +1 -0
  149. package/dist/predict/queue.d.mts +505 -0
  150. package/dist/predict/queue.d.mts.map +1 -0
  151. package/dist/predict/queue.mjs +774 -0
  152. package/dist/predict/queue.mjs.map +1 -0
  153. package/dist/predict/reads/balances.mjs +1 -1
  154. package/dist/predict/reads/markets.mjs +46 -5
  155. package/dist/predict/reads/markets.mjs.map +1 -1
  156. package/dist/predict/reads/pool.mjs +1 -1
  157. package/dist/predict/reads/pricing.d.mts +1 -1
  158. package/dist/predict/reads/queue.d.mts +105 -0
  159. package/dist/predict/reads/queue.d.mts.map +1 -0
  160. package/dist/predict/reads/queue.mjs +445 -0
  161. package/dist/predict/reads/queue.mjs.map +1 -0
  162. package/dist/predict/ticks.d.mts +9 -1
  163. package/dist/predict/ticks.d.mts.map +1 -1
  164. package/dist/predict/ticks.mjs +18 -1
  165. package/dist/predict/ticks.mjs.map +1 -1
  166. package/dist/predict/tx/authed.mjs +1 -1
  167. package/dist/predict/tx/common.d.mts.map +1 -1
  168. package/dist/predict/tx/common.mjs +12 -1
  169. package/dist/predict/tx/common.mjs.map +1 -1
  170. package/dist/predict/tx/queue.d.mts +220 -0
  171. package/dist/predict/tx/queue.d.mts.map +1 -0
  172. package/dist/predict/tx/queue.mjs +399 -0
  173. package/dist/predict/tx/queue.mjs.map +1 -0
  174. package/dist/predict/tx/trade.d.mts.map +1 -1
  175. package/dist/predict/tx/trade.mjs +61 -43
  176. package/dist/predict/tx/trade.mjs.map +1 -1
  177. package/dist/sessions.d.mts +90 -2
  178. package/dist/sessions.d.mts.map +1 -1
  179. package/dist/sessions.mjs +107 -2
  180. package/dist/sessions.mjs.map +1 -1
  181. package/dist/transactions/balanceManager.d.mts +12 -12
  182. package/dist/transactions/balanceManager.d.mts.map +1 -1
  183. package/dist/transactions/deepbook.d.mts +20 -20
  184. package/dist/transactions/deepbook.d.mts.map +1 -1
  185. package/dist/transactions/deepbookAdmin.d.mts +4 -4
  186. package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
  187. package/dist/transactions/marginAdmin.d.mts +7 -7
  188. package/dist/transactions/marginAdmin.d.mts.map +1 -1
  189. package/dist/transactions/marginLiquidations.d.mts +3 -3
  190. package/dist/transactions/marginMaintainer.d.mts +5 -5
  191. package/dist/transactions/marginMaintainer.d.mts.map +1 -1
  192. package/dist/transactions/marginManager.d.mts +32 -32
  193. package/dist/transactions/marginManager.d.mts.map +1 -1
  194. package/dist/transactions/marginPool.d.mts +18 -18
  195. package/dist/transactions/marginRegistry.d.mts +16 -16
  196. package/dist/transactions/marginTPSL.d.mts +10 -10
  197. package/dist/transactions/marginTPSL.d.mts.map +1 -1
  198. package/dist/transactions/poolProxy.d.mts +8 -8
  199. package/dist/transactions/poolProxy.d.mts.map +1 -1
  200. package/package.json +4 -4
  201. package/src/contracts/deepbook_predict/config_events.ts +39 -0
  202. package/src/contracts/deepbook_predict/deps/std/type_name.ts +24 -0
  203. package/src/contracts/deepbook_predict/expiry_market.ts +960 -169
  204. package/src/contracts/deepbook_predict/order_events.ts +3 -1
  205. package/src/contracts/deepbook_predict/plp.ts +150 -9
  206. package/src/contracts/deepbook_predict/pricing.ts +46 -7
  207. package/src/contracts/deepbook_predict/pricing_config.ts +3 -1
  208. package/src/contracts/deepbook_predict/protocol_config.ts +648 -33
  209. package/src/contracts/deepbook_predict/strike_payout_tree.ts +25 -21
  210. package/src/contracts/deepbook_predict/vault_events.ts +65 -0
  211. package/src/contracts/deepbook_predict_math/config-arguments.ts +6 -0
  212. package/src/contracts/deepbook_predict_math/lazer_price.ts +196 -0
  213. package/src/contracts/deepbook_predict_math/math.ts +553 -0
  214. package/src/contracts/deepbook_predict_orders/config-arguments.ts +11 -0
  215. package/src/contracts/deepbook_predict_orders/delayed_execution_config.ts +430 -0
  216. package/src/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.ts +108 -0
  217. package/src/contracts/deepbook_predict_orders/deps/deepbook_predict/pricing.ts +58 -0
  218. package/src/contracts/deepbook_predict_orders/deps/fixed_math/i64.ts +21 -0
  219. package/src/contracts/deepbook_predict_orders/deps/sui/balance.ts +19 -0
  220. package/src/contracts/deepbook_predict_orders/deps/sui/table.ts +37 -0
  221. package/src/contracts/deepbook_predict_orders/desk.ts +419 -0
  222. package/src/contracts/deepbook_predict_orders/order_flow.ts +19 -0
  223. package/src/contracts/deepbook_predict_orders/order_queue.ts +1670 -0
  224. package/src/contracts/deepbook_predict_orders/queue.ts +1394 -0
  225. package/src/contracts/deepbook_predict_orders/queue_events.ts +189 -0
  226. package/src/contracts/deepbook_sessions/sessions.ts +355 -4
  227. package/src/deployments/mainnet.ts +7 -2
  228. package/src/deployments/testnet.ts +7 -2
  229. package/src/deployments/types.ts +14 -1
  230. package/src/predict/bindings/expiry-market.ts +127 -0
  231. package/src/predict/bindings/protocol-config.ts +59 -0
  232. package/src/predict/bindings/rename.ts +14 -0
  233. package/src/predict/client.ts +2076 -13
  234. package/src/predict/config/generated.ts +50 -0
  235. package/src/predict/config/mainnet.ts +16 -2
  236. package/src/predict/config/testnet.ts +16 -2
  237. package/src/predict/config/types.ts +51 -1
  238. package/src/predict/cost.ts +62 -14
  239. package/src/predict/decode.ts +691 -2
  240. package/src/predict/errors.ts +391 -14
  241. package/src/predict/index.ts +87 -6
  242. package/src/predict/queue-id.ts +22 -0
  243. package/src/predict/queue.ts +1231 -0
  244. package/src/predict/reads/markets.ts +30 -0
  245. package/src/predict/reads/queue.ts +606 -0
  246. package/src/predict/ticks.ts +35 -0
  247. package/src/predict/tx/common.ts +25 -1
  248. package/src/predict/tx/queue.ts +525 -0
  249. package/src/predict/tx/trade.ts +80 -49
  250. package/src/sessions.ts +206 -1
@@ -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. The deployed
9
- // Predict packages are compiled with CLEVER ERRORS, so the fullnode decodes the
10
- // `E…` error-constant name out of the abort code's high bits and returns it on
11
- // the structured execution error. We read that name straight from chain instead
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, decoded from the clever-error abort code by the
29
- * fullnode, or null when the transport surfaced no name (a non-clever abort,
30
- * or a JSON-RPC failure that carries only a line number). */
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. This is the on-chain
56
- // name that replaces the old hand-maintained ABORT_TABLES. JSON-RPC surfaces only
57
- // a line number, so `constantName` (and thus `abortName`) is absent there.
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 taken straight from the chain-decoded clever-error constant; it is
72
- * null when the abort predates clever errors or the transport didn't surface a name.
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 ?? null;
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
+ }
@@ -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 '../contracts/deepbook_predict/expiry_market.js';
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 '../contracts/deepbook_predict/protocol_config.js';
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 { PredictInputError, PredictMoveError, decodeMoveAbort } from './errors.js';
106
- export type { MoveAbortError } from './errors.js';
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
- export { toGeneratedConfig, type GeneratedConfig } from './config/generated.js';
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
+ }