@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
@@ -0,0 +1,912 @@
1
+ import { __exportAll } from "../../_virtual/rolldown_runtime.mjs";
2
+ import { MoveStruct, normalizeMoveArguments } from "../utils/index.mjs";
3
+ import { OrderBook } from "./order_queue.mjs";
4
+ import { bcs } from "@mysten/sui/bcs";
5
+
6
+ //#region src/contracts/deepbook_predict_orders/queue.ts
7
+ /**************************************************************
8
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
9
+ **************************************************************/
10
+ /**
11
+ * One expiry market's delayed-execution queue, `MarketQueue`, and its flows:
12
+ * placement of queued mints and early sells, commit of verified Pyth Lazer prices,
13
+ * resolve at the committed tick, the deadline and admin refunds, the settlement
14
+ * drain and payout walk, cleanup, and the queue reads.
15
+ *
16
+ * Every money-moving step runs inside one of Predict's order-flow primitives,
17
+ * which check their own gates and bindings when they run: admission (`admit_mint`,
18
+ * `admit_sell`), `commit`, `try_fill`, `release`, and `try_pay_settled`. The queue
19
+ * owns what Predict leaves to the companion: τ and the deadline, the stuck gate,
20
+ * capacities and per-account caps, cohort order, the exact-or-backup tick choice,
21
+ * escrow custody, refund routing, and the queue events. Each record holds
22
+ * Predict's receipt for its order and that order's own escrow, so a refund pays
23
+ * exactly that record's escrow.
24
+ *
25
+ * A queued fill never enters the account: it stays an Open record until
26
+ * `enqueue_redeem_open` sells it or the settlement payout walk or `pay_open` pays
27
+ * it.
28
+ *
29
+ * Mainnet USDC is a regulated coin: Sui aborts a transaction that sends it to an
30
+ * address on its deny list for the current epoch, or to anyone while it is
31
+ * globally paused. Every walker restarts at the same head record, so one such send
32
+ * would block the market's fills, refunds, and payouts for good. So nothing here,
33
+ * and nothing in Predict's primitives, sends to a denied address. Predict refuses
34
+ * a fill for a denied receive address (reason 9), keeps a denied builder's or
35
+ * referrer's fee in market cash, and skips a denied winner's payout. The queue
36
+ * parks change and refunds it cannot send in the record, which finishes as usual
37
+ * with the funds kept (`RecordFundsParked`). `claim_parked` sends them, and
38
+ * `pay_open` pays a skipped Open record, once the address is clear. While USDC is
39
+ * globally paused every address counts as denied: fills refuse, refunds park, and
40
+ * payouts skip until the pause lifts.
41
+ */
42
+ var queue_exports = /* @__PURE__ */ __exportAll({
43
+ MarketQueue: () => MarketQueue,
44
+ adminRefund: () => adminRefund,
45
+ claimParked: () => claimParked,
46
+ cleanup: () => cleanup,
47
+ commit: () => commit,
48
+ createAndShare: () => createAndShare,
49
+ deskId: () => deskId,
50
+ enqueueExactAmount: () => enqueueExactAmount,
51
+ enqueueExactCost: () => enqueueExactCost,
52
+ enqueueExactQuantity: () => enqueueExactQuantity,
53
+ enqueueRedeemOpen: () => enqueueRedeemOpen,
54
+ expiryMarketId: () => expiryMarketId,
55
+ id: () => id,
56
+ oldestUnfinishedTauMs: () => oldestUnfinishedTauMs,
57
+ order: () => order,
58
+ payOpen: () => payOpen,
59
+ payoutProgress: () => payoutProgress,
60
+ pendingCounts: () => pendingCounts,
61
+ phaseDone: () => phaseDone,
62
+ phaseDrain: () => phaseDrain,
63
+ phasePay: () => phasePay,
64
+ queueHeads: () => queueHeads,
65
+ queueId: () => queueId,
66
+ queueStuck: () => queueStuck,
67
+ quoteRedeemOpen: () => quoteRedeemOpen,
68
+ refund: () => refund,
69
+ resolve: () => resolve,
70
+ settleStep: () => settleStep,
71
+ waitingCohorts: () => waitingCohorts,
72
+ waitingOrders: () => waitingOrders
73
+ });
74
+ const $moduleName = "@local-pkg/deepbook_predict_orders::queue";
75
+ const MarketQueue = new MoveStruct({
76
+ name: `${$moduleName}::MarketQueue`,
77
+ fields: {
78
+ id: bcs.Address,
79
+ desk_id: bcs.Address,
80
+ expiry_market_id: bcs.Address,
81
+ book: OrderBook,
82
+ payouts_completed: bcs.bool()
83
+ }
84
+ });
85
+ function phaseDrain(options = {}) {
86
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
87
+ return (tx) => tx.moveCall({
88
+ package: packageAddress,
89
+ module: "queue",
90
+ function: "phase_drain"
91
+ });
92
+ }
93
+ function phasePay(options = {}) {
94
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
95
+ return (tx) => tx.moveCall({
96
+ package: packageAddress,
97
+ module: "queue",
98
+ function: "phase_pay"
99
+ });
100
+ }
101
+ function phaseDone(options = {}) {
102
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
103
+ return (tx) => tx.moveCall({
104
+ package: packageAddress,
105
+ module: "queue",
106
+ function: "phase_done"
107
+ });
108
+ }
109
+ /**
110
+ * Return the ID of `expiry_market_id`'s queue under the queue registry
111
+ * `registry_id`, whether or not it exists yet. For PTB construction.
112
+ */
113
+ function queueId(options) {
114
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
115
+ const argumentsTypes = ["0x2::object::ID", "0x2::object::ID"];
116
+ const parameterNames = ["registryId", "expiryMarketId"];
117
+ return (tx) => tx.moveCall({
118
+ package: packageAddress,
119
+ module: "queue",
120
+ function: "queue_id",
121
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
122
+ });
123
+ }
124
+ function id(options) {
125
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
126
+ const argumentsTypes = [null];
127
+ const parameterNames = ["queue"];
128
+ return (tx) => tx.moveCall({
129
+ package: packageAddress,
130
+ module: "queue",
131
+ function: "id",
132
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
133
+ });
134
+ }
135
+ function deskId(options) {
136
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
137
+ const argumentsTypes = [null];
138
+ const parameterNames = ["queue"];
139
+ return (tx) => tx.moveCall({
140
+ package: packageAddress,
141
+ module: "queue",
142
+ function: "desk_id",
143
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
144
+ });
145
+ }
146
+ function expiryMarketId(options) {
147
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
148
+ const argumentsTypes = [null];
149
+ const parameterNames = ["queue"];
150
+ return (tx) => tx.moveCall({
151
+ package: packageAddress,
152
+ module: "queue",
153
+ function: "expiry_market_id",
154
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
155
+ });
156
+ }
157
+ /** Return one record, or `none` for a missing or deleted record ID. */
158
+ function order(options) {
159
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
160
+ const argumentsTypes = [null, "u64"];
161
+ const parameterNames = ["queue", "recordId"];
162
+ return (tx) => tx.moveCall({
163
+ package: packageAddress,
164
+ module: "queue",
165
+ function: "order",
166
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
167
+ });
168
+ }
169
+ /**
170
+ * Return `(resolve_head, next_id, last_tau_ms, last_committed_tau_ms)`.
171
+ * `resolve_head` is a lower bound on the first unfinished record.
172
+ */
173
+ function queueHeads(options) {
174
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
175
+ const argumentsTypes = [null];
176
+ const parameterNames = ["queue"];
177
+ return (tx) => tx.moveCall({
178
+ package: packageAddress,
179
+ module: "queue",
180
+ function: "queue_heads",
181
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
182
+ });
183
+ }
184
+ /**
185
+ * Return `(payout_cursor, next_id, payouts_completed)`. The settlement payout walk
186
+ * is finished once `payouts_completed` is set.
187
+ */
188
+ function payoutProgress(options) {
189
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
190
+ const argumentsTypes = [null];
191
+ const parameterNames = ["queue"];
192
+ return (tx) => tx.moveCall({
193
+ package: packageAddress,
194
+ module: "queue",
195
+ function: "payout_progress",
196
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
197
+ });
198
+ }
199
+ /**
200
+ * Return
201
+ * `(cohort count, oldest uncommitted τ, oldest uncommitted τ above last_committed_tau_ms)`.
202
+ * The third value is the cohort the stuck gate's first rule watches.
203
+ */
204
+ function waitingCohorts(options) {
205
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
206
+ const argumentsTypes = [null];
207
+ const parameterNames = ["queue"];
208
+ return (tx) => tx.moveCall({
209
+ package: packageAddress,
210
+ module: "queue",
211
+ function: "waiting_cohorts",
212
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
213
+ });
214
+ }
215
+ /**
216
+ * Whether placement would refuse a new order as stuck right now (both rules of the
217
+ * stuck gate). Drives the app's "pricing delayed" banner.
218
+ */
219
+ function queueStuck(options) {
220
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
221
+ const argumentsTypes = [
222
+ null,
223
+ null,
224
+ "0x2::clock::Clock"
225
+ ];
226
+ const parameterNames = ["queue", "desk"];
227
+ return (tx) => tx.moveCall({
228
+ package: packageAddress,
229
+ module: "queue",
230
+ function: "queue_stuck",
231
+ arguments: normalizeMoveArguments({
232
+ ...options.arguments,
233
+ desk: options.arguments?.desk ?? options.config?.orderDesk
234
+ }, argumentsTypes, parameterNames)
235
+ });
236
+ }
237
+ /**
238
+ * Return `(pending_mints, pending_sells)`, the unfinished orders counted against
239
+ * the policy capacities.
240
+ */
241
+ function pendingCounts(options) {
242
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
243
+ const argumentsTypes = [null];
244
+ const parameterNames = ["queue"];
245
+ return (tx) => tx.moveCall({
246
+ package: packageAddress,
247
+ module: "queue",
248
+ function: "pending_counts",
249
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
250
+ });
251
+ }
252
+ /**
253
+ * Return the unfinished queued orders `account_id` holds in this queue, the count
254
+ * the per-account cap checks. The settlement drain (`settle_step`) refunds without
255
+ * lowering it, since no placement reads it once the market has expired, so after
256
+ * expiry it can overstate what the account still has waiting. Read `order` for
257
+ * each record's status instead.
258
+ */
259
+ function waitingOrders(options) {
260
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
261
+ const argumentsTypes = [null, "0x2::object::ID"];
262
+ const parameterNames = ["queue", "accountId"];
263
+ return (tx) => tx.moveCall({
264
+ package: packageAddress,
265
+ module: "queue",
266
+ function: "waiting_orders",
267
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
268
+ });
269
+ }
270
+ /** Return τ of the oldest cohort with an unfinished order, for monitoring. */
271
+ function oldestUnfinishedTauMs(options) {
272
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
273
+ const argumentsTypes = [null];
274
+ const parameterNames = ["queue"];
275
+ return (tx) => tx.moveCall({
276
+ package: packageAddress,
277
+ module: "queue",
278
+ function: "oldest_unfinished_tau_ms",
279
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
280
+ });
281
+ }
282
+ /**
283
+ * Quote an early sell of `close_quantity` from the Open record `record_id` at a
284
+ * live `Pricer`, with the wrapper account's builder code, through Predict's
285
+ * `quote_close`: the close a queued sell fills, with the trading fee at the clock
286
+ * instead of a committed tick. `proceeds` is before the order fee. Changes
287
+ * nothing. Aborts `ERecordNotOpen` for a missing or non-Open record, and otherwise
288
+ * as `quote_close` does. Does not check that the account owns the record. For SDK
289
+ * and devInspect pricing before `enqueue_redeem_open`.
290
+ */
291
+ function quoteRedeemOpen(options) {
292
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
293
+ const argumentsTypes = [
294
+ null,
295
+ null,
296
+ null,
297
+ null,
298
+ "u64",
299
+ "u64",
300
+ "0x2::clock::Clock"
301
+ ];
302
+ const parameterNames = [
303
+ "queue",
304
+ "market",
305
+ "wrapper",
306
+ "pricer",
307
+ "recordId",
308
+ "closeQuantity"
309
+ ];
310
+ return (tx) => tx.moveCall({
311
+ package: packageAddress,
312
+ module: "queue",
313
+ function: "quote_redeem_open",
314
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
315
+ });
316
+ }
317
+ /**
318
+ * Create and share `market`'s queue under `desk`. Permissionless; the caller pays
319
+ * its storage. The queue's ID is derived from the desk's registry and the market,
320
+ * so a second call for the same market aborts. Writes only the registry, which no
321
+ * trading call reads, so creation never contends with trading on the desk. Aborts
322
+ * `EWrongDesk` for another desk's registry.
323
+ */
324
+ function createAndShare(options) {
325
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
326
+ const argumentsTypes = [
327
+ null,
328
+ null,
329
+ null
330
+ ];
331
+ const parameterNames = [
332
+ "registry",
333
+ "desk",
334
+ "market"
335
+ ];
336
+ return (tx) => tx.moveCall({
337
+ package: packageAddress,
338
+ module: "queue",
339
+ function: "create_and_share",
340
+ arguments: normalizeMoveArguments({
341
+ ...options.arguments,
342
+ registry: options.arguments?.registry ?? options.config?.queueRegistry,
343
+ desk: options.arguments?.desk ?? options.config?.orderDesk
344
+ }, argumentsTypes, parameterNames)
345
+ });
346
+ }
347
+ /**
348
+ * Place a queued mint for an exact quantity, priced later at Pyth's signed price
349
+ * for its τ. `max_cost` caps the all-in withdrawal and is mandatory;
350
+ * `max_probability` caps the entry probability at τ. Escrows the budget,
351
+ * `min(max_cost, quantity, available - order_fee)`, and the order fee, and returns
352
+ * the new record ID.
353
+ *
354
+ * Aborts, charging nothing, when the queue refuses the order: the desk floor,
355
+ * another desk's or market's queue (`EWrongDesk`, `EWrongMarket`), a stuck or full
356
+ * queue (`EQueueStuck`, `EQueueFull`, `EAccountOrderCap`), τ at or past the cutoff
357
+ * (`EPastCutoff`), an unlimited or zero `max_cost` (`EMintCostCapRequired`), or a
358
+ * balance not above the order fee (`EFeeNotCovered`). Then Predict's `admit_mint`
359
+ * applies its gates, the order's own limits at the clock, and the market's spare
360
+ * cash.
361
+ */
362
+ function enqueueExactQuantity(options) {
363
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
364
+ const argumentsTypes = [
365
+ null,
366
+ null,
367
+ null,
368
+ null,
369
+ null,
370
+ null,
371
+ null,
372
+ null,
373
+ null,
374
+ null,
375
+ "u64",
376
+ "u64",
377
+ "u64",
378
+ "u64",
379
+ "u64",
380
+ "0x2::accumulator::AccumulatorRoot",
381
+ "0x2::clock::Clock"
382
+ ];
383
+ const parameterNames = [
384
+ "queue",
385
+ "market",
386
+ "wrapper",
387
+ "auth",
388
+ "desk",
389
+ "config",
390
+ "propbookRegistry",
391
+ "pyth",
392
+ "bsValues",
393
+ "bsSvi",
394
+ "lowerTick",
395
+ "higherTick",
396
+ "quantity",
397
+ "maxCost",
398
+ "maxProbability"
399
+ ];
400
+ return (tx) => tx.moveCall({
401
+ package: packageAddress,
402
+ module: "queue",
403
+ function: "enqueue_exact_quantity",
404
+ arguments: normalizeMoveArguments({
405
+ ...options.arguments,
406
+ desk: options.arguments?.desk ?? options.config?.orderDesk,
407
+ config: options.arguments?.config ?? options.config?.protocolConfig,
408
+ propbookRegistry: options.arguments?.propbookRegistry ?? options.config?.oracleRegistry
409
+ }, argumentsTypes, parameterNames)
410
+ });
411
+ }
412
+ /**
413
+ * Place a queued premium-budget mint: sized at τ under `max_premium`, at least
414
+ * `min_quantity`, with the all-in withdrawal capped by the mandatory `max_cost`.
415
+ * Escrows `min(max_cost, available - order_fee)` and the order fee. Refuses orders
416
+ * like `enqueue_exact_quantity`. Returns the new record ID.
417
+ */
418
+ function enqueueExactAmount(options) {
419
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
420
+ const argumentsTypes = [
421
+ null,
422
+ null,
423
+ null,
424
+ null,
425
+ null,
426
+ null,
427
+ null,
428
+ null,
429
+ null,
430
+ null,
431
+ "u64",
432
+ "u64",
433
+ "u64",
434
+ "u64",
435
+ "u64",
436
+ "0x2::accumulator::AccumulatorRoot",
437
+ "0x2::clock::Clock"
438
+ ];
439
+ const parameterNames = [
440
+ "queue",
441
+ "market",
442
+ "wrapper",
443
+ "auth",
444
+ "desk",
445
+ "config",
446
+ "propbookRegistry",
447
+ "pyth",
448
+ "bsValues",
449
+ "bsSvi",
450
+ "lowerTick",
451
+ "higherTick",
452
+ "maxPremium",
453
+ "minQuantity",
454
+ "maxCost"
455
+ ];
456
+ return (tx) => tx.moveCall({
457
+ package: packageAddress,
458
+ module: "queue",
459
+ function: "enqueue_exact_amount",
460
+ arguments: normalizeMoveArguments({
461
+ ...options.arguments,
462
+ desk: options.arguments?.desk ?? options.config?.orderDesk,
463
+ config: options.arguments?.config ?? options.config?.protocolConfig,
464
+ propbookRegistry: options.arguments?.propbookRegistry ?? options.config?.oracleRegistry
465
+ }, argumentsTypes, parameterNames)
466
+ });
467
+ }
468
+ /**
469
+ * Place a queued all-in-budget mint: sized at τ so the all-in cost fits
470
+ * `max_cost`, at least `min_quantity`. Escrows
471
+ * `min(max_cost, available - order_fee)` and the order fee. `max_cost` is
472
+ * mandatory here too: the unlimited value is refused. Refuses orders like
473
+ * `enqueue_exact_quantity`. Returns the new record ID.
474
+ */
475
+ function enqueueExactCost(options) {
476
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
477
+ const argumentsTypes = [
478
+ null,
479
+ null,
480
+ null,
481
+ null,
482
+ null,
483
+ null,
484
+ null,
485
+ null,
486
+ null,
487
+ null,
488
+ "u64",
489
+ "u64",
490
+ "u64",
491
+ "u64",
492
+ "0x2::accumulator::AccumulatorRoot",
493
+ "0x2::clock::Clock"
494
+ ];
495
+ const parameterNames = [
496
+ "queue",
497
+ "market",
498
+ "wrapper",
499
+ "auth",
500
+ "desk",
501
+ "config",
502
+ "propbookRegistry",
503
+ "pyth",
504
+ "bsValues",
505
+ "bsSvi",
506
+ "lowerTick",
507
+ "higherTick",
508
+ "maxCost",
509
+ "minQuantity"
510
+ ];
511
+ return (tx) => tx.moveCall({
512
+ package: packageAddress,
513
+ module: "queue",
514
+ function: "enqueue_exact_cost",
515
+ arguments: normalizeMoveArguments({
516
+ ...options.arguments,
517
+ desk: options.arguments?.desk ?? options.config?.orderDesk,
518
+ config: options.arguments?.config ?? options.config?.protocolConfig,
519
+ propbookRegistry: options.arguments?.propbookRegistry ?? options.config?.oracleRegistry
520
+ }, argumentsTypes, parameterNames)
521
+ });
522
+ }
523
+ /**
524
+ * Place a queued early sell of `close_quantity` of an Open record's position.
525
+ * `record_id` is the record's queue ID, not the position's order ID. The source
526
+ * record must belong to this account (`ENotRecordOwner`) and be Open
527
+ * (`ERecordNotOpen`, also for a missing ID). It is marked Closed and its receipt
528
+ * and whole position move into the new record until the sell fills or refunds.
529
+ * `min_probability` and `min_proceeds` are the close-side floors at τ. Returns the
530
+ * new record ID.
531
+ *
532
+ * Escrows only the order fee, so a balance equal to it is enough. Refuses a sell
533
+ * below `min_sell_quantity` or one leaving a remainder below it (`EBelowMinSell`),
534
+ * and otherwise like `enqueue_exact_quantity`. Predict's `admit_sell` is open
535
+ * during the trading pause and a market mint pause and has no spare-cash check:
536
+ * the keeper funds the market before τ, and resolve refunds a sell the market
537
+ * still cannot cover.
538
+ */
539
+ function enqueueRedeemOpen(options) {
540
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
541
+ const argumentsTypes = [
542
+ null,
543
+ null,
544
+ null,
545
+ null,
546
+ null,
547
+ null,
548
+ null,
549
+ null,
550
+ null,
551
+ null,
552
+ "u64",
553
+ "u64",
554
+ "u64",
555
+ "u64",
556
+ "0x2::accumulator::AccumulatorRoot",
557
+ "0x2::clock::Clock"
558
+ ];
559
+ const parameterNames = [
560
+ "queue",
561
+ "market",
562
+ "wrapper",
563
+ "auth",
564
+ "desk",
565
+ "config",
566
+ "propbookRegistry",
567
+ "pyth",
568
+ "bsValues",
569
+ "bsSvi",
570
+ "recordId",
571
+ "closeQuantity",
572
+ "minProbability",
573
+ "minProceeds"
574
+ ];
575
+ return (tx) => tx.moveCall({
576
+ package: packageAddress,
577
+ module: "queue",
578
+ function: "enqueue_redeem_open",
579
+ arguments: normalizeMoveArguments({
580
+ ...options.arguments,
581
+ desk: options.arguments?.desk ?? options.config?.orderDesk,
582
+ config: options.arguments?.config ?? options.config?.protocolConfig,
583
+ propbookRegistry: options.arguments?.propbookRegistry ?? options.config?.oracleRegistry
584
+ }, argumentsTypes, parameterNames)
585
+ });
586
+ }
587
+ /**
588
+ * Attach verified Pyth Lazer prices to the waiting cohorts whose τ they match.
589
+ * Permissionless. Each update must come from the Pyth Lazer verifier earlier in
590
+ * the same PTB; their order in `updates` does not matter. An update that matches
591
+ * no waiting cohort is skipped.
592
+ *
593
+ * Matching reads only the inline cohort list and picks at most one update per
594
+ * waiting cohort before its deadline: the one stamped exactly its τ on its
595
+ * channel, or else, once the price buffer is above zero and now is at least
596
+ * `gap_wait_ms` past τ, the one stamped one tick of the cohort's own channel
597
+ * later. Each matched cohort then commits whole or not at all: one price per feed
598
+ * is decoded through `lazer_price::from_update`, every Pending order is checked
599
+ * against it before any is written, and an empty price, a price generated before
600
+ * τ, or an envelope after now leaves the cohort for a later commit or its deadline
601
+ * refund. The decode aborts on an update that lacks an order's feed or one of its
602
+ * properties, because the caller passed the wrong update. Each committed mint
603
+ * escrows the subsidy Predict reserves for it.
604
+ *
605
+ * Uses Lazer's v1 `Update`, which Pyth marked deprecated on Mainnet but still
606
+ * serves; v2 arrives with a later library constructor.
607
+ */
608
+ function commit(options) {
609
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
610
+ const argumentsTypes = [
611
+ null,
612
+ null,
613
+ null,
614
+ null,
615
+ "vector<null>",
616
+ "0x2::clock::Clock"
617
+ ];
618
+ const parameterNames = [
619
+ "queue",
620
+ "market",
621
+ "desk",
622
+ "config",
623
+ "updates"
624
+ ];
625
+ return (tx) => tx.moveCall({
626
+ package: packageAddress,
627
+ module: "queue",
628
+ function: "commit",
629
+ arguments: normalizeMoveArguments({
630
+ ...options.arguments,
631
+ desk: options.arguments?.desk ?? options.config?.orderDesk,
632
+ config: options.arguments?.config ?? options.config?.protocolConfig
633
+ }, argumentsTypes, parameterNames)
634
+ });
635
+ }
636
+ /**
637
+ * Fill or refund committed orders in τ order, visiting at most `max_orders`
638
+ * records, and never more than 450 (each emits up to two events, and Sui caps a
639
+ * transaction at 1,024). Permissionless. Returns how many orders it finished.
640
+ *
641
+ * Walks the cohorts in τ order and loads only committed or overdue ones; a cohort
642
+ * still waiting for its price is skipped without loading a record. Every record
643
+ * visited counts against `max_orders`, finished or missing ones included. The 450
644
+ * cap bounds events, not loaded objects (`MAX_ORDERS_PER_CALL`), so the caller
645
+ * sizes `max_orders` to stay inside Sui's per-transaction object limit. An order
646
+ * at or past its deadline is refunded (reason 5), never filled. A committed order
647
+ * goes to Predict's `try_fill`, which fills it or returns the refund reason (1, 2,
648
+ * 4, 8, or 9); the queue returns the escrow Predict hands back to the trader, or
649
+ * parks it in the record when the receive address is denied. Returns 0 on a
650
+ * settled market, whose waiting orders the settlement drain refunds.
651
+ */
652
+ function resolve(options) {
653
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
654
+ const argumentsTypes = [
655
+ null,
656
+ null,
657
+ null,
658
+ null,
659
+ "u64",
660
+ "0x2::deny_list::DenyList",
661
+ "0x2::clock::Clock"
662
+ ];
663
+ const parameterNames = [
664
+ "queue",
665
+ "market",
666
+ "desk",
667
+ "config",
668
+ "maxOrders"
669
+ ];
670
+ return (tx) => tx.moveCall({
671
+ package: packageAddress,
672
+ module: "queue",
673
+ function: "resolve",
674
+ arguments: normalizeMoveArguments({
675
+ ...options.arguments,
676
+ desk: options.arguments?.desk ?? options.config?.orderDesk,
677
+ config: options.arguments?.config ?? options.config?.protocolConfig
678
+ }, argumentsTypes, parameterNames)
679
+ });
680
+ }
681
+ /**
682
+ * Refund waiting orders at or past their deadline (reason 5), visiting at most
683
+ * `max_orders` records, refunded or not, and never more than 450, as `resolve`
684
+ * does. It walks the cohorts in τ order and stops at the first one not yet due,
685
+ * since deadlines never decrease along the queue. Permissionless, and available
686
+ * while Predict is frozen or this companion's witness is disabled: Predict's
687
+ * `release` checks only its version floor. A refund the receive address cannot
688
+ * take is parked in its record. Returns how many orders it refunded: `0`, without
689
+ * aborting, when none is due.
690
+ */
691
+ function refund(options) {
692
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
693
+ const argumentsTypes = [
694
+ null,
695
+ null,
696
+ null,
697
+ null,
698
+ "u64",
699
+ "0x2::deny_list::DenyList",
700
+ "0x2::clock::Clock"
701
+ ];
702
+ const parameterNames = [
703
+ "queue",
704
+ "market",
705
+ "desk",
706
+ "config",
707
+ "maxOrders"
708
+ ];
709
+ return (tx) => tx.moveCall({
710
+ package: packageAddress,
711
+ module: "queue",
712
+ function: "refund",
713
+ arguments: normalizeMoveArguments({
714
+ ...options.arguments,
715
+ desk: options.arguments?.desk ?? options.config?.orderDesk,
716
+ config: options.arguments?.config ?? options.config?.protocolConfig
717
+ }, argumentsTypes, parameterNames)
718
+ });
719
+ }
720
+ /**
721
+ * Refund the listed waiting orders at once (reason 7), wherever they sit in the
722
+ * queue. Predict's `AdminCap` only, and available while Predict is frozen. Missing
723
+ * and finished IDs are skipped, and a refund the receive address cannot take is
724
+ * parked in its record.
725
+ */
726
+ function adminRefund(options) {
727
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
728
+ const argumentsTypes = [
729
+ null,
730
+ null,
731
+ null,
732
+ null,
733
+ null,
734
+ "vector<u64>",
735
+ "0x2::deny_list::DenyList",
736
+ "0x2::clock::Clock"
737
+ ];
738
+ const parameterNames = [
739
+ "queue",
740
+ "market",
741
+ "AdminCap",
742
+ "desk",
743
+ "config",
744
+ "recordIds"
745
+ ];
746
+ return (tx) => tx.moveCall({
747
+ package: packageAddress,
748
+ module: "queue",
749
+ function: "admin_refund",
750
+ arguments: normalizeMoveArguments({
751
+ ...options.arguments,
752
+ desk: options.arguments?.desk ?? options.config?.orderDesk,
753
+ config: options.arguments?.config ?? options.config?.protocolConfig
754
+ }, argumentsTypes, parameterNames)
755
+ });
756
+ }
757
+ /**
758
+ * Delete Refunded and Closed records of a settled market. Permissionless; the
759
+ * storage rebate goes to the caller. Missing IDs, other statuses, and records
760
+ * still holding a receipt or funds (parked funds included, until `claim_parked`)
761
+ * are skipped; `QueuedOrdersCleaned` is emitted only when a record was deleted.
762
+ * Takes `&Clock` only to stamp the event.
763
+ */
764
+ function cleanup(options) {
765
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
766
+ const argumentsTypes = [
767
+ null,
768
+ null,
769
+ null,
770
+ "vector<u64>",
771
+ "0x2::clock::Clock"
772
+ ];
773
+ const parameterNames = [
774
+ "queue",
775
+ "market",
776
+ "desk",
777
+ "recordIds"
778
+ ];
779
+ return (tx) => tx.moveCall({
780
+ package: packageAddress,
781
+ module: "queue",
782
+ function: "cleanup",
783
+ arguments: normalizeMoveArguments({
784
+ ...options.arguments,
785
+ desk: options.arguments?.desk ?? options.config?.orderDesk
786
+ }, argumentsTypes, parameterNames)
787
+ });
788
+ }
789
+ /**
790
+ * Run one bounded settlement phase on this queue and return the phase the queue is
791
+ * in afterwards, which the next call runs (`phase_drain`, `phase_pay`, or
792
+ * `phase_done`). Permissionless; aborts `EMarketNotExpired` before expiry.
793
+ *
794
+ * - DRAIN, while unfinished orders remain: refund them in τ order with reason 5,
795
+ * visiting at most the policy's `settle_refund_batch` records, refunded or not.
796
+ * No pruning and no account rows, so each refund loads its record alone. A
797
+ * refund the receive address cannot take is parked in its record. Runs before
798
+ * and after Predict settles, and while Predict is frozen.
799
+ * - PAY, once nothing is unfinished and Predict has settled the market: from the
800
+ * payout cursor, visit at most `settle_payout_batch` records. Each Open record
801
+ * is paid its settled payout through `try_pay_settled` (zero for a loser),
802
+ * marked Closed, and reported with `OpenRecordSettled`. A record the market
803
+ * cannot pay, or whose receive address is denied, stays Open with
804
+ * `OpenRecordPayoutSkipped`, and `pay_open` pays it later. Before Predict
805
+ * settles, a PAY call changes nothing.
806
+ * - DONE: the call whose walk reaches the last record emits
807
+ * `MarketPayoutsCompleted`; later calls change nothing. Skipped records are
808
+ * still paid through `pay_open`.
809
+ *
810
+ * The keeper sends one call per transaction until it returns `phase_done()`.
811
+ */
812
+ function settleStep(options) {
813
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
814
+ const argumentsTypes = [
815
+ null,
816
+ null,
817
+ null,
818
+ null,
819
+ "0x2::deny_list::DenyList",
820
+ "0x2::clock::Clock"
821
+ ];
822
+ const parameterNames = [
823
+ "queue",
824
+ "market",
825
+ "desk",
826
+ "config"
827
+ ];
828
+ return (tx) => tx.moveCall({
829
+ package: packageAddress,
830
+ module: "queue",
831
+ function: "settle_step",
832
+ arguments: normalizeMoveArguments({
833
+ ...options.arguments,
834
+ desk: options.arguments?.desk ?? options.config?.orderDesk,
835
+ config: options.arguments?.config ?? options.config?.protocolConfig
836
+ }, argumentsTypes, parameterNames)
837
+ });
838
+ }
839
+ /**
840
+ * Pay one Open record of a settled market its settled payout through Predict's
841
+ * `try_pay_settled`, at any time after settlement, before or after `settle_step`
842
+ * completes: the record the payout walk skipped because the market was short of
843
+ * cash or its receive address was denied. Permissionless. Emits
844
+ * `OpenRecordSettled` and closes the record, or emits `OpenRecordPayoutSkipped`
845
+ * and leaves it Open if the cause persists. A missing or non-Open record is left
846
+ * alone. Aborts `EMarketNotSettled` before Predict settles the market.
847
+ */
848
+ function payOpen(options) {
849
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
850
+ const argumentsTypes = [
851
+ null,
852
+ null,
853
+ null,
854
+ null,
855
+ "u64",
856
+ "0x2::deny_list::DenyList",
857
+ "0x2::clock::Clock"
858
+ ];
859
+ const parameterNames = [
860
+ "queue",
861
+ "market",
862
+ "desk",
863
+ "config",
864
+ "recordId"
865
+ ];
866
+ return (tx) => tx.moveCall({
867
+ package: packageAddress,
868
+ module: "queue",
869
+ function: "pay_open",
870
+ arguments: normalizeMoveArguments({
871
+ ...options.arguments,
872
+ desk: options.arguments?.desk ?? options.config?.orderDesk,
873
+ config: options.arguments?.config ?? options.config?.protocolConfig
874
+ }, argumentsTypes, parameterNames)
875
+ });
876
+ }
877
+ /**
878
+ * Send a finished record's parked funds, change or a refund its receive address
879
+ * could not take, to that address once a send would go through (`denied` is
880
+ * false). Permissionless: the funds go only to the record's own receive address.
881
+ * Emits `RecordFundsClaimed` and returns the amount sent, or returns `0` and
882
+ * changes nothing for a missing or unfinished record, one with nothing parked, or
883
+ * an address still denied.
884
+ */
885
+ function claimParked(options) {
886
+ const packageAddress = options.package ?? options.config?.predictOrdersPackageId ?? "@local-pkg/deepbook_predict_orders";
887
+ const argumentsTypes = [
888
+ null,
889
+ null,
890
+ "u64",
891
+ "0x2::deny_list::DenyList",
892
+ "0x2::clock::Clock"
893
+ ];
894
+ const parameterNames = [
895
+ "queue",
896
+ "desk",
897
+ "recordId"
898
+ ];
899
+ return (tx) => tx.moveCall({
900
+ package: packageAddress,
901
+ module: "queue",
902
+ function: "claim_parked",
903
+ arguments: normalizeMoveArguments({
904
+ ...options.arguments,
905
+ desk: options.arguments?.desk ?? options.config?.orderDesk
906
+ }, argumentsTypes, parameterNames)
907
+ });
908
+ }
909
+
910
+ //#endregion
911
+ export { adminRefund, claimParked, cleanup, commit, createAndShare, enqueueExactAmount, enqueueExactCost, enqueueExactQuantity, enqueueRedeemOpen, order, payOpen, payoutProgress, pendingCounts, queueHeads, queueStuck, queue_exports, quoteRedeemOpen, refund, resolve, settleStep, waitingCohorts, waitingOrders };
912
+ //# sourceMappingURL=queue.mjs.map