@mysten/deepbook-v3 2.3.0 → 2.4.1
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 +29 -0
- package/PREDICT.md +149 -55
- package/README.md +18 -13
- package/dist/contracts/account/account_events.d.mts +20 -20
- package/dist/contracts/account/account_events.d.mts.map +1 -1
- 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/session_config.d.mts.map +1 -1
- package/dist/contracts/deepbook_sessions/sessions.d.mts +22 -22
- 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/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginRegistry.d.mts +16 -16
- package/package.json +2 -2
- 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;AAC5B,IAAG,IAAI,QAAQ;AACf,QAAO;;;;;;AAkMR,SAAgB,QAAyC,EACxD,OAAO,WACP,SACA,UAKuE;AACvE,QAAO;EACN;EACA,WAAW,WAAW,IAAI,cAAc;GAAE;GAAQ;GAAS;GAAQ,CAAC;EACpE;;;;;;;;;AAUF,IAAa,gBAAb,MAAa,cAAc;CAG1B,KAAIA,SAA2B;AAC9B,SAAO,kBAAkB,KAAK,IAAI;;CAEnC;CAKA,+BAAe,IAAI,KAA6B;CAIhD,kCAAkB,IAAI,KAA8B;CAEpD,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GhB,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'),\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,MAAa,oBAAoB,OAAO,gBAAgB,MAAM,gBAAgB;AAG9E,SAAS,KAAK,SAAqE;CAClF,MAAM,KAAK,IAAI,aAAa;AAC5B,IAAG,IAAI,QAAQ;AACf,QAAO;;;;;;AAkMR,SAAgB,QAAyC,EACxD,OAAO,WACP,SACA,UAKuE;AACvE,QAAO;EACN;EACA,WAAW,WAAW,IAAI,cAAc;GAAE;GAAQ;GAAS;GAAQ,CAAC;EACpE;;;;;;;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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_transactions298 from "@mysten/sui/transactions";
|
|
3
3
|
import { Transaction } from "@mysten/sui/transactions";
|
|
4
4
|
|
|
5
5
|
//#region src/transactions/marginLiquidations.d.ts
|
|
@@ -35,7 +35,7 @@ declare class MarginLiquidationsContract {
|
|
|
35
35
|
* @param {number} amount The amount to withdraw
|
|
36
36
|
* @returns A function that takes a Transaction object and returns the withdrawn coin
|
|
37
37
|
*/
|
|
38
|
-
withdraw: (vaultId: string, liquidationAdminCap: string, coinKey: string, amount: number) => (tx: Transaction) =>
|
|
38
|
+
withdraw: (vaultId: string, liquidationAdminCap: string, coinKey: string, amount: number) => (tx: Transaction) => _mysten_sui_transactions298.TransactionResult;
|
|
39
39
|
/**
|
|
40
40
|
* @description Liquidate a margin manager by repaying base debt
|
|
41
41
|
* @param {string} vaultId The liquidation vault object ID
|
|
@@ -60,7 +60,7 @@ declare class MarginLiquidationsContract {
|
|
|
60
60
|
* @param {string} coinKey The key to identify the coin type
|
|
61
61
|
* @returns A function that takes a Transaction object
|
|
62
62
|
*/
|
|
63
|
-
balance: (vaultId: string, coinKey: string) => (tx: Transaction) =>
|
|
63
|
+
balance: (vaultId: string, coinKey: string) => (tx: Transaction) => _mysten_sui_transactions298.TransactionResult;
|
|
64
64
|
}
|
|
65
65
|
//#endregion
|
|
66
66
|
export { MarginLiquidationsContract };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_sui_transactions300 from "@mysten/sui/transactions";
|
|
3
3
|
import { Transaction } from "@mysten/sui/transactions";
|
|
4
4
|
|
|
5
5
|
//#region src/transactions/marginRegistry.d.ts
|
|
@@ -17,90 +17,90 @@ declare class MarginRegistryContract {
|
|
|
17
17
|
* @param {string} poolKey The key to identify the pool
|
|
18
18
|
* @returns A function that takes a Transaction object
|
|
19
19
|
*/
|
|
20
|
-
poolEnabled: (poolKey: string) => (tx: Transaction) =>
|
|
20
|
+
poolEnabled: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions300.TransactionResult;
|
|
21
21
|
/**
|
|
22
22
|
* @description Get the margin pool ID for a given asset
|
|
23
23
|
* @param {string} coinKey The key to identify the coin
|
|
24
24
|
* @returns A function that takes a Transaction object
|
|
25
25
|
*/
|
|
26
|
-
getMarginPoolId: (coinKey: string) => (tx: Transaction) =>
|
|
26
|
+
getMarginPoolId: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions300.TransactionResult;
|
|
27
27
|
/**
|
|
28
28
|
* @description Get the margin pool IDs (base and quote) for a deepbook pool
|
|
29
29
|
* @param {string} poolKey The key to identify the pool
|
|
30
30
|
* @returns A function that takes a Transaction object
|
|
31
31
|
*/
|
|
32
|
-
getDeepbookPoolMarginPoolIds: (poolKey: string) => (tx: Transaction) =>
|
|
32
|
+
getDeepbookPoolMarginPoolIds: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions300.TransactionResult;
|
|
33
33
|
/**
|
|
34
34
|
* @description Get the margin manager IDs for a given owner
|
|
35
35
|
* @param {string} owner The owner address
|
|
36
36
|
* @returns A function that takes a Transaction object
|
|
37
37
|
*/
|
|
38
|
-
getMarginManagerIds: (owner: string) => (tx: Transaction) =>
|
|
38
|
+
getMarginManagerIds: (owner: string) => (tx: Transaction) => _mysten_sui_transactions300.TransactionResult;
|
|
39
39
|
/**
|
|
40
40
|
* @description Get the base margin pool ID for a deepbook pool
|
|
41
41
|
* @param {string} poolKey The key to identify the pool
|
|
42
42
|
* @returns A function that takes a Transaction object
|
|
43
43
|
*/
|
|
44
|
-
baseMarginPoolId: (poolKey: string) => (tx: Transaction) =>
|
|
44
|
+
baseMarginPoolId: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions300.TransactionResult;
|
|
45
45
|
/**
|
|
46
46
|
* @description Get the quote margin pool ID for a deepbook pool
|
|
47
47
|
* @param {string} poolKey The key to identify the pool
|
|
48
48
|
* @returns A function that takes a Transaction object
|
|
49
49
|
*/
|
|
50
|
-
quoteMarginPoolId: (poolKey: string) => (tx: Transaction) =>
|
|
50
|
+
quoteMarginPoolId: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions300.TransactionResult;
|
|
51
51
|
/**
|
|
52
52
|
* @description Get the minimum withdraw risk ratio for a deepbook pool
|
|
53
53
|
* @param {string} poolKey The key to identify the pool
|
|
54
54
|
* @returns A function that takes a Transaction object
|
|
55
55
|
*/
|
|
56
|
-
minWithdrawRiskRatio: (poolKey: string) => (tx: Transaction) =>
|
|
56
|
+
minWithdrawRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions300.TransactionResult;
|
|
57
57
|
/**
|
|
58
58
|
* @description Get the minimum borrow risk ratio for a deepbook pool
|
|
59
59
|
* @param {string} poolKey The key to identify the pool
|
|
60
60
|
* @returns A function that takes a Transaction object
|
|
61
61
|
*/
|
|
62
|
-
minBorrowRiskRatio: (poolKey: string) => (tx: Transaction) =>
|
|
62
|
+
minBorrowRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions300.TransactionResult;
|
|
63
63
|
/**
|
|
64
64
|
* @description Get the minimum risk ratio required to open a new position on
|
|
65
65
|
* a deepbook pool. Distinct from `minBorrowRiskRatio`, which gates borrowing.
|
|
66
66
|
* @param {string} poolKey The key to identify the pool
|
|
67
67
|
* @returns A function that takes a Transaction object
|
|
68
68
|
*/
|
|
69
|
-
minOpenRiskRatio: (poolKey: string) => (tx: Transaction) =>
|
|
69
|
+
minOpenRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions300.TransactionResult;
|
|
70
70
|
/**
|
|
71
71
|
* @description Get the liquidation risk ratio for a deepbook pool
|
|
72
72
|
* @param {string} poolKey The key to identify the pool
|
|
73
73
|
* @returns A function that takes a Transaction object
|
|
74
74
|
*/
|
|
75
|
-
liquidationRiskRatio: (poolKey: string) => (tx: Transaction) =>
|
|
75
|
+
liquidationRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions300.TransactionResult;
|
|
76
76
|
/**
|
|
77
77
|
* @description Get the target liquidation risk ratio for a deepbook pool
|
|
78
78
|
* @param {string} poolKey The key to identify the pool
|
|
79
79
|
* @returns A function that takes a Transaction object
|
|
80
80
|
*/
|
|
81
|
-
targetLiquidationRiskRatio: (poolKey: string) => (tx: Transaction) =>
|
|
81
|
+
targetLiquidationRiskRatio: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions300.TransactionResult;
|
|
82
82
|
/**
|
|
83
83
|
* @description Get the user liquidation reward for a deepbook pool
|
|
84
84
|
* @param {string} poolKey The key to identify the pool
|
|
85
85
|
* @returns A function that takes a Transaction object
|
|
86
86
|
*/
|
|
87
|
-
userLiquidationReward: (poolKey: string) => (tx: Transaction) =>
|
|
87
|
+
userLiquidationReward: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions300.TransactionResult;
|
|
88
88
|
/**
|
|
89
89
|
* @description Get the pool liquidation reward for a deepbook pool
|
|
90
90
|
* @param {string} poolKey The key to identify the pool
|
|
91
91
|
* @returns A function that takes a Transaction object
|
|
92
92
|
*/
|
|
93
|
-
poolLiquidationReward: (poolKey: string) => (tx: Transaction) =>
|
|
93
|
+
poolLiquidationReward: (poolKey: string) => (tx: Transaction) => _mysten_sui_transactions300.TransactionResult;
|
|
94
94
|
/**
|
|
95
95
|
* @description Get all allowed maintainer cap IDs
|
|
96
96
|
* @returns A function that takes a Transaction object
|
|
97
97
|
*/
|
|
98
|
-
allowedMaintainers: () => (tx: Transaction) =>
|
|
98
|
+
allowedMaintainers: () => (tx: Transaction) => _mysten_sui_transactions300.TransactionResult;
|
|
99
99
|
/**
|
|
100
100
|
* @description Get all allowed pause cap IDs
|
|
101
101
|
* @returns A function that takes a Transaction object
|
|
102
102
|
*/
|
|
103
|
-
allowedPauseCaps: () => (tx: Transaction) =>
|
|
103
|
+
allowedPauseCaps: () => (tx: Transaction) => _mysten_sui_transactions300.TransactionResult;
|
|
104
104
|
}
|
|
105
105
|
//#endregion
|
|
106
106
|
export { MarginRegistryContract };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@mysten/deepbook-v3",
|
|
3
3
|
"author": "Mysten Labs <build@mystenlabs.com>",
|
|
4
4
|
"description": "Sui Deepbook SDK",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.4.1",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"wait-on": "^9.1.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@mysten/sui": "^2.
|
|
68
|
+
"@mysten/sui": "^2.31.0"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
|
package/src/predict/client.ts
CHANGED
|
@@ -290,8 +290,9 @@ export function predict<Name extends string = 'predict'>({
|
|
|
290
290
|
* The one object an app constructs. Wraps the config, a client for reads, and
|
|
291
291
|
* a derived-account model so callers pass owner addresses, decimal amounts, and
|
|
292
292
|
* human market coordinates — the facade converts to raw units, resolves markets
|
|
293
|
-
* (cached), and delegates to the internal tx primitives / reads.
|
|
294
|
-
*
|
|
293
|
+
* (cached), and delegates to the internal tx primitives / reads. Each `tx.*` builder
|
|
294
|
+
* returns a finished `Transaction`; callers composing their own PTBs use the generated
|
|
295
|
+
* move-call bindings this subpath exports (`plpMoveCalls`, `expiryMarketMoveCalls`, …).
|
|
295
296
|
*/
|
|
296
297
|
export class PredictClient {
|
|
297
298
|
readonly cfg: PredictConfig;
|
package/src/predict/index.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
// Public API for `@mysten/deepbook-v3/predict`. The curated surface is the `PredictClient`
|
|
4
4
|
// facade plus the value types, unit conversions, tick helpers, typed errors, and typed
|
|
5
|
-
// execution-result decoders — and the few primitives below
|
|
6
|
-
//
|
|
5
|
+
// execution-result decoders — and, for composing your own PTBs, the few primitives below
|
|
6
|
+
// that compose predict accounts with FOREIGN packages plus the generated move-call bindings.
|
|
7
7
|
|
|
8
8
|
// === Facade === (register as a client extension: `client.$extend(predict({ network }))`)
|
|
9
9
|
export { POSITION_LOT_SIZE, PredictClient, predict } from './client.js';
|
|
@@ -30,6 +30,30 @@ export type {
|
|
|
30
30
|
// shared account primitive — reach for its `AccountContract` to drive it directly.
|
|
31
31
|
export { deriveAccountWrapperId, generateAuth } from './tx/common.js';
|
|
32
32
|
|
|
33
|
+
// === Move-call bindings === the generated transaction thunks for every Predict module with a
|
|
34
|
+
// callable function, for putting Predict calls into a PTB you are building — each facade `tx.*`
|
|
35
|
+
// builder returns a finished `Transaction` instead. Mirrors `/account`'s `accountMoveCalls`. Pass
|
|
36
|
+
// `config: toGeneratedConfig(cfg)` and the shared objects fill themselves in; owner-authorized
|
|
37
|
+
// calls take an `Auth` from `generateAuth(cfg)`. Each namespace also carries its module's BCS
|
|
38
|
+
// structs; the `*Events` namespaces are event layouts only.
|
|
39
|
+
export * as adminMoveCalls from '../contracts/deepbook_predict/admin.js';
|
|
40
|
+
export * as builderCodeMoveCalls from '../contracts/deepbook_predict/builder_code.js';
|
|
41
|
+
export * as expiryMarketMoveCalls from '../contracts/deepbook_predict/expiry_market.js';
|
|
42
|
+
export * as marketLifecycleCapMoveCalls from '../contracts/deepbook_predict/market_lifecycle_cap.js';
|
|
43
|
+
export * as marketManagerMoveCalls from '../contracts/deepbook_predict/market_manager.js';
|
|
44
|
+
export * as pauseCapMoveCalls from '../contracts/deepbook_predict/pause_cap.js';
|
|
45
|
+
export * as plpMoveCalls from '../contracts/deepbook_predict/plp.js';
|
|
46
|
+
export * as poolValuationCapMoveCalls from '../contracts/deepbook_predict/pool_valuation_cap.js';
|
|
47
|
+
export * as predictAccountMoveCalls from '../contracts/deepbook_predict/predict_account.js';
|
|
48
|
+
export * as pricingMoveCalls from '../contracts/deepbook_predict/pricing.js';
|
|
49
|
+
export * as protocolConfigMoveCalls from '../contracts/deepbook_predict/protocol_config.js';
|
|
50
|
+
export * as rangeCodecMoveCalls from '../contracts/deepbook_predict/range_codec.js';
|
|
51
|
+
export * as registryMoveCalls from '../contracts/deepbook_predict/registry.js';
|
|
52
|
+
export * as builderCodeEvents from '../contracts/deepbook_predict/builder_code_events.js';
|
|
53
|
+
export * as configEvents from '../contracts/deepbook_predict/config_events.js';
|
|
54
|
+
export * as orderEvents from '../contracts/deepbook_predict/order_events.js';
|
|
55
|
+
export * as vaultEvents from '../contracts/deepbook_predict/vault_events.js';
|
|
56
|
+
|
|
33
57
|
// === Config ===
|
|
34
58
|
export {
|
|
35
59
|
MAINNET_CONFIG,
|