@mysten/deepbook-v3 2.4.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/contracts/account/account.d.mts +23 -23
  3. package/dist/contracts/account/account.d.mts.map +1 -1
  4. package/dist/contracts/account/account_events.d.mts +20 -20
  5. package/dist/contracts/account/account_events.d.mts.map +1 -1
  6. package/dist/contracts/account/account_registry.d.mts +19 -19
  7. package/dist/contracts/account/account_registry.d.mts.map +1 -1
  8. package/dist/contracts/deepbook/account.d.mts +18 -18
  9. package/dist/contracts/deepbook/balances.d.mts +4 -4
  10. package/dist/contracts/deepbook/deep_price.d.mts +3 -3
  11. package/dist/contracts/deepbook/order.d.mts +12 -12
  12. package/dist/contracts/deepbook_predict/admin.d.mts +4 -4
  13. package/dist/contracts/deepbook_predict/builder_code.d.mts +11 -11
  14. package/dist/contracts/deepbook_predict/builder_code_events.d.mts +10 -10
  15. package/dist/contracts/deepbook_predict/config_events.d.mts +67 -67
  16. package/dist/contracts/deepbook_predict/expiry_market.d.mts +95 -95
  17. package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts +5 -5
  18. package/dist/contracts/deepbook_predict/market_manager.d.mts +27 -27
  19. package/dist/contracts/deepbook_predict/market_manager.d.mts.map +1 -1
  20. package/dist/contracts/deepbook_predict/order_events.d.mts +50 -50
  21. package/dist/contracts/deepbook_predict/pause_cap.d.mts +5 -5
  22. package/dist/contracts/deepbook_predict/plp.d.mts +72 -72
  23. package/dist/contracts/deepbook_predict/plp.mjs +1 -1
  24. package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts +5 -5
  25. package/dist/contracts/deepbook_predict/predict_account.d.mts +14 -14
  26. package/dist/contracts/deepbook_predict/pricing.d.mts +92 -51
  27. package/dist/contracts/deepbook_predict/pricing.d.mts.map +1 -1
  28. package/dist/contracts/deepbook_predict/pricing.mjs +57 -7
  29. package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -1
  30. package/dist/contracts/deepbook_predict/protocol_config.d.mts +64 -64
  31. package/dist/contracts/deepbook_predict/range_codec.d.mts +2 -2
  32. package/dist/contracts/deepbook_predict/registry.d.mts +28 -28
  33. package/dist/contracts/deepbook_predict/strike_exposure.mjs +3 -2
  34. package/dist/contracts/deepbook_predict/strike_exposure.mjs.map +1 -1
  35. package/dist/contracts/deepbook_predict/vault_events.d.mts +105 -105
  36. package/dist/contracts/deepbook_sessions/session_config.d.mts +8 -8
  37. package/dist/contracts/deepbook_sessions/session_config.d.mts.map +1 -1
  38. package/dist/contracts/deepbook_sessions/sessions.d.mts +22 -22
  39. package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -1
  40. package/dist/deployments/mainnet.mjs +21 -21
  41. package/dist/deployments/mainnet.mjs.map +1 -1
  42. package/dist/deployments/testnet.mjs +21 -21
  43. package/dist/deployments/testnet.mjs.map +1 -1
  44. package/dist/predict/index.mjs +1 -1
  45. package/dist/predict/reads/markets.mjs +11 -3
  46. package/dist/predict/reads/markets.mjs.map +1 -1
  47. package/dist/predict/reads/pricing.mjs +1 -1
  48. package/dist/transactions/balanceManager.d.mts +12 -12
  49. package/dist/transactions/balanceManager.d.mts.map +1 -1
  50. package/dist/transactions/deepbook.d.mts +20 -20
  51. package/dist/transactions/deepbookAdmin.d.mts +4 -4
  52. package/dist/transactions/marginAdmin.d.mts +7 -7
  53. package/dist/transactions/marginLiquidations.d.mts +3 -3
  54. package/dist/transactions/marginMaintainer.d.mts +5 -5
  55. package/dist/transactions/marginManager.d.mts +32 -32
  56. package/dist/transactions/marginPool.d.mts +18 -18
  57. package/dist/transactions/marginPool.d.mts.map +1 -1
  58. package/dist/transactions/marginRegistry.d.mts +16 -16
  59. package/dist/transactions/marginTPSL.d.mts +10 -10
  60. package/dist/transactions/marginTPSL.d.mts.map +1 -1
  61. package/dist/transactions/poolProxy.d.mts +8 -8
  62. package/dist/transactions/poolProxy.d.mts.map +1 -1
  63. package/package.json +2 -2
  64. package/src/contracts/deepbook_predict/pricing.ts +88 -6
  65. package/src/contracts/deepbook_predict/strike_exposure.ts +3 -2
  66. package/src/contracts/propbook/block_scholes_store.ts +34 -0
  67. package/src/contracts/propbook/pyth_feed.ts +3 -1
  68. package/src/deployments/mainnet.ts +22 -22
  69. package/src/deployments/testnet.ts +22 -22
  70. package/src/predict/reads/markets.ts +16 -3
@@ -1,6 +1,6 @@
1
1
  import { MarginProposalParams, PlaceMarginLimitOrderParams, PlaceMarginMarketOrderParams } from "../types/index.mjs";
2
2
  import { DeepBookConfig } from "../utils/config.mjs";
3
- import * as _mysten_sui_transactions139 from "@mysten/sui/transactions";
3
+ import * as _mysten_sui_transactions90 from "@mysten/sui/transactions";
4
4
  import { Transaction } from "@mysten/sui/transactions";
5
5
 
6
6
  //#region src/transactions/poolProxy.d.ts
@@ -20,7 +20,7 @@ declare class PoolProxyContract {
20
20
  * @param {PlaceMarginLimitOrderParams} params Parameters for placing a limit order
21
21
  * @returns A function that takes a Transaction object
22
22
  */
23
- placeLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions139.TransactionResult;
23
+ placeLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
24
24
  /**
25
25
  * @description Place a market order. Enforces a post-trade `risk_ratio >=
26
26
  * min_borrow_risk_ratio` invariant on the manager (skipped when the manager
@@ -28,7 +28,7 @@ declare class PoolProxyContract {
28
28
  * @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order
29
29
  * @returns A function that takes a Transaction object
30
30
  */
31
- placeMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions139.TransactionResult;
31
+ placeMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
32
32
  /**
33
33
  * @description Place a reduce only limit order. Requires the manager to have
34
34
  * debt on the relevant side; enforces a monotonic `risk_ratio_after >=
@@ -37,7 +37,7 @@ declare class PoolProxyContract {
37
37
  * @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order
38
38
  * @returns A function that takes a Transaction object
39
39
  */
40
- placeReduceOnlyLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions139.TransactionResult;
40
+ placeReduceOnlyLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
41
41
  /**
42
42
  * @description Place a reduce only market order. Requires the manager to
43
43
  * have debt on the relevant side; enforces a monotonic `risk_ratio_after >=
@@ -46,7 +46,7 @@ declare class PoolProxyContract {
46
46
  * @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order
47
47
  * @returns A function that takes a Transaction object
48
48
  */
49
- placeReduceOnlyMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions139.TransactionResult;
49
+ placeReduceOnlyMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
50
50
  /**
51
51
  * @description Place a market order and repay the loan from the fill proceeds.
52
52
  * The taker fill settles into the manager's balance, so the proceeds (plus any
@@ -58,7 +58,7 @@ declare class PoolProxyContract {
58
58
  * @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order
59
59
  * @returns A function that takes a Transaction object
60
60
  */
61
- placeMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions139.TransactionResult;
61
+ placeMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
62
62
  /**
63
63
  * @description Place a reduce only limit order and repay the loan from the
64
64
  * fill proceeds. Requires debt on the relevant side (a bid needs base debt; an
@@ -68,7 +68,7 @@ declare class PoolProxyContract {
68
68
  * @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order
69
69
  * @returns A function that takes a Transaction object
70
70
  */
71
- placeReduceOnlyLimitOrderAndRepayLoan: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions139.TransactionResult;
71
+ placeReduceOnlyLimitOrderAndRepayLoan: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
72
72
  /**
73
73
  * @description Place a reduce only market order and repay the loan from the
74
74
  * fill proceeds. Same reduce-only direction guard as
@@ -78,7 +78,7 @@ declare class PoolProxyContract {
78
78
  * @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order
79
79
  * @returns A function that takes a Transaction object
80
80
  */
81
- placeReduceOnlyMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions139.TransactionResult;
81
+ placeReduceOnlyMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
82
82
  /**
83
83
  * @description Modify an existing order
84
84
  * @param {string} marginManagerKey The key to identify the MarginManager
@@ -1 +1 @@
1
- {"version":3,"file":"poolProxy.d.mts","names":[],"sources":["../../src/transactions/poolProxy.ts"],"mappings":";;;;;;;;;cAmBa,iBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAoBuD;;;;;;;EAA3E,eAAA,GAAmB,MAAA,EAAQ,2BAAA,MAAiC,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA0JC;;;;;;;EArG5E,gBAAA,GAAoB,MAAA,EAAQ,4BAAA,MAAkC,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAgQnE;;;;;;;;EAjNV,yBAAA,GAA6B,MAAA,EAAQ,2BAAA,MAAiC,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAsZxC;;;;;;;;EAhW7C,0BAAA,GAA8B,MAAA,EAAQ,4BAAA,MAAkC,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBA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A;EAxBiB;;;;;EA+CtE,sBAAA,GAA0B,gBAAA,cAA8B,EAAA,EAAI,WAAA;EAA5D;;;;;;EAwBA,KAAA,GAAS,gBAAA,UAA0B,WAAA,cAAyB,EAAA,EAAI,WAAA;EAAA;;;;;EA0BhE,OAAA,GAAW,gBAAA,cAA8B,EAAA,EAAI,WAAA;EAwB7C;;;;;;EAAA,cAAA,GACE,gBAAA,UAA0B,MAAA,EAAQ,oBAAA,MAA0B,EAAA,EAAI,WAAA;EA+B1D;;;;;;EAAR,IAAA,GAAQ,gBAAA,UAA0B,UAAA,cAAwB,EAAA,EAAI,WAAA;EAwBjB;;;;;EAA7C,WAAA,GAAe,gBAAA,cAA8B,EAAA,EAAI,WAAA;EA+CjD;;;;;;EAvBA,4BAAA,GACE,OAAA,UAAiB,eAAA,cAA6B,EAAA,EAAI,WAAA;;;;;;EAsBpD,kBAAA,GAAsB,OAAA,cAAqB,EAAA,EAAI,WAAA;AAAA"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@mysten/deepbook-v3",
3
3
  "author": "Mysten Labs <build@mystenlabs.com>",
4
4
  "description": "Sui Deepbook SDK",
5
- "version": "2.4.1",
5
+ "version": "2.5.0",
6
6
  "license": "Apache-2.0",
7
7
  "type": "module",
8
8
  "sideEffects": false,
@@ -65,7 +65,7 @@
65
65
  "wait-on": "^9.1.0"
66
66
  },
67
67
  "peerDependencies": {
68
- "@mysten/sui": "^2.31.0"
68
+ "@mysten/sui": "^2.31.1"
69
69
  },
70
70
  "scripts": {
71
71
  "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
@@ -7,10 +7,12 @@
7
7
  *
8
8
  * This module reads canonical Propbook Pyth and Block Scholes feeds and computes
9
9
  * SVI-adjusted digital probabilities. Live reads require fresh, pricing-safe Block
10
- * Scholes spot, forward, and SVI observations. The live forward comes from one of
11
- * two admin-selected sources (`PricingConfig.use_pyth_spot_for_forward`): a fresh
12
- * positive Pyth spot carrying the Block Scholes basis, or the Block Scholes
13
- * forward directly. Exact-history reads do not apply live freshness policy.
10
+ * Scholes spot, forward, and SVI observations. The latest forward is paired with
11
+ * an exact source-timestamp spot from Propbook's bounded recent history. The live
12
+ * forward comes from one of two admin-selected sources
13
+ * (`PricingConfig.use_pyth_spot_for_forward`): a fresh positive Pyth spot carrying
14
+ * the Block Scholes basis, or the Block Scholes forward directly. Exact-history
15
+ * reads do not apply live freshness policy.
14
16
  */
15
17
 
16
18
  import { MoveStruct, normalizeMoveArguments } from '../utils/index.js';
@@ -65,6 +67,13 @@ export const Pricer = new MoveStruct({
65
67
  block_scholes_svi_source_timestamp_ms: U64,
66
68
  },
67
69
  });
70
+ export const RangePrice = new MoveStruct({
71
+ name: `${$moduleName}::RangePrice`,
72
+ fields: {
73
+ lower_up: bcs.option(U64),
74
+ higher_up: bcs.option(U64),
75
+ },
76
+ });
68
77
  export const RawSVI = new MoveStruct({
69
78
  name: `${$moduleName}::RawSVI`,
70
79
  fields: {
@@ -118,8 +127,8 @@ export interface RangePriceOptions {
118
127
  };
119
128
  }
120
129
  /**
121
- * Return the current probability for `(lower, higher]`, floored at zero if the two
122
- * approximated boundary probabilities invert.
130
+ * Return both boundary probabilities for `(lower, higher]`. Use `probability()`
131
+ * for the combined range probability; absent boundaries are infinite sentinels.
123
132
  */
124
133
  export function rangePrice(options: RangePriceOptions) {
125
134
  const packageAddress =
@@ -134,3 +143,76 @@ export function rangePrice(options: RangePriceOptions) {
134
143
  arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
135
144
  });
136
145
  }
146
+ export interface LowerUpArguments {
147
+ price: TransactionArgument;
148
+ }
149
+ export interface LowerUpOptions {
150
+ package?: string;
151
+ arguments: LowerUpArguments | [price: TransactionArgument];
152
+ config?: {
153
+ predictPackageId?: string;
154
+ };
155
+ }
156
+ export function lowerUp(options: LowerUpOptions) {
157
+ const packageAddress =
158
+ options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
159
+ const argumentsTypes = [null] satisfies (string | null)[];
160
+ const parameterNames = ['price'];
161
+ return (tx: Transaction) =>
162
+ tx.moveCall({
163
+ package: packageAddress,
164
+ module: 'pricing',
165
+ function: 'lower_up',
166
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
167
+ });
168
+ }
169
+ export interface HigherUpArguments {
170
+ price: TransactionArgument;
171
+ }
172
+ export interface HigherUpOptions {
173
+ package?: string;
174
+ arguments: HigherUpArguments | [price: TransactionArgument];
175
+ config?: {
176
+ predictPackageId?: string;
177
+ };
178
+ }
179
+ export function higherUp(options: HigherUpOptions) {
180
+ const packageAddress =
181
+ options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
182
+ const argumentsTypes = [null] satisfies (string | null)[];
183
+ const parameterNames = ['price'];
184
+ return (tx: Transaction) =>
185
+ tx.moveCall({
186
+ package: packageAddress,
187
+ module: 'pricing',
188
+ function: 'higher_up',
189
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
190
+ });
191
+ }
192
+ export interface ProbabilityArguments {
193
+ price: TransactionArgument;
194
+ }
195
+ export interface ProbabilityOptions {
196
+ package?: string;
197
+ arguments: ProbabilityArguments | [price: TransactionArgument];
198
+ config?: {
199
+ predictPackageId?: string;
200
+ };
201
+ }
202
+ /**
203
+ * Return the combined probability, floored at zero if approximated boundary prices
204
+ * invert.
205
+ */
206
+ export function probability(options: ProbabilityOptions) {
207
+ const packageAddress =
208
+ options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
209
+ const argumentsTypes = [null] satisfies (string | null)[];
210
+ const parameterNames = ['price'];
211
+ return (tx: Transaction) =>
212
+ tx.moveCall({
213
+ package: packageAddress,
214
+ module: 'pricing',
215
+ function: 'probability',
216
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
217
+ });
218
+ }
@@ -18,6 +18,7 @@ import { bcs } from '@mysten/sui/bcs';
18
18
  import { U64 } from '../../bcs/integers.js';
19
19
  import * as strike_exposure_config from './strike_exposure_config.js';
20
20
  import * as strike_payout_tree from './strike_payout_tree.js';
21
+ import * as pricing from './pricing.js';
21
22
  import * as order from './order.js';
22
23
  const $moduleName = '@local-pkg/deepbook_predict::strike_exposure';
23
24
  export const StrikeExposure = new MoveStruct({
@@ -57,7 +58,7 @@ export const MintTerms = new MoveStruct({
57
58
  lower_tick: U64,
58
59
  higher_tick: U64,
59
60
  quantity: U64,
60
- entry_probability: U64,
61
+ price: pricing.RangePrice,
61
62
  premium: U64,
62
63
  /** Separate inventory-impact charge, sampled against the pre-mint book. */
63
64
  inventory_impact_charge: U64,
@@ -70,7 +71,7 @@ export const LiveCloseTerms = new MoveStruct({
70
71
  order: order.Order,
71
72
  close_quantity: U64,
72
73
  redeem_amount: U64,
73
- range_probability: U64,
74
+ price: pricing.RangePrice,
74
75
  /** Separate inventory-impact rebate, sampled against the pre-close book. */
75
76
  inventory_impact_rebate: U64,
76
77
  },
@@ -67,6 +67,10 @@ export const BlockScholesValueStore = new MoveStruct({
67
67
  * advances it forward-only after a package upgrade.
68
68
  */
69
69
  version: U64,
70
+ spot_reads: bcs.vector(BsRead(U128)),
71
+ /** Next slot to overwrite; also the next append position until the buffer fills. */
72
+ next_spot_write: U64,
73
+ /** Latest forward by canonical SID; spot observations live only in `spot_reads`. */
70
74
  values: table.Table,
71
75
  /** First positive `u64`-representable canonical spot at each exact minute boundary. */
72
76
  exact_spot_reads: table.Table,
@@ -339,6 +343,36 @@ export function spot(options: SpotOptions) {
339
343
  arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
340
344
  });
341
345
  }
346
+ export interface RecentSpotAtArguments {
347
+ store: RawTransactionArgument<string>;
348
+ sourceTimestampMs: RawTransactionArgument<number | bigint>;
349
+ }
350
+ export interface RecentSpotAtOptions {
351
+ package?: string;
352
+ arguments:
353
+ | RecentSpotAtArguments
354
+ | [
355
+ store: RawTransactionArgument<string>,
356
+ sourceTimestampMs: RawTransactionArgument<number | bigint>,
357
+ ];
358
+ }
359
+ /**
360
+ * Returns an exact source-time match from the ten recent spot observations for
361
+ * live pricing. This bounded buffer is independent of the permanent
362
+ * minute-boundary settlement history.
363
+ */
364
+ export function recentSpotAt(options: RecentSpotAtOptions) {
365
+ const packageAddress = options.package ?? '@local-pkg/propbook';
366
+ const argumentsTypes = [null, 'u64'] satisfies (string | null)[];
367
+ const parameterNames = ['store', 'sourceTimestampMs'];
368
+ return (tx: Transaction) =>
369
+ tx.moveCall({
370
+ package: packageAddress,
371
+ module: 'block_scholes_store',
372
+ function: 'recent_spot_at',
373
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
374
+ });
375
+ }
342
376
  export interface SpotAtArguments {
343
377
  store: RawTransactionArgument<string>;
344
378
  sourceTimestampMs: RawTransactionArgument<number | bigint>;
@@ -15,7 +15,9 @@
15
15
  * time so a carried price ages by its true age, while the exact-history key stays
16
16
  * on the envelope so a settlement tick resolves to the canonical price as of that
17
17
  * tick. This module normalizes positive prices to 1e9 scale but leaves freshness
18
- * and market-use policy to consumers.
18
+ * and market-use policy to consumers. Both deployed Pyth lineages support this
19
+ * Update type. The legacy Testnet package has no update_v2, so retain the common
20
+ * ABI when linking Mainnet v2.
19
21
  */
20
22
 
21
23
  import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
@@ -8,7 +8,7 @@
8
8
  // checkout out to the new anchor and re-run the script.
9
9
  //
10
10
  // Deployment: deepbook-predict-mainnet
11
- // sourceCommit: 14a7e8f822e0397df2d61fbfbce3ef21086891c2
11
+ // sourceCommit: 7b169bde2c2a25fee3ac9aa4686e346309bfe570
12
12
  //
13
13
  // Runtime-dependency-free — every subpath reads a slice of this, so a value import here
14
14
  // would pull that module into all of their graphs. The type import below is erased.
@@ -29,13 +29,13 @@ export const MAINNET_DEPLOYMENT: DeploymentInfo = Object.freeze({
29
29
  deployment: 'deepbook-predict-mainnet',
30
30
  network: 'mainnet',
31
31
  chainId: '35834a8a',
32
- sourceCommit: '14a7e8f822e0397df2d61fbfbce3ef21086891c2',
32
+ sourceCommit: '7b169bde2c2a25fee3ac9aa4686e346309bfe570',
33
33
  });
34
34
 
35
35
  /** Ids for the shared `account` primitive — the `/account` subpath's slice. */
36
36
  export const MAINNET_ACCOUNT: AccountIds = Object.freeze({
37
- accountPackageId: '0xa6f1b22aaeb429f6fd8f01c13f605256e00876457fd122da8a0e2c1045c75929',
38
- accountRegistry: '0x210ba485d973b5356e9078318837137efabdd5ffb9eeb3705ba7eef3340324fc',
37
+ accountPackageId: '0x4e1dd01465713c9d832313fed5f45c222a4d5c62a533d6da96764c8b2a245d58',
38
+ accountRegistry: '0x8c52c6f5b2374e33f4a726d9c32337b1aee3a71410d41c18faa91d938d66e4bc',
39
39
  });
40
40
 
41
41
  /**
@@ -46,15 +46,15 @@ export const MAINNET_ACCOUNT: AccountIds = Object.freeze({
46
46
  * the package root for one id.
47
47
  */
48
48
  export const MAINNET_SESSIONS: SessionsIds = Object.freeze({
49
- sessionsPackageId: '0xebfa125baee571c1f8c903c1dd54a5bc57949db82469b836c32eca251756c82a',
50
- sessionsConfig: '0x0c5f64365b3bf1f67827d6975893190079cc048247f9ff0b08390aa9ee697c5c',
51
- accountPackageId: '0xa6f1b22aaeb429f6fd8f01c13f605256e00876457fd122da8a0e2c1045c75929',
52
- accountRegistry: '0x210ba485d973b5356e9078318837137efabdd5ffb9eeb3705ba7eef3340324fc',
49
+ sessionsPackageId: '0x9a068beffa019ae756f4a6d2611e9899d3c6dd888812dd9eca87535d2ac55e2a',
50
+ sessionsConfig: '0xb2fba483748aac7508676020d4e691d68239b66f8bf7c5e7634dd1a76a329317',
51
+ accountPackageId: '0x4e1dd01465713c9d832313fed5f45c222a4d5c62a533d6da96764c8b2a245d58',
52
+ accountRegistry: '0x8c52c6f5b2374e33f4a726d9c32337b1aee3a71410d41c18faa91d938d66e4bc',
53
53
  deepbookRegistry: '0xaf16199a2dff736e9f07a845f23c5da6df6f756eddb631aed9d24a93efc4549d',
54
54
  deepbookCoreAccountPackageId:
55
- '0xebcd5b403ee78021e3f78d1c77e2117a676caa8a9754dedb99e7b102b0d81872',
55
+ '0xd71b5a341dc8dc7e187517849edf61e54670b60fe496e07186c09a65fa7afdb7',
56
56
  /** Required by every Predict session wrapper — they all take `config: &ProtocolConfig`. */
57
- protocolConfig: '0x55e8800bcb31b792683ca4385bd533716e2a9721364236a69ee2c3bee61dd8f2',
57
+ protocolConfig: '0x5fa6efbe7691809565a660adde23f0c184ca1d19cefafa4e1c88d655fe279580',
58
58
  });
59
59
 
60
60
  /**
@@ -73,16 +73,16 @@ export const MAINNET_UNITS: DeploymentUnits = Object.freeze({
73
73
  export const MAINNET_PREDICT: PredictIds = Object.freeze({
74
74
  network: 'mainnet',
75
75
  packages: Object.freeze({
76
- predict: '0x774f9555865a7b96e31ec982f62d5bdf9d74bf57a6468b5ed41340c231afd7df',
77
- account: '0xa6f1b22aaeb429f6fd8f01c13f605256e00876457fd122da8a0e2c1045c75929',
78
- propbook: '0x2a63e378ab0138cdcb12651a093f3799f8b8e4f6c927ce6de0e8bc7ded0ec49d',
76
+ predict: '0x89aea622e7bb3bdd598bde87dde40ee31c9eed4971b9546e23ec83de3c48bbba',
77
+ account: '0x4e1dd01465713c9d832313fed5f45c222a4d5c62a533d6da96764c8b2a245d58',
78
+ propbook: '0xa6c8f32015b5b41d34ee09995a2e9d7a21cdecf0e1910a50b264fd252cd33831',
79
79
  }),
80
80
  objects: Object.freeze({
81
- registry: '0xc98e430d82bed9f777288061faa1988da705a97db7f0da9f215ab372c53a2362',
82
- protocolConfig: '0x55e8800bcb31b792683ca4385bd533716e2a9721364236a69ee2c3bee61dd8f2',
83
- poolVault: '0x3f80653bf9324162254d89724276aae7b36ba7c83d4650214afbf266da98f492',
84
- oracleRegistry: '0x1ff67a8499b0af7c0fbb26ba82c319be25413af93d9a961ee60f8d1229e7de7c',
85
- accountRegistry: '0x210ba485d973b5356e9078318837137efabdd5ffb9eeb3705ba7eef3340324fc',
81
+ registry: '0x94327dbc256a2cfabd164c2bf4b3fe033bfaa4771f7a6f716954e07cb1b4beba',
82
+ protocolConfig: '0x5fa6efbe7691809565a660adde23f0c184ca1d19cefafa4e1c88d655fe279580',
83
+ poolVault: '0x4d227a1baf8cfcaf6e652a9182d0e63f85f9ce82cd542fdf3356bb3581be3b99',
84
+ oracleRegistry: '0x5d62c0d9be43efa769a708ade53fbe5bea98c15c865b64ca7c498c87b045a698',
85
+ accountRegistry: '0x8c52c6f5b2374e33f4a726d9c32337b1aee3a71410d41c18faa91d938d66e4bc',
86
86
  }),
87
87
  quoteCoinType: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC',
88
88
  /**
@@ -91,7 +91,7 @@ export const MAINNET_PREDICT: PredictIds = Object.freeze({
91
91
  * moves to the latest. They agree only while predict is at v1.
92
92
  */
93
93
  coinTypes: Object.freeze({
94
- plp: '0x774f9555865a7b96e31ec982f62d5bdf9d74bf57a6468b5ed41340c231afd7df::plp::PLP',
94
+ plp: '0x89aea622e7bb3bdd598bde87dde40ee31c9eed4971b9546e23ec83de3c48bbba::plp::PLP',
95
95
  deep: '0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP',
96
96
  }),
97
97
  units: MAINNET_UNITS,
@@ -99,9 +99,9 @@ export const MAINNET_PREDICT: PredictIds = Object.freeze({
99
99
  BTC: Object.freeze({
100
100
  symbol: 'BTC',
101
101
  propbookUnderlyingId: 1,
102
- pythFeed: '0x44bd2e00549973bb6a58785836e97ed80b4979e67dc3bf312c997e56053e5376',
103
- blockScholesValueStore: '0xe7c83ee4ac0c300d68d8d4c3d265d78287b4767dcbc5f279cd6f210b6248d493',
104
- blockScholesSviStore: '0x8e5568aebf490c2adfd4e010a9b4ddcf7c774183f58c98fcd438bae1fc68f561',
102
+ pythFeed: '0x4c5d2b4c8238f04b7687c3a8df915b69c50d5f4d291fc49aea44bdb6b52e1a20',
103
+ blockScholesValueStore: '0xe83f843b15ae63045b2cea445fb8ea7ad85c5fc2a05f66db122a511e1f2c67bc',
104
+ blockScholesSviStore: '0xfdd447be39d847747caf18ecf3355031bb33979c472581f1a5481375d3748bfb',
105
105
  }),
106
106
  }),
107
107
  });
@@ -8,7 +8,7 @@
8
8
  // checkout out to the new anchor and re-run the script.
9
9
  //
10
10
  // Deployment: deepbook-predict-testnet
11
- // sourceCommit: a928bd2da4b71abf7c4ea6f66abec2763308331e
11
+ // sourceCommit: 4d752fb82d909a821c85bcc5d3963725efb546f4
12
12
  //
13
13
  // Runtime-dependency-free — every subpath reads a slice of this, so a value import here
14
14
  // would pull that module into all of their graphs. The type import below is erased.
@@ -29,13 +29,13 @@ export const TESTNET_DEPLOYMENT: DeploymentInfo = Object.freeze({
29
29
  deployment: 'deepbook-predict-testnet',
30
30
  network: 'testnet',
31
31
  chainId: '4c78adac',
32
- sourceCommit: 'a928bd2da4b71abf7c4ea6f66abec2763308331e',
32
+ sourceCommit: '4d752fb82d909a821c85bcc5d3963725efb546f4',
33
33
  });
34
34
 
35
35
  /** Ids for the shared `account` primitive — the `/account` subpath's slice. */
36
36
  export const TESTNET_ACCOUNT: AccountIds = Object.freeze({
37
- accountPackageId: '0x543139156cb90d1a73df33b5dca37d7c8bdce62506c7874ebc854afd319b98f1',
38
- accountRegistry: '0xb889caefe327cbdea58e529e3b9e10dc93f1e661ddef32824d28527edf8d6385',
37
+ accountPackageId: '0x1e57d6554b99e4ca68330322c3e5c409ba1b681642726b603bf1be92c1840ca9',
38
+ accountRegistry: '0x511e11f7f5d5c1043d795180657603d59e06e90fbfcafd3f90c67ff0836bbd0c',
39
39
  });
40
40
 
41
41
  /**
@@ -46,15 +46,15 @@ export const TESTNET_ACCOUNT: AccountIds = Object.freeze({
46
46
  * the package root for one id.
47
47
  */
48
48
  export const TESTNET_SESSIONS: SessionsIds = Object.freeze({
49
- sessionsPackageId: '0x10c91d168dc4a04357f9d23795a204092ca46e5b97f8b9ef26fea95664d5bb38',
50
- sessionsConfig: '0x63cde7c7d846f15c51802ec3d44ba44918658e3155b0d2e0cb26d6fc1b4dadd8',
51
- accountPackageId: '0x543139156cb90d1a73df33b5dca37d7c8bdce62506c7874ebc854afd319b98f1',
52
- accountRegistry: '0xb889caefe327cbdea58e529e3b9e10dc93f1e661ddef32824d28527edf8d6385',
49
+ sessionsPackageId: '0x1908eee49d7a08d74a537d7f23766b363a145517fe0d3e0d85635d1682831ffd',
50
+ sessionsConfig: '0xc096b97289821b27badfdf758d614bbbfa386f93d3faa409ecc1fcc6075d1186',
51
+ accountPackageId: '0x1e57d6554b99e4ca68330322c3e5c409ba1b681642726b603bf1be92c1840ca9',
52
+ accountRegistry: '0x511e11f7f5d5c1043d795180657603d59e06e90fbfcafd3f90c67ff0836bbd0c',
53
53
  deepbookRegistry: '0x7c256edbda983a2cd6f946655f4bf3f00a41043993781f8674a7046e8c0e11d1',
54
54
  deepbookCoreAccountPackageId:
55
- '0x2dbb8e6a5b9a8ac6201c7aeff6de0c7e7bca5dcd8d6c16538cb1a7447a298071',
55
+ '0x2a3a5f51e1c566e0a77c667596a8212d036b44aeac32790991c9eb97580fabb1',
56
56
  /** Required by every Predict session wrapper — they all take `config: &ProtocolConfig`. */
57
- protocolConfig: '0xfeda745dfdef2cd9721c2ff1e1de538d103bc6012469d0eec10ea5de67f636d0',
57
+ protocolConfig: '0x422a45c31128e69d0310ab3bed28bd14f730acf9f5681f70936d20c60d26bfb0',
58
58
  });
59
59
 
60
60
  /**
@@ -73,16 +73,16 @@ export const TESTNET_UNITS: DeploymentUnits = Object.freeze({
73
73
  export const TESTNET_PREDICT: PredictIds = Object.freeze({
74
74
  network: 'testnet',
75
75
  packages: Object.freeze({
76
- predict: '0x25d075d2de915feda7ab9b8f855afe59cbcd4b2ce96f75324940c810f84da018',
77
- account: '0x543139156cb90d1a73df33b5dca37d7c8bdce62506c7874ebc854afd319b98f1',
78
- propbook: '0xa04a43dbbfb123feec96691a22809d8a87e9ac37ae9356079c439750145aa92b',
76
+ predict: '0x59d71119e990573a738dd3ff9c4c7d28d6893af69c87c1a7f3a2e90e280ce2f4',
77
+ account: '0x1e57d6554b99e4ca68330322c3e5c409ba1b681642726b603bf1be92c1840ca9',
78
+ propbook: '0xa83f9d7651de09672a40cea371c387bf954e0f3092947670d71428d4fbc9edd9',
79
79
  }),
80
80
  objects: Object.freeze({
81
- registry: '0xd21fab5444128eb65c5f6299564f583db72ad84d17581a4febe68878127100d5',
82
- protocolConfig: '0xfeda745dfdef2cd9721c2ff1e1de538d103bc6012469d0eec10ea5de67f636d0',
83
- poolVault: '0xd6b96a77d5acfd4f4a660cbd1098ed62abf2317e85a01274d1a4eeef19603767',
84
- oracleRegistry: '0xda71af88a8b9d01b6913937a84c5a63bb4e1015a7a2142185ec9ef73f675615f',
85
- accountRegistry: '0xb889caefe327cbdea58e529e3b9e10dc93f1e661ddef32824d28527edf8d6385',
81
+ registry: '0x85cfaa857f9dfca75f6ba624eead063c4a1bc9b701201b8f21e1f9c15833ccc4',
82
+ protocolConfig: '0x422a45c31128e69d0310ab3bed28bd14f730acf9f5681f70936d20c60d26bfb0',
83
+ poolVault: '0x6fd178a49848387d60ccfd3e53bf06969929970246a3a7983ae5bb2a5ed52ee3',
84
+ oracleRegistry: '0xf4ad65184b2e4e9d8e50d44b02a76c64e9607f63e3dbc362e110c99e20a17161',
85
+ accountRegistry: '0x511e11f7f5d5c1043d795180657603d59e06e90fbfcafd3f90c67ff0836bbd0c',
86
86
  }),
87
87
  quoteCoinType: '0xc028557a1ed49e42ed091e115aedefd70a442b184c18fbec5c48d5b6c0b8c184::usdc::USDC',
88
88
  /**
@@ -91,7 +91,7 @@ export const TESTNET_PREDICT: PredictIds = Object.freeze({
91
91
  * moves to the latest. They agree only while predict is at v1.
92
92
  */
93
93
  coinTypes: Object.freeze({
94
- plp: '0x25d075d2de915feda7ab9b8f855afe59cbcd4b2ce96f75324940c810f84da018::plp::PLP',
94
+ plp: '0x59d71119e990573a738dd3ff9c4c7d28d6893af69c87c1a7f3a2e90e280ce2f4::plp::PLP',
95
95
  deep: '0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP',
96
96
  }),
97
97
  units: TESTNET_UNITS,
@@ -99,9 +99,9 @@ export const TESTNET_PREDICT: PredictIds = Object.freeze({
99
99
  BTC: Object.freeze({
100
100
  symbol: 'BTC',
101
101
  propbookUnderlyingId: 1,
102
- pythFeed: '0x7179188b3a27758c53668a4ec09a81be114dea5ffabcf367f4e720a26db8ee59',
103
- blockScholesValueStore: '0x77dee47fb870753c740439f436e0c30c00c60f13f171c901125b3d60f89518e5',
104
- blockScholesSviStore: '0xe8aa80965d201e2cb18359c3aa315e3abc5bbf807a10a59d6e011ef41be5db7a',
102
+ pythFeed: '0x8ef99c3d14e57612d09a67bcc9b5bff568a80992df6beca2bfcd922973192faa',
103
+ blockScholesValueStore: '0x1e5142471311505a7428b072230c9ffe8a747b3b9392720e39246af4aea08216',
104
+ blockScholesSviStore: '0x0f1cbefd1dd2ba08ae700a7067c32e0718edf926fa18cea80bd231c02d509ece',
105
105
  }),
106
106
  }),
107
107
  });
@@ -123,6 +123,12 @@ export async function marketStates(
123
123
  // POS_INF_TICK → +inf, and any finite tick → tick*tick_size. `range_price` is a
124
124
  // public fun on the deployed package. Both sides read the SAME pricer in one PTB, so
125
125
  // `down` is the chain's number, not 1 − up.
126
+ //
127
+ // `range_price` now returns a `RangePrice` carrying both boundary probabilities so the
128
+ // fee can charge each leg separately; `probability()` is the combined range number this
129
+ // function has always returned (`lower_up.saturating_sub(higher_up)`, unchanged). The
130
+ // extra call per side is what keeps the u64 parse below reading a u64 rather than the
131
+ // struct's BCS.
126
132
  export async function rangePrices(
127
133
  client: ReadClient,
128
134
  config: GeneratedConfig,
@@ -141,9 +147,16 @@ export async function rangePrices(
141
147
  const strike = mkStrike(strikeTick);
142
148
  const posInf = mkStrike(POS_INF_TICK);
143
149
  const negInf = mkStrike(0n);
144
- // UP: (strike, +inf], then DOWN: (-inf, strike] the last two commands.
145
- tx.add(pricing.rangePrice({ config, arguments: { pricer, lower: strike, higher: posInf } }));
146
- tx.add(pricing.rangePrice({ config, arguments: { pricer, lower: negInf, higher: strike } }));
150
+ // UP: (strike, +inf], then DOWN: (-inf, strike]. The two `probability` reductions are
151
+ // the last two commands, which is what the tail-relative parse below indexes.
152
+ const up = tx.add(
153
+ pricing.rangePrice({ config, arguments: { pricer, lower: strike, higher: posInf } }),
154
+ );
155
+ const down = tx.add(
156
+ pricing.rangePrice({ config, arguments: { pricer, lower: negInf, higher: strike } }),
157
+ );
158
+ tx.add(pricing.probability({ config, arguments: { price: up } }));
159
+ tx.add(pricing.probability({ config, arguments: { price: down } }));
147
160
  const cmds = await inspectReturns(client, tx);
148
161
  return {
149
162
  upRaw: parseU64LE(cmds[cmds.length - 2][0]),