@mysten/deepbook-v3 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/PREDICT.md +149 -55
- package/README.md +18 -13
- 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/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/account.d.mts.map +1 -1
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/balances.d.mts.map +1 -1
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook_predict/admin.d.mts +27 -0
- package/dist/contracts/deepbook_predict/admin.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/admin.mjs +38 -0
- package/dist/contracts/deepbook_predict/admin.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/builder_code.d.mts +81 -0
- package/dist/contracts/deepbook_predict/builder_code.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/builder_code.mjs +103 -0
- package/dist/contracts/deepbook_predict/builder_code.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/builder_code_events.d.mts +25 -0
- package/dist/contracts/deepbook_predict/builder_code_events.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/builder_code_events.mjs +7 -1
- package/dist/contracts/deepbook_predict/builder_code_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/config_events.d.mts +104 -0
- package/dist/contracts/deepbook_predict/config_events.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/config_events.mjs +155 -0
- package/dist/contracts/deepbook_predict/config_events.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/ewma_config.mjs +28 -0
- package/dist/contracts/deepbook_predict/ewma_config.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_market.d.mts +859 -0
- package/dist/contracts/deepbook_predict/expiry_market.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_market.mjs +647 -1
- package/dist/contracts/deepbook_predict/expiry_market.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts +39 -0
- package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/market_lifecycle_cap.mjs +51 -0
- package/dist/contracts/deepbook_predict/market_lifecycle_cap.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/market_manager.d.mts +159 -0
- package/dist/contracts/deepbook_predict/market_manager.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/market_manager.mjs +88 -2
- package/dist/contracts/deepbook_predict/market_manager.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/order_events.d.mts +101 -0
- package/dist/contracts/deepbook_predict/order_events.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/order_events.mjs +7 -1
- package/dist/contracts/deepbook_predict/order_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pause_cap.d.mts +39 -0
- package/dist/contracts/deepbook_predict/pause_cap.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/pause_cap.mjs +51 -0
- package/dist/contracts/deepbook_predict/pause_cap.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/plp.d.mts +801 -0
- package/dist/contracts/deepbook_predict/plp.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/plp.mjs +458 -1
- package/dist/contracts/deepbook_predict/plp.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts +39 -0
- package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/pool_valuation_cap.mjs +52 -0
- package/dist/contracts/deepbook_predict/pool_valuation_cap.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/predict_account.d.mts +90 -0
- package/dist/contracts/deepbook_predict/predict_account.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/predict_account.mjs +24 -1
- package/dist/contracts/deepbook_predict/predict_account.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pricing.d.mts +127 -0
- package/dist/contracts/deepbook_predict/pricing.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/pricing.mjs +25 -1
- package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pricing_config.mjs +28 -0
- package/dist/contracts/deepbook_predict/pricing_config.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/protocol_config.d.mts +665 -0
- package/dist/contracts/deepbook_predict/protocol_config.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/protocol_config.mjs +841 -0
- package/dist/contracts/deepbook_predict/protocol_config.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/range_codec.d.mts +30 -0
- package/dist/contracts/deepbook_predict/range_codec.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/range_codec.mjs +6 -1
- package/dist/contracts/deepbook_predict/range_codec.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/registry.d.mts +382 -0
- package/dist/contracts/deepbook_predict/registry.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/registry.mjs +456 -1
- package/dist/contracts/deepbook_predict/registry.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/vault_events.d.mts +199 -0
- package/dist/contracts/deepbook_predict/vault_events.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/vault_events.mjs +19 -1
- 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/sessions.d.mts +22 -22
- package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -1
- package/dist/predict/client.d.mts +3 -2
- package/dist/predict/client.d.mts.map +1 -1
- package/dist/predict/client.mjs +3 -2
- package/dist/predict/client.mjs.map +1 -1
- package/dist/predict/index.d.mts +18 -1
- package/dist/predict/index.mjs +18 -1
- package/dist/transactions/balanceManager.d.mts +12 -12
- 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/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginRegistry.d.mts +16 -16
- package/dist/transactions/marginTPSL.d.mts +10 -10
- package/dist/transactions/poolProxy.d.mts +8 -8
- package/package.json +1 -1
- package/src/predict/client.ts +3 -2
- package/src/predict/index.ts +26 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","names":["#config","opts","#buildMint","#feeds","#resolveMarket","#strikeTicks","#buildRedeem","#client","#referencePriceOf","#positionsCache","#strikeRawFor","#underlying","#marketCache","resolved","#assertAdmittedTick","#gridTick","#assertLot"],"sources":["../../src/predict/client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { ClientWithCoreApi, SuiClientRegistration } from '@mysten/sui/client';\nimport { Transaction, coinWithBalance, type TransactionResult } from '@mysten/sui/transactions';\nimport { isValidSuiObjectId } from '@mysten/sui/utils';\nimport { TESTNET_PREDICT } from '../deployments/testnet.js';\nimport { getConfig, type PredictConfig, type UnderlyingConfig } from './config/index.js';\nimport { toGeneratedConfig, type GeneratedConfig } from './config/generated.js';\nimport {\n\tdecodeAccountsCreated,\n\tdecodeBuilderCodeSets,\n\tdecodeClaims,\n\tdecodeDeposits,\n\tdecodeMints,\n\tdecodePlpCancels,\n\tdecodePlpRequests,\n\tdecodeRedeems,\n\tdecodeWithdrawals,\n\texactlyOne,\n\ttype DecodableTransactionResult,\n} from './decode.js';\nimport { PredictInputError } from './errors.js';\nimport { simulateWithEvents } from './reads/inspect.js';\nimport {\n\tpositionsFromTable,\n\tresolvePositionsTable,\n\ttype OpenPosition,\n\ttype PositionsHandle,\n} from './reads/positions.js';\nimport { accountBalance, hasPosition } from './reads/balances.js';\nimport {\n\tactiveMarketIds,\n\tcurrentNav,\n\texpiryMarketId,\n\tmarketState,\n\tmarketStates,\n\trangePrices,\n\treferenceTick,\n\ttype MarketState,\n} from './reads/markets.js';\nimport { poolStats } from './reads/pool.js';\nimport { readPricerSnapshot, type PricerSnapshot } from './reads/pricing.js';\nimport { boardPricer, type BoardPricer } from './pricing.js';\nimport { POS_INF_TICK, binaryRangeTicks, type Side } from './ticks.js';\nimport {\n\tcancelSupplyRequest,\n\tcancelWithdrawRequest,\n\tdepositFunds,\n\trequestSupply,\n\trequestWithdraw,\n\tsetBuilderCode,\n\tunsetBuilderCode,\n\twithdrawFunds,\n} from './tx/authed.js';\n\nimport { accountContract, deriveAccountWrapperIdFrom } from './tx/common.js';\nimport type { MarketFeeds } from './tx/trade.js';\nimport { mintExactAmount, mintExactQuantity, redeemLive, redeemSettled } from './tx/trade.js';\nimport {\n\tpriceToRaw,\n\tprobabilityToRaw,\n\trawToProbability,\n\trawToUsdc,\n\tusdcToRaw,\n\tfromRaw,\n} from './units.js';\n\n// `position_lot_size` — a position quantity must be a whole multiple of this many\n// raw payout units ($0.01 lots). See packages/predict/sources/constants.move.\n/**\n * Testnet's `position_lot_size`, read from the deployment record. Validation uses the lot\n * size of the config actually in play; this is the convenience constant for testnet callers.\n */\nexport const POSITION_LOT_SIZE = BigInt(TESTNET_PREDICT.units.positionLotSize);\n\n// Most `tx.*` builders are one builder's worth of commands in a fresh PTB.\nfunction txOf(command: (tx: Transaction) => TransactionResult | void): Transaction {\n\tconst tx = new Transaction();\n\ttx.add(command);\n\treturn tx;\n}\n\n/** A live/settled market addressed by its human coordinates: a binary position\n * (single strike + side) or a two-strike range position. */\nexport type MarketDescriptor = {\n\tunderlying: string;\n\texpiryMs: number | bigint;\n\t/**\n\t * Pin resolution to this exact `ExpiryMarket` object, skipping the\n\t * underlying+expiry lookup — a caller that reviewed a specific market object\n\t * mints against exactly that object, not whatever resolves at submit time.\n\t */\n\tmarketId?: string;\n} & (\n\t| {\n\t\t\tside: Side;\n\t\t\t/**\n\t\t\t * Strike in USD, or \"reference\" to trade at the market's on-chain reference\n\t\t\t * price (the Polymarket-style anchor: derived from the exact previous-window\n\t\t\t * oracle observation, so consecutive windows chain settlement → next strike).\n\t\t\t */\n\t\t\tstrike: number | 'reference';\n\t }\n\t| {\n\t\t\t/** A range position: pays out when settlement lands inside `(lower, upper]`\n\t\t\t * (left-open, right-closed — same convention as the on-chain range key). */\n\t\t\tside: 'range';\n\t\t\t/** Lower strike bound in USD — finite, on the tick grid. */\n\t\t\tlower: number;\n\t\t\t/** Upper strike bound in USD — finite, on the tick grid, above `lower`. */\n\t\t\tupper: number;\n\t }\n);\n\n/** Options for the friendly `mint` (exact payout quantity). */\nexport interface MintOptions {\n\tquantity: number;\n\tmaxCost?: number;\n\tmaxProbability?: number;\n}\n\n/** Options for `mintAmount` (spend up to a premium budget, floor the quantity received). */\nexport interface MintAmountOptions {\n\t/** Premium budget in quote units — the max premium paid (chain also caps it at the account balance). */\n\tspend: number;\n\tminQuantity: number;\n\t/** All-in cost ceiling in quote units (premium + fees). Omitted → uncapped. */\n\tmaxCost?: number;\n}\n\n/** Options for `redeem`: which order and how much to close. `claimSettled` takes only\n * `orderId` — a settled claim closes the order in full. */\nexport interface CloseOptions {\n\torderId: bigint;\n\tquantity: number;\n}\n\n/** Options for `supplyPlp`. */\nexport interface PlpSupplyOptions {\n\t/**\n\t * Floor on the PLP minted for the whole request, as raw `bigint` shares — PLP is raw\n\t * everywhere in this SDK. It is a floor on the MARK, not a share count: a flush quoting\n\t * less does not fill smaller, it declines. Omitted → `0n`, no floor.\n\t *\n\t * How a miss is handled is the deployment's `lp_request_limit_flush_attempts`: at the\n\t * shipped count of one the first flush below the floor cancels and refunds the request.\n\t */\n\tminPlpOut?: bigint;\n}\n\n/** Options for `withdrawPlp`. */\nexport interface PlpWithdrawOptions {\n\t/**\n\t * Floor on the USDC paid for the whole request, in USD decimals like every other amount\n\t * here. A floor on the MARK, not an amount: a flush quoting less declines rather than\n\t * paying out smaller. Omitted → no floor. Measured after the protocol's withdraw fee.\n\t */\n\tminUsdcOut?: number | string;\n}\n\n/** One tradeable market as returned by read.markets(). */\nexport interface ActiveMarket {\n\tid: string;\n\texpiryMs: bigint;\n\t/** Strike granularity in USD (e.g. 0.01). */\n\ttickSize: number;\n\t/**\n\t * Coarser step new mint strikes must align to. A numeric strike must be a whole\n\t * multiple of this (the market's `referencePrice` is the one exception the chain\n\t * admits off-grid); otherwise the mint aborts `EInvalidAdmissionTick`.\n\t */\n\tadmissionTickSize: number;\n\tmintPaused: boolean;\n\t/** The window's anchor strike in USD, or null until the keeper seeds it. */\n\treferencePrice: number | null;\n}\n\n/** A resolved live market: its on-chain state summary for the caller. */\nexport interface MarketSummary {\n\tid: string;\n\texpiryMs: bigint;\n\ttickSize: number;\n\t/**\n\t * Coarser step new mint strikes must align to. A numeric strike must be a whole\n\t * multiple of this (the market's `referencePrice` is the one exception the chain\n\t * admits off-grid); otherwise the mint aborts `EInvalidAdmissionTick`.\n\t */\n\tadmissionTickSize: number;\n\tmintPaused: boolean;\n\tnav: number;\n\t/** The window's anchor strike in USD, or null until the keeper seeds it. */\n\treferencePrice: number | null;\n}\n\n/** Aggregate pool figures. Balances in human units (shares raw); the pending fields\n * are request COUNTS, not amounts — the on-chain getters expose queue lengths, and\n * the escrowed USDC/PLP behind them is tracked separately. */\nexport interface PoolSummary {\n\tplpTotalSupply: bigint;\n\tidleUsdc: number;\n\t/** Number of LP supply requests queued for the next flush. */\n\tsupplyRequestsPending: number;\n\t/** Number of LP withdraw requests queued for the next flush. */\n\twithdrawRequestsPending: number;\n}\n\n/** Exact pre-trade quote: the dry-run receipt of the mint you are about to send. */\nexport interface MintQuote {\n\t/** Fill price, 0..1 per $1 payout. */\n\tentryProbability: number;\n\t/** Premium paid into LP backing (quote units). */\n\tpremium: number;\n\t/**\n\t * Fee breakdown. `referral` is a PORTION of the trader-paid trading fee and\n\t * congestion surcharge routed to the referrer — it is already inside those\n\t * numbers and is NOT an extra debit. `inventoryImpact` is a separate charge and\n\t * IS part of `cost`.\n\t */\n\tfees: {\n\t\ttrading: number;\n\t\tsubsidy: number;\n\t\tbuilder: number;\n\t\tpenalty: number;\n\t\treferral: number;\n\t\tinventoryImpact: number;\n\t};\n\t/**\n\t * All-in account debit: premium + (trading − subsidy) + builder + penalty +\n\t * inventoryImpact — exactly what the chain withdraws (the deployed\n\t * `compute_mint_quote`'s `all_in_cost`); pass this (plus your buffer) as maxCost.\n\t */\n\tcost: number;\n\tquantity: number;\n\traw: { premium: bigint; cost: bigint; quantity: bigint; entryProbability: bigint };\n\t/** True: computed by the real mint code path against real account state. */\n\tfeesExact: true;\n}\n\n/** Exact pre-close quote: the dry-run receipt of the redeem you are about to send. */\nexport interface RedeemQuote {\n\t/** NET quote credited to the account. */\n\tproceeds: number;\n\t/** Gross close value before fees. */\n\tgross: number;\n\t/** `inventoryImpactRebate` is credited back on the close, so `proceeds` is\n\t * gross + rebate − trading − builder − penalty. */\n\tfees: { trading: number; builder: number; penalty: number; inventoryImpactRebate: number };\n\tquantityClosed: number;\n\tremaining: number;\n\traw: { proceeds: bigint; gross: bigint; quantityClosed: bigint };\n\tfeesExact: true;\n}\n\ninterface ResolvedMarket {\n\tid: string;\n\tstate: MarketState;\n}\n\n// The strike-bearing (binary) arm of MarketDescriptor, for read.price and its\n// seam — anonymous board pricing has no range semantics.\ntype BinaryMarketCoordinates = Pick<MarketDescriptor, 'underlying' | 'expiryMs' | 'marketId'> & {\n\tstrike: number | 'reference';\n};\n\n/** The Sui client surface PredictClient reads through: any `ClientWithCoreApi`\n * (gRPC or JSON-RPC) provides both the `simulateTransaction` the reads/quotes\n * sit on and the `core` object methods position enumeration needs. */\nexport interface PredictCompatibleClient extends ClientWithCoreApi {}\n\n/**\n * Register PredictClient as a `client.predict` extension, mirroring\n * `@mysten/deepbook-v3`'s `deepbook(...)`: `client.$extend(predict({ network }))`.\n */\nexport function predict<Name extends string = 'predict'>({\n\tname = 'predict' as Name,\n\tnetwork,\n\tconfig,\n}: {\n\tname?: Name;\n\tnetwork: 'testnet' | 'mainnet';\n\tconfig?: PredictConfig;\n}): SuiClientRegistration<PredictCompatibleClient, Name, PredictClient> {\n\treturn {\n\t\tname,\n\t\tregister: (client) => new PredictClient({ client, network, config }),\n\t};\n}\n\n/**\n * The one object an app constructs. Wraps the config, a client for reads, and\n * a derived-account model so callers pass owner addresses, decimal amounts, and\n * human market coordinates — the facade converts to raw units, resolves markets\n * (cached), and delegates to the internal tx primitives / reads. Callers who need\n * to compose their own PTBs can use the generated bindings under `contracts/`.\n */\nexport class PredictClient {\n\treadonly cfg: PredictConfig;\n\t// The flat slice every generated call resolves `options.config` against.\n\tget #config(): GeneratedConfig {\n\t\treturn toGeneratedConfig(this.cfg);\n\t}\n\t#client: PredictCompatibleClient;\n\t// underlying:expiryMs → resolved market. The id and tickSizeRaw — the only\n\t// state tx building depends on — are immutable per (underlying, expiry), so\n\t// one resolution per market per client suffices. (mintPaused IS mutable; the\n\t// cached copy is never consulted for a tx decision — the chain enforces it.)\n\t#marketCache = new Map<string, ResolvedMarket>();\n\t// owner → resolved position-store ids. accountUid and the table id are\n\t// immutable once created, so cache-forever; a missing table (no Predict\n\t// data yet) is NOT cached — it appears after the owner's first trade.\n\t#positionsCache = new Map<string, PositionsHandle>();\n\n\tconstructor(opts: {\n\t\tnetwork: 'testnet' | 'mainnet';\n\t\tclient: PredictCompatibleClient;\n\t\tconfig?: PredictConfig;\n\t}) {\n\t\tthis.cfg = opts.config ?? getConfig(opts.network);\n\t\tthis.#client = opts.client;\n\t}\n\n\t/** The deterministic id of an owner's canonical account wrapper — no chain read. */\n\twrapperIdFor(owner: string): string {\n\t\treturn deriveAccountWrapperIdFrom(this.#config, owner);\n\t}\n\n\t// The deployment's wiring for a symbol; throws a typed error on an unknown symbol.\n\t// Per-underlying ids are the one thing the flat config slice does not carry.\n\t#underlying(underlying: string): UnderlyingConfig {\n\t\tconst u = this.cfg.underlyings[underlying];\n\t\tif (!u) throw new PredictInputError(`unknown underlying: ${underlying}`);\n\t\treturn u;\n\t}\n\n\t// The oracle feed ids for a symbol; throws a typed error on an unknown symbol.\n\t#feeds(underlying: string): MarketFeeds {\n\t\tconst u = this.#underlying(underlying);\n\t\treturn {\n\t\t\tpythFeed: u.pythFeed,\n\t\t\tblockScholesValueStore: u.blockScholesValueStore,\n\t\t\tblockScholesSviStore: u.blockScholesSviStore,\n\t\t};\n\t}\n\n\t// Resolve (and cache) a market's id + state from its human coordinates. An\n\t// explicit `marketId` pin skips the underlying+expiry lookup but still reads\n\t// that market's state — tx building depends on tickSizeRaw.\n\tasync #resolveMarket(\n\t\tm: Pick<MarketDescriptor, 'underlying' | 'expiryMs' | 'marketId'>,\n\t): Promise<ResolvedMarket> {\n\t\tif (m.marketId != null) {\n\t\t\tif (!isValidSuiObjectId(m.marketId)) {\n\t\t\t\tthrow new PredictInputError(`invalid marketId: ${JSON.stringify(m.marketId)}`);\n\t\t\t}\n\t\t\tconst resolved: ResolvedMarket = this.#marketCache.get(m.marketId) ?? {\n\t\t\t\tid: m.marketId,\n\t\t\t\tstate: await marketState(this.#client, this.#config, m.marketId),\n\t\t\t};\n\t\t\t// The pin must agree with the descriptor's coordinates: catching a stale or\n\t\t\t// wrong-market id here beats minting against mismatched oracle feeds. (The\n\t\t\t// underlying cannot be cross-checked — market state does not carry it.)\n\t\t\tif (resolved.state.expiryMs !== BigInt(m.expiryMs)) {\n\t\t\t\tthrow new PredictInputError(\n\t\t\t\t\t`pinned market ${m.marketId} expires at ${resolved.state.expiryMs}, descriptor says ${BigInt(m.expiryMs)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.#marketCache.set(m.marketId, resolved);\n\t\t\treturn resolved;\n\t\t}\n\t\tconst expiryMs = BigInt(m.expiryMs);\n\t\tconst key = `${m.underlying}:${expiryMs}`;\n\t\tconst hit = this.#marketCache.get(key);\n\t\tif (hit) return hit;\n\t\tconst u = this.#underlying(m.underlying);\n\t\tconst id = await expiryMarketId(this.#client, this.#config, u, expiryMs);\n\t\tif (!id) throw new PredictInputError(`no market for ${m.underlying} at expiry ${expiryMs}`);\n\t\tconst state = await marketState(this.#client, this.#config, id);\n\t\tconst resolved: ResolvedMarket = { id, state };\n\t\tthis.#marketCache.set(key, resolved);\n\t\treturn resolved;\n\t}\n\n\t// Reference PRICE in USD from a state (tick index × tick size), or null.\n\tstatic #referencePriceOf(state: MarketState): number | null {\n\t\treturn state.referenceTickRaw == null\n\t\t\t? null\n\t\t\t: fromRaw(state.referenceTickRaw * state.tickSizeRaw, 9);\n\t}\n\n\t// A finite tick from a USD strike, validated exactly like binaryRangeTicks:\n\t// whole-tick multiple, inside the finite domain (1..POS_INF_TICK-1).\n\t#gridTick(strike: number, tickSizeRaw: bigint): bigint {\n\t\tconst raw = priceToRaw(strike);\n\t\tconst tick = raw / tickSizeRaw;\n\t\tif (tick * tickSizeRaw !== raw) {\n\t\t\tthrow new PredictInputError(\n\t\t\t\t`strike ${strike} is not on the ${fromRaw(tickSizeRaw, 9)} tick grid`,\n\t\t\t);\n\t\t}\n\t\tif (tick <= 0n || tick >= POS_INF_TICK) {\n\t\t\tthrow new PredictInputError(\n\t\t\t\t`strike tick ${tick} outside the finite tick domain (1..POS_INF_TICK-1)`,\n\t\t\t);\n\t\t}\n\t\treturn tick;\n\t}\n\n\t// New finite MINT boundaries must land on the market's coarser ADMISSION grid,\n\t// not merely the fine tick grid — the chain asserts exactly this\n\t// (`assert_admitted_mint_ticks`, `EInvalidAdmissionTick`). The ±inf sentinels are\n\t// exempt, and the market's reference tick is the one finite boundary allowed to\n\t// bypass the grid, so an off-grid tick is only rejected after confirming it is not\n\t// the reference (one extra read, and only on the failing path).\n\tasync #assertAdmittedTick(tick: bigint, marketId: string, state: MarketState): Promise<void> {\n\t\tif (tick === 0n || tick === POS_INF_TICK) return;\n\t\tconst multiple = state.admissionTickSizeRaw / state.tickSizeRaw;\n\t\tif (multiple > 0n && tick % multiple === 0n) return;\n\t\tconst reference = await referenceTick(this.#client, this.#config, marketId);\n\t\tif (reference != null && reference === tick) return;\n\t\tconst admission = fromRaw(state.admissionTickSizeRaw, 9);\n\t\tthrow new PredictInputError(\n\t\t\t`strike ${fromRaw(tick * state.tickSizeRaw, 9)} is not on the ${admission} admission grid ` +\n\t\t\t\t`(mint boundaries must be a multiple of ${admission}, or the market's reference strike)`,\n\t\t);\n\t}\n\n\t// Resolve a descriptor's strike(s) to the (lower, higher) tick pair. A binary\n\t// numeric strike converts and validates against the tick grid; \"reference\"\n\t// reads the market's reference tick FRESH (never cached — it is unset early in\n\t// a window) and uses it directly: it is on the tick grid by construction. A\n\t// range descriptor converts both bounds to finite grid ticks (\"reference\" is\n\t// binary-only: a range has no single reference strike).\n\tasync #strikeTicks(\n\t\tm: MarketDescriptor,\n\t\tmarketId: string,\n\t\tstate: MarketState,\n\t): Promise<{ lowerTick: bigint; higherTick: bigint }> {\n\t\tif (m.side === 'range') {\n\t\t\tif (!(m.lower < m.upper)) {\n\t\t\t\tthrow new PredictInputError(`range lower ${m.lower} must be below upper ${m.upper}`);\n\t\t\t}\n\t\t\tconst lowerTick = this.#gridTick(m.lower, state.tickSizeRaw);\n\t\t\tconst higherTick = this.#gridTick(m.upper, state.tickSizeRaw);\n\t\t\tawait this.#assertAdmittedTick(lowerTick, marketId, state);\n\t\t\tawait this.#assertAdmittedTick(higherTick, marketId, state);\n\t\t\treturn { lowerTick, higherTick };\n\t\t}\n\t\tif (m.strike !== 'reference') {\n\t\t\tconst ticks = binaryRangeTicks(priceToRaw(m.strike), m.side, state.tickSizeRaw);\n\t\t\tawait this.#assertAdmittedTick(ticks.lowerTick, marketId, state);\n\t\t\tawait this.#assertAdmittedTick(ticks.higherTick, marketId, state);\n\t\t\treturn ticks;\n\t\t}\n\t\tconst tick = await referenceTick(this.#client, this.#config, marketId);\n\t\tif (tick == null) {\n\t\t\tthrow new PredictInputError(\n\t\t\t\t`reference price not set yet for ${m.underlying} @ ${m.expiryMs} — retry shortly or pass a numeric strike`,\n\t\t\t);\n\t\t}\n\t\treturn m.side === 'up'\n\t\t\t? { lowerTick: tick, higherTick: POS_INF_TICK }\n\t\t\t: { lowerTick: 0n, higherTick: tick };\n\t}\n\n\t// Raw payout quantity must land on a lot boundary — the chain rejects otherwise.\n\t#assertLot(quantityRaw: bigint): void {\n\t\t// From the config in play, not the exported testnet constant — a deployment with a\n\t\t// different `position_lot_size` must not be validated against testnet's.\n\t\tconst lot = BigInt(this.cfg.units.positionLotSize);\n\t\tif (quantityRaw % lot !== 0n) {\n\t\t\tthrow new PredictInputError(\n\t\t\t\t`quantity ${quantityRaw} raw is not a whole ${lot}-unit lot (position_lot_size)`,\n\t\t\t);\n\t\t}\n\t}\n\n\t// Shared construction for tx.mint and read.quoteMint. The quote dry-runs the\n\t// same mint the trade sends; quoteMint omits the caller's cost/probability caps\n\t// (they only gate via abort and don't change the receipt numbers).\n\tasync #buildMint(owner: string, m: MarketDescriptor, opts: MintOptions): Promise<Transaction> {\n\t\tconst feeds = this.#feeds(m.underlying);\n\t\tconst { id, state } = await this.#resolveMarket(m);\n\t\tconst quantityRaw = usdcToRaw(opts.quantity);\n\t\tthis.#assertLot(quantityRaw);\n\t\tconst { lowerTick, higherTick } = await this.#strikeTicks(m, id, state);\n\t\treturn txOf(\n\t\t\tmintExactQuantity(this.#config, {\n\t\t\t\texpiryMarketId: id,\n\t\t\t\twrapperId: this.wrapperIdFor(owner),\n\t\t\t\tlowerTick,\n\t\t\t\thigherTick,\n\t\t\t\tquantityRaw,\n\t\t\t\tmaxCostRaw: opts.maxCost != null ? usdcToRaw(opts.maxCost) : undefined,\n\t\t\t\tmaxProbabilityRaw:\n\t\t\t\t\topts.maxProbability != null ? probabilityToRaw(opts.maxProbability) : undefined,\n\t\t\t\t...feeds,\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Shared construction for tx.redeem and read.quoteRedeem.\n\tasync #buildRedeem(owner: string, m: MarketDescriptor, opts: CloseOptions): Promise<Transaction> {\n\t\tconst feeds = this.#feeds(m.underlying);\n\t\tconst { id } = await this.#resolveMarket(m);\n\t\tconst closeQuantityRaw = usdcToRaw(opts.quantity);\n\t\tthis.#assertLot(closeQuantityRaw);\n\t\treturn txOf(\n\t\t\tredeemLive(this.#config, {\n\t\t\t\texpiryMarketId: id,\n\t\t\t\twrapperId: this.wrapperIdFor(owner),\n\t\t\t\torderId: opts.orderId,\n\t\t\t\tcloseQuantityRaw,\n\t\t\t\t...feeds,\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Raw strike for anonymous pricing: numeric strikes validate against the tick\n\t// grid; \"reference\" reads the market's reference tick fresh (unset → typed error).\n\tasync #strikeRawFor(\n\t\tm: BinaryMarketCoordinates,\n\t\tmarketId: string,\n\t\tstate: MarketState,\n\t): Promise<bigint> {\n\t\tif (m.strike !== 'reference') {\n\t\t\t// Same validation as the mint path: on the grid AND inside the finite tick\n\t\t\t// domain (0 / POS_INF are the ±inf sentinels, not quotable strikes).\n\t\t\treturn this.#gridTick(m.strike, state.tickSizeRaw) * state.tickSizeRaw;\n\t\t}\n\t\tconst tick = await referenceTick(this.#client, this.#config, marketId);\n\t\tif (tick == null) {\n\t\t\tthrow new PredictInputError(\n\t\t\t\t`reference price not set yet for ${m.underlying} @ ${m.expiryMs} — retry shortly or pass a numeric strike`,\n\t\t\t);\n\t\t}\n\t\treturn tick * state.tickSizeRaw;\n\t}\n\n\t// === tx builders ===\n\t// Each returns a ready-to-sign Transaction. Market-resolving builders are async.\n\treadonly tx = {\n\t\tcreateManager: (): Transaction => txOf(accountContract(this.cfg).createAccount()),\n\n\t\t// `create: true` composes first-time funding into ONE PTB: create the account\n\t\t// wrapper, deposit into it through the fresh handle, and `share` it LAST (once\n\t\t// shared, by-value use of the handle is over). The wrapper is derived from the\n\t\t// transaction SENDER (`account_registry::new` takes no owner), so `owner` MUST\n\t\t// be the address that signs this transaction — a sponsored/backend signer would\n\t\t// silently fund its own fresh account instead. The caller also asserts the\n\t\t// account does not exist yet: `new` ABORTS at the deterministic address if it\n\t\t// already exists — no chain read is done here. Gate on your own existence check\n\t\t// (`wrapperIdFor(owner)` + a getObject), or retry without the flag on that abort.\n\t\t//\n\t\t// Without `create`, the sourced coin goes into the existing account's stored\n\t\t// balance via the PTB-callable `deposit_funds` (folds settle → authorize → load →\n\t\t// deposit; clock auto-injected). Command order is auth → deposit (auth is a hot\n\t\t// potato consumed by the deposit). See\n\t\t// `packages/account/sources/account.move` (`deposit_funds`).\n\t\tdeposit: (\n\t\t\towner: string,\n\t\t\tamountUsdc: number | string,\n\t\t\topts?: { create?: boolean },\n\t\t): Transaction => {\n\t\t\tconst tx = new Transaction();\n\t\t\tconst coin = tx.add(\n\t\t\t\tcoinWithBalance({\n\t\t\t\t\ttype: this.cfg.quoteCoinType,\n\t\t\t\t\tbalance: usdcToRaw(amountUsdc),\n\t\t\t\t\tuseGasCoin: false,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (opts?.create) {\n\t\t\t\ttx.add(\n\t\t\t\t\taccountContract(this.cfg).createAccountAndDeposit({\n\t\t\t\t\t\tcoin,\n\t\t\t\t\t\tcoinType: this.cfg.quoteCoinType,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\ttx.add(\n\t\t\t\t\tdepositFunds({\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\targuments: { wrapper: this.wrapperIdFor(owner), coin },\n\t\t\t\t\t\ttypeArguments: [this.cfg.quoteCoinType],\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn tx;\n\t\t},\n\n\t\t// Withdraw `amountUsdc` from the account back to `owner`. By default the funds land\n\t\t// in the owner's USDC *address balance* (the versionless accumulator) via\n\t\t// `0x2::coin::send_funds` — no coin-object churn, and they merge into the same\n\t\t// balance `deposit` draws from, closing the loop. Pass `{ toCoinObject: true }` to\n\t\t// instead receive a discrete `Coin<T>` object (for wallets/explorers that only\n\t\t// render coin objects, or to compose the coin further in your own PTB). Either way\n\t\t// the underlying `withdraw_funds` returns the raw `Coin<T>` — the PTB-callable form\n\t\t// that folds settle → authorize → load → withdraw (clock auto-injected, `ctx`\n\t\t// implicit); command order is auth → withdraw. See\n\t\t// `packages/account/sources/account.move` (`withdraw_funds`).\n\t\twithdraw: (\n\t\t\towner: string,\n\t\t\tamountUsdc: number | string,\n\t\t\topts?: { toCoinObject?: boolean },\n\t\t): Transaction => {\n\t\t\tconst tx = new Transaction();\n\t\t\tconst coin = tx.add(\n\t\t\t\twithdrawFunds({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper: this.wrapperIdFor(owner), amount: usdcToRaw(amountUsdc) },\n\t\t\t\t\ttypeArguments: [this.cfg.quoteCoinType],\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (opts?.toCoinObject) {\n\t\t\t\ttx.transferObjects([coin], owner);\n\t\t\t} else {\n\t\t\t\ttx.moveCall({\n\t\t\t\t\ttarget: '0x2::coin::send_funds',\n\t\t\t\t\ttypeArguments: [this.cfg.quoteCoinType],\n\t\t\t\t\targuments: [coin, tx.pure.address(owner)],\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn tx;\n\t\t},\n\n\t\tmint: (owner: string, m: MarketDescriptor, opts: MintOptions): Promise<Transaction> =>\n\t\t\tthis.#buildMint(owner, m, opts),\n\n\t\tmintAmount: async (\n\t\t\towner: string,\n\t\t\tm: MarketDescriptor,\n\t\t\topts: MintAmountOptions,\n\t\t): Promise<Transaction> => {\n\t\t\tconst feeds = this.#feeds(m.underlying);\n\t\t\t// The chain requires a positive all-in cost cap (EMintCostCapRequired);\n\t\t\t// reject a zero cap pre-flight rather than surface a cryptic Move abort.\n\t\t\tif (opts.maxCost != null && opts.maxCost <= 0) {\n\t\t\t\tthrow new PredictInputError('maxCost must be > 0');\n\t\t\t}\n\t\t\tconst { id, state } = await this.#resolveMarket(m);\n\t\t\t// No lot check: min_quantity is a floor the chain compares against an\n\t\t\t// already-lot-floored minted quantity, so any floor value is legal.\n\t\t\tconst minQuantityRaw = usdcToRaw(opts.minQuantity);\n\t\t\tconst { lowerTick, higherTick } = await this.#strikeTicks(m, id, state);\n\t\t\treturn txOf(\n\t\t\t\tmintExactAmount(this.#config, {\n\t\t\t\t\texpiryMarketId: id,\n\t\t\t\t\twrapperId: this.wrapperIdFor(owner),\n\t\t\t\t\tlowerTick,\n\t\t\t\t\thigherTick,\n\t\t\t\t\tmaxPremiumRaw: usdcToRaw(opts.spend),\n\t\t\t\t\tminQuantityRaw,\n\t\t\t\t\tmaxCostRaw: opts.maxCost != null ? usdcToRaw(opts.maxCost) : undefined,\n\t\t\t\t\t...feeds,\n\t\t\t\t}),\n\t\t\t);\n\t\t},\n\n\t\tredeem: (owner: string, m: MarketDescriptor, opts: CloseOptions): Promise<Transaction> =>\n\t\t\tthis.#buildRedeem(owner, m, opts),\n\n\t\tclaimSettled: async (\n\t\t\towner: string,\n\t\t\tm: Pick<MarketDescriptor, 'underlying' | 'expiryMs' | 'marketId'>,\n\t\t\topts: Pick<CloseOptions, 'orderId'>,\n\t\t): Promise<Transaction> => {\n\t\t\tconst { id } = await this.#resolveMarket(m);\n\t\t\treturn txOf(\n\t\t\t\tredeemSettled(this.#config, {\n\t\t\t\t\texpiryMarketId: id,\n\t\t\t\t\twrapperId: this.wrapperIdFor(owner),\n\t\t\t\t\torderId: opts.orderId,\n\t\t\t\t}),\n\t\t\t);\n\t\t},\n\n\t\t// Queue a supply request pulling `amountUsdc` from the account's existing custody\n\t\t// balance. `request_supply` auto-settles USDC then `account.withdraw`s the payment\n\t\t// into queue escrow; the PLP fill is delivered at the next flush, not returned here.\n\t\t// Command order is auth → request (auth is a hot potato consumed by this call). The\n\t\t// `minPlpOut` slot is the per-request floor on PLP minted at flush — `options.minPlpOut`\n\t\t// when given, otherwise 0 (no floor). At the shipped attempt count of one, the first\n\t\t// flush whose mark quotes less cancels and refunds the request; three is the\n\t\t// configurable maximum, not the default.\n\t\tsupplyPlp: (\n\t\t\towner: string,\n\t\t\tamountUsdc: number | string,\n\t\t\toptions: PlpSupplyOptions = {},\n\t\t): Transaction =>\n\t\t\ttxOf(\n\t\t\t\trequestSupply({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\twrapper: this.wrapperIdFor(owner),\n\t\t\t\t\t\tamount: usdcToRaw(amountUsdc),\n\t\t\t\t\t\tminPlpOut: options.minPlpOut ?? 0n,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t),\n\n\t\t// Queue a withdraw request pulling `shares` (raw PLP u64) from account custody into\n\t\t// queue escrow — the Move parameter is named `amount`, but on `request_withdraw` it\n\t\t// counts PLP SHARES, not USDC. Auto-settles flush-delivered PLP first; the USDC\n\t\t// fill lands on the account at the next flush (no `withdraw_settled` entrypoint).\n\t\t// Command order is auth → request. The `minUsdcOut` slot is the per-request floor\n\t\t// on USDC paid at flush — `options.minUsdcOut` when given, otherwise 0 (no floor).\n\t\t// At the shipped attempt count of one, the first flush whose mark quotes less\n\t\t// cancels and refunds the request; three is the configurable maximum, not the\n\t\t// default.\n\t\twithdrawPlp: (owner: string, shares: bigint, options: PlpWithdrawOptions = {}): Transaction =>\n\t\t\ttxOf(\n\t\t\t\trequestWithdraw({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\twrapper: this.wrapperIdFor(owner),\n\t\t\t\t\t\tamount: shares,\n\t\t\t\t\t\tminUsdcOut: options.minUsdcOut === undefined ? 0n : usdcToRaw(options.minUsdcOut),\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t),\n\n\t\t// Cancel a still-pending supply request by queue `index`, refunding its escrowed\n\t\t// USDC straight back into the requesting account. Command order is auth → cancel.\n\t\tcancelSupplyPlp: (owner: string, index: bigint): Transaction =>\n\t\t\ttxOf(\n\t\t\t\tcancelSupplyRequest({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper: this.wrapperIdFor(owner), index },\n\t\t\t\t}),\n\t\t\t),\n\n\t\t// Cancel a still-pending withdraw request by queue `index`, refunding its escrowed\n\t\t// PLP straight back into the requesting account. Command order is auth → cancel.\n\t\tcancelWithdrawPlp: (owner: string, index: bigint): Transaction =>\n\t\t\ttxOf(\n\t\t\t\tcancelWithdrawRequest({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper: this.wrapperIdFor(owner), index },\n\t\t\t\t}),\n\t\t\t),\n\n\t\t// Set the account's sticky builder-code attribution to `builderCodeId`, an existing\n\t\t// `BuilderCode` object borrowed as `&BuilderCode`. Command order is auth → set (auth\n\t\t// is a hot potato consumed by this call). Lives in the PREDICT package's\n\t\t// `predict_account` module, NOT the account package. Deployed sig\n\t\t// `packages/predict/sources/predict_account.move:134` — 3 moveCall args\n\t\t// (wrapper, auth, code; ctx implicit).\n\t\tsetBuilderCode: (owner: string, builderCodeId: string): Transaction =>\n\t\t\ttxOf(\n\t\t\t\tsetBuilderCode({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper: this.wrapperIdFor(owner), code: builderCodeId },\n\t\t\t\t}),\n\t\t\t),\n\n\t\t// Clear the account's sticky builder-code attribution. Command order is auth → unset.\n\t\t// Deployed sig `.../predict_account.move:151` — 2 moveCall args (wrapper, auth; ctx\n\t\t// implicit).\n\t\tunsetBuilderCode: (owner: string): Transaction =>\n\t\t\ttxOf(\n\t\t\t\tunsetBuilderCode({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper: this.wrapperIdFor(owner) },\n\t\t\t\t}),\n\t\t\t),\n\t};\n\n\t// === reads ===\n\treadonly read = {\n\t\t// All tradeable (active) markets with the state a frontend needs to render\n\t\t// and mint: one chain read for ids + one batched PTB for the states.\n\t\tmarkets: async (): Promise<ActiveMarket[]> => {\n\t\t\tconst ids = await activeMarketIds(this.#client, this.#config);\n\t\t\tconst states = await marketStates(this.#client, this.#config, ids);\n\t\t\treturn ids.map((id, i) => ({\n\t\t\t\tid,\n\t\t\t\texpiryMs: states[i].expiryMs,\n\t\t\t\ttickSize: fromRaw(states[i].tickSizeRaw, 9),\n\t\t\t\tadmissionTickSize: fromRaw(states[i].admissionTickSizeRaw, 9),\n\t\t\t\tmintPaused: states[i].mintPaused,\n\t\t\t\treferencePrice: PredictClient.#referencePriceOf(states[i]),\n\t\t\t}));\n\t\t},\n\n\t\t// Validate an app-stored order id against the chain (stale after full\n\t\t// close or partial-close replacement — see RedeemReceipt.replacementOrderId).\n\t\thasPosition: (owner: string, marketId: string, orderId: bigint): Promise<boolean> =>\n\t\t\thasPosition(this.#client, this.#config, owner, marketId, orderId),\n\n\t\t// All open positions for an owner, enumerated from the chain (the\n\t\t// account's positions Table): 1 call per page warm, +2 resolution calls\n\t\t// once per owner. Returns [] for owners with no Predict account.\n\t\tpositions: async (owner: string): Promise<OpenPosition[]> => {\n\t\t\tlet handle = this.#positionsCache.get(owner);\n\t\t\tif (!handle?.positionsTableId) {\n\t\t\t\tconst resolved = await resolvePositionsTable(this.#client, this.#config, owner);\n\t\t\t\tif (!resolved) return []; // never onboarded — do not cache\n\t\t\t\tif (resolved.positionsTableId) this.#positionsCache.set(owner, resolved);\n\t\t\t\thandle = resolved;\n\t\t\t}\n\t\t\tif (!handle.positionsTableId) return [];\n\t\t\treturn positionsFromTable(this.#client, handle.positionsTableId);\n\t\t},\n\n\t\t// Anonymous board pricing: the chain's probability for both sides of a\n\t\t// strike, from one fresh pricer (no account needed). This is the ↑/↓\n\t\t// button price before a user has onboarded.\n\t\tprice: async (m: BinaryMarketCoordinates): Promise<{ up: number; down: number }> => {\n\t\t\tconst feeds = this.#feeds(m.underlying);\n\t\t\tconst { id, state } = await this.#resolveMarket(m);\n\t\t\tconst strikeRaw = await this.#strikeRawFor(m, id, state);\n\t\t\tconst { upRaw, downRaw } = await rangePrices(\n\t\t\t\tthis.#client,\n\t\t\t\tthis.#config,\n\t\t\t\tid,\n\t\t\t\tfeeds,\n\t\t\t\tstrikeRaw,\n\t\t\t\tstate.tickSizeRaw,\n\t\t\t);\n\t\t\treturn { up: rawToProbability(upRaw), down: rawToProbability(downRaw) };\n\t\t},\n\n\t\t// A client-side board pricer for one market: ONE simulate reads the chain's\n\t\t// resolved pricer (already forward-selected + rolled to now), then prices every\n\t\t// strike LOCALLY with no further chain calls — `pricer.up(strike)`,\n\t\t// `.down(strike)`, `.range(lo,hi)`, `.strikeAtProbability(p)`. Use this to paint a\n\t\t// whole board instantly; `read.price` / `read.quoteMint` stay the authoritative\n\t\t// per-strike quote at trade time. Throws the same typed stale-oracle/expired\n\t\t// PredictMoveError `read.price` would when the chain itself cannot quote.\n\t\tpricer: async (\n\t\t\tm: Pick<MarketDescriptor, 'underlying' | 'expiryMs'>,\n\t\t): Promise<BoardPricer & { asOf: PricerSnapshot['sources'] }> => {\n\t\t\tconst feeds = this.#feeds(m.underlying);\n\t\t\tconst { id } = await this.#resolveMarket(m);\n\t\t\tconst snap = await readPricerSnapshot(this.#client, this.#config, id, feeds);\n\t\t\treturn { ...boardPricer(snap), asOf: snap.sources };\n\t\t},\n\n\t\t// Exact pre-trade quote: dry-runs the caller's own mint (same tx as\n\t\t// tx.mint) and decodes the receipt. Requires a funded account; throws\n\t\t// the same typed errors the real trade would — quote doubles as preflight.\n\t\tquoteMint: async (\n\t\t\towner: string,\n\t\t\tm: MarketDescriptor,\n\t\t\topts: Pick<MintOptions, 'quantity'>,\n\t\t): Promise<MintQuote> => {\n\t\t\tconst tx = await this.#buildMint(owner, m, opts);\n\t\t\tconst events = await simulateWithEvents(this.#client, tx, owner);\n\t\t\tconst r = exactlyOne(decodeMints(this.cfg, { events }), 'OrderMinted');\n\t\t\t// Mirrors the deployed `compute_mint_quote`'s all_in_cost exactly:\n\t\t\t// premium + (trading − subsidy) + builder + penalty + inventory-impact.\n\t\t\t// `referral_fee` is deliberately NOT added — it is a portion OF the\n\t\t\t// trader-paid trading fee and congestion surcharge, not an extra debit.\n\t\t\tconst costRaw =\n\t\t\t\tr.raw.premium +\n\t\t\t\t(r.raw.tradingFee - r.raw.feeIncentiveSubsidy) +\n\t\t\t\tr.raw.builderFee +\n\t\t\t\tr.raw.penaltyFee +\n\t\t\t\tr.raw.inventoryImpactCharge;\n\t\t\treturn {\n\t\t\t\tentryProbability: r.entryProbability,\n\t\t\t\tpremium: r.premium,\n\t\t\t\tfees: r.fees,\n\t\t\t\tcost: rawToUsdc(costRaw),\n\t\t\t\tquantity: r.quantity,\n\t\t\t\traw: {\n\t\t\t\t\tpremium: r.raw.premium,\n\t\t\t\t\tcost: costRaw,\n\t\t\t\t\tquantity: r.raw.quantity,\n\t\t\t\t\tentryProbability: r.raw.entryProbability,\n\t\t\t\t},\n\t\t\t\tfeesExact: true,\n\t\t\t};\n\t\t},\n\n\t\t// Exact pre-close quote: dry-runs the caller's own redeem and decodes\n\t\t// the receipt — the informed close against the floor-less deployed redeem.\n\t\tquoteRedeem: async (\n\t\t\towner: string,\n\t\t\tm: MarketDescriptor,\n\t\t\topts: CloseOptions,\n\t\t): Promise<RedeemQuote> => {\n\t\t\tconst tx = await this.#buildRedeem(owner, m, opts);\n\t\t\tconst events = await simulateWithEvents(this.#client, tx, owner);\n\t\t\tconst r = exactlyOne(decodeRedeems(this.cfg, { events }), 'order-redeemed');\n\t\t\treturn {\n\t\t\t\tproceeds: r.proceeds,\n\t\t\t\tgross: r.gross,\n\t\t\t\tfees: r.fees,\n\t\t\t\tquantityClosed: r.quantityClosed,\n\t\t\t\tremaining: r.remaining,\n\t\t\t\traw: {\n\t\t\t\t\tproceeds: r.raw.proceeds,\n\t\t\t\t\tgross: r.raw.gross,\n\t\t\t\t\tquantityClosed: r.raw.quantityClosed,\n\t\t\t\t},\n\t\t\t\tfeesExact: true,\n\t\t\t};\n\t\t},\n\n\t\tmarket: async (\n\t\t\tm: Pick<MarketDescriptor, 'underlying' | 'expiryMs'>,\n\t\t): Promise<MarketSummary | null> => {\n\t\t\tconst expiryMs = BigInt(m.expiryMs);\n\t\t\t// Deliberately re-queries and overwrites the cache instead of reading\n\t\t\t// through it: this read must return live state (nav, mintPaused), and\n\t\t\t// refreshing the cache on the way keeps later tx builds consistent.\n\t\t\tconst u = this.#underlying(m.underlying);\n\t\t\tconst id = await expiryMarketId(this.#client, this.#config, u, expiryMs);\n\t\t\tif (!id) return null;\n\t\t\tconst state = await marketState(this.#client, this.#config, id);\n\t\t\tthis.#marketCache.set(`${m.underlying}:${expiryMs}`, { id, state });\n\t\t\tconst navRaw = await currentNav(this.#client, this.#config, id, u);\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\texpiryMs: state.expiryMs,\n\t\t\t\ttickSize: fromRaw(state.tickSizeRaw, 9), // strike/price scale\n\t\t\t\tadmissionTickSize: fromRaw(state.admissionTickSizeRaw, 9),\n\t\t\t\tmintPaused: state.mintPaused,\n\t\t\t\tnav: rawToUsdc(navRaw),\n\t\t\t\treferencePrice: PredictClient.#referencePriceOf(state),\n\t\t\t};\n\t\t},\n\n\t\tbalance: async (owner: string): Promise<number> =>\n\t\t\trawToUsdc(await accountBalance(this.#client, this.#config, owner, this.cfg.quoteCoinType)),\n\n\t\t// PLP shares held in the owner's account custody (raw u64, 6-decimal PLP coin).\n\t\tplpBalance: (owner: string): Promise<bigint> =>\n\t\t\taccountBalance(this.#client, this.#config, owner, this.cfg.coinTypes.plp),\n\n\t\tpool: async (): Promise<PoolSummary> => {\n\t\t\tconst s = await poolStats(this.#client, this.#config);\n\t\t\treturn {\n\t\t\t\tplpTotalSupply: s.plpTotalSupply, // shares raw (6-decimal)\n\t\t\t\tidleUsdc: rawToUsdc(s.idleBalance),\n\t\t\t\t// These are queue LENGTHS (counts of pending requests), not token amounts.\n\t\t\t\tsupplyRequestsPending: Number(s.supplyRequestsPending),\n\t\t\t\twithdrawRequestsPending: Number(s.withdrawRequestsPending),\n\t\t\t};\n\t\t},\n\t};\n\n\t// === execution-result decoders ===\n\t// Pure event parsing (no network): pass the executed/simulated transaction\n\t// result (with events included) and get a typed receipt back. Singular forms\n\t// throw unless exactly one matching event exists; plural forms return all\n\t// (an integrator batching N actions in one PTB gets N receipts).\n\treadonly decode = {\n\t\tmint: (r: DecodableTransactionResult) => exactlyOne(decodeMints(this.cfg, r), 'OrderMinted'),\n\t\tmints: (r: DecodableTransactionResult) => decodeMints(this.cfg, r),\n\t\tredeem: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodeRedeems(this.cfg, r), 'order-redeemed'),\n\t\tredeems: (r: DecodableTransactionResult) => decodeRedeems(this.cfg, r),\n\t\tclaim: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodeClaims(this.cfg, r), 'SettledOrderRedeemed'),\n\t\tclaims: (r: DecodableTransactionResult) => decodeClaims(this.cfg, r),\n\t\tcreateManager: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodeAccountsCreated(this.cfg, r), 'AccountCreated'),\n\t\tdeposit: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodeDeposits(this.cfg, r), 'Deposited'),\n\t\twithdraw: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodeWithdrawals(this.cfg, r), 'Withdrawn'),\n\t\tplpRequest: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodePlpRequests(this.cfg, r), 'supply/withdraw-requested'),\n\t\tplpCancel: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodePlpCancels(this.cfg, r), 'RequestCancelled'),\n\t\tbuilderCode: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodeBuilderCodeSets(this.cfg, r), 'BuilderCodeSet'),\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,MAAa,oBAAoB,OAAO,gBAAgB,MAAM,gBAAgB;AAG9E,SAAS,KAAK,SAAqE;CAClF,MAAM,KAAK,IAAI,aAAa;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AM,QAAQ,MAAKH,MAAO,EAAE,WAAW;EACvC,MAAM,EAAE,OAAO,MAAM,MAAKC,cAAe,EAAE;EAC3C,MAAM,mBAAmB,UAAU,KAAK,SAAS;AACjD,QAAKY,UAAW,iBAAiB;AACjC,SAAO,KACN,WAAW,MAAKhB,QAAS;GACxB,gBAAgB;GAChB,WAAW,KAAK,aAAa,MAAM;GACnC,SAAS,KAAK;GACd;GACA,GAAG;GACH,CAAC,CACF;;CAKF,OAAMU,aACL,GACA,UACA,OACkB;AAClB,MAAI,EAAE,WAAW,YAGhB,QAAO,MAAKK,SAAU,EAAE,QAAQ,MAAM,YAAY,GAAG,MAAM;EAE5D,MAAM,OAAO,MAAM,cAAc,MAAKR,QAAS,MAAKP,QAAS,SAAS;AACtE,MAAI,QAAQ,KACX,OAAM,IAAI,kBACT,mCAAmC,EAAE,WAAW,KAAK,EAAE,SAAS,2CAChE;AAEF,SAAO,OAAO,MAAM"}
|
|
1
|
+
{"version":3,"file":"client.mjs","names":["#config","opts","#buildMint","#feeds","#resolveMarket","#strikeTicks","#buildRedeem","#client","#referencePriceOf","#positionsCache","#strikeRawFor","#underlying","#marketCache","resolved","#assertAdmittedTick","#gridTick","#assertLot"],"sources":["../../src/predict/client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { ClientWithCoreApi, SuiClientRegistration } from '@mysten/sui/client';\nimport { Transaction, coinWithBalance, type TransactionResult } from '@mysten/sui/transactions';\nimport { isValidSuiObjectId } from '@mysten/sui/utils';\nimport { TESTNET_PREDICT } from '../deployments/testnet.js';\nimport { getConfig, type PredictConfig, type UnderlyingConfig } from './config/index.js';\nimport { toGeneratedConfig, type GeneratedConfig } from './config/generated.js';\nimport {\n\tdecodeAccountsCreated,\n\tdecodeBuilderCodeSets,\n\tdecodeClaims,\n\tdecodeDeposits,\n\tdecodeMints,\n\tdecodePlpCancels,\n\tdecodePlpRequests,\n\tdecodeRedeems,\n\tdecodeWithdrawals,\n\texactlyOne,\n\ttype DecodableTransactionResult,\n} from './decode.js';\nimport { PredictInputError } from './errors.js';\nimport { simulateWithEvents } from './reads/inspect.js';\nimport {\n\tpositionsFromTable,\n\tresolvePositionsTable,\n\ttype OpenPosition,\n\ttype PositionsHandle,\n} from './reads/positions.js';\nimport { accountBalance, hasPosition } from './reads/balances.js';\nimport {\n\tactiveMarketIds,\n\tcurrentNav,\n\texpiryMarketId,\n\tmarketState,\n\tmarketStates,\n\trangePrices,\n\treferenceTick,\n\ttype MarketState,\n} from './reads/markets.js';\nimport { poolStats } from './reads/pool.js';\nimport { readPricerSnapshot, type PricerSnapshot } from './reads/pricing.js';\nimport { boardPricer, type BoardPricer } from './pricing.js';\nimport { POS_INF_TICK, binaryRangeTicks, type Side } from './ticks.js';\nimport {\n\tcancelSupplyRequest,\n\tcancelWithdrawRequest,\n\tdepositFunds,\n\trequestSupply,\n\trequestWithdraw,\n\tsetBuilderCode,\n\tunsetBuilderCode,\n\twithdrawFunds,\n} from './tx/authed.js';\n\nimport { accountContract, deriveAccountWrapperIdFrom } from './tx/common.js';\nimport type { MarketFeeds } from './tx/trade.js';\nimport { mintExactAmount, mintExactQuantity, redeemLive, redeemSettled } from './tx/trade.js';\nimport {\n\tpriceToRaw,\n\tprobabilityToRaw,\n\trawToProbability,\n\trawToUsdc,\n\tusdcToRaw,\n\tfromRaw,\n} from './units.js';\n\n// `position_lot_size` — a position quantity must be a whole multiple of this many\n// raw payout units ($0.01 lots). See packages/predict/sources/constants.move.\n/**\n * Testnet's `position_lot_size`, read from the deployment record. Validation uses the lot\n * size of the config actually in play; this is the convenience constant for testnet callers.\n */\nexport const POSITION_LOT_SIZE = BigInt(TESTNET_PREDICT.units.positionLotSize);\n\n// Most `tx.*` builders are one builder's worth of commands in a fresh PTB.\nfunction txOf(command: (tx: Transaction) => TransactionResult | void): Transaction {\n\tconst tx = new Transaction();\n\ttx.add(command);\n\treturn tx;\n}\n\n/** A live/settled market addressed by its human coordinates: a binary position\n * (single strike + side) or a two-strike range position. */\nexport type MarketDescriptor = {\n\tunderlying: string;\n\texpiryMs: number | bigint;\n\t/**\n\t * Pin resolution to this exact `ExpiryMarket` object, skipping the\n\t * underlying+expiry lookup — a caller that reviewed a specific market object\n\t * mints against exactly that object, not whatever resolves at submit time.\n\t */\n\tmarketId?: string;\n} & (\n\t| {\n\t\t\tside: Side;\n\t\t\t/**\n\t\t\t * Strike in USD, or \"reference\" to trade at the market's on-chain reference\n\t\t\t * price (the Polymarket-style anchor: derived from the exact previous-window\n\t\t\t * oracle observation, so consecutive windows chain settlement → next strike).\n\t\t\t */\n\t\t\tstrike: number | 'reference';\n\t }\n\t| {\n\t\t\t/** A range position: pays out when settlement lands inside `(lower, upper]`\n\t\t\t * (left-open, right-closed — same convention as the on-chain range key). */\n\t\t\tside: 'range';\n\t\t\t/** Lower strike bound in USD — finite, on the tick grid. */\n\t\t\tlower: number;\n\t\t\t/** Upper strike bound in USD — finite, on the tick grid, above `lower`. */\n\t\t\tupper: number;\n\t }\n);\n\n/** Options for the friendly `mint` (exact payout quantity). */\nexport interface MintOptions {\n\tquantity: number;\n\tmaxCost?: number;\n\tmaxProbability?: number;\n}\n\n/** Options for `mintAmount` (spend up to a premium budget, floor the quantity received). */\nexport interface MintAmountOptions {\n\t/** Premium budget in quote units — the max premium paid (chain also caps it at the account balance). */\n\tspend: number;\n\tminQuantity: number;\n\t/** All-in cost ceiling in quote units (premium + fees). Omitted → uncapped. */\n\tmaxCost?: number;\n}\n\n/** Options for `redeem`: which order and how much to close. `claimSettled` takes only\n * `orderId` — a settled claim closes the order in full. */\nexport interface CloseOptions {\n\torderId: bigint;\n\tquantity: number;\n}\n\n/** Options for `supplyPlp`. */\nexport interface PlpSupplyOptions {\n\t/**\n\t * Floor on the PLP minted for the whole request, as raw `bigint` shares — PLP is raw\n\t * everywhere in this SDK. It is a floor on the MARK, not a share count: a flush quoting\n\t * less does not fill smaller, it declines. Omitted → `0n`, no floor.\n\t *\n\t * How a miss is handled is the deployment's `lp_request_limit_flush_attempts`: at the\n\t * shipped count of one the first flush below the floor cancels and refunds the request.\n\t */\n\tminPlpOut?: bigint;\n}\n\n/** Options for `withdrawPlp`. */\nexport interface PlpWithdrawOptions {\n\t/**\n\t * Floor on the USDC paid for the whole request, in USD decimals like every other amount\n\t * here. A floor on the MARK, not an amount: a flush quoting less declines rather than\n\t * paying out smaller. Omitted → no floor. Measured after the protocol's withdraw fee.\n\t */\n\tminUsdcOut?: number | string;\n}\n\n/** One tradeable market as returned by read.markets(). */\nexport interface ActiveMarket {\n\tid: string;\n\texpiryMs: bigint;\n\t/** Strike granularity in USD (e.g. 0.01). */\n\ttickSize: number;\n\t/**\n\t * Coarser step new mint strikes must align to. A numeric strike must be a whole\n\t * multiple of this (the market's `referencePrice` is the one exception the chain\n\t * admits off-grid); otherwise the mint aborts `EInvalidAdmissionTick`.\n\t */\n\tadmissionTickSize: number;\n\tmintPaused: boolean;\n\t/** The window's anchor strike in USD, or null until the keeper seeds it. */\n\treferencePrice: number | null;\n}\n\n/** A resolved live market: its on-chain state summary for the caller. */\nexport interface MarketSummary {\n\tid: string;\n\texpiryMs: bigint;\n\ttickSize: number;\n\t/**\n\t * Coarser step new mint strikes must align to. A numeric strike must be a whole\n\t * multiple of this (the market's `referencePrice` is the one exception the chain\n\t * admits off-grid); otherwise the mint aborts `EInvalidAdmissionTick`.\n\t */\n\tadmissionTickSize: number;\n\tmintPaused: boolean;\n\tnav: number;\n\t/** The window's anchor strike in USD, or null until the keeper seeds it. */\n\treferencePrice: number | null;\n}\n\n/** Aggregate pool figures. Balances in human units (shares raw); the pending fields\n * are request COUNTS, not amounts — the on-chain getters expose queue lengths, and\n * the escrowed USDC/PLP behind them is tracked separately. */\nexport interface PoolSummary {\n\tplpTotalSupply: bigint;\n\tidleUsdc: number;\n\t/** Number of LP supply requests queued for the next flush. */\n\tsupplyRequestsPending: number;\n\t/** Number of LP withdraw requests queued for the next flush. */\n\twithdrawRequestsPending: number;\n}\n\n/** Exact pre-trade quote: the dry-run receipt of the mint you are about to send. */\nexport interface MintQuote {\n\t/** Fill price, 0..1 per $1 payout. */\n\tentryProbability: number;\n\t/** Premium paid into LP backing (quote units). */\n\tpremium: number;\n\t/**\n\t * Fee breakdown. `referral` is a PORTION of the trader-paid trading fee and\n\t * congestion surcharge routed to the referrer — it is already inside those\n\t * numbers and is NOT an extra debit. `inventoryImpact` is a separate charge and\n\t * IS part of `cost`.\n\t */\n\tfees: {\n\t\ttrading: number;\n\t\tsubsidy: number;\n\t\tbuilder: number;\n\t\tpenalty: number;\n\t\treferral: number;\n\t\tinventoryImpact: number;\n\t};\n\t/**\n\t * All-in account debit: premium + (trading − subsidy) + builder + penalty +\n\t * inventoryImpact — exactly what the chain withdraws (the deployed\n\t * `compute_mint_quote`'s `all_in_cost`); pass this (plus your buffer) as maxCost.\n\t */\n\tcost: number;\n\tquantity: number;\n\traw: { premium: bigint; cost: bigint; quantity: bigint; entryProbability: bigint };\n\t/** True: computed by the real mint code path against real account state. */\n\tfeesExact: true;\n}\n\n/** Exact pre-close quote: the dry-run receipt of the redeem you are about to send. */\nexport interface RedeemQuote {\n\t/** NET quote credited to the account. */\n\tproceeds: number;\n\t/** Gross close value before fees. */\n\tgross: number;\n\t/** `inventoryImpactRebate` is credited back on the close, so `proceeds` is\n\t * gross + rebate − trading − builder − penalty. */\n\tfees: { trading: number; builder: number; penalty: number; inventoryImpactRebate: number };\n\tquantityClosed: number;\n\tremaining: number;\n\traw: { proceeds: bigint; gross: bigint; quantityClosed: bigint };\n\tfeesExact: true;\n}\n\ninterface ResolvedMarket {\n\tid: string;\n\tstate: MarketState;\n}\n\n// The strike-bearing (binary) arm of MarketDescriptor, for read.price and its\n// seam — anonymous board pricing has no range semantics.\ntype BinaryMarketCoordinates = Pick<MarketDescriptor, 'underlying' | 'expiryMs' | 'marketId'> & {\n\tstrike: number | 'reference';\n};\n\n/** The Sui client surface PredictClient reads through: any `ClientWithCoreApi`\n * (gRPC or JSON-RPC) provides both the `simulateTransaction` the reads/quotes\n * sit on and the `core` object methods position enumeration needs. */\nexport interface PredictCompatibleClient extends ClientWithCoreApi {}\n\n/**\n * Register PredictClient as a `client.predict` extension, mirroring\n * `@mysten/deepbook-v3`'s `deepbook(...)`: `client.$extend(predict({ network }))`.\n */\nexport function predict<Name extends string = 'predict'>({\n\tname = 'predict' as Name,\n\tnetwork,\n\tconfig,\n}: {\n\tname?: Name;\n\tnetwork: 'testnet' | 'mainnet';\n\tconfig?: PredictConfig;\n}): SuiClientRegistration<PredictCompatibleClient, Name, PredictClient> {\n\treturn {\n\t\tname,\n\t\tregister: (client) => new PredictClient({ client, network, config }),\n\t};\n}\n\n/**\n * The one object an app constructs. Wraps the config, a client for reads, and\n * a derived-account model so callers pass owner addresses, decimal amounts, and\n * human market coordinates — the facade converts to raw units, resolves markets\n * (cached), and delegates to the internal tx primitives / reads. Each `tx.*` builder\n * returns a finished `Transaction`; callers composing their own PTBs use the generated\n * move-call bindings this subpath exports (`plpMoveCalls`, `expiryMarketMoveCalls`, …).\n */\nexport class PredictClient {\n\treadonly cfg: PredictConfig;\n\t// The flat slice every generated call resolves `options.config` against.\n\tget #config(): GeneratedConfig {\n\t\treturn toGeneratedConfig(this.cfg);\n\t}\n\t#client: PredictCompatibleClient;\n\t// underlying:expiryMs → resolved market. The id and tickSizeRaw — the only\n\t// state tx building depends on — are immutable per (underlying, expiry), so\n\t// one resolution per market per client suffices. (mintPaused IS mutable; the\n\t// cached copy is never consulted for a tx decision — the chain enforces it.)\n\t#marketCache = new Map<string, ResolvedMarket>();\n\t// owner → resolved position-store ids. accountUid and the table id are\n\t// immutable once created, so cache-forever; a missing table (no Predict\n\t// data yet) is NOT cached — it appears after the owner's first trade.\n\t#positionsCache = new Map<string, PositionsHandle>();\n\n\tconstructor(opts: {\n\t\tnetwork: 'testnet' | 'mainnet';\n\t\tclient: PredictCompatibleClient;\n\t\tconfig?: PredictConfig;\n\t}) {\n\t\tthis.cfg = opts.config ?? getConfig(opts.network);\n\t\tthis.#client = opts.client;\n\t}\n\n\t/** The deterministic id of an owner's canonical account wrapper — no chain read. */\n\twrapperIdFor(owner: string): string {\n\t\treturn deriveAccountWrapperIdFrom(this.#config, owner);\n\t}\n\n\t// The deployment's wiring for a symbol; throws a typed error on an unknown symbol.\n\t// Per-underlying ids are the one thing the flat config slice does not carry.\n\t#underlying(underlying: string): UnderlyingConfig {\n\t\tconst u = this.cfg.underlyings[underlying];\n\t\tif (!u) throw new PredictInputError(`unknown underlying: ${underlying}`);\n\t\treturn u;\n\t}\n\n\t// The oracle feed ids for a symbol; throws a typed error on an unknown symbol.\n\t#feeds(underlying: string): MarketFeeds {\n\t\tconst u = this.#underlying(underlying);\n\t\treturn {\n\t\t\tpythFeed: u.pythFeed,\n\t\t\tblockScholesValueStore: u.blockScholesValueStore,\n\t\t\tblockScholesSviStore: u.blockScholesSviStore,\n\t\t};\n\t}\n\n\t// Resolve (and cache) a market's id + state from its human coordinates. An\n\t// explicit `marketId` pin skips the underlying+expiry lookup but still reads\n\t// that market's state — tx building depends on tickSizeRaw.\n\tasync #resolveMarket(\n\t\tm: Pick<MarketDescriptor, 'underlying' | 'expiryMs' | 'marketId'>,\n\t): Promise<ResolvedMarket> {\n\t\tif (m.marketId != null) {\n\t\t\tif (!isValidSuiObjectId(m.marketId)) {\n\t\t\t\tthrow new PredictInputError(`invalid marketId: ${JSON.stringify(m.marketId)}`);\n\t\t\t}\n\t\t\tconst resolved: ResolvedMarket = this.#marketCache.get(m.marketId) ?? {\n\t\t\t\tid: m.marketId,\n\t\t\t\tstate: await marketState(this.#client, this.#config, m.marketId),\n\t\t\t};\n\t\t\t// The pin must agree with the descriptor's coordinates: catching a stale or\n\t\t\t// wrong-market id here beats minting against mismatched oracle feeds. (The\n\t\t\t// underlying cannot be cross-checked — market state does not carry it.)\n\t\t\tif (resolved.state.expiryMs !== BigInt(m.expiryMs)) {\n\t\t\t\tthrow new PredictInputError(\n\t\t\t\t\t`pinned market ${m.marketId} expires at ${resolved.state.expiryMs}, descriptor says ${BigInt(m.expiryMs)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.#marketCache.set(m.marketId, resolved);\n\t\t\treturn resolved;\n\t\t}\n\t\tconst expiryMs = BigInt(m.expiryMs);\n\t\tconst key = `${m.underlying}:${expiryMs}`;\n\t\tconst hit = this.#marketCache.get(key);\n\t\tif (hit) return hit;\n\t\tconst u = this.#underlying(m.underlying);\n\t\tconst id = await expiryMarketId(this.#client, this.#config, u, expiryMs);\n\t\tif (!id) throw new PredictInputError(`no market for ${m.underlying} at expiry ${expiryMs}`);\n\t\tconst state = await marketState(this.#client, this.#config, id);\n\t\tconst resolved: ResolvedMarket = { id, state };\n\t\tthis.#marketCache.set(key, resolved);\n\t\treturn resolved;\n\t}\n\n\t// Reference PRICE in USD from a state (tick index × tick size), or null.\n\tstatic #referencePriceOf(state: MarketState): number | null {\n\t\treturn state.referenceTickRaw == null\n\t\t\t? null\n\t\t\t: fromRaw(state.referenceTickRaw * state.tickSizeRaw, 9);\n\t}\n\n\t// A finite tick from a USD strike, validated exactly like binaryRangeTicks:\n\t// whole-tick multiple, inside the finite domain (1..POS_INF_TICK-1).\n\t#gridTick(strike: number, tickSizeRaw: bigint): bigint {\n\t\tconst raw = priceToRaw(strike);\n\t\tconst tick = raw / tickSizeRaw;\n\t\tif (tick * tickSizeRaw !== raw) {\n\t\t\tthrow new PredictInputError(\n\t\t\t\t`strike ${strike} is not on the ${fromRaw(tickSizeRaw, 9)} tick grid`,\n\t\t\t);\n\t\t}\n\t\tif (tick <= 0n || tick >= POS_INF_TICK) {\n\t\t\tthrow new PredictInputError(\n\t\t\t\t`strike tick ${tick} outside the finite tick domain (1..POS_INF_TICK-1)`,\n\t\t\t);\n\t\t}\n\t\treturn tick;\n\t}\n\n\t// New finite MINT boundaries must land on the market's coarser ADMISSION grid,\n\t// not merely the fine tick grid — the chain asserts exactly this\n\t// (`assert_admitted_mint_ticks`, `EInvalidAdmissionTick`). The ±inf sentinels are\n\t// exempt, and the market's reference tick is the one finite boundary allowed to\n\t// bypass the grid, so an off-grid tick is only rejected after confirming it is not\n\t// the reference (one extra read, and only on the failing path).\n\tasync #assertAdmittedTick(tick: bigint, marketId: string, state: MarketState): Promise<void> {\n\t\tif (tick === 0n || tick === POS_INF_TICK) return;\n\t\tconst multiple = state.admissionTickSizeRaw / state.tickSizeRaw;\n\t\tif (multiple > 0n && tick % multiple === 0n) return;\n\t\tconst reference = await referenceTick(this.#client, this.#config, marketId);\n\t\tif (reference != null && reference === tick) return;\n\t\tconst admission = fromRaw(state.admissionTickSizeRaw, 9);\n\t\tthrow new PredictInputError(\n\t\t\t`strike ${fromRaw(tick * state.tickSizeRaw, 9)} is not on the ${admission} admission grid ` +\n\t\t\t\t`(mint boundaries must be a multiple of ${admission}, or the market's reference strike)`,\n\t\t);\n\t}\n\n\t// Resolve a descriptor's strike(s) to the (lower, higher) tick pair. A binary\n\t// numeric strike converts and validates against the tick grid; \"reference\"\n\t// reads the market's reference tick FRESH (never cached — it is unset early in\n\t// a window) and uses it directly: it is on the tick grid by construction. A\n\t// range descriptor converts both bounds to finite grid ticks (\"reference\" is\n\t// binary-only: a range has no single reference strike).\n\tasync #strikeTicks(\n\t\tm: MarketDescriptor,\n\t\tmarketId: string,\n\t\tstate: MarketState,\n\t): Promise<{ lowerTick: bigint; higherTick: bigint }> {\n\t\tif (m.side === 'range') {\n\t\t\tif (!(m.lower < m.upper)) {\n\t\t\t\tthrow new PredictInputError(`range lower ${m.lower} must be below upper ${m.upper}`);\n\t\t\t}\n\t\t\tconst lowerTick = this.#gridTick(m.lower, state.tickSizeRaw);\n\t\t\tconst higherTick = this.#gridTick(m.upper, state.tickSizeRaw);\n\t\t\tawait this.#assertAdmittedTick(lowerTick, marketId, state);\n\t\t\tawait this.#assertAdmittedTick(higherTick, marketId, state);\n\t\t\treturn { lowerTick, higherTick };\n\t\t}\n\t\tif (m.strike !== 'reference') {\n\t\t\tconst ticks = binaryRangeTicks(priceToRaw(m.strike), m.side, state.tickSizeRaw);\n\t\t\tawait this.#assertAdmittedTick(ticks.lowerTick, marketId, state);\n\t\t\tawait this.#assertAdmittedTick(ticks.higherTick, marketId, state);\n\t\t\treturn ticks;\n\t\t}\n\t\tconst tick = await referenceTick(this.#client, this.#config, marketId);\n\t\tif (tick == null) {\n\t\t\tthrow new PredictInputError(\n\t\t\t\t`reference price not set yet for ${m.underlying} @ ${m.expiryMs} — retry shortly or pass a numeric strike`,\n\t\t\t);\n\t\t}\n\t\treturn m.side === 'up'\n\t\t\t? { lowerTick: tick, higherTick: POS_INF_TICK }\n\t\t\t: { lowerTick: 0n, higherTick: tick };\n\t}\n\n\t// Raw payout quantity must land on a lot boundary — the chain rejects otherwise.\n\t#assertLot(quantityRaw: bigint): void {\n\t\t// From the config in play, not the exported testnet constant — a deployment with a\n\t\t// different `position_lot_size` must not be validated against testnet's.\n\t\tconst lot = BigInt(this.cfg.units.positionLotSize);\n\t\tif (quantityRaw % lot !== 0n) {\n\t\t\tthrow new PredictInputError(\n\t\t\t\t`quantity ${quantityRaw} raw is not a whole ${lot}-unit lot (position_lot_size)`,\n\t\t\t);\n\t\t}\n\t}\n\n\t// Shared construction for tx.mint and read.quoteMint. The quote dry-runs the\n\t// same mint the trade sends; quoteMint omits the caller's cost/probability caps\n\t// (they only gate via abort and don't change the receipt numbers).\n\tasync #buildMint(owner: string, m: MarketDescriptor, opts: MintOptions): Promise<Transaction> {\n\t\tconst feeds = this.#feeds(m.underlying);\n\t\tconst { id, state } = await this.#resolveMarket(m);\n\t\tconst quantityRaw = usdcToRaw(opts.quantity);\n\t\tthis.#assertLot(quantityRaw);\n\t\tconst { lowerTick, higherTick } = await this.#strikeTicks(m, id, state);\n\t\treturn txOf(\n\t\t\tmintExactQuantity(this.#config, {\n\t\t\t\texpiryMarketId: id,\n\t\t\t\twrapperId: this.wrapperIdFor(owner),\n\t\t\t\tlowerTick,\n\t\t\t\thigherTick,\n\t\t\t\tquantityRaw,\n\t\t\t\tmaxCostRaw: opts.maxCost != null ? usdcToRaw(opts.maxCost) : undefined,\n\t\t\t\tmaxProbabilityRaw:\n\t\t\t\t\topts.maxProbability != null ? probabilityToRaw(opts.maxProbability) : undefined,\n\t\t\t\t...feeds,\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Shared construction for tx.redeem and read.quoteRedeem.\n\tasync #buildRedeem(owner: string, m: MarketDescriptor, opts: CloseOptions): Promise<Transaction> {\n\t\tconst feeds = this.#feeds(m.underlying);\n\t\tconst { id } = await this.#resolveMarket(m);\n\t\tconst closeQuantityRaw = usdcToRaw(opts.quantity);\n\t\tthis.#assertLot(closeQuantityRaw);\n\t\treturn txOf(\n\t\t\tredeemLive(this.#config, {\n\t\t\t\texpiryMarketId: id,\n\t\t\t\twrapperId: this.wrapperIdFor(owner),\n\t\t\t\torderId: opts.orderId,\n\t\t\t\tcloseQuantityRaw,\n\t\t\t\t...feeds,\n\t\t\t}),\n\t\t);\n\t}\n\n\t// Raw strike for anonymous pricing: numeric strikes validate against the tick\n\t// grid; \"reference\" reads the market's reference tick fresh (unset → typed error).\n\tasync #strikeRawFor(\n\t\tm: BinaryMarketCoordinates,\n\t\tmarketId: string,\n\t\tstate: MarketState,\n\t): Promise<bigint> {\n\t\tif (m.strike !== 'reference') {\n\t\t\t// Same validation as the mint path: on the grid AND inside the finite tick\n\t\t\t// domain (0 / POS_INF are the ±inf sentinels, not quotable strikes).\n\t\t\treturn this.#gridTick(m.strike, state.tickSizeRaw) * state.tickSizeRaw;\n\t\t}\n\t\tconst tick = await referenceTick(this.#client, this.#config, marketId);\n\t\tif (tick == null) {\n\t\t\tthrow new PredictInputError(\n\t\t\t\t`reference price not set yet for ${m.underlying} @ ${m.expiryMs} — retry shortly or pass a numeric strike`,\n\t\t\t);\n\t\t}\n\t\treturn tick * state.tickSizeRaw;\n\t}\n\n\t// === tx builders ===\n\t// Each returns a ready-to-sign Transaction. Market-resolving builders are async.\n\treadonly tx = {\n\t\tcreateManager: (): Transaction => txOf(accountContract(this.cfg).createAccount()),\n\n\t\t// `create: true` composes first-time funding into ONE PTB: create the account\n\t\t// wrapper, deposit into it through the fresh handle, and `share` it LAST (once\n\t\t// shared, by-value use of the handle is over). The wrapper is derived from the\n\t\t// transaction SENDER (`account_registry::new` takes no owner), so `owner` MUST\n\t\t// be the address that signs this transaction — a sponsored/backend signer would\n\t\t// silently fund its own fresh account instead. The caller also asserts the\n\t\t// account does not exist yet: `new` ABORTS at the deterministic address if it\n\t\t// already exists — no chain read is done here. Gate on your own existence check\n\t\t// (`wrapperIdFor(owner)` + a getObject), or retry without the flag on that abort.\n\t\t//\n\t\t// Without `create`, the sourced coin goes into the existing account's stored\n\t\t// balance via the PTB-callable `deposit_funds` (folds settle → authorize → load →\n\t\t// deposit; clock auto-injected). Command order is auth → deposit (auth is a hot\n\t\t// potato consumed by the deposit). See\n\t\t// `packages/account/sources/account.move` (`deposit_funds`).\n\t\tdeposit: (\n\t\t\towner: string,\n\t\t\tamountUsdc: number | string,\n\t\t\topts?: { create?: boolean },\n\t\t): Transaction => {\n\t\t\tconst tx = new Transaction();\n\t\t\tconst coin = tx.add(\n\t\t\t\tcoinWithBalance({\n\t\t\t\t\ttype: this.cfg.quoteCoinType,\n\t\t\t\t\tbalance: usdcToRaw(amountUsdc),\n\t\t\t\t\tuseGasCoin: false,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (opts?.create) {\n\t\t\t\ttx.add(\n\t\t\t\t\taccountContract(this.cfg).createAccountAndDeposit({\n\t\t\t\t\t\tcoin,\n\t\t\t\t\t\tcoinType: this.cfg.quoteCoinType,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\ttx.add(\n\t\t\t\t\tdepositFunds({\n\t\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\t\targuments: { wrapper: this.wrapperIdFor(owner), coin },\n\t\t\t\t\t\ttypeArguments: [this.cfg.quoteCoinType],\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn tx;\n\t\t},\n\n\t\t// Withdraw `amountUsdc` from the account back to `owner`. By default the funds land\n\t\t// in the owner's USDC *address balance* (the versionless accumulator) via\n\t\t// `0x2::coin::send_funds` — no coin-object churn, and they merge into the same\n\t\t// balance `deposit` draws from, closing the loop. Pass `{ toCoinObject: true }` to\n\t\t// instead receive a discrete `Coin<T>` object (for wallets/explorers that only\n\t\t// render coin objects, or to compose the coin further in your own PTB). Either way\n\t\t// the underlying `withdraw_funds` returns the raw `Coin<T>` — the PTB-callable form\n\t\t// that folds settle → authorize → load → withdraw (clock auto-injected, `ctx`\n\t\t// implicit); command order is auth → withdraw. See\n\t\t// `packages/account/sources/account.move` (`withdraw_funds`).\n\t\twithdraw: (\n\t\t\towner: string,\n\t\t\tamountUsdc: number | string,\n\t\t\topts?: { toCoinObject?: boolean },\n\t\t): Transaction => {\n\t\t\tconst tx = new Transaction();\n\t\t\tconst coin = tx.add(\n\t\t\t\twithdrawFunds({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper: this.wrapperIdFor(owner), amount: usdcToRaw(amountUsdc) },\n\t\t\t\t\ttypeArguments: [this.cfg.quoteCoinType],\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (opts?.toCoinObject) {\n\t\t\t\ttx.transferObjects([coin], owner);\n\t\t\t} else {\n\t\t\t\ttx.moveCall({\n\t\t\t\t\ttarget: '0x2::coin::send_funds',\n\t\t\t\t\ttypeArguments: [this.cfg.quoteCoinType],\n\t\t\t\t\targuments: [coin, tx.pure.address(owner)],\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn tx;\n\t\t},\n\n\t\tmint: (owner: string, m: MarketDescriptor, opts: MintOptions): Promise<Transaction> =>\n\t\t\tthis.#buildMint(owner, m, opts),\n\n\t\tmintAmount: async (\n\t\t\towner: string,\n\t\t\tm: MarketDescriptor,\n\t\t\topts: MintAmountOptions,\n\t\t): Promise<Transaction> => {\n\t\t\tconst feeds = this.#feeds(m.underlying);\n\t\t\t// The chain requires a positive all-in cost cap (EMintCostCapRequired);\n\t\t\t// reject a zero cap pre-flight rather than surface a cryptic Move abort.\n\t\t\tif (opts.maxCost != null && opts.maxCost <= 0) {\n\t\t\t\tthrow new PredictInputError('maxCost must be > 0');\n\t\t\t}\n\t\t\tconst { id, state } = await this.#resolveMarket(m);\n\t\t\t// No lot check: min_quantity is a floor the chain compares against an\n\t\t\t// already-lot-floored minted quantity, so any floor value is legal.\n\t\t\tconst minQuantityRaw = usdcToRaw(opts.minQuantity);\n\t\t\tconst { lowerTick, higherTick } = await this.#strikeTicks(m, id, state);\n\t\t\treturn txOf(\n\t\t\t\tmintExactAmount(this.#config, {\n\t\t\t\t\texpiryMarketId: id,\n\t\t\t\t\twrapperId: this.wrapperIdFor(owner),\n\t\t\t\t\tlowerTick,\n\t\t\t\t\thigherTick,\n\t\t\t\t\tmaxPremiumRaw: usdcToRaw(opts.spend),\n\t\t\t\t\tminQuantityRaw,\n\t\t\t\t\tmaxCostRaw: opts.maxCost != null ? usdcToRaw(opts.maxCost) : undefined,\n\t\t\t\t\t...feeds,\n\t\t\t\t}),\n\t\t\t);\n\t\t},\n\n\t\tredeem: (owner: string, m: MarketDescriptor, opts: CloseOptions): Promise<Transaction> =>\n\t\t\tthis.#buildRedeem(owner, m, opts),\n\n\t\tclaimSettled: async (\n\t\t\towner: string,\n\t\t\tm: Pick<MarketDescriptor, 'underlying' | 'expiryMs' | 'marketId'>,\n\t\t\topts: Pick<CloseOptions, 'orderId'>,\n\t\t): Promise<Transaction> => {\n\t\t\tconst { id } = await this.#resolveMarket(m);\n\t\t\treturn txOf(\n\t\t\t\tredeemSettled(this.#config, {\n\t\t\t\t\texpiryMarketId: id,\n\t\t\t\t\twrapperId: this.wrapperIdFor(owner),\n\t\t\t\t\torderId: opts.orderId,\n\t\t\t\t}),\n\t\t\t);\n\t\t},\n\n\t\t// Queue a supply request pulling `amountUsdc` from the account's existing custody\n\t\t// balance. `request_supply` auto-settles USDC then `account.withdraw`s the payment\n\t\t// into queue escrow; the PLP fill is delivered at the next flush, not returned here.\n\t\t// Command order is auth → request (auth is a hot potato consumed by this call). The\n\t\t// `minPlpOut` slot is the per-request floor on PLP minted at flush — `options.minPlpOut`\n\t\t// when given, otherwise 0 (no floor). At the shipped attempt count of one, the first\n\t\t// flush whose mark quotes less cancels and refunds the request; three is the\n\t\t// configurable maximum, not the default.\n\t\tsupplyPlp: (\n\t\t\towner: string,\n\t\t\tamountUsdc: number | string,\n\t\t\toptions: PlpSupplyOptions = {},\n\t\t): Transaction =>\n\t\t\ttxOf(\n\t\t\t\trequestSupply({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\twrapper: this.wrapperIdFor(owner),\n\t\t\t\t\t\tamount: usdcToRaw(amountUsdc),\n\t\t\t\t\t\tminPlpOut: options.minPlpOut ?? 0n,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t),\n\n\t\t// Queue a withdraw request pulling `shares` (raw PLP u64) from account custody into\n\t\t// queue escrow — the Move parameter is named `amount`, but on `request_withdraw` it\n\t\t// counts PLP SHARES, not USDC. Auto-settles flush-delivered PLP first; the USDC\n\t\t// fill lands on the account at the next flush (no `withdraw_settled` entrypoint).\n\t\t// Command order is auth → request. The `minUsdcOut` slot is the per-request floor\n\t\t// on USDC paid at flush — `options.minUsdcOut` when given, otherwise 0 (no floor).\n\t\t// At the shipped attempt count of one, the first flush whose mark quotes less\n\t\t// cancels and refunds the request; three is the configurable maximum, not the\n\t\t// default.\n\t\twithdrawPlp: (owner: string, shares: bigint, options: PlpWithdrawOptions = {}): Transaction =>\n\t\t\ttxOf(\n\t\t\t\trequestWithdraw({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: {\n\t\t\t\t\t\twrapper: this.wrapperIdFor(owner),\n\t\t\t\t\t\tamount: shares,\n\t\t\t\t\t\tminUsdcOut: options.minUsdcOut === undefined ? 0n : usdcToRaw(options.minUsdcOut),\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t),\n\n\t\t// Cancel a still-pending supply request by queue `index`, refunding its escrowed\n\t\t// USDC straight back into the requesting account. Command order is auth → cancel.\n\t\tcancelSupplyPlp: (owner: string, index: bigint): Transaction =>\n\t\t\ttxOf(\n\t\t\t\tcancelSupplyRequest({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper: this.wrapperIdFor(owner), index },\n\t\t\t\t}),\n\t\t\t),\n\n\t\t// Cancel a still-pending withdraw request by queue `index`, refunding its escrowed\n\t\t// PLP straight back into the requesting account. Command order is auth → cancel.\n\t\tcancelWithdrawPlp: (owner: string, index: bigint): Transaction =>\n\t\t\ttxOf(\n\t\t\t\tcancelWithdrawRequest({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper: this.wrapperIdFor(owner), index },\n\t\t\t\t}),\n\t\t\t),\n\n\t\t// Set the account's sticky builder-code attribution to `builderCodeId`, an existing\n\t\t// `BuilderCode` object borrowed as `&BuilderCode`. Command order is auth → set (auth\n\t\t// is a hot potato consumed by this call). Lives in the PREDICT package's\n\t\t// `predict_account` module, NOT the account package. Deployed sig\n\t\t// `packages/predict/sources/predict_account.move:134` — 3 moveCall args\n\t\t// (wrapper, auth, code; ctx implicit).\n\t\tsetBuilderCode: (owner: string, builderCodeId: string): Transaction =>\n\t\t\ttxOf(\n\t\t\t\tsetBuilderCode({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper: this.wrapperIdFor(owner), code: builderCodeId },\n\t\t\t\t}),\n\t\t\t),\n\n\t\t// Clear the account's sticky builder-code attribution. Command order is auth → unset.\n\t\t// Deployed sig `.../predict_account.move:151` — 2 moveCall args (wrapper, auth; ctx\n\t\t// implicit).\n\t\tunsetBuilderCode: (owner: string): Transaction =>\n\t\t\ttxOf(\n\t\t\t\tunsetBuilderCode({\n\t\t\t\t\tconfig: this.#config,\n\t\t\t\t\targuments: { wrapper: this.wrapperIdFor(owner) },\n\t\t\t\t}),\n\t\t\t),\n\t};\n\n\t// === reads ===\n\treadonly read = {\n\t\t// All tradeable (active) markets with the state a frontend needs to render\n\t\t// and mint: one chain read for ids + one batched PTB for the states.\n\t\tmarkets: async (): Promise<ActiveMarket[]> => {\n\t\t\tconst ids = await activeMarketIds(this.#client, this.#config);\n\t\t\tconst states = await marketStates(this.#client, this.#config, ids);\n\t\t\treturn ids.map((id, i) => ({\n\t\t\t\tid,\n\t\t\t\texpiryMs: states[i].expiryMs,\n\t\t\t\ttickSize: fromRaw(states[i].tickSizeRaw, 9),\n\t\t\t\tadmissionTickSize: fromRaw(states[i].admissionTickSizeRaw, 9),\n\t\t\t\tmintPaused: states[i].mintPaused,\n\t\t\t\treferencePrice: PredictClient.#referencePriceOf(states[i]),\n\t\t\t}));\n\t\t},\n\n\t\t// Validate an app-stored order id against the chain (stale after full\n\t\t// close or partial-close replacement — see RedeemReceipt.replacementOrderId).\n\t\thasPosition: (owner: string, marketId: string, orderId: bigint): Promise<boolean> =>\n\t\t\thasPosition(this.#client, this.#config, owner, marketId, orderId),\n\n\t\t// All open positions for an owner, enumerated from the chain (the\n\t\t// account's positions Table): 1 call per page warm, +2 resolution calls\n\t\t// once per owner. Returns [] for owners with no Predict account.\n\t\tpositions: async (owner: string): Promise<OpenPosition[]> => {\n\t\t\tlet handle = this.#positionsCache.get(owner);\n\t\t\tif (!handle?.positionsTableId) {\n\t\t\t\tconst resolved = await resolvePositionsTable(this.#client, this.#config, owner);\n\t\t\t\tif (!resolved) return []; // never onboarded — do not cache\n\t\t\t\tif (resolved.positionsTableId) this.#positionsCache.set(owner, resolved);\n\t\t\t\thandle = resolved;\n\t\t\t}\n\t\t\tif (!handle.positionsTableId) return [];\n\t\t\treturn positionsFromTable(this.#client, handle.positionsTableId);\n\t\t},\n\n\t\t// Anonymous board pricing: the chain's probability for both sides of a\n\t\t// strike, from one fresh pricer (no account needed). This is the ↑/↓\n\t\t// button price before a user has onboarded.\n\t\tprice: async (m: BinaryMarketCoordinates): Promise<{ up: number; down: number }> => {\n\t\t\tconst feeds = this.#feeds(m.underlying);\n\t\t\tconst { id, state } = await this.#resolveMarket(m);\n\t\t\tconst strikeRaw = await this.#strikeRawFor(m, id, state);\n\t\t\tconst { upRaw, downRaw } = await rangePrices(\n\t\t\t\tthis.#client,\n\t\t\t\tthis.#config,\n\t\t\t\tid,\n\t\t\t\tfeeds,\n\t\t\t\tstrikeRaw,\n\t\t\t\tstate.tickSizeRaw,\n\t\t\t);\n\t\t\treturn { up: rawToProbability(upRaw), down: rawToProbability(downRaw) };\n\t\t},\n\n\t\t// A client-side board pricer for one market: ONE simulate reads the chain's\n\t\t// resolved pricer (already forward-selected + rolled to now), then prices every\n\t\t// strike LOCALLY with no further chain calls — `pricer.up(strike)`,\n\t\t// `.down(strike)`, `.range(lo,hi)`, `.strikeAtProbability(p)`. Use this to paint a\n\t\t// whole board instantly; `read.price` / `read.quoteMint` stay the authoritative\n\t\t// per-strike quote at trade time. Throws the same typed stale-oracle/expired\n\t\t// PredictMoveError `read.price` would when the chain itself cannot quote.\n\t\tpricer: async (\n\t\t\tm: Pick<MarketDescriptor, 'underlying' | 'expiryMs'>,\n\t\t): Promise<BoardPricer & { asOf: PricerSnapshot['sources'] }> => {\n\t\t\tconst feeds = this.#feeds(m.underlying);\n\t\t\tconst { id } = await this.#resolveMarket(m);\n\t\t\tconst snap = await readPricerSnapshot(this.#client, this.#config, id, feeds);\n\t\t\treturn { ...boardPricer(snap), asOf: snap.sources };\n\t\t},\n\n\t\t// Exact pre-trade quote: dry-runs the caller's own mint (same tx as\n\t\t// tx.mint) and decodes the receipt. Requires a funded account; throws\n\t\t// the same typed errors the real trade would — quote doubles as preflight.\n\t\tquoteMint: async (\n\t\t\towner: string,\n\t\t\tm: MarketDescriptor,\n\t\t\topts: Pick<MintOptions, 'quantity'>,\n\t\t): Promise<MintQuote> => {\n\t\t\tconst tx = await this.#buildMint(owner, m, opts);\n\t\t\tconst events = await simulateWithEvents(this.#client, tx, owner);\n\t\t\tconst r = exactlyOne(decodeMints(this.cfg, { events }), 'OrderMinted');\n\t\t\t// Mirrors the deployed `compute_mint_quote`'s all_in_cost exactly:\n\t\t\t// premium + (trading − subsidy) + builder + penalty + inventory-impact.\n\t\t\t// `referral_fee` is deliberately NOT added — it is a portion OF the\n\t\t\t// trader-paid trading fee and congestion surcharge, not an extra debit.\n\t\t\tconst costRaw =\n\t\t\t\tr.raw.premium +\n\t\t\t\t(r.raw.tradingFee - r.raw.feeIncentiveSubsidy) +\n\t\t\t\tr.raw.builderFee +\n\t\t\t\tr.raw.penaltyFee +\n\t\t\t\tr.raw.inventoryImpactCharge;\n\t\t\treturn {\n\t\t\t\tentryProbability: r.entryProbability,\n\t\t\t\tpremium: r.premium,\n\t\t\t\tfees: r.fees,\n\t\t\t\tcost: rawToUsdc(costRaw),\n\t\t\t\tquantity: r.quantity,\n\t\t\t\traw: {\n\t\t\t\t\tpremium: r.raw.premium,\n\t\t\t\t\tcost: costRaw,\n\t\t\t\t\tquantity: r.raw.quantity,\n\t\t\t\t\tentryProbability: r.raw.entryProbability,\n\t\t\t\t},\n\t\t\t\tfeesExact: true,\n\t\t\t};\n\t\t},\n\n\t\t// Exact pre-close quote: dry-runs the caller's own redeem and decodes\n\t\t// the receipt — the informed close against the floor-less deployed redeem.\n\t\tquoteRedeem: async (\n\t\t\towner: string,\n\t\t\tm: MarketDescriptor,\n\t\t\topts: CloseOptions,\n\t\t): Promise<RedeemQuote> => {\n\t\t\tconst tx = await this.#buildRedeem(owner, m, opts);\n\t\t\tconst events = await simulateWithEvents(this.#client, tx, owner);\n\t\t\tconst r = exactlyOne(decodeRedeems(this.cfg, { events }), 'order-redeemed');\n\t\t\treturn {\n\t\t\t\tproceeds: r.proceeds,\n\t\t\t\tgross: r.gross,\n\t\t\t\tfees: r.fees,\n\t\t\t\tquantityClosed: r.quantityClosed,\n\t\t\t\tremaining: r.remaining,\n\t\t\t\traw: {\n\t\t\t\t\tproceeds: r.raw.proceeds,\n\t\t\t\t\tgross: r.raw.gross,\n\t\t\t\t\tquantityClosed: r.raw.quantityClosed,\n\t\t\t\t},\n\t\t\t\tfeesExact: true,\n\t\t\t};\n\t\t},\n\n\t\tmarket: async (\n\t\t\tm: Pick<MarketDescriptor, 'underlying' | 'expiryMs'>,\n\t\t): Promise<MarketSummary | null> => {\n\t\t\tconst expiryMs = BigInt(m.expiryMs);\n\t\t\t// Deliberately re-queries and overwrites the cache instead of reading\n\t\t\t// through it: this read must return live state (nav, mintPaused), and\n\t\t\t// refreshing the cache on the way keeps later tx builds consistent.\n\t\t\tconst u = this.#underlying(m.underlying);\n\t\t\tconst id = await expiryMarketId(this.#client, this.#config, u, expiryMs);\n\t\t\tif (!id) return null;\n\t\t\tconst state = await marketState(this.#client, this.#config, id);\n\t\t\tthis.#marketCache.set(`${m.underlying}:${expiryMs}`, { id, state });\n\t\t\tconst navRaw = await currentNav(this.#client, this.#config, id, u);\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\texpiryMs: state.expiryMs,\n\t\t\t\ttickSize: fromRaw(state.tickSizeRaw, 9), // strike/price scale\n\t\t\t\tadmissionTickSize: fromRaw(state.admissionTickSizeRaw, 9),\n\t\t\t\tmintPaused: state.mintPaused,\n\t\t\t\tnav: rawToUsdc(navRaw),\n\t\t\t\treferencePrice: PredictClient.#referencePriceOf(state),\n\t\t\t};\n\t\t},\n\n\t\tbalance: async (owner: string): Promise<number> =>\n\t\t\trawToUsdc(await accountBalance(this.#client, this.#config, owner, this.cfg.quoteCoinType)),\n\n\t\t// PLP shares held in the owner's account custody (raw u64, 6-decimal PLP coin).\n\t\tplpBalance: (owner: string): Promise<bigint> =>\n\t\t\taccountBalance(this.#client, this.#config, owner, this.cfg.coinTypes.plp),\n\n\t\tpool: async (): Promise<PoolSummary> => {\n\t\t\tconst s = await poolStats(this.#client, this.#config);\n\t\t\treturn {\n\t\t\t\tplpTotalSupply: s.plpTotalSupply, // shares raw (6-decimal)\n\t\t\t\tidleUsdc: rawToUsdc(s.idleBalance),\n\t\t\t\t// These are queue LENGTHS (counts of pending requests), not token amounts.\n\t\t\t\tsupplyRequestsPending: Number(s.supplyRequestsPending),\n\t\t\t\twithdrawRequestsPending: Number(s.withdrawRequestsPending),\n\t\t\t};\n\t\t},\n\t};\n\n\t// === execution-result decoders ===\n\t// Pure event parsing (no network): pass the executed/simulated transaction\n\t// result (with events included) and get a typed receipt back. Singular forms\n\t// throw unless exactly one matching event exists; plural forms return all\n\t// (an integrator batching N actions in one PTB gets N receipts).\n\treadonly decode = {\n\t\tmint: (r: DecodableTransactionResult) => exactlyOne(decodeMints(this.cfg, r), 'OrderMinted'),\n\t\tmints: (r: DecodableTransactionResult) => decodeMints(this.cfg, r),\n\t\tredeem: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodeRedeems(this.cfg, r), 'order-redeemed'),\n\t\tredeems: (r: DecodableTransactionResult) => decodeRedeems(this.cfg, r),\n\t\tclaim: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodeClaims(this.cfg, r), 'SettledOrderRedeemed'),\n\t\tclaims: (r: DecodableTransactionResult) => decodeClaims(this.cfg, r),\n\t\tcreateManager: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodeAccountsCreated(this.cfg, r), 'AccountCreated'),\n\t\tdeposit: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodeDeposits(this.cfg, r), 'Deposited'),\n\t\twithdraw: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodeWithdrawals(this.cfg, r), 'Withdrawn'),\n\t\tplpRequest: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodePlpRequests(this.cfg, r), 'supply/withdraw-requested'),\n\t\tplpCancel: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodePlpCancels(this.cfg, r), 'RequestCancelled'),\n\t\tbuilderCode: (r: DecodableTransactionResult) =>\n\t\t\texactlyOne(decodeBuilderCodeSets(this.cfg, r), 'BuilderCodeSet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AAU,KAAK,QAAQ,GAAG;GAC7D,mBACC,KAAK,kBAAkB,OAAO,iBAAiB,KAAK,eAAe,GAAG;GACvE,GAAG;GACH,CAAC,CACF;;CAIF,OAAMM,YAAa,OAAe,GAAqB,MAA0C;EAChG,MAAM,QAAQ,MAAKH,MAAO,EAAE,WAAW;EACvC,MAAM,EAAE,OAAO,MAAM,MAAKC,cAAe,EAAE;EAC3C,MAAM,mBAAmB,UAAU,KAAK,SAAS;AACjD,QAAKY,UAAW,iBAAiB;AACjC,SAAO,KACN,WAAW,MAAKhB,QAAS;GACxB,gBAAgB;GAChB,WAAW,KAAK,aAAa,MAAM;GACnC,SAAS,KAAK;GACd;GACA,GAAG;GACH,CAAC,CACF;;CAKF,OAAMU,aACL,GACA,UACA,OACkB;AAClB,MAAI,EAAE,WAAW,YAGhB,QAAO,MAAKK,SAAU,EAAE,QAAQ,MAAM,YAAY,GAAG,MAAM;EAE5D,MAAM,OAAO,MAAM,cAAc,MAAKR,QAAS,MAAKP,QAAS,SAAS;AACtE,MAAI,QAAQ,KACX,OAAM,IAAI,kBACT,mCAAmC,EAAE,WAAW,KAAK,EAAE,SAAS,2CAChE;AAEF,SAAO,OAAO,MAAM"}
|
package/dist/predict/index.d.mts
CHANGED
|
@@ -15,6 +15,23 @@ import { PricerSnapshot } from "./reads/pricing.mjs";
|
|
|
15
15
|
import { POS_INF_TICK, Side, binaryRangeTicks } from "./ticks.mjs";
|
|
16
16
|
import { ActiveMarket, CloseOptions, MarketDescriptor, MarketSummary, MintAmountOptions, MintOptions, MintQuote, POSITION_LOT_SIZE, PlpSupplyOptions, PlpWithdrawOptions, PoolSummary, PredictClient, PredictCompatibleClient, RedeemQuote, predict } from "./client.mjs";
|
|
17
17
|
import { deriveAccountWrapperId, generateAuth } from "./tx/common.mjs";
|
|
18
|
+
import { admin_d_exports } from "../contracts/deepbook_predict/admin.mjs";
|
|
19
|
+
import { builder_code_d_exports } from "../contracts/deepbook_predict/builder_code.mjs";
|
|
20
|
+
import { expiry_market_d_exports } from "../contracts/deepbook_predict/expiry_market.mjs";
|
|
21
|
+
import { market_lifecycle_cap_d_exports } from "../contracts/deepbook_predict/market_lifecycle_cap.mjs";
|
|
22
|
+
import { market_manager_d_exports } from "../contracts/deepbook_predict/market_manager.mjs";
|
|
23
|
+
import { pause_cap_d_exports } from "../contracts/deepbook_predict/pause_cap.mjs";
|
|
24
|
+
import { plp_d_exports } from "../contracts/deepbook_predict/plp.mjs";
|
|
25
|
+
import { pool_valuation_cap_d_exports } from "../contracts/deepbook_predict/pool_valuation_cap.mjs";
|
|
26
|
+
import { predict_account_d_exports } from "../contracts/deepbook_predict/predict_account.mjs";
|
|
27
|
+
import { pricing_d_exports as pricing_d_exports$1 } from "../contracts/deepbook_predict/pricing.mjs";
|
|
28
|
+
import { protocol_config_d_exports } from "../contracts/deepbook_predict/protocol_config.mjs";
|
|
29
|
+
import { range_codec_d_exports } from "../contracts/deepbook_predict/range_codec.mjs";
|
|
30
|
+
import { registry_d_exports } from "../contracts/deepbook_predict/registry.mjs";
|
|
31
|
+
import { builder_code_events_d_exports } from "../contracts/deepbook_predict/builder_code_events.mjs";
|
|
32
|
+
import { config_events_d_exports } from "../contracts/deepbook_predict/config_events.mjs";
|
|
33
|
+
import { order_events_d_exports } from "../contracts/deepbook_predict/order_events.mjs";
|
|
34
|
+
import { vault_events_d_exports } from "../contracts/deepbook_predict/vault_events.mjs";
|
|
18
35
|
import { U64_MAX, priceToRaw, probabilityToRaw, rawToPrice, rawToProbability, rawToUsdc, usdcToRaw } from "./units.mjs";
|
|
19
36
|
import { MoveAbortError, PredictInputError, PredictMoveError, decodeMoveAbort } from "./errors.mjs";
|
|
20
|
-
export { type ActiveMarket, type BalanceChangeReceipt, type BuilderCodeReceipt, type ClaimReceipt, type CloseOptions, type CreateManagerReceipt, type DecodableEvent, type DecodableTransactionResult, type GeneratedConfig, MAINNET_CONFIG, MAINNET_DEPLOYMENT, MAINNET_UNITS, type MarketDescriptor, type MarketFeeds, type MarketSummary, type MintAmountOptions, type MintOptions, type MintQuote, type MintReceipt, type MoveAbortError, type OpenPosition, POSITION_LOT_SIZE, POS_INF_TICK, type PlpCancelReceipt, type PlpRequestReceipt, type PlpSupplyOptions, type PlpWithdrawOptions, type PoolSummary, PredictClient, type PredictCompatibleClient, type PredictConfig, PredictInputError, PredictMoveError, type PredictPackages, type PricerSnapshot, type ReadClient, type RedeemQuote, type RedeemReceipt, type Side, TESTNET_CONFIG, TESTNET_DEPLOYMENT, TESTNET_UNITS, U64_MAX, type UnderlyingConfig, binaryRangeTicks, decodeMoveAbort, deriveAccountWrapperId, generateAuth, getConfig, getDeployment, getUnits, loadLivePricer, predict, priceToRaw, pricing_d_exports as pricing, probabilityToRaw, rawToPrice, rawToProbability, rawToUsdc, toGeneratedConfig, usdcToRaw };
|
|
37
|
+
export { type ActiveMarket, type BalanceChangeReceipt, type BuilderCodeReceipt, type ClaimReceipt, type CloseOptions, type CreateManagerReceipt, type DecodableEvent, type DecodableTransactionResult, type GeneratedConfig, MAINNET_CONFIG, MAINNET_DEPLOYMENT, MAINNET_UNITS, type MarketDescriptor, type MarketFeeds, type MarketSummary, type MintAmountOptions, type MintOptions, type MintQuote, type MintReceipt, type MoveAbortError, type OpenPosition, POSITION_LOT_SIZE, POS_INF_TICK, type PlpCancelReceipt, type PlpRequestReceipt, type PlpSupplyOptions, type PlpWithdrawOptions, type PoolSummary, PredictClient, type PredictCompatibleClient, type PredictConfig, PredictInputError, PredictMoveError, type PredictPackages, type PricerSnapshot, type ReadClient, type RedeemQuote, type RedeemReceipt, type Side, TESTNET_CONFIG, TESTNET_DEPLOYMENT, TESTNET_UNITS, U64_MAX, type UnderlyingConfig, admin_d_exports as adminMoveCalls, binaryRangeTicks, builder_code_events_d_exports as builderCodeEvents, builder_code_d_exports as builderCodeMoveCalls, config_events_d_exports as configEvents, decodeMoveAbort, deriveAccountWrapperId, expiry_market_d_exports as expiryMarketMoveCalls, generateAuth, getConfig, getDeployment, getUnits, loadLivePricer, market_lifecycle_cap_d_exports as marketLifecycleCapMoveCalls, market_manager_d_exports as marketManagerMoveCalls, order_events_d_exports as orderEvents, pause_cap_d_exports as pauseCapMoveCalls, plp_d_exports as plpMoveCalls, pool_valuation_cap_d_exports as poolValuationCapMoveCalls, predict, predict_account_d_exports as predictAccountMoveCalls, priceToRaw, pricing_d_exports as pricing, pricing_d_exports$1 as pricingMoveCalls, probabilityToRaw, protocol_config_d_exports as protocolConfigMoveCalls, range_codec_d_exports as rangeCodecMoveCalls, rawToPrice, rawToProbability, rawToUsdc, registry_d_exports as registryMoveCalls, toGeneratedConfig, usdcToRaw, vault_events_d_exports as vaultEvents };
|
package/dist/predict/index.mjs
CHANGED
|
@@ -5,12 +5,29 @@ import { MAINNET_CONFIG } from "./config/mainnet.mjs";
|
|
|
5
5
|
import { TESTNET_CONFIG } from "./config/testnet.mjs";
|
|
6
6
|
import { getConfig } from "./config/index.mjs";
|
|
7
7
|
import { toGeneratedConfig } from "./config/generated.mjs";
|
|
8
|
+
import { builder_code_events_exports } from "../contracts/deepbook_predict/builder_code_events.mjs";
|
|
9
|
+
import { order_events_exports } from "../contracts/deepbook_predict/order_events.mjs";
|
|
10
|
+
import { vault_events_exports } from "../contracts/deepbook_predict/vault_events.mjs";
|
|
8
11
|
import { PredictInputError, PredictMoveError, decodeMoveAbort } from "./errors.mjs";
|
|
9
12
|
import { U64_MAX, priceToRaw, probabilityToRaw, rawToPrice, rawToProbability, rawToUsdc, usdcToRaw } from "./units.mjs";
|
|
10
13
|
import { deriveAccountWrapperId, generateAuth } from "./tx/common.mjs";
|
|
14
|
+
import { predict_account_exports } from "../contracts/deepbook_predict/predict_account.mjs";
|
|
11
15
|
import { POS_INF_TICK, binaryRangeTicks } from "./ticks.mjs";
|
|
16
|
+
import { expiry_market_exports } from "../contracts/deepbook_predict/expiry_market.mjs";
|
|
12
17
|
import { loadLivePricer } from "./tx/trade.mjs";
|
|
18
|
+
import { pricing_exports as pricing_exports$1 } from "../contracts/deepbook_predict/pricing.mjs";
|
|
19
|
+
import { plp_exports } from "../contracts/deepbook_predict/plp.mjs";
|
|
20
|
+
import { range_codec_exports } from "../contracts/deepbook_predict/range_codec.mjs";
|
|
21
|
+
import { market_manager_exports } from "../contracts/deepbook_predict/market_manager.mjs";
|
|
22
|
+
import { registry_exports } from "../contracts/deepbook_predict/registry.mjs";
|
|
13
23
|
import { pricing_exports } from "./pricing.mjs";
|
|
14
24
|
import { POSITION_LOT_SIZE, PredictClient, predict } from "./client.mjs";
|
|
25
|
+
import { admin_exports } from "../contracts/deepbook_predict/admin.mjs";
|
|
26
|
+
import { builder_code_exports } from "../contracts/deepbook_predict/builder_code.mjs";
|
|
27
|
+
import { market_lifecycle_cap_exports } from "../contracts/deepbook_predict/market_lifecycle_cap.mjs";
|
|
28
|
+
import { pause_cap_exports } from "../contracts/deepbook_predict/pause_cap.mjs";
|
|
29
|
+
import { pool_valuation_cap_exports } from "../contracts/deepbook_predict/pool_valuation_cap.mjs";
|
|
30
|
+
import { protocol_config_exports } from "../contracts/deepbook_predict/protocol_config.mjs";
|
|
31
|
+
import { config_events_exports } from "../contracts/deepbook_predict/config_events.mjs";
|
|
15
32
|
|
|
16
|
-
export { MAINNET_CONFIG, MAINNET_DEPLOYMENT, MAINNET_UNITS, POSITION_LOT_SIZE, POS_INF_TICK, PredictClient, PredictInputError, PredictMoveError, TESTNET_CONFIG, TESTNET_DEPLOYMENT, TESTNET_UNITS, U64_MAX, binaryRangeTicks, decodeMoveAbort, deriveAccountWrapperId, generateAuth, getConfig, getDeployment, getUnits, loadLivePricer, predict, priceToRaw, pricing_exports as pricing, probabilityToRaw, rawToPrice, rawToProbability, rawToUsdc, toGeneratedConfig, usdcToRaw };
|
|
33
|
+
export { MAINNET_CONFIG, MAINNET_DEPLOYMENT, MAINNET_UNITS, POSITION_LOT_SIZE, POS_INF_TICK, PredictClient, PredictInputError, PredictMoveError, TESTNET_CONFIG, TESTNET_DEPLOYMENT, TESTNET_UNITS, U64_MAX, admin_exports as adminMoveCalls, binaryRangeTicks, builder_code_events_exports as builderCodeEvents, builder_code_exports as builderCodeMoveCalls, config_events_exports as configEvents, decodeMoveAbort, deriveAccountWrapperId, expiry_market_exports as expiryMarketMoveCalls, generateAuth, getConfig, getDeployment, getUnits, loadLivePricer, market_lifecycle_cap_exports as marketLifecycleCapMoveCalls, market_manager_exports as marketManagerMoveCalls, order_events_exports as orderEvents, pause_cap_exports as pauseCapMoveCalls, plp_exports as plpMoveCalls, pool_valuation_cap_exports as poolValuationCapMoveCalls, predict, predict_account_exports as predictAccountMoveCalls, priceToRaw, pricing_exports as pricing, pricing_exports$1 as pricingMoveCalls, probabilityToRaw, protocol_config_exports as protocolConfigMoveCalls, range_codec_exports as rangeCodecMoveCalls, rawToPrice, rawToProbability, rawToUsdc, registry_exports as registryMoveCalls, toGeneratedConfig, usdcToRaw, vault_events_exports as vaultEvents };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_sui_transactions36 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_transactions36.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_transactions36.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_transactions36.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_transactions36.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_transactions36.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_transactions36.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_transactions36.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_transactions36.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_transactions36.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_transactions36.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_transactions36.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,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_transactions47 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_transactions47.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_transactions47.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_transactions47.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_transactions47.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_transactions47.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_transactions47.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_transactions47.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_transactions47.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_transactions47.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_transactions47.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_transactions47.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_transactions47.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_transactions47.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_transactions47.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_transactions47.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_transactions47.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_transactions47.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_transactions47.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_transactions47.TransactionResult;
|
|
509
509
|
}
|
|
510
510
|
//#endregion
|
|
511
511
|
export { DeepBookContract };
|