@mysten/deepbook-v3 2.0.0 → 2.1.3

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 (302) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/PREDICT.md +256 -0
  3. package/README.md +116 -0
  4. package/dist/account.d.mts +139 -0
  5. package/dist/account.d.mts.map +1 -0
  6. package/dist/account.mjs +181 -0
  7. package/dist/account.mjs.map +1 -0
  8. package/dist/bcs/integers.mjs +23 -0
  9. package/dist/bcs/integers.mjs.map +1 -0
  10. package/dist/contracts/account/account.d.mts +382 -0
  11. package/dist/contracts/account/account.d.mts.map +1 -0
  12. package/dist/contracts/account/account.mjs +443 -0
  13. package/dist/contracts/account/account.mjs.map +1 -0
  14. package/dist/contracts/account/account_events.d.mts +41 -0
  15. package/dist/contracts/account/account_events.d.mts.map +1 -0
  16. package/dist/contracts/account/account_events.mjs +72 -0
  17. package/dist/contracts/account/account_events.mjs.map +1 -0
  18. package/dist/contracts/account/account_registry.d.mts +210 -0
  19. package/dist/contracts/account/account_registry.d.mts.map +1 -0
  20. package/dist/contracts/account/account_registry.mjs +263 -0
  21. package/dist/contracts/account/account_registry.mjs.map +1 -0
  22. package/dist/contracts/account/config-arguments.d.mts +10 -0
  23. package/dist/contracts/account/config-arguments.d.mts.map +1 -0
  24. package/dist/contracts/account/deps/sui/bag.mjs +44 -0
  25. package/dist/contracts/account/deps/sui/bag.mjs.map +1 -0
  26. package/dist/contracts/deepbook/account.d.mts +18 -18
  27. package/dist/contracts/deepbook/balance_manager.mjs.map +1 -1
  28. package/dist/contracts/deepbook/balances.d.mts +4 -4
  29. package/dist/contracts/deepbook/balances.d.mts.map +1 -1
  30. package/dist/contracts/deepbook/deep_price.d.mts +3 -3
  31. package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
  32. package/dist/contracts/deepbook/order.d.mts +12 -12
  33. package/dist/contracts/deepbook/pool.mjs.map +1 -1
  34. package/dist/contracts/deepbook/registry.mjs.map +1 -1
  35. package/dist/contracts/deepbook_margin/margin_manager.mjs.map +1 -1
  36. package/dist/contracts/deepbook_margin/margin_manager_upgraded.mjs.map +1 -1
  37. package/dist/contracts/deepbook_margin/margin_pool.mjs.map +1 -1
  38. package/dist/contracts/deepbook_margin/margin_registry.mjs.map +1 -1
  39. package/dist/contracts/deepbook_margin/pool_proxy.mjs.map +1 -1
  40. package/dist/contracts/deepbook_margin/protocol_config.mjs.map +1 -1
  41. package/dist/contracts/deepbook_margin/tpsl.mjs.map +1 -1
  42. package/dist/contracts/deepbook_predict/builder_code_events.mjs +38 -0
  43. package/dist/contracts/deepbook_predict/builder_code_events.mjs.map +1 -0
  44. package/dist/contracts/deepbook_predict/config-arguments.d.mts +13 -0
  45. package/dist/contracts/deepbook_predict/config-arguments.d.mts.map +1 -0
  46. package/dist/contracts/deepbook_predict/deps/fixed_math/i64.mjs +25 -0
  47. package/dist/contracts/deepbook_predict/deps/fixed_math/i64.mjs.map +1 -0
  48. package/dist/contracts/deepbook_predict/deps/sui/balance.mjs +25 -0
  49. package/dist/contracts/deepbook_predict/deps/sui/balance.mjs.map +1 -0
  50. package/dist/contracts/deepbook_predict/deps/sui/coin.mjs +24 -0
  51. package/dist/contracts/deepbook_predict/deps/sui/coin.mjs.map +1 -0
  52. package/dist/contracts/deepbook_predict/deps/sui/table.mjs +39 -0
  53. package/dist/contracts/deepbook_predict/deps/sui/table.mjs.map +1 -0
  54. package/dist/contracts/deepbook_predict/deps/sui/vec_set.mjs +26 -0
  55. package/dist/contracts/deepbook_predict/deps/sui/vec_set.mjs.map +1 -0
  56. package/dist/contracts/deepbook_predict/ewma.mjs +29 -0
  57. package/dist/contracts/deepbook_predict/ewma.mjs.map +1 -0
  58. package/dist/contracts/deepbook_predict/expiry_cash.mjs +27 -0
  59. package/dist/contracts/deepbook_predict/expiry_cash.mjs.map +1 -0
  60. package/dist/contracts/deepbook_predict/expiry_market.mjs +367 -0
  61. package/dist/contracts/deepbook_predict/expiry_market.mjs.map +1 -0
  62. package/dist/contracts/deepbook_predict/lp_book.mjs +92 -0
  63. package/dist/contracts/deepbook_predict/lp_book.mjs.map +1 -0
  64. package/dist/contracts/deepbook_predict/market_manager.mjs +59 -0
  65. package/dist/contracts/deepbook_predict/market_manager.mjs.map +1 -0
  66. package/dist/contracts/deepbook_predict/order.mjs +26 -0
  67. package/dist/contracts/deepbook_predict/order.mjs.map +1 -0
  68. package/dist/contracts/deepbook_predict/order_events.mjs +84 -0
  69. package/dist/contracts/deepbook_predict/order_events.mjs.map +1 -0
  70. package/dist/contracts/deepbook_predict/plp.mjs +284 -0
  71. package/dist/contracts/deepbook_predict/plp.mjs.map +1 -0
  72. package/dist/contracts/deepbook_predict/pool_accounting.mjs +58 -0
  73. package/dist/contracts/deepbook_predict/pool_accounting.mjs.map +1 -0
  74. package/dist/contracts/deepbook_predict/predict_account.mjs +106 -0
  75. package/dist/contracts/deepbook_predict/predict_account.mjs.map +1 -0
  76. package/dist/contracts/deepbook_predict/pricing.mjs +80 -0
  77. package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -0
  78. package/dist/contracts/deepbook_predict/range_codec.mjs +41 -0
  79. package/dist/contracts/deepbook_predict/range_codec.mjs.map +1 -0
  80. package/dist/contracts/deepbook_predict/registry.mjs +55 -0
  81. package/dist/contracts/deepbook_predict/registry.mjs.map +1 -0
  82. package/dist/contracts/deepbook_predict/strike_exposure.mjs +65 -0
  83. package/dist/contracts/deepbook_predict/strike_exposure.mjs.map +1 -0
  84. package/dist/contracts/deepbook_predict/strike_exposure_config.mjs +33 -0
  85. package/dist/contracts/deepbook_predict/strike_exposure_config.mjs.map +1 -0
  86. package/dist/contracts/deepbook_predict/strike_payout_tree.mjs +72 -0
  87. package/dist/contracts/deepbook_predict/strike_payout_tree.mjs.map +1 -0
  88. package/dist/contracts/deepbook_predict/vault_events.mjs +184 -0
  89. package/dist/contracts/deepbook_predict/vault_events.mjs.map +1 -0
  90. package/dist/contracts/deepbook_sessions/config-arguments.d.mts +10 -0
  91. package/dist/contracts/deepbook_sessions/config-arguments.d.mts.map +1 -0
  92. package/dist/contracts/deepbook_sessions/deps/sui/vec_map.mjs +37 -0
  93. package/dist/contracts/deepbook_sessions/deps/sui/vec_map.mjs.map +1 -0
  94. package/dist/contracts/deepbook_sessions/session_config.d.mts +63 -0
  95. package/dist/contracts/deepbook_sessions/session_config.d.mts.map +1 -0
  96. package/dist/contracts/deepbook_sessions/session_config.mjs +82 -0
  97. package/dist/contracts/deepbook_sessions/session_config.mjs.map +1 -0
  98. package/dist/contracts/deepbook_sessions/sessions.d.mts +275 -0
  99. package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -0
  100. package/dist/contracts/deepbook_sessions/sessions.mjs +443 -0
  101. package/dist/contracts/deepbook_sessions/sessions.mjs.map +1 -0
  102. package/dist/contracts/margin_liquidation/liquidation_vault.mjs.map +1 -1
  103. package/dist/contracts/utils/index.d.mts +18 -1
  104. package/dist/contracts/utils/index.d.mts.map +1 -1
  105. package/dist/deployments/index.d.mts +31 -0
  106. package/dist/deployments/index.d.mts.map +1 -0
  107. package/dist/deployments/index.mjs +30 -0
  108. package/dist/deployments/index.mjs.map +1 -0
  109. package/dist/deployments/testnet.d.mts +14 -0
  110. package/dist/deployments/testnet.d.mts.map +1 -0
  111. package/dist/deployments/testnet.mjs +73 -0
  112. package/dist/deployments/testnet.mjs.map +1 -0
  113. package/dist/deployments/types.d.mts +36 -0
  114. package/dist/deployments/types.d.mts.map +1 -0
  115. package/dist/index.mjs +0 -1
  116. package/dist/predict/client.d.mts +255 -0
  117. package/dist/predict/client.d.mts.map +1 -0
  118. package/dist/predict/client.mjs +436 -0
  119. package/dist/predict/client.mjs.map +1 -0
  120. package/dist/predict/config/generated.d.mts +29 -0
  121. package/dist/predict/config/generated.d.mts.map +1 -0
  122. package/dist/predict/config/generated.mjs +16 -0
  123. package/dist/predict/config/generated.mjs.map +1 -0
  124. package/dist/predict/config/index.d.mts +10 -0
  125. package/dist/predict/config/index.d.mts.map +1 -0
  126. package/dist/predict/config/index.mjs +13 -0
  127. package/dist/predict/config/index.mjs.map +1 -0
  128. package/dist/predict/config/testnet.d.mts +17 -0
  129. package/dist/predict/config/testnet.d.mts.map +1 -0
  130. package/dist/predict/config/testnet.mjs +26 -0
  131. package/dist/predict/config/testnet.mjs.map +1 -0
  132. package/dist/predict/config/types.d.mts +55 -0
  133. package/dist/predict/config/types.d.mts.map +1 -0
  134. package/dist/predict/decode.d.mts +162 -0
  135. package/dist/predict/decode.d.mts.map +1 -0
  136. package/dist/predict/decode.mjs +175 -0
  137. package/dist/predict/decode.mjs.map +1 -0
  138. package/dist/predict/errors.d.mts +42 -0
  139. package/dist/predict/errors.d.mts.map +1 -0
  140. package/dist/predict/errors.mjs +37 -0
  141. package/dist/predict/errors.mjs.map +1 -0
  142. package/dist/predict/index.d.mts +18 -0
  143. package/dist/predict/index.mjs +14 -0
  144. package/dist/predict/pricing.d.mts +73 -0
  145. package/dist/predict/pricing.d.mts.map +1 -0
  146. package/dist/predict/pricing.mjs +129 -0
  147. package/dist/predict/pricing.mjs.map +1 -0
  148. package/dist/predict/reads/balances.mjs +41 -0
  149. package/dist/predict/reads/balances.mjs.map +1 -0
  150. package/dist/predict/reads/inspect.d.mts +8 -0
  151. package/dist/predict/reads/inspect.d.mts.map +1 -0
  152. package/dist/predict/reads/inspect.mjs +37 -0
  153. package/dist/predict/reads/inspect.mjs.map +1 -0
  154. package/dist/predict/reads/markets.mjs +130 -0
  155. package/dist/predict/reads/markets.mjs.map +1 -0
  156. package/dist/predict/reads/parse.mjs +20 -0
  157. package/dist/predict/reads/parse.mjs.map +1 -0
  158. package/dist/predict/reads/pool.mjs +26 -0
  159. package/dist/predict/reads/pool.mjs.map +1 -0
  160. package/dist/predict/reads/positions.d.mts +12 -0
  161. package/dist/predict/reads/positions.d.mts.map +1 -0
  162. package/dist/predict/reads/positions.mjs +77 -0
  163. package/dist/predict/reads/positions.mjs.map +1 -0
  164. package/dist/predict/reads/pricing.d.mts +20 -0
  165. package/dist/predict/reads/pricing.d.mts.map +1 -0
  166. package/dist/predict/reads/pricing.mjs +43 -0
  167. package/dist/predict/reads/pricing.mjs.map +1 -0
  168. package/dist/predict/ticks.d.mts +11 -0
  169. package/dist/predict/ticks.d.mts.map +1 -0
  170. package/dist/predict/ticks.mjs +21 -0
  171. package/dist/predict/ticks.mjs.map +1 -0
  172. package/dist/predict/tx/authed.mjs +18 -0
  173. package/dist/predict/tx/authed.mjs.map +1 -0
  174. package/dist/predict/tx/common.d.mts +18 -0
  175. package/dist/predict/tx/common.d.mts.map +1 -0
  176. package/dist/predict/tx/common.mjs +52 -0
  177. package/dist/predict/tx/common.mjs.map +1 -0
  178. package/dist/predict/tx/trade.d.mts +15 -0
  179. package/dist/predict/tx/trade.d.mts.map +1 -0
  180. package/dist/predict/tx/trade.mjs +86 -0
  181. package/dist/predict/tx/trade.mjs.map +1 -0
  182. package/dist/predict/units.d.mts +11 -0
  183. package/dist/predict/units.d.mts.map +1 -0
  184. package/dist/predict/units.mjs +44 -0
  185. package/dist/predict/units.mjs.map +1 -0
  186. package/dist/queries/accountQueries.mjs +0 -1
  187. package/dist/queries/accountQueries.mjs.map +1 -1
  188. package/dist/queries/orderQueries.mjs +0 -1
  189. package/dist/queries/orderQueries.mjs.map +1 -1
  190. package/dist/queries/registryQueries.mjs +0 -1
  191. package/dist/queries/registryQueries.mjs.map +1 -1
  192. package/dist/sessions.d.mts +244 -0
  193. package/dist/sessions.d.mts.map +1 -0
  194. package/dist/sessions.mjs +291 -0
  195. package/dist/sessions.mjs.map +1 -0
  196. package/dist/transactions/balanceManager.d.mts +12 -12
  197. package/dist/transactions/deepbook.d.mts +20 -20
  198. package/dist/transactions/deepbookAdmin.d.mts +4 -4
  199. package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
  200. package/dist/transactions/marginAdmin.d.mts +7 -7
  201. package/dist/transactions/marginLiquidations.d.mts +3 -3
  202. package/dist/transactions/marginMaintainer.d.mts +5 -5
  203. package/dist/transactions/marginManager.d.mts +32 -32
  204. package/dist/transactions/marginPool.d.mts +18 -18
  205. package/dist/transactions/marginRegistry.d.mts +16 -16
  206. package/dist/transactions/marginTPSL.d.mts +10 -10
  207. package/dist/transactions/poolProxy.d.mts +8 -8
  208. package/dist/types/index.d.mts.map +1 -1
  209. package/dist/types/index.mjs.map +1 -1
  210. package/dist/utils/constants.d.mts.map +1 -1
  211. package/dist/utils/constants.mjs +1 -1
  212. package/dist/utils/constants.mjs.map +1 -1
  213. package/package.json +33 -12
  214. package/src/account.ts +239 -0
  215. package/src/bcs/integers.ts +35 -0
  216. package/src/contracts/account/account.ts +706 -0
  217. package/src/contracts/account/account_events.ts +64 -0
  218. package/src/contracts/account/account_registry.ts +468 -0
  219. package/src/contracts/account/config-arguments.ts +8 -0
  220. package/src/contracts/account/deps/sui/bag.ts +42 -0
  221. package/src/contracts/deepbook/balance_manager.ts +1 -2
  222. package/src/contracts/deepbook/pool.ts +12 -24
  223. package/src/contracts/deepbook/registry.ts +1 -2
  224. package/src/contracts/deepbook_margin/margin_manager.ts +9 -18
  225. package/src/contracts/deepbook_margin/margin_manager_upgraded.ts +5 -10
  226. package/src/contracts/deepbook_margin/margin_pool.ts +2 -4
  227. package/src/contracts/deepbook_margin/margin_registry.ts +3 -6
  228. package/src/contracts/deepbook_margin/pool_proxy.ts +3 -6
  229. package/src/contracts/deepbook_margin/protocol_config.ts +1 -2
  230. package/src/contracts/deepbook_margin/tpsl.ts +1 -2
  231. package/src/contracts/deepbook_predict/admin.ts +44 -0
  232. package/src/contracts/deepbook_predict/builder_code.ts +155 -0
  233. package/src/contracts/deepbook_predict/builder_code_events.ts +34 -0
  234. package/src/contracts/deepbook_predict/config-arguments.ts +11 -0
  235. package/src/contracts/deepbook_predict/config_events.ts +140 -0
  236. package/src/contracts/deepbook_predict/deps/fixed_math/i64.ts +21 -0
  237. package/src/contracts/deepbook_predict/deps/sui/balance.ts +25 -0
  238. package/src/contracts/deepbook_predict/deps/sui/coin.ts +20 -0
  239. package/src/contracts/deepbook_predict/deps/sui/table.ts +37 -0
  240. package/src/contracts/deepbook_predict/deps/sui/vec_set.ts +22 -0
  241. package/src/contracts/deepbook_predict/ewma.ts +26 -0
  242. package/src/contracts/deepbook_predict/ewma_config.ts +28 -0
  243. package/src/contracts/deepbook_predict/expiry_cash.ts +24 -0
  244. package/src/contracts/deepbook_predict/expiry_market.ts +1549 -0
  245. package/src/contracts/deepbook_predict/lp_book.ts +105 -0
  246. package/src/contracts/deepbook_predict/market_lifecycle_cap.ts +75 -0
  247. package/src/contracts/deepbook_predict/market_manager.ts +218 -0
  248. package/src/contracts/deepbook_predict/order.ts +24 -0
  249. package/src/contracts/deepbook_predict/order_events.ts +129 -0
  250. package/src/contracts/deepbook_predict/pause_cap.ts +68 -0
  251. package/src/contracts/deepbook_predict/plp.ts +987 -0
  252. package/src/contracts/deepbook_predict/pool_accounting.ts +79 -0
  253. package/src/contracts/deepbook_predict/predict_account.ts +180 -0
  254. package/src/contracts/deepbook_predict/pricing.ts +124 -0
  255. package/src/contracts/deepbook_predict/pricing_config.ts +41 -0
  256. package/src/contracts/deepbook_predict/protocol_config.ts +1066 -0
  257. package/src/contracts/deepbook_predict/range_codec.ts +53 -0
  258. package/src/contracts/deepbook_predict/registry.ts +694 -0
  259. package/src/contracts/deepbook_predict/strike_exposure.ts +77 -0
  260. package/src/contracts/deepbook_predict/strike_exposure_config.ts +46 -0
  261. package/src/contracts/deepbook_predict/strike_payout_tree.ts +89 -0
  262. package/src/contracts/deepbook_predict/vault_events.ts +222 -0
  263. package/src/contracts/deepbook_sessions/config-arguments.ts +8 -0
  264. package/src/contracts/deepbook_sessions/deps/sui/vec_map.ts +33 -0
  265. package/src/contracts/deepbook_sessions/session_config.ts +130 -0
  266. package/src/contracts/deepbook_sessions/sessions.ts +663 -0
  267. package/src/contracts/margin_liquidation/liquidation_vault.ts +2 -4
  268. package/src/contracts/propbook/block_scholes_store.ts +842 -0
  269. package/src/contracts/propbook/deps/sui/table.ts +37 -0
  270. package/src/contracts/propbook/oracle_lane.ts +170 -0
  271. package/src/contracts/propbook/pyth_feed.ts +414 -0
  272. package/src/contracts/propbook/registry.ts +596 -0
  273. package/src/contracts/pyth/pyth.ts +2 -4
  274. package/src/deployments/index.ts +73 -0
  275. package/src/deployments/testnet.ts +107 -0
  276. package/src/deployments/types.ts +81 -0
  277. package/src/index.ts +5 -0
  278. package/src/predict/client.ts +941 -0
  279. package/src/predict/config/generated.ts +39 -0
  280. package/src/predict/config/index.ts +25 -0
  281. package/src/predict/config/testnet.ts +27 -0
  282. package/src/predict/config/types.ts +52 -0
  283. package/src/predict/decode.ts +476 -0
  284. package/src/predict/errors.ts +83 -0
  285. package/src/predict/index.ts +94 -0
  286. package/src/predict/pricing.ts +199 -0
  287. package/src/predict/reads/balances.ts +55 -0
  288. package/src/predict/reads/inspect.ts +78 -0
  289. package/src/predict/reads/markets.ts +222 -0
  290. package/src/predict/reads/parse.ts +30 -0
  291. package/src/predict/reads/pool.ts +37 -0
  292. package/src/predict/reads/positions.ts +144 -0
  293. package/src/predict/reads/pricing.ts +79 -0
  294. package/src/predict/ticks.ts +42 -0
  295. package/src/predict/tx/authed.ts +20 -0
  296. package/src/predict/tx/common.ts +92 -0
  297. package/src/predict/tx/trade.ts +183 -0
  298. package/src/predict/units.ts +49 -0
  299. package/src/sessions.ts +471 -0
  300. package/src/types/index.ts +1 -2
  301. package/src/utils/constants.ts +1 -7
  302. package/dist/types/bcs.mjs +0 -7
@@ -0,0 +1,291 @@
1
+ import { TESTNET_DEPLOYMENT, TESTNET_SESSIONS, TESTNET_UNITS } from "./deployments/testnet.mjs";
2
+ import { getDeployment, getUnits } from "./deployments/index.mjs";
3
+ import { AccountContract } from "./account.mjs";
4
+ import { SessionAuthorized, SessionRevoked, SessionsApp, SessionsData, authorizeSession, mintExactAmount, mintExactQuantity, redeemLive, redeemSettled, revokeSession, sessionExpirationMs, sessions_exports } from "./contracts/deepbook_sessions/sessions.mjs";
5
+ import { session_config_exports } from "./contracts/deepbook_sessions/session_config.mjs";
6
+ import { bcs } from "@mysten/sui/bcs";
7
+ import { deriveDynamicFieldID, deriveObjectID } from "@mysten/sui/utils";
8
+
9
+ //#region src/sessions.ts
10
+ /**
11
+ * @description The deployed sessions ids for `network`, so a caller does not transcribe
12
+ * them. Generated from the deploy manifest — see `src/deployments/`. The returned object
13
+ * also carries {@link SessionsSpotIds} for the generated spot wrappers.
14
+ * @throws if the network has no recorded deployment, rather than returning placeholder ids.
15
+ *
16
+ * ```ts
17
+ * const sessions = new SessionsContract(getSessionsConfig('testnet'));
18
+ * ```
19
+ */
20
+ function getSessionsConfig(network) {
21
+ if (network === "testnet") return TESTNET_SESSIONS;
22
+ throw new Error(`@mysten/deepbook-v3/sessions: no sessions deployment recorded for network '${network}'. Sessions is testnet-only today; for your own deployment construct a \`SessionsConfig\` and pass it to SessionsContract directly.`);
23
+ }
24
+ /** The maximum session duration the contract accepts: 30 days, in milliseconds. */
25
+ const MAX_SESSION_DURATION_MS = 720 * 60 * 60 * 1e3;
26
+ /** The maximum number of distinct session addresses one Account may store. */
27
+ const MAX_SESSIONS_PER_ACCOUNT = 20;
28
+ const SessionsDataField = bcs.struct("Field<DataKey,SessionsData>", {
29
+ id: bcs.Address,
30
+ name: bcs.bool(),
31
+ value: SessionsData
32
+ });
33
+ const AccountKey = bcs.struct("AccountKey", { pos0: bcs.Address });
34
+ /**
35
+ * SessionsContract — time-limited trading sessions over a canonical Account.
36
+ *
37
+ * An Account owner authorizes an ephemeral address to submit a bounded set of
38
+ * transactions on the Account's behalf until a fixed expiry. The session key never
39
+ * receives a reusable `Auth`: each wrapper mints app authorization internally and
40
+ * consumes it in the same call.
41
+ *
42
+ * WHAT A SESSION KEY CAN DO. It cannot withdraw to an address, cannot grant or revoke
43
+ * sessions, and cannot outlive its expiry — those all require owner auth. It CAN trade
44
+ * the Account's full balance: the spot wrappers take a caller-chosen `Pool` and, through
45
+ * `deepbook_core_account`, pull the account's entire Base, Quote and DEEP balance
46
+ * (stored plus unsettled) into the embedded manager for the duration of the call, with
47
+ * `price_limit` supplied by the caller. Nothing caps notional, restricts which pools are
48
+ * reachable, or bounds loss to adverse pricing. Treat a session key as authority over
49
+ * everything the Account holds, and fund an ephemeral-session Account accordingly.
50
+ *
51
+ * Operational precondition: an admin must have authorized `SessionsApp` on the account
52
+ * registry. Until then — or after a `deauthorize_app` — the TRADING wrappers abort with
53
+ * `EAppNotAuthorized`; `authorizeSession`, `revokeSession` and `sessionExpirationMs` use
54
+ * owner auth or no auth and keep working. Note that `deauthorize_app` does not clear
55
+ * `SessionsData`, so re-authorizing makes every still-unexpired grant live again at once
56
+ * — it is a pause, not a kill switch. Revoking, and reading expirations, also keep
57
+ * working if the sessions package is later version-gated.
58
+ *
59
+ * This class wraps the session lifecycle and the **Predict** entrypoints. The DeepBook
60
+ * spot session wrappers are generated (see `sessionsMoveCalls`) but are not wrapped here
61
+ * — note `placeLimitOrder` and `placeMarketOrder` put `accountRegistry` at index 2 and
62
+ * `sessionsConfig` at 4, because `deepbookRegistry` sits between them; the other three
63
+ * (`cancelLiveOrder`, `cancelLiveOrders`, `withdrawSettledAmounts`) take no
64
+ * `deepbookRegistry` and so keep 1 and 3 like the Predict wrappers:
65
+ * the surrounding spot-over-Account workflow — discovering the embedded balance manager,
66
+ * reading resting orders and locked balances — is not modelled yet, so a wrapped builder
67
+ * would be hard to use well. They are reachable from the generated bindings meanwhile.
68
+ */
69
+ var SessionsContract = class {
70
+ #config;
71
+ constructor(config) {
72
+ this.#config = config;
73
+ }
74
+ get #generatedConfig() {
75
+ return {
76
+ sessionsPackageId: this.#config.sessionsPackageId,
77
+ sessionsConfig: this.#config.sessionsConfig
78
+ };
79
+ }
80
+ /**
81
+ * @description The owner's canonical `AccountWrapper` id — derived off-chain, no read.
82
+ * Every builder here takes that id.
83
+ */
84
+ deriveAccountWrapperId(owner) {
85
+ return new AccountContract({
86
+ accountPackageId: this.#config.accountPackageId,
87
+ accountRegistry: this.#config.accountRegistry
88
+ }).deriveAccountWrapperId(owner);
89
+ }
90
+ /**
91
+ * @description The owner's canonical ACCOUNT id — a different derived object from the
92
+ * wrapper. The session grants hang off this one, so this is what
93
+ * {@link deriveSessionsFieldId} and {@link decodeSessions} work from.
94
+ */
95
+ deriveAccountId(owner) {
96
+ return deriveObjectID(this.#config.accountRegistry, `${this.#config.accountPackageId}::account_registry::AccountKey`, AccountKey.serialize({ pos0: owner }).toBytes());
97
+ }
98
+ /**
99
+ * @description The object id of the owner's `DataKey<SessionsApp>` dynamic field —
100
+ * fetch this object and pass its BCS contents to {@link decodeSessions}. There is no
101
+ * bulk on-chain read, so this is the route to enumerating grants.
102
+ */
103
+ deriveSessionsFieldId(owner) {
104
+ return deriveDynamicFieldID(this.deriveAccountId(owner), `${this.#config.accountPackageId}::account::DataKey<${this.#config.sessionsPackageId}::sessions::SessionsApp>`, new Uint8Array([0]));
105
+ }
106
+ /**
107
+ * @description Grant `session` authority over the Account until `now + durationMs`.
108
+ * Authority is derived from the transaction SENDER, so the owner must sign this.
109
+ * `durationMs` must be > 0 and <= {@link MAX_SESSION_DURATION_MS}; an Account holds at
110
+ * most {@link MAX_SESSIONS_PER_ACCOUNT} distinct addresses. Re-authorizing an address
111
+ * replaces its expiry in place and consumes no additional slot.
112
+ * @returns A function that takes a Transaction object
113
+ */
114
+ authorizeSession(params) {
115
+ return (tx) => {
116
+ tx.add(authorizeSession({
117
+ config: this.#generatedConfig,
118
+ arguments: {
119
+ wrapper: params.wrapperId,
120
+ session: params.session,
121
+ durationMs: params.durationMs
122
+ }
123
+ }));
124
+ };
125
+ }
126
+ /**
127
+ * @description Remove `session`'s grant. Owner-signed, like `authorizeSession`.
128
+ * Deliberately takes no `SessionsConfig`: revocation is not version-gated, so it keeps
129
+ * working after the package is retired. Revoking an address that holds no grant is a
130
+ * silent no-op — it neither aborts nor emits, so read before and after if you need to
131
+ * distinguish "revoked" from "was never granted".
132
+ * @returns A function that takes a Transaction object
133
+ */
134
+ revokeSession(params) {
135
+ return (tx) => {
136
+ tx.add(revokeSession({
137
+ config: this.#generatedConfig,
138
+ arguments: {
139
+ wrapper: params.wrapperId,
140
+ session: params.session
141
+ }
142
+ }));
143
+ };
144
+ }
145
+ /**
146
+ * @description Read one session's absolute expiry as `Option<u64>`. Compose in a
147
+ * dev-inspect/simulate PTB and decode the returned BCS. Not version-gated.
148
+ * @returns A function that takes a Transaction object
149
+ */
150
+ sessionExpirationMs(params) {
151
+ return (tx) => tx.add(sessionExpirationMs({
152
+ config: this.#generatedConfig,
153
+ arguments: {
154
+ wrapper: params.wrapperId,
155
+ session: params.session
156
+ }
157
+ }));
158
+ }
159
+ /**
160
+ * @description Mint a position of an exact payout quantity, as `session`. Pass
161
+ * `u64::MAX` for `maxCost` / `maxProbability` to leave either slippage cap
162
+ * effectively unbounded — the chain asserts `value <= cap`, so the max value can never
163
+ * trip. Both are required; there is no default.
164
+ * @returns A function that takes a Transaction object and returns the new order id (u256)
165
+ */
166
+ mintExactQuantity(params) {
167
+ return (tx) => tx.add(mintExactQuantity({
168
+ config: this.#generatedConfig,
169
+ arguments: {
170
+ market: params.expiryMarketId,
171
+ accountRegistry: this.#config.accountRegistry,
172
+ wrapper: params.wrapperId,
173
+ config: params.protocolConfig,
174
+ pricer: params.pricer,
175
+ lowerTick: params.lowerTick,
176
+ higherTick: params.higherTick,
177
+ quantity: params.quantity,
178
+ maxCost: params.maxCost,
179
+ maxProbability: params.maxProbability
180
+ }
181
+ }));
182
+ }
183
+ /**
184
+ * @description Mint by spending up to a premium budget, flooring the quantity received.
185
+ * The chain requires `maxCost > 0`.
186
+ * @returns A function that takes a Transaction object and returns the new order id (u256)
187
+ */
188
+ mintExactAmount(params) {
189
+ return (tx) => tx.add(mintExactAmount({
190
+ config: this.#generatedConfig,
191
+ arguments: {
192
+ market: params.expiryMarketId,
193
+ accountRegistry: this.#config.accountRegistry,
194
+ wrapper: params.wrapperId,
195
+ config: params.protocolConfig,
196
+ pricer: params.pricer,
197
+ lowerTick: params.lowerTick,
198
+ higherTick: params.higherTick,
199
+ maxPremium: params.maxPremium,
200
+ minQuantity: params.minQuantity,
201
+ maxCost: params.maxCost
202
+ }
203
+ }));
204
+ }
205
+ /**
206
+ * @description Close part or all of a live position at the pricer's mark, as `session`.
207
+ * `minProbability` / `minProceeds` are close-side slippage floors; `0` disables either,
208
+ * and OMITTING them is `0` — unlike the mint caps, which are required. On a delegated
209
+ * key this is the direction that closes a position at any price, so pass real floors
210
+ * unless you mean to accept whatever the mark gives you.
211
+ * @returns A function that takes a Transaction object and returns `Option<u256>` — the
212
+ * replacement order id when a partial close leaves quantity open
213
+ */
214
+ redeemLive(params) {
215
+ return (tx) => tx.add(redeemLive({
216
+ config: this.#generatedConfig,
217
+ arguments: {
218
+ market: params.expiryMarketId,
219
+ accountRegistry: this.#config.accountRegistry,
220
+ wrapper: params.wrapperId,
221
+ config: params.protocolConfig,
222
+ pricer: params.pricer,
223
+ orderId: params.orderId,
224
+ closeQuantity: params.closeQuantity,
225
+ minProbability: params.minProbability ?? 0,
226
+ minProceeds: params.minProceeds ?? 0
227
+ }
228
+ }));
229
+ }
230
+ /**
231
+ * @description Claim a settled position in full, as `session`. Takes no pricer — the
232
+ * settlement price is fixed — and no quantity: a settled claim is all-or-nothing.
233
+ * @returns A function that takes a Transaction object
234
+ */
235
+ redeemSettled(params) {
236
+ return (tx) => {
237
+ tx.add(redeemSettled({
238
+ config: this.#generatedConfig,
239
+ arguments: {
240
+ market: params.expiryMarketId,
241
+ accountRegistry: this.#config.accountRegistry,
242
+ wrapper: params.wrapperId,
243
+ config: params.protocolConfig,
244
+ orderId: params.orderId
245
+ }
246
+ }));
247
+ };
248
+ }
249
+ /**
250
+ * @description Decode an Account's stored grants from the raw BCS content of its
251
+ * `DataKey<SessionsApp>` dynamic FIELD object — the whole
252
+ * `Field<DataKey<SessionsApp>, SessionsData>`, as the core API returns it, not the
253
+ * inner `SessionsData`. Get the id from {@link deriveSessionsFieldId}.
254
+ *
255
+ * There is no bulk on-chain read — `sessionExpirationMs` answers one address at a time —
256
+ * so listing grants means fetching that field and decoding it here. Note the field hangs
257
+ * off the DERIVED ACCOUNT address, not the wrapper address; they are different objects.
258
+ *
259
+ * Expired grants are never pruned automatically and keep occupying slots, so callers
260
+ * managing the {@link MAX_SESSIONS_PER_ACCOUNT} cap should list, drop anything already
261
+ * expired, and revoke before granting again.
262
+ */
263
+ static decodeSessions(contents) {
264
+ const field = SessionsDataField.parse(contents);
265
+ const reencoded = SessionsDataField.serialize(field).toBytes();
266
+ if (reencoded.length !== contents.length) throw new Error(`sessions field is ${contents.length} bytes but its contents encode to ${reencoded.length}; the bytes are truncated or carry trailing data`);
267
+ return field.value.sessions.contents.map((entry) => ({
268
+ session: entry.key,
269
+ expiresAtMs: BigInt(entry.value)
270
+ }));
271
+ }
272
+ /** Grants from {@link decodeSessions} that are still live at `nowMs`. */
273
+ static activeSessions(grants, nowMs) {
274
+ const now = BigInt(nowMs);
275
+ return grants.filter((g) => now < g.expiresAtMs);
276
+ }
277
+ /**
278
+ * @description Grants that are already dead at `nowMs` — the complement of
279
+ * {@link activeSessions}, and the list to revoke when reclaiming slots. Use this rather
280
+ * than filtering by hand: `nowMs > expiresAtMs` looks equivalent but leaves the grant
281
+ * expiring exactly at `nowMs` occupying a slot forever.
282
+ */
283
+ static expiredSessions(grants, nowMs) {
284
+ const now = BigInt(nowMs);
285
+ return grants.filter((g) => now >= g.expiresAtMs);
286
+ }
287
+ };
288
+
289
+ //#endregion
290
+ export { MAX_SESSIONS_PER_ACCOUNT, MAX_SESSION_DURATION_MS, SessionAuthorized, SessionRevoked, SessionsApp, SessionsContract, SessionsData, TESTNET_DEPLOYMENT, TESTNET_UNITS, getDeployment, getSessionsConfig, getUnits, session_config_exports as sessionConfigMoveCalls, sessions_exports as sessionsMoveCalls };
291
+ //# sourceMappingURL=sessions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.mjs","names":["#config","#generatedConfig","sessions.authorizeSession","sessions.revokeSession","sessions.sessionExpirationMs","sessions.mintExactQuantity","sessions.mintExactAmount","sessions.redeemLive","sessions.redeemSettled"],"sources":["../src/sessions.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { bcs } from '@mysten/sui/bcs';\nimport type { Transaction, TransactionArgument, TransactionResult } from '@mysten/sui/transactions';\nimport { deriveDynamicFieldID, deriveObjectID } from '@mysten/sui/utils';\n\nimport { TESTNET_SESSIONS } from './deployments/testnet.js';\nimport type { NetworkArg } from './deployments/index.js';\n\n// Provenance and scale constants, so a sessions-only consumer can answer \"which deployment\n// is this pinned to?\" and format a custody balance without importing another subpath.\nexport { getDeployment, getUnits, TESTNET_DEPLOYMENT, TESTNET_UNITS } from './deployments/index.js';\nexport type { DeployedNetwork, NetworkArg } from './deployments/index.js';\n\nimport { AccountContract } from './account.js';\nimport type { DeepbookSessionsConfig } from './contracts/deepbook_sessions/config-arguments.js';\nimport * as sessions from './contracts/deepbook_sessions/sessions.js';\nimport { SessionsData } from './contracts/deepbook_sessions/sessions.js';\n\n/**\n * Deployed ids the sessions builders address.\n *\n * `accountPackageId` / `accountRegistry` are the same shared-account ids\n * {@link AccountContract} takes — sessions is an Account app, so it addresses the same\n * registry. `sessionsPackageId` and `sessionsConfig` come from the sessions deployment.\n */\nexport interface SessionsConfig extends DeepbookSessionsConfig {\n\t/** The `deepbook_sessions` Move package id. */\n\tsessionsPackageId: string;\n\t/** The shared `SessionsConfig` object id. */\n\tsessionsConfig: string;\n\t/** The shared `account` Move package id. */\n\taccountPackageId: string;\n\t/** The shared `AccountRegistry` object id. */\n\taccountRegistry: string;\n}\n\n/**\n * Ids the DeepBook **spot** session wrappers need on top of {@link SessionsConfig}. The\n * Predict wrappers never take these, so they are kept off the main config rather than made\n * optional there.\n */\nexport interface SessionsSpotIds {\n\t/** DeepBook's shared `Registry` — `deepbook_registry` on the spot entrypoints. */\n\tdeepbookRegistry: string;\n\t/** The `deepbook_core_account` Move package id. */\n\tdeepbookCoreAccountPackageId: string;\n}\n\n/** Ids the Predict session wrappers need beyond {@link SessionsConfig}. */\nexport interface SessionsPredictIds {\n\t/** Every Predict wrapper takes `config: &ProtocolConfig`. */\n\tprotocolConfig: string;\n}\n\n/**\n * @description The deployed sessions ids for `network`, so a caller does not transcribe\n * them. Generated from the deploy manifest — see `src/deployments/`. The returned object\n * also carries {@link SessionsSpotIds} for the generated spot wrappers.\n * @throws if the network has no recorded deployment, rather than returning placeholder ids.\n *\n * ```ts\n * const sessions = new SessionsContract(getSessionsConfig('testnet'));\n * ```\n */\nexport function getSessionsConfig(\n\tnetwork: NetworkArg,\n): SessionsConfig & SessionsSpotIds & SessionsPredictIds {\n\t// The frozen record itself, matching `/account` — returning a spread here would have\n\t// quietly exempted this subpath from the immutability the others guarantee.\n\tif (network === 'testnet') return TESTNET_SESSIONS;\n\tthrow new Error(\n\t\t`@mysten/deepbook-v3/sessions: no sessions deployment recorded for network '${network}'. ` +\n\t\t\t'Sessions is testnet-only today; for your own deployment construct a `SessionsConfig` ' +\n\t\t\t'and pass it to SessionsContract directly.',\n\t);\n}\n\n/** The maximum session duration the contract accepts: 30 days, in milliseconds. */\nexport const MAX_SESSION_DURATION_MS = 30 * 24 * 60 * 60 * 1000;\n\n/** The maximum number of distinct session addresses one Account may store. */\nexport const MAX_SESSIONS_PER_ACCOUNT = 20;\n\n// `sui::dynamic_field::Field<DataKey<SessionsApp>, SessionsData>` — what a core `getObject`\n// on the grant field actually returns. `DataKey` is source-empty, but Move inserts a\n// hidden `dummy_field: bool` into empty structs, so the name occupies ONE zero byte\n// between the id and the value. Decoding the value alone would read the field id's first\n// byte as the VecMap length: garbage grants, or a silent empty list.\nconst SessionsDataField = bcs.struct('Field<DataKey,SessionsData>', {\n\tid: bcs.Address,\n\tname: bcs.bool(), // DataKey's hidden dummy_field\n\tvalue: SessionsData,\n});\n\n// `AccountKey(owner)` — the canonical ACCOUNT identity, a different derived object from\n// the wrapper. Grant data hangs off this one.\nconst AccountKey = bcs.struct('AccountKey', { pos0: bcs.Address });\n\n/** One stored session grant. */\nexport interface SessionGrant {\n\t/** The authorized ephemeral address. */\n\tsession: string;\n\t/** Absolute expiry, ms since epoch. The grant is dead AT this timestamp (strict `<`). */\n\texpiresAtMs: bigint;\n}\n\n/**\n * SessionsContract — time-limited trading sessions over a canonical Account.\n *\n * An Account owner authorizes an ephemeral address to submit a bounded set of\n * transactions on the Account's behalf until a fixed expiry. The session key never\n * receives a reusable `Auth`: each wrapper mints app authorization internally and\n * consumes it in the same call.\n *\n * WHAT A SESSION KEY CAN DO. It cannot withdraw to an address, cannot grant or revoke\n * sessions, and cannot outlive its expiry — those all require owner auth. It CAN trade\n * the Account's full balance: the spot wrappers take a caller-chosen `Pool` and, through\n * `deepbook_core_account`, pull the account's entire Base, Quote and DEEP balance\n * (stored plus unsettled) into the embedded manager for the duration of the call, with\n * `price_limit` supplied by the caller. Nothing caps notional, restricts which pools are\n * reachable, or bounds loss to adverse pricing. Treat a session key as authority over\n * everything the Account holds, and fund an ephemeral-session Account accordingly.\n *\n * Operational precondition: an admin must have authorized `SessionsApp` on the account\n * registry. Until then — or after a `deauthorize_app` — the TRADING wrappers abort with\n * `EAppNotAuthorized`; `authorizeSession`, `revokeSession` and `sessionExpirationMs` use\n * owner auth or no auth and keep working. Note that `deauthorize_app` does not clear\n * `SessionsData`, so re-authorizing makes every still-unexpired grant live again at once\n * — it is a pause, not a kill switch. Revoking, and reading expirations, also keep\n * working if the sessions package is later version-gated.\n *\n * This class wraps the session lifecycle and the **Predict** entrypoints. The DeepBook\n * spot session wrappers are generated (see `sessionsMoveCalls`) but are not wrapped here\n * — note `placeLimitOrder` and `placeMarketOrder` put `accountRegistry` at index 2 and\n * `sessionsConfig` at 4, because `deepbookRegistry` sits between them; the other three\n * (`cancelLiveOrder`, `cancelLiveOrders`, `withdrawSettledAmounts`) take no\n * `deepbookRegistry` and so keep 1 and 3 like the Predict wrappers:\n * the surrounding spot-over-Account workflow — discovering the embedded balance manager,\n * reading resting orders and locked balances — is not modelled yet, so a wrapped builder\n * would be hard to use well. They are reachable from the generated bindings meanwhile.\n */\nexport class SessionsContract {\n\t#config: SessionsConfig;\n\n\tconstructor(config: SessionsConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t// The generated thunks resolve the package address and auto-inject the shared\n\t// `SessionsConfig` from this object. `accountRegistry` stays an explicit argument —\n\t// it belongs to the account package, which is a separate codegen entry.\n\tget #generatedConfig() {\n\t\treturn {\n\t\t\tsessionsPackageId: this.#config.sessionsPackageId,\n\t\t\tsessionsConfig: this.#config.sessionsConfig,\n\t\t};\n\t}\n\n\t/**\n\t * @description The owner's canonical `AccountWrapper` id — derived off-chain, no read.\n\t * Every builder here takes that id.\n\t */\n\tderiveAccountWrapperId(owner: string): string {\n\t\treturn new AccountContract({\n\t\t\taccountPackageId: this.#config.accountPackageId,\n\t\t\taccountRegistry: this.#config.accountRegistry,\n\t\t}).deriveAccountWrapperId(owner);\n\t}\n\n\t/**\n\t * @description The owner's canonical ACCOUNT id — a different derived object from the\n\t * wrapper. The session grants hang off this one, so this is what\n\t * {@link deriveSessionsFieldId} and {@link decodeSessions} work from.\n\t */\n\tderiveAccountId(owner: string): string {\n\t\treturn deriveObjectID(\n\t\t\tthis.#config.accountRegistry,\n\t\t\t`${this.#config.accountPackageId}::account_registry::AccountKey`,\n\t\t\tAccountKey.serialize({ pos0: owner }).toBytes(),\n\t\t);\n\t}\n\n\t/**\n\t * @description The object id of the owner's `DataKey<SessionsApp>` dynamic field —\n\t * fetch this object and pass its BCS contents to {@link decodeSessions}. There is no\n\t * bulk on-chain read, so this is the route to enumerating grants.\n\t */\n\tderiveSessionsFieldId(owner: string): string {\n\t\t// A PLAIN dynamic field, not a derived object: `account::attach` writes it with\n\t\t// `df::add` (`use fun df::add as UID.add`), whereas the account and wrapper ids are\n\t\t// claimed through `derived_object::claim`. `deriveObjectID` would wrap the tag in\n\t\t// `0x2::derived_object::DerivedObjectKey<..>` and yield an id that points at nothing.\n\t\treturn deriveDynamicFieldID(\n\t\t\tthis.deriveAccountId(owner),\n\t\t\t`${this.#config.accountPackageId}::account::DataKey<${this.#config.sessionsPackageId}::sessions::SessionsApp>`,\n\t\t\t// DataKey is source-empty; Move's hidden `dummy_field: bool` is the key's one byte.\n\t\t\tnew Uint8Array([0]),\n\t\t);\n\t}\n\n\t/**\n\t * @description Grant `session` authority over the Account until `now + durationMs`.\n\t * Authority is derived from the transaction SENDER, so the owner must sign this.\n\t * `durationMs` must be > 0 and <= {@link MAX_SESSION_DURATION_MS}; an Account holds at\n\t * most {@link MAX_SESSIONS_PER_ACCOUNT} distinct addresses. Re-authorizing an address\n\t * replaces its expiry in place and consumes no additional slot.\n\t * @returns A function that takes a Transaction object\n\t */\n\tauthorizeSession(params: { wrapperId: string; session: string; durationMs: number | bigint }) {\n\t\treturn (tx: Transaction): void => {\n\t\t\ttx.add(\n\t\t\t\tsessions.authorizeSession({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\twrapper: params.wrapperId,\n\t\t\t\t\t\tsession: params.session,\n\t\t\t\t\t\tdurationMs: params.durationMs,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * @description Remove `session`'s grant. Owner-signed, like `authorizeSession`.\n\t * Deliberately takes no `SessionsConfig`: revocation is not version-gated, so it keeps\n\t * working after the package is retired. Revoking an address that holds no grant is a\n\t * silent no-op — it neither aborts nor emits, so read before and after if you need to\n\t * distinguish \"revoked\" from \"was never granted\".\n\t * @returns A function that takes a Transaction object\n\t */\n\trevokeSession(params: { wrapperId: string; session: string }) {\n\t\treturn (tx: Transaction): void => {\n\t\t\ttx.add(\n\t\t\t\tsessions.revokeSession({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: { wrapper: params.wrapperId, session: params.session },\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * @description Read one session's absolute expiry as `Option<u64>`. Compose in a\n\t * dev-inspect/simulate PTB and decode the returned BCS. Not version-gated.\n\t * @returns A function that takes a Transaction object\n\t */\n\tsessionExpirationMs(params: { wrapperId: string; session: string }) {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(\n\t\t\t\tsessions.sessionExpirationMs({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: { wrapper: params.wrapperId, session: params.session },\n\t\t\t\t}),\n\t\t\t);\n\t}\n\n\t// === Predict wrappers ===\n\t//\n\t// Each mirrors the Predict entrypoint of the same name, with two differences: the\n\t// caller supplies NO `Auth` (the wrapper mints and consumes app authorization\n\t// internally), and `accountRegistry` + `sessionsConfig` are threaded in. `pricer` is a\n\t// PTB RESULT, not an object — it comes from a preceding `expiry_market::load_live_pricer`\n\t// command in the same transaction. Everything else matches Predict exactly, and Predict\n\t// still performs all parameter validation.\n\n\t/**\n\t * @description Mint a position of an exact payout quantity, as `session`. Pass\n\t * `u64::MAX` for `maxCost` / `maxProbability` to leave either slippage cap\n\t * effectively unbounded — the chain asserts `value <= cap`, so the max value can never\n\t * trip. Both are required; there is no default.\n\t * @returns A function that takes a Transaction object and returns the new order id (u256)\n\t */\n\tmintExactQuantity(params: {\n\t\texpiryMarketId: string;\n\t\twrapperId: string;\n\t\tprotocolConfig: string;\n\t\tpricer: TransactionArgument;\n\t\tlowerTick: number | bigint;\n\t\thigherTick: number | bigint;\n\t\tquantity: number | bigint;\n\t\tmaxCost: number | bigint;\n\t\tmaxProbability: number | bigint;\n\t}) {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(\n\t\t\t\tsessions.mintExactQuantity({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tmarket: params.expiryMarketId,\n\t\t\t\t\t\taccountRegistry: this.#config.accountRegistry,\n\t\t\t\t\t\twrapper: params.wrapperId,\n\t\t\t\t\t\tconfig: params.protocolConfig,\n\t\t\t\t\t\tpricer: params.pricer,\n\t\t\t\t\t\tlowerTick: params.lowerTick,\n\t\t\t\t\t\thigherTick: params.higherTick,\n\t\t\t\t\t\tquantity: params.quantity,\n\t\t\t\t\t\tmaxCost: params.maxCost,\n\t\t\t\t\t\tmaxProbability: params.maxProbability,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t}\n\n\t/**\n\t * @description Mint by spending up to a premium budget, flooring the quantity received.\n\t * The chain requires `maxCost > 0`.\n\t * @returns A function that takes a Transaction object and returns the new order id (u256)\n\t */\n\tmintExactAmount(params: {\n\t\texpiryMarketId: string;\n\t\twrapperId: string;\n\t\tprotocolConfig: string;\n\t\tpricer: TransactionArgument;\n\t\tlowerTick: number | bigint;\n\t\thigherTick: number | bigint;\n\t\tmaxPremium: number | bigint;\n\t\tminQuantity: number | bigint;\n\t\tmaxCost: number | bigint;\n\t}) {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(\n\t\t\t\tsessions.mintExactAmount({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tmarket: params.expiryMarketId,\n\t\t\t\t\t\taccountRegistry: this.#config.accountRegistry,\n\t\t\t\t\t\twrapper: params.wrapperId,\n\t\t\t\t\t\tconfig: params.protocolConfig,\n\t\t\t\t\t\tpricer: params.pricer,\n\t\t\t\t\t\tlowerTick: params.lowerTick,\n\t\t\t\t\t\thigherTick: params.higherTick,\n\t\t\t\t\t\tmaxPremium: params.maxPremium,\n\t\t\t\t\t\tminQuantity: params.minQuantity,\n\t\t\t\t\t\tmaxCost: params.maxCost,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t}\n\n\t/**\n\t * @description Close part or all of a live position at the pricer's mark, as `session`.\n\t * `minProbability` / `minProceeds` are close-side slippage floors; `0` disables either,\n\t * and OMITTING them is `0` — unlike the mint caps, which are required. On a delegated\n\t * key this is the direction that closes a position at any price, so pass real floors\n\t * unless you mean to accept whatever the mark gives you.\n\t * @returns A function that takes a Transaction object and returns `Option<u256>` — the\n\t * replacement order id when a partial close leaves quantity open\n\t */\n\tredeemLive(params: {\n\t\texpiryMarketId: string;\n\t\twrapperId: string;\n\t\tprotocolConfig: string;\n\t\tpricer: TransactionArgument;\n\t\torderId: bigint;\n\t\tcloseQuantity: number | bigint;\n\t\tminProbability?: number | bigint;\n\t\tminProceeds?: number | bigint;\n\t}) {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(\n\t\t\t\tsessions.redeemLive({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tmarket: params.expiryMarketId,\n\t\t\t\t\t\taccountRegistry: this.#config.accountRegistry,\n\t\t\t\t\t\twrapper: params.wrapperId,\n\t\t\t\t\t\tconfig: params.protocolConfig,\n\t\t\t\t\t\tpricer: params.pricer,\n\t\t\t\t\t\torderId: params.orderId,\n\t\t\t\t\t\tcloseQuantity: params.closeQuantity,\n\t\t\t\t\t\tminProbability: params.minProbability ?? 0,\n\t\t\t\t\t\tminProceeds: params.minProceeds ?? 0,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t}\n\n\t/**\n\t * @description Claim a settled position in full, as `session`. Takes no pricer — the\n\t * settlement price is fixed — and no quantity: a settled claim is all-or-nothing.\n\t * @returns A function that takes a Transaction object\n\t */\n\tredeemSettled(params: {\n\t\texpiryMarketId: string;\n\t\twrapperId: string;\n\t\tprotocolConfig: string;\n\t\torderId: bigint;\n\t}) {\n\t\treturn (tx: Transaction): void => {\n\t\t\ttx.add(\n\t\t\t\tsessions.redeemSettled({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tmarket: params.expiryMarketId,\n\t\t\t\t\t\taccountRegistry: this.#config.accountRegistry,\n\t\t\t\t\t\twrapper: params.wrapperId,\n\t\t\t\t\t\tconfig: params.protocolConfig,\n\t\t\t\t\t\torderId: params.orderId,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * @description Decode an Account's stored grants from the raw BCS content of its\n\t * `DataKey<SessionsApp>` dynamic FIELD object — the whole\n\t * `Field<DataKey<SessionsApp>, SessionsData>`, as the core API returns it, not the\n\t * inner `SessionsData`. Get the id from {@link deriveSessionsFieldId}.\n\t *\n\t * There is no bulk on-chain read — `sessionExpirationMs` answers one address at a time —\n\t * so listing grants means fetching that field and decoding it here. Note the field hangs\n\t * off the DERIVED ACCOUNT address, not the wrapper address; they are different objects.\n\t *\n\t * Expired grants are never pruned automatically and keep occupying slots, so callers\n\t * managing the {@link MAX_SESSIONS_PER_ACCOUNT} cap should list, drop anything already\n\t * expired, and revoke before granting again.\n\t */\n\tstatic decodeSessions(contents: Uint8Array): SessionGrant[] {\n\t\t// Assert full consumption. `@mysten/bcs`'s ULEB reader indexes the underlying\n\t\t// ArrayBuffer rather than the view, so a truncated SUBARRAY — which is exactly what a\n\t\t// gRPC `content` field is — can read past its bound and decode to `[]` with no error.\n\t\t// Re-serializing and comparing lengths turns both truncation and trailing junk into a\n\t\t// throw, so \"no grants\" can only ever mean no grants.\n\t\tconst field = SessionsDataField.parse(contents);\n\t\tconst reencoded = SessionsDataField.serialize(field).toBytes();\n\t\tif (reencoded.length !== contents.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`sessions field is ${contents.length} bytes but its contents encode to ${reencoded.length}; ` +\n\t\t\t\t\t'the bytes are truncated or carry trailing data',\n\t\t\t);\n\t\t}\n\t\treturn field.value.sessions.contents.map((entry) => ({\n\t\t\tsession: entry.key,\n\t\t\texpiresAtMs: BigInt(entry.value),\n\t\t}));\n\t}\n\n\t/** Grants from {@link decodeSessions} that are still live at `nowMs`. */\n\tstatic activeSessions(grants: readonly SessionGrant[], nowMs: number | bigint): SessionGrant[] {\n\t\tconst now = BigInt(nowMs);\n\t\t// The chain asserts `now < expiresAtMs`, so a grant is dead AT its expiry.\n\t\treturn grants.filter((g) => now < g.expiresAtMs);\n\t}\n\n\t/**\n\t * @description Grants that are already dead at `nowMs` — the complement of\n\t * {@link activeSessions}, and the list to revoke when reclaiming slots. Use this rather\n\t * than filtering by hand: `nowMs > expiresAtMs` looks equivalent but leaves the grant\n\t * expiring exactly at `nowMs` occupying a slot forever.\n\t */\n\tstatic expiredSessions(grants: readonly SessionGrant[], nowMs: number | bigint): SessionGrant[] {\n\t\tconst now = BigInt(nowMs);\n\t\treturn grants.filter((g) => now >= g.expiresAtMs);\n\t}\n}\n\n// === Generated bindings ===\n// NOTE: this namespace carries the DeepBook spot session calls too\n// (`placeLimitOrder`, `placeMarketOrder`, `cancelLiveOrder(s)`, `withdrawSettledAmounts`).\n// They are generated and callable; they are simply not wrapped on `SessionsContract`.\nexport * as sessionsMoveCalls from './contracts/deepbook_sessions/sessions.js';\nexport * as sessionConfigMoveCalls from './contracts/deepbook_sessions/session_config.js';\nexport {\n\tSessionsApp,\n\tSessionsData,\n\tSessionAuthorized,\n\tSessionRevoked,\n} from './contracts/deepbook_sessions/sessions.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiEA,SAAgB,kBACf,SACwD;AAGxD,KAAI,YAAY,UAAW,QAAO;AAClC,OAAM,IAAI,MACT,8EAA8E,QAAQ,qIAGtF;;;AAIF,MAAa,0BAA0B,MAAU,KAAK,KAAK;;AAG3D,MAAa,2BAA2B;AAOxC,MAAM,oBAAoB,IAAI,OAAO,+BAA+B;CACnE,IAAI,IAAI;CACR,MAAM,IAAI,MAAM;CAChB,OAAO;CACP,CAAC;AAIF,MAAM,aAAa,IAAI,OAAO,cAAc,EAAE,MAAM,IAAI,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6ClE,IAAa,mBAAb,MAA8B;CAC7B;CAEA,YAAY,QAAwB;AACnC,QAAKA,SAAU;;CAMhB,KAAIC,kBAAmB;AACtB,SAAO;GACN,mBAA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AAO,MAAM,MAAM,SAAS,SAAS,KAAK,WAAW;GACpD,SAAS,MAAM;GACf,aAAa,OAAO,MAAM,MAAM;GAChC,EAAE;;;CAIJ,OAAO,eAAe,QAAiC,OAAwC;EAC9F,MAAM,MAAM,OAAO,MAAM;AAEzB,SAAO,OAAO,QAAQ,MAAM,MAAM,EAAE,YAAY;;;;;;;;CASjD,OAAO,gBAAgB,QAAiC,OAAwC;EAC/F,MAAM,MAAM,OAAO,MAAM;AACzB,SAAO,OAAO,QAAQ,MAAM,OAAO,EAAE,YAAY"}
@@ -1,5 +1,5 @@
1
1
  import { DeepBookConfig } from "../utils/config.mjs";
2
- import * as _mysten_sui_transactions2 from "@mysten/sui/transactions";
2
+ import * as _mysten_sui_transactions0 from "@mysten/sui/transactions";
3
3
  import { Transaction, TransactionArgument } from "@mysten/sui/transactions";
4
4
 
5
5
  //#region src/transactions/balanceManager.d.ts
@@ -21,7 +21,7 @@ declare class BalanceManagerContract {
21
21
  * @description Create a new BalanceManager, manually set the owner. Returns the manager.
22
22
  * @returns A function that takes a Transaction object
23
23
  */
24
- createBalanceManagerWithOwner: (ownerAddress: string) => (tx: Transaction) => _mysten_sui_transactions2.TransactionResult;
24
+ createBalanceManagerWithOwner: (ownerAddress: string) => (tx: Transaction) => _mysten_sui_transactions0.TransactionResult;
25
25
  /**
26
26
  * @description Share the BalanceManager
27
27
  * @param {TransactionArgument} manager The BalanceManager to share
@@ -65,38 +65,38 @@ declare class BalanceManagerContract {
65
65
  * @param {string} managerKey The key of the BalanceManager
66
66
  * @returns A function that takes a Transaction object
67
67
  */
68
- generateProof: (managerKey: string) => (tx: Transaction) => _mysten_sui_transactions2.TransactionResult;
68
+ generateProof: (managerKey: string) => (tx: Transaction) => _mysten_sui_transactions0.TransactionResult;
69
69
  /**
70
70
  * @description Generate a trade proof as the owner
71
71
  * @param {string} managerId The ID of the BalanceManager
72
72
  * @returns A function that takes a Transaction object
73
73
  */
74
- generateProofAsOwner: (managerId: string) => (tx: Transaction) => _mysten_sui_transactions2.TransactionResult;
74
+ generateProofAsOwner: (managerId: string) => (tx: Transaction) => _mysten_sui_transactions0.TransactionResult;
75
75
  /**
76
76
  * @description Generate a trade proof as a trader
77
77
  * @param {string} managerId The ID of the BalanceManager
78
78
  * @param {string} tradeCapId The ID of the tradeCap
79
79
  * @returns A function that takes a Transaction object
80
80
  */
81
- generateProofAsTrader: (managerId: string, tradeCapId: string) => (tx: Transaction) => _mysten_sui_transactions2.TransactionResult;
81
+ generateProofAsTrader: (managerId: string, tradeCapId: string) => (tx: Transaction) => _mysten_sui_transactions0.TransactionResult;
82
82
  /**
83
83
  * @description Mint a TradeCap
84
84
  * @param {string} managerKey The name of the BalanceManager
85
85
  * @returns A function that takes a Transaction object
86
86
  */
87
- mintTradeCap: (managerKey: string) => (tx: Transaction) => _mysten_sui_transactions2.TransactionResult;
87
+ mintTradeCap: (managerKey: string) => (tx: Transaction) => _mysten_sui_transactions0.TransactionResult;
88
88
  /**
89
89
  * @description Mint a DepositCap
90
90
  * @param {string} managerKey The name of the BalanceManager
91
91
  * @returns A function that takes a Transaction object
92
92
  */
93
- mintDepositCap: (managerKey: string) => (tx: Transaction) => _mysten_sui_transactions2.TransactionResult;
93
+ mintDepositCap: (managerKey: string) => (tx: Transaction) => _mysten_sui_transactions0.TransactionResult;
94
94
  /**
95
95
  * @description Mint a WithdrawalCap
96
96
  * @param {string} managerKey The name of the BalanceManager
97
97
  * @returns A function that takes a Transaction object
98
98
  */
99
- mintWithdrawalCap: (managerKey: string) => (tx: Transaction) => _mysten_sui_transactions2.TransactionResult;
99
+ mintWithdrawalCap: (managerKey: string) => (tx: Transaction) => _mysten_sui_transactions0.TransactionResult;
100
100
  /**
101
101
  * @description Deposit using the DepositCap
102
102
  * @param {string} managerKey The name of the BalanceManager
@@ -112,7 +112,7 @@ declare class BalanceManagerContract {
112
112
  * @param {number} amountToWithdraw The amount to withdraw
113
113
  * @returns A function that takes a Transaction object
114
114
  */
115
- withdrawWithCap: (managerKey: string, coinKey: string, amountToWithdraw: number) => (tx: Transaction) => _mysten_sui_transactions2.TransactionResult;
115
+ withdrawWithCap: (managerKey: string, coinKey: string, amountToWithdraw: number) => (tx: Transaction) => _mysten_sui_transactions0.TransactionResult;
116
116
  /**
117
117
  * @description Set the referral for the BalanceManager for a specific pool
118
118
  * @param {string} managerKey The name of the BalanceManager
@@ -147,20 +147,20 @@ declare class BalanceManagerContract {
147
147
  * @param {string} referralId The ID of the referral to get the owner of
148
148
  * @returns A function that takes a Transaction object
149
149
  */
150
- balanceManagerReferralOwner: (referralId: string) => (tx: Transaction) => _mysten_sui_transactions2.TransactionResult;
150
+ balanceManagerReferralOwner: (referralId: string) => (tx: Transaction) => _mysten_sui_transactions0.TransactionResult;
151
151
  /**
152
152
  * @description Get the pool ID associated with a referral (DeepBookPoolReferral)
153
153
  * @param {string} referralId The ID of the referral to get the pool ID of
154
154
  * @returns A function that takes a Transaction object
155
155
  */
156
- balanceManagerReferralPoolId: (referralId: string) => (tx: Transaction) => _mysten_sui_transactions2.TransactionResult;
156
+ balanceManagerReferralPoolId: (referralId: string) => (tx: Transaction) => _mysten_sui_transactions0.TransactionResult;
157
157
  /**
158
158
  * @description Get the referral ID from the balance manager for a specific pool
159
159
  * @param {string} managerKey The name of the BalanceManager
160
160
  * @param {string} poolKey Key of the pool to get the referral for
161
161
  * @returns A function that takes a Transaction object
162
162
  */
163
- getBalanceManagerReferralId: (managerKey: string, poolKey: string) => (tx: Transaction) => _mysten_sui_transactions2.TransactionResult;
163
+ getBalanceManagerReferralId: (managerKey: string, poolKey: string) => (tx: Transaction) => _mysten_sui_transactions0.TransactionResult;
164
164
  /**
165
165
  * @description Revoke a TradeCap. This also revokes the associated DepositCap and WithdrawCap.
166
166
  * @param {string} managerKey The name of the BalanceManager
@@ -1,6 +1,6 @@
1
1
  import { CanPlaceLimitOrderParams, CanPlaceMarketOrderParams, CreatePermissionlessPoolParams, PlaceLimitOrderParams, PlaceMarketOrderParams, SwapParams, SwapWithManagerParams } from "../types/index.mjs";
2
2
  import { DeepBookConfig } from "../utils/config.mjs";
3
- import * as _mysten_sui_transactions13 from "@mysten/sui/transactions";
3
+ import * as _mysten_sui_transactions10 from "@mysten/sui/transactions";
4
4
  import { Transaction } from "@mysten/sui/transactions";
5
5
 
6
6
  //#region src/transactions/deepbook.d.ts
@@ -380,40 +380,40 @@ declare class DeepBookContract {
380
380
  * @param {string} referral The referral (DeepBookPoolReferral) to get the balances for
381
381
  * @returns A function that takes a Transaction object
382
382
  */
383
- getPoolReferralBalances: (poolKey: string, referral: string) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
383
+ getPoolReferralBalances: (poolKey: string, referral: string) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
384
384
  /**
385
385
  * @description Get the multiplier for a referral (DeepBookPoolReferral)
386
386
  * @param {string} poolKey The key to identify the pool
387
387
  * @param {string} referral The referral (DeepBookPoolReferral) to get the multiplier for
388
388
  * @returns A function that takes a Transaction object
389
389
  */
390
- poolReferralMultiplier: (poolKey: string, referral: string) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
390
+ poolReferralMultiplier: (poolKey: string, referral: string) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
391
391
  /**
392
392
  * @description Check if a pool is a stable pool
393
393
  * @param {string} poolKey The key to identify the pool
394
394
  * @returns A function that takes a Transaction object
395
395
  */
396
- stablePool: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
396
+ stablePool: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
397
397
  /**
398
398
  * @description Check if a pool is registered
399
399
  * @param {string} poolKey The key to identify the pool
400
400
  * @returns A function that takes a Transaction object
401
401
  */
402
- registeredPool: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
402
+ registeredPool: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
403
403
  /**
404
404
  * @description Get the quote quantity out for a given base quantity using input token as fee
405
405
  * @param {string} poolKey The key to identify the pool
406
406
  * @param {number} baseQuantity Base quantity to convert
407
407
  * @returns A function that takes a Transaction object
408
408
  */
409
- getQuoteQuantityOutInputFee: (poolKey: string, baseQuantity: number | bigint) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
409
+ getQuoteQuantityOutInputFee: (poolKey: string, baseQuantity: number | bigint) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
410
410
  /**
411
411
  * @description Get the base quantity out for a given quote quantity using input token as fee
412
412
  * @param {string} poolKey The key to identify the pool
413
413
  * @param {number} quoteQuantity Quote quantity to convert
414
414
  * @returns A function that takes a Transaction object
415
415
  */
416
- getBaseQuantityOutInputFee: (poolKey: string, quoteQuantity: number | bigint) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
416
+ getBaseQuantityOutInputFee: (poolKey: string, quoteQuantity: number | bigint) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
417
417
  /**
418
418
  * @description Get the quantity out for a given base or quote quantity using input token as fee
419
419
  * @param {string} poolKey The key to identify the pool
@@ -421,7 +421,7 @@ declare class DeepBookContract {
421
421
  * @param {number} quoteQuantity Quote quantity to convert
422
422
  * @returns A function that takes a Transaction object
423
423
  */
424
- getQuantityOutInputFee: (poolKey: string, baseQuantity: number | bigint, quoteQuantity: number | bigint) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
424
+ getQuantityOutInputFee: (poolKey: string, baseQuantity: number | bigint, quoteQuantity: number | bigint) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
425
425
  /**
426
426
  * @description Get the base quantity needed to receive a target quote quantity
427
427
  * @param {string} poolKey The key to identify the pool
@@ -429,7 +429,7 @@ declare class DeepBookContract {
429
429
  * @param {boolean} payWithDeep Whether to pay fees with DEEP
430
430
  * @returns A function that takes a Transaction object
431
431
  */
432
- getBaseQuantityIn: (poolKey: string, targetQuoteQuantity: number | bigint, payWithDeep: boolean) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
432
+ getBaseQuantityIn: (poolKey: string, targetQuoteQuantity: number | bigint, payWithDeep: boolean) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
433
433
  /**
434
434
  * @description Get the quote quantity needed to receive a target base quantity
435
435
  * @param {string} poolKey The key to identify the pool
@@ -437,14 +437,14 @@ declare class DeepBookContract {
437
437
  * @param {boolean} payWithDeep Whether to pay fees with DEEP
438
438
  * @returns A function that takes a Transaction object
439
439
  */
440
- getQuoteQuantityIn: (poolKey: string, targetBaseQuantity: number | bigint, payWithDeep: boolean) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
440
+ getQuoteQuantityIn: (poolKey: string, targetBaseQuantity: number | bigint, payWithDeep: boolean) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
441
441
  /**
442
442
  * @description Get account order details for a balance manager
443
443
  * @param {string} poolKey The key to identify the pool
444
444
  * @param {string} managerKey Key of the balance manager
445
445
  * @returns A function that takes a Transaction object
446
446
  */
447
- getAccountOrderDetails: (poolKey: string, managerKey: string) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
447
+ getAccountOrderDetails: (poolKey: string, managerKey: string) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
448
448
  /**
449
449
  * @description Get the DEEP required for an order
450
450
  * @param {string} poolKey The key to identify the pool
@@ -452,51 +452,51 @@ declare class DeepBookContract {
452
452
  * @param {number} price Price
453
453
  * @returns A function that takes a Transaction object
454
454
  */
455
- getOrderDeepRequired: (poolKey: string, baseQuantity: number | bigint, price: number | bigint) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
455
+ getOrderDeepRequired: (poolKey: string, baseQuantity: number | bigint, price: number | bigint) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
456
456
  /**
457
457
  * @description Check if account exists for a balance manager
458
458
  * @param {string} poolKey The key to identify the pool
459
459
  * @param {string} managerKey Key of the balance manager
460
460
  * @returns A function that takes a Transaction object
461
461
  */
462
- accountExists: (poolKey: string, managerKey: string) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
462
+ accountExists: (poolKey: string, managerKey: string) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
463
463
  /**
464
464
  * @description Get the next epoch trade parameters for a pool
465
465
  * @param {string} poolKey The key to identify the pool
466
466
  * @returns A function that takes a Transaction object
467
467
  */
468
- poolTradeParamsNext: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
468
+ poolTradeParamsNext: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
469
469
  /**
470
470
  * @description Get the quorum for a pool
471
471
  * @param {string} poolKey The key to identify the pool
472
472
  * @returns A function that takes a Transaction object
473
473
  */
474
- quorum: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
474
+ quorum: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
475
475
  /**
476
476
  * @description Get the pool ID
477
477
  * @param {string} poolKey The key to identify the pool
478
478
  * @returns A function that takes a Transaction object
479
479
  */
480
- poolId: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
480
+ poolId: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
481
481
  /**
482
482
  * @description Check if a limit order can be placed
483
483
  * @param {CanPlaceLimitOrderParams} params Parameters for checking limit order validity
484
484
  * @returns A function that takes a Transaction object
485
485
  */
486
- canPlaceLimitOrder: (params: CanPlaceLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
486
+ canPlaceLimitOrder: (params: CanPlaceLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
487
487
  /**
488
488
  * @description Check if a market order can be placed
489
489
  * @param {CanPlaceMarketOrderParams} params Parameters for checking market order validity
490
490
  * @returns A function that takes a Transaction object
491
491
  */
492
- canPlaceMarketOrder: (params: CanPlaceMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
492
+ canPlaceMarketOrder: (params: CanPlaceMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
493
493
  /**
494
494
  * @description Check if market order params are valid
495
495
  * @param {string} poolKey The key to identify the pool
496
496
  * @param {number} quantity Quantity
497
497
  * @returns A function that takes a Transaction object
498
498
  */
499
- checkMarketOrderParams: (poolKey: string, quantity: number | bigint) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
499
+ checkMarketOrderParams: (poolKey: string, quantity: number | bigint) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
500
500
  /**
501
501
  * @description Check if limit order params are valid
502
502
  * @param {string} poolKey The key to identify the pool
@@ -505,7 +505,7 @@ declare class DeepBookContract {
505
505
  * @param {number} expireTimestamp Expiration timestamp
506
506
  * @returns A function that takes a Transaction object
507
507
  */
508
- checkLimitOrderParams: (poolKey: string, price: number | bigint, quantity: number | bigint, expireTimestamp: number) => (tx: Transaction) => _mysten_sui_transactions13.TransactionResult;
508
+ checkLimitOrderParams: (poolKey: string, price: number | bigint, quantity: number | bigint, expireTimestamp: number) => (tx: Transaction) => _mysten_sui_transactions10.TransactionResult;
509
509
  }
510
510
  //#endregion
511
511
  export { DeepBookContract };
@@ -1,6 +1,6 @@
1
1
  import { CreatePoolAdminParams, SetEwmaParams } from "../types/index.mjs";
2
2
  import { DeepBookConfig } from "../utils/config.mjs";
3
- import * as _mysten_sui_transactions0 from "@mysten/sui/transactions";
3
+ import * as _mysten_sui_transactions29 from "@mysten/sui/transactions";
4
4
  import { Transaction } from "@mysten/sui/transactions";
5
5
 
6
6
  //#region src/transactions/deepbookAdmin.d.ts
@@ -104,7 +104,7 @@ declare class DeepBookAdminContract {
104
104
  * @description Deauthorize the MarginApp by removing its authorization key
105
105
  * @returns A function that takes a Transaction object and returns a bool
106
106
  */
107
- deauthorizeMarginApp: () => (tx: Transaction) => _mysten_sui_transactions0.TransactionResult;
107
+ deauthorizeMarginApp: () => (tx: Transaction) => _mysten_sui_transactions29.TransactionResult;
108
108
  /**
109
109
  * @description Mint a `DeepbookCorePauseCap`. The new cap's ID is recorded
110
110
  * in the core registry so it can later disable any allowed package version
@@ -112,7 +112,7 @@ declare class DeepBookAdminContract {
112
112
  * `MarginAdminContract.mintPauseCap`.
113
113
  * @returns A function that takes a Transaction object and returns the new pause cap
114
114
  */
115
- mintCorePauseCap: () => (tx: Transaction) => _mysten_sui_transactions0.TransactionResult;
115
+ mintCorePauseCap: () => (tx: Transaction) => _mysten_sui_transactions29.TransactionResult;
116
116
  /**
117
117
  * @description Revoke a previously minted `DeepbookCorePauseCap` by ID.
118
118
  * @param {string} pauseCapId The ID of the core pause cap to revoke
@@ -133,7 +133,7 @@ declare class DeepBookAdminContract {
133
133
  * core registry.
134
134
  * @returns A function that takes a Transaction object and returns a `VecSet<ID>`
135
135
  */
136
- corePauseCaps: () => (tx: Transaction) => _mysten_sui_transactions0.TransactionResult;
136
+ corePauseCaps: () => (tx: Transaction) => _mysten_sui_transactions29.TransactionResult;
137
137
  }
138
138
  //#endregion
139
139
  export { DeepBookAdminContract };
@@ -1 +1 @@
1
- {"version":3,"file":"deepbookAdmin.d.mts","names":[],"sources":["../../src/transactions/deepbookAdmin.ts"],"mappings":";;;;;;;;;cAea,qBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAyD4B;;;;;EApChD,eAAA,GAAmB,MAAA,EAAQ,qBAAA,MAA2B,EAAA,EAAI,WAAA;EA0IP;;;;;EAtGnD,mBAAA,GAAuB,OAAA,cAAqB,EAAA,EAAI,WAAA;EA6Na;;;;;EAvM7D,qBAAA,GAAyB,OAAA,cAAqB,EAAA,EAAI,WAAA;EAsQA;;;;;EAhPlD,aAAA,GAAiB,OAAA,cAAqB,EAAA,EAAI,WAAA;;;;;;EAc1C,cAAA,GAAkB,OAAA,cAAqB,EAAA,EAAI,WAAA;EA9FxB;;;;;EA4GnB,kBAAA,GAAsB,eAAA,cAA6B,EAAA,EAAI,WAAA;EAxEX;;;;;EAsF5C,aA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