@mysten/deepbook-v3 2.9.2 → 2.10.1

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 (204) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +21 -0
  3. package/dist/account-bindings/account-registry.d.mts +109 -0
  4. package/dist/account-bindings/account-registry.d.mts.map +1 -0
  5. package/dist/account-bindings/account-registry.mjs +56 -0
  6. package/dist/account-bindings/account-registry.mjs.map +1 -0
  7. package/dist/account-bindings/account.d.mts +176 -0
  8. package/dist/account-bindings/account.d.mts.map +1 -0
  9. package/dist/account-bindings/account.mjs +94 -0
  10. package/dist/account-bindings/account.mjs.map +1 -0
  11. package/dist/account-bindings/latest.d.mts +12 -0
  12. package/dist/account-bindings/latest.d.mts.map +1 -0
  13. package/dist/account-bindings/latest.mjs +19 -0
  14. package/dist/account-bindings/latest.mjs.map +1 -0
  15. package/dist/account.d.mts +46 -3
  16. package/dist/account.d.mts.map +1 -1
  17. package/dist/account.mjs +51 -2
  18. package/dist/account.mjs.map +1 -1
  19. package/dist/contracts/account/account.d.mts +25 -97
  20. package/dist/contracts/account/account.d.mts.map +1 -1
  21. package/dist/contracts/account/account.mjs +43 -35
  22. package/dist/contracts/account/account.mjs.map +1 -1
  23. package/dist/contracts/account/account_events.d.mts +20 -20
  24. package/dist/contracts/account/account_events.d.mts.map +1 -1
  25. package/dist/contracts/account/account_registry.d.mts +7 -54
  26. package/dist/contracts/account/account_registry.d.mts.map +1 -1
  27. package/dist/contracts/account/account_registry.mjs +2 -22
  28. package/dist/contracts/account/account_registry.mjs.map +1 -1
  29. package/dist/contracts/deepbook/account.d.mts +18 -18
  30. package/dist/contracts/deepbook/balances.d.mts +4 -4
  31. package/dist/contracts/deepbook/deep_price.d.mts +3 -3
  32. package/dist/contracts/deepbook/order.d.mts +12 -12
  33. package/dist/contracts/deepbook_predict/admin.d.mts +4 -4
  34. package/dist/contracts/deepbook_predict/admin.d.mts.map +1 -1
  35. package/dist/contracts/deepbook_predict/builder_code.d.mts +60 -13
  36. package/dist/contracts/deepbook_predict/builder_code.d.mts.map +1 -1
  37. package/dist/contracts/deepbook_predict/builder_code.mjs +55 -1
  38. package/dist/contracts/deepbook_predict/builder_code.mjs.map +1 -1
  39. package/dist/contracts/deepbook_predict/builder_code_events.d.mts +10 -10
  40. package/dist/contracts/deepbook_predict/config_events.d.mts +88 -84
  41. package/dist/contracts/deepbook_predict/config_events.d.mts.map +1 -1
  42. package/dist/contracts/deepbook_predict/config_events.mjs +8 -0
  43. package/dist/contracts/deepbook_predict/config_events.mjs.map +1 -1
  44. package/dist/contracts/deepbook_predict/expiry_market.d.mts +262 -101
  45. package/dist/contracts/deepbook_predict/expiry_market.d.mts.map +1 -1
  46. package/dist/contracts/deepbook_predict/expiry_market.mjs +320 -41
  47. package/dist/contracts/deepbook_predict/expiry_market.mjs.map +1 -1
  48. package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts +5 -5
  49. package/dist/contracts/deepbook_predict/market_manager.d.mts +27 -27
  50. package/dist/contracts/deepbook_predict/order_events.d.mts +56 -54
  51. package/dist/contracts/deepbook_predict/order_events.d.mts.map +1 -1
  52. package/dist/contracts/deepbook_predict/order_events.mjs.map +1 -1
  53. package/dist/contracts/deepbook_predict/pause_cap.d.mts +5 -5
  54. package/dist/contracts/deepbook_predict/plp.d.mts +74 -74
  55. package/dist/contracts/deepbook_predict/plp.d.mts.map +1 -1
  56. package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts +5 -5
  57. package/dist/contracts/deepbook_predict/predict_account.d.mts +22 -17
  58. package/dist/contracts/deepbook_predict/predict_account.d.mts.map +1 -1
  59. package/dist/contracts/deepbook_predict/predict_account.mjs +12 -6
  60. package/dist/contracts/deepbook_predict/predict_account.mjs.map +1 -1
  61. package/dist/contracts/deepbook_predict/pricing.d.mts +67 -67
  62. package/dist/contracts/deepbook_predict/pricing.d.mts.map +1 -1
  63. package/dist/contracts/deepbook_predict/protocol_config.d.mts +127 -83
  64. package/dist/contracts/deepbook_predict/protocol_config.d.mts.map +1 -1
  65. package/dist/contracts/deepbook_predict/protocol_config.mjs +59 -1
  66. package/dist/contracts/deepbook_predict/protocol_config.mjs.map +1 -1
  67. package/dist/contracts/deepbook_predict/range_codec.d.mts +2 -2
  68. package/dist/contracts/deepbook_predict/registry.d.mts +32 -32
  69. package/dist/contracts/deepbook_predict/vault_events.d.mts +131 -131
  70. package/dist/contracts/deepbook_predict_math/lazer_price.d.mts +13 -13
  71. package/dist/contracts/deepbook_predict_math/math.d.mts +14 -14
  72. package/dist/contracts/deepbook_predict_orders/delayed_execution_config.d.mts +30 -30
  73. package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.mjs +6 -0
  74. package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.mjs.map +1 -1
  75. package/dist/contracts/deepbook_predict_orders/desk.d.mts +28 -28
  76. package/dist/contracts/deepbook_predict_orders/order_queue.d.mts +187 -187
  77. package/dist/contracts/deepbook_predict_orders/queue.d.mts +240 -62
  78. package/dist/contracts/deepbook_predict_orders/queue.d.mts.map +1 -1
  79. package/dist/contracts/deepbook_predict_orders/queue.mjs +306 -41
  80. package/dist/contracts/deepbook_predict_orders/queue.mjs.map +1 -1
  81. package/dist/contracts/deepbook_predict_orders/queue_events.d.mts +140 -140
  82. package/dist/contracts/deepbook_sessions/session_config.d.mts +8 -8
  83. package/dist/contracts/deepbook_sessions/session_config.d.mts.map +1 -1
  84. package/dist/contracts/deepbook_sessions/sessions.d.mts +271 -31
  85. package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -1
  86. package/dist/contracts/deepbook_sessions/sessions.mjs +363 -3
  87. package/dist/contracts/deepbook_sessions/sessions.mjs.map +1 -1
  88. package/dist/deployments/mainnet.mjs.map +1 -1
  89. package/dist/deployments/testnet.d.mts.map +1 -1
  90. package/dist/deployments/testnet.mjs +7 -4
  91. package/dist/deployments/testnet.mjs.map +1 -1
  92. package/dist/predict/bindings/expiry-market.d.mts +57 -7
  93. package/dist/predict/bindings/expiry-market.d.mts.map +1 -1
  94. package/dist/predict/bindings/expiry-market.mjs +48 -2
  95. package/dist/predict/bindings/expiry-market.mjs.map +1 -1
  96. package/dist/predict/bindings/protocol-config.d.mts +5 -5
  97. package/dist/predict/bindings/protocol-config.mjs +4 -1
  98. package/dist/predict/bindings/protocol-config.mjs.map +1 -1
  99. package/dist/predict/bindings/queue.d.mts +30 -0
  100. package/dist/predict/bindings/queue.d.mts.map +1 -0
  101. package/dist/predict/bindings/queue.mjs +59 -0
  102. package/dist/predict/bindings/queue.mjs.map +1 -0
  103. package/dist/predict/bindings/rename.mjs +5 -1
  104. package/dist/predict/bindings/rename.mjs.map +1 -1
  105. package/dist/predict/client.d.mts.map +1 -1
  106. package/dist/predict/client.mjs +11 -5
  107. package/dist/predict/client.mjs.map +1 -1
  108. package/dist/predict/config/generated.d.mts +1 -1
  109. package/dist/predict/config/generated.d.mts.map +1 -1
  110. package/dist/predict/config/generated.mjs +1 -0
  111. package/dist/predict/config/generated.mjs.map +1 -1
  112. package/dist/predict/config/mainnet.mjs +3 -1
  113. package/dist/predict/config/mainnet.mjs.map +1 -1
  114. package/dist/predict/config/testnet.mjs +3 -1
  115. package/dist/predict/config/testnet.mjs.map +1 -1
  116. package/dist/predict/config/types.d.mts +23 -0
  117. package/dist/predict/config/types.d.mts.map +1 -1
  118. package/dist/predict/cost.d.mts +9 -1
  119. package/dist/predict/cost.d.mts.map +1 -1
  120. package/dist/predict/cost.mjs.map +1 -1
  121. package/dist/predict/errors.d.mts.map +1 -1
  122. package/dist/predict/errors.mjs +6 -2
  123. package/dist/predict/errors.mjs.map +1 -1
  124. package/dist/predict/index.d.mts +1 -1
  125. package/dist/predict/index.mjs +2 -2
  126. package/dist/predict/queue.d.mts +8 -4
  127. package/dist/predict/queue.d.mts.map +1 -1
  128. package/dist/predict/queue.mjs +8 -4
  129. package/dist/predict/queue.mjs.map +1 -1
  130. package/dist/predict/reads/balances.mjs +1 -1
  131. package/dist/predict/reads/queue.d.mts +3 -2
  132. package/dist/predict/reads/queue.d.mts.map +1 -1
  133. package/dist/predict/reads/queue.mjs +5 -4
  134. package/dist/predict/reads/queue.mjs.map +1 -1
  135. package/dist/predict/tx/authed.mjs +1 -1
  136. package/dist/predict/tx/common.d.mts.map +1 -1
  137. package/dist/predict/tx/common.mjs +3 -2
  138. package/dist/predict/tx/common.mjs.map +1 -1
  139. package/dist/predict/tx/trade.d.mts.map +1 -1
  140. package/dist/predict/tx/trade.mjs +3 -2
  141. package/dist/predict/tx/trade.mjs.map +1 -1
  142. package/dist/sessions.d.mts +10 -1
  143. package/dist/sessions.d.mts.map +1 -1
  144. package/dist/sessions.mjs.map +1 -1
  145. package/dist/transactions/balanceManager.d.mts +12 -12
  146. package/dist/transactions/balanceManager.d.mts.map +1 -1
  147. package/dist/transactions/deepbook.d.mts +20 -20
  148. package/dist/transactions/deepbook.d.mts.map +1 -1
  149. package/dist/transactions/deepbookAdmin.d.mts +4 -4
  150. package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
  151. package/dist/transactions/marginAdmin.d.mts +7 -7
  152. package/dist/transactions/marginAdmin.d.mts.map +1 -1
  153. package/dist/transactions/marginLiquidations.d.mts +3 -3
  154. package/dist/transactions/marginMaintainer.d.mts +5 -5
  155. package/dist/transactions/marginMaintainer.d.mts.map +1 -1
  156. package/dist/transactions/marginManager.d.mts +32 -32
  157. package/dist/transactions/marginManager.d.mts.map +1 -1
  158. package/dist/transactions/marginPool.d.mts +18 -18
  159. package/dist/transactions/marginPool.d.mts.map +1 -1
  160. package/dist/transactions/marginRegistry.d.mts +16 -16
  161. package/dist/transactions/marginTPSL.d.mts +10 -10
  162. package/dist/transactions/marginTPSL.d.mts.map +1 -1
  163. package/dist/transactions/poolProxy.d.mts +8 -8
  164. package/dist/transactions/poolProxy.d.mts.map +1 -1
  165. package/dist/utils/constants.d.mts.map +1 -1
  166. package/dist/utils/constants.mjs +2 -2
  167. package/dist/utils/constants.mjs.map +1 -1
  168. package/package.json +1 -1
  169. package/src/account-bindings/account-registry.ts +39 -0
  170. package/src/account-bindings/account.ts +73 -0
  171. package/src/account-bindings/latest.ts +41 -0
  172. package/src/account.ts +89 -5
  173. package/src/contracts/account/account.ts +73 -4
  174. package/src/contracts/account/account_registry.ts +1 -1
  175. package/src/contracts/deepbook_predict/builder_code.ts +94 -2
  176. package/src/contracts/deepbook_predict/config_events.ts +7 -0
  177. package/src/contracts/deepbook_predict/expiry_market.ts +490 -44
  178. package/src/contracts/deepbook_predict/order_events.ts +6 -4
  179. package/src/contracts/deepbook_predict/predict_account.ts +12 -6
  180. package/src/contracts/deepbook_predict/protocol_config.ts +85 -0
  181. package/src/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.ts +14 -0
  182. package/src/contracts/deepbook_predict_orders/order_flow.ts +4 -0
  183. package/src/contracts/deepbook_predict_orders/queue.ts +495 -9
  184. package/src/contracts/deepbook_sessions/sessions.ts +538 -3
  185. package/src/deployments/mainnet.ts +4 -4
  186. package/src/deployments/testnet.ts +18 -7
  187. package/src/deployments/types.ts +14 -0
  188. package/src/predict/bindings/expiry-market.ts +87 -0
  189. package/src/predict/bindings/queue.ts +42 -0
  190. package/src/predict/bindings/rename.ts +5 -1
  191. package/src/predict/client.ts +25 -3
  192. package/src/predict/config/generated.ts +3 -0
  193. package/src/predict/config/mainnet.ts +4 -0
  194. package/src/predict/config/testnet.ts +4 -0
  195. package/src/predict/config/types.ts +23 -0
  196. package/src/predict/cost.ts +9 -1
  197. package/src/predict/errors.ts +11 -1
  198. package/src/predict/index.ts +1 -1
  199. package/src/predict/queue.ts +8 -4
  200. package/src/predict/reads/queue.ts +7 -4
  201. package/src/predict/tx/common.ts +2 -0
  202. package/src/predict/tx/trade.ts +3 -1
  203. package/src/sessions.ts +10 -1
  204. package/src/utils/constants.ts +8 -3
@@ -38,8 +38,20 @@ export interface DeploymentUnits {
38
38
 
39
39
  /** Ids for the shared `account` primitive. */
40
40
  export interface AccountIds {
41
+ /**
42
+ * The ORIGINAL `account` package ID. Type tags and the derived wrapper and account addresses
43
+ * are built from it, because Move types keep their defining package across upgrades. Moving it
44
+ * to a newer package would derive addresses nothing lives at.
45
+ */
41
46
  accountPackageId: string;
42
47
  accountRegistry: string;
48
+ /**
49
+ * The latest `account` package, once the network has upgraded it: the call target of every
50
+ * account call. A PTB can't call a package at an older version than another package in it
51
+ * links (Predict's Version 5 links account v2), and `receive_coin` only exists from v2.
52
+ * Absent while the network runs v1. Never used for type tags or derived addresses.
53
+ */
54
+ accountPackageIdLatest?: string;
43
55
  }
44
56
 
45
57
  /** Ids for time-limited sessions, including the spot- and Predict-only extras. */
@@ -79,6 +91,8 @@ export interface PredictIds {
79
91
  predictOrdersV1?: string;
80
92
  /** `deepbook_predict_math`, once the network records delayed execution. */
81
93
  predictMath?: string;
94
+ /** Latest `account`, once the network has upgraded it. `account` stays the original ID. */
95
+ accountLatest?: string;
82
96
  };
83
97
  objects: {
84
98
  registry: string;
@@ -125,3 +125,90 @@ export function redeemLive(options: RedeemLiveOptions) {
125
125
  arguments: renameArguments(options.arguments, TRADE_KEYS),
126
126
  });
127
127
  }
128
+
129
+ // Predict v5 underscore-prefixed the parameters of three more functions: `redeem_settled` and
130
+ // `redeem_settled_permissionless` retired, and `quote_close` ignores its builder code since
131
+ // builder fees moved to each trade (`quote_close_with_builder_fee` quotes one). Their shipped keys
132
+ // are kept here like the immediate trades'.
133
+ const SETTLED_KEYS = {
134
+ market: 'Market',
135
+ wrapper: 'Wrapper',
136
+ auth: 'Auth',
137
+ config: 'Config',
138
+ accountRegistry: 'AccountRegistry',
139
+ orderId: 'OrderId',
140
+ } as const;
141
+
142
+ type Positional<Options extends { arguments: unknown }> = Extract<
143
+ Options['arguments'],
144
+ readonly unknown[]
145
+ >;
146
+
147
+ export interface RedeemSettledArguments {
148
+ market: RawTransactionArgument<string>;
149
+ wrapper: RawTransactionArgument<string>;
150
+ auth: TransactionArgument;
151
+ config?: RawTransactionArgument<string>;
152
+ orderId: RawTransactionArgument<number | bigint>;
153
+ }
154
+ export interface RedeemSettledOptions extends Omit<generated.RedeemSettledOptions, 'arguments'> {
155
+ arguments: RedeemSettledArguments | Positional<generated.RedeemSettledOptions>;
156
+ }
157
+ /**
158
+ * @deprecated Retired by delayed execution in Predict v5: it always aborts
159
+ * `EDelayedExecutionRequired`. A queued fill never enters the account; the order-flow package pays
160
+ * its Open record at settlement. A network whose Predict call target is still v4 runs it as before.
161
+ */
162
+ export function redeemSettled(options: RedeemSettledOptions) {
163
+ return generated.redeemSettled({
164
+ ...options,
165
+ arguments: renameArguments(options.arguments, SETTLED_KEYS),
166
+ });
167
+ }
168
+
169
+ export interface RedeemSettledPermissionlessArguments {
170
+ market: RawTransactionArgument<string>;
171
+ accountRegistry: RawTransactionArgument<string>;
172
+ wrapper: RawTransactionArgument<string>;
173
+ config?: RawTransactionArgument<string>;
174
+ orderId: RawTransactionArgument<number | bigint>;
175
+ }
176
+ export interface RedeemSettledPermissionlessOptions extends Omit<
177
+ generated.RedeemSettledPermissionlessOptions,
178
+ 'arguments'
179
+ > {
180
+ arguments:
181
+ RedeemSettledPermissionlessArguments | Positional<generated.RedeemSettledPermissionlessOptions>;
182
+ }
183
+ /**
184
+ * @deprecated Retired with `redeem_settled` in Predict v5: it always aborts
185
+ * `EDelayedExecutionRequired`. A network whose Predict call target is still v4 runs it as before.
186
+ */
187
+ export function redeemSettledPermissionless(options: RedeemSettledPermissionlessOptions) {
188
+ return generated.redeemSettledPermissionless({
189
+ ...options,
190
+ arguments: renameArguments(options.arguments, SETTLED_KEYS),
191
+ });
192
+ }
193
+
194
+ export interface QuoteCloseArguments {
195
+ market: RawTransactionArgument<string>;
196
+ pricer: TransactionArgument;
197
+ receipt: TransactionArgument;
198
+ closeQuantity: RawTransactionArgument<number | bigint>;
199
+ builderCodeId: RawTransactionArgument<string | null>;
200
+ }
201
+ export interface QuoteCloseOptions extends Omit<generated.QuoteCloseOptions, 'arguments'> {
202
+ arguments: QuoteCloseArguments | Positional<generated.QuoteCloseOptions>;
203
+ }
204
+ /**
205
+ * The close a sell fill prices, without the trader's floors. From Predict v5 it quotes a sell that
206
+ * names no builder, whatever `builderCodeId` names; `quoteCloseWithBuilderFee` quotes one that
207
+ * does. Changes nothing.
208
+ */
209
+ export function quoteClose(options: QuoteCloseOptions) {
210
+ return generated.quoteClose({
211
+ ...options,
212
+ arguments: renameArguments(options.arguments, { builderCodeId: 'BuilderCodeId' }),
213
+ });
214
+ }
@@ -0,0 +1,42 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // The public `queueMoveCalls`: the generated order-flow `queue` bindings, with the argument key
5
+ // `quote_redeem_open` shipped with (see `rename.ts`). Its `wrapper` parameter became `_wrapper` in
6
+ // predict_orders v2 (Testnet v3), when builder fees moved from the account to each trade.
7
+
8
+ import type { TransactionArgument } from '@mysten/sui/transactions';
9
+ import * as generated from '../../contracts/deepbook_predict_orders/queue.js';
10
+ import type { RawTransactionArgument } from '../../contracts/utils/index.js';
11
+ import { renameArguments } from './rename.js';
12
+
13
+ export * from '../../contracts/deepbook_predict_orders/queue.js';
14
+
15
+ export interface QuoteRedeemOpenArguments {
16
+ queue: RawTransactionArgument<string>;
17
+ market: RawTransactionArgument<string>;
18
+ wrapper: RawTransactionArgument<string>;
19
+ pricer: TransactionArgument;
20
+ recordId: RawTransactionArgument<number | bigint>;
21
+ closeQuantity: RawTransactionArgument<number | bigint>;
22
+ }
23
+ export interface QuoteRedeemOpenOptions extends Omit<
24
+ generated.QuoteRedeemOpenOptions,
25
+ 'arguments'
26
+ > {
27
+ arguments:
28
+ | QuoteRedeemOpenArguments
29
+ | Extract<generated.QuoteRedeemOpenOptions['arguments'], readonly unknown[]>;
30
+ }
31
+ /**
32
+ * Quote an early sell of `closeQuantity` from the Open record `recordId` at a live `Pricer`: the
33
+ * close a queued sell fills, with no builder fee, matching `enqueue_redeem_open`.
34
+ * `quoteRedeemOpenWithBuilderFee` quotes a sell that names a builder. Changes nothing. The
35
+ * `wrapper` is no longer read, because the fee comes from the trade, not the account.
36
+ */
37
+ export function quoteRedeemOpen(options: QuoteRedeemOpenOptions) {
38
+ return generated.quoteRedeemOpen({
39
+ ...options,
40
+ arguments: renameArguments(options.arguments, { wrapper: 'Wrapper' }),
41
+ });
42
+ }
@@ -6,8 +6,12 @@
6
6
  // move-call exports keep the keys these bindings shipped with, renamed here before calling the
7
7
  // generated binding, so the emitted move call is unchanged.
8
8
 
9
- /** Rename an arguments object's keys by `keys` (shipped key → generated key). */
9
+ /**
10
+ * Rename an arguments object's keys by `keys` (shipped key → generated key). A positional tuple
11
+ * has no keys, so it passes through unchanged.
12
+ */
10
13
  export function renameArguments<T>(args: object, keys: Readonly<Record<string, string>>): T {
14
+ if (Array.isArray(args)) return args as T;
11
15
  return Object.fromEntries(
12
16
  Object.entries(args).map(([key, value]) => [keys[key] ?? key, value]),
13
17
  ) as T;
@@ -44,6 +44,7 @@ import {
44
44
  } from './errors.js';
45
45
  import {
46
46
  ORDER_FLOW_PACKAGE_VERSION,
47
+ PREDICT_PACKAGE_VERSION,
47
48
  ORDER_KIND,
48
49
  ORDER_STATUS,
49
50
  budgetMintLimits,
@@ -1286,6 +1287,16 @@ export class PredictClient {
1286
1287
  return Boolean(predictDelayedExecution && predictOrders && orderDesk && queueRegistry);
1287
1288
  }
1288
1289
 
1290
+ // The version constants the configured call targets compile: the network's own pins, else the
1291
+ // versions these bindings were generated from. A watermark above one retires that code.
1292
+ #predictCurrentVersion(): bigint {
1293
+ return this.cfg.packages.predictCurrentVersion ?? PREDICT_PACKAGE_VERSION;
1294
+ }
1295
+
1296
+ #ordersCurrentVersion(): bigint {
1297
+ return this.cfg.packages.predictOrdersCurrentVersion ?? ORDER_FLOW_PACKAGE_VERSION;
1298
+ }
1299
+
1289
1300
  // The market's queue ID, once its `MarketQueue` is known to exist. A missing queue would abort
1290
1301
  // every read and order with an opaque error, so it is refused here with a typed one.
1291
1302
  async #existingQueueId(orders: OrdersGeneratedConfig, marketId: string): Promise<string> {
@@ -1333,7 +1344,12 @@ export class PredictClient {
1333
1344
  "queued orders aren't live yet: the protocol hasn't enabled the order-flow package",
1334
1345
  );
1335
1346
  }
1336
- const mode = executionModeFor(state.protocol.versionWatermark, true);
1347
+ const mode = executionModeFor(
1348
+ state.protocol.versionWatermark,
1349
+ true,
1350
+ true,
1351
+ this.#predictCurrentVersion(),
1352
+ );
1337
1353
  if (mode === 'retired') {
1338
1354
  throw new PredictPreflightError(
1339
1355
  'retired',
@@ -1346,7 +1362,7 @@ export class PredictClient {
1346
1362
  "queued orders aren't live yet: the protocol's version watermark hasn't been raised",
1347
1363
  );
1348
1364
  }
1349
- if (state.desk.versionWatermark > ORDER_FLOW_PACKAGE_VERSION) {
1365
+ if (state.desk.versionWatermark > this.#ordersCurrentVersion()) {
1350
1366
  throw new PredictPreflightError(
1351
1367
  'retired',
1352
1368
  'the order-flow package version this SDK calls is retired: update the SDK',
@@ -2385,6 +2401,7 @@ export class PredictClient {
2385
2401
  await versionWatermark(this.#client, this.cfg.objects.protocolConfig),
2386
2402
  this.#recordsDelayedExecution(),
2387
2403
  this.cfg.packages.predictDelayedExecution != null,
2404
+ this.#predictCurrentVersion(),
2388
2405
  ),
2389
2406
 
2390
2407
  /**
@@ -2400,7 +2417,12 @@ export class PredictClient {
2400
2417
  const state = await this.#queueState(orders, id, { owner });
2401
2418
  const nowMs = BigInt(Date.now());
2402
2419
  const policy = state.desk.policy;
2403
- const mode = executionModeFor(state.protocol.versionWatermark, true);
2420
+ const mode = executionModeFor(
2421
+ state.protocol.versionWatermark,
2422
+ true,
2423
+ true,
2424
+ this.#predictCurrentVersion(),
2425
+ );
2404
2426
  const timing = previewTiming({
2405
2427
  nowMs,
2406
2428
  policy,
@@ -26,6 +26,7 @@ export type GeneratedConfig = DeepbookPredictConfig &
26
26
  AccountConfig & {
27
27
  predictPackageId: string;
28
28
  predictPackageIdV1: string;
29
+ /** The ORIGINAL account ID: type tags and derived addresses are built from it. */
29
30
  accountPackageId: string;
30
31
  accountRegistry: string;
31
32
  };
@@ -35,6 +36,8 @@ export function toGeneratedConfig(cfg: PredictConfig): GeneratedConfig {
35
36
  predictPackageId: cfg.packages.predict,
36
37
  predictPackageIdV1: cfg.packages.predictV1 ?? cfg.packages.predict,
37
38
  accountPackageId: cfg.packages.account,
39
+ // The account bindings call this when present (see `account-bindings/latest.ts`).
40
+ accountPackageIdLatest: cfg.packages.accountLatest,
38
41
  protocolConfig: cfg.objects.protocolConfig,
39
42
  poolVault: cfg.objects.poolVault,
40
43
  registry: cfg.objects.registry,
@@ -27,6 +27,10 @@ export const MAINNET_CONFIG: PredictConfig = Object.freeze({
27
27
  packages: Object.freeze({
28
28
  ...MAINNET_PREDICT.packages,
29
29
  predictDelayedExecution: '0x98235c5842831c9b5f51dc637cf34c91db2aca5510802eb6ebfec63f5b71a7bb',
30
+ // The version constants the call targets compile: Predict v4 compiles 4 and orders v1 compiles
31
+ // 1. Move them with the call targets at the Version 5 upgrade (to 5 and 2).
32
+ predictCurrentVersion: 4n,
33
+ predictOrdersCurrentVersion: 1n,
30
34
  }),
31
35
  objects: Object.freeze({
32
36
  ...MAINNET_PREDICT.objects,
@@ -27,6 +27,10 @@ export const TESTNET_CONFIG: PredictConfig = Object.freeze({
27
27
  packages: Object.freeze({
28
28
  ...TESTNET_PREDICT.packages,
29
29
  predictDelayedExecution: '0x0654ecbed7c0f2645d9de7cb6cf08e65c2ee05cdbb39a415f17a6bd1cd92e267',
30
+ // The version constants the call targets compile (Version 5: Predict 5, orders 2, as Mainnet
31
+ // will ship them), not their Testnet package numbers (v8, v3). Move them with the call targets.
32
+ predictCurrentVersion: 5n,
33
+ predictOrdersCurrentVersion: 2n,
30
34
  }),
31
35
  objects: Object.freeze({
32
36
  ...TESTNET_PREDICT.objects,
@@ -37,8 +37,31 @@ export interface PredictPackages {
37
37
  predictOrdersV1?: string;
38
38
  /** The `deepbook_predict_math` package ID, for its pure calls and layouts. */
39
39
  predictMath?: string;
40
+ /**
41
+ * ORIGINAL `account` package ID: type tags (`DataKey`, events) and the derived wrapper and
42
+ * account addresses are built from it, so it never moves.
43
+ */
40
44
  account: string;
45
+ /**
46
+ * Latest `account` package once the network has upgraded it: the call target of every account
47
+ * call in a Predict PTB (`generate_auth`, `deposit_funds`, `load_account`, …). A PTB can't call
48
+ * a package at an older version than another package in it links, and Predict's Version 5
49
+ * links account v2. Omit while account is at v1: calls then target `account`.
50
+ */
51
+ accountLatest?: string;
41
52
  propbook: string;
53
+ /**
54
+ * Predict's `constants::current_version` compiled into `predict`, the call target. A
55
+ * `ProtocolConfig.version_watermark` above it retires the code this config calls. It follows the
56
+ * Mainnet package number, not the Testnet one (Testnet's package v8 compiles 5). Defaults to
57
+ * `PREDICT_PACKAGE_VERSION`, the version these bindings were generated from.
58
+ */
59
+ predictCurrentVersion?: bigint;
60
+ /**
61
+ * `desk::current_version` compiled into `predictOrders`. A desk floor above it retires the
62
+ * order-flow code this config calls. Defaults to `ORDER_FLOW_PACKAGE_VERSION`.
63
+ */
64
+ predictOrdersCurrentVersion?: bigint;
42
65
  }
43
66
 
44
67
  /**
@@ -545,7 +545,11 @@ interface MintInputsBase {
545
545
  nowMs?: number | bigint;
546
546
  /** Boundary probabilities, or a pricer snapshot plus the range's strikes. */
547
547
  probabilities: ProbabilitySource;
548
- /** Whether the minting account carries a builder code (it pays the builder fee). */
548
+ /**
549
+ * Whether the minting account carries a builder code and pays the account-attached builder fee:
550
+ * Predict v4 semantics. From Predict Version 5 an attached code charges nothing (a builder fee
551
+ * is passed on each trade instead), so leave this `false` on a network running Version 5.
552
+ */
549
553
  builderCode?: boolean;
550
554
  /** The expiry's remaining sponsored fee balance (`fee_incentive_balance`). Default `0n`. */
551
555
  feeIncentiveBalance?: number | bigint;
@@ -902,6 +906,10 @@ export interface RedeemLiveInputs {
902
906
  closeQuantity: number | bigint;
903
907
  /** Current position payout quantity, when known. Validates the close and returns the remainder. */
904
908
  positionQuantity?: number | bigint;
909
+ /**
910
+ * Whether the selling account pays the account-attached builder fee: Predict v4 semantics.
911
+ * Leave it `false` on a network running Version 5, where an attached code charges nothing.
912
+ */
905
913
  builderCode?: boolean;
906
914
  penaltyRate?: bigint;
907
915
  /** Pre-trade payout-tree terms. Required when inventory impact is enabled. */
@@ -114,6 +114,8 @@ export const ABORT_NAMES: Readonly<Record<string, readonly string[]>> = Object.f
114
114
  'ECutoverNotReached',
115
115
  'EEwmaRetired',
116
116
  'EOrderFlowNotAllowed',
117
+ // Predict v5: a builder trade before the watermark reaches the builder-fee version.
118
+ 'EBuilderFeeCutoverNotReached',
117
119
  ],
118
120
  // Predict's live pricer, which every quote, plan and enqueue loads.
119
121
  pricing: [
@@ -234,7 +236,15 @@ export const ABORT_NAMES: Readonly<Record<string, readonly string[]>> = Object.f
234
236
  // The math library (`deepbook_predict_math`).
235
237
  lazer_price: ['EPropertyNotRequested', 'EGenerationAfterEnvelope', 'EFeedMissing'],
236
238
  // Sessions (`deepbook_sessions`), which the `/sessions` Predict wrappers abort in.
237
- sessions: ['EInvalidSessionDuration', 'ESessionNotAuthorized', 'ESessionLimitExceeded'],
239
+ sessions: [
240
+ 'EInvalidSessionDuration',
241
+ 'ESessionNotAuthorized',
242
+ 'ESessionLimitExceeded',
243
+ // Session builder approvals (Sessions v4, the Mainnet number).
244
+ 'EBuilderNotApproved',
245
+ 'EBuilderFeeAboveApproved',
246
+ 'EBuilderApprovalsNotEnabled',
247
+ ],
238
248
  session_config: ['EPackageVersionDisabled', 'EVersionWatermarkNotAdvanced'],
239
249
  // The shared account (`deepbook_account`).
240
250
  account_registry: ['EAppAlreadyAuthorized', 'EAppNotAuthorized', 'EAccountAlreadyExists'],
@@ -81,7 +81,7 @@ export * as vaultEvents from '../contracts/deepbook_predict/vault_events.js';
81
81
  // `config: toOrdersConfig(cfg)`, which adds the companion package and the desk to the projected
82
82
  // config. `deepbook_predict_math` is the pure math library (`predictMathMoveCalls`) and the
83
83
  // `LazerPrice` a verified Pyth Lazer update decodes to (`lazerPriceMoveCalls`).
84
- export * as queueMoveCalls from '../contracts/deepbook_predict_orders/queue.js';
84
+ export * as queueMoveCalls from './bindings/queue.js';
85
85
  export * as deskMoveCalls from '../contracts/deepbook_predict_orders/desk.js';
86
86
  export * as orderQueueMoveCalls from '../contracts/deepbook_predict_orders/order_queue.js';
87
87
  export * as delayedExecutionConfigMoveCalls from '../contracts/deepbook_predict_orders/delayed_execution_config.js';
@@ -38,16 +38,20 @@ export const DELAYED_EXECUTION_VERSION = 4n;
38
38
  * Predict's `constants::current_version` of the package these bindings were generated from. Every
39
39
  * version-gated Predict call checks `chk_version`, which aborts `EPackageVersionDisabled` once
40
40
  * `ProtocolConfig.version_watermark` is above it, so a higher watermark retires the Predict code
41
- * this SDK calls. Bump it with Predict when regenerating.
41
+ * this SDK calls. Bump it with Predict when regenerating. Like `DELAYED_EXECUTION_VERSION` it is the
42
+ * code's version constant, which follows the Mainnet package number (5 ships as Mainnet v5 and runs
43
+ * as Testnet package v8), never the Testnet package number.
42
44
  */
43
- export const PREDICT_PACKAGE_VERSION = 4n;
45
+ export const PREDICT_PACKAGE_VERSION = 5n;
44
46
 
45
47
  /**
46
48
  * `desk::current_version` of the order-flow package these bindings were generated from. The desk's
47
49
  * version floor retires older companion code, so a floor above it means the package this SDK calls
48
- * aborts `EPackageVersionDisabled`. Bump it with the companion when regenerating.
50
+ * aborts `EPackageVersionDisabled`. Bump it with the companion when regenerating. It follows the
51
+ * Mainnet package number (2 ships as Mainnet v2 and runs as Testnet package v3), never the Testnet
52
+ * package number.
49
53
  */
50
- export const ORDER_FLOW_PACKAGE_VERSION = 1n;
54
+ export const ORDER_FLOW_PACKAGE_VERSION = 2n;
51
55
 
52
56
  /** `queue::phase_*`: what `settle_step` returns, the phase the next call runs. */
53
57
  export const SETTLE_PHASE = Object.freeze({
@@ -29,6 +29,7 @@ import { DelayedExecutionPolicy as DelayedExecutionPolicyBcs } from '../../contr
29
29
  import * as desk from '../../contracts/deepbook_predict_orders/desk.js';
30
30
  import { OrderView as OrderViewBcs } from '../../contracts/deepbook_predict_orders/order_queue.js';
31
31
  import * as queue from '../../contracts/deepbook_predict_orders/queue.js';
32
+ import { quoteRedeemOpen as quoteRedeemOpenCall } from '../bindings/queue.js';
32
33
  import { inspectReturns, type ReadClient } from './inspect.js';
33
34
  import { parseOptionalU64, parseU64LE } from './parse.js';
34
35
 
@@ -294,8 +295,9 @@ export async function versionWatermark(
294
295
  * `EDelayedExecutionRequired`.
295
296
  * - `'unsupported'`: the watermark is raised but this SDK's config has no delayed-execution
296
297
  * record for the network. Upgrade the SDK, or pass a config that records it.
297
- * - `'retired'`: the watermark is above the Predict code version this SDK calls
298
- * (`PREDICT_PACKAGE_VERSION`), so every version-gated call aborts `EPackageVersionDisabled`.
298
+ * - `'retired'`: the watermark is above the Predict code version the config calls
299
+ * (`packages.predictCurrentVersion`, else `PREDICT_PACKAGE_VERSION`), so every version-gated
300
+ * call aborts `EPackageVersionDisabled`.
299
301
  * Upgrade the SDK.
300
302
  */
301
303
  export type ExecutionMode =
@@ -312,10 +314,11 @@ export function executionModeFor(
312
314
  watermark: bigint,
313
315
  recordsDelayedExecution: boolean,
314
316
  recordsPredictUpgrade: boolean = recordsDelayedExecution,
317
+ predictCurrentVersion: bigint = PREDICT_PACKAGE_VERSION,
315
318
  ): ExecutionMode {
316
319
  if (watermark >= DELAYED_EXECUTION_VERSION) {
317
320
  if (!recordsDelayedExecution) return 'unsupported';
318
- return watermark > PREDICT_PACKAGE_VERSION ? 'retired' : 'delayed';
321
+ return watermark > predictCurrentVersion ? 'retired' : 'delayed';
319
322
  }
320
323
  return recordsDelayedExecution || recordsPredictUpgrade ? 'awaiting-cutover' : 'immediate';
321
324
  }
@@ -400,7 +403,7 @@ export async function quoteRedeemOpen(
400
403
  const tx = new Transaction();
401
404
  const pricer = tx.add(loadLivePricer(config, args));
402
405
  tx.add(
403
- queue.quoteRedeemOpen({
406
+ quoteRedeemOpenCall({
404
407
  config,
405
408
  arguments: {
406
409
  queue: queueIdOf(config, args),
@@ -15,6 +15,7 @@ export function accountContract(cfg: PredictConfig): AccountContract {
15
15
  return new AccountContract({
16
16
  accountPackageId: cfg.packages.account,
17
17
  accountRegistry: cfg.objects.accountRegistry,
18
+ accountPackageIdLatest: cfg.packages.accountLatest,
18
19
  });
19
20
  }
20
21
 
@@ -84,6 +85,7 @@ export function deriveAccountWrapperIdFrom(
84
85
  config: Pick<GeneratedConfig, 'accountRegistry' | 'accountPackageId'>,
85
86
  owner: string,
86
87
  ): string {
88
+ // The original ID: the key type's defining package, whatever account version runs.
87
89
  return new AccountContract({
88
90
  accountPackageId: config.accountPackageId,
89
91
  accountRegistry: config.accountRegistry,
@@ -5,12 +5,14 @@ import type { GeneratedConfig } from '../config/generated.js';
5
5
  import { U64_MAX } from '../units.js';
6
6
  import { accountMoveCalls as account } from '../../account.js';
7
7
  import * as expiryMarket from '../../contracts/deepbook_predict/expiry_market.js';
8
+ import * as expiryMarketBindings from '../bindings/expiry-market.js';
8
9
  import { withAuth } from './common.js';
9
10
 
10
11
  // The trade calls with their `auth` argument already supplied (see `withAuth`): each
11
12
  // takes its generated options minus that slot and expands to auth → call.
12
13
  const authed = {
13
- redeemSettled: withAuth(expiryMarket.redeemSettled),
14
+ // The shipped argument keys: Predict v5 underscore-prefixed the retired call's parameters.
15
+ redeemSettled: withAuth(expiryMarketBindings.redeemSettled),
14
16
  };
15
17
 
16
18
  // The oracle feed object ids a live market's pricer reads. Grouped so callers pass one
package/src/sessions.ts CHANGED
@@ -33,10 +33,19 @@ export interface SessionsConfig extends DeepbookSessionsConfig {
33
33
  sessionsPackageIdV1?: string;
34
34
  /** The shared `SessionsConfig` object id. */
35
35
  sessionsConfig: string;
36
- /** The shared `account` Move package id. */
36
+ /**
37
+ * The ORIGINAL shared `account` package id. The derived account and wrapper ids and the
38
+ * session data key's type are built from it, so it never moves to an upgraded package.
39
+ */
37
40
  accountPackageId: string;
38
41
  /** The shared `AccountRegistry` object id. */
39
42
  accountRegistry: string;
43
+ /**
44
+ * The latest `account` package once the network has upgraded it: the call target for any
45
+ * account call composed into the same PTB as these sessions calls, which link it. A PTB can't
46
+ * call account at an older version (`InvalidLinkage`). Absent while the network runs v1.
47
+ */
48
+ accountPackageIdLatest?: string;
40
49
  }
41
50
 
42
51
  /**
@@ -26,8 +26,9 @@ export const testnetPackageIds = {
26
26
  MARGIN_PACKAGE_ID: '0x0ad965f35189c7eca57d4718c8f5bf1b7f9f7eb4ced6d5b7aa6496a16d71e8d2',
27
27
  MARGIN_V1: '0xb8620c24c9ea1a4a41e79613d2b3d1d93648d1bb6f6b789a7c8f261c94110e4b',
28
28
  MARGIN_REGISTRY_ID: '0x48d7640dfae2c6e9ceeada197a7a1643984b5a24c55a0c6c023dac77e0339f75',
29
- // margin_liquidation v4 — carries liquidate_base_upgraded / liquidate_quote_upgraded.
30
- LIQUIDATION_PACKAGE_ID: '0x29bccec5261b7d040555a13e98bbc6bef7bad007d62759aac8b71c19916f6476',
29
+ // margin_liquidation v5, linked to core v21 and margin v17 — the same source as mainnet v6
30
+ // (legacy-Pyth liquidate_base / liquidate_quote retired; the builders call the _upgraded pair).
31
+ LIQUIDATION_PACKAGE_ID: '0x4f4916fc38892fe335a8aab45e3f42700060eb2d20f854607489ad88a88393a9',
31
32
  } satisfies DeepbookPackageIds;
32
33
 
33
34
  export const mainnetPackageIds = {
@@ -43,7 +44,11 @@ export const mainnetPackageIds = {
43
44
  MARGIN_PACKAGE_ID: '0x40fa183b5602cd0f6c4d7b16c08766ad8d7d581608fbe3b2570fe72ab4f5625f',
44
45
  MARGIN_V1: '0x97d9473771b01f77b0940c589484184b49f6444627ec121314fae6a6d36fb86b',
45
46
  MARGIN_REGISTRY_ID: '0x0e40998b359a9ccbab22a98ed21bd4346abf19158bc7980c8291908086b3a742',
46
- LIQUIDATION_PACKAGE_ID: '0xba2b39c026650fef52038c93c526fc5314a4286318a0d2a7054b65815178fb74',
47
+ // margin_liquidation v6, linked to core v9 and margin v8. Older versions link margin v7, so
48
+ // their liquidations abort once margin version 7 is disabled on the MarginRegistry. v6
49
+ // retires the legacy-Pyth liquidate_base / liquidate_quote; the builders here call the
50
+ // _upgraded pair.
51
+ LIQUIDATION_PACKAGE_ID: '0xd61f264aaf707285a712347fccfb8e905e99d7dc72a6bd1053829ddebf420c2b',
47
52
  } satisfies DeepbookPackageIds;
48
53
 
49
54
  /**