@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
@@ -15,28 +15,33 @@
15
15
  * anything the caller supplies: rotations are driven by measured subtree height,
16
16
  * which bounds depth at `O(log n)` for _every_ tick set rather than in expectation
17
17
  * over a random one. Depth is the cost model that matters — each node is a
18
- * dynamic-field child, and `apply_at` and `settlement_prefix_payout` touch one per
19
- * level against a per-transaction cached-object ceiling.
18
+ * dynamic-field child, and `apply_at` and `prefix_pay` touch one per level against
19
+ * a per-transaction cached-object ceiling.
20
20
  *
21
21
  * It tracks each order's quantity, which is also its settled payout: a winning
22
22
  * order pays its full quantity. Live cash backing is the max-point payout plus a
23
23
  * buffer over the disjoint-book gap; the tree's max-point term is the floor anchor
24
24
  * of that enforced reserve.
25
25
  *
26
- * Shape carries no value for a consistent index: `combine_summaries` is
27
- * associative over the in-order sequence, so any arrangement of the same
28
- * boundaries yields identical summaries, settlement prefixes, and linear-walk
29
- * totals. That holds only while every prefix is non-negative, which a consistent
30
- * book guarantees. Under a caller/index desync the settlement walk's underflow
31
- * abort depends on which prefixes a given shape happens to visit, so it is not a
32
- * desync detector — the per-boundary underflow in `apply_net_delta` is the
33
- * authority.
26
+ * Shape carries no value for a consistent index: `combine` is associative over the
27
+ * in-order sequence, so any arrangement of the same boundaries yields identical
28
+ * summaries, settlement prefixes, and linear-walk totals. That holds only while
29
+ * every prefix is non-negative, which a consistent book guarantees. Under a
30
+ * caller/index desync the settlement walk's underflow abort depends on which
31
+ * prefixes a given shape happens to visit, so it is not a desync detector — the
32
+ * per-boundary underflow in `apply_net` is the authority.
34
33
  *
35
34
  * The module also owns the valuation snapshot for the resumable flush: while a
36
35
  * flush generation is active, each node lazily captures its boundary quantities
37
36
  * immediately before its first mutation under that generation (an untouched node
38
- * is its own snapshot), and `walk_linear_frozen` prices the tree exactly as it
39
- * stood at the snapshot instant through the same walk the live read uses.
37
+ * is its own snapshot), and `walk_frozen` prices the tree exactly as it stood at
38
+ * the snapshot instant through the same walk the live read uses.
39
+ *
40
+ * Delayed execution adds pins: a waiting order's boundary ticks, passed in as
41
+ * `pins` (tick -> count of waiting orders; a key is present only while its count
42
+ * is positive). Enqueue creates the nodes up front (`ensure_node`), no deletion
43
+ * path removes a pinned node, and a resolve fill inserts over existing nodes only
44
+ * (`insert_exist`), so the keeper never creates a node.
40
45
  */
41
46
 
42
47
  import { MoveStruct } from '../utils/index.js';
@@ -61,9 +66,9 @@ export const StrikePayoutTree = new MoveStruct({
61
66
  */
62
67
  snapshot_seq: U64,
63
68
  /**
64
- * True from `activate_snapshot` until `release_snapshot`/`deactivate_snapshot`.
65
- * While set, mutations capture shadows and emptied nodes with shadow quantities
66
- * are retained for the frozen walk instead of removed.
69
+ * True from `snap_on` until `snap_done`/`snap_off`. While set, mutations capture
70
+ * shadows and emptied nodes with shadow quantities are retained for the frozen
71
+ * walk instead of removed.
67
72
  */
68
73
  snapshot_active: bcs.bool(),
69
74
  /** `base` as of the snapshot instant, captured eagerly at activation. */
@@ -76,12 +81,11 @@ export const PayoutSummary = new MoveStruct({
76
81
  start: U64,
77
82
  end: U64,
78
83
  /**
79
- * Never exceeds `start`, by construction in `boundary_summary` and
80
- * `combine_summaries`. That bound is what makes `combine_summaries` associative at
81
- * u64 scale — and therefore what makes the tree's shape irrelevant to every value
82
- * it reports. A summary term that could outgrow `start` would break
83
- * shape-independence with no test to catch it, and would also abort
84
- * `strike_exposure`'s plain `total - max` subtraction.
84
+ * Never exceeds `start`, by construction in `bound_sum` and `combine`. That bound
85
+ * is what makes `combine` associative at u64 scale — and therefore what makes the
86
+ * tree's shape irrelevant to every value it reports. A summary term that could
87
+ * outgrow `start` would break shape-independence with no test to catch it, and
88
+ * would also abort `strike_exposure`'s plain `total - max` subtraction.
85
89
  */
86
90
  max_payout_prefix_gain: U64,
87
91
  },
@@ -43,6 +43,47 @@ export const ExpiryProfitMaterialized = new MoveStruct({
43
43
  pending_protocol_profit_after: U64,
44
44
  },
45
45
  });
46
+ export const ExpiryPnl = new MoveStruct({
47
+ name: `${$moduleName}::ExpiryPnl`,
48
+ fields: {
49
+ pool_vault_id: bcs.Address,
50
+ expiry_market_id: bcs.Address,
51
+ propbook_underlying_id: bcs.u32(),
52
+ /**
53
+ * Start of the market's cadence period (`expiry` minus the cadence period), in
54
+ * milliseconds. The market's creation transaction may land before it.
55
+ */
56
+ period_start_ms: U64,
57
+ expiry: U64,
58
+ settlement_price: U64,
59
+ sent_to_expiry: U64,
60
+ received_from_expiry: U64,
61
+ /**
62
+ * True when `received_from_expiry >= sent_to_expiry`; break-even reports a zero
63
+ * profit.
64
+ */
65
+ in_profit: bcs.bool(),
66
+ /** Absolute difference between `received_from_expiry` and `sent_to_expiry`. */
67
+ amount: U64,
68
+ },
69
+ });
70
+ export const ExpiryPnlRealized = new MoveStruct({
71
+ name: `${$moduleName}::ExpiryPnlRealized`,
72
+ fields: {
73
+ pool_vault_id: bcs.Address,
74
+ expiry_market_id: bcs.Address,
75
+ propbook_underlying_id: bcs.u32(),
76
+ expiry: U64,
77
+ settlement_price: U64,
78
+ /** False only for a loss, which only an expiry's first emission can report. */
79
+ in_profit: bcs.bool(),
80
+ /**
81
+ * Magnitude of the change in the gross realized result since the previous
82
+ * emission.
83
+ */
84
+ amount: U64,
85
+ },
86
+ });
46
87
  export const SupplyRequested = new MoveStruct({
47
88
  name: `${$moduleName}::SupplyRequested`,
48
89
  fields: {
@@ -222,6 +263,14 @@ export const CapitalLocked = new MoveStruct({
222
263
  amount: U64,
223
264
  },
224
265
  });
266
+ export const UsdcAddedToPlp = new MoveStruct({
267
+ name: `${$moduleName}::UsdcAddedToPlp`,
268
+ fields: {
269
+ pool_vault_id: bcs.Address,
270
+ contributor: bcs.Address,
271
+ amount: U64,
272
+ },
273
+ });
225
274
  export const FeeIncentivesSponsored = new MoveStruct({
226
275
  name: `${$moduleName}::FeeIncentivesSponsored`,
227
276
  fields: {
@@ -231,6 +280,22 @@ export const FeeIncentivesSponsored = new MoveStruct({
231
280
  reserve_after: U64,
232
281
  },
233
282
  });
283
+ export const FeeIncentivesWithdrawn = new MoveStruct({
284
+ name: `${$moduleName}::FeeIncentivesWithdrawn`,
285
+ fields: {
286
+ pool_vault_id: bcs.Address,
287
+ amount: U64,
288
+ reserve_after: U64,
289
+ },
290
+ });
291
+ export const FeeIncentiveLifetimeCapSnapshotted = new MoveStruct({
292
+ name: `${$moduleName}::FeeIncentiveLifetimeCapSnapshotted`,
293
+ fields: {
294
+ pool_vault_id: bcs.Address,
295
+ expiry_market_id: bcs.Address,
296
+ fee_incentive_lifetime_cap: U64,
297
+ },
298
+ });
234
299
  export const FeeIncentivesAllocated = new MoveStruct({
235
300
  name: `${$moduleName}::FeeIncentivesAllocated`,
236
301
  fields: {
@@ -0,0 +1,6 @@
1
+ /**************************************************************
2
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
3
+ **************************************************************/
4
+ export interface DeepbookPredictMathConfig {
5
+ predictMathPackageId?: string;
6
+ }
@@ -0,0 +1,196 @@
1
+ /**************************************************************
2
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
3
+ **************************************************************/
4
+
5
+ /**
6
+ * A Pyth Lazer price decoded from a verified update, for Predict's order-flow
7
+ * commit.
8
+ *
9
+ * A `LazerPrice` is built only from a `pyth_lazer::update::Update`, which only
10
+ * Pyth's verifier produces, so holding one proves a Pyth signature over its feed,
11
+ * channel, timestamps, and price. It has `copy` and `drop` but not `store`, so it
12
+ * lives within one transaction. The decode is Predict v4's queue commit decode: it
13
+ * aborts on an update that does not carry the requested feed or lacks its price,
14
+ * exponent, or feed-update-time property, because the caller then passed the wrong
15
+ * update, and it returns `none` only when the feed has no usable price at that
16
+ * tick: an empty price or update time, or a price that does not normalize to
17
+ * Predict's pricing-safe 1e9 spot.
18
+ */
19
+
20
+ import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
21
+ import { bcs } from '@mysten/sui/bcs';
22
+ import { U64 } from '../../bcs/integers.js';
23
+ import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
24
+ const $moduleName = '@local-pkg/deepbook_predict_math::lazer_price';
25
+ export const LazerPrice = new MoveStruct({
26
+ name: `${$moduleName}::LazerPrice`,
27
+ fields: {
28
+ feed_id: bcs.u32(),
29
+ /**
30
+ * A Lazer channel id: `channel_fixed_rate_50ms!()`, `channel_fixed_rate_200ms!()`,
31
+ * or `1` for real-time.
32
+ */
33
+ channel: bcs.u8(),
34
+ /** The update's timestamp, in µs. */
35
+ envelope_us: U64,
36
+ /** The feed's own update time, in µs. Never after the envelope. */
37
+ generation_us: U64,
38
+ /**
39
+ * The price normalized to 1e9, rounded down when the source is finer; positive and
40
+ * at most `u64::MAX / 100`.
41
+ */
42
+ spot: U64,
43
+ },
44
+ });
45
+ export interface FromUpdateArguments {
46
+ update: TransactionArgument;
47
+ feedId: RawTransactionArgument<number>;
48
+ }
49
+ export interface FromUpdateOptions {
50
+ package?: string;
51
+ arguments:
52
+ FromUpdateArguments | [update: TransactionArgument, feedId: RawTransactionArgument<number>];
53
+ config?: {
54
+ predictMathPackageId?: string;
55
+ };
56
+ }
57
+ /**
58
+ * Decode `feed_id` from a verified Lazer update. `none` when the feed's price or
59
+ * update time is empty at this tick, or its price does not normalize to a
60
+ * pricing-safe spot. Aborts `EFeedMissing` when the update does not carry the feed
61
+ * and `EPropertyNotRequested` when the feed lacks the price, exponent, or
62
+ * update-time property, because the caller then passed the wrong update, and
63
+ * `EGenerationAfterEnvelope` when the feed claims an update time after the
64
+ * envelope that carries it.
65
+ *
66
+ * Uses Lazer's v1 `Update`, which Pyth marked deprecated on Mainnet but still
67
+ * serves; a later library upgrade adds a constructor for v2.
68
+ */
69
+ export function fromUpdate(options: FromUpdateOptions) {
70
+ const packageAddress =
71
+ options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
72
+ const argumentsTypes = [null, 'u32'] satisfies (string | null)[];
73
+ const parameterNames = ['update', 'feedId'];
74
+ return (tx: Transaction) =>
75
+ tx.moveCall({
76
+ package: packageAddress,
77
+ module: 'lazer_price',
78
+ function: 'from_update',
79
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
80
+ });
81
+ }
82
+ export interface FeedIdArguments {
83
+ price: TransactionArgument;
84
+ }
85
+ export interface FeedIdOptions {
86
+ package?: string;
87
+ arguments: FeedIdArguments | [price: TransactionArgument];
88
+ config?: {
89
+ predictMathPackageId?: string;
90
+ };
91
+ }
92
+ export function feedId(options: FeedIdOptions) {
93
+ const packageAddress =
94
+ options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
95
+ const argumentsTypes = [null] satisfies (string | null)[];
96
+ const parameterNames = ['price'];
97
+ return (tx: Transaction) =>
98
+ tx.moveCall({
99
+ package: packageAddress,
100
+ module: 'lazer_price',
101
+ function: 'feed_id',
102
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
103
+ });
104
+ }
105
+ export interface ChannelArguments {
106
+ price: TransactionArgument;
107
+ }
108
+ export interface ChannelOptions {
109
+ package?: string;
110
+ arguments: ChannelArguments | [price: TransactionArgument];
111
+ config?: {
112
+ predictMathPackageId?: string;
113
+ };
114
+ }
115
+ export function channel(options: ChannelOptions) {
116
+ const packageAddress =
117
+ options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
118
+ const argumentsTypes = [null] satisfies (string | null)[];
119
+ const parameterNames = ['price'];
120
+ return (tx: Transaction) =>
121
+ tx.moveCall({
122
+ package: packageAddress,
123
+ module: 'lazer_price',
124
+ function: 'channel',
125
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
126
+ });
127
+ }
128
+ export interface EnvelopeUsArguments {
129
+ price: TransactionArgument;
130
+ }
131
+ export interface EnvelopeUsOptions {
132
+ package?: string;
133
+ arguments: EnvelopeUsArguments | [price: TransactionArgument];
134
+ config?: {
135
+ predictMathPackageId?: string;
136
+ };
137
+ }
138
+ export function envelopeUs(options: EnvelopeUsOptions) {
139
+ const packageAddress =
140
+ options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
141
+ const argumentsTypes = [null] satisfies (string | null)[];
142
+ const parameterNames = ['price'];
143
+ return (tx: Transaction) =>
144
+ tx.moveCall({
145
+ package: packageAddress,
146
+ module: 'lazer_price',
147
+ function: 'envelope_us',
148
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
149
+ });
150
+ }
151
+ export interface GenerationUsArguments {
152
+ price: TransactionArgument;
153
+ }
154
+ export interface GenerationUsOptions {
155
+ package?: string;
156
+ arguments: GenerationUsArguments | [price: TransactionArgument];
157
+ config?: {
158
+ predictMathPackageId?: string;
159
+ };
160
+ }
161
+ export function generationUs(options: GenerationUsOptions) {
162
+ const packageAddress =
163
+ options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
164
+ const argumentsTypes = [null] satisfies (string | null)[];
165
+ const parameterNames = ['price'];
166
+ return (tx: Transaction) =>
167
+ tx.moveCall({
168
+ package: packageAddress,
169
+ module: 'lazer_price',
170
+ function: 'generation_us',
171
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
172
+ });
173
+ }
174
+ export interface SpotArguments {
175
+ price: TransactionArgument;
176
+ }
177
+ export interface SpotOptions {
178
+ package?: string;
179
+ arguments: SpotArguments | [price: TransactionArgument];
180
+ config?: {
181
+ predictMathPackageId?: string;
182
+ };
183
+ }
184
+ export function spot(options: SpotOptions) {
185
+ const packageAddress =
186
+ options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
187
+ const argumentsTypes = [null] satisfies (string | null)[];
188
+ const parameterNames = ['price'];
189
+ return (tx: Transaction) =>
190
+ tx.moveCall({
191
+ package: packageAddress,
192
+ module: 'lazer_price',
193
+ function: 'spot',
194
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
195
+ });
196
+ }