@mysten/deepbook-v3 2.1.4 → 2.4.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 (193) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/PREDICT.md +154 -48
  3. package/README.md +18 -13
  4. package/dist/account.d.mts.map +1 -1
  5. package/dist/account.mjs +3 -1
  6. package/dist/account.mjs.map +1 -1
  7. package/dist/client.d.mts +2 -2
  8. package/dist/contracts/account/account.d.mts +23 -23
  9. package/dist/contracts/account/account.d.mts.map +1 -1
  10. package/dist/contracts/account/account_events.d.mts +20 -20
  11. package/dist/contracts/account/account_registry.d.mts +19 -19
  12. package/dist/contracts/deepbook/account.d.mts +18 -18
  13. package/dist/contracts/deepbook/account.d.mts.map +1 -1
  14. package/dist/contracts/deepbook/balances.d.mts +4 -4
  15. package/dist/contracts/deepbook/balances.d.mts.map +1 -1
  16. package/dist/contracts/deepbook/deep_price.d.mts +3 -3
  17. package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
  18. package/dist/contracts/deepbook/order.d.mts +12 -12
  19. package/dist/contracts/deepbook_predict/admin.d.mts +27 -0
  20. package/dist/contracts/deepbook_predict/admin.d.mts.map +1 -0
  21. package/dist/contracts/deepbook_predict/admin.mjs +38 -0
  22. package/dist/contracts/deepbook_predict/admin.mjs.map +1 -0
  23. package/dist/contracts/deepbook_predict/builder_code.d.mts +81 -0
  24. package/dist/contracts/deepbook_predict/builder_code.d.mts.map +1 -0
  25. package/dist/contracts/deepbook_predict/builder_code.mjs +103 -0
  26. package/dist/contracts/deepbook_predict/builder_code.mjs.map +1 -0
  27. package/dist/contracts/deepbook_predict/builder_code_events.d.mts +25 -0
  28. package/dist/contracts/deepbook_predict/builder_code_events.d.mts.map +1 -0
  29. package/dist/contracts/deepbook_predict/builder_code_events.mjs +7 -1
  30. package/dist/contracts/deepbook_predict/builder_code_events.mjs.map +1 -1
  31. package/dist/contracts/deepbook_predict/config_events.d.mts +104 -0
  32. package/dist/contracts/deepbook_predict/config_events.d.mts.map +1 -0
  33. package/dist/contracts/deepbook_predict/config_events.mjs +155 -0
  34. package/dist/contracts/deepbook_predict/config_events.mjs.map +1 -0
  35. package/dist/contracts/deepbook_predict/deps/sui/vec_map.mjs +37 -0
  36. package/dist/contracts/deepbook_predict/deps/sui/vec_map.mjs.map +1 -0
  37. package/dist/contracts/deepbook_predict/ewma_config.mjs +28 -0
  38. package/dist/contracts/deepbook_predict/ewma_config.mjs.map +1 -0
  39. package/dist/contracts/deepbook_predict/expiry_cash.mjs +1 -1
  40. package/dist/contracts/deepbook_predict/expiry_cash.mjs.map +1 -1
  41. package/dist/contracts/deepbook_predict/expiry_market.d.mts +859 -0
  42. package/dist/contracts/deepbook_predict/expiry_market.d.mts.map +1 -0
  43. package/dist/contracts/deepbook_predict/expiry_market.mjs +662 -7
  44. package/dist/contracts/deepbook_predict/expiry_market.mjs.map +1 -1
  45. package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts +39 -0
  46. package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts.map +1 -0
  47. package/dist/contracts/deepbook_predict/market_lifecycle_cap.mjs +51 -0
  48. package/dist/contracts/deepbook_predict/market_lifecycle_cap.mjs.map +1 -0
  49. package/dist/contracts/deepbook_predict/market_manager.d.mts +159 -0
  50. package/dist/contracts/deepbook_predict/market_manager.d.mts.map +1 -0
  51. package/dist/contracts/deepbook_predict/market_manager.mjs +88 -2
  52. package/dist/contracts/deepbook_predict/market_manager.mjs.map +1 -1
  53. package/dist/contracts/deepbook_predict/order_events.d.mts +101 -0
  54. package/dist/contracts/deepbook_predict/order_events.d.mts.map +1 -0
  55. package/dist/contracts/deepbook_predict/order_events.mjs +7 -1
  56. package/dist/contracts/deepbook_predict/order_events.mjs.map +1 -1
  57. package/dist/contracts/deepbook_predict/pause_cap.d.mts +39 -0
  58. package/dist/contracts/deepbook_predict/pause_cap.d.mts.map +1 -0
  59. package/dist/contracts/deepbook_predict/pause_cap.mjs +51 -0
  60. package/dist/contracts/deepbook_predict/pause_cap.mjs.map +1 -0
  61. package/dist/contracts/deepbook_predict/plp.d.mts +801 -0
  62. package/dist/contracts/deepbook_predict/plp.d.mts.map +1 -0
  63. package/dist/contracts/deepbook_predict/plp.mjs +511 -32
  64. package/dist/contracts/deepbook_predict/plp.mjs.map +1 -1
  65. package/dist/contracts/deepbook_predict/pool_accounting.mjs +7 -7
  66. package/dist/contracts/deepbook_predict/pool_accounting.mjs.map +1 -1
  67. package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts +39 -0
  68. package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts.map +1 -0
  69. package/dist/contracts/deepbook_predict/pool_valuation_cap.mjs +52 -0
  70. package/dist/contracts/deepbook_predict/pool_valuation_cap.mjs.map +1 -0
  71. package/dist/contracts/deepbook_predict/predict_account.d.mts +90 -0
  72. package/dist/contracts/deepbook_predict/predict_account.d.mts.map +1 -0
  73. package/dist/contracts/deepbook_predict/predict_account.mjs +25 -2
  74. package/dist/contracts/deepbook_predict/predict_account.mjs.map +1 -1
  75. package/dist/contracts/deepbook_predict/pricing.d.mts +127 -0
  76. package/dist/contracts/deepbook_predict/pricing.d.mts.map +1 -0
  77. package/dist/contracts/deepbook_predict/pricing.mjs +37 -1
  78. package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -1
  79. package/dist/contracts/deepbook_predict/pricing_config.mjs +28 -0
  80. package/dist/contracts/deepbook_predict/pricing_config.mjs.map +1 -0
  81. package/dist/contracts/deepbook_predict/protocol_config.d.mts +665 -0
  82. package/dist/contracts/deepbook_predict/protocol_config.d.mts.map +1 -0
  83. package/dist/contracts/deepbook_predict/protocol_config.mjs +841 -0
  84. package/dist/contracts/deepbook_predict/protocol_config.mjs.map +1 -0
  85. package/dist/contracts/deepbook_predict/range_codec.d.mts +30 -0
  86. package/dist/contracts/deepbook_predict/range_codec.d.mts.map +1 -0
  87. package/dist/contracts/deepbook_predict/range_codec.mjs +6 -1
  88. package/dist/contracts/deepbook_predict/range_codec.mjs.map +1 -1
  89. package/dist/contracts/deepbook_predict/registry.d.mts +382 -0
  90. package/dist/contracts/deepbook_predict/registry.d.mts.map +1 -0
  91. package/dist/contracts/deepbook_predict/registry.mjs +458 -2
  92. package/dist/contracts/deepbook_predict/registry.mjs.map +1 -1
  93. package/dist/contracts/deepbook_predict/strike_exposure.mjs.map +1 -1
  94. package/dist/contracts/deepbook_predict/strike_payout_tree.mjs +13 -1
  95. package/dist/contracts/deepbook_predict/strike_payout_tree.mjs.map +1 -1
  96. package/dist/contracts/deepbook_predict/vault_events.d.mts +199 -0
  97. package/dist/contracts/deepbook_predict/vault_events.d.mts.map +1 -0
  98. package/dist/contracts/deepbook_predict/vault_events.mjs +38 -8
  99. package/dist/contracts/deepbook_predict/vault_events.mjs.map +1 -1
  100. package/dist/contracts/deepbook_sessions/session_config.d.mts +8 -8
  101. package/dist/contracts/deepbook_sessions/session_config.d.mts.map +1 -1
  102. package/dist/contracts/deepbook_sessions/sessions.d.mts +22 -22
  103. package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -1
  104. package/dist/deployments/index.d.mts +3 -2
  105. package/dist/deployments/index.d.mts.map +1 -1
  106. package/dist/deployments/index.mjs +4 -1
  107. package/dist/deployments/index.mjs.map +1 -1
  108. package/dist/deployments/mainnet.d.mts +14 -0
  109. package/dist/deployments/mainnet.d.mts.map +1 -0
  110. package/dist/deployments/mainnet.mjs +73 -0
  111. package/dist/deployments/mainnet.mjs.map +1 -0
  112. package/dist/deployments/testnet.mjs +23 -23
  113. package/dist/deployments/testnet.mjs.map +1 -1
  114. package/dist/deployments/types.d.mts +1 -1
  115. package/dist/predict/client.d.mts +28 -6
  116. package/dist/predict/client.d.mts.map +1 -1
  117. package/dist/predict/client.mjs +7 -6
  118. package/dist/predict/client.mjs.map +1 -1
  119. package/dist/predict/config/index.d.mts +2 -0
  120. package/dist/predict/config/index.d.mts.map +1 -1
  121. package/dist/predict/config/index.mjs +4 -1
  122. package/dist/predict/config/index.mjs.map +1 -1
  123. package/dist/predict/config/mainnet.d.mts +17 -0
  124. package/dist/predict/config/mainnet.d.mts.map +1 -0
  125. package/dist/predict/config/mainnet.mjs +26 -0
  126. package/dist/predict/config/mainnet.mjs.map +1 -0
  127. package/dist/predict/config/types.d.mts +6 -0
  128. package/dist/predict/config/types.d.mts.map +1 -1
  129. package/dist/predict/index.d.mts +21 -2
  130. package/dist/predict/index.mjs +20 -1
  131. package/dist/predict/pricing.d.mts +6 -6
  132. package/dist/predict/pricing.d.mts.map +1 -1
  133. package/dist/predict/pricing.mjs +6 -6
  134. package/dist/predict/pricing.mjs.map +1 -1
  135. package/dist/predict/reads/balances.mjs.map +1 -1
  136. package/dist/predict/reads/markets.mjs +1 -1
  137. package/dist/predict/reads/markets.mjs.map +1 -1
  138. package/dist/predict/reads/pricing.d.mts +2 -1
  139. package/dist/predict/reads/pricing.d.mts.map +1 -1
  140. package/dist/predict/reads/pricing.mjs.map +1 -1
  141. package/dist/sessions.d.mts.map +1 -1
  142. package/dist/sessions.mjs +3 -1
  143. package/dist/sessions.mjs.map +1 -1
  144. package/dist/transactions/balanceManager.d.mts +12 -12
  145. package/dist/transactions/balanceManager.d.mts.map +1 -1
  146. package/dist/transactions/deepbook.d.mts +20 -20
  147. package/dist/transactions/deepbook.d.mts.map +1 -1
  148. package/dist/transactions/deepbookAdmin.d.mts +4 -4
  149. package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
  150. package/dist/transactions/marginAdmin.d.mts +7 -7
  151. package/dist/transactions/marginLiquidations.d.mts +3 -3
  152. package/dist/transactions/marginMaintainer.d.mts +5 -5
  153. package/dist/transactions/marginManager.d.mts +32 -32
  154. package/dist/transactions/marginPool.d.mts +18 -18
  155. package/dist/transactions/marginPool.d.mts.map +1 -1
  156. package/dist/transactions/marginRegistry.d.mts +16 -16
  157. package/dist/transactions/marginTPSL.d.mts +10 -10
  158. package/dist/transactions/poolProxy.d.mts +8 -8
  159. package/package.json +3 -3
  160. package/src/account.ts +3 -1
  161. package/src/contracts/deepbook_predict/builder_code.ts +3 -3
  162. package/src/contracts/deepbook_predict/config_events.ts +9 -2
  163. package/src/contracts/deepbook_predict/deps/sui/vec_map.ts +33 -0
  164. package/src/contracts/deepbook_predict/expiry_cash.ts +1 -1
  165. package/src/contracts/deepbook_predict/expiry_market.ts +70 -11
  166. package/src/contracts/deepbook_predict/market_lifecycle_cap.ts +3 -10
  167. package/src/contracts/deepbook_predict/market_manager.ts +2 -2
  168. package/src/contracts/deepbook_predict/order_events.ts +6 -6
  169. package/src/contracts/deepbook_predict/plp.ts +263 -81
  170. package/src/contracts/deepbook_predict/pool_accounting.ts +14 -14
  171. package/src/contracts/deepbook_predict/pool_valuation_cap.ts +69 -0
  172. package/src/contracts/deepbook_predict/predict_account.ts +1 -1
  173. package/src/contracts/deepbook_predict/pricing.ts +16 -4
  174. package/src/contracts/deepbook_predict/protocol_config.ts +202 -7
  175. package/src/contracts/deepbook_predict/registry.ts +91 -17
  176. package/src/contracts/deepbook_predict/strike_exposure.ts +1 -1
  177. package/src/contracts/deepbook_predict/strike_payout_tree.ts +27 -0
  178. package/src/contracts/deepbook_predict/vault_events.ts +45 -14
  179. package/src/contracts/propbook/block_scholes_store.ts +8 -42
  180. package/src/deployments/index.ts +13 -3
  181. package/src/deployments/mainnet.ts +107 -0
  182. package/src/deployments/testnet.ts +25 -25
  183. package/src/deployments/types.ts +1 -1
  184. package/src/predict/client.ts +48 -17
  185. package/src/predict/config/index.ts +7 -2
  186. package/src/predict/config/mainnet.ts +27 -0
  187. package/src/predict/config/types.ts +7 -1
  188. package/src/predict/index.ts +31 -2
  189. package/src/predict/pricing.ts +11 -9
  190. package/src/predict/reads/balances.ts +1 -1
  191. package/src/predict/reads/markets.ts +1 -1
  192. package/src/predict/reads/pricing.ts +2 -1
  193. package/src/sessions.ts +4 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,75 @@
1
1
  # @mysten/deepbook-v3
2
2
 
3
+ ## 2.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b07659a: Predict: export the generated move-call bindings from `@mysten/deepbook-v3/predict`, the
8
+ way `/account` already exports `accountMoveCalls`. Each `client.predict.tx.*` builder returns a
9
+ finished `Transaction`, so a Predict call could not join a PTB the caller was building — creating
10
+ an account, funding it and queueing a PLP supply in one transaction meant hand-writing
11
+ `plp::request_supply` as a raw `moveCall`. Every Predict module with a callable function is now
12
+ reachable as a namespace of transaction thunks (`plpMoveCalls`, `expiryMarketMoveCalls`,
13
+ `predictAccountMoveCalls`, `protocolConfigMoveCalls`, `registryMoveCalls`, `builderCodeMoveCalls`,
14
+ `marketManagerMoveCalls`, `pricingMoveCalls`, `rangeCodecMoveCalls`, and the cap modules),
15
+ alongside the event layouts (`vaultEvents`, `orderEvents`, `configEvents`, `builderCodeEvents`).
16
+ Pass `config: toGeneratedConfig(cfg)` and the shared objects fill themselves in; owner-authorized
17
+ calls take an `Auth` from `generateAuth(cfg)`. Additive only: no existing export changes.
18
+
19
+ ### Patch Changes
20
+
21
+ - ee8df5d: Predict docs: document both recorded deployments. `PREDICT.md` and the README now
22
+ describe the `deepbook-predict-mainnet` and `deepbook-predict-testnet` records that `getConfig`,
23
+ `getDeployment`, `getUnits`, `getAccountConfig`, and `getSessionsConfig` resolve, the quote coin
24
+ per network (Circle native USDC on mainnet, a mintable test coin that displays as DUSDC on
25
+ testnet, read from `quoteCoinType`), the `side: 'range'` descriptor arm, which decoders have
26
+ plural forms, what is exported for PTB composition, that `read.markets()` returns
27
+ live-and-not-yet-settled markets, and the `supplyPlp` / `withdrawPlp` floor options as shipped.
28
+ Documentation only; no runtime change.
29
+
30
+ ## 2.3.0
31
+
32
+ ### Minor Changes
33
+
34
+ - 7b47a9a: Predict: let `supplyPlp` and `withdrawPlp` set a price floor. Both hard-pinned the
35
+ request's floor to 0, so the SDK could only ever queue an LP request that accepts whatever mark
36
+ the next pool flush quotes. They now take an optional third argument — `{ minPlpOut }` (raw
37
+ `bigint` shares) and `{ minUsdcOut }` (USD decimals) — defaulting to the previous no-floor
38
+ behaviour.
39
+ - 1e2f728: Add Mainnet deployment ids for Predict, sessions and the account primitive. `getConfig`,
40
+ `getAccountConfig`, `getSessionsConfig`, `getUnits` and `getDeployment` now resolve `'mainnet'`
41
+ instead of throwing, and `MAINNET_CONFIG` / `MAINNET_DEPLOYMENT` / `MAINNET_UNITS` are exported
42
+ alongside their testnet counterparts. `DeployedNetwork` widens to `'testnet' | 'mainnet'`.
43
+
44
+ Mainnet settles in Circle's native USDC
45
+ (`0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC`). The in-repo
46
+ test currency is never published to Mainnet, so the collateral type resolves to Circle's package
47
+ there and to the DeepBook test coin on Testnet — read `quoteCoinType` from the config rather than
48
+ assuming either.
49
+
50
+ The ids are generated from the deploy tooling's own Mainnet manifest, like Testnet's, so both
51
+ networks move together on a redeploy and cannot drift apart across subpaths.
52
+
53
+ ## 2.2.0
54
+
55
+ ### Minor Changes
56
+
57
+ - e7c8014: Target the `deepbook-predict-testnet` deployment. Every testnet id the SDK ships changes
58
+ — the Predict, account and sessions packages and their shared objects — so `getConfig('testnet')`,
59
+ `getAccountConfig('testnet')`, `getSessionsConfig('testnet')` and `TESTNET_CONFIG` all resolve
60
+ against the new deployment, and `getDeployment('testnet')` reports it by name and source commit.
61
+ Anything pinned to the previous testnet deployment's ids will not find its accounts, positions or
62
+ markets there; they are separate deployments, not an upgrade.
63
+
64
+ The settlement collateral is renamed upstream from `dusdc::dusdc::DUSDC` to `usdc::usdc::USDC`, so
65
+ one Move module path resolves on both testnet and mainnet and mainnet can link native USDC by
66
+ address alone. `quoteCoinType` carries the new type. The testnet coin keeps the `DUSDC` display
67
+ symbol, which is what distinguishes the mintable test coin from native USDC in wallets and
68
+ explorers — read `quoteCoinType` rather than assuming a symbol or a type.
69
+
70
+ The exported surface is otherwise unchanged: no symbol is added, removed or re-typed, and the
71
+ renamed Move argument (`min_usdc_out`) is internal to the transaction builders.
72
+
3
73
  ## 2.1.4
4
74
 
5
75
  ## 2.1.3
package/PREDICT.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # DeepBook Predict (`@mysten/deepbook-v3/predict`)
2
2
 
3
- TypeScript SDK for DeepBook Predict — binary markets on Sui. Builds ready-to-sign transactions and
4
- reads on-chain state through your Sui client. The SDK never signs and never touches keys: every
5
- `tx.*` method returns a `Transaction` for your wallet (dapp-kit) or signer to execute.
3
+ TypeScript SDK for DeepBook Predict — binary and range markets on Sui. Builds ready-to-sign
4
+ transactions and reads on-chain state through your Sui client. The SDK never signs and never touches
5
+ keys: every `tx.*` method returns a `Transaction` for your wallet (dapp-kit) or signer to execute.
6
6
 
7
7
  ## Install
8
8
 
@@ -12,8 +12,10 @@ npm i @mysten/deepbook-v3 @mysten/sui
12
12
 
13
13
  `@mysten/sui` is a peer dependency.
14
14
 
15
- > Predict is deployed on **testnet** only. `getConfig('mainnet')` throws until a mainnet deployment
16
- > exists.
15
+ > Two deployments are recorded, **testnet** and **mainnet**: `predict({ network })` and
16
+ > `getConfig(network)` resolve either, and any other network throws. They settle in different coins
17
+ > that share one Move module path — read `quoteCoinType` from the config rather than assuming a
18
+ > symbol or a type. See [Networks & deployments](#networks--deployments).
17
19
 
18
20
  ## Quickstart
19
21
 
@@ -32,16 +34,22 @@ const client = new SuiGrpcClient({
32
34
  // One-time: create your Predict account (a shared AccountWrapper).
33
35
  const createTx = client.predict.tx.createManager();
34
36
 
35
- // Fund it: pulls DUSDC from your address (coin objects and/or address balance).
37
+ // Fund it: pulls the deployment's quote coin (`client.predict.cfg.quoteCoinType`) from your
38
+ // address (coin objects and/or address balance).
36
39
  const depositTx = client.predict.tx.deposit(myAddress, 250); // $250
37
40
 
38
- // Cash out: lands in your DUSDC address balance by default (no coin-object churn).
41
+ // Cash out: lands in your quote-coin address balance by default (no coin-object churn).
39
42
  // Pass { toCoinObject: true } if you need a discrete Coin<T> instead.
40
43
  const withdrawTx = client.predict.tx.withdraw(myAddress, 100); // $100
41
44
 
42
- // Pick a live market. Expiries are absolute timestamps, so never hardcode one.
45
+ // Pick a market. `read.markets()` lists ACTIVE markets live and not yet settled — which
46
+ // includes a market past its expiry that nobody has settled yet; quoting against one aborts.
47
+ // Expiries are absolute timestamps, so never hardcode one: filter on `expiryMs`, leaving
48
+ // room to quote, sign and land (and clear the pre-expiry no-trade window).
43
49
  const markets = await client.predict.read.markets();
44
- const expiryMs = markets[0].expiryMs;
50
+ // -> [{ id, expiryMs, tickSize, admissionTickSize, mintPaused, referencePrice }, ...]
51
+ const tradeable = markets.filter((m) => Number(m.expiryMs) > Date.now() + 30_000 && !m.mintPaused);
52
+ const expiryMs = tradeable[0].expiryMs;
45
53
 
46
54
  // Describe the position once and reuse it — quoting and minting take the same descriptor.
47
55
  const desc = { underlying: 'BTC', expiryMs, strike: 'reference', side: 'up' } as const;
@@ -73,14 +81,10 @@ receipt.entryProbability; // your fill price (0..1 per $1 payout)
73
81
  receipt.premium; // exact cost breakdown
74
82
  receipt.fees;
75
83
 
76
- // Read: tradeable markets and pool state.
77
- const markets = await client.predict.read.markets();
78
- // -> [{ id, expiryMs, tickSize, admissionTickSize, mintPaused, referencePrice }, ...]
79
- const market = await client.predict.read.market({
80
- underlying: 'BTC',
81
- expiryMs: markets[0].expiryMs,
82
- });
84
+ // Read: one market's live state (+ NAV) and the pool.
85
+ const market = await client.predict.read.market({ underlying: 'BTC', expiryMs });
83
86
  console.log(market?.nav, market?.tickSize, market?.mintPaused);
87
+ const pool = await client.predict.read.pool();
84
88
  ```
85
89
 
86
90
  ## ⚠ Slippage defaults are UNCAPPED
@@ -89,25 +93,41 @@ console.log(market?.nav, market?.tickSize, market?.mintPaused);
89
93
  **uncapped** — if the price moves between your quote and execution, the position can cost up to your
90
94
  full account balance. **Call `read.quoteMint` and pass its `cost` (plus your buffer) as `maxCost`.**
91
95
  The same applies to `redeem`: the deployed `redeem_live` DOES take `min_probability` /
92
- `min_proceeds` floors, but the facade does not surface them yet and always sends `0` (uncapped).
93
- `read.quoteRedeem` first, close fast or drive `redeemLive` from the tx layer to set the floors.
96
+ `min_proceeds` floors, but the facade's `tx.redeem` does not surface them and always sends `0`
97
+ (uncapped). `read.quoteRedeem` first, close fast. The floors are reachable through `/sessions`:
98
+ `SessionsContract.redeemLive` takes `minProbability` / `minProceeds` (raw units —
99
+ `probabilityToRaw`, `usdcToRaw`) plus a `pricer` from `loadLivePricer`, and is signed by a session
100
+ key the owner has authorized (see the README's `/sessions` section).
94
101
 
95
102
  ## Units
96
103
 
97
104
  Everything human-facing is decimal; everything on-chain is scaled integers. The facade converts
98
105
  **inputs** exactly (string/bigint math — no floats on the money path in). Read outputs typed
99
- `number` are display values: above 2^53 raw they lose low-digit precision — for accounting-exact
100
- reads use the primitives layer, which returns raw `bigint`s (`accountBalance`, `poolStats`, …).
106
+ `number` are display values: above 2^53 raw they lose low-digit precision — quotes and receipts
107
+ carry a `raw` block of `bigint`s alongside, and `plpBalance` / `pool().plpTotalSupply` are raw
108
+ `bigint` already.
109
+
110
+ Amounts are in the deployment's quote coin — `getConfig(network).quoteCoinType`: Circle native USDC
111
+ on mainnet, a mintable 6-decimal test coin on testnet. Both are `…::usdc::USDC`, so only the package
112
+ address tells them apart; read the type, never assume a symbol.
101
113
 
102
114
  | Concept | You pass / receive | On-chain raw |
103
115
  | ------------------------------------------- | -------------------------------------------------------------- | ------------------------------------- |
104
- | Amounts (deposit, spend, maxCost, balances) | USD decimal number or string (`12.5`, `"12.5"`) | ×1e6 (DUSDC) |
116
+ | Amounts (deposit, spend, maxCost, balances) | USD decimal number or string (`12.5`, `"12.5"`) | ×1e6 (quote coin) |
105
117
  | `quantity` | **max payout** in USD; positions pay $1 per contract at expiry | ×1e6, in $0.01 lots |
106
118
  | `strike` | USD (`105_000`) | ×1e9, must land on the admission grid |
107
119
  | `maxProbability` | 0..1 (`0.35` = 35¢ per $1 contract) | ×1e9 |
108
120
  | PLP shares (`withdrawPlp`, `plpBalance`) | raw `bigint` shares | 6-decimal coin |
109
121
 
110
- `side: "up"` wins if the settlement price is above the strike; `"down"` below.
122
+ `side: "up"` wins if the settlement price is above the strike; `"down"` below; `"range"` (see
123
+ [Range positions](#range-positions)) if it lands inside `(lower, upper]`.
124
+
125
+ Trading closes slightly before expiry: the protocol enforces a short pre-expiry no-trade window
126
+ (`no_trade_window_ms` on the live `ProtocolConfig`, 2 s on both recorded deployments), so a mint or
127
+ redeem submitted inside it aborts `ETradeWindowClosed` rather than filling. Treat the last seconds
128
+ of a window as untradeable rather than retrying, and when choosing a market from `read.markets()`
129
+ leave enough of the window to quote, sign and land — a quote taken seconds before expiry executes
130
+ inside the window.
111
131
 
112
132
  ## Reference-price markets (Polymarket-style windows)
113
133
 
@@ -134,11 +154,11 @@ strikes away from the reference remain fully supported.
134
154
  ### Numeric strikes must sit on the admission grid
135
155
 
136
156
  New mint strikes must be a whole multiple of the market's **`admissionTickSize`** — a step
137
- deliberately coarser than `tickSize`, and it varies by cadence (on the current testnet deployment
138
- the 1m/5m/1h markets use `$1` and the 1d/1w markets `$100`, against a `$0.01` tick). Always read it
139
- off the market rather than assuming a value. The market's `referencePrice` is the one finite strike
140
- the chain admits off-grid. `read.markets()` and `read.market()` both report `admissionTickSize`, so
141
- a board can be built from it directly:
157
+ deliberately coarser than `tickSize`, and it is configured per cadence (both recorded deployments
158
+ run `$1` against a `$0.01` tick on their enabled cadences, 1m and 5m). Always read it off the market
159
+ rather than assuming a value. The market's `referencePrice` is the one finite strike the chain
160
+ admits off-grid. `read.markets()` and `read.market()` both report `admissionTickSize`, so a board
161
+ can be built from it directly:
142
162
 
143
163
  ```ts
144
164
  const m = (await client.predict.read.markets())[0];
@@ -148,6 +168,23 @@ const strike = Math.round(target / m.admissionTickSize) * m.admissionTickSize;
148
168
  An off-grid numeric strike throws `PredictInputError` at build time rather than aborting on chain
149
169
  with `EInvalidAdmissionTick`.
150
170
 
171
+ ### Range positions
172
+
173
+ `MarketDescriptor` has a third arm: `{ underlying, expiryMs, side: 'range', lower, upper }`. It pays
174
+ $1 per contract when the settlement price lands inside `(lower, upper]` — left-open, right-closed,
175
+ the same convention as the on-chain range key. Both bounds are USD strikes that must be finite, on
176
+ the tick grid, with `lower < upper`, and **each is admission-grid checked** exactly like a binary
177
+ numeric strike. `strike: 'reference'` is binary-only — a range has no single reference strike — and
178
+ `read.price` is binary-only too; price a range locally with `pricer.range(lower, upper)`.
179
+
180
+ ```ts
181
+ const tx = await client.predict.tx.mint(
182
+ myAddress,
183
+ { underlying: 'BTC', expiryMs, side: 'range', lower: 104_000, upper: 106_000 },
184
+ { quantity: 25, maxCost: 10 },
185
+ );
186
+ ```
187
+
151
188
  ## What's in the box
152
189
 
153
190
  - **`client.predict.tx`** — `createManager`, `deposit`, `withdraw`, `mint`, `mintAmount`, `redeem`,
@@ -155,23 +192,59 @@ with `EInvalidAdmissionTick`.
155
192
  `setBuilderCode`, `unsetBuilderCode`. Market-resolving builders
156
193
  (`mint`/`mintAmount`/`redeem`/`claimSettled`) are async: they resolve the market object from
157
194
  `{ underlying, expiryMs, strike, side }` via the on-chain registry (cached per client).
158
- - **`client.predict.read`** — `markets()` (tradeable summaries: id, expiry, tick size, mint-paused,
159
- reference price), `market(desc)` (state + live NAV), `price(m)` (anonymous both-sides pricing for
160
- any strike, one chain call per strike), `pricer(m)` (a **client-side board pricer** one chain
161
- read of the resolved pricer, then price every strike locally; see below),
195
+ - **`client.predict.read`** — `markets()` (summaries of the pool's **active** markets — live and not
196
+ yet settled, so a market past expiry that nobody has settled is still listed and quoting against
197
+ it aborts; filter on `expiryMs` and `mintPaused` before trading: id, expiry, tick size, admission
198
+ tick size, mint-paused, reference price), `market(desc)` (state + live NAV), `price(m)` (anonymous
199
+ both-sides pricing for any strike, one chain call per strike), `pricer(m)` (a **client-side board
200
+ pricer** — one chain read of the resolved pricer, then price every strike locally; see below),
162
201
  `quoteMint(owner, m, opts)` / `quoteRedeem(owner, m, opts)` (exact dry-run quotes: real fees from
163
202
  the real code path — and they throw the same typed errors the real trade would, so a quote doubles
164
203
  as preflight), `balance(owner)`, `plpBalance(owner)`, `pool()`, `positions(owner)` (chain-only
165
204
  enumeration of open positions), `hasPosition(owner, marketId, orderId)`. All reads run over the
166
205
  client's `simulateTransaction`; no indexer required.
167
206
  - **`client.predict.decode`** — pure execution-result decoders (no network): `mint`, `redeem`,
168
- `claim`, `createManager`, `deposit`, `withdraw`, `plpRequest`, `plpCancel`, `builderCode`, each
169
- with a plural form for batched PTBs. Execute transactions with events included and pass the
170
- result; receipts come back in SDK units with raw bigints alongside. Decoding uses the events'
171
- canonical BCS bytes, so it is transport-independent.
172
- - **PTB composition** integrators who need to compose their own transactions can use the generated
173
- Move bindings under `contracts/` directly (transaction thunks + BCS structs), the same layer the
174
- facade builds on.
207
+ `claim`, `createManager`, `deposit`, `withdraw`, `plpRequest`, `plpCancel`, `builderCode`. Each
208
+ singular form throws unless exactly one matching event is present; `mints`, `redeems` and `claims`
209
+ are the plural forms for batched PTBs and return every receipt (the other decoders have no
210
+ plural). Execute transactions with events included and pass the result; receipts come back in SDK
211
+ units with raw bigints alongside. Decoding uses the events' canonical BCS bytes, so it is
212
+ transport-independent.
213
+ - **PTB composition** — each `client.predict.tx.*` builder returns a finished `Transaction`, so to
214
+ put a Predict call into a PTB you are building, use the generated move-call bindings `/predict`
215
+ exports: one namespace of transaction thunks per Predict module (`plpMoveCalls`,
216
+ `expiryMarketMoveCalls`, `predictAccountMoveCalls`, `protocolConfigMoveCalls`,
217
+ `registryMoveCalls`, `builderCodeMoveCalls`, `marketManagerMoveCalls`, `pricingMoveCalls`,
218
+ `rangeCodecMoveCalls`, `adminMoveCalls` and the cap modules) plus the event layouts
219
+ (`vaultEvents`, `orderEvents`, `configEvents`, `builderCodeEvents`). Pass
220
+ `config: toGeneratedConfig(cfg)` — the flat config slice the bindings resolve the shared objects
221
+ against — and give owner-authorized calls `auth: tx.add(generateAuth(cfg))`, the hot-potato `Auth`
222
+ the account calls consume. The account itself (create, deposit, share) is
223
+ `@mysten/deepbook-v3/account`'s `accountRegistryMoveCalls` / `accountMoveCalls`. Also exported:
224
+ `loadLivePricer(toGeneratedConfig(cfg), { expiryMarketId, ...cfg.underlyings[sym] })` — the
225
+ `pricer` every live trade call borrows, which the `/sessions` Predict wrappers take as a PTB
226
+ result — and `deriveAccountWrapperId(cfg, owner)`.
227
+
228
+ ```ts
229
+ // Create an account, fund it, and queue a PLP supply — one PTB, one signature.
230
+ const config = toGeneratedConfig(cfg);
231
+ const wrapper = tx.add(accountRegistryMoveCalls._new({ config }));
232
+ tx.add(
233
+ accountMoveCalls.depositFunds({
234
+ config,
235
+ arguments: { wrapper, auth: tx.add(generateAuth(cfg)), coin },
236
+ typeArguments: [cfg.quoteCoinType],
237
+ }),
238
+ );
239
+ tx.add(
240
+ plpMoveCalls.requestSupply({
241
+ config,
242
+ arguments: { wrapper, auth: tx.add(generateAuth(cfg)), amount, minPlpOut },
243
+ }),
244
+ );
245
+ tx.add(accountMoveCalls.share({ config, arguments: { self: wrapper } }));
246
+ ```
247
+
175
248
  - **Typed errors** — invalid inputs throw `PredictInputError` before the chain sees them; failed
176
249
  simulations throw `PredictMoveError` with the decoded Move abort (`module`, `code`, `abortName`).
177
250
 
@@ -198,9 +271,9 @@ on-chain; the client only evaluates the digital. It throws the same typed stale-
198
271
  The math is a faithful float port of the deployed `pricing::compute_nd2` (SVI with the skew
199
272
  correction, signed params, and the remaining-time roll-down). It agrees with the chain closely —
200
273
  within ~1e-4 in probability, up to ~1e-4 near ATM where the chain's fixed-point truncation dominates
201
- (`tests/testnet/pricing.test.ts` bounds it live). The pure functions are exported under a `pricing`
202
- namespace for callers who already hold their own oracle inputs (e.g. a live feed) and want zero
203
- chain calls:
274
+ (`test/predict/testnet/pricing.test.ts` bounds it live). The pure functions are exported under a
275
+ `pricing` namespace for callers who already hold their own oracle inputs (e.g. a live feed) and want
276
+ zero chain calls:
204
277
 
205
278
  ```ts
206
279
  import { pricing } from '@mysten/deepbook-v3/predict';
@@ -218,11 +291,29 @@ const rolled = pricing.rollDown(rawSvi, remainingMs, anchorTteMs); // decay a, b
218
291
 
219
292
  ## Networks & deployments
220
293
 
221
- **Testnet only today** `getConfig("mainnet")` throws until a mainnet deployment exists. Object ids
222
- for the current testnet deployment are baked into the SDK (`TESTNET_CONFIG`); they are updated, with
223
- a release, whenever a new package version is deployed. Move-call targets flow through one resolution
224
- seam, which will switch to MVR names (`@deepbook/predict`) once registered — package upgrades then
225
- stop requiring an SDK release for target resolution.
294
+ Two deployments are recorded. `getDeployment(network)` names each one and the deepbookv3 commit its
295
+ ids were generated at:
296
+
297
+ | Network | Deployment | Chain id | Source commit | `quoteCoinType` |
298
+ | --------- | -------------------------- | ---------- | ------------- | -------------------------------------------------------------------------------------------------------------------------- |
299
+ | `mainnet` | `deepbook-predict-mainnet` | `35834a8a` | `14a7e8f8` | Circle native USDC — `0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC` |
300
+ | `testnet` | `deepbook-predict-testnet` | `4c78adac` | `a928bd2d` | mintable test coin, displays as `DUSDC` — `0xc028557a1ed49e42ed091e115aedefd70a442b184c18fbec5c48d5b6c0b8c184::usdc::USDC` |
301
+
302
+ Object ids for both are baked into the SDK — `MAINNET_CONFIG` / `TESTNET_CONFIG`, with
303
+ `MAINNET_DEPLOYMENT` / `TESTNET_DEPLOYMENT` and `MAINNET_UNITS` / `TESTNET_UNITS` alongside — and
304
+ are regenerated, with a release, whenever a deployment moves. `getConfig`, `getDeployment` and
305
+ `getUnits` resolve both networks and throw on any other; `getAccountConfig` (`/account`) and
306
+ `getSessionsConfig` (`/sessions`) read slices of the same generated record, so the three subpaths
307
+ cannot address different deployments. Units are identical on both (`$0.01` lots, 6 quote decimals,
308
+ 1e9 fixed-point scale).
309
+
310
+ Move-call targets resolve from the config's package ids, so a deployment of your own is addressed by
311
+ passing `config` — `predict({ network, config })` or
312
+ `new PredictClient({ client, network, config })` — and `network` is then not consulted.
313
+
314
+ An expired market stays in `read.markets()` until someone settles it — the list is the pool's
315
+ live-and-not-yet-settled set, not a tradeable set. On either network, check `expiryMs` against the
316
+ clock (and `mintPaused`) before quoting rather than assuming the list is tradeable.
226
317
 
227
318
  ## Notes
228
319
 
@@ -233,11 +324,26 @@ stop requiring an SDK release for target resolution.
233
324
  as the cheap validator.
234
325
  - PLP supply/withdraw are queued and fill at the next pool flush; cancels take the queue `index` —
235
326
  get it from `decode.plpRequest(result).index`.
327
+ - **Both take an optional price floor**, and default to none:
328
+ `supplyPlp(owner, amountUsdc, { minPlpOut })` (`PlpSupplyOptions`, raw `bigint` shares; omitted →
329
+ `0n`) and `withdrawPlp(owner, shares, { minUsdcOut })` (`PlpWithdrawOptions`, USD decimals as
330
+ `number | string`, measured after the protocol's withdraw fee; omitted → no floor). Each floors
331
+ the flush's MARK for the whole request rather than naming a quantity — a flush quoting less
332
+ declines instead of filling smaller. What a miss costs is the deployment's
333
+ `lp_request_limit_flush_attempts`: the deployed value is one on both recorded deployments, so the
334
+ first flush below the floor cancels the request and refunds it, and re-queueing is a fresh
335
+ transaction (three is the configurable maximum, not the default). Leave the floor off and the
336
+ request takes whatever mark the flush quotes.
337
+ - **First-time funding in one PTB**: `deposit(owner, amount, { create: true })` creates the wrapper,
338
+ deposits through the fresh handle and shares it last. `owner` must be the transaction signer (the
339
+ wrapper is derived from the sender), and it aborts if the account already exists — the builder
340
+ does no chain read, so gate on `wrapperIdFor(owner)` + a `getObject`, or fall back to `deposit`
341
+ without the flag on that abort.
236
342
  - `claimSettled` closes the order in full — the deployed entrypoint takes no quantity.
237
343
  - **`withdraw` lands in your address balance by default** (`0x2::coin::send_funds`), not a coin
238
344
  object — it merges into the versionless accumulator `deposit` already draws from, so the round
239
- trip never accretes stray `Coin<DUSDC>` objects. `read.balance(owner)` reflects the account's
240
- internal custody balance; use the client's `getBalance(owner)` for the wallet-side DUSDC total
345
+ trip never accretes stray `Coin<USDC>` objects. `read.balance(owner)` reflects the account's
346
+ internal custody balance; use the client's `getBalance(owner)` for the wallet-side USDC total
241
347
  (coin objects + address balance). Pass `withdraw(owner, amt, { toCoinObject: true })` for a
242
348
  discrete coin (wallets/explorers that only render coin objects, or same-PTB composition).
243
349
 
package/README.md CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  ## Entry points
4
4
 
5
- | Import | Contents |
6
- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7
- | `@mysten/deepbook-v3` | DeepBook spot and margin — pools, orders, balance managers, flash loans, governance, margin managers/pools, TPSL. |
8
- | `@mysten/deepbook-v3/account` | The shared on-chain **account primitive** (`AccountContract`): the canonical `AccountWrapper`, `Auth`, and custody balances that DeepBook's core account wrapper and DeepBook Predict both build on. |
9
- | `@mysten/deepbook-v3/sessions` | **Time-limited trading sessions** over a canonical Account (`SessionsContract`): grant an ephemeral address bounded authority until a fixed expiry. Covers the session lifecycle and the DeepBook Predict wrappers. |
10
- | `@mysten/deepbook-v3/predict` | **DeepBook Predict** — binary markets: market discovery, quotes, mint/redeem/claim, PLP, typed receipts and a client-side board pricer. See [PREDICT.md](./PREDICT.md). |
5
+ | Import | Contents |
6
+ | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7
+ | `@mysten/deepbook-v3` | DeepBook spot and margin — pools, orders, balance managers, flash loans, governance, margin managers/pools, TPSL. |
8
+ | `@mysten/deepbook-v3/account` | The shared on-chain **account primitive** (`AccountContract`): the canonical `AccountWrapper`, `Auth`, and custody balances that DeepBook's core account wrapper and DeepBook Predict both build on. |
9
+ | `@mysten/deepbook-v3/sessions` | **Time-limited trading sessions** over a canonical Account (`SessionsContract`): grant an ephemeral address bounded authority until a fixed expiry. Covers the session lifecycle and the DeepBook Predict wrappers. |
10
+ | `@mysten/deepbook-v3/predict` | **DeepBook Predict** — binary and range markets: market discovery, quotes, mint/redeem/claim, PLP, typed receipts and a client-side board pricer, with deployed ids for testnet and mainnet. See [PREDICT.md](./PREDICT.md). |
11
11
 
12
12
  Subpaths are separate module graphs — importing `@mysten/deepbook-v3/account` does not load any spot
13
13
  or margin code.
@@ -15,10 +15,13 @@ or margin code.
15
15
  Each subpath also exports the **deployed ids** for its own surface, so a caller never transcribes
16
16
  them: `getAccountConfig(network)` on `/account`, `getSessionsConfig(network)` on `/sessions`,
17
17
  `getConfig(network)` on `/predict`. All three read one generated record (`src/deployments/`), so a
18
- redeploy updates every subpath at once and they cannot end up addressing different deployments.
19
- `getDeployment(network)` names the deployment and the deepbookv3 commit those ids came from.
20
- Predict, sessions and the account primitive are testnet-only today; an unrecorded network throws
21
- rather than returning placeholder ids.
18
+ redeploy updates every subpath at once and they cannot end up addressing different deployments. Two
19
+ networks are recorded, `testnet` (`deepbook-predict-testnet`) and `mainnet`
20
+ (`deepbook-predict-mainnet`); `getDeployment(network)` names the deployment and the deepbookv3
21
+ commit those ids came from, and an unrecorded network throws rather than returning placeholder ids.
22
+ The two deployments settle in different coins that share one Move module path — Circle native USDC
23
+ on mainnet, a mintable test coin (displayed as `DUSDC`) on testnet — so take the coin type from
24
+ `getConfig(network).quoteCoinType` on `/predict` rather than assuming either.
22
25
 
23
26
  ### `@mysten/deepbook-v3/account`
24
27
 
@@ -30,7 +33,7 @@ is computable off-chain with no chain read. `AccountContract` takes only the dep
30
33
  import { Transaction } from '@mysten/sui/transactions';
31
34
  import { AccountContract, getAccountConfig } from '@mysten/deepbook-v3/account';
32
35
 
33
- // Deployed ids ship with the package — no transcription.
36
+ // Deployed ids ship with the package — no transcription. 'testnet' | 'mainnet'.
34
37
  const account = new AccountContract(getAccountConfig('testnet'));
35
38
 
36
39
  // …or drive a deployment of your own:
@@ -38,8 +41,10 @@ const custom = new AccountContract({ accountPackageId: '0x…', accountRegistry:
38
41
 
39
42
  const wrapperId = account.deriveAccountWrapperId(owner);
40
43
 
44
+ // `quoteCoinType` is the deployment's settlement coin — `getConfig(network).quoteCoinType`
45
+ // from `/predict` — not a symbol you assume.
41
46
  const tx = new Transaction();
42
- tx.add(account.depositFunds({ wrapperId, coin, coinType: USDC }));
47
+ tx.add(account.depositFunds({ wrapperId, coin, coinType: quoteCoinType }));
43
48
  ```
44
49
 
45
50
  > `Account` exported from the package root is `@deepbook/core::account::Account` (the per-pool
@@ -61,7 +66,7 @@ withdrawal or arbitrary-mutation entrypoint.
61
66
  ```ts
62
67
  import { SessionsContract, getSessionsConfig } from '@mysten/deepbook-v3/sessions';
63
68
 
64
- // Deployed ids ship with the package — no transcription.
69
+ // Deployed ids ship with the package — no transcription. 'testnet' | 'mainnet'.
65
70
  const sessions = new SessionsContract(getSessionsConfig('testnet'));
66
71
 
67
72
  const wrapperId = sessions.deriveAccountWrapperId(owner);
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.mts","names":[],"sources":["../src/account.ts"],"mappings":";;;;;;;;;;;;AAoCA;;;;;;;;;AAiBA;;UAjBiB,aAAA,SAAsB,eAAA;EAiB6B;EAfnE,gBAAA;EAegC;EAbhC,eAAA;AAAA;;AAqCD;;;;;;;;;iBAxBgB,gBAAA,CAAiB,OAAA,EAAS,UAAA,GAAa,aAAA;;;;;;;;;;cAwB1C,eAAA;EAAA;EAMQ;;;cAAR,MAAA,EAAQ,aAAA;EA0BpB;;;;;;;EAfA,sBAAA,CAAuB,KAAA;EA0CW;;;;;;EA3BlC,YAAA,CAAA,IACS,EAAA,EAAI,WAAA,KAAc,iBAAA;EAgDJ;;;;;;EAtCvB,aAAA,CAAA,IACS,EAAA,EAAI,WAAA;EA0Db;;;;;;;;;EA3CA,uBAAA,CAAwB,MAAA;IAAU,IAAA,EAAM,yBAAA;IAA2B,QAAA;EAAA,KAC1D,EAAA,EAAI,WAAA;EA8Dc;;;;;;;EAzC3B,YAAA,CAAa,MAAA;IAAU,SAAA;IAAmB,IAAA,EAAM,yBAAA;IAA2B,QAAA;EAAA,KAClE,EAAA,EAAI,WAAA;;;;;;;;;EAoBb,aAAA,CAAc,MAAA;IAAU,SAAA;IAAmB,MAAA;IAAgB,QAAA;EAAA,KAClD,EAAA,EAAI,WAAA,KAAc,iBAAA;;;;;;;EAkB3B,WAAA,CAAY,MAAA;IAAU,SAAA;EAAA,KACb,EAAA,EAAI,WAAA,KAAc,iBAAA;;;;;;;;EAW3B,OAAA,CAAQ,MAAA;IAAU,KAAA;IAAe,QAAA;EAAA,KACxB,EAAA,EAAI,WAAA,KAAc,iBAAA;AAAA"}
1
+ {"version":3,"file":"account.d.mts","names":[],"sources":["../src/account.ts"],"mappings":";;;;;;;;;;;;AAqCA;;;;;;;;;AAiBA;;UAjBiB,aAAA,SAAsB,eAAA;EAiB6B;EAfnE,gBAAA;EAegC;EAbhC,eAAA;AAAA;;AAsCD;;;;;;;;;iBAzBgB,gBAAA,CAAiB,OAAA,EAAS,UAAA,GAAa,aAAA;;;;;;;;;;cAyB1C,eAAA;EAAA;EAMQ;;;cAAR,MAAA,EAAQ,aAAA;EA0BpB;;;;;;;EAfA,sBAAA,CAAuB,KAAA;EA0CW;;;;;;EA3BlC,YAAA,CAAA,IACS,EAAA,EAAI,WAAA,KAAc,iBAAA;EAgDJ;;;;;;EAtCvB,aAAA,CAAA,IACS,EAAA,EAAI,WAAA;EA0Db;;;;;;;;;EA3CA,uBAAA,CAAwB,MAAA;IAAU,IAAA,EAAM,yBAAA;IAA2B,QAAA;EAAA,KAC1D,EAAA,EAAI,WAAA;EA8Dc;;;;;;;EAzC3B,YAAA,CAAa,MAAA;IAAU,SAAA;IAAmB,IAAA,EAAM,yBAAA;IAA2B,QAAA;EAAA,KAClE,EAAA,EAAI,WAAA;;;;;;;;;EAoBb,aAAA,CAAc,MAAA;IAAU,SAAA;IAAmB,MAAA;IAAgB,QAAA;EAAA,KAClD,EAAA,EAAI,WAAA,KAAc,iBAAA;;;;;;;EAkB3B,WAAA,CAAY,MAAA;IAAU,SAAA;EAAA,KACb,EAAA,EAAI,WAAA,KAAc,iBAAA;;;;;;;;EAW3B,OAAA,CAAQ,MAAA;IAAU,KAAA;IAAe,QAAA;EAAA,KACxB,EAAA,EAAI,WAAA,KAAc,iBAAA;AAAA"}
package/dist/account.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Account, AccountWrapper, account_exports, balance, depositFunds, generateAuth, loadAccount, share, withdrawFunds } from "./contracts/account/account.mjs";
2
2
  import { _new, account_registry_exports } from "./contracts/account/account_registry.mjs";
3
+ import { MAINNET_ACCOUNT } from "./deployments/mainnet.mjs";
3
4
  import { TESTNET_ACCOUNT, TESTNET_DEPLOYMENT, TESTNET_UNITS } from "./deployments/testnet.mjs";
4
5
  import { getDeployment, getUnits } from "./deployments/index.mjs";
5
6
  import { account_events_exports } from "./contracts/account/account_events.mjs";
@@ -19,7 +20,8 @@ import { deriveObjectID } from "@mysten/sui/utils";
19
20
  */
20
21
  function getAccountConfig(network) {
21
22
  if (network === "testnet") return TESTNET_ACCOUNT;
22
- throw new Error(`@mysten/deepbook-v3/account: no account deployment recorded for network '${network}'. The account primitive is testnet-only today; for your own deployment pass \`{ accountPackageId, accountRegistry }\` to AccountContract directly.`);
23
+ if (network === "mainnet") return MAINNET_ACCOUNT;
24
+ throw new Error(`@mysten/deepbook-v3/account: no account deployment recorded for network '${network}'. The account primitive is recorded for testnet and mainnet; for your own deployment pass \`{ accountPackageId, accountRegistry }\` to AccountContract directly.`);
23
25
  }
24
26
  const AccountWrapperKey = bcs.struct("AccountWrapperKey", { pos0: bcs.Address });
25
27
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"account.mjs","names":["#config","account.generateAuth","accountRegistry._new","account.share","account.depositFunds","account.withdrawFunds","account.loadAccount","account.balance"],"sources":["../src/account.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { bcs } from '@mysten/sui/bcs';\nimport type {\n\tTransaction,\n\tTransactionObjectArgument,\n\tTransactionResult,\n} from '@mysten/sui/transactions';\nimport { deriveObjectID } from '@mysten/sui/utils';\n\nimport * as account from './contracts/account/account.js';\nimport * as accountRegistry from './contracts/account/account_registry.js';\nimport type { AccountConfig as GeneratedAccountConfig } from './contracts/account/config-arguments.js';\nimport { TESTNET_ACCOUNT } from './deployments/testnet.js';\nimport type { NetworkArg } from './deployments/index.js';\n\n// Provenance: which on-chain deployment the ids above came from. Re-exported so a consumer\n// can answer \"which deploy is this build pinned to?\" without reaching for another subpath.\nexport { getDeployment, getUnits, TESTNET_DEPLOYMENT, TESTNET_UNITS } from './deployments/index.js';\nexport type { NetworkArg } from './deployments/index.js';\nexport type { DeployedNetwork } from './deployments/index.js';\n\n/**\n * The deployed ids of the shared `account` package this contract builds against.\n *\n * Kept deliberately minimal — ids only — so any consumer of the shared account primitive\n * (DeepBook core's account wrapper, Predict, …) can drive these builders with its OWN\n * deployment's ids without constructing a full product-SDK config.\n *\n * Extends the codegen-generated config interface so there is exactly one config shape and\n * casing: the generated bindings resolve `options.config` against these same keys, and if\n * codegen adds, drops, or renames a key this file stops compiling instead of silently\n * building a PTB against the wrong object. The ids are narrowed to `string` — codegen types\n * the package id as optional and the registry as the wider `ConfigValue`, but the\n * wrapper-address derivation needs plain ids.\n */\nexport interface AccountConfig extends GeneratedAccountConfig {\n\t/** The `account` Move package id. */\n\taccountPackageId: string;\n\t/** The shared `AccountRegistry` object id. */\n\taccountRegistry: string;\n}\n\n/**\n * @description The deployed `account` ids for `network`, so a caller does not transcribe\n * them. Generated from the deploy manifest — see `src/deployments/`.\n * @throws if the network has no recorded deployment, rather than returning placeholder ids\n * that would fail as a confusing on-chain abort.\n *\n * ```ts\n * const account = new AccountContract(getAccountConfig('testnet'));\n * ```\n */\nexport function getAccountConfig(network: NetworkArg): AccountConfig {\n\tif (network === 'testnet') return TESTNET_ACCOUNT;\n\tthrow new Error(\n\t\t`@mysten/deepbook-v3/account: no account deployment recorded for network '${network}'. ` +\n\t\t\t'The account primitive is testnet-only today; for your own deployment pass ' +\n\t\t\t'`{ accountPackageId, accountRegistry }` to AccountContract directly.',\n\t);\n}\n\n// `AccountWrapperKey(address)` is a one-field positional struct, so its BCS is just the\n// owner's 32-byte address. See `packages/account/sources/account_registry.move`.\nconst AccountWrapperKey = bcs.struct('AccountWrapperKey', {\n\tpos0: bcs.Address,\n});\n\n/**\n * AccountContract — the reusable on-chain account primitive (`packages/account`).\n *\n * An owner has one canonical `AccountWrapper`, a *derived* object of the account registry,\n * so its id is computable off-chain (no read). The wrapper holds an `Account` whose custody\n * balances apps deposit into and withdraw from; app-specific data hangs off it under an\n * app-keyed slot. Authority is a hot-potato `Auth` minted from the tx sender and consumed\n * by the very next account-loading call.\n */\nexport class AccountContract {\n\t#config: AccountConfig;\n\n\t/**\n\t * @param {AccountConfig} config Deployed ids of the shared `account` package\n\t */\n\tconstructor(config: AccountConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description The deterministic id of an owner's canonical account wrapper — no chain\n\t * read needed. The wrapper is a derived object of the account registry, so its id is\n\t * `derive_address(registry, AccountWrapperKey(owner))`.\n\t * @param {string} owner Owner address\n\t * @returns The wrapper object id\n\t */\n\tderiveAccountWrapperId(owner: string): string {\n\t\tconst key = AccountWrapperKey.serialize({ pos0: owner }).toBytes();\n\t\treturn deriveObjectID(\n\t\t\tthis.#config.accountRegistry,\n\t\t\t`${this.#config.accountPackageId}::account_registry::AccountWrapperKey`,\n\t\t\tkey,\n\t\t);\n\t}\n\n\t/**\n\t * @description Mint owner authority for the transaction sender. A hot-potato `Auth`\n\t * consumed by the very next account-loading call (`load_account_mut` inside\n\t * `deposit_funds` / `withdraw_funds` / an app's own entrypoints).\n\t * @returns A function that takes a Transaction object\n\t */\n\tgenerateAuth() {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(account.generateAuth({ config: this.#config }));\n\t}\n\n\t/**\n\t * @description Create the sender's canonical account wrapper and share it. `new` derives\n\t * the wrapper at its deterministic address (see `deriveAccountWrapperId`) and aborts if\n\t * it already exists; `share` publishes the shared object apps borrow against.\n\t * @returns A function that takes a Transaction object\n\t */\n\tcreateAccount() {\n\t\treturn (tx: Transaction): void => {\n\t\t\tconst wrapper = tx.add(accountRegistry._new({ config: this.#config }));\n\t\t\ttx.add(account.share({ config: this.#config, arguments: { self: wrapper } }));\n\t\t};\n\t}\n\n\t/**\n\t * @description First-time funding in ONE PTB: create the sender's wrapper, deposit\n\t * `coin` through the fresh handle, then `share` LAST (once shared, by-value use of the\n\t * handle is over). This cannot be split into `createAccount` + `depositFunds`: an object\n\t * input can only address an object that pre-exists the PTB, so a wrapper created inside\n\t * it is reachable only through `new`'s result handle.\n\t * @param {object} params Coin to deposit and its coin type\n\t * @returns A function that takes a Transaction object\n\t */\n\tcreateAccountAndDeposit(params: { coin: TransactionObjectArgument; coinType: string }) {\n\t\treturn (tx: Transaction): void => {\n\t\t\tconst wrapper = tx.add(accountRegistry._new({ config: this.#config }));\n\t\t\tconst auth = tx.add(this.generateAuth());\n\t\t\ttx.add(\n\t\t\t\taccount.depositFunds({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper, auth, coin: params.coin },\n\t\t\t\t\ttypeArguments: [params.coinType],\n\t\t\t\t}),\n\t\t\t);\n\t\t\ttx.add(account.share({ config: this.#config, arguments: { self: wrapper } }));\n\t\t};\n\t}\n\n\t/**\n\t * @description Deposit a caller-provided `coin` into the account's stored balance via the\n\t * PTB-callable `deposit_funds` (folds settle → authorize → load → deposit; clock and\n\t * accumulator root auto-injected). The caller owns coin sourcing.\n\t * @param {object} params Wrapper id, coin to deposit, and its coin type\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositFunds(params: { wrapperId: string; coin: TransactionObjectArgument; coinType: string }) {\n\t\treturn (tx: Transaction): void => {\n\t\t\tconst auth = tx.add(this.generateAuth());\n\t\t\ttx.add(\n\t\t\t\taccount.depositFunds({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper: params.wrapperId, auth, coin: params.coin },\n\t\t\t\t\ttypeArguments: [params.coinType],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * @description Withdraw `amount` (raw u64 units) from the account's stored balance via\n\t * the PTB-callable `withdraw_funds` (folds settle → authorize → load → withdraw; clock\n\t * and accumulator root auto-injected), returning the minted `Coin<T>` for the caller to\n\t * transfer or compose.\n\t * @param {object} params Wrapper id, raw amount, and coin type\n\t * @returns A function that takes a Transaction object and returns the `Coin<T>`\n\t */\n\twithdrawFunds(params: { wrapperId: string; amount: bigint; coinType: string }) {\n\t\treturn (tx: Transaction): TransactionResult => {\n\t\t\tconst auth = tx.add(this.generateAuth());\n\t\t\treturn tx.add(\n\t\t\t\taccount.withdrawFunds({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper: params.wrapperId, auth, amount: params.amount },\n\t\t\t\t\ttypeArguments: [params.coinType],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * @description Borrow the `Account` out of its wrapper — the read-side entry point apps\n\t * chain their own getters onto (`account::balance<T>`, an app's own data accessors).\n\t * @param {object} params Wrapper id\n\t * @returns A function that takes a Transaction object and returns the `Account`\n\t */\n\tloadAccount(params: { wrapperId: string }) {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(account.loadAccount({ config: this.#config, arguments: { self: params.wrapperId } }));\n\t}\n\n\t/**\n\t * @description Read an owner's stored custody balance for a coin type: chains\n\t * `load_account(wrapper)` → `balance<T>(account, root, clock)`. Compose in a\n\t * dev-inspect/simulate PTB and read the u64 return of the LAST command.\n\t * @param {object} params Owner address and coin type\n\t * @returns A function that takes a Transaction object\n\t */\n\tbalance(params: { owner: string; coinType: string }) {\n\t\treturn (tx: Transaction): TransactionResult => {\n\t\t\tconst acct = tx.add(\n\t\t\t\tthis.loadAccount({ wrapperId: this.deriveAccountWrapperId(params.owner) }),\n\t\t\t);\n\t\t\treturn tx.add(\n\t\t\t\taccount.balance({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\ttypeArguments: [params.coinType],\n\t\t\t\t\targuments: { self: acct },\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n}\n\n// === Generated bindings ===\n// The move-call thunks and BCS structs, for consumers composing their own PTBs or\n// parsing account objects/events (e.g. `AccountWrapper.parse`, the event layouts).\n//\n// NOTE: `Account` here is the shared account primitive's custody account\n// (`account::account::Account`). It is deliberately NOT re-exported from this\n// package's root — the root already exports a different `Account`\n// (`@deepbook/core::account::Account`, the per-pool trading account) and the two\n// have unrelated layouts. Keep them separated by subpath.\nexport * as accountMoveCalls from './contracts/account/account.js';\nexport * as accountRegistryMoveCalls from './contracts/account/account_registry.js';\nexport * as accountEvents from './contracts/account/account_events.js';\nexport { Account, AccountWrapper } from './contracts/account/account.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqDA,SAAgB,iBAAiB,SAAoC;AACpE,KAAI,YAAY,UAAW,QAAO;AAClC,OAAM,IAAI,MACT,4EAA4E,QAAQ,qJAGpF;;AAKF,MAAM,oBAAoB,IAAI,OAAO,qBAAqB,EACzD,MAAM,IAAI,SACV,CAAC;;;;;;;;;;AAWF,IAAa,kBAAb,MAA6B;CAC5B;;;;CAKA,YAAY,QAAuB;AAClC,QAAKA,SAAU;;;;;;;;;CAUhB,uBAAuB,OAAuB;EAC7C,MAAM,MAAM,kBAAkB,UAAU,EAAE,MAAM,OAAO,CAAC,CAAC,SAAS;AAClE,SAAO,eACN,MAAKA,OAAQ,iBACb,GAAG,MAAKA,OAAQ,iBAAiB,wCACjC,IACA;;;;;;;;CASF,eAAe;AACd,UAAQ,OACP,GAAG,IAAIC,aAAqB,EAAE,QAAQ,MAAKD,QAAS,CAAC,CAAC;;;;;;;;CASxD,gBAAgB;AACf,UAAQ,OAA0B;GACjC,MAAM,UAAU,GAAG,IAAIE,KAAqB,EAAE,QAAQ,MAAKF,QAAS,CAAC,CAAC;AACtE,MAAG,IAAIG,MAAc;IAAE,QAAQ,MAAKH;IAAS,WAAW,EAAE,MAAM,SAAS;IAAE,CAAC,CAAC;;;;;;;;;;;;CAa/E,wBAAwB,QAA+D;AACtF,UAAQ,OAA0B;GACjC,MAAM,UAAU,GAAG,IAAIE,KAAqB,EAAE,QAAQ,MAAKF,QAAS,CAAC,CAAC;GACtE,MAAM,OAAO,GAAG,IAAI,KAAK,cAAc,CAAC;AACxC,MAAG,IACFI,aAAqB;IACpB,QAAQ,MAAKJ;IACb,WAAW;KAAE;KAAS;KAAM,MAAM,OAAO;KAAM;IAC/C,eAAe,CAAC,OAAO,SAAS;IAChC,CAAC,CACF;AACD,MAAG,IAAIG,MAAc;IAAE,QAAQ,MAAKH;IAAS,WAAW,EAAE,MAAM,SAAS;IAAE,CAAC,CAAC;;;;;;;;;;CAW/E,aAAa,QAAkF;AAC9F,UAAQ,OAA0B;GACjC,MAAM,OAAO,GAAG,IAAI,KAAK,cAAc,CAAC;AACxC,MAAG,IACFI,aAAqB;IACpB,QAAQ,MAAKJ;IACb,WAAW;KAAE,SAAS,OAAO;KAAW;KAAM,MAAM,OAAO;KAAM;IACjE,eAAe,CAAC,OAAO,SAAS;IAChC,CAAC,CACF;;;;;;;;;;;CAYH,cAAc,QAAiE;AAC9E,UAAQ,OAAuC;GAC9C,MAAM,OAAO,GAAG,IAAI,KAAK,cAAc,CAAC;AACxC,UAAO,GAAG,IACTK,cAAsB;IACrB,QAAQ,MAAKL;IACb,WAAW;KAAE,SAAS,OAAO;KAAW;KAAM,QAAQ,OAAO;KAAQ;IACrE,eAAe,CAAC,OAAO,SAAS;IAChC,CAAC,CACF;;;;;;;;;CAUH,YAAY,QAA+B;AAC1C,UAAQ,OACP,GAAG,IAAIM,YAAoB;GAAE,QAAQ,MAAKN;GAAS,WAAW,EAAE,MAAM,OAAO,WAAW;GAAE,CAAC,CAAC;;;;;;;;;CAU9F,QAAQ,QAA6C;AACpD,UAAQ,OAAuC;GAC9C,MAAM,OAAO,GAAG,IACf,KAAK,YAAY,EAAE,WAAW,KAAK,uBAAuB,OAAO,MAAM,EAAE,CAAC,CAC1E;AACD,UAAO,GAAG,IACTO,QAAgB;IACf,QAAQ,MAAKP;IACb,eAAe,CAAC,OAAO,SAAS;IAChC,WAAW,EAAE,MAAM,MAAM;IACzB,CAAC,CACF"}
1
+ {"version":3,"file":"account.mjs","names":["#config","account.generateAuth","accountRegistry._new","account.share","account.depositFunds","account.withdrawFunds","account.loadAccount","account.balance"],"sources":["../src/account.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { bcs } from '@mysten/sui/bcs';\nimport type {\n\tTransaction,\n\tTransactionObjectArgument,\n\tTransactionResult,\n} from '@mysten/sui/transactions';\nimport { deriveObjectID } from '@mysten/sui/utils';\n\nimport * as account from './contracts/account/account.js';\nimport * as accountRegistry from './contracts/account/account_registry.js';\nimport type { AccountConfig as GeneratedAccountConfig } from './contracts/account/config-arguments.js';\nimport { MAINNET_ACCOUNT } from './deployments/mainnet.js';\nimport { TESTNET_ACCOUNT } from './deployments/testnet.js';\nimport type { NetworkArg } from './deployments/index.js';\n\n// Provenance: which on-chain deployment the ids above came from. Re-exported so a consumer\n// can answer \"which deploy is this build pinned to?\" without reaching for another subpath.\nexport { getDeployment, getUnits, TESTNET_DEPLOYMENT, TESTNET_UNITS } from './deployments/index.js';\nexport type { NetworkArg } from './deployments/index.js';\nexport type { DeployedNetwork } from './deployments/index.js';\n\n/**\n * The deployed ids of the shared `account` package this contract builds against.\n *\n * Kept deliberately minimal — ids only — so any consumer of the shared account primitive\n * (DeepBook core's account wrapper, Predict, …) can drive these builders with its OWN\n * deployment's ids without constructing a full product-SDK config.\n *\n * Extends the codegen-generated config interface so there is exactly one config shape and\n * casing: the generated bindings resolve `options.config` against these same keys, and if\n * codegen adds, drops, or renames a key this file stops compiling instead of silently\n * building a PTB against the wrong object. The ids are narrowed to `string` — codegen types\n * the package id as optional and the registry as the wider `ConfigValue`, but the\n * wrapper-address derivation needs plain ids.\n */\nexport interface AccountConfig extends GeneratedAccountConfig {\n\t/** The `account` Move package id. */\n\taccountPackageId: string;\n\t/** The shared `AccountRegistry` object id. */\n\taccountRegistry: string;\n}\n\n/**\n * @description The deployed `account` ids for `network`, so a caller does not transcribe\n * them. Generated from the deploy manifest — see `src/deployments/`.\n * @throws if the network has no recorded deployment, rather than returning placeholder ids\n * that would fail as a confusing on-chain abort.\n *\n * ```ts\n * const account = new AccountContract(getAccountConfig('testnet'));\n * ```\n */\nexport function getAccountConfig(network: NetworkArg): AccountConfig {\n\tif (network === 'testnet') return TESTNET_ACCOUNT;\n\tif (network === 'mainnet') return MAINNET_ACCOUNT;\n\tthrow new Error(\n\t\t`@mysten/deepbook-v3/account: no account deployment recorded for network '${network}'. ` +\n\t\t\t'The account primitive is recorded for testnet and mainnet; for your own deployment pass ' +\n\t\t\t'`{ accountPackageId, accountRegistry }` to AccountContract directly.',\n\t);\n}\n\n// `AccountWrapperKey(address)` is a one-field positional struct, so its BCS is just the\n// owner's 32-byte address. See `packages/account/sources/account_registry.move`.\nconst AccountWrapperKey = bcs.struct('AccountWrapperKey', {\n\tpos0: bcs.Address,\n});\n\n/**\n * AccountContract — the reusable on-chain account primitive (`packages/account`).\n *\n * An owner has one canonical `AccountWrapper`, a *derived* object of the account registry,\n * so its id is computable off-chain (no read). The wrapper holds an `Account` whose custody\n * balances apps deposit into and withdraw from; app-specific data hangs off it under an\n * app-keyed slot. Authority is a hot-potato `Auth` minted from the tx sender and consumed\n * by the very next account-loading call.\n */\nexport class AccountContract {\n\t#config: AccountConfig;\n\n\t/**\n\t * @param {AccountConfig} config Deployed ids of the shared `account` package\n\t */\n\tconstructor(config: AccountConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description The deterministic id of an owner's canonical account wrapper — no chain\n\t * read needed. The wrapper is a derived object of the account registry, so its id is\n\t * `derive_address(registry, AccountWrapperKey(owner))`.\n\t * @param {string} owner Owner address\n\t * @returns The wrapper object id\n\t */\n\tderiveAccountWrapperId(owner: string): string {\n\t\tconst key = AccountWrapperKey.serialize({ pos0: owner }).toBytes();\n\t\treturn deriveObjectID(\n\t\t\tthis.#config.accountRegistry,\n\t\t\t`${this.#config.accountPackageId}::account_registry::AccountWrapperKey`,\n\t\t\tkey,\n\t\t);\n\t}\n\n\t/**\n\t * @description Mint owner authority for the transaction sender. A hot-potato `Auth`\n\t * consumed by the very next account-loading call (`load_account_mut` inside\n\t * `deposit_funds` / `withdraw_funds` / an app's own entrypoints).\n\t * @returns A function that takes a Transaction object\n\t */\n\tgenerateAuth() {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(account.generateAuth({ config: this.#config }));\n\t}\n\n\t/**\n\t * @description Create the sender's canonical account wrapper and share it. `new` derives\n\t * the wrapper at its deterministic address (see `deriveAccountWrapperId`) and aborts if\n\t * it already exists; `share` publishes the shared object apps borrow against.\n\t * @returns A function that takes a Transaction object\n\t */\n\tcreateAccount() {\n\t\treturn (tx: Transaction): void => {\n\t\t\tconst wrapper = tx.add(accountRegistry._new({ config: this.#config }));\n\t\t\ttx.add(account.share({ config: this.#config, arguments: { self: wrapper } }));\n\t\t};\n\t}\n\n\t/**\n\t * @description First-time funding in ONE PTB: create the sender's wrapper, deposit\n\t * `coin` through the fresh handle, then `share` LAST (once shared, by-value use of the\n\t * handle is over). This cannot be split into `createAccount` + `depositFunds`: an object\n\t * input can only address an object that pre-exists the PTB, so a wrapper created inside\n\t * it is reachable only through `new`'s result handle.\n\t * @param {object} params Coin to deposit and its coin type\n\t * @returns A function that takes a Transaction object\n\t */\n\tcreateAccountAndDeposit(params: { coin: TransactionObjectArgument; coinType: string }) {\n\t\treturn (tx: Transaction): void => {\n\t\t\tconst wrapper = tx.add(accountRegistry._new({ config: this.#config }));\n\t\t\tconst auth = tx.add(this.generateAuth());\n\t\t\ttx.add(\n\t\t\t\taccount.depositFunds({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper, auth, coin: params.coin },\n\t\t\t\t\ttypeArguments: [params.coinType],\n\t\t\t\t}),\n\t\t\t);\n\t\t\ttx.add(account.share({ config: this.#config, arguments: { self: wrapper } }));\n\t\t};\n\t}\n\n\t/**\n\t * @description Deposit a caller-provided `coin` into the account's stored balance via the\n\t * PTB-callable `deposit_funds` (folds settle → authorize → load → deposit; clock and\n\t * accumulator root auto-injected). The caller owns coin sourcing.\n\t * @param {object} params Wrapper id, coin to deposit, and its coin type\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositFunds(params: { wrapperId: string; coin: TransactionObjectArgument; coinType: string }) {\n\t\treturn (tx: Transaction): void => {\n\t\t\tconst auth = tx.add(this.generateAuth());\n\t\t\ttx.add(\n\t\t\t\taccount.depositFunds({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper: params.wrapperId, auth, coin: params.coin },\n\t\t\t\t\ttypeArguments: [params.coinType],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * @description Withdraw `amount` (raw u64 units) from the account's stored balance via\n\t * the PTB-callable `withdraw_funds` (folds settle → authorize → load → withdraw; clock\n\t * and accumulator root auto-injected), returning the minted `Coin<T>` for the caller to\n\t * transfer or compose.\n\t * @param {object} params Wrapper id, raw amount, and coin type\n\t * @returns A function that takes a Transaction object and returns the `Coin<T>`\n\t */\n\twithdrawFunds(params: { wrapperId: string; amount: bigint; coinType: string }) {\n\t\treturn (tx: Transaction): TransactionResult => {\n\t\t\tconst auth = tx.add(this.generateAuth());\n\t\t\treturn tx.add(\n\t\t\t\taccount.withdrawFunds({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper: params.wrapperId, auth, amount: params.amount },\n\t\t\t\t\ttypeArguments: [params.coinType],\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * @description Borrow the `Account` out of its wrapper — the read-side entry point apps\n\t * chain their own getters onto (`account::balance<T>`, an app's own data accessors).\n\t * @param {object} params Wrapper id\n\t * @returns A function that takes a Transaction object and returns the `Account`\n\t */\n\tloadAccount(params: { wrapperId: string }) {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(account.loadAccount({ config: this.#config, arguments: { self: params.wrapperId } }));\n\t}\n\n\t/**\n\t * @description Read an owner's stored custody balance for a coin type: chains\n\t * `load_account(wrapper)` → `balance<T>(account, root, clock)`. Compose in a\n\t * dev-inspect/simulate PTB and read the u64 return of the LAST command.\n\t * @param {object} params Owner address and coin type\n\t * @returns A function that takes a Transaction object\n\t */\n\tbalance(params: { owner: string; coinType: string }) {\n\t\treturn (tx: Transaction): TransactionResult => {\n\t\t\tconst acct = tx.add(\n\t\t\t\tthis.loadAccount({ wrapperId: this.deriveAccountWrapperId(params.owner) }),\n\t\t\t);\n\t\t\treturn tx.add(\n\t\t\t\taccount.balance({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\ttypeArguments: [params.coinType],\n\t\t\t\t\targuments: { self: acct },\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n}\n\n// === Generated bindings ===\n// The move-call thunks and BCS structs, for consumers composing their own PTBs or\n// parsing account objects/events (e.g. `AccountWrapper.parse`, the event layouts).\n//\n// NOTE: `Account` here is the shared account primitive's custody account\n// (`account::account::Account`). It is deliberately NOT re-exported from this\n// package's root — the root already exports a different `Account`\n// (`@deepbook/core::account::Account`, the per-pool trading account) and the two\n// have unrelated layouts. Keep them separated by subpath.\nexport * as accountMoveCalls from './contracts/account/account.js';\nexport * as accountRegistryMoveCalls from './contracts/account/account_registry.js';\nexport * as accountEvents from './contracts/account/account_events.js';\nexport { Account, AccountWrapper } from './contracts/account/account.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,iBAAiB,SAAoC;AACpE,KAAI,YAAY,UAAW,QAAO;AAClC,KAAI,YAAY,UAAW,QAAO;AAClC,OAAM,IAAI,MACT,4EAA4E,QAAQ,mKAGpF;;AAKF,MAAM,oBAAoB,IAAI,OAAO,qBAAqB,EACzD,MAAM,IAAI,SACV,CAAC;;;;;;;;;;AAWF,IAAa,kBAAb,MAA6B;CAC5B;;;;CAKA,YAAY,QAAuB;AAClC,QAAKA,SAAU;;;;;;;;;CAUhB,uBAAuB,OAAuB;EAC7C,MAAM,MAAM,kBAAkB,UAAU,EAAE,MAAM,OAAO,CAAC,CAAC,SAAS;AAClE,SAAO,eACN,MAAKA,OAAQ,iBACb,GAAG,MAAKA,OAAQ,iBAAiB,wCACjC,IACA;;;;;;;;CASF,eAAe;AACd,UAAQ,OACP,GAAG,IAAIC,aAAqB,EAAE,QAAQ,MAAKD,QAAS,CAAC,CAAC;;;;;;;;CASxD,gBAAgB;AACf,UAAQ,OAA0B;GACjC,MAAM,UAAU,GAAG,IAAIE,KAAqB,EAAE,QAAQ,MAAKF,QAAS,CAAC,CAAC;AACtE,MAAG,IAAIG,MAAc;IAAE,QAAQ,MAAKH;IAAS,WAAW,EAAE,MAAM,SAAS;IAAE,CAAC,CAAC;;;;;;;;;;;;CAa/E,wBAAwB,QAA+D;AACtF,UAAQ,OAA0B;GACjC,MAAM,UAAU,GAAG,IAAIE,KAAqB,EAAE,QAAQ,MAAKF,QAAS,CAAC,CAAC;GACtE,MAAM,OAAO,GAAG,IAAI,KAAK,cAAc,CAAC;AACxC,MAAG,IACFI,aAAqB;IACpB,QAAQ,MAAKJ;IACb,WAAW;KAAE;KAAS;KAAM,MAAM,OAAO;KAAM;IAC/C,eAAe,CAAC,OAAO,SAAS;IAChC,CAAC,CACF;AACD,MAAG,IAAIG,MAAc;IAAE,QAAQ,MAAKH;IAAS,WAAW,EAAE,MAAM,SAAS;IAAE,CAAC,CAAC;;;;;;;;;;CAW/E,aAAa,QAAkF;AAC9F,UAAQ,OAA0B;GACjC,MAAM,OAAO,GAAG,IAAI,KAAK,cAAc,CAAC;AACxC,MAAG,IACFI,aAAqB;IACpB,QAAQ,MAAKJ;IACb,WAAW;KAAE,SAAS,OAAO;KAAW;KAAM,MAAM,OAAO;KAAM;IACjE,eAAe,CAAC,OAAO,SAAS;IAChC,CAAC,CACF;;;;;;;;;;;CAYH,cAAc,QAAiE;AAC9E,UAAQ,OAAuC;GAC9C,MAAM,OAAO,GAAG,IAAI,KAAK,cAAc,CAAC;AACxC,UAAO,GAAG,IACTK,cAAsB;IACrB,QAAQ,MAAKL;IACb,WAAW;KAAE,SAAS,OAAO;KAAW;KAAM,QAAQ,OAAO;KAAQ;IACrE,eAAe,CAAC,OAAO,SAAS;IAChC,CAAC,CACF;;;;;;;;;CAUH,YAAY,QAA+B;AAC1C,UAAQ,OACP,GAAG,IAAIM,YAAoB;GAAE,QAAQ,MAAKN;GAAS,WAAW,EAAE,MAAM,OAAO,WAAW;GAAE,CAAC,CAAC;;;;;;;;;CAU9F,QAAQ,QAA6C;AACpD,UAAQ,OAAuC;GAC9C,MAAM,OAAO,GAAG,IACf,KAAK,YAAY,EAAE,WAAW,KAAK,uBAAuB,OAAO,MAAM,EAAE,CAAC,CAC1E;AACD,UAAO,GAAG,IACTO,QAAgB;IACf,QAAQ,MAAKP;IACb,eAAe,CAAC,OAAO,SAAS;IAChC,WAAW,EAAE,MAAM,MAAM;IACzB,CAAC,CACF"}
package/dist/client.d.mts CHANGED
@@ -163,7 +163,7 @@ declare class DeepBookClient {
163
163
  }[] | null>;
164
164
  getLevel2Range(poolKey: string, priceLow: number | bigint, priceHigh: number | bigint, isBid: boolean): Promise<Level2Range>;
165
165
  getLevel2TicksFromMid(poolKey: string, ticks: number): Promise<Level2TicksFromMid>;
166
- getAccountOrderDetails(poolKey: string, managerKey: string): Promise<[] | {
166
+ getAccountOrderDetails(poolKey: string, managerKey: string): Promise<{
167
167
  balance_manager_id: string;
168
168
  order_id: string;
169
169
  client_order_id: string;
@@ -177,7 +177,7 @@ declare class DeepBookClient {
177
177
  epoch: string;
178
178
  status: number;
179
179
  expire_timestamp: string;
180
- }[]>;
180
+ }[] | []>;
181
181
  account(poolKey: string, managerKey: string): Promise<AccountInfo>;
182
182
  lockedBalance(poolKey: string, balanceManagerKey: string): Promise<LockedBalances>;
183
183
  getPoolDeepPrice(poolKey: string): Promise<PoolDeepPrice>;