@mysten/deepbook-v3 2.1.3 → 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 +45 -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/contracts/account/account.d.mts +23 -23
- package/dist/contracts/account/account.d.mts.map +1 -1
- package/dist/contracts/account/account_events.d.mts +20 -20
- package/dist/contracts/account/account_registry.d.mts +19 -19
- package/dist/contracts/account/account_registry.d.mts.map +1 -1
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- 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/deepbookAdmin.d.mts +4 -4
- package/dist/transactions/marginAdmin.d.mts +7 -7
- 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/marginTPSL.d.mts +10 -10
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/poolProxy.d.mts +8 -8
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markets.mjs","names":["plp.activeExpiryMarkets","registry.expiryMarketId","expiryMarket.expiry","expiryMarket.tickSize","expiryMarket.admissionTickSize","expiryMarket.mintPaused","expiryMarket.referenceTick","rangeCodec.strikeFromTick","pricing.rangePrice","expiryMarket.currentNav"],"sources":["../../../src/predict/reads/markets.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { Transaction } from '@mysten/sui/transactions';\nimport { type GeneratedConfig } from '../config/generated.js';\nimport { type UnderlyingConfig } from '../config/index.js';\nimport { PredictMoveError } from '../errors.js';\nimport { POS_INF_TICK } from '../ticks.js';\nimport { loadLivePricer, type MarketFeeds } from '../tx/trade.js';\nimport * as expiryMarket from '../../contracts/deepbook_predict/expiry_market.js';\nimport * as plp from '../../contracts/deepbook_predict/plp.js';\nimport * as pricing from '../../contracts/deepbook_predict/pricing.js';\nimport * as rangeCodec from '../../contracts/deepbook_predict/range_codec.js';\nimport * as registry from '../../contracts/deepbook_predict/registry.js';\nimport { inspectReturns, type ReadClient } from './inspect.js';\nimport { parseOptionalId, parseOptionalU64, parseU64LE, parseVectorOfIds } from './parse.js';\n\n// On-chain ids of the pool's active (live, not-yet-settled) expiry markets.\n// `plp::active_expiry_markets(vault)` — see packages/predict/sources/plp/plp.move:179.\nexport async function activeMarketIds(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n): Promise<string[]> {\n\tconst tx = new Transaction();\n\ttx.add(plp.activeExpiryMarkets({ config }));\n\tconst [cmd0] = await inspectReturns(client, tx);\n\treturn parseVectorOfIds(cmd0[0]);\n}\n\n// The expiry market id for one underlying at one expiry, or null if none exists.\n// `registry::expiry_market_id(registry, propbook_underlying_id: u32, expiry: u64):\n// Option<ID>` — see packages/predict/sources/registry/registry.move:53.\nexport async function expiryMarketId(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n\tunderlying: UnderlyingConfig,\n\texpiryMs: bigint,\n): Promise<string | null> {\n\tconst tx = new Transaction();\n\ttx.add(\n\t\tregistry.expiryMarketId({\n\t\t\tconfig,\n\t\t\targuments: { propbookUnderlyingId: underlying.propbookUnderlyingId, expiry: expiryMs },\n\t\t}),\n\t);\n\tconst [cmd0] = await inspectReturns(client, tx);\n\treturn parseOptionalId(cmd0[0]);\n}\n\nexport interface MarketState {\n\texpiryMs: bigint;\n\ttickSizeRaw: bigint;\n\t/**\n\t * The COARSER raw-price step new finite mint boundaries must align to\n\t * (`expiry_market::admission_tick_size`). A numeric strike must be a whole\n\t * multiple of this — the fine `tickSizeRaw` grid alone is not sufficient — or\n\t * the chain aborts `EInvalidAdmissionTick`. The market's reference tick is the\n\t * one finite boundary allowed to bypass it.\n\t */\n\tadmissionTickSizeRaw: bigint;\n\tmintPaused: boolean;\n\t/**\n\t * The reference fine-grid tick (Polymarket-style anchor strike: derived\n\t * on-chain from the exact previous-window oracle observation), or null while\n\t * the keeper has not seeded it. Reference PRICE raw = tick * tickSizeRaw.\n\t */\n\treferenceTickRaw: bigint | null;\n}\n\n// The per-market state getters, in fixed order. `expiry_market::{expiry,\n// tick_size, mint_paused, reference_tick}` — see\n// packages/predict/sources/expiry_market.move:{101,177,259,187}. reference_tick\n// returns Option (no abort risk). settlement is read separately via\n// `settlementPrice` (its own non-batched getter below).\nconst STATE_FNS = [\n\texpiryMarket.expiry,\n\texpiryMarket.tickSize,\n\texpiryMarket.admissionTickSize,\n\texpiryMarket.mintPaused,\n\texpiryMarket.referenceTick,\n] as const;\n\nfunction parseStateAt(cmds: Uint8Array[][], base: number): MarketState {\n\treturn {\n\t\texpiryMs: parseU64LE(cmds[base][0]),\n\t\ttickSizeRaw: parseU64LE(cmds[base + 1][0]),\n\t\tadmissionTickSizeRaw: parseU64LE(cmds[base + 2][0]),\n\t\tmintPaused: (cmds[base + 3][0][0] ?? 0) !== 0, // BCS bool: 1 byte\n\t\treferenceTickRaw: parseOptionalU64(cmds[base + 4][0]),\n\t};\n}\n\nexport async function marketState(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n\tmarketId: string,\n): Promise<MarketState> {\n\tconst [state] = await marketStates(client, config, [marketId]);\n\treturn state;\n}\n\n// Batched marketState for N markets in ONE PTB (STATE_FNS.length commands per\n// market, same order). Returns states aligned with `marketIds`.\nexport async function marketStates(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n\tmarketIds: readonly string[],\n): Promise<MarketState[]> {\n\tif (marketIds.length === 0) return [];\n\tconst tx = new Transaction();\n\tfor (const id of marketIds) {\n\t\tfor (const fn of STATE_FNS) {\n\t\t\ttx.add(fn({ config, arguments: { market: id } }));\n\t\t}\n\t}\n\tconst cmds = await inspectReturns(client, tx);\n\treturn marketIds.map((_, i) => parseStateAt(cmds, STATE_FNS.length * i));\n}\n\n// Anonymous both-sides pricing for one strike: the chain's own probability for\n// (strike, +inf] and (-inf, strike]. Deployed `pricing::range_price` takes typed\n// `range_codec::Strike`s (NOT raw u64) — each boundary is built via\n// `range_codec::strike_from_tick(tick, tick_size)`, which maps tick 0 → -inf,\n// POS_INF_TICK → +inf, and any finite tick → tick*tick_size. `range_price` is a\n// public fun on the deployed package. Both sides read the SAME pricer in one PTB, so\n// `down` is the chain's number, not 1 − up.\nexport async function rangePrices(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n\tmarketId: string,\n\tfeeds: MarketFeeds,\n\tstrikeRaw: bigint,\n\ttickSizeRaw: bigint,\n): Promise<{ upRaw: bigint; downRaw: bigint }> {\n\tconst tx = new Transaction();\n\tconst pricer = tx.add(loadLivePricer(config, { expiryMarketId: marketId, ...feeds }));\n\t// strikeRaw is a whole tick multiple (the caller validates divisibility), so the\n\t// finite boundary is `strike_from_tick(strikeRaw / tickSize, tickSize)`.\n\tconst strikeTick = strikeRaw / tickSizeRaw;\n\tconst mkStrike = (tick: bigint) =>\n\t\ttx.add(rangeCodec.strikeFromTick({ config, arguments: { tick, tickSize: tickSizeRaw } }));\n\tconst strike = mkStrike(strikeTick);\n\tconst posInf = mkStrike(POS_INF_TICK);\n\tconst negInf = mkStrike(0n);\n\t// UP: (strike, +inf], then DOWN: (-inf, strike] — the last two commands.\n\ttx.add(pricing.rangePrice({ config, arguments: { pricer, lower: strike, higher: posInf } }));\n\ttx.add(pricing.rangePrice({ config, arguments: { pricer, lower: negInf, higher: strike } }));\n\tconst cmds = await inspectReturns(client, tx);\n\treturn {\n\t\tupRaw: parseU64LE(cmds[cmds.length - 2][0]),\n\t\tdownRaw: parseU64LE(cmds[cmds.length - 1][0]),\n\t};\n}\n\n// Fresh single read of the reference tick — used by mint-at-reference, which\n// must not trust a cached state (the reference is unset early in a window\n// until the keeper seeds it).\nexport async function referenceTick(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n\tmarketId: string,\n): Promise<bigint | null> {\n\tconst tx = new Transaction();\n\ttx.add(expiryMarket.referenceTick({ config, arguments: { market: marketId } }));\n\tconst [cmd0] = await inspectReturns(client, tx);\n\treturn parseOptionalU64(cmd0[0]);\n}\n\n// The recorded settlement price, or null while the market is unsettled.\n//\n// On the deployed package `expiry_market::settlement_price` is public and\n// `destroy_some`s the stored Option — callable here only because simulate runs with\n// checksEnabled:false, and it aborts in std::option (EOPTION_NOT_SET) when the\n// market has not settled; we map exactly that abort (and the public\n// EMarketNotSettled variant, should a future package guard it directly) to null.\n// (A non-aborting `try_settlement_price` also exists on-chain if this ever wants to\n// drop the abort-catch.)\nexport async function settlementPrice(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n\tmarketId: string,\n): Promise<bigint | null> {\n\tconst tx = new Transaction();\n\ttx.add(expiryMarket.settlementPrice({ config, arguments: { market: marketId } }));\n\ttry {\n\t\tconst [cmd0] = await inspectReturns(client, tx);\n\t\treturn parseU64LE(cmd0[0]);\n\t} catch (e) {\n\t\tif (\n\t\t\te instanceof PredictMoveError &&\n\t\t\t(e.module === 'option' ||\n\t\t\t\t(e.module === 'expiry_market' && e.abortName === 'EMarketNotSettled'))\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\t\tthrow e;\n\t}\n}\n\n// A market's current NAV mark (the per-expiry recoverable value the flush prices\n// against). Loads a fresh live pricer, then reads `current_nav(market, &pricer)` —\n// see packages/predict/sources/expiry_market.move:236. `Pricer` has copy+drop, so\n// the unconsumed borrow is fine in a read-only inspect.\nexport async function currentNav(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n\tmarketId: string,\n\tunderlying: UnderlyingConfig,\n): Promise<bigint> {\n\tconst tx = new Transaction();\n\tconst pricer = tx.add(\n\t\tloadLivePricer(config, {\n\t\t\texpiryMarketId: marketId,\n\t\t\tpythFeed: underlying.pythFeed,\n\t\t\tblockScholesValueStore: underlying.blockScholesValueStore,\n\t\t\tblockScholesSviStore: underlying.blockScholesSviStore,\n\t\t}),\n\t);\n\ttx.add(expiryMarket.currentNav({ config, arguments: { market: marketId, pricer } }));\n\tconst cmds = await inspectReturns(client, tx);\n\t// current_nav is the last command; load_live_pricer precedes it.\n\treturn parseU64LE(cmds[cmds.length - 1][0]);\n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EACnC,sBAAsB,WAAW;EACjC,CAAC,CACF;AACD,IAAG,IAAIG,aAAwB;EAAE;EAAQ,WAAW;GAAE,QAAQ;GAAU;GAAQ;EAAE,CAAC,CAAC;CACpF,MAAM,OAAO,MAAM,eAAe,QAAQ,GAAG;AAE7C,QAAO,WAAW,KAAK,KAAK,SAAS,GAAG,GAAG"}
|
|
1
|
+
{"version":3,"file":"markets.mjs","names":["plp.activeExpiryMarkets","registry.expiryMarketId","expiryMarket.expiry","expiryMarket.tickSize","expiryMarket.admissionTickSize","expiryMarket.mintPaused","expiryMarket.referenceTick","rangeCodec.strikeFromTick","pricing.rangePrice","expiryMarket.currentNav"],"sources":["../../../src/predict/reads/markets.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { Transaction } from '@mysten/sui/transactions';\nimport { type GeneratedConfig } from '../config/generated.js';\nimport { type UnderlyingConfig } from '../config/index.js';\nimport { PredictMoveError } from '../errors.js';\nimport { POS_INF_TICK } from '../ticks.js';\nimport { loadLivePricer, type MarketFeeds } from '../tx/trade.js';\nimport * as expiryMarket from '../../contracts/deepbook_predict/expiry_market.js';\nimport * as plp from '../../contracts/deepbook_predict/plp.js';\nimport * as pricing from '../../contracts/deepbook_predict/pricing.js';\nimport * as rangeCodec from '../../contracts/deepbook_predict/range_codec.js';\nimport * as registry from '../../contracts/deepbook_predict/registry.js';\nimport { inspectReturns, type ReadClient } from './inspect.js';\nimport { parseOptionalId, parseOptionalU64, parseU64LE, parseVectorOfIds } from './parse.js';\n\n// On-chain ids of the pool's active (live, not-yet-settled) expiry markets.\n// `plp::active_expiry_markets(vault)` — see packages/predict/sources/plp/plp.move:179.\nexport async function activeMarketIds(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n): Promise<string[]> {\n\tconst tx = new Transaction();\n\ttx.add(plp.activeExpiryMarkets({ config }));\n\tconst [cmd0] = await inspectReturns(client, tx);\n\treturn parseVectorOfIds(cmd0[0]);\n}\n\n// The expiry market id for one underlying at one expiry, or null if none exists.\n// `registry::expiry_market_id(registry, propbook_underlying_id: u32, expiry: u64):\n// Option<ID>` — see packages/predict/sources/registry/registry.move:58.\nexport async function expiryMarketId(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n\tunderlying: UnderlyingConfig,\n\texpiryMs: bigint,\n): Promise<string | null> {\n\tconst tx = new Transaction();\n\ttx.add(\n\t\tregistry.expiryMarketId({\n\t\t\tconfig,\n\t\t\targuments: { propbookUnderlyingId: underlying.propbookUnderlyingId, expiry: expiryMs },\n\t\t}),\n\t);\n\tconst [cmd0] = await inspectReturns(client, tx);\n\treturn parseOptionalId(cmd0[0]);\n}\n\nexport interface MarketState {\n\texpiryMs: bigint;\n\ttickSizeRaw: bigint;\n\t/**\n\t * The COARSER raw-price step new finite mint boundaries must align to\n\t * (`expiry_market::admission_tick_size`). A numeric strike must be a whole\n\t * multiple of this — the fine `tickSizeRaw` grid alone is not sufficient — or\n\t * the chain aborts `EInvalidAdmissionTick`. The market's reference tick is the\n\t * one finite boundary allowed to bypass it.\n\t */\n\tadmissionTickSizeRaw: bigint;\n\tmintPaused: boolean;\n\t/**\n\t * The reference fine-grid tick (Polymarket-style anchor strike: derived\n\t * on-chain from the exact previous-window oracle observation), or null while\n\t * the keeper has not seeded it. Reference PRICE raw = tick * tickSizeRaw.\n\t */\n\treferenceTickRaw: bigint | null;\n}\n\n// The per-market state getters, in fixed order. `expiry_market::{expiry,\n// tick_size, mint_paused, reference_tick}` — see\n// packages/predict/sources/expiry_market.move:{101,177,259,187}. reference_tick\n// returns Option (no abort risk). settlement is read separately via\n// `settlementPrice` (its own non-batched getter below).\nconst STATE_FNS = [\n\texpiryMarket.expiry,\n\texpiryMarket.tickSize,\n\texpiryMarket.admissionTickSize,\n\texpiryMarket.mintPaused,\n\texpiryMarket.referenceTick,\n] as const;\n\nfunction parseStateAt(cmds: Uint8Array[][], base: number): MarketState {\n\treturn {\n\t\texpiryMs: parseU64LE(cmds[base][0]),\n\t\ttickSizeRaw: parseU64LE(cmds[base + 1][0]),\n\t\tadmissionTickSizeRaw: parseU64LE(cmds[base + 2][0]),\n\t\tmintPaused: (cmds[base + 3][0][0] ?? 0) !== 0, // BCS bool: 1 byte\n\t\treferenceTickRaw: parseOptionalU64(cmds[base + 4][0]),\n\t};\n}\n\nexport async function marketState(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n\tmarketId: string,\n): Promise<MarketState> {\n\tconst [state] = await marketStates(client, config, [marketId]);\n\treturn state;\n}\n\n// Batched marketState for N markets in ONE PTB (STATE_FNS.length commands per\n// market, same order). Returns states aligned with `marketIds`.\nexport async function marketStates(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n\tmarketIds: readonly string[],\n): Promise<MarketState[]> {\n\tif (marketIds.length === 0) return [];\n\tconst tx = new Transaction();\n\tfor (const id of marketIds) {\n\t\tfor (const fn of STATE_FNS) {\n\t\t\ttx.add(fn({ config, arguments: { market: id } }));\n\t\t}\n\t}\n\tconst cmds = await inspectReturns(client, tx);\n\treturn marketIds.map((_, i) => parseStateAt(cmds, STATE_FNS.length * i));\n}\n\n// Anonymous both-sides pricing for one strike: the chain's own probability for\n// (strike, +inf] and (-inf, strike]. Deployed `pricing::range_price` takes typed\n// `range_codec::Strike`s (NOT raw u64) — each boundary is built via\n// `range_codec::strike_from_tick(tick, tick_size)`, which maps tick 0 → -inf,\n// POS_INF_TICK → +inf, and any finite tick → tick*tick_size. `range_price` is a\n// public fun on the deployed package. Both sides read the SAME pricer in one PTB, so\n// `down` is the chain's number, not 1 − up.\nexport async function rangePrices(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n\tmarketId: string,\n\tfeeds: MarketFeeds,\n\tstrikeRaw: bigint,\n\ttickSizeRaw: bigint,\n): Promise<{ upRaw: bigint; downRaw: bigint }> {\n\tconst tx = new Transaction();\n\tconst pricer = tx.add(loadLivePricer(config, { expiryMarketId: marketId, ...feeds }));\n\t// strikeRaw is a whole tick multiple (the caller validates divisibility), so the\n\t// finite boundary is `strike_from_tick(strikeRaw / tickSize, tickSize)`.\n\tconst strikeTick = strikeRaw / tickSizeRaw;\n\tconst mkStrike = (tick: bigint) =>\n\t\ttx.add(rangeCodec.strikeFromTick({ config, arguments: { tick, tickSize: tickSizeRaw } }));\n\tconst strike = mkStrike(strikeTick);\n\tconst posInf = mkStrike(POS_INF_TICK);\n\tconst negInf = mkStrike(0n);\n\t// UP: (strike, +inf], then DOWN: (-inf, strike] — the last two commands.\n\ttx.add(pricing.rangePrice({ config, arguments: { pricer, lower: strike, higher: posInf } }));\n\ttx.add(pricing.rangePrice({ config, arguments: { pricer, lower: negInf, higher: strike } }));\n\tconst cmds = await inspectReturns(client, tx);\n\treturn {\n\t\tupRaw: parseU64LE(cmds[cmds.length - 2][0]),\n\t\tdownRaw: parseU64LE(cmds[cmds.length - 1][0]),\n\t};\n}\n\n// Fresh single read of the reference tick — used by mint-at-reference, which\n// must not trust a cached state (the reference is unset early in a window\n// until the keeper seeds it).\nexport async function referenceTick(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n\tmarketId: string,\n): Promise<bigint | null> {\n\tconst tx = new Transaction();\n\ttx.add(expiryMarket.referenceTick({ config, arguments: { market: marketId } }));\n\tconst [cmd0] = await inspectReturns(client, tx);\n\treturn parseOptionalU64(cmd0[0]);\n}\n\n// The recorded settlement price, or null while the market is unsettled.\n//\n// On the deployed package `expiry_market::settlement_price` is public and\n// `destroy_some`s the stored Option — callable here only because simulate runs with\n// checksEnabled:false, and it aborts in std::option (EOPTION_NOT_SET) when the\n// market has not settled; we map exactly that abort (and the public\n// EMarketNotSettled variant, should a future package guard it directly) to null.\n// (A non-aborting `try_settlement_price` also exists on-chain if this ever wants to\n// drop the abort-catch.)\nexport async function settlementPrice(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n\tmarketId: string,\n): Promise<bigint | null> {\n\tconst tx = new Transaction();\n\ttx.add(expiryMarket.settlementPrice({ config, arguments: { market: marketId } }));\n\ttry {\n\t\tconst [cmd0] = await inspectReturns(client, tx);\n\t\treturn parseU64LE(cmd0[0]);\n\t} catch (e) {\n\t\tif (\n\t\t\te instanceof PredictMoveError &&\n\t\t\t(e.module === 'option' ||\n\t\t\t\t(e.module === 'expiry_market' && e.abortName === 'EMarketNotSettled'))\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\t\tthrow e;\n\t}\n}\n\n// A market's current NAV mark (the per-expiry recoverable value the flush prices\n// against). Loads a fresh live pricer, then reads `current_nav(market, &pricer)` —\n// see packages/predict/sources/expiry_market.move:236. `Pricer` has copy+drop, so\n// the unconsumed borrow is fine in a read-only inspect.\nexport async function currentNav(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n\tmarketId: string,\n\tunderlying: UnderlyingConfig,\n): Promise<bigint> {\n\tconst tx = new Transaction();\n\tconst pricer = tx.add(\n\t\tloadLivePricer(config, {\n\t\t\texpiryMarketId: marketId,\n\t\t\tpythFeed: underlying.pythFeed,\n\t\t\tblockScholesValueStore: underlying.blockScholesValueStore,\n\t\t\tblockScholesSviStore: underlying.blockScholesSviStore,\n\t\t}),\n\t);\n\ttx.add(expiryMarket.currentNav({ config, arguments: { market: marketId, pricer } }));\n\tconst cmds = await inspectReturns(client, tx);\n\t// current_nav is the last command; load_live_pricer precedes it.\n\treturn parseU64LE(cmds[cmds.length - 1][0]);\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,eAAsB,gBACrB,QACA,QACoB;CACpB,MAAM,KAAK,IAAI,aAAa;AAC5B,IAAG,IAAIA,oBAAwB,EAAE,QAAQ,CAAC,CAAC;CAC3C,MAAM,CAAC,QAAQ,MAAM,eAAe,QAAQ,GAAG;AAC/C,QAAO,iBAAiB,KAAK,GAAG;;AAMjC,eAAsB,eACrB,QACA,QACA,YACA,UACyB;CACzB,MAAM,KAAK,IAAI,aAAa;AAC5B,IAAG,IACFC,iBAAwB;EACvB;EACA,WAAW;GAAE,sBAAsB,WAAW;GAAsB,Q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AAS,SAAS,WAAW;CACnC,MAAM,SAAS,SAAS,aAAa;CACrC,MAAM,SAAS,SAAS,GAAG;AAE3B,IAAG,IAAIC,WAAmB;EAAE;EAAQ,WAAW;GAAE;GAAQ,OAAO;GAAQ,QAAQ;GAAQ;EAAE,CAAC,CAAC;AAC5F,IAAG,IAAIA,WAAmB;EAAE;EAAQ,WAAW;GAAE;GAAQ,OAAO;GAAQ,QAAQ;GAAQ;EAAE,CAAC,CAAC;CAC5F,MAAM,OAAO,MAAM,eAAe,QAAQ,GAAG;AAC7C,QAAO;EACN,OAAO,WAAW,KAAK,KAAK,SAAS,GAAG,GAAG;EAC3C,SAAS,WAAW,KAAK,KAAK,SAAS,GAAG,GAAG;EAC7C;;AAMF,eAAsB,cACrB,QACA,QACA,UACyB;CACzB,MAAM,KAAK,IAAI,aAAa;AAC5B,IAAG,IAAIF,gBAA2B;EAAE;EAAQ,WAAW,EAAE,QAAQ,UAAU;EAAE,CAAC,CAAC;CAC/E,MAAM,CAAC,QAAQ,MAAM,eAAe,QAAQ,GAAG;AAC/C,QAAO,iBAAiB,KAAK,GAAG;;AAsCjC,eAAsB,WACrB,QACA,QACA,UACA,YACkB;CAClB,MAAM,KAAK,IAAI,aAAa;CAC5B,MAAM,SAAS,GAAG,IACjB,eAAe,QAAQ;EACtB,gBAAgB;EAChB,UAAU,WAAW;EACrB,wBAAwB,WAAW;EACnC,sBAAsB,WAAW;EACjC,CAAC,CACF;AACD,IAAG,IAAIG,aAAwB;EAAE;EAAQ,WAAW;GAAE,QAAQ;GAAU;GAAQ;EAAE,CAAC,CAAC;CACpF,MAAM,OAAO,MAAM,eAAe,QAAQ,GAAG;AAE7C,QAAO,WAAW,KAAK,KAAK,SAAS,GAAG,GAAG"}
|
|
@@ -6,7 +6,8 @@ import "../tx/trade.mjs";
|
|
|
6
6
|
/** A resolved pricer snapshot read from the chain: the decimal forward + rolled SVI the
|
|
7
7
|
* client-side math consumes, plus the oracle source timestamps behind it (ms; for
|
|
8
8
|
* staleness display — Pyth is 0 when no usable spot existed). The Block-Scholes entries are
|
|
9
|
-
*
|
|
9
|
+
* the provider's PER-UPDATE source timestamps (`value_timestamp` for spot/forward,
|
|
10
|
+
* `svi_timestamp` for SVI) — the clocks freshness and the SVI roll-down anchor on. */
|
|
10
11
|
interface PricerSnapshot extends PricerInputs {
|
|
11
12
|
sources: {
|
|
12
13
|
pythSpotMs: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.d.mts","names":[],"sources":["../../../src/predict/reads/pricing.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"pricing.d.mts","names":[],"sources":["../../../src/predict/reads/pricing.ts"],"mappings":";;;;;;AA2BA;;;;UAAiB,cAAA,SAAuB,YAAA;EACvC,OAAA;IACC,UAAA;IACA,kBAAA;IACA,qBAAA;IACA,iBAAA;EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.mjs","names":[],"sources":["../../../src/predict/reads/pricing.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { Transaction } from '@mysten/sui/transactions';\nimport { type GeneratedConfig } from '../config/generated.js';\nimport { Pricer } from '../../contracts/deepbook_predict/pricing.js';\nimport type { PricerInputs, Svi } from '../pricing.js';\nimport { loadLivePricer, type MarketFeeds } from '../tx/trade.js';\nimport { inspectReturns, type ReadClient } from './inspect.js';\n\n// The chain's fixed-point scales for the rolled `PricingSVI` (see the generated\n// `Pricer`/`PricingSVI` struct): forward and rho/m/sigma at 1e9; the rolled `a`/`b` land\n// at 1e18 (roll_down multiplies the 1e9 raw by an extra 1e9). Converting to `number`\n// (float) is deliberate — this is a display pricer; a is a variance ~O(1e-2), so f64's\n// ~15 significant digits are ample and, per pricing.ts, more precise than the chain's\n// fixed point on the short-dated surfaces this prices.\nconst FORWARD_SCALE = 1e9;\nconst AB_SCALE = 1e18;\nconst RMS_SCALE = 1e9; // rho, m, sigma\n\nconst i64 = (v: { magnitude: string | number | bigint; is_negative: boolean }): number =>\n\t(v.is_negative ? -1 : 1) * Number(v.magnitude);\n\n/** A resolved pricer snapshot read from the chain: the decimal forward + rolled SVI the\n * client-side math consumes, plus the oracle source timestamps behind it (ms; for\n * staleness display — Pyth is 0 when no usable spot existed). The Block-Scholes entries are\n *
|
|
1
|
+
{"version":3,"file":"pricing.mjs","names":[],"sources":["../../../src/predict/reads/pricing.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { Transaction } from '@mysten/sui/transactions';\nimport { type GeneratedConfig } from '../config/generated.js';\nimport { Pricer } from '../../contracts/deepbook_predict/pricing.js';\nimport type { PricerInputs, Svi } from '../pricing.js';\nimport { loadLivePricer, type MarketFeeds } from '../tx/trade.js';\nimport { inspectReturns, type ReadClient } from './inspect.js';\n\n// The chain's fixed-point scales for the rolled `PricingSVI` (see the generated\n// `Pricer`/`PricingSVI` struct): forward and rho/m/sigma at 1e9; the rolled `a`/`b` land\n// at 1e18 (roll_down multiplies the 1e9 raw by an extra 1e9). Converting to `number`\n// (float) is deliberate — this is a display pricer; a is a variance ~O(1e-2), so f64's\n// ~15 significant digits are ample and, per pricing.ts, more precise than the chain's\n// fixed point on the short-dated surfaces this prices.\nconst FORWARD_SCALE = 1e9;\nconst AB_SCALE = 1e18;\nconst RMS_SCALE = 1e9; // rho, m, sigma\n\nconst i64 = (v: { magnitude: string | number | bigint; is_negative: boolean }): number =>\n\t(v.is_negative ? -1 : 1) * Number(v.magnitude);\n\n/** A resolved pricer snapshot read from the chain: the decimal forward + rolled SVI the\n * client-side math consumes, plus the oracle source timestamps behind it (ms; for\n * staleness display — Pyth is 0 when no usable spot existed). The Block-Scholes entries are\n * the provider's PER-UPDATE source timestamps (`value_timestamp` for spot/forward,\n * `svi_timestamp` for SVI) — the clocks freshness and the SVI roll-down anchor on. */\nexport interface PricerSnapshot extends PricerInputs {\n\tsources: {\n\t\tpythSpotMs: number;\n\t\tblockScholesSpotMs: number;\n\t\tblockScholesForwardMs: number;\n\t\tblockScholesSviMs: number;\n\t};\n}\n\n// Decode a `Pricer` (already forward-resolved + roll-down-applied on-chain) into decimal\n// `PricerInputs`. Signed fields (`a`, `rho`, `m`) carry the magnitude/flag pair the chain\n// uses; `b`/`sigma` are non-negative.\nfunction decodePricer(pricer: ReturnType<typeof Pricer.parse>): PricerSnapshot {\n\tconst s = pricer.svi;\n\tconst svi: Svi = {\n\t\ta: ((s.a_is_negative ? -1 : 1) * Number(s.a_magnitude)) / AB_SCALE,\n\t\tb: Number(s.b) / AB_SCALE,\n\t\trho: i64(s.rho) / RMS_SCALE,\n\t\tm: i64(s.m) / RMS_SCALE,\n\t\tsigma: Number(s.sigma) / RMS_SCALE,\n\t};\n\treturn {\n\t\tforward: Number(pricer.forward) / FORWARD_SCALE,\n\t\tsvi,\n\t\tsources: {\n\t\t\tpythSpotMs: Number(pricer.pyth_spot_source_timestamp_ms),\n\t\t\tblockScholesSpotMs: Number(pricer.block_scholes_spot_source_timestamp_ms),\n\t\t\tblockScholesForwardMs: Number(pricer.block_scholes_forward_source_timestamp_ms),\n\t\t\tblockScholesSviMs: Number(pricer.block_scholes_svi_source_timestamp_ms),\n\t\t},\n\t};\n}\n\n// Read one live pricer snapshot for `marketId`: a single simulate of\n// `load_live_pricer` — the chain reads the oracle feeds, picks the forward\n// (Pyth-vs-Block-Scholes admin policy + freshness), and rolls the SVI down to now, then\n// returns the whole `Pricer` by value (copy+drop), whose BCS we decode. One round trip;\n// then a `boardPricer` prices every strike locally.\n//\n// `load_live_pricer` ABORTS (a typed PredictMoveError) when the market is expired, a feed\n// is stale, or the surface fails the pricing-safe envelope — i.e. exactly when the chain\n// itself cannot quote. Callers surface that the same way `read.price` does.\nexport async function readPricerSnapshot(\n\tclient: ReadClient,\n\tconfig: GeneratedConfig,\n\tmarketId: string,\n\tfeeds: MarketFeeds,\n): Promise<PricerSnapshot> {\n\tconst tx = new Transaction();\n\ttx.add(loadLivePricer(config, { expiryMarketId: marketId, ...feeds }));\n\tconst [cmd0] = await inspectReturns(client, tx);\n\treturn decodePricer(Pricer.parse(cmd0[0]));\n}\n"],"mappings":";;;;;;AAeA,MAAM,gBAAgB;AACtB,MAAM,WAAW;AACjB,MAAM,YAAY;AAElB,MAAM,OAAO,OACX,EAAE,cAAc,KAAK,KAAK,OAAO,EAAE,UAAU;AAmB/C,SAAS,aAAa,QAAyD;CAC9E,MAAM,IAAI,OAAO;CACjB,MAAM,MAAW;EAChB,IAAK,EAAE,gBAAgB,KAAK,KAAK,OAAO,EAAE,YAAY,GAAI;EAC1D,GAAG,OAAO,EAAE,EAAE,GAAG;EACjB,KAAK,IAAI,EAAE,IAAI,GAAG;EAClB,GAAG,IAAI,EAAE,EAAE,GAAG;EACd,OAAO,OAAO,EAAE,MAAM,GAAG;EACzB;AACD,QAAO;EACN,SAAS,OAAO,OAAO,QAAQ,GAAG;EAClC;EACA,SAAS;GACR,YAAY,OAAO,OAAO,8BAA8B;GACxD,oBAAoB,OAAO,OAAO,uCAAuC;GACzE,uBAAuB,OAAO,OAAO,0CAA0C;GAC/E,mBAAmB,OAAO,OAAO,sCAAsC;GACvE;EACD;;AAYF,eAAsB,mBACrB,QACA,QACA,UACA,OAC0B;CAC1B,MAAM,KAAK,IAAI,aAAa;AAC5B,IAAG,IAAI,eAAe,QAAQ;EAAE,gBAAgB;EAAU,GAAG;EAAO,CAAC,CAAC;CACtE,MAAM,CAAC,QAAQ,MAAM,eAAe,QAAQ,GAAG;AAC/C,QAAO,aAAa,OAAO,MAAM,KAAK,GAAG,CAAC"}
|
package/dist/sessions.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.d.mts","names":[],"sources":["../src/sessions.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"sessions.d.mts","names":[],"sources":["../src/sessions.ts"],"mappings":";;;;;;;;;;;AA2BA;;;;UAAiB,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IACR,SAAA;IACA,UAAA;IACA,UAAA;IACA,WAAA;IACA,OAAA;EAAA,KAEQ,EAAA,EAAI,WAAA,KAAc,iBAAA;EAoIkE;;;;;;;;;EAvG7F,UAAA,CAAW,MAAA;IACV,cAAA;IACA,SAAA;IACA,cAAA;IACA,MAAA,EAAQ,mBAAA;IACR,OAAA;IACA,aAAA;IACA,cAAA;IACA,WAAA;EAAA,KAEQ,EAAA,EAAI,WAAA,KAAc,iBAAA;;;;;;EAwB3B,aAAA,CAAc,MAAA;IACb,cAAA;IACA,SAAA;IACA,cAAA;IACA,OAAA;EAAA,KAEQ,EAAA,EAAI,WAAA;;;;;;;;;;;;;;;SA8BN,cAAA,CAAe,QAAA,EAAU,UAAA,GAAa,YAAA;;SAqBtC,cAAA,CAAe,MAAA,WAAiB,YAAA,IAAgB,KAAA,oBAAyB,YAAA;;;;;;;SAYzE,eAAA,CAAgB,MAAA,WAAiB,YAAA,IAAgB,KAAA,oBAAyB,YAAA;AAAA"}
|
package/dist/sessions.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MAINNET_SESSIONS } from "./deployments/mainnet.mjs";
|
|
1
2
|
import { TESTNET_DEPLOYMENT, TESTNET_SESSIONS, TESTNET_UNITS } from "./deployments/testnet.mjs";
|
|
2
3
|
import { getDeployment, getUnits } from "./deployments/index.mjs";
|
|
3
4
|
import { AccountContract } from "./account.mjs";
|
|
@@ -19,7 +20,8 @@ import { deriveDynamicFieldID, deriveObjectID } from "@mysten/sui/utils";
|
|
|
19
20
|
*/
|
|
20
21
|
function getSessionsConfig(network) {
|
|
21
22
|
if (network === "testnet") return TESTNET_SESSIONS;
|
|
22
|
-
|
|
23
|
+
if (network === "mainnet") return MAINNET_SESSIONS;
|
|
24
|
+
throw new Error(`@mysten/deepbook-v3/sessions: no sessions deployment recorded for network '${network}'. Sessions is recorded for testnet and mainnet; for your own deployment construct a \`SessionsConfig\` and pass it to SessionsContract directly.`);
|
|
23
25
|
}
|
|
24
26
|
/** The maximum session duration the contract accepts: 30 days, in milliseconds. */
|
|
25
27
|
const MAX_SESSION_DURATION_MS = 720 * 60 * 60 * 1e3;
|
package/dist/sessions.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.mjs","names":["#config","#generatedConfig","sessions.authorizeSession","sessions.revokeSession","sessions.sessionExpirationMs","sessions.mintExactQuantity","sessions.mintExactAmount","sessions.redeemLive","sessions.redeemSettled"],"sources":["../src/sessions.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { bcs } from '@mysten/sui/bcs';\nimport type { Transaction, TransactionArgument, TransactionResult } from '@mysten/sui/transactions';\nimport { deriveDynamicFieldID, deriveObjectID } from '@mysten/sui/utils';\n\nimport { TESTNET_SESSIONS } from './deployments/testnet.js';\nimport type { NetworkArg } from './deployments/index.js';\n\n// Provenance and scale constants, so a sessions-only consumer can answer \"which deployment\n// is this pinned to?\" and format a custody balance without importing another subpath.\nexport { getDeployment, getUnits, TESTNET_DEPLOYMENT, TESTNET_UNITS } from './deployments/index.js';\nexport type { DeployedNetwork, NetworkArg } from './deployments/index.js';\n\nimport { AccountContract } from './account.js';\nimport type { DeepbookSessionsConfig } from './contracts/deepbook_sessions/config-arguments.js';\nimport * as sessions from './contracts/deepbook_sessions/sessions.js';\nimport { SessionsData } from './contracts/deepbook_sessions/sessions.js';\n\n/**\n * Deployed ids the sessions builders address.\n *\n * `accountPackageId` / `accountRegistry` are the same shared-account ids\n * {@link AccountContract} takes — sessions is an Account app, so it addresses the same\n * registry. `sessionsPackageId` and `sessionsConfig` come from the sessions deployment.\n */\nexport interface SessionsConfig extends DeepbookSessionsConfig {\n\t/** The `deepbook_sessions` Move package id. */\n\tsessionsPackageId: string;\n\t/** The shared `SessionsConfig` object id. */\n\tsessionsConfig: string;\n\t/** The shared `account` Move package id. */\n\taccountPackageId: string;\n\t/** The shared `AccountRegistry` object id. */\n\taccountRegistry: string;\n}\n\n/**\n * Ids the DeepBook **spot** session wrappers need on top of {@link SessionsConfig}. The\n * Predict wrappers never take these, so they are kept off the main config rather than made\n * optional there.\n */\nexport interface SessionsSpotIds {\n\t/** DeepBook's shared `Registry` — `deepbook_registry` on the spot entrypoints. */\n\tdeepbookRegistry: string;\n\t/** The `deepbook_core_account` Move package id. */\n\tdeepbookCoreAccountPackageId: string;\n}\n\n/** Ids the Predict session wrappers need beyond {@link SessionsConfig}. */\nexport interface SessionsPredictIds {\n\t/** Every Predict wrapper takes `config: &ProtocolConfig`. */\n\tprotocolConfig: string;\n}\n\n/**\n * @description The deployed sessions ids for `network`, so a caller does not transcribe\n * them. Generated from the deploy manifest — see `src/deployments/`. The returned object\n * also carries {@link SessionsSpotIds} for the generated spot wrappers.\n * @throws if the network has no recorded deployment, rather than returning placeholder ids.\n *\n * ```ts\n * const sessions = new SessionsContract(getSessionsConfig('testnet'));\n * ```\n */\nexport function getSessionsConfig(\n\tnetwork: NetworkArg,\n): SessionsConfig & SessionsSpotIds & SessionsPredictIds {\n\t// The frozen record itself, matching `/account` — returning a spread here would have\n\t// quietly exempted this subpath from the immutability the others guarantee.\n\tif (network === 'testnet') return TESTNET_SESSIONS;\n\tthrow new Error(\n\t\t`@mysten/deepbook-v3/sessions: no sessions deployment recorded for network '${network}'. ` +\n\t\t\t'Sessions is testnet-only today; for your own deployment construct a `SessionsConfig` ' +\n\t\t\t'and pass it to SessionsContract directly.',\n\t);\n}\n\n/** The maximum session duration the contract accepts: 30 days, in milliseconds. */\nexport const MAX_SESSION_DURATION_MS = 30 * 24 * 60 * 60 * 1000;\n\n/** The maximum number of distinct session addresses one Account may store. */\nexport const MAX_SESSIONS_PER_ACCOUNT = 20;\n\n// `sui::dynamic_field::Field<DataKey<SessionsApp>, SessionsData>` — what a core `getObject`\n// on the grant field actually returns. `DataKey` is source-empty, but Move inserts a\n// hidden `dummy_field: bool` into empty structs, so the name occupies ONE zero byte\n// between the id and the value. Decoding the value alone would read the field id's first\n// byte as the VecMap length: garbage grants, or a silent empty list.\nconst SessionsDataField = bcs.struct('Field<DataKey,SessionsData>', {\n\tid: bcs.Address,\n\tname: bcs.bool(), // DataKey's hidden dummy_field\n\tvalue: SessionsData,\n});\n\n// `AccountKey(owner)` — the canonical ACCOUNT identity, a different derived object from\n// the wrapper. Grant data hangs off this one.\nconst AccountKey = bcs.struct('AccountKey', { pos0: bcs.Address });\n\n/** One stored session grant. */\nexport interface SessionGrant {\n\t/** The authorized ephemeral address. */\n\tsession: string;\n\t/** Absolute expiry, ms since epoch. The grant is dead AT this timestamp (strict `<`). */\n\texpiresAtMs: bigint;\n}\n\n/**\n * SessionsContract — time-limited trading sessions over a canonical Account.\n *\n * An Account owner authorizes an ephemeral address to submit a bounded set of\n * transactions on the Account's behalf until a fixed expiry. The session key never\n * receives a reusable `Auth`: each wrapper mints app authorization internally and\n * consumes it in the same call.\n *\n * WHAT A SESSION KEY CAN DO. It cannot withdraw to an address, cannot grant or revoke\n * sessions, and cannot outlive its expiry — those all require owner auth. It CAN trade\n * the Account's full balance: the spot wrappers take a caller-chosen `Pool` and, through\n * `deepbook_core_account`, pull the account's entire Base, Quote and DEEP balance\n * (stored plus unsettled) into the embedded manager for the duration of the call, with\n * `price_limit` supplied by the caller. Nothing caps notional, restricts which pools are\n * reachable, or bounds loss to adverse pricing. Treat a session key as authority over\n * everything the Account holds, and fund an ephemeral-session Account accordingly.\n *\n * Operational precondition: an admin must have authorized `SessionsApp` on the account\n * registry. Until then — or after a `deauthorize_app` — the TRADING wrappers abort with\n * `EAppNotAuthorized`; `authorizeSession`, `revokeSession` and `sessionExpirationMs` use\n * owner auth or no auth and keep working. Note that `deauthorize_app` does not clear\n * `SessionsData`, so re-authorizing makes every still-unexpired grant live again at once\n * — it is a pause, not a kill switch. Revoking, and reading expirations, also keep\n * working if the sessions package is later version-gated.\n *\n * This class wraps the session lifecycle and the **Predict** entrypoints. The DeepBook\n * spot session wrappers are generated (see `sessionsMoveCalls`) but are not wrapped here\n * — note `placeLimitOrder` and `placeMarketOrder` put `accountRegistry` at index 2 and\n * `sessionsConfig` at 4, because `deepbookRegistry` sits between them; the other three\n * (`cancelLiveOrder`, `cancelLiveOrders`, `withdrawSettledAmounts`) take no\n * `deepbookRegistry` and so keep 1 and 3 like the Predict wrappers:\n * the surrounding spot-over-Account workflow — discovering the embedded balance manager,\n * reading resting orders and locked balances — is not modelled yet, so a wrapped builder\n * would be hard to use well. They are reachable from the generated bindings meanwhile.\n */\nexport class SessionsContract {\n\t#config: SessionsConfig;\n\n\tconstructor(config: SessionsConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t// The generated thunks resolve the package address and auto-inject the shared\n\t// `SessionsConfig` from this object. `accountRegistry` stays an explicit argument —\n\t// it belongs to the account package, which is a separate codegen entry.\n\tget #generatedConfig() {\n\t\treturn {\n\t\t\tsessionsPackageId: this.#config.sessionsPackageId,\n\t\t\tsessionsConfig: this.#config.sessionsConfig,\n\t\t};\n\t}\n\n\t/**\n\t * @description The owner's canonical `AccountWrapper` id — derived off-chain, no read.\n\t * Every builder here takes that id.\n\t */\n\tderiveAccountWrapperId(owner: string): string {\n\t\treturn new AccountContract({\n\t\t\taccountPackageId: this.#config.accountPackageId,\n\t\t\taccountRegistry: this.#config.accountRegistry,\n\t\t}).deriveAccountWrapperId(owner);\n\t}\n\n\t/**\n\t * @description The owner's canonical ACCOUNT id — a different derived object from the\n\t * wrapper. The session grants hang off this one, so this is what\n\t * {@link deriveSessionsFieldId} and {@link decodeSessions} work from.\n\t */\n\tderiveAccountId(owner: string): string {\n\t\treturn deriveObjectID(\n\t\t\tthis.#config.accountRegistry,\n\t\t\t`${this.#config.accountPackageId}::account_registry::AccountKey`,\n\t\t\tAccountKey.serialize({ pos0: owner }).toBytes(),\n\t\t);\n\t}\n\n\t/**\n\t * @description The object id of the owner's `DataKey<SessionsApp>` dynamic field —\n\t * fetch this object and pass its BCS contents to {@link decodeSessions}. There is no\n\t * bulk on-chain read, so this is the route to enumerating grants.\n\t */\n\tderiveSessionsFieldId(owner: string): string {\n\t\t// A PLAIN dynamic field, not a derived object: `account::attach` writes it with\n\t\t// `df::add` (`use fun df::add as UID.add`), whereas the account and wrapper ids are\n\t\t// claimed through `derived_object::claim`. `deriveObjectID` would wrap the tag in\n\t\t// `0x2::derived_object::DerivedObjectKey<..>` and yield an id that points at nothing.\n\t\treturn deriveDynamicFieldID(\n\t\t\tthis.deriveAccountId(owner),\n\t\t\t`${this.#config.accountPackageId}::account::DataKey<${this.#config.sessionsPackageId}::sessions::SessionsApp>`,\n\t\t\t// DataKey is source-empty; Move's hidden `dummy_field: bool` is the key's one byte.\n\t\t\tnew Uint8Array([0]),\n\t\t);\n\t}\n\n\t/**\n\t * @description Grant `session` authority over the Account until `now + durationMs`.\n\t * Authority is derived from the transaction SENDER, so the owner must sign this.\n\t * `durationMs` must be > 0 and <= {@link MAX_SESSION_DURATION_MS}; an Account holds at\n\t * most {@link MAX_SESSIONS_PER_ACCOUNT} distinct addresses. Re-authorizing an address\n\t * replaces its expiry in place and consumes no additional slot.\n\t * @returns A function that takes a Transaction object\n\t */\n\tauthorizeSession(params: { wrapperId: string; session: string; durationMs: number | bigint }) {\n\t\treturn (tx: Transaction): void => {\n\t\t\ttx.add(\n\t\t\t\tsessions.authorizeSession({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\twrapper: params.wrapperId,\n\t\t\t\t\t\tsession: params.session,\n\t\t\t\t\t\tdurationMs: params.durationMs,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * @description Remove `session`'s grant. Owner-signed, like `authorizeSession`.\n\t * Deliberately takes no `SessionsConfig`: revocation is not version-gated, so it keeps\n\t * working after the package is retired. Revoking an address that holds no grant is a\n\t * silent no-op — it neither aborts nor emits, so read before and after if you need to\n\t * distinguish \"revoked\" from \"was never granted\".\n\t * @returns A function that takes a Transaction object\n\t */\n\trevokeSession(params: { wrapperId: string; session: string }) {\n\t\treturn (tx: Transaction): void => {\n\t\t\ttx.add(\n\t\t\t\tsessions.revokeSession({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: { wrapper: params.wrapperId, session: params.session },\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * @description Read one session's absolute expiry as `Option<u64>`. Compose in a\n\t * dev-inspect/simulate PTB and decode the returned BCS. Not version-gated.\n\t * @returns A function that takes a Transaction object\n\t */\n\tsessionExpirationMs(params: { wrapperId: string; session: string }) {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(\n\t\t\t\tsessions.sessionExpirationMs({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: { wrapper: params.wrapperId, session: params.session },\n\t\t\t\t}),\n\t\t\t);\n\t}\n\n\t// === Predict wrappers ===\n\t//\n\t// Each mirrors the Predict entrypoint of the same name, with two differences: the\n\t// caller supplies NO `Auth` (the wrapper mints and consumes app authorization\n\t// internally), and `accountRegistry` + `sessionsConfig` are threaded in. `pricer` is a\n\t// PTB RESULT, not an object — it comes from a preceding `expiry_market::load_live_pricer`\n\t// command in the same transaction. Everything else matches Predict exactly, and Predict\n\t// still performs all parameter validation.\n\n\t/**\n\t * @description Mint a position of an exact payout quantity, as `session`. Pass\n\t * `u64::MAX` for `maxCost` / `maxProbability` to leave either slippage cap\n\t * effectively unbounded — the chain asserts `value <= cap`, so the max value can never\n\t * trip. Both are required; there is no default.\n\t * @returns A function that takes a Transaction object and returns the new order id (u256)\n\t */\n\tmintExactQuantity(params: {\n\t\texpiryMarketId: string;\n\t\twrapperId: string;\n\t\tprotocolConfig: string;\n\t\tpricer: TransactionArgument;\n\t\tlowerTick: number | bigint;\n\t\thigherTick: number | bigint;\n\t\tquantity: number | bigint;\n\t\tmaxCost: number | bigint;\n\t\tmaxProbability: number | bigint;\n\t}) {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(\n\t\t\t\tsessions.mintExactQuantity({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tmarket: params.expiryMarketId,\n\t\t\t\t\t\taccountRegistry: this.#config.accountRegistry,\n\t\t\t\t\t\twrapper: params.wrapperId,\n\t\t\t\t\t\tconfig: params.protocolConfig,\n\t\t\t\t\t\tpricer: params.pricer,\n\t\t\t\t\t\tlowerTick: params.lowerTick,\n\t\t\t\t\t\thigherTick: params.higherTick,\n\t\t\t\t\t\tquantity: params.quantity,\n\t\t\t\t\t\tmaxCost: params.maxCost,\n\t\t\t\t\t\tmaxProbability: params.maxProbability,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t}\n\n\t/**\n\t * @description Mint by spending up to a premium budget, flooring the quantity received.\n\t * The chain requires `maxCost > 0`.\n\t * @returns A function that takes a Transaction object and returns the new order id (u256)\n\t */\n\tmintExactAmount(params: {\n\t\texpiryMarketId: string;\n\t\twrapperId: string;\n\t\tprotocolConfig: string;\n\t\tpricer: TransactionArgument;\n\t\tlowerTick: number | bigint;\n\t\thigherTick: number | bigint;\n\t\tmaxPremium: number | bigint;\n\t\tminQuantity: number | bigint;\n\t\tmaxCost: number | bigint;\n\t}) {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(\n\t\t\t\tsessions.mintExactAmount({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tmarket: params.expiryMarketId,\n\t\t\t\t\t\taccountRegistry: this.#config.accountRegistry,\n\t\t\t\t\t\twrapper: params.wrapperId,\n\t\t\t\t\t\tconfig: params.protocolConfig,\n\t\t\t\t\t\tpricer: params.pricer,\n\t\t\t\t\t\tlowerTick: params.lowerTick,\n\t\t\t\t\t\thigherTick: params.higherTick,\n\t\t\t\t\t\tmaxPremium: params.maxPremium,\n\t\t\t\t\t\tminQuantity: params.minQuantity,\n\t\t\t\t\t\tmaxCost: params.maxCost,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t}\n\n\t/**\n\t * @description Close part or all of a live position at the pricer's mark, as `session`.\n\t * `minProbability` / `minProceeds` are close-side slippage floors; `0` disables either,\n\t * and OMITTING them is `0` — unlike the mint caps, which are required. On a delegated\n\t * key this is the direction that closes a position at any price, so pass real floors\n\t * unless you mean to accept whatever the mark gives you.\n\t * @returns A function that takes a Transaction object and returns `Option<u256>` — the\n\t * replacement order id when a partial close leaves quantity open\n\t */\n\tredeemLive(params: {\n\t\texpiryMarketId: string;\n\t\twrapperId: string;\n\t\tprotocolConfig: string;\n\t\tpricer: TransactionArgument;\n\t\torderId: bigint;\n\t\tcloseQuantity: number | bigint;\n\t\tminProbability?: number | bigint;\n\t\tminProceeds?: number | bigint;\n\t}) {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(\n\t\t\t\tsessions.redeemLive({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tmarket: params.expiryMarketId,\n\t\t\t\t\t\taccountRegistry: this.#config.accountRegistry,\n\t\t\t\t\t\twrapper: params.wrapperId,\n\t\t\t\t\t\tconfig: params.protocolConfig,\n\t\t\t\t\t\tpricer: params.pricer,\n\t\t\t\t\t\torderId: params.orderId,\n\t\t\t\t\t\tcloseQuantity: params.closeQuantity,\n\t\t\t\t\t\tminProbability: params.minProbability ?? 0,\n\t\t\t\t\t\tminProceeds: params.minProceeds ?? 0,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t}\n\n\t/**\n\t * @description Claim a settled position in full, as `session`. Takes no pricer — the\n\t * settlement price is fixed — and no quantity: a settled claim is all-or-nothing.\n\t * @returns A function that takes a Transaction object\n\t */\n\tredeemSettled(params: {\n\t\texpiryMarketId: string;\n\t\twrapperId: string;\n\t\tprotocolConfig: string;\n\t\torderId: bigint;\n\t}) {\n\t\treturn (tx: Transaction): void => {\n\t\t\ttx.add(\n\t\t\t\tsessions.redeemSettled({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tmarket: params.expiryMarketId,\n\t\t\t\t\t\taccountRegistry: this.#config.accountRegistry,\n\t\t\t\t\t\twrapper: params.wrapperId,\n\t\t\t\t\t\tconfig: params.protocolConfig,\n\t\t\t\t\t\torderId: params.orderId,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * @description Decode an Account's stored grants from the raw BCS content of its\n\t * `DataKey<SessionsApp>` dynamic FIELD object — the whole\n\t * `Field<DataKey<SessionsApp>, SessionsData>`, as the core API returns it, not the\n\t * inner `SessionsData`. Get the id from {@link deriveSessionsFieldId}.\n\t *\n\t * There is no bulk on-chain read — `sessionExpirationMs` answers one address at a time —\n\t * so listing grants means fetching that field and decoding it here. Note the field hangs\n\t * off the DERIVED ACCOUNT address, not the wrapper address; they are different objects.\n\t *\n\t * Expired grants are never pruned automatically and keep occupying slots, so callers\n\t * managing the {@link MAX_SESSIONS_PER_ACCOUNT} cap should list, drop anything already\n\t * expired, and revoke before granting again.\n\t */\n\tstatic decodeSessions(contents: Uint8Array): SessionGrant[] {\n\t\t// Assert full consumption. `@mysten/bcs`'s ULEB reader indexes the underlying\n\t\t// ArrayBuffer rather than the view, so a truncated SUBARRAY — which is exactly what a\n\t\t// gRPC `content` field is — can read past its bound and decode to `[]` with no error.\n\t\t// Re-serializing and comparing lengths turns both truncation and trailing junk into a\n\t\t// throw, so \"no grants\" can only ever mean no grants.\n\t\tconst field = SessionsDataField.parse(contents);\n\t\tconst reencoded = SessionsDataField.serialize(field).toBytes();\n\t\tif (reencoded.length !== contents.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`sessions field is ${contents.length} bytes but its contents encode to ${reencoded.length}; ` +\n\t\t\t\t\t'the bytes are truncated or carry trailing data',\n\t\t\t);\n\t\t}\n\t\treturn field.value.sessions.contents.map((entry) => ({\n\t\t\tsession: entry.key,\n\t\t\texpiresAtMs: BigInt(entry.value),\n\t\t}));\n\t}\n\n\t/** Grants from {@link decodeSessions} that are still live at `nowMs`. */\n\tstatic activeSessions(grants: readonly SessionGrant[], nowMs: number | bigint): SessionGrant[] {\n\t\tconst now = BigInt(nowMs);\n\t\t// The chain asserts `now < expiresAtMs`, so a grant is dead AT its expiry.\n\t\treturn grants.filter((g) => now < g.expiresAtMs);\n\t}\n\n\t/**\n\t * @description Grants that are already dead at `nowMs` — the complement of\n\t * {@link activeSessions}, and the list to revoke when reclaiming slots. Use this rather\n\t * than filtering by hand: `nowMs > expiresAtMs` looks equivalent but leaves the grant\n\t * expiring exactly at `nowMs` occupying a slot forever.\n\t */\n\tstatic expiredSessions(grants: readonly SessionGrant[], nowMs: number | bigint): SessionGrant[] {\n\t\tconst now = BigInt(nowMs);\n\t\treturn grants.filter((g) => now >= g.expiresAtMs);\n\t}\n}\n\n// === Generated bindings ===\n// NOTE: this namespace carries the DeepBook spot session calls too\n// (`placeLimitOrder`, `placeMarketOrder`, `cancelLiveOrder(s)`, `withdrawSettledAmounts`).\n// They are generated and callable; they are simply not wrapped on `SessionsContract`.\nexport * as sessionsMoveCalls from './contracts/deepbook_sessions/sessions.js';\nexport * as sessionConfigMoveCalls from './contracts/deepbook_sessions/session_config.js';\nexport {\n\tSessionsApp,\n\tSessionsData,\n\tSessionAuthorized,\n\tSessionRevoked,\n} from './contracts/deepbook_sessions/sessions.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiEA,SAAgB,kBACf,SACwD;AAGxD,KAAI,YAAY,UAAW,QAAO;AAClC,OAAM,IAAI,MACT,8EAA8E,QAAQ,qIAGtF;;;AAIF,MAAa,0BAA0B,MAAU,KAAK,KAAK;;AAG3D,MAAa,2BAA2B;AAOxC,MAAM,oBAAoB,IAAI,OAAO,+BAA+B;CACnE,IAAI,IAAI;CACR,MAAM,IAAI,MAAM;CAChB,OAAO;CACP,CAAC;AAIF,MAAM,aAAa,IAAI,OAAO,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D,MAAM,QAAQ,kBAAkB,MAAM,SAAS;EAC/C,MAAM,YAAY,kBAAkB,UAAU,MAAM,CAAC,SAAS;AAC9D,MAAI,UAAU,WAAW,SAAS,OACjC,OAAM,IAAI,MACT,qBAAqB,SAAS,OAAO,oCAAoC,UAAU,OAAO,kDAE1F;AAEF,SAAO,MAAM,MAAM,SAAS,SAAS,KAAK,WAAW;GACpD,SAAS,MAAM;GACf,aAAa,OAAO,MAAM,MAAM;GAChC,EAAE;;;CAIJ,OAAO,eAAe,QAAiC,OAAwC;EAC9F,MAAM,MAAM,OAAO,MAAM;AAEzB,SAAO,OAAO,QAAQ,MAAM,MAAM,EAAE,YAAY;;;;;;;;CASjD,OAAO,gBAAgB,QAAiC,OAAwC;EAC/F,MAAM,MAAM,OAAO,MAAM;AACzB,SAAO,OAAO,QAAQ,MAAM,OAAO,EAAE,YAAY"}
|
|
1
|
+
{"version":3,"file":"sessions.mjs","names":["#config","#generatedConfig","sessions.authorizeSession","sessions.revokeSession","sessions.sessionExpirationMs","sessions.mintExactQuantity","sessions.mintExactAmount","sessions.redeemLive","sessions.redeemSettled"],"sources":["../src/sessions.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { bcs } from '@mysten/sui/bcs';\nimport type { Transaction, TransactionArgument, TransactionResult } from '@mysten/sui/transactions';\nimport { deriveDynamicFieldID, deriveObjectID } from '@mysten/sui/utils';\n\nimport { MAINNET_SESSIONS } from './deployments/mainnet.js';\nimport { TESTNET_SESSIONS } from './deployments/testnet.js';\nimport type { NetworkArg } from './deployments/index.js';\n\n// Provenance and scale constants, so a sessions-only consumer can answer \"which deployment\n// is this pinned to?\" and format a custody balance without importing another subpath.\nexport { getDeployment, getUnits, TESTNET_DEPLOYMENT, TESTNET_UNITS } from './deployments/index.js';\nexport type { DeployedNetwork, NetworkArg } from './deployments/index.js';\n\nimport { AccountContract } from './account.js';\nimport type { DeepbookSessionsConfig } from './contracts/deepbook_sessions/config-arguments.js';\nimport * as sessions from './contracts/deepbook_sessions/sessions.js';\nimport { SessionsData } from './contracts/deepbook_sessions/sessions.js';\n\n/**\n * Deployed ids the sessions builders address.\n *\n * `accountPackageId` / `accountRegistry` are the same shared-account ids\n * {@link AccountContract} takes — sessions is an Account app, so it addresses the same\n * registry. `sessionsPackageId` and `sessionsConfig` come from the sessions deployment.\n */\nexport interface SessionsConfig extends DeepbookSessionsConfig {\n\t/** The `deepbook_sessions` Move package id. */\n\tsessionsPackageId: string;\n\t/** The shared `SessionsConfig` object id. */\n\tsessionsConfig: string;\n\t/** The shared `account` Move package id. */\n\taccountPackageId: string;\n\t/** The shared `AccountRegistry` object id. */\n\taccountRegistry: string;\n}\n\n/**\n * Ids the DeepBook **spot** session wrappers need on top of {@link SessionsConfig}. The\n * Predict wrappers never take these, so they are kept off the main config rather than made\n * optional there.\n */\nexport interface SessionsSpotIds {\n\t/** DeepBook's shared `Registry` — `deepbook_registry` on the spot entrypoints. */\n\tdeepbookRegistry: string;\n\t/** The `deepbook_core_account` Move package id. */\n\tdeepbookCoreAccountPackageId: string;\n}\n\n/** Ids the Predict session wrappers need beyond {@link SessionsConfig}. */\nexport interface SessionsPredictIds {\n\t/** Every Predict wrapper takes `config: &ProtocolConfig`. */\n\tprotocolConfig: string;\n}\n\n/**\n * @description The deployed sessions ids for `network`, so a caller does not transcribe\n * them. Generated from the deploy manifest — see `src/deployments/`. The returned object\n * also carries {@link SessionsSpotIds} for the generated spot wrappers.\n * @throws if the network has no recorded deployment, rather than returning placeholder ids.\n *\n * ```ts\n * const sessions = new SessionsContract(getSessionsConfig('testnet'));\n * ```\n */\nexport function getSessionsConfig(\n\tnetwork: NetworkArg,\n): SessionsConfig & SessionsSpotIds & SessionsPredictIds {\n\t// The frozen record itself, matching `/account` — returning a spread here would have\n\t// quietly exempted this subpath from the immutability the others guarantee.\n\tif (network === 'testnet') return TESTNET_SESSIONS;\n\tif (network === 'mainnet') return MAINNET_SESSIONS;\n\tthrow new Error(\n\t\t`@mysten/deepbook-v3/sessions: no sessions deployment recorded for network '${network}'. ` +\n\t\t\t'Sessions is recorded for testnet and mainnet; for your own deployment construct a ' +\n\t\t\t'`SessionsConfig` ' +\n\t\t\t'and pass it to SessionsContract directly.',\n\t);\n}\n\n/** The maximum session duration the contract accepts: 30 days, in milliseconds. */\nexport const MAX_SESSION_DURATION_MS = 30 * 24 * 60 * 60 * 1000;\n\n/** The maximum number of distinct session addresses one Account may store. */\nexport const MAX_SESSIONS_PER_ACCOUNT = 20;\n\n// `sui::dynamic_field::Field<DataKey<SessionsApp>, SessionsData>` — what a core `getObject`\n// on the grant field actually returns. `DataKey` is source-empty, but Move inserts a\n// hidden `dummy_field: bool` into empty structs, so the name occupies ONE zero byte\n// between the id and the value. Decoding the value alone would read the field id's first\n// byte as the VecMap length: garbage grants, or a silent empty list.\nconst SessionsDataField = bcs.struct('Field<DataKey,SessionsData>', {\n\tid: bcs.Address,\n\tname: bcs.bool(), // DataKey's hidden dummy_field\n\tvalue: SessionsData,\n});\n\n// `AccountKey(owner)` — the canonical ACCOUNT identity, a different derived object from\n// the wrapper. Grant data hangs off this one.\nconst AccountKey = bcs.struct('AccountKey', { pos0: bcs.Address });\n\n/** One stored session grant. */\nexport interface SessionGrant {\n\t/** The authorized ephemeral address. */\n\tsession: string;\n\t/** Absolute expiry, ms since epoch. The grant is dead AT this timestamp (strict `<`). */\n\texpiresAtMs: bigint;\n}\n\n/**\n * SessionsContract — time-limited trading sessions over a canonical Account.\n *\n * An Account owner authorizes an ephemeral address to submit a bounded set of\n * transactions on the Account's behalf until a fixed expiry. The session key never\n * receives a reusable `Auth`: each wrapper mints app authorization internally and\n * consumes it in the same call.\n *\n * WHAT A SESSION KEY CAN DO. It cannot withdraw to an address, cannot grant or revoke\n * sessions, and cannot outlive its expiry — those all require owner auth. It CAN trade\n * the Account's full balance: the spot wrappers take a caller-chosen `Pool` and, through\n * `deepbook_core_account`, pull the account's entire Base, Quote and DEEP balance\n * (stored plus unsettled) into the embedded manager for the duration of the call, with\n * `price_limit` supplied by the caller. Nothing caps notional, restricts which pools are\n * reachable, or bounds loss to adverse pricing. Treat a session key as authority over\n * everything the Account holds, and fund an ephemeral-session Account accordingly.\n *\n * Operational precondition: an admin must have authorized `SessionsApp` on the account\n * registry. Until then — or after a `deauthorize_app` — the TRADING wrappers abort with\n * `EAppNotAuthorized`; `authorizeSession`, `revokeSession` and `sessionExpirationMs` use\n * owner auth or no auth and keep working. Note that `deauthorize_app` does not clear\n * `SessionsData`, so re-authorizing makes every still-unexpired grant live again at once\n * — it is a pause, not a kill switch. Revoking, and reading expirations, also keep\n * working if the sessions package is later version-gated.\n *\n * This class wraps the session lifecycle and the **Predict** entrypoints. The DeepBook\n * spot session wrappers are generated (see `sessionsMoveCalls`) but are not wrapped here\n * — note `placeLimitOrder` and `placeMarketOrder` put `accountRegistry` at index 2 and\n * `sessionsConfig` at 4, because `deepbookRegistry` sits between them; the other three\n * (`cancelLiveOrder`, `cancelLiveOrders`, `withdrawSettledAmounts`) take no\n * `deepbookRegistry` and so keep 1 and 3 like the Predict wrappers:\n * the surrounding spot-over-Account workflow — discovering the embedded balance manager,\n * reading resting orders and locked balances — is not modelled yet, so a wrapped builder\n * would be hard to use well. They are reachable from the generated bindings meanwhile.\n */\nexport class SessionsContract {\n\t#config: SessionsConfig;\n\n\tconstructor(config: SessionsConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t// The generated thunks resolve the package address and auto-inject the shared\n\t// `SessionsConfig` from this object. `accountRegistry` stays an explicit argument —\n\t// it belongs to the account package, which is a separate codegen entry.\n\tget #generatedConfig() {\n\t\treturn {\n\t\t\tsessionsPackageId: this.#config.sessionsPackageId,\n\t\t\tsessionsConfig: this.#config.sessionsConfig,\n\t\t};\n\t}\n\n\t/**\n\t * @description The owner's canonical `AccountWrapper` id — derived off-chain, no read.\n\t * Every builder here takes that id.\n\t */\n\tderiveAccountWrapperId(owner: string): string {\n\t\treturn new AccountContract({\n\t\t\taccountPackageId: this.#config.accountPackageId,\n\t\t\taccountRegistry: this.#config.accountRegistry,\n\t\t}).deriveAccountWrapperId(owner);\n\t}\n\n\t/**\n\t * @description The owner's canonical ACCOUNT id — a different derived object from the\n\t * wrapper. The session grants hang off this one, so this is what\n\t * {@link deriveSessionsFieldId} and {@link decodeSessions} work from.\n\t */\n\tderiveAccountId(owner: string): string {\n\t\treturn deriveObjectID(\n\t\t\tthis.#config.accountRegistry,\n\t\t\t`${this.#config.accountPackageId}::account_registry::AccountKey`,\n\t\t\tAccountKey.serialize({ pos0: owner }).toBytes(),\n\t\t);\n\t}\n\n\t/**\n\t * @description The object id of the owner's `DataKey<SessionsApp>` dynamic field —\n\t * fetch this object and pass its BCS contents to {@link decodeSessions}. There is no\n\t * bulk on-chain read, so this is the route to enumerating grants.\n\t */\n\tderiveSessionsFieldId(owner: string): string {\n\t\t// A PLAIN dynamic field, not a derived object: `account::attach` writes it with\n\t\t// `df::add` (`use fun df::add as UID.add`), whereas the account and wrapper ids are\n\t\t// claimed through `derived_object::claim`. `deriveObjectID` would wrap the tag in\n\t\t// `0x2::derived_object::DerivedObjectKey<..>` and yield an id that points at nothing.\n\t\treturn deriveDynamicFieldID(\n\t\t\tthis.deriveAccountId(owner),\n\t\t\t`${this.#config.accountPackageId}::account::DataKey<${this.#config.sessionsPackageId}::sessions::SessionsApp>`,\n\t\t\t// DataKey is source-empty; Move's hidden `dummy_field: bool` is the key's one byte.\n\t\t\tnew Uint8Array([0]),\n\t\t);\n\t}\n\n\t/**\n\t * @description Grant `session` authority over the Account until `now + durationMs`.\n\t * Authority is derived from the transaction SENDER, so the owner must sign this.\n\t * `durationMs` must be > 0 and <= {@link MAX_SESSION_DURATION_MS}; an Account holds at\n\t * most {@link MAX_SESSIONS_PER_ACCOUNT} distinct addresses. Re-authorizing an address\n\t * replaces its expiry in place and consumes no additional slot.\n\t * @returns A function that takes a Transaction object\n\t */\n\tauthorizeSession(params: { wrapperId: string; session: string; durationMs: number | bigint }) {\n\t\treturn (tx: Transaction): void => {\n\t\t\ttx.add(\n\t\t\t\tsessions.authorizeSession({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\twrapper: params.wrapperId,\n\t\t\t\t\t\tsession: params.session,\n\t\t\t\t\t\tdurationMs: params.durationMs,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * @description Remove `session`'s grant. Owner-signed, like `authorizeSession`.\n\t * Deliberately takes no `SessionsConfig`: revocation is not version-gated, so it keeps\n\t * working after the package is retired. Revoking an address that holds no grant is a\n\t * silent no-op — it neither aborts nor emits, so read before and after if you need to\n\t * distinguish \"revoked\" from \"was never granted\".\n\t * @returns A function that takes a Transaction object\n\t */\n\trevokeSession(params: { wrapperId: string; session: string }) {\n\t\treturn (tx: Transaction): void => {\n\t\t\ttx.add(\n\t\t\t\tsessions.revokeSession({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: { wrapper: params.wrapperId, session: params.session },\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * @description Read one session's absolute expiry as `Option<u64>`. Compose in a\n\t * dev-inspect/simulate PTB and decode the returned BCS. Not version-gated.\n\t * @returns A function that takes a Transaction object\n\t */\n\tsessionExpirationMs(params: { wrapperId: string; session: string }) {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(\n\t\t\t\tsessions.sessionExpirationMs({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: { wrapper: params.wrapperId, session: params.session },\n\t\t\t\t}),\n\t\t\t);\n\t}\n\n\t// === Predict wrappers ===\n\t//\n\t// Each mirrors the Predict entrypoint of the same name, with two differences: the\n\t// caller supplies NO `Auth` (the wrapper mints and consumes app authorization\n\t// internally), and `accountRegistry` + `sessionsConfig` are threaded in. `pricer` is a\n\t// PTB RESULT, not an object — it comes from a preceding `expiry_market::load_live_pricer`\n\t// command in the same transaction. Everything else matches Predict exactly, and Predict\n\t// still performs all parameter validation.\n\n\t/**\n\t * @description Mint a position of an exact payout quantity, as `session`. Pass\n\t * `u64::MAX` for `maxCost` / `maxProbability` to leave either slippage cap\n\t * effectively unbounded — the chain asserts `value <= cap`, so the max value can never\n\t * trip. Both are required; there is no default.\n\t * @returns A function that takes a Transaction object and returns the new order id (u256)\n\t */\n\tmintExactQuantity(params: {\n\t\texpiryMarketId: string;\n\t\twrapperId: string;\n\t\tprotocolConfig: string;\n\t\tpricer: TransactionArgument;\n\t\tlowerTick: number | bigint;\n\t\thigherTick: number | bigint;\n\t\tquantity: number | bigint;\n\t\tmaxCost: number | bigint;\n\t\tmaxProbability: number | bigint;\n\t}) {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(\n\t\t\t\tsessions.mintExactQuantity({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tmarket: params.expiryMarketId,\n\t\t\t\t\t\taccountRegistry: this.#config.accountRegistry,\n\t\t\t\t\t\twrapper: params.wrapperId,\n\t\t\t\t\t\tconfig: params.protocolConfig,\n\t\t\t\t\t\tpricer: params.pricer,\n\t\t\t\t\t\tlowerTick: params.lowerTick,\n\t\t\t\t\t\thigherTick: params.higherTick,\n\t\t\t\t\t\tquantity: params.quantity,\n\t\t\t\t\t\tmaxCost: params.maxCost,\n\t\t\t\t\t\tmaxProbability: params.maxProbability,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t}\n\n\t/**\n\t * @description Mint by spending up to a premium budget, flooring the quantity received.\n\t * The chain requires `maxCost > 0`.\n\t * @returns A function that takes a Transaction object and returns the new order id (u256)\n\t */\n\tmintExactAmount(params: {\n\t\texpiryMarketId: string;\n\t\twrapperId: string;\n\t\tprotocolConfig: string;\n\t\tpricer: TransactionArgument;\n\t\tlowerTick: number | bigint;\n\t\thigherTick: number | bigint;\n\t\tmaxPremium: number | bigint;\n\t\tminQuantity: number | bigint;\n\t\tmaxCost: number | bigint;\n\t}) {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(\n\t\t\t\tsessions.mintExactAmount({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tmarket: params.expiryMarketId,\n\t\t\t\t\t\taccountRegistry: this.#config.accountRegistry,\n\t\t\t\t\t\twrapper: params.wrapperId,\n\t\t\t\t\t\tconfig: params.protocolConfig,\n\t\t\t\t\t\tpricer: params.pricer,\n\t\t\t\t\t\tlowerTick: params.lowerTick,\n\t\t\t\t\t\thigherTick: params.higherTick,\n\t\t\t\t\t\tmaxPremium: params.maxPremium,\n\t\t\t\t\t\tminQuantity: params.minQuantity,\n\t\t\t\t\t\tmaxCost: params.maxCost,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t}\n\n\t/**\n\t * @description Close part or all of a live position at the pricer's mark, as `session`.\n\t * `minProbability` / `minProceeds` are close-side slippage floors; `0` disables either,\n\t * and OMITTING them is `0` — unlike the mint caps, which are required. On a delegated\n\t * key this is the direction that closes a position at any price, so pass real floors\n\t * unless you mean to accept whatever the mark gives you.\n\t * @returns A function that takes a Transaction object and returns `Option<u256>` — the\n\t * replacement order id when a partial close leaves quantity open\n\t */\n\tredeemLive(params: {\n\t\texpiryMarketId: string;\n\t\twrapperId: string;\n\t\tprotocolConfig: string;\n\t\tpricer: TransactionArgument;\n\t\torderId: bigint;\n\t\tcloseQuantity: number | bigint;\n\t\tminProbability?: number | bigint;\n\t\tminProceeds?: number | bigint;\n\t}) {\n\t\treturn (tx: Transaction): TransactionResult =>\n\t\t\ttx.add(\n\t\t\t\tsessions.redeemLive({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tmarket: params.expiryMarketId,\n\t\t\t\t\t\taccountRegistry: this.#config.accountRegistry,\n\t\t\t\t\t\twrapper: params.wrapperId,\n\t\t\t\t\t\tconfig: params.protocolConfig,\n\t\t\t\t\t\tpricer: params.pricer,\n\t\t\t\t\t\torderId: params.orderId,\n\t\t\t\t\t\tcloseQuantity: params.closeQuantity,\n\t\t\t\t\t\tminProbability: params.minProbability ?? 0,\n\t\t\t\t\t\tminProceeds: params.minProceeds ?? 0,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t}\n\n\t/**\n\t * @description Claim a settled position in full, as `session`. Takes no pricer — the\n\t * settlement price is fixed — and no quantity: a settled claim is all-or-nothing.\n\t * @returns A function that takes a Transaction object\n\t */\n\tredeemSettled(params: {\n\t\texpiryMarketId: string;\n\t\twrapperId: string;\n\t\tprotocolConfig: string;\n\t\torderId: bigint;\n\t}) {\n\t\treturn (tx: Transaction): void => {\n\t\t\ttx.add(\n\t\t\t\tsessions.redeemSettled({\n\t\t\t\t\tconfig: this.#generatedConfig,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\tmarket: params.expiryMarketId,\n\t\t\t\t\t\taccountRegistry: this.#config.accountRegistry,\n\t\t\t\t\t\twrapper: params.wrapperId,\n\t\t\t\t\t\tconfig: params.protocolConfig,\n\t\t\t\t\t\torderId: params.orderId,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * @description Decode an Account's stored grants from the raw BCS content of its\n\t * `DataKey<SessionsApp>` dynamic FIELD object — the whole\n\t * `Field<DataKey<SessionsApp>, SessionsData>`, as the core API returns it, not the\n\t * inner `SessionsData`. Get the id from {@link deriveSessionsFieldId}.\n\t *\n\t * There is no bulk on-chain read — `sessionExpirationMs` answers one address at a time —\n\t * so listing grants means fetching that field and decoding it here. Note the field hangs\n\t * off the DERIVED ACCOUNT address, not the wrapper address; they are different objects.\n\t *\n\t * Expired grants are never pruned automatically and keep occupying slots, so callers\n\t * managing the {@link MAX_SESSIONS_PER_ACCOUNT} cap should list, drop anything already\n\t * expired, and revoke before granting again.\n\t */\n\tstatic decodeSessions(contents: Uint8Array): SessionGrant[] {\n\t\t// Assert full consumption. `@mysten/bcs`'s ULEB reader indexes the underlying\n\t\t// ArrayBuffer rather than the view, so a truncated SUBARRAY — which is exactly what a\n\t\t// gRPC `content` field is — can read past its bound and decode to `[]` with no error.\n\t\t// Re-serializing and comparing lengths turns both truncation and trailing junk into a\n\t\t// throw, so \"no grants\" can only ever mean no grants.\n\t\tconst field = SessionsDataField.parse(contents);\n\t\tconst reencoded = SessionsDataField.serialize(field).toBytes();\n\t\tif (reencoded.length !== contents.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`sessions field is ${contents.length} bytes but its contents encode to ${reencoded.length}; ` +\n\t\t\t\t\t'the bytes are truncated or carry trailing data',\n\t\t\t);\n\t\t}\n\t\treturn field.value.sessions.contents.map((entry) => ({\n\t\t\tsession: entry.key,\n\t\t\texpiresAtMs: BigInt(entry.value),\n\t\t}));\n\t}\n\n\t/** Grants from {@link decodeSessions} that are still live at `nowMs`. */\n\tstatic activeSessions(grants: readonly SessionGrant[], nowMs: number | bigint): SessionGrant[] {\n\t\tconst now = BigInt(nowMs);\n\t\t// The chain asserts `now < expiresAtMs`, so a grant is dead AT its expiry.\n\t\treturn grants.filter((g) => now < g.expiresAtMs);\n\t}\n\n\t/**\n\t * @description Grants that are already dead at `nowMs` — the complement of\n\t * {@link activeSessions}, and the list to revoke when reclaiming slots. Use this rather\n\t * than filtering by hand: `nowMs > expiresAtMs` looks equivalent but leaves the grant\n\t * expiring exactly at `nowMs` occupying a slot forever.\n\t */\n\tstatic expiredSessions(grants: readonly SessionGrant[], nowMs: number | bigint): SessionGrant[] {\n\t\tconst now = BigInt(nowMs);\n\t\treturn grants.filter((g) => now >= g.expiresAtMs);\n\t}\n}\n\n// === Generated bindings ===\n// NOTE: this namespace carries the DeepBook spot session calls too\n// (`placeLimitOrder`, `placeMarketOrder`, `cancelLiveOrder(s)`, `withdrawSettledAmounts`).\n// They are generated and callable; they are simply not wrapped on `SessionsContract`.\nexport * as sessionsMoveCalls from './contracts/deepbook_sessions/sessions.js';\nexport * as sessionConfigMoveCalls from './contracts/deepbook_sessions/session_config.js';\nexport {\n\tSessionsApp,\n\tSessionsData,\n\tSessionAuthorized,\n\tSessionRevoked,\n} from './contracts/deepbook_sessions/sessions.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkEA,SAAgB,kBACf,SACwD;AAGxD,KAAI,YAAY,UAAW,QAAO;AAClC,KAAI,YAAY,UAAW,QAAO;AAClC,OAAM,IAAI,MACT,8EAA8E,QAAQ,mJAItF;;;AAIF,MAAa,0BAA0B,MAAU,KAAK,KAAK;;AAG3D,MAAa,2BAA2B;AAOxC,MAAM,oBAAoB,IAAI,OAAO,+BAA+B;CACnE,IAAI,IAAI;CACR,MAAM,IAAI,MAAM;CAChB,OAAO;CACP,CAAC;AAIF,MAAM,aAAa,IAAI,OAAO,cAAc,EAAE,MAAM,IAAI,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6ClE,IAAa,mBAAb,MAA8B;CAC7B;CAEA,YAAY,QAAwB;AACnC,QAAKA,SAAU;;CAMhB,KAAIC,kBAAmB;AACtB,SAAO;GACN,mBAAmB,MAAKD,OAAQ;GAChC,gBAAgB,MAAKA,OAAQ;GAC7B;;;;;;CAOF,uBAAuB,OAAuB;AAC7C,SAAO,IAAI,gBAAgB;GAC1B,kBAAkB,MAAKA,OAAQ;GAC/B,iBAAiB,MAAKA,OAAQ;GAC9B,CAAC,CAAC,uBAAuB,MAAM;;;;;;;CAQjC,gBAAgB,OAAuB;AACtC,SAAO,eACN,MAAKA,OAAQ,iBACb,GAAG,MAAKA,OAAQ,iBAAiB,iCACjC,WAAW,UAAU,EAAE,MAAM,OAAO,CAAC,CAAC,SAAS,CAC/C;;;;;;;CAQF,sBAAsB,OAAuB;AAK5C,SAAO,qBACN,KAAK,gBAAgB,MAAM,EAC3B,GAAG,MAAKA,OAAQ,iBAAiB,qBAAqB,MAAKA,OAAQ,kBAAkB,2BAErF,IAAI,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oB;GACnB,QAAQ,MAAKN;GACb,WAAW;IACV,QAAQ,OAAO;IACf,iBAAiB,MAAKD,OAAQ;IAC9B,SAAS,OAAO;IAChB,QAAQ,OAAO;IACf,QAAQ,OAAO;IACf,SAAS,OAAO;IAChB,eAAe,OAAO;IACtB,gBAAgB,OAAO,kBAAkB;IACzC,aAAa,OAAO,eAAe;IACnC;GACD,CAAC,CACF;;;;;;;CAQH,cAAc,QAKX;AACF,UAAQ,OAA0B;AACjC,MAAG,IACFQ,cAAuB;IACtB,QAAQ,MAAKP;IACb,WAAW;KACV,QAAQ,OAAO;KACf,iBAAiB,MAAKD,OAAQ;KAC9B,SAAS,OAAO;KAChB,QAAQ,OAAO;KACf,SAAS,OAAO;KAChB;IACD,CAAC,CACF;;;;;;;;;;;;;;;;;CAkBH,OAAO,eAAe,UAAsC;EAM3D,MAAM,QAAQ,kBAAkB,MAAM,SAAS;EAC/C,MAAM,YAAY,kBAAkB,UAAU,MAAM,CAAC,SAAS;AAC9D,MAAI,UAAU,WAAW,SAAS,OACjC,OAAM,IAAI,MACT,qBAAqB,SAAS,OAAO,oCAAoC,UAAU,OAAO,kDAE1F;AAEF,SAAO,MAAM,MAAM,SAAS,SAAS,KAAK,WAAW;GACpD,SAAS,MAAM;GACf,aAAa,OAAO,MAAM,MAAM;GAChC,EAAE;;;CAIJ,OAAO,eAAe,QAAiC,OAAwC;EAC9F,MAAM,MAAM,OAAO,MAAM;AAEzB,SAAO,OAAO,QAAQ,MAAM,MAAM,EAAE,YAAY;;;;;;;;CASjD,OAAO,gBAAgB,QAAiC,OAAwC;EAC/F,MAAM,MAAM,OAAO,MAAM;AACzB,SAAO,OAAO,QAAQ,MAAM,OAAO,EAAE,YAAY"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_sui_transactions48 from "@mysten/sui/transactions";
|
|
3
3
|
import { Transaction, TransactionArgument } from "@mysten/sui/transactions";
|
|
4
4
|
|
|
5
5
|
//#region src/transactions/balanceManager.d.ts
|
|
@@ -21,7 +21,7 @@ declare class BalanceManagerContract {
|
|
|
21
21
|
* @description Create a new BalanceManager, manually set the owner. Returns the manager.
|
|
22
22
|
* @returns A function that takes a Transaction object
|
|
23
23
|
*/
|
|
24
|
-
createBalanceManagerWithOwner: (ownerAddress: string) => (tx: Transaction) =>
|
|
24
|
+
createBalanceManagerWithOwner: (ownerAddress: string) => (tx: Transaction) => _mysten_sui_transactions48.TransactionResult;
|
|
25
25
|
/**
|
|
26
26
|
* @description Share the BalanceManager
|
|
27
27
|
* @param {TransactionArgument} manager The BalanceManager to share
|
|
@@ -65,38 +65,38 @@ declare class BalanceManagerContract {
|
|
|
65
65
|
* @param {string} managerKey The key of the BalanceManager
|
|
66
66
|
* @returns A function that takes a Transaction object
|
|
67
67
|
*/
|
|
68
|
-
generateProof: (managerKey: string) => (tx: Transaction) =>
|
|
68
|
+
generateProof: (managerKey: string) => (tx: Transaction) => _mysten_sui_transactions48.TransactionResult;
|
|
69
69
|
/**
|
|
70
70
|
* @description Generate a trade proof as the owner
|
|
71
71
|
* @param {string} managerId The ID of the BalanceManager
|
|
72
72
|
* @returns A function that takes a Transaction object
|
|
73
73
|
*/
|
|
74
|
-
generateProofAsOwner: (managerId: string) => (tx: Transaction) =>
|
|
74
|
+
generateProofAsOwner: (managerId: string) => (tx: Transaction) => _mysten_sui_transactions48.TransactionResult;
|
|
75
75
|
/**
|
|
76
76
|
* @description Generate a trade proof as a trader
|
|
77
77
|
* @param {string} managerId The ID of the BalanceManager
|
|
78
78
|
* @param {string} tradeCapId The ID of the tradeCap
|
|
79
79
|
* @returns A function that takes a Transaction object
|
|
80
80
|
*/
|
|
81
|
-
generateProofAsTrader: (managerId: string, tradeCapId: string) => (tx: Transaction) =>
|
|
81
|
+
generateProofAsTrader: (managerId: string, tradeCapId: string) => (tx: Transaction) => _mysten_sui_transactions48.TransactionResult;
|
|
82
82
|
/**
|
|
83
83
|
* @description Mint a TradeCap
|
|
84
84
|
* @param {string} managerKey The name of the BalanceManager
|
|
85
85
|
* @returns A function that takes a Transaction object
|
|
86
86
|
*/
|
|
87
|
-
mintTradeCap: (managerKey: string) => (tx: Transaction) =>
|
|
87
|
+
mintTradeCap: (managerKey: string) => (tx: Transaction) => _mysten_sui_transactions48.TransactionResult;
|
|
88
88
|
/**
|
|
89
89
|
* @description Mint a DepositCap
|
|
90
90
|
* @param {string} managerKey The name of the BalanceManager
|
|
91
91
|
* @returns A function that takes a Transaction object
|
|
92
92
|
*/
|
|
93
|
-
mintDepositCap: (managerKey: string) => (tx: Transaction) =>
|
|
93
|
+
mintDepositCap: (managerKey: string) => (tx: Transaction) => _mysten_sui_transactions48.TransactionResult;
|
|
94
94
|
/**
|
|
95
95
|
* @description Mint a WithdrawalCap
|
|
96
96
|
* @param {string} managerKey The name of the BalanceManager
|
|
97
97
|
* @returns A function that takes a Transaction object
|
|
98
98
|
*/
|
|
99
|
-
mintWithdrawalCap: (managerKey: string) => (tx: Transaction) =>
|
|
99
|
+
mintWithdrawalCap: (managerKey: string) => (tx: Transaction) => _mysten_sui_transactions48.TransactionResult;
|
|
100
100
|
/**
|
|
101
101
|
* @description Deposit using the DepositCap
|
|
102
102
|
* @param {string} managerKey The name of the BalanceManager
|
|
@@ -112,7 +112,7 @@ declare class BalanceManagerContract {
|
|
|
112
112
|
* @param {number} amountToWithdraw The amount to withdraw
|
|
113
113
|
* @returns A function that takes a Transaction object
|
|
114
114
|
*/
|
|
115
|
-
withdrawWithCap: (managerKey: string, coinKey: string, amountToWithdraw: number) => (tx: Transaction) =>
|
|
115
|
+
withdrawWithCap: (managerKey: string, coinKey: string, amountToWithdraw: number) => (tx: Transaction) => _mysten_sui_transactions48.TransactionResult;
|
|
116
116
|
/**
|
|
117
117
|
* @description Set the referral for the BalanceManager for a specific pool
|
|
118
118
|
* @param {string} managerKey The name of the BalanceManager
|
|
@@ -147,20 +147,20 @@ declare class BalanceManagerContract {
|
|
|
147
147
|
* @param {string} referralId The ID of the referral to get the owner of
|
|
148
148
|
* @returns A function that takes a Transaction object
|
|
149
149
|
*/
|
|
150
|
-
balanceManagerReferralOwner: (referralId: string) => (tx: Transaction) =>
|
|
150
|
+
balanceManagerReferralOwner: (referralId: string) => (tx: Transaction) => _mysten_sui_transactions48.TransactionResult;
|
|
151
151
|
/**
|
|
152
152
|
* @description Get the pool ID associated with a referral (DeepBookPoolReferral)
|
|
153
153
|
* @param {string} referralId The ID of the referral to get the pool ID of
|
|
154
154
|
* @returns A function that takes a Transaction object
|
|
155
155
|
*/
|
|
156
|
-
balanceManagerReferralPoolId: (referralId: string) => (tx: Transaction) =>
|
|
156
|
+
balanceManagerReferralPoolId: (referralId: string) => (tx: Transaction) => _mysten_sui_transactions48.TransactionResult;
|
|
157
157
|
/**
|
|
158
158
|
* @description Get the referral ID from the balance manager for a specific pool
|
|
159
159
|
* @param {string} managerKey The name of the BalanceManager
|
|
160
160
|
* @param {string} poolKey Key of the pool to get the referral for
|
|
161
161
|
* @returns A function that takes a Transaction object
|
|
162
162
|
*/
|
|
163
|
-
getBalanceManagerReferralId: (managerKey: string, poolKey: string) => (tx: Transaction) =>
|
|
163
|
+
getBalanceManagerReferralId: (managerKey: string, poolKey: string) => (tx: Transaction) => _mysten_sui_transactions48.TransactionResult;
|
|
164
164
|
/**
|
|
165
165
|
* @description Revoke a TradeCap. This also revokes the associated DepositCap and WithdrawCap.
|
|
166
166
|
* @param {string} managerKey The name of the BalanceManager
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"balanceManager.d.mts","names":[],"sources":["../../src/transactions/balanceManager.ts"],"mappings":";;;;;;;;cAYa,sBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EA6BsD;;;;EArB1E,4BAAA,SAAsC,EAAA,EAAI,WAAA;EAyGwB;;;;EApFlE,6BAAA,GAAiC,YAAA,cAA0B,EAAA,EAAI,WAAA,KAAW,
|
|
1
|
+
{"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A,cAAwB,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EA7DpC;;;;;;;EA+ExB,cAAA,GACE,UAAA,UAAoB,OAAA,UAAiB,eAAA,cAA6B,EAAA,EAAI,WAAA;EAjEJ;;;;;;;EA+FpE,eAAA,GACE,UAAA,UAAoB,OAAA,UAAiB,gBAAA,cAA8B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAlElE;;;;;;;EA4FlB,yBAAA,GACE,UAAA,UAAoB,QAAA,UAAkB,QAAA,EAAU,mBAAA,MAAyB,EAAA,EAAI,WAAA;EA7EnB;;;;;;;EA8F5D,2BAAA,GACE,UAAA,UAAoB,OAAA,UAAiB,QAAA,EAAU,mBAAA,MAAyB,EAAA,EAAI,WAAA;EAW9E,sBAAA,GAA0B,UAAA,cAAwB,EAAA,EAAI,WAAA;EAxDhC;;;;;EAuEtB,KAAA,GAAS,UAAA,cAAwB,EAAA,EAAI,WAAA;EA5CnC;;;;;EA2DF,EAAA,GAAM,UAAA,cAAwB,EAAA,EAAI,WAAA;EA1ClC;;;;;EAyDA,2BAAA,GAA+B,UAAA,cAAwB,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAxDI;;;;;EAsE1E,4BAAA,GAAgC,UAAA,cAAwB,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EA5C9D;;;;;;EA2DT,2BAAA,GAA+B,UAAA,UAAoB,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EA7BvF;;;;;;EA8CA,cAAA,GAAkB,UAAA,UAAoB,UAAA,cAAwB,EAAA,EAAI,WAAA;AAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CanPlaceLimitOrderParams, CanPlaceMarketOrderParams, CreatePermissionlessPoolParams, PlaceLimitOrderParams, PlaceMarketOrderParams, SwapParams, SwapWithManagerParams } from "../types/index.mjs";
|
|
2
2
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _mysten_sui_transactions59 from "@mysten/sui/transactions";
|
|
4
4
|
import { Transaction } from "@mysten/sui/transactions";
|
|
5
5
|
|
|
6
6
|
//#region src/transactions/deepbook.d.ts
|
|
@@ -380,40 +380,40 @@ declare class DeepBookContract {
|
|
|
380
380
|
* @param {string} referral The referral (DeepBookPoolReferral) to get the balances for
|
|
381
381
|
* @returns A function that takes a Transaction object
|
|
382
382
|
*/
|
|
383
|
-
getPoolReferralBalances: (poolKey: string, referral: string) => (tx: Transaction) =>
|
|
383
|
+
getPoolReferralBalances: (poolKey: string, referral: string) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
384
384
|
/**
|
|
385
385
|
* @description Get the multiplier for a referral (DeepBookPoolReferral)
|
|
386
386
|
* @param {string} poolKey The key to identify the pool
|
|
387
387
|
* @param {string} referral The referral (DeepBookPoolReferral) to get the multiplier for
|
|
388
388
|
* @returns A function that takes a Transaction object
|
|
389
389
|
*/
|
|
390
|
-
poolReferralMultiplier: (poolKey: string, referral: string) => (tx: Transaction) =>
|
|
390
|
+
poolReferralMultiplier: (poolKey: string, referral: string) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
391
391
|
/**
|
|
392
392
|
* @description Check if a pool is a stable pool
|
|
393
393
|
* @param {string} poolKey The key to identify the pool
|
|
394
394
|
* @returns A function that takes a Transaction object
|
|
395
395
|
*/
|
|
396
|
-
stablePool: (poolKey: string) => (tx: Transaction) =>
|
|
396
|
+
stablePool: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
397
397
|
/**
|
|
398
398
|
* @description Check if a pool is registered
|
|
399
399
|
* @param {string} poolKey The key to identify the pool
|
|
400
400
|
* @returns A function that takes a Transaction object
|
|
401
401
|
*/
|
|
402
|
-
registeredPool: (poolKey: string) => (tx: Transaction) =>
|
|
402
|
+
registeredPool: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
403
403
|
/**
|
|
404
404
|
* @description Get the quote quantity out for a given base quantity using input token as fee
|
|
405
405
|
* @param {string} poolKey The key to identify the pool
|
|
406
406
|
* @param {number} baseQuantity Base quantity to convert
|
|
407
407
|
* @returns A function that takes a Transaction object
|
|
408
408
|
*/
|
|
409
|
-
getQuoteQuantityOutInputFee: (poolKey: string, baseQuantity: number | bigint) => (tx: Transaction) =>
|
|
409
|
+
getQuoteQuantityOutInputFee: (poolKey: string, baseQuantity: number | bigint) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
410
410
|
/**
|
|
411
411
|
* @description Get the base quantity out for a given quote quantity using input token as fee
|
|
412
412
|
* @param {string} poolKey The key to identify the pool
|
|
413
413
|
* @param {number} quoteQuantity Quote quantity to convert
|
|
414
414
|
* @returns A function that takes a Transaction object
|
|
415
415
|
*/
|
|
416
|
-
getBaseQuantityOutInputFee: (poolKey: string, quoteQuantity: number | bigint) => (tx: Transaction) =>
|
|
416
|
+
getBaseQuantityOutInputFee: (poolKey: string, quoteQuantity: number | bigint) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
417
417
|
/**
|
|
418
418
|
* @description Get the quantity out for a given base or quote quantity using input token as fee
|
|
419
419
|
* @param {string} poolKey The key to identify the pool
|
|
@@ -421,7 +421,7 @@ declare class DeepBookContract {
|
|
|
421
421
|
* @param {number} quoteQuantity Quote quantity to convert
|
|
422
422
|
* @returns A function that takes a Transaction object
|
|
423
423
|
*/
|
|
424
|
-
getQuantityOutInputFee: (poolKey: string, baseQuantity: number | bigint, quoteQuantity: number | bigint) => (tx: Transaction) =>
|
|
424
|
+
getQuantityOutInputFee: (poolKey: string, baseQuantity: number | bigint, quoteQuantity: number | bigint) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
425
425
|
/**
|
|
426
426
|
* @description Get the base quantity needed to receive a target quote quantity
|
|
427
427
|
* @param {string} poolKey The key to identify the pool
|
|
@@ -429,7 +429,7 @@ declare class DeepBookContract {
|
|
|
429
429
|
* @param {boolean} payWithDeep Whether to pay fees with DEEP
|
|
430
430
|
* @returns A function that takes a Transaction object
|
|
431
431
|
*/
|
|
432
|
-
getBaseQuantityIn: (poolKey: string, targetQuoteQuantity: number | bigint, payWithDeep: boolean) => (tx: Transaction) =>
|
|
432
|
+
getBaseQuantityIn: (poolKey: string, targetQuoteQuantity: number | bigint, payWithDeep: boolean) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
433
433
|
/**
|
|
434
434
|
* @description Get the quote quantity needed to receive a target base quantity
|
|
435
435
|
* @param {string} poolKey The key to identify the pool
|
|
@@ -437,14 +437,14 @@ declare class DeepBookContract {
|
|
|
437
437
|
* @param {boolean} payWithDeep Whether to pay fees with DEEP
|
|
438
438
|
* @returns A function that takes a Transaction object
|
|
439
439
|
*/
|
|
440
|
-
getQuoteQuantityIn: (poolKey: string, targetBaseQuantity: number | bigint, payWithDeep: boolean) => (tx: Transaction) =>
|
|
440
|
+
getQuoteQuantityIn: (poolKey: string, targetBaseQuantity: number | bigint, payWithDeep: boolean) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
441
441
|
/**
|
|
442
442
|
* @description Get account order details for a balance manager
|
|
443
443
|
* @param {string} poolKey The key to identify the pool
|
|
444
444
|
* @param {string} managerKey Key of the balance manager
|
|
445
445
|
* @returns A function that takes a Transaction object
|
|
446
446
|
*/
|
|
447
|
-
getAccountOrderDetails: (poolKey: string, managerKey: string) => (tx: Transaction) =>
|
|
447
|
+
getAccountOrderDetails: (poolKey: string, managerKey: string) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
448
448
|
/**
|
|
449
449
|
* @description Get the DEEP required for an order
|
|
450
450
|
* @param {string} poolKey The key to identify the pool
|
|
@@ -452,51 +452,51 @@ declare class DeepBookContract {
|
|
|
452
452
|
* @param {number} price Price
|
|
453
453
|
* @returns A function that takes a Transaction object
|
|
454
454
|
*/
|
|
455
|
-
getOrderDeepRequired: (poolKey: string, baseQuantity: number | bigint, price: number | bigint) => (tx: Transaction) =>
|
|
455
|
+
getOrderDeepRequired: (poolKey: string, baseQuantity: number | bigint, price: number | bigint) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
456
456
|
/**
|
|
457
457
|
* @description Check if account exists for a balance manager
|
|
458
458
|
* @param {string} poolKey The key to identify the pool
|
|
459
459
|
* @param {string} managerKey Key of the balance manager
|
|
460
460
|
* @returns A function that takes a Transaction object
|
|
461
461
|
*/
|
|
462
|
-
accountExists: (poolKey: string, managerKey: string) => (tx: Transaction) =>
|
|
462
|
+
accountExists: (poolKey: string, managerKey: string) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
463
463
|
/**
|
|
464
464
|
* @description Get the next epoch trade parameters for a pool
|
|
465
465
|
* @param {string} poolKey The key to identify the pool
|
|
466
466
|
* @returns A function that takes a Transaction object
|
|
467
467
|
*/
|
|
468
|
-
poolTradeParamsNext: (poolKey: string) => (tx: Transaction) =>
|
|
468
|
+
poolTradeParamsNext: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
469
469
|
/**
|
|
470
470
|
* @description Get the quorum for a pool
|
|
471
471
|
* @param {string} poolKey The key to identify the pool
|
|
472
472
|
* @returns A function that takes a Transaction object
|
|
473
473
|
*/
|
|
474
|
-
quorum: (poolKey: string) => (tx: Transaction) =>
|
|
474
|
+
quorum: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
475
475
|
/**
|
|
476
476
|
* @description Get the pool ID
|
|
477
477
|
* @param {string} poolKey The key to identify the pool
|
|
478
478
|
* @returns A function that takes a Transaction object
|
|
479
479
|
*/
|
|
480
|
-
poolId: (poolKey: string) => (tx: Transaction) =>
|
|
480
|
+
poolId: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
481
481
|
/**
|
|
482
482
|
* @description Check if a limit order can be placed
|
|
483
483
|
* @param {CanPlaceLimitOrderParams} params Parameters for checking limit order validity
|
|
484
484
|
* @returns A function that takes a Transaction object
|
|
485
485
|
*/
|
|
486
|
-
canPlaceLimitOrder: (params: CanPlaceLimitOrderParams) => (tx: Transaction) =>
|
|
486
|
+
canPlaceLimitOrder: (params: CanPlaceLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
487
487
|
/**
|
|
488
488
|
* @description Check if a market order can be placed
|
|
489
489
|
* @param {CanPlaceMarketOrderParams} params Parameters for checking market order validity
|
|
490
490
|
* @returns A function that takes a Transaction object
|
|
491
491
|
*/
|
|
492
|
-
canPlaceMarketOrder: (params: CanPlaceMarketOrderParams) => (tx: Transaction) =>
|
|
492
|
+
canPlaceMarketOrder: (params: CanPlaceMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
493
493
|
/**
|
|
494
494
|
* @description Check if market order params are valid
|
|
495
495
|
* @param {string} poolKey The key to identify the pool
|
|
496
496
|
* @param {number} quantity Quantity
|
|
497
497
|
* @returns A function that takes a Transaction object
|
|
498
498
|
*/
|
|
499
|
-
checkMarketOrderParams: (poolKey: string, quantity: number | bigint) => (tx: Transaction) =>
|
|
499
|
+
checkMarketOrderParams: (poolKey: string, quantity: number | bigint) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
500
500
|
/**
|
|
501
501
|
* @description Check if limit order params are valid
|
|
502
502
|
* @param {string} poolKey The key to identify the pool
|
|
@@ -505,7 +505,7 @@ declare class DeepBookContract {
|
|
|
505
505
|
* @param {number} expireTimestamp Expiration timestamp
|
|
506
506
|
* @returns A function that takes a Transaction object
|
|
507
507
|
*/
|
|
508
|
-
checkLimitOrderParams: (poolKey: string, price: number | bigint, quantity: number | bigint, expireTimestamp: number) => (tx: Transaction) =>
|
|
508
|
+
checkLimitOrderParams: (poolKey: string, price: number | bigint, quantity: number | bigint, expireTimestamp: number) => (tx: Transaction) => _mysten_sui_transactions59.TransactionResult;
|
|
509
509
|
}
|
|
510
510
|
//#endregion
|
|
511
511
|
export { DeepBookContract };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CreatePoolAdminParams, SetEwmaParams } from "../types/index.mjs";
|
|
2
2
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _mysten_sui_transactions78 from "@mysten/sui/transactions";
|
|
4
4
|
import { Transaction } from "@mysten/sui/transactions";
|
|
5
5
|
|
|
6
6
|
//#region src/transactions/deepbookAdmin.d.ts
|
|
@@ -104,7 +104,7 @@ declare class DeepBookAdminContract {
|
|
|
104
104
|
* @description Deauthorize the MarginApp by removing its authorization key
|
|
105
105
|
* @returns A function that takes a Transaction object and returns a bool
|
|
106
106
|
*/
|
|
107
|
-
deauthorizeMarginApp: () => (tx: Transaction) =>
|
|
107
|
+
deauthorizeMarginApp: () => (tx: Transaction) => _mysten_sui_transactions78.TransactionResult;
|
|
108
108
|
/**
|
|
109
109
|
* @description Mint a `DeepbookCorePauseCap`. The new cap's ID is recorded
|
|
110
110
|
* in the core registry so it can later disable any allowed package version
|
|
@@ -112,7 +112,7 @@ declare class DeepBookAdminContract {
|
|
|
112
112
|
* `MarginAdminContract.mintPauseCap`.
|
|
113
113
|
* @returns A function that takes a Transaction object and returns the new pause cap
|
|
114
114
|
*/
|
|
115
|
-
mintCorePauseCap: () => (tx: Transaction) =>
|
|
115
|
+
mintCorePauseCap: () => (tx: Transaction) => _mysten_sui_transactions78.TransactionResult;
|
|
116
116
|
/**
|
|
117
117
|
* @description Revoke a previously minted `DeepbookCorePauseCap` by ID.
|
|
118
118
|
* @param {string} pauseCapId The ID of the core pause cap to revoke
|
|
@@ -133,7 +133,7 @@ declare class DeepBookAdminContract {
|
|
|
133
133
|
* core registry.
|
|
134
134
|
* @returns A function that takes a Transaction object and returns a `VecSet<ID>`
|
|
135
135
|
*/
|
|
136
|
-
corePauseCaps: () => (tx: Transaction) =>
|
|
136
|
+
corePauseCaps: () => (tx: Transaction) => _mysten_sui_transactions78.TransactionResult;
|
|
137
137
|
}
|
|
138
138
|
//#endregion
|
|
139
139
|
export { DeepBookAdminContract };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PoolConfigParams } from "../types/index.mjs";
|
|
2
2
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _mysten_sui_transactions81 from "@mysten/sui/transactions";
|
|
4
4
|
import { Transaction, TransactionArgument } from "@mysten/sui/transactions";
|
|
5
5
|
|
|
6
6
|
//#region src/transactions/marginAdmin.d.ts
|
|
@@ -17,7 +17,7 @@ declare class MarginAdminContract {
|
|
|
17
17
|
* @description Mint a maintainer cap
|
|
18
18
|
* @returns A function that takes a Transaction object
|
|
19
19
|
*/
|
|
20
|
-
mintMaintainerCap: () => (tx: Transaction) =>
|
|
20
|
+
mintMaintainerCap: () => (tx: Transaction) => _mysten_sui_transactions81.TransactionResult;
|
|
21
21
|
/**
|
|
22
22
|
* @description Revoke a maintainer cap
|
|
23
23
|
* @returns A function that takes a Transaction object
|
|
@@ -121,7 +121,7 @@ declare class MarginAdminContract {
|
|
|
121
121
|
* @param {PoolConfigParams} poolConfigParams The parameters for the pool config
|
|
122
122
|
* @returns A function that takes a Transaction object
|
|
123
123
|
*/
|
|
124
|
-
newPoolConfig: (poolKey: string, poolConfigParams: PoolConfigParams) => (tx: Transaction) =>
|
|
124
|
+
newPoolConfig: (poolKey: string, poolConfigParams: PoolConfigParams) => (tx: Transaction) => _mysten_sui_transactions81.TransactionResult;
|
|
125
125
|
/**
|
|
126
126
|
* @description Create a new pool config with leverage
|
|
127
127
|
* @param {string} poolKey The key to identify the pool
|
|
@@ -136,7 +136,7 @@ declare class MarginAdminContract {
|
|
|
136
136
|
* @param {number} maxEwmaDifferenceBps The maximum EWMA difference in basis points
|
|
137
137
|
* @returns A function that takes a Transaction object
|
|
138
138
|
*/
|
|
139
|
-
newCoinTypeData: (coinKey: string, maxConfBps: number, maxEwmaDifferenceBps: number) => (tx: Transaction) =>
|
|
139
|
+
newCoinTypeData: (coinKey: string, maxConfBps: number, maxEwmaDifferenceBps: number) => (tx: Transaction) => _mysten_sui_transactions81.TransactionResult;
|
|
140
140
|
/**
|
|
141
141
|
* @description Create a new Pyth config
|
|
142
142
|
* @param {Array<{coinKey: string, maxConfBps: number, maxEwmaDifferenceBps: number}>} coinSetups The coins with their oracle config to be added to the Pyth config
|
|
@@ -147,12 +147,12 @@ declare class MarginAdminContract {
|
|
|
147
147
|
coinKey: string;
|
|
148
148
|
maxConfBps: number;
|
|
149
149
|
maxEwmaDifferenceBps: number;
|
|
150
|
-
}>, maxAgeSeconds: number) => (tx: Transaction) =>
|
|
150
|
+
}>, maxAgeSeconds: number) => (tx: Transaction) => _mysten_sui_transactions81.TransactionResult;
|
|
151
151
|
/**
|
|
152
152
|
* @description Mint a pause cap
|
|
153
153
|
* @returns A function that takes a Transaction object
|
|
154
154
|
*/
|
|
155
|
-
mintPauseCap: () => (tx: Transaction) =>
|
|
155
|
+
mintPauseCap: () => (tx: Transaction) => _mysten_sui_transactions81.TransactionResult;
|
|
156
156
|
/**
|
|
157
157
|
* @description Revoke a pause cap
|
|
158
158
|
* @param {string} pauseCapId The ID of the pause cap to revoke
|
|
@@ -172,7 +172,7 @@ declare class MarginAdminContract {
|
|
|
172
172
|
* @param {string} coinKey The key to identify the margin pool
|
|
173
173
|
* @returns A function that takes a Transaction object and returns a Coin<Asset>
|
|
174
174
|
*/
|
|
175
|
-
adminWithdrawDefaultReferralFees: (coinKey: string) => (tx: Transaction) =>
|
|
175
|
+
adminWithdrawDefaultReferralFees: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions81.TransactionResult;
|
|
176
176
|
}
|
|
177
177
|
//#endregion
|
|
178
178
|
export { MarginAdminContract };
|