@mysten/deepbook-v3 2.1.4 → 2.3.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.
- package/CHANGELOG.md +43 -0
- package/PREDICT.md +17 -5
- package/dist/account.d.mts.map +1 -1
- package/dist/account.mjs +3 -1
- package/dist/account.mjs.map +1 -1
- package/dist/client.d.mts +2 -2
- package/dist/contracts/account/account_events.d.mts +20 -20
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook_predict/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook_predict/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_cash.mjs +1 -1
- package/dist/contracts/deepbook_predict/expiry_cash.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/expiry_market.mjs +15 -6
- package/dist/contracts/deepbook_predict/expiry_market.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/market_manager.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/order_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/plp.mjs +53 -31
- package/dist/contracts/deepbook_predict/plp.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pool_accounting.mjs +7 -7
- package/dist/contracts/deepbook_predict/pool_accounting.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/predict_account.mjs +1 -1
- package/dist/contracts/deepbook_predict/predict_account.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pricing.mjs +13 -1
- package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/registry.mjs +2 -1
- package/dist/contracts/deepbook_predict/registry.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/strike_exposure.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs +13 -1
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/vault_events.mjs +19 -7
- package/dist/contracts/deepbook_predict/vault_events.mjs.map +1 -1
- package/dist/contracts/deepbook_sessions/session_config.d.mts +8 -8
- package/dist/contracts/deepbook_sessions/session_config.d.mts.map +1 -1
- package/dist/contracts/deepbook_sessions/sessions.d.mts +22 -22
- package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -1
- package/dist/deployments/index.d.mts +3 -2
- package/dist/deployments/index.d.mts.map +1 -1
- package/dist/deployments/index.mjs +4 -1
- package/dist/deployments/index.mjs.map +1 -1
- package/dist/deployments/mainnet.d.mts +14 -0
- package/dist/deployments/mainnet.d.mts.map +1 -0
- package/dist/deployments/mainnet.mjs +73 -0
- package/dist/deployments/mainnet.mjs.map +1 -0
- package/dist/deployments/testnet.mjs +23 -23
- package/dist/deployments/testnet.mjs.map +1 -1
- package/dist/deployments/types.d.mts +1 -1
- package/dist/predict/client.d.mts +25 -4
- package/dist/predict/client.d.mts.map +1 -1
- package/dist/predict/client.mjs +4 -4
- package/dist/predict/client.mjs.map +1 -1
- package/dist/predict/config/index.d.mts +2 -0
- package/dist/predict/config/index.d.mts.map +1 -1
- package/dist/predict/config/index.mjs +4 -1
- package/dist/predict/config/index.mjs.map +1 -1
- package/dist/predict/config/mainnet.d.mts +17 -0
- package/dist/predict/config/mainnet.d.mts.map +1 -0
- package/dist/predict/config/mainnet.mjs +26 -0
- package/dist/predict/config/mainnet.mjs.map +1 -0
- package/dist/predict/config/types.d.mts +6 -0
- package/dist/predict/config/types.d.mts.map +1 -1
- package/dist/predict/index.d.mts +4 -2
- package/dist/predict/index.mjs +3 -1
- package/dist/predict/pricing.d.mts +6 -6
- package/dist/predict/pricing.d.mts.map +1 -1
- package/dist/predict/pricing.mjs +6 -6
- package/dist/predict/pricing.mjs.map +1 -1
- package/dist/predict/reads/balances.mjs.map +1 -1
- package/dist/predict/reads/markets.mjs +1 -1
- package/dist/predict/reads/markets.mjs.map +1 -1
- package/dist/predict/reads/pricing.d.mts +2 -1
- package/dist/predict/reads/pricing.d.mts.map +1 -1
- package/dist/predict/reads/pricing.mjs.map +1 -1
- package/dist/sessions.d.mts.map +1 -1
- package/dist/sessions.mjs +3 -1
- package/dist/sessions.mjs.map +1 -1
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/balanceManager.d.mts.map +1 -1
- package/dist/transactions/deepbook.d.mts +20 -20
- package/dist/transactions/deepbook.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.d.mts +4 -4
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +7 -7
- package/dist/transactions/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginPool.d.mts.map +1 -1
- package/dist/transactions/marginRegistry.d.mts +16 -16
- package/dist/transactions/marginTPSL.d.mts +10 -10
- package/dist/transactions/poolProxy.d.mts +8 -8
- package/package.json +3 -3
- package/src/account.ts +3 -1
- package/src/contracts/deepbook_predict/builder_code.ts +3 -3
- package/src/contracts/deepbook_predict/config_events.ts +9 -2
- package/src/contracts/deepbook_predict/deps/sui/vec_map.ts +33 -0
- package/src/contracts/deepbook_predict/expiry_cash.ts +1 -1
- package/src/contracts/deepbook_predict/expiry_market.ts +70 -11
- package/src/contracts/deepbook_predict/market_lifecycle_cap.ts +3 -10
- package/src/contracts/deepbook_predict/market_manager.ts +2 -2
- package/src/contracts/deepbook_predict/order_events.ts +6 -6
- package/src/contracts/deepbook_predict/plp.ts +263 -81
- package/src/contracts/deepbook_predict/pool_accounting.ts +14 -14
- package/src/contracts/deepbook_predict/pool_valuation_cap.ts +69 -0
- package/src/contracts/deepbook_predict/predict_account.ts +1 -1
- package/src/contracts/deepbook_predict/pricing.ts +16 -4
- package/src/contracts/deepbook_predict/protocol_config.ts +202 -7
- package/src/contracts/deepbook_predict/registry.ts +91 -17
- package/src/contracts/deepbook_predict/strike_exposure.ts +1 -1
- package/src/contracts/deepbook_predict/strike_payout_tree.ts +27 -0
- package/src/contracts/deepbook_predict/vault_events.ts +45 -14
- package/src/contracts/propbook/block_scholes_store.ts +8 -42
- package/src/deployments/index.ts +13 -3
- package/src/deployments/mainnet.ts +107 -0
- package/src/deployments/testnet.ts +25 -25
- package/src/deployments/types.ts +1 -1
- package/src/predict/client.ts +45 -15
- package/src/predict/config/index.ts +7 -2
- package/src/predict/config/mainnet.ts +27 -0
- package/src/predict/config/types.ts +7 -1
- package/src/predict/index.ts +5 -0
- package/src/predict/pricing.ts +11 -9
- package/src/predict/reads/balances.ts +1 -1
- package/src/predict/reads/markets.ts +1 -1
- package/src/predict/reads/pricing.ts +2 -1
- package/src/sessions.ts +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# @mysten/deepbook-v3
|
|
2
2
|
|
|
3
|
+
## 2.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7b47a9a: Predict: let `supplyPlp` and `withdrawPlp` set a price floor. Both hard-pinned the
|
|
8
|
+
request's floor to 0, so the SDK could only ever queue an LP request that accepts whatever mark
|
|
9
|
+
the next pool flush quotes. They now take an optional third argument — `{ minPlpOut }` (raw
|
|
10
|
+
`bigint` shares) and `{ minUsdcOut }` (USD decimals) — defaulting to the previous no-floor
|
|
11
|
+
behaviour.
|
|
12
|
+
- 1e2f728: Add Mainnet deployment ids for Predict, sessions and the account primitive. `getConfig`,
|
|
13
|
+
`getAccountConfig`, `getSessionsConfig`, `getUnits` and `getDeployment` now resolve `'mainnet'`
|
|
14
|
+
instead of throwing, and `MAINNET_CONFIG` / `MAINNET_DEPLOYMENT` / `MAINNET_UNITS` are exported
|
|
15
|
+
alongside their testnet counterparts. `DeployedNetwork` widens to `'testnet' | 'mainnet'`.
|
|
16
|
+
|
|
17
|
+
Mainnet settles in Circle's native USDC
|
|
18
|
+
(`0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC`). The in-repo
|
|
19
|
+
test currency is never published to Mainnet, so the collateral type resolves to Circle's package
|
|
20
|
+
there and to the DeepBook test coin on Testnet — read `quoteCoinType` from the config rather than
|
|
21
|
+
assuming either.
|
|
22
|
+
|
|
23
|
+
The ids are generated from the deploy tooling's own Mainnet manifest, like Testnet's, so both
|
|
24
|
+
networks move together on a redeploy and cannot drift apart across subpaths.
|
|
25
|
+
|
|
26
|
+
## 2.2.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- e7c8014: Target the `deepbook-predict-testnet` deployment. Every testnet id the SDK ships changes
|
|
31
|
+
— the Predict, account and sessions packages and their shared objects — so `getConfig('testnet')`,
|
|
32
|
+
`getAccountConfig('testnet')`, `getSessionsConfig('testnet')` and `TESTNET_CONFIG` all resolve
|
|
33
|
+
against the new deployment, and `getDeployment('testnet')` reports it by name and source commit.
|
|
34
|
+
Anything pinned to the previous testnet deployment's ids will not find its accounts, positions or
|
|
35
|
+
markets there; they are separate deployments, not an upgrade.
|
|
36
|
+
|
|
37
|
+
The settlement collateral is renamed upstream from `dusdc::dusdc::DUSDC` to `usdc::usdc::USDC`, so
|
|
38
|
+
one Move module path resolves on both testnet and mainnet and mainnet can link native USDC by
|
|
39
|
+
address alone. `quoteCoinType` carries the new type. The testnet coin keeps the `DUSDC` display
|
|
40
|
+
symbol, which is what distinguishes the mintable test coin from native USDC in wallets and
|
|
41
|
+
explorers — read `quoteCoinType` rather than assuming a symbol or a type.
|
|
42
|
+
|
|
43
|
+
The exported surface is otherwise unchanged: no symbol is added, removed or re-typed, and the
|
|
44
|
+
renamed Move argument (`min_usdc_out`) is internal to the transaction builders.
|
|
45
|
+
|
|
3
46
|
## 2.1.4
|
|
4
47
|
|
|
5
48
|
## 2.1.3
|
package/PREDICT.md
CHANGED
|
@@ -32,10 +32,10 @@ const client = new SuiGrpcClient({
|
|
|
32
32
|
// One-time: create your Predict account (a shared AccountWrapper).
|
|
33
33
|
const createTx = client.predict.tx.createManager();
|
|
34
34
|
|
|
35
|
-
// Fund it: pulls
|
|
35
|
+
// Fund it: pulls USDC from your address (coin objects and/or address balance).
|
|
36
36
|
const depositTx = client.predict.tx.deposit(myAddress, 250); // $250
|
|
37
37
|
|
|
38
|
-
// Cash out: lands in your
|
|
38
|
+
// Cash out: lands in your USDC address balance by default (no coin-object churn).
|
|
39
39
|
// Pass { toCoinObject: true } if you need a discrete Coin<T> instead.
|
|
40
40
|
const withdrawTx = client.predict.tx.withdraw(myAddress, 100); // $100
|
|
41
41
|
|
|
@@ -101,7 +101,7 @@ reads use the primitives layer, which returns raw `bigint`s (`accountBalance`, `
|
|
|
101
101
|
|
|
102
102
|
| Concept | You pass / receive | On-chain raw |
|
|
103
103
|
| ------------------------------------------- | -------------------------------------------------------------- | ------------------------------------- |
|
|
104
|
-
| Amounts (deposit, spend, maxCost, balances) | USD decimal number or string (`12.5`, `"12.5"`) | ×1e6 (
|
|
104
|
+
| Amounts (deposit, spend, maxCost, balances) | USD decimal number or string (`12.5`, `"12.5"`) | ×1e6 (USDC) |
|
|
105
105
|
| `quantity` | **max payout** in USD; positions pay $1 per contract at expiry | ×1e6, in $0.01 lots |
|
|
106
106
|
| `strike` | USD (`105_000`) | ×1e9, must land on the admission grid |
|
|
107
107
|
| `maxProbability` | 0..1 (`0.35` = 35¢ per $1 contract) | ×1e9 |
|
|
@@ -109,6 +109,11 @@ reads use the primitives layer, which returns raw `bigint`s (`accountBalance`, `
|
|
|
109
109
|
|
|
110
110
|
`side: "up"` wins if the settlement price is above the strike; `"down"` below.
|
|
111
111
|
|
|
112
|
+
Trading closes slightly before expiry: the protocol enforces a short pre-expiry no-trade window
|
|
113
|
+
(`no_trade_window_ms` on the live `ProtocolConfig`, 2s on the current testnet deployment), so a mint
|
|
114
|
+
or redeem submitted inside it aborts `ETradeWindowClosed` rather than filling. Treat the last
|
|
115
|
+
seconds of a window as untradeable rather than retrying.
|
|
116
|
+
|
|
112
117
|
## Reference-price markets (Polymarket-style windows)
|
|
113
118
|
|
|
114
119
|
Each market carries an on-chain **reference price** — derived from the exact previous-window oracle
|
|
@@ -233,11 +238,18 @@ stop requiring an SDK release for target resolution.
|
|
|
233
238
|
as the cheap validator.
|
|
234
239
|
- PLP supply/withdraw are queued and fill at the next pool flush; cancels take the queue `index` —
|
|
235
240
|
get it from `decode.plpRequest(result).index`.
|
|
241
|
+
- **Both take an optional price floor**, and default to none:
|
|
242
|
+
`supplyPlp(owner, amount, { minPlpOut })` (raw `bigint` shares) and
|
|
243
|
+
`withdrawPlp(owner, shares, { minUsdcOut })` (USD decimals). Each floors the flush's MARK for the
|
|
244
|
+
whole request rather than naming a quantity — a flush quoting less declines instead of filling
|
|
245
|
+
smaller. What a miss costs is the deployment's `lp_request_limit_flush_attempts`: at the shipped
|
|
246
|
+
count of one, the first flush below the floor cancels the request and refunds it, so re-queueing
|
|
247
|
+
is a fresh transaction. Leave the floor off and the request takes whatever mark the flush quotes.
|
|
236
248
|
- `claimSettled` closes the order in full — the deployed entrypoint takes no quantity.
|
|
237
249
|
- **`withdraw` lands in your address balance by default** (`0x2::coin::send_funds`), not a coin
|
|
238
250
|
object — it merges into the versionless accumulator `deposit` already draws from, so the round
|
|
239
|
-
trip never accretes stray `Coin<
|
|
240
|
-
internal custody balance; use the client's `getBalance(owner)` for the wallet-side
|
|
251
|
+
trip never accretes stray `Coin<USDC>` objects. `read.balance(owner)` reflects the account's
|
|
252
|
+
internal custody balance; use the client's `getBalance(owner)` for the wallet-side USDC total
|
|
241
253
|
(coin objects + address balance). Pass `withdraw(owner, amt, { toCoinObject: true })` for a
|
|
242
254
|
discrete coin (wallets/explorers that only render coin objects, or same-PTB composition).
|
|
243
255
|
|
package/dist/account.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.mts","names":[],"sources":["../src/account.ts"],"mappings":";;;;;;;;;;;;
|
|
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
|
-
|
|
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
|
/**
|
package/dist/account.mjs.map
CHANGED
|
@@ -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>;
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import { MoveStruct } from "../utils/index.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_sui_bcs7 from "@mysten/sui/bcs";
|
|
3
3
|
|
|
4
4
|
//#region src/contracts/account/account_events.d.ts
|
|
5
5
|
declare namespace account_events_d_exports {
|
|
6
6
|
export { AccountCreated, AppAuthorized, AppDeauthorized, Deposited, FundsSettled, Withdrawn };
|
|
7
7
|
}
|
|
8
8
|
declare const AccountCreated: MoveStruct<{
|
|
9
|
-
account_id:
|
|
10
|
-
wrapper_id:
|
|
11
|
-
owner:
|
|
12
|
-
self_owned:
|
|
13
|
-
referrer_account_id:
|
|
9
|
+
account_id: _mysten_sui_bcs7.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
10
|
+
wrapper_id: _mysten_sui_bcs7.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
11
|
+
owner: _mysten_sui_bcs7.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
12
|
+
self_owned: _mysten_sui_bcs7.BcsType<boolean, boolean, "bool">;
|
|
13
|
+
referrer_account_id: _mysten_sui_bcs7.BcsType<string | null, string | Uint8Array<ArrayBufferLike> | null | undefined, "Option<bytes[32]>">;
|
|
14
14
|
}, "@local-pkg/account::account_events::AccountCreated">;
|
|
15
15
|
declare const AppAuthorized: MoveStruct<{
|
|
16
|
-
/** Fully-qualified `App` witness type name. */app:
|
|
16
|
+
/** Fully-qualified `App` witness type name. */app: _mysten_sui_bcs7.BcsType<string, string, "string">;
|
|
17
17
|
}, "@local-pkg/account::account_events::AppAuthorized">;
|
|
18
18
|
declare const AppDeauthorized: MoveStruct<{
|
|
19
|
-
app:
|
|
19
|
+
app: _mysten_sui_bcs7.BcsType<string, string, "string">;
|
|
20
20
|
}, "@local-pkg/account::account_events::AppDeauthorized">;
|
|
21
21
|
declare const Deposited: MoveStruct<{
|
|
22
|
-
account_id:
|
|
23
|
-
coin_type:
|
|
24
|
-
amount:
|
|
25
|
-
new_balance:
|
|
22
|
+
account_id: _mysten_sui_bcs7.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
23
|
+
coin_type: _mysten_sui_bcs7.BcsType<string, string, "string">;
|
|
24
|
+
amount: _mysten_sui_bcs7.BcsType<bigint, string | number | bigint, "u64">;
|
|
25
|
+
new_balance: _mysten_sui_bcs7.BcsType<bigint, string | number | bigint, "u64">;
|
|
26
26
|
}, "@local-pkg/account::account_events::Deposited">;
|
|
27
27
|
declare const Withdrawn: MoveStruct<{
|
|
28
|
-
account_id:
|
|
29
|
-
coin_type:
|
|
30
|
-
amount:
|
|
31
|
-
new_balance:
|
|
28
|
+
account_id: _mysten_sui_bcs7.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
29
|
+
coin_type: _mysten_sui_bcs7.BcsType<string, string, "string">;
|
|
30
|
+
amount: _mysten_sui_bcs7.BcsType<bigint, string | number | bigint, "u64">;
|
|
31
|
+
new_balance: _mysten_sui_bcs7.BcsType<bigint, string | number | bigint, "u64">;
|
|
32
32
|
}, "@local-pkg/account::account_events::Withdrawn">;
|
|
33
33
|
declare const FundsSettled: MoveStruct<{
|
|
34
|
-
account_id:
|
|
35
|
-
coin_type:
|
|
36
|
-
amount:
|
|
37
|
-
new_balance:
|
|
34
|
+
account_id: _mysten_sui_bcs7.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
35
|
+
coin_type: _mysten_sui_bcs7.BcsType<string, string, "string">;
|
|
36
|
+
amount: _mysten_sui_bcs7.BcsType<bigint, string | number | bigint, "u64">;
|
|
37
|
+
new_balance: _mysten_sui_bcs7.BcsType<bigint, string | number | bigint, "u64">;
|
|
38
38
|
}, "@local-pkg/account::account_events::FundsSettled">;
|
|
39
39
|
//#endregion
|
|
40
40
|
export { account_events_d_exports };
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { MoveStruct } from "../utils/index.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_sui_bcs82 from "@mysten/sui/bcs";
|
|
3
3
|
import { Transaction, TransactionArgument } from "@mysten/sui/transactions";
|
|
4
4
|
|
|
5
5
|
//#region src/contracts/deepbook/account.d.ts
|
|
6
6
|
declare const Account: MoveStruct<{
|
|
7
|
-
epoch:
|
|
7
|
+
epoch: _mysten_sui_bcs82.BcsType<string, string | number | bigint, "u64">;
|
|
8
8
|
open_orders: MoveStruct<{
|
|
9
|
-
contents:
|
|
9
|
+
contents: _mysten_sui_bcs82.BcsType<string[], Iterable<string | number | bigint> & {
|
|
10
10
|
length: number;
|
|
11
11
|
}, string>;
|
|
12
12
|
}, "0x2::vec_set::VecSet<u128>">;
|
|
13
|
-
taker_volume:
|
|
14
|
-
maker_volume:
|
|
15
|
-
active_stake:
|
|
16
|
-
inactive_stake:
|
|
17
|
-
created_proposal:
|
|
18
|
-
voted_proposal:
|
|
13
|
+
taker_volume: _mysten_sui_bcs82.BcsType<string, string | number | bigint, "u128">;
|
|
14
|
+
maker_volume: _mysten_sui_bcs82.BcsType<string, string | number | bigint, "u128">;
|
|
15
|
+
active_stake: _mysten_sui_bcs82.BcsType<string, string | number | bigint, "u64">;
|
|
16
|
+
inactive_stake: _mysten_sui_bcs82.BcsType<string, string | number | bigint, "u64">;
|
|
17
|
+
created_proposal: _mysten_sui_bcs82.BcsType<boolean, boolean, "bool">;
|
|
18
|
+
voted_proposal: _mysten_sui_bcs82.BcsType<string | null, string | Uint8Array<ArrayBufferLike> | null | undefined, "Option<bytes[32]>">;
|
|
19
19
|
unclaimed_rebates: MoveStruct<{
|
|
20
|
-
base:
|
|
21
|
-
quote:
|
|
22
|
-
deep:
|
|
20
|
+
base: _mysten_sui_bcs82.BcsType<string, string | number | bigint, "u64">;
|
|
21
|
+
quote: _mysten_sui_bcs82.BcsType<string, string | number | bigint, "u64">;
|
|
22
|
+
deep: _mysten_sui_bcs82.BcsType<string, string | number | bigint, "u64">;
|
|
23
23
|
}, "@deepbook/core::balances::Balances">;
|
|
24
24
|
settled_balances: MoveStruct<{
|
|
25
|
-
base:
|
|
26
|
-
quote:
|
|
27
|
-
deep:
|
|
25
|
+
base: _mysten_sui_bcs82.BcsType<string, string | number | bigint, "u64">;
|
|
26
|
+
quote: _mysten_sui_bcs82.BcsType<string, string | number | bigint, "u64">;
|
|
27
|
+
deep: _mysten_sui_bcs82.BcsType<string, string | number | bigint, "u64">;
|
|
28
28
|
}, "@deepbook/core::balances::Balances">;
|
|
29
29
|
owed_balances: MoveStruct<{
|
|
30
|
-
base:
|
|
31
|
-
quote:
|
|
32
|
-
deep:
|
|
30
|
+
base: _mysten_sui_bcs82.BcsType<string, string | number | bigint, "u64">;
|
|
31
|
+
quote: _mysten_sui_bcs82.BcsType<string, string | number | bigint, "u64">;
|
|
32
|
+
deep: _mysten_sui_bcs82.BcsType<string, string | number | bigint, "u64">;
|
|
33
33
|
}, "@deepbook/core::balances::Balances">;
|
|
34
34
|
}, "@deepbook/core::account::Account">;
|
|
35
35
|
//#endregion
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { MoveStruct } from "../utils/index.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_sui_bcs47 from "@mysten/sui/bcs";
|
|
3
3
|
|
|
4
4
|
//#region src/contracts/deepbook/balances.d.ts
|
|
5
5
|
declare const Balances: MoveStruct<{
|
|
6
|
-
base:
|
|
7
|
-
quote:
|
|
8
|
-
deep:
|
|
6
|
+
base: _mysten_sui_bcs47.BcsType<string, string | number | bigint, "u64">;
|
|
7
|
+
quote: _mysten_sui_bcs47.BcsType<string, string | number | bigint, "u64">;
|
|
8
|
+
deep: _mysten_sui_bcs47.BcsType<string, string | number | bigint, "u64">;
|
|
9
9
|
}, "@deepbook/core::balances::Balances">;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { Balances };
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { MoveStruct } from "../utils/index.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_sui_bcs50 from "@mysten/sui/bcs";
|
|
3
3
|
import { Transaction, TransactionArgument } from "@mysten/sui/transactions";
|
|
4
4
|
|
|
5
5
|
//#region src/contracts/deepbook/order.d.ts
|
|
6
6
|
declare const Order: MoveStruct<{
|
|
7
|
-
balance_manager_id:
|
|
8
|
-
order_id:
|
|
9
|
-
client_order_id:
|
|
10
|
-
quantity:
|
|
11
|
-
filled_quantity:
|
|
12
|
-
fee_is_deep:
|
|
7
|
+
balance_manager_id: _mysten_sui_bcs50.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
8
|
+
order_id: _mysten_sui_bcs50.BcsType<string, string | number | bigint, "u128">;
|
|
9
|
+
client_order_id: _mysten_sui_bcs50.BcsType<string, string | number | bigint, "u64">;
|
|
10
|
+
quantity: _mysten_sui_bcs50.BcsType<string, string | number | bigint, "u64">;
|
|
11
|
+
filled_quantity: _mysten_sui_bcs50.BcsType<string, string | number | bigint, "u64">;
|
|
12
|
+
fee_is_deep: _mysten_sui_bcs50.BcsType<boolean, boolean, "bool">;
|
|
13
13
|
order_deep_price: MoveStruct<{
|
|
14
|
-
asset_is_base:
|
|
15
|
-
deep_per_asset:
|
|
14
|
+
asset_is_base: _mysten_sui_bcs50.BcsType<boolean, boolean, "bool">;
|
|
15
|
+
deep_per_asset: _mysten_sui_bcs50.BcsType<string, string | number | bigint, "u64">;
|
|
16
16
|
}, "@deepbook/core::deep_price::OrderDeepPrice">;
|
|
17
|
-
epoch:
|
|
18
|
-
status:
|
|
19
|
-
expire_timestamp:
|
|
17
|
+
epoch: _mysten_sui_bcs50.BcsType<string, string | number | bigint, "u64">;
|
|
18
|
+
status: _mysten_sui_bcs50.BcsType<number, number, "u8">;
|
|
19
|
+
expire_timestamp: _mysten_sui_bcs50.BcsType<string, string | number | bigint, "u64">;
|
|
20
20
|
}, "@deepbook/core::order::Order">;
|
|
21
21
|
//#endregion
|
|
22
22
|
export { Order };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { MoveStruct } from "../../../utils/index.mjs";
|
|
2
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/deepbook_predict/deps/sui/vec_map.ts
|
|
5
|
+
/**************************************************************
|
|
6
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
7
|
+
**************************************************************/
|
|
8
|
+
const $moduleName = "0x2::vec_map";
|
|
9
|
+
/** An entry in the map */
|
|
10
|
+
function Entry(...typeParameters) {
|
|
11
|
+
return new MoveStruct({
|
|
12
|
+
name: `${$moduleName}::Entry<${typeParameters[0].name}, ${typeParameters[1].name}>`,
|
|
13
|
+
fields: {
|
|
14
|
+
key: typeParameters[0],
|
|
15
|
+
value: typeParameters[1]
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A map data structure backed by a vector. The map is guaranteed not to contain
|
|
21
|
+
* duplicate keys, but entries are _not_ sorted by key--entries are included in
|
|
22
|
+
* insertion order. All operations are O(N) in the size of the map--the intention
|
|
23
|
+
* of this data structure is only to provide the convenience of programming against
|
|
24
|
+
* a map API. Large maps should use handwritten parent/child relationships instead.
|
|
25
|
+
* Maps that need sorted iteration rather than insertion order iteration should
|
|
26
|
+
* also be handwritten.
|
|
27
|
+
*/
|
|
28
|
+
function VecMap(...typeParameters) {
|
|
29
|
+
return new MoveStruct({
|
|
30
|
+
name: `${$moduleName}::VecMap<${typeParameters[0].name}, ${typeParameters[1].name}>`,
|
|
31
|
+
fields: { contents: bcs.vector(Entry(typeParameters[0], typeParameters[1])) }
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { VecMap };
|
|
37
|
+
//# sourceMappingURL=vec_map.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vec_map.mjs","names":[],"sources":["../../../../../src/contracts/deepbook_predict/deps/sui/vec_map.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { type BcsType, bcs } from '@mysten/sui/bcs';\nimport { MoveStruct } from '../../../utils/index.js';\nconst $moduleName = '0x2::vec_map';\n/** An entry in the map */\nexport function Entry<K extends BcsType<any>, V extends BcsType<any>>(...typeParameters: [K, V]) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::Entry<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`,\n\t\tfields: {\n\t\t\tkey: typeParameters[0],\n\t\t\tvalue: typeParameters[1],\n\t\t},\n\t});\n}\n/**\n * A map data structure backed by a vector. The map is guaranteed not to contain\n * duplicate keys, but entries are _not_ sorted by key--entries are included in\n * insertion order. All operations are O(N) in the size of the map--the intention\n * of this data structure is only to provide the convenience of programming against\n * a map API. Large maps should use handwritten parent/child relationships instead.\n * Maps that need sorted iteration rather than insertion order iteration should\n * also be handwritten.\n */\nexport function VecMap<K extends BcsType<any>, V extends BcsType<any>>(...typeParameters: [K, V]) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::VecMap<${typeParameters[0].name as K['name']}, ${typeParameters[1].name as V['name']}>`,\n\t\tfields: {\n\t\t\tcontents: bcs.vector(Entry(typeParameters[0], typeParameters[1])),\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;;AAKA,MAAM,cAAc;;AAEpB,SAAgB,MAAsD,GAAG,gBAAwB;AAChG,QAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,UAAU,eAAe,GAAG,KAAkB,IAAI,eAAe,GAAG,KAAkB;EAC3G,QAAQ;GACP,KAAK,eAAe;GACpB,OAAO,eAAe;GACtB;EACD,CAAC;;;;;;;;;;;AAWH,SAAgB,OAAuD,GAAG,gBAAwB;AACjG,QAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,WAAW,eAAe,GAAG,KAAkB,IAAI,eAAe,GAAG,KAAkB;EAC5G,QAAQ,EACP,UAAU,IAAI,OAAO,MAAM,eAAe,IAAI,eAAe,GAAG,CAAC,EACjE;EACD,CAAC"}
|
|
@@ -7,7 +7,7 @@ import { Balance } from "./deps/sui/balance.mjs";
|
|
|
7
7
|
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
8
8
|
**************************************************************/
|
|
9
9
|
/**
|
|
10
|
-
* Expiry-local
|
|
10
|
+
* Expiry-local USDC custody and isolated reserve accounting.
|
|
11
11
|
*
|
|
12
12
|
* This leaf owns cash balance arithmetic and the inventory-impact escrow used only
|
|
13
13
|
* for live-close rebates. It does not decide payment eligibility, pool allocation,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expiry_cash.mjs","names":["balance.Balance"],"sources":["../../../src/contracts/deepbook_predict/expiry_cash.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * Expiry-local
|
|
1
|
+
{"version":3,"file":"expiry_cash.mjs","names":["balance.Balance"],"sources":["../../../src/contracts/deepbook_predict/expiry_cash.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * Expiry-local USDC custody and isolated reserve accounting.\n *\n * This leaf owns cash balance arithmetic and the inventory-impact escrow used only\n * for live-close rebates. It does not decide payment eligibility, pool allocation,\n * or market phase sequencing; `ExpiryMarket` owns those policies.\n */\n\nimport { MoveStruct } from '../utils/index.js';\nimport { U64 } from '../../bcs/integers.js';\nimport * as balance from './deps/sui/balance.js';\nconst $moduleName = '@local-pkg/deepbook_predict::expiry_cash';\nexport const ExpiryCash = new MoveStruct({\n\tname: `${$moduleName}::ExpiryCash`,\n\tfields: {\n\t\tcash_balance: balance.Balance,\n\t\t/** Collected inventory-impact charges still reserved for live-close rebates. */\n\t\tinventory_impact_reserve: U64,\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,cAAc;AACpB,MAAa,aAAa,IAAI,WAAW;CACxC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,cAAcA;EAEd,0BAA0B;EAC1B;CACD,CAAC"}
|
|
@@ -21,6 +21,14 @@ import { bcs } from "@mysten/sui/bcs";
|
|
|
21
21
|
* and profit accounting remain outside this module.
|
|
22
22
|
*/
|
|
23
23
|
const $moduleName = "@local-pkg/deepbook_predict::expiry_market";
|
|
24
|
+
const ValuationStamp = new MoveStruct({
|
|
25
|
+
name: `${$moduleName}::ValuationStamp`,
|
|
26
|
+
fields: {
|
|
27
|
+
flush_seq: U64,
|
|
28
|
+
snapshot_cash: U64,
|
|
29
|
+
snapshot_impact_reserve: U64
|
|
30
|
+
}
|
|
31
|
+
});
|
|
24
32
|
const ExpiryMarket = new MoveStruct({
|
|
25
33
|
name: `${$moduleName}::ExpiryMarket`,
|
|
26
34
|
fields: {
|
|
@@ -31,7 +39,8 @@ const ExpiryMarket = new MoveStruct({
|
|
|
31
39
|
fee_incentive_balance: Balance,
|
|
32
40
|
strike_exposure: StrikeExposure,
|
|
33
41
|
ewma: EwmaState,
|
|
34
|
-
mint_paused: bcs.bool()
|
|
42
|
+
mint_paused: bcs.bool(),
|
|
43
|
+
valuation_stamp: bcs.option(ValuationStamp)
|
|
35
44
|
}
|
|
36
45
|
});
|
|
37
46
|
const MintQuote = new MoveStruct({
|
|
@@ -180,7 +189,7 @@ function mintPaused(options) {
|
|
|
180
189
|
* withdraw through the loaded account. The position's strike range is the tick
|
|
181
190
|
* pair `(lower_tick, higher_tick]` (`lower_tick = 0` is `-inf`,
|
|
182
191
|
* `higher_tick = pos_inf_tick` is `+inf`); the SDK converts raw strikes to ticks.
|
|
183
|
-
* `max_cost` caps the all-in
|
|
192
|
+
* `max_cost` caps the all-in USDC withdrawal, while `max_probability` caps the
|
|
184
193
|
* quoted per-contract probability before fees. Callers can pass
|
|
185
194
|
* `std::u64::max_value!()` for either uncapped guard. Returns the minted order ID
|
|
186
195
|
* for future order-scoped flows.
|
|
@@ -229,12 +238,12 @@ function mintExactQuantity(options) {
|
|
|
229
238
|
* must meet `min_quantity`.
|
|
230
239
|
*
|
|
231
240
|
* Fees, builder fees, and EWMA congestion penalties are charged on top of
|
|
232
|
-
* `max_premium`, so `max_cost` — not `max_premium` — bounds the all-in
|
|
241
|
+
* `max_premium`, so `max_cost` — not `max_premium` — bounds the all-in USDC
|
|
233
242
|
* withdrawal (`premium + trader-paid fee + builder_fee + EWMA penalty`).
|
|
234
243
|
* `max_cost` is required: unlike `mint_exact_quantity`'s guards there is no value
|
|
235
244
|
* that disables it, because the budget shape exists to bound spend. The sizing
|
|
236
|
-
* budget is first capped to the account's available
|
|
237
|
-
* still require additional available
|
|
245
|
+
* budget is first capped to the account's available USDC after settlement; fees
|
|
246
|
+
* still require additional available USDC at payment time. Any unspent premium
|
|
238
247
|
* dust remains in the account because order quantity must be an integer number of
|
|
239
248
|
* `position_lot_size` lots.
|
|
240
249
|
*/
|
|
@@ -286,7 +295,7 @@ function mintExactAmount(options) {
|
|
|
286
295
|
* Two close-side slippage floors, the mirror of mint's `max_probability` /
|
|
287
296
|
* `max_cost` pair; pass `0` to disable either. `min_probability` floors the quoted
|
|
288
297
|
* per-contract range probability (same units as mint's `max_probability`).
|
|
289
|
-
* `min_proceeds` floors the all-in net
|
|
298
|
+
* `min_proceeds` floors the all-in net USDC credited to the account
|
|
290
299
|
* (`redeem_amount` minus trading fee, builder fee, and EWMA penalty), the mirror
|
|
291
300
|
* of mint's all-in `max_cost`.
|
|
292
301
|
*/
|