@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
@@ -1,3 +1,5 @@
1
+ import { PredictInputError } from "../errors.mjs";
2
+
1
3
  //#region src/predict/config/generated.ts
2
4
  function toGeneratedConfig(cfg) {
3
5
  return {
@@ -11,7 +13,34 @@ function toGeneratedConfig(cfg) {
11
13
  accountRegistry: cfg.objects.accountRegistry
12
14
  };
13
15
  }
16
+ /**
17
+ * Project a config that records delayed execution onto {@link OrdersGeneratedConfig}. Throws
18
+ * `PredictInputError` while the config lacks the Predict upgrade, the companion package, its desk
19
+ * or its queue registry: building a queued order against a guessed package would abort on chain
20
+ * or, worse, address the wrong one.
21
+ */
22
+ function toOrdersConfig(cfg) {
23
+ const { predictDelayedExecution, predictOrders, predictOrdersV1, predictMath } = cfg.packages;
24
+ const { orderDesk, queueRegistry } = cfg.objects;
25
+ if (!predictDelayedExecution || !predictOrders || !orderDesk || !queueRegistry) {
26
+ const missing = [
27
+ !predictDelayedExecution && "`packages.predictDelayedExecution`",
28
+ !predictOrders && "`packages.predictOrders`",
29
+ !orderDesk && "`objects.orderDesk`",
30
+ !queueRegistry && "`objects.queueRegistry`"
31
+ ].filter(Boolean);
32
+ throw new PredictInputError(`delayed execution isn't recorded for ${cfg.network} in this SDK version (missing ${missing.join(", ")}): pass a \`config\` that records the Predict upgrade, the \`deepbook_predict_orders\` package, its order desk and its queue registry`);
33
+ }
34
+ return {
35
+ ...toGeneratedConfig(cfg),
36
+ predictOrdersPackageId: predictOrders,
37
+ predictOrdersPackageIdV1: predictOrdersV1 ?? predictOrders,
38
+ predictMathPackageId: predictMath,
39
+ orderDesk,
40
+ queueRegistry
41
+ };
42
+ }
14
43
 
15
44
  //#endregion
16
- export { toGeneratedConfig };
45
+ export { toGeneratedConfig, toOrdersConfig };
17
46
  //# sourceMappingURL=generated.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"generated.mjs","names":[],"sources":["../../../src/predict/config/generated.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { AccountConfig } from '../../account.js';\nimport type { DeepbookPredictConfig } from '../../contracts/deepbook_predict/config-arguments.js';\nimport type { PredictConfig } from './types.js';\n\n/**\n * The flat config slice the generated bindings resolve `options.config` against, projected from\n * the nested public `PredictConfig`. Each generated call declares only the keys it consumes, so a\n * single object carrying all of them satisfies every call site.\n *\n * Typed as the intersection of the two generated interfaces on purpose: if codegen adds, drops, or\n * renames a config key, this file stops compiling instead of silently building a PTB against the\n * wrong object.\n *\n * `predictPackageId` is narrowed to `string` because codegen types package ids as optional, while\n * this projection always supplies one. `predictPackageIdV1` separately supplies the original\n * identity for existing struct tags and dynamic-field keys. The two account ids restate a narrowing\n * `AccountConfig` already applies, so they are redundant today; they are kept so this projection\n * still compiles to plain ids if that package ever widens them back.\n */\nexport type GeneratedConfig = DeepbookPredictConfig &\n\tAccountConfig & {\n\t\tpredictPackageId: string;\n\t\tpredictPackageIdV1: string;\n\t\taccountPackageId: string;\n\t\taccountRegistry: string;\n\t};\n\nexport function toGeneratedConfig(cfg: PredictConfig): GeneratedConfig {\n\treturn {\n\t\tpredictPackageId: cfg.packages.predict,\n\t\tpredictPackageIdV1: cfg.packages.predictV1 ?? cfg.packages.predict,\n\t\taccountPackageId: cfg.packages.account,\n\t\tprotocolConfig: cfg.objects.protocolConfig,\n\t\tpoolVault: cfg.objects.poolVault,\n\t\tregistry: cfg.objects.registry,\n\t\toracleRegistry: cfg.objects.oracleRegistry,\n\t\taccountRegistry: cfg.objects.accountRegistry,\n\t};\n}\n"],"mappings":";AA6BA,SAAgB,kBAAkB,KAAqC;AACtE,QAAO;EACN,kBAAkB,IAAI,SAAS;EAC/B,oBAAoB,IAAI,SAAS,aAAa,IAAI,SAAS;EAC3D,kBAAkB,IAAI,SAAS;EAC/B,gBAAgB,IAAI,QAAQ;EAC5B,WAAW,IAAI,QAAQ;EACvB,UAAU,IAAI,QAAQ;EACtB,gBAAgB,IAAI,QAAQ;EAC5B,iBAAiB,IAAI,QAAQ;EAC7B"}
1
+ {"version":3,"file":"generated.mjs","names":[],"sources":["../../../src/predict/config/generated.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { AccountConfig } from '../../account.js';\nimport type { DeepbookPredictConfig } from '../../contracts/deepbook_predict/config-arguments.js';\nimport type { DeepbookPredictMathConfig } from '../../contracts/deepbook_predict_math/config-arguments.js';\nimport type { DeepbookPredictOrdersConfig } from '../../contracts/deepbook_predict_orders/config-arguments.js';\nimport { PredictInputError } from '../errors.js';\nimport type { PredictConfig } from './types.js';\n\n/**\n * The flat config slice the generated bindings resolve `options.config` against, projected from\n * the nested public `PredictConfig`. Each generated call declares only the keys it consumes, so a\n * single object carrying all of them satisfies every call site.\n *\n * Typed as the intersection of the two generated interfaces on purpose: if codegen adds, drops, or\n * renames a config key, this file stops compiling instead of silently building a PTB against the\n * wrong object.\n *\n * `predictPackageId` is narrowed to `string` because codegen types package ids as optional, while\n * this projection always supplies one. `predictPackageIdV1` separately supplies the original\n * identity for existing struct tags and dynamic-field keys. The two account ids restate a narrowing\n * `AccountConfig` already applies, so they are redundant today; they are kept so this projection\n * still compiles to plain ids if that package ever widens them back.\n */\nexport type GeneratedConfig = DeepbookPredictConfig &\n\tAccountConfig & {\n\t\tpredictPackageId: string;\n\t\tpredictPackageIdV1: string;\n\t\taccountPackageId: string;\n\t\taccountRegistry: string;\n\t};\n\nexport function toGeneratedConfig(cfg: PredictConfig): GeneratedConfig {\n\treturn {\n\t\tpredictPackageId: cfg.packages.predict,\n\t\tpredictPackageIdV1: cfg.packages.predictV1 ?? cfg.packages.predict,\n\t\taccountPackageId: cfg.packages.account,\n\t\tprotocolConfig: cfg.objects.protocolConfig,\n\t\tpoolVault: cfg.objects.poolVault,\n\t\tregistry: cfg.objects.registry,\n\t\toracleRegistry: cfg.objects.oracleRegistry,\n\t\taccountRegistry: cfg.objects.accountRegistry,\n\t};\n}\n\n/**\n * {@link GeneratedConfig} plus the order-flow companion (`deepbook_predict_orders`) and the math\n * library: the slice the queued-order thunks and reads take. A queued order calls the companion,\n * which calls into Predict, so one object carries both packages' keys. `predictOrdersPackageIdV1`\n * is the companion's original ID, which types `OrderFlow` and the queue events.\n */\nexport type OrdersGeneratedConfig = GeneratedConfig &\n\tDeepbookPredictOrdersConfig &\n\tDeepbookPredictMathConfig & {\n\t\tpredictOrdersPackageId: string;\n\t\tpredictOrdersPackageIdV1: string;\n\t\torderDesk: string;\n\t\tqueueRegistry: string;\n\t};\n\n/**\n * Project a config that records delayed execution onto {@link OrdersGeneratedConfig}. Throws\n * `PredictInputError` while the config lacks the Predict upgrade, the companion package, its desk\n * or its queue registry: building a queued order against a guessed package would abort on chain\n * or, worse, address the wrong one.\n */\nexport function toOrdersConfig(cfg: PredictConfig): OrdersGeneratedConfig {\n\tconst { predictDelayedExecution, predictOrders, predictOrdersV1, predictMath } = cfg.packages;\n\tconst { orderDesk, queueRegistry } = cfg.objects;\n\tif (!predictDelayedExecution || !predictOrders || !orderDesk || !queueRegistry) {\n\t\tconst missing = [\n\t\t\t!predictDelayedExecution && '`packages.predictDelayedExecution`',\n\t\t\t!predictOrders && '`packages.predictOrders`',\n\t\t\t!orderDesk && '`objects.orderDesk`',\n\t\t\t!queueRegistry && '`objects.queueRegistry`',\n\t\t].filter(Boolean);\n\t\tthrow new PredictInputError(\n\t\t\t`delayed execution isn't recorded for ${cfg.network} in this SDK version (missing ` +\n\t\t\t\t`${missing.join(', ')}): pass a \\`config\\` that records the Predict upgrade, the ` +\n\t\t\t\t'`deepbook_predict_orders` package, its order desk and its queue registry',\n\t\t);\n\t}\n\treturn {\n\t\t...toGeneratedConfig(cfg),\n\t\tpredictOrdersPackageId: predictOrders,\n\t\tpredictOrdersPackageIdV1: predictOrdersV1 ?? predictOrders,\n\t\tpredictMathPackageId: predictMath,\n\t\torderDesk,\n\t\tqueueRegistry,\n\t};\n}\n"],"mappings":";;;AAgCA,SAAgB,kBAAkB,KAAqC;AACtE,QAAO;EACN,kBAAkB,IAAI,SAAS;EAC/B,oBAAoB,IAAI,SAAS,aAAa,IAAI,SAAS;EAC3D,kBAAkB,IAAI,SAAS;EAC/B,gBAAgB,IAAI,QAAQ;EAC5B,WAAW,IAAI,QAAQ;EACvB,UAAU,IAAI,QAAQ;EACtB,gBAAgB,IAAI,QAAQ;EAC5B,iBAAiB,IAAI,QAAQ;EAC7B;;;;;;;;AAwBF,SAAgB,eAAe,KAA2C;CACzE,MAAM,EAAE,yBAAyB,eAAe,iBAAiB,gBAAgB,IAAI;CACrF,MAAM,EAAE,WAAW,kBAAkB,IAAI;AACzC,KAAI,CAAC,2BAA2B,CAAC,iBAAiB,CAAC,aAAa,CAAC,eAAe;EAC/E,MAAM,UAAU;GACf,CAAC,2BAA2B;GAC5B,CAAC,iBAAiB;GAClB,CAAC,aAAa;GACd,CAAC,iBAAiB;GAClB,CAAC,OAAO,QAAQ;AACjB,QAAM,IAAI,kBACT,wCAAwC,IAAI,QAAQ,gCAChD,QAAQ,KAAK,KAAK,CAAC,uIAEvB;;AAEF,QAAO;EACN,GAAG,kBAAkB,IAAI;EACzB,wBAAwB;EACxB,0BAA0B,mBAAmB;EAC7C,sBAAsB;EACtB;EACA;EACA"}
@@ -13,12 +13,20 @@ import { MAINNET_PREDICT } from "../../deployments/mainnet.mjs";
13
13
  */
14
14
  const MAINNET_CONFIG = Object.freeze({
15
15
  network: "mainnet",
16
- packages: MAINNET_PREDICT.packages,
17
- objects: MAINNET_PREDICT.objects,
16
+ packages: Object.freeze({
17
+ ...MAINNET_PREDICT.packages,
18
+ predictDelayedExecution: "0x98235c5842831c9b5f51dc637cf34c91db2aca5510802eb6ebfec63f5b71a7bb"
19
+ }),
20
+ objects: Object.freeze({
21
+ ...MAINNET_PREDICT.objects,
22
+ orderDesk: "0x87b0a87262aacf58eaff567eed2fb7cb0f9cbc1f5ce33ef79216cd26d13a1b5b",
23
+ queueRegistry: "0x8d4f0c671862f065ac7f2c2cb24abc47cf75ed8fc8e5e52c1d4bdfa53eee164f"
24
+ }),
18
25
  quoteCoinType: MAINNET_PREDICT.quoteCoinType,
19
26
  coinTypes: MAINNET_PREDICT.coinTypes,
20
27
  units: MAINNET_PREDICT.units,
21
- underlyings: MAINNET_PREDICT.underlyings
28
+ underlyings: MAINNET_PREDICT.underlyings,
29
+ oracle: MAINNET_PREDICT.oracle
22
30
  });
23
31
 
24
32
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"mainnet.mjs","names":[],"sources":["../../../src/predict/config/mainnet.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { MAINNET_PREDICT } from '../../deployments/mainnet.js';\nimport type { PredictConfig } from './types.js';\n\n/**\n * Mainnet deployment constants, read from the shared generated record in\n * `src/deployments/` rather than transcribed here. `/account` and `/sessions` read slices of\n * that same record, so a redeploy (`pnpm sync-deployment`) moves every subpath together and\n * they cannot end up addressing different deployments.\n *\n * The record is generated from the deploy tooling's `deployment.mainnet.json`; see\n * `scripts/sync-deployment.ts`. `getDeployment('mainnet')` names the deployment and the\n * deepbookv3 commit these ids came from.\n */\nexport const MAINNET_CONFIG: PredictConfig = Object.freeze({\n\t// The record widens `network` to `string` so the published types don't pin a literal;\n\t// this file is the mainnet config by construction.\n\tnetwork: 'mainnet',\n\tpackages: MAINNET_PREDICT.packages,\n\tobjects: MAINNET_PREDICT.objects,\n\tquoteCoinType: MAINNET_PREDICT.quoteCoinType,\n\tcoinTypes: MAINNET_PREDICT.coinTypes,\n\tunits: MAINNET_PREDICT.units,\n\tunderlyings: MAINNET_PREDICT.underlyings,\n});\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,iBAAgC,OAAO,OAAO;CAG1D,SAAS;CACT,UAAU,gBAAgB;CAC1B,SAAS,gBAAgB;CACzB,eAAe,gBAAgB;CAC/B,WAAW,gBAAgB;CAC3B,OAAO,gBAAgB;CACvB,aAAa,gBAAgB;CAC7B,CAAC"}
1
+ {"version":3,"file":"mainnet.mjs","names":[],"sources":["../../../src/predict/config/mainnet.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { MAINNET_PREDICT } from '../../deployments/mainnet.js';\nimport type { PredictConfig } from './types.js';\n\n/**\n * Mainnet deployment constants, read from the shared generated record in\n * `src/deployments/` rather than transcribed here. `/account` and `/sessions` read slices of\n * that same record, so a redeploy (`pnpm sync-deployment`) moves every subpath together and\n * they cannot end up addressing different deployments.\n *\n * The record is generated from the deploy tooling's `deployment.mainnet.json`; see\n * `scripts/sync-deployment.ts`. `getDeployment('mainnet')` names the deployment and the\n * deepbookv3 commit these ids came from.\n */\nexport const MAINNET_CONFIG: PredictConfig = Object.freeze({\n\t// The record widens `network` to `string` so the published types don't pin a literal;\n\t// this file is the mainnet config by construction.\n\tnetwork: 'mainnet',\n\t// Delayed execution (DBU-885) is recorded on Mainnet. The generated record carries the package\n\t// IDs that move with upgrades (Predict, `deepbook_predict_orders`, `deepbook_predict_math`) and\n\t// the Lazer `State`. The three IDs pinned below are in no publication record and never move:\n\t// the Predict version that introduced delayed execution (Mainnet v4), which defines its new\n\t// types and events, and the `OrderDesk` and `QueueRegistry` that `deepbook_predict_orders`'s\n\t// `init` shared at publish.\n\tpackages: Object.freeze({\n\t\t...MAINNET_PREDICT.packages,\n\t\tpredictDelayedExecution: '0x98235c5842831c9b5f51dc637cf34c91db2aca5510802eb6ebfec63f5b71a7bb',\n\t}),\n\tobjects: Object.freeze({\n\t\t...MAINNET_PREDICT.objects,\n\t\torderDesk: '0x87b0a87262aacf58eaff567eed2fb7cb0f9cbc1f5ce33ef79216cd26d13a1b5b',\n\t\tqueueRegistry: '0x8d4f0c671862f065ac7f2c2cb24abc47cf75ed8fc8e5e52c1d4bdfa53eee164f',\n\t}),\n\tquoteCoinType: MAINNET_PREDICT.quoteCoinType,\n\tcoinTypes: MAINNET_PREDICT.coinTypes,\n\tunits: MAINNET_PREDICT.units,\n\tunderlyings: MAINNET_PREDICT.underlyings,\n\toracle: MAINNET_PREDICT.oracle,\n});\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,iBAAgC,OAAO,OAAO;CAG1D,SAAS;CAOT,UAAU,OAAO,OAAO;EACvB,GAAG,gBAAgB;EACnB,yBAAyB;EACzB,CAAC;CACF,SAAS,OAAO,OAAO;EACtB,GAAG,gBAAgB;EACnB,WAAW;EACX,eAAe;EACf,CAAC;CACF,eAAe,gBAAgB;CAC/B,WAAW,gBAAgB;CAC3B,OAAO,gBAAgB;CACvB,aAAa,gBAAgB;CAC7B,QAAQ,gBAAgB;CACxB,CAAC"}
@@ -13,12 +13,20 @@ import { TESTNET_PREDICT } from "../../deployments/testnet.mjs";
13
13
  */
14
14
  const TESTNET_CONFIG = Object.freeze({
15
15
  network: "testnet",
16
- packages: TESTNET_PREDICT.packages,
17
- objects: TESTNET_PREDICT.objects,
16
+ packages: Object.freeze({
17
+ ...TESTNET_PREDICT.packages,
18
+ predictDelayedExecution: "0x0654ecbed7c0f2645d9de7cb6cf08e65c2ee05cdbb39a415f17a6bd1cd92e267"
19
+ }),
20
+ objects: Object.freeze({
21
+ ...TESTNET_PREDICT.objects,
22
+ orderDesk: "0x160fc026c4143f3dec36acfc6556379d54661d37fe28ad837b6a85e42aeddfea",
23
+ queueRegistry: "0xe9d75ed05b089d52a660a94b94963cdc89aeb7f3c75b57f76771454c81faae1f"
24
+ }),
18
25
  quoteCoinType: TESTNET_PREDICT.quoteCoinType,
19
26
  coinTypes: TESTNET_PREDICT.coinTypes,
20
27
  units: TESTNET_PREDICT.units,
21
- underlyings: TESTNET_PREDICT.underlyings
28
+ underlyings: TESTNET_PREDICT.underlyings,
29
+ oracle: TESTNET_PREDICT.oracle
22
30
  });
23
31
 
24
32
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"testnet.mjs","names":[],"sources":["../../../src/predict/config/testnet.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { TESTNET_PREDICT } from '../../deployments/testnet.js';\nimport type { PredictConfig } from './types.js';\n\n/**\n * Testnet deployment constants, read from the shared generated record in\n * `src/deployments/` rather than transcribed here. `/account` and `/sessions` read slices of\n * that same record, so a redeploy (`pnpm sync-deployment`) moves every subpath together and\n * they cannot end up addressing different deployments.\n *\n * The record is generated from the deploy tooling's `deployment.testnet.json`; see\n * `scripts/sync-deployment.ts`. `getDeployment('testnet')` names the deployment and the\n * deepbookv3 commit these ids came from.\n */\nexport const TESTNET_CONFIG: PredictConfig = Object.freeze({\n\t// The record widens `network` to `string` so the published types don't pin a literal;\n\t// this file is the testnet config by construction.\n\tnetwork: 'testnet',\n\tpackages: TESTNET_PREDICT.packages,\n\tobjects: TESTNET_PREDICT.objects,\n\tquoteCoinType: TESTNET_PREDICT.quoteCoinType,\n\tcoinTypes: TESTNET_PREDICT.coinTypes,\n\tunits: TESTNET_PREDICT.units,\n\tunderlyings: TESTNET_PREDICT.underlyings,\n});\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,iBAAgC,OAAO,OAAO;CAG1D,SAAS;CACT,UAAU,gBAAgB;CAC1B,SAAS,gBAAgB;CACzB,eAAe,gBAAgB;CAC/B,WAAW,gBAAgB;CAC3B,OAAO,gBAAgB;CACvB,aAAa,gBAAgB;CAC7B,CAAC"}
1
+ {"version":3,"file":"testnet.mjs","names":[],"sources":["../../../src/predict/config/testnet.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { TESTNET_PREDICT } from '../../deployments/testnet.js';\nimport type { PredictConfig } from './types.js';\n\n/**\n * Testnet deployment constants, read from the shared generated record in\n * `src/deployments/` rather than transcribed here. `/account` and `/sessions` read slices of\n * that same record, so a redeploy (`pnpm sync-deployment`) moves every subpath together and\n * they cannot end up addressing different deployments.\n *\n * The record is generated from the deploy tooling's `deployment.testnet.json`; see\n * `scripts/sync-deployment.ts`. `getDeployment('testnet')` names the deployment and the\n * deepbookv3 commit these ids came from.\n */\nexport const TESTNET_CONFIG: PredictConfig = Object.freeze({\n\t// The record widens `network` to `string` so the published types don't pin a literal;\n\t// this file is the testnet config by construction.\n\tnetwork: 'testnet',\n\t// Delayed execution (DBU-885) is recorded on Testnet. The generated record carries the package\n\t// IDs that move with upgrades (Predict, `deepbook_predict_orders`, `deepbook_predict_math`) and\n\t// the Lazer `State`. The three IDs pinned below are in no publication record and never move:\n\t// the Predict version that introduced delayed execution (Testnet v5), which defines its new\n\t// types and events, and the `OrderDesk` and `QueueRegistry` that `deepbook_predict_orders`'s\n\t// `init` shared at publish.\n\tpackages: Object.freeze({\n\t\t...TESTNET_PREDICT.packages,\n\t\tpredictDelayedExecution: '0x0654ecbed7c0f2645d9de7cb6cf08e65c2ee05cdbb39a415f17a6bd1cd92e267',\n\t}),\n\tobjects: Object.freeze({\n\t\t...TESTNET_PREDICT.objects,\n\t\torderDesk: '0x160fc026c4143f3dec36acfc6556379d54661d37fe28ad837b6a85e42aeddfea',\n\t\tqueueRegistry: '0xe9d75ed05b089d52a660a94b94963cdc89aeb7f3c75b57f76771454c81faae1f',\n\t}),\n\tquoteCoinType: TESTNET_PREDICT.quoteCoinType,\n\tcoinTypes: TESTNET_PREDICT.coinTypes,\n\tunits: TESTNET_PREDICT.units,\n\tunderlyings: TESTNET_PREDICT.underlyings,\n\toracle: TESTNET_PREDICT.oracle,\n});\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,iBAAgC,OAAO,OAAO;CAG1D,SAAS;CAOT,UAAU,OAAO,OAAO;EACvB,GAAG,gBAAgB;EACnB,yBAAyB;EACzB,CAAC;CACF,SAAS,OAAO,OAAO;EACtB,GAAG,gBAAgB;EACnB,WAAW;EACX,eAAe;EACf,CAAC;CACF,eAAe,gBAAgB;CAC/B,WAAW,gBAAgB;CAC3B,OAAO,gBAAgB;CACvB,aAAa,gBAAgB;CAC7B,QAAQ,gBAAgB;CACxB,CAAC"}
@@ -1,10 +1,41 @@
1
1
  //#region src/predict/config/types.d.ts
2
- /** The three published Move packages a Predict deployment spans. */
2
+ /**
3
+ * The published Move packages a Predict deployment spans.
4
+ *
5
+ * Delayed execution (DBU-885) ships as three packages: the Predict upgrade, the order-flow
6
+ * companion `deepbook_predict_orders` (a fresh publish), and the math library
7
+ * `deepbook_predict_math` (a fresh publish). The queued-order builders, reads and decoders need
8
+ * `predictDelayedExecution`, `predictOrders`, `objects.orderDesk` and `objects.queueRegistry` all
9
+ * recorded, and throw
10
+ * `PredictInputError` otherwise rather than address the wrong package. Pass a custom `config`
11
+ * (a localnet publish) to use them before a network record exists.
12
+ */
3
13
  interface PredictPackages {
4
14
  /** Latest published package ID, used for Move calls. */
5
15
  predict: string;
6
16
  /** Original ID for v1 structs/events. Omit only for an unupgraded custom deployment. */
7
17
  predictV1?: string;
18
+ /**
19
+ * The Predict version that introduced delayed execution (Mainnet v4, Testnet v5): the
20
+ * defining ID of the Predict types and events that version added (`ExpiryPnlRealized`,
21
+ * `FlushOperatorUpdated`, `OrderFlowUpdated`, `OrderReceipt`). A later upgrade does not move
22
+ * it, so it is pinned once per network rather than read from the latest publication.
23
+ */
24
+ predictDelayedExecution?: string;
25
+ /**
26
+ * Latest published `deepbook_predict_orders` package ID: the call target of every queued-order
27
+ * entry point (`queue::enqueue_*`, `commit`, `resolve`, `refund`, `settle_step`, …), the queue
28
+ * reads and the desk setters.
29
+ */
30
+ predictOrders?: string;
31
+ /**
32
+ * Original `deepbook_predict_orders` ID, which types `MarketQueue`, `OrderDesk`, the queue
33
+ * events and the `OrderFlow` witness. Omit until the package is first upgraded: it then
34
+ * defaults to `predictOrders`.
35
+ */
36
+ predictOrdersV1?: string;
37
+ /** The `deepbook_predict_math` package ID, for its pure calls and layouts. */
38
+ predictMath?: string;
8
39
  account: string;
9
40
  propbook: string;
10
41
  }
@@ -33,6 +64,17 @@ interface PredictConfig {
33
64
  poolVault: string;
34
65
  oracleRegistry: string;
35
66
  accountRegistry: string;
67
+ /**
68
+ * The order-flow companion's shared `OrderDesk`: the delayed-execution policy and the
69
+ * companion's version floor. Created once, by the package's `init` at publish.
70
+ */
71
+ orderDesk?: string;
72
+ /**
73
+ * The order-flow companion's shared `QueueRegistry`, created next to the desk by the same
74
+ * `init`. Each market's `MarketQueue` sits at an ID derived from it and the market
75
+ * (`deriveQueueId`), and `queue::create_and_share` writes it.
76
+ */
77
+ queueRegistry?: string;
36
78
  };
37
79
  /**
38
80
  * The deployment's settlement coin type. Always read this rather than assuming a type:
@@ -58,6 +100,13 @@ interface PredictConfig {
58
100
  positionQuantityDecimals: number;
59
101
  };
60
102
  underlyings: Record<string, UnderlyingConfig>;
103
+ /**
104
+ * Oracle objects only the delayed-execution filler needs. Optional: traders never pass
105
+ * them, and a filler can name the Lazer `State` per call instead.
106
+ */
107
+ oracle?: {
108
+ /** Pyth Lazer's shared `State`, which carries the current Lazer package ID. */pythLazerState?: string;
109
+ };
61
110
  }
62
111
  //#endregion
63
112
  export { PredictConfig, PredictPackages, UnderlyingConfig };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../../src/predict/config/types.ts"],"mappings":";;UAGiB,eAAA;EAAe;EAE/B,OAAA;EAF+B;EAI/B,SAAA;EACA,OAAA;EACA,QAAA;AAAA;;;AAQD;;;UAAiB,gBAAA;EAChB,MAAA;EACA,oBAAA;EAEA;EAAA,QAAA;EAIA;EAFA,sBAAA;EAEoB;EAApB,oBAAA;AAAA;;UAIgB,aAAA;EAChB,OAAA;EACA,QAAA,EAAU,eAAA;EACV,OAAA;IACC,QAAA;IACA,cAAA;IACA,SAAA;IACA,cAAA;IACA,eAAA;EAAA;EAHA;;;;;;EAWD,aAAA;EAM0B;;;;;EAA1B,SAAA;IAAa,GAAA;IAAa,IAAA;EAAA;EAQkB;EAN5C,KAAA;IACC,eAAA;IACA,eAAA;IACA,iBAAA;IACA,wBAAA;EAAA;EAED,WAAA,EAAa,MAAA,SAAe,gBAAA;AAAA"}
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../../src/predict/config/types.ts"],"mappings":";;AAaA;;;;;;;;;;UAAiB,eAAA;EA2BhB;EAzBA,OAAA;EAyBQ;EAvBR,SAAA;EA+BgC;;;;;;EAxBhC,uBAAA;EAgCA;;;AAID;;EA9BC,aAAA;EAgCU;;;;;EA1BV,eAAA;EA0BA;EAxBA,WAAA;EACA,OAAA;EACA,QAAA;AAAA;;;;;;UAQgB,gBAAA;EAChB,MAAA;EACA,oBAAA;EA2C0B;EAzC1B,QAAA;EA4CC;EA1CD,sBAAA;EA4CC;EA1CD,oBAAA;AAAA;;UAIgB,aAAA;EAChB,OAAA;EACA,QAAA,EAAU,eAAA;EACV,OAAA;IACC,QAAA;IACA,cAAA;IACA,SAAA;IACA,cAAA;IACA,eAAA;;;;;IAKA,SAAA;;;;;;IAMA,aAAA;EAAA;;;;;;;EAQD,aAAA;;;;;;EAMA,SAAA;IAAa,GAAA;IAAa,IAAA;EAAA;;EAE1B,KAAA;IACC,eAAA;IACA,eAAA;IACA,iBAAA;IACA,wBAAA;EAAA;EAED,WAAA,EAAa,MAAA,SAAe,gBAAA;;;;;EAK5B,MAAA;mFAEC,cAAA;EAAA;AAAA"}
@@ -3,7 +3,7 @@ import { POS_INF_TICK } from "./ticks.mjs";
3
3
 
4
4
  //#region src/predict/cost.d.ts
5
5
  declare namespace cost_d_exports {
6
- export { BUILDER_FEE_MULTIPLIER, Boundaries, CloseBookTerms, CongestionPolicy, CongestionState, FEE_INCENTIVE_SUBSIDY_RATE, FLOAT_SCALING, FeePolicy, MAX_BUILDER_FEE_RATE, MAX_QUANTITY_LOTS, MIN_PREMIUM, MintBookTerms, MintBudgetCost, MintBudgetInputs, MintCost, MintCostInputs, OrderRange, POSITION_LOT_SIZE, POS_INF_TICK, ProbabilitySource, RedeemLiveInputs, RedeemLiveProceeds, SHIPPED_FEE_POLICY, bernoulliFeeRate, boundaryProbabilities, builderFee, closeInventoryImpact, congestionPenaltyRate, decodeOrderRange, expiryFeeMultiplier, feeIncentiveSubsidy, inventoryImpactPotential, mintCost, mintCostForBudget, mintInventoryImpact, orderStrikes, rangeProbability, redeemLiveProceeds, sqrtDown, tradingFee };
6
+ export { BUILDER_FEE_MULTIPLIER, Boundaries, CloseBookTerms, CongestionPolicy, CongestionState, FEE_INCENTIVE_SUBSIDY_RATE, FLOAT_SCALING, FeePolicy, MAX_BUILDER_FEE_RATE, MAX_QUANTITY_LOTS, MIN_PREMIUM, MintBookTerms, MintBudgetCost, MintBudgetInputs, MintCost, MintCostInputs, OrderRange, POSITION_LOT_SIZE, POS_INF_TICK, ProbabilitySource, RedeemLiveInputs, RedeemLiveProceeds, SHIPPED_FEE_POLICY, bernoulliFeeRate, boundaryProbabilities, builderFee, closeInventoryImpact, congestionPenaltyRate, decodeOrderRange, expiryFeeMultiplier, feeIncentiveSubsidy, inventoryImpactPotential, mintCost, mintCostForBudget, mintInventoryImpact, orderStrikes, rangeProbability, redeemLiveProceeds, settledPayout, sqrtDown, tradingFee };
7
7
  }
8
8
  /** `math::float_scaling` — 1e9 is 1.0 for every rate and probability here. */
9
9
  declare const FLOAT_SCALING = 1000000000n;
@@ -15,7 +15,14 @@ declare const MIN_PREMIUM = 1000000n;
15
15
  declare const BUILDER_FEE_MULTIPLIER = 100000000n;
16
16
  /** `constants::max_builder_fee_rate` — cap on the builder fee as a share of quantity (0.5%). */
17
17
  declare const MAX_BUILDER_FEE_RATE = 5000000n;
18
- /** `constants::fee_incentive_subsidy_rate` — sponsor share of a trader's mint fee (20%). */
18
+ /**
19
+ * The default sponsor share of a trader's mint fee (20%), and the rate the chain reads while the
20
+ * admin hasn't set one.
21
+ * @deprecated From delayed execution (DBU-885) the rate is admin-set: read it with
22
+ * `protocol_config::fee_incentive_subsidy_rate` (`read.queue(...).protocol.feeIncentiveSubsidyRate`)
23
+ * and pass it as `feeIncentiveSubsidyRate`. A hardcoded 20% underquotes every mint once the rate
24
+ * moves.
25
+ */
19
26
  declare const FEE_INCENTIVE_SUBSIDY_RATE = 200000000n;
20
27
  /** `order::max_quantity_lots` — the order ID's 32-bit lot field. */
21
28
  declare const MAX_QUANTITY_LOTS: bigint;
@@ -24,8 +31,8 @@ declare function sqrtDown(x: bigint): bigint;
24
31
  /**
25
32
  * One market's fee policy: the `StrikeExposureConfig` it snapshotted at creation, in raw 1e9
26
33
  * rates. Snapshotted means later admin changes do NOT reprice a market already trading, so
27
- * read it per market (the `MarketCreated` event carries every field) rather than assuming the
28
- * template. The last three are the inventory-impact parameters, inert while
34
+ * read it per market with `read.feePolicy(market)` (the `MarketCreated` event carries every field
35
+ * too) rather than assuming the template. The last three are the inventory-impact parameters, inert while
29
36
  * `inventoryImpactMaxRate` is `0n` (the shipped value).
30
37
  */
31
38
  interface FeePolicy {
@@ -51,9 +58,11 @@ interface FeePolicy {
51
58
  /**
52
59
  * The shipped template (`config_constants` defaults): 10% Bernoulli fee, a 2.2% per-leg floor,
53
60
  * a one-day ramp window that is inert at a 1.0 multiplier, a 1%–99% entry band, and inventory
54
- * impact disabled. A market that was created under these values charges exactly this; one
55
- * created after an admin change does not, which is why the per-market snapshot is the real
56
- * answer. Verify against the deployment's `MarketCreated` before pricing money on it.
61
+ * impact disabled. Neither recorded deployment's template matches it any more: both charge a
62
+ * 20.4% Bernoulli fee, ramp it to 3× over the last 60 s and admit entries in 25%–75% (checked
63
+ * 2026-10-09), so a live market's costs from this policy come out low. Pass
64
+ * `read.feePolicy(market)` instead. This stays for tests and for a deployment still on the
65
+ * defaults.
57
66
  */
58
67
  declare const SHIPPED_FEE_POLICY: FeePolicy;
59
68
  /** A range's two boundary UP probabilities, raw 1e9. `null` is an infinite boundary — the
@@ -119,8 +128,9 @@ declare function tradingFee(policy: FeePolicy, boundaries: Boundaries, quantity:
119
128
  * multiple of its trading fee, capped as a share of quantity. */
120
129
  declare function builderFee(fee: bigint, quantity: bigint, hasBuilderCode: boolean): bigint;
121
130
  /** `expiry_market::fee_incentive_subsidy_amount` — a sponsor pays part of the trader's MINT
122
- * fee, bounded by the expiry's remaining sponsored balance. Mints only; redeems pay in full. */
123
- declare function feeIncentiveSubsidy(fee: bigint, feeIncentiveBalance: bigint): bigint;
131
+ * fee, bounded by the expiry's remaining sponsored balance. Mints only; redeems pay in full.
132
+ * `rate` is the protocol's `fee_incentive_subsidy_rate` (1e9-scaled), 20% when omitted. */
133
+ declare function feeIncentiveSubsidy(fee: bigint, feeIncentiveBalance: bigint, rate?: bigint): bigint;
124
134
  /**
125
135
  * `ewma::penalty_fee`'s firing test, as a per-unit RATE: `penalty_rate` when the transaction's
126
136
  * gas price is a high outlier against the market's pre-trade EWMA, else zero. It is a rate and
@@ -163,7 +173,15 @@ interface MintInputsBase {
163
173
  builderCode?: boolean;
164
174
  /** The expiry's remaining sponsored fee balance (`fee_incentive_balance`). Default `0n`. */
165
175
  feeIncentiveBalance?: number | bigint;
166
- /** Per-unit congestion surcharge rate — see {@link congestionPenaltyRate}. Default `0n`. */
176
+ /**
177
+ * The protocol's admin-set mint fee subsidy rate (`protocol_config::fee_incentive_subsidy_rate`),
178
+ * 1e9-scaled. Defaults to the 20% the chain reads while unset.
179
+ */
180
+ feeIncentiveSubsidyRate?: bigint;
181
+ /**
182
+ * Per-unit congestion surcharge rate — see {@link congestionPenaltyRate}. Default `0n`. A
183
+ * queued (delayed-execution) fill pays no congestion penalty, so queued previews keep it 0.
184
+ */
167
185
  penaltyRate?: bigint;
168
186
  /** Pre-trade payout-tree terms. Required when inventory impact is enabled. */
169
187
  book?: MintBookTerms;
@@ -341,6 +359,15 @@ interface OrderRange {
341
359
  /** Decode an order ID's range and quantity — the TypeScript mirror of `order::lower_tick` /
342
360
  * `higher_tick` / `quantity`. */
343
361
  declare function decodeOrderRange(orderId: bigint, lotSize?: bigint): OrderRange;
362
+ /**
363
+ * What an order pays at settlement, raw USDC: its full quantity when the settlement price lies
364
+ * in `(lower, higher]`, else 0. The mirror of `strike_exposure::settled_order_payout`, which
365
+ * rounds the settlement price up to the market's tick grid (`range_codec::limit_tick`) before
366
+ * comparing it with the order's ticks, so a price inside a tick counts as that tick's upper edge.
367
+ * Pass `read.settlement`'s `settlementPriceRaw` and `tickSizeRaw`, and the config's
368
+ * `units.positionLotSize` when it isn't the default.
369
+ */
370
+ declare function settledPayout(orderId: bigint, settlementPriceRaw: bigint, tickSizeRaw: bigint, lotSize?: bigint): bigint;
344
371
  /** The strikes an {@link OrderRange} prices against, in USD, with `null` for each infinite
345
372
  * side — the shape {@link boundaryProbabilities} takes. `tickSize` is the market's raw tick
346
373
  * size (`ActiveMarket.tickSize` in USD, or the raw value from the deployment). */
@@ -349,5 +376,5 @@ declare function orderStrikes(range: OrderRange, tickSizeRaw: bigint): {
349
376
  upper: number | null;
350
377
  };
351
378
  //#endregion
352
- export { cost_d_exports };
379
+ export { FeePolicy, cost_d_exports };
353
380
  //# sourceMappingURL=cost.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cost.d.mts","names":[],"sources":["../../src/predict/cost.ts"],"mappings":";;;;;;;;cA8Ca,aAAA;;cAEA,iBAAA;;cAEA,WAAA;;cAEA,sBAAA;;cAEA,oBAAA;;cAEA,0BAAA;;cAEA,iBAAA;;iBAgEG,QAAA,CAAS,CAAA;;;;;;;;UAcR,SAAA;;EAEhB,OAAA;;EAEA,MAAA;;EAEA,iBAAA;;EAEA,sBAAA;;EAEA,mBAAA;;EAEA,mBAAA;;EAEA,sBAAA;;EAEA,oBAAA;;EAEA,mBAAA;AAAA;;;AA5GD;;;;;cAsHa,kBAAA,EAAoB,SAAA;;;;UAehB,UAAA;EAjIJ;EAmIZ,OAAA;;EAEA,QAAA;AAAA;AAnID;;;AAAA,KAyIY,iBAAA,GACX,UAAA;EAAe,MAAA,EAAQ,YAAA;EAAc,KAAA;EAAsB,KAAA;AAAA;;UAG3C,eAAA;EAChB,IAAA;EACA,QAAA;AAAA;;UAIgB,gBAAA;EAChB,OAAA;EA9IgD;EAgJhD,WAAA;EAhJgD;EAkJhD,eAAA;AAAA;;;UAKgB,aAAA;EAvFiB;EAyFjC,SAAA;EA3EyB;EA6EzB,WAAA;EA7EyB;EA+EzB,cAAA;AAAA;;;UAKgB,cAAA,SAAuB,aAAA;EAxEvC;EA0EA,mBAAA;AAAA;;;iBAuDe,gBAAA,CAAiB,OAAA,UAAiB,WAAA;AAjHlD;;AAAA,iBA0HgB,mBAAA,CAAoB,MAAA,EAAQ,SAAA,EAAW,cAAA;;;AA3GvD;;;;iBA2IgB,UAAA,CACf,MAAA,EAAQ,SAAA,EACR,UAAA,EAAY,UAAA,EACZ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A,WAAA,UACA,OAAA;;;;iBAYe,YAAA,CACf,KAAA,EAAO,UAAA,EACP,WAAA;EACI,KAAA;EAAsB,KAAA;AAAA"}
@@ -1,8 +1,8 @@
1
1
  import { __exportAll } from "../_virtual/rolldown_runtime.mjs";
2
2
  import { PredictInputError } from "./errors.mjs";
3
- import { U64_MAX, fromRaw, usdcToRaw } from "./units.mjs";
4
- import { POS_INF_TICK } from "./ticks.mjs";
5
3
  import { upProbability } from "./pricing.mjs";
4
+ import { POS_INF_TICK } from "./ticks.mjs";
5
+ import { U64_MAX, fromRaw, usdcToRaw } from "./units.mjs";
6
6
 
7
7
  //#region src/predict/cost.ts
8
8
  var cost_exports = /* @__PURE__ */ __exportAll({
@@ -30,6 +30,7 @@ var cost_exports = /* @__PURE__ */ __exportAll({
30
30
  orderStrikes: () => orderStrikes,
31
31
  rangeProbability: () => rangeProbability,
32
32
  redeemLiveProceeds: () => redeemLiveProceeds,
33
+ settledPayout: () => settledPayout,
33
34
  sqrtDown: () => sqrtDown,
34
35
  tradingFee: () => tradingFee
35
36
  });
@@ -43,7 +44,14 @@ const MIN_PREMIUM = 1000000n;
43
44
  const BUILDER_FEE_MULTIPLIER = 100000000n;
44
45
  /** `constants::max_builder_fee_rate` — cap on the builder fee as a share of quantity (0.5%). */
45
46
  const MAX_BUILDER_FEE_RATE = 5000000n;
46
- /** `constants::fee_incentive_subsidy_rate` — sponsor share of a trader's mint fee (20%). */
47
+ /**
48
+ * The default sponsor share of a trader's mint fee (20%), and the rate the chain reads while the
49
+ * admin hasn't set one.
50
+ * @deprecated From delayed execution (DBU-885) the rate is admin-set: read it with
51
+ * `protocol_config::fee_incentive_subsidy_rate` (`read.queue(...).protocol.feeIncentiveSubsidyRate`)
52
+ * and pass it as `feeIncentiveSubsidyRate`. A hardcoded 20% underquotes every mint once the rate
53
+ * moves.
54
+ */
47
55
  const FEE_INCENTIVE_SUBSIDY_RATE = 200000000n;
48
56
  /** `order::max_quantity_lots` — the order ID's 32-bit lot field. */
49
57
  const MAX_QUANTITY_LOTS = (1n << 32n) - 1n;
@@ -101,9 +109,11 @@ function sqrtDown(x) {
101
109
  /**
102
110
  * The shipped template (`config_constants` defaults): 10% Bernoulli fee, a 2.2% per-leg floor,
103
111
  * a one-day ramp window that is inert at a 1.0 multiplier, a 1%–99% entry band, and inventory
104
- * impact disabled. A market that was created under these values charges exactly this; one
105
- * created after an admin change does not, which is why the per-market snapshot is the real
106
- * answer. Verify against the deployment's `MarketCreated` before pricing money on it.
112
+ * impact disabled. Neither recorded deployment's template matches it any more: both charge a
113
+ * 20.4% Bernoulli fee, ramp it to 3× over the last 60 s and admit entries in 25%–75% (checked
114
+ * 2026-10-09), so a live market's costs from this policy come out low. Pass
115
+ * `read.feePolicy(market)` instead. This stays for tests and for a deployment still on the
116
+ * defaults.
107
117
  */
108
118
  const SHIPPED_FEE_POLICY = Object.freeze({
109
119
  baseFee: 100000000n,
@@ -185,11 +195,13 @@ function builderFee(fee, quantity, hasBuilderCode) {
185
195
  return min(mulDown(fee, BUILDER_FEE_MULTIPLIER), mulDown(quantity, MAX_BUILDER_FEE_RATE));
186
196
  }
187
197
  /** `expiry_market::fee_incentive_subsidy_amount` — a sponsor pays part of the trader's MINT
188
- * fee, bounded by the expiry's remaining sponsored balance. Mints only; redeems pay in full. */
189
- function feeIncentiveSubsidy(fee, feeIncentiveBalance) {
198
+ * fee, bounded by the expiry's remaining sponsored balance. Mints only; redeems pay in full.
199
+ * `rate` is the protocol's `fee_incentive_subsidy_rate` (1e9-scaled), 20% when omitted. */
200
+ function feeIncentiveSubsidy(fee, feeIncentiveBalance, rate = FEE_INCENTIVE_SUBSIDY_RATE) {
190
201
  assertUint(fee, "fee");
191
202
  assertUint(feeIncentiveBalance, "feeIncentiveBalance");
192
- return min(mulDown(fee, FEE_INCENTIVE_SUBSIDY_RATE), feeIncentiveBalance);
203
+ assertUint(rate, "feeIncentiveSubsidyRate", FLOAT_SCALING);
204
+ return min(mulDown(fee, rate), feeIncentiveBalance);
193
205
  }
194
206
  /**
195
207
  * `ewma::penalty_fee`'s firing test, as a per-unit RATE: `penalty_rate` when the transaction's
@@ -323,7 +335,7 @@ function timeToExpiry(expiryMs, nowMs) {
323
335
  function mintQuoteAt(inputs, boundaries, quantity, timeToExpiryMs) {
324
336
  const premium = mulDown(rangeProbability(boundaries), quantity);
325
337
  const fee = tradingFee(inputs.fees, boundaries, quantity, timeToExpiryMs);
326
- const subsidy = feeIncentiveSubsidy(fee, rawAmount(inputs.feeIncentiveBalance ?? 0n));
338
+ const subsidy = feeIncentiveSubsidy(fee, rawAmount(inputs.feeIncentiveBalance ?? 0n), inputs.feeIncentiveSubsidyRate);
327
339
  const builder = builderFee(fee, quantity, inputs.builderCode ?? false);
328
340
  const penalty = mulDown(inputs.penaltyRate ?? 0n, quantity);
329
341
  const impact = inputs.book ? mintInventoryImpact(inputs.fees, inputs.book, quantity) : 0n;
@@ -540,6 +552,20 @@ function decodeOrderRange(orderId, lotSize = POSITION_LOT_SIZE) {
540
552
  quantity: (orderId >> QUANTITY_LOTS_OFFSET & U32_MASK) * lotSize
541
553
  };
542
554
  }
555
+ /**
556
+ * What an order pays at settlement, raw USDC: its full quantity when the settlement price lies
557
+ * in `(lower, higher]`, else 0. The mirror of `strike_exposure::settled_order_payout`, which
558
+ * rounds the settlement price up to the market's tick grid (`range_codec::limit_tick`) before
559
+ * comparing it with the order's ticks, so a price inside a tick counts as that tick's upper edge.
560
+ * Pass `read.settlement`'s `settlementPriceRaw` and `tickSizeRaw`, and the config's
561
+ * `units.positionLotSize` when it isn't the default.
562
+ */
563
+ function settledPayout(orderId, settlementPriceRaw, tickSizeRaw, lotSize = POSITION_LOT_SIZE) {
564
+ if (tickSizeRaw <= 0n) throw new PredictInputError("tickSizeRaw must be positive");
565
+ const { lowerTick, higherTick, quantity } = decodeOrderRange(orderId, lotSize);
566
+ const limit = (settlementPriceRaw + tickSizeRaw - 1n) / tickSizeRaw;
567
+ return lowerTick < limit && (higherTick === POS_INF_TICK || limit <= higherTick) ? quantity : 0n;
568
+ }
543
569
  /** The strikes an {@link OrderRange} prices against, in USD, with `null` for each infinite
544
570
  * side — the shape {@link boundaryProbabilities} takes. `tickSize` is the market's raw tick
545
571
  * size (`ActiveMarket.tickSize` in USD, or the raw value from the deployment). */
@@ -551,5 +577,5 @@ function orderStrikes(range, tickSizeRaw) {
551
577
  }
552
578
 
553
579
  //#endregion
554
- export { cost_exports };
580
+ export { FLOAT_SCALING, MAX_QUANTITY_LOTS, MIN_PREMIUM, POSITION_LOT_SIZE, cost_exports, decodeOrderRange };
555
581
  //# sourceMappingURL=cost.mjs.map