import { PredictConfig } from "./config/types.mjs"; import { MaxMintNow, OrderKindName, OrderView, QueuedOrder, TimingPreview, slippageBand } from "./queue.mjs"; import { BalanceChangeReceipt, BuilderCodeReceipt, ClaimReceipt, CohortCommitReceipt, CreateManagerReceipt, DecodableTransactionResult, EnqueueReceipt, ExpiryPnlRealizedReceipt, MarketPayoutsCompletedReceipt, MintReceipt, OpenRecordPayoutReceipt, PlpCancelReceipt, PlpRequestReceipt, PolicyUpdateReceipt, QueueEvent, QueueOpsReceipt, QueuedFillReceipt, QueuedRefundReceipt, RecordFundsReceipt, RedeemReceipt } from "./decode.mjs"; import { BoardPricer } from "./pricing.mjs"; import { Side } from "./ticks.mjs"; import { FeePolicy } from "./cost.mjs"; import { PredictPreflightCode } from "./errors.mjs"; import { LazerPackages } from "./tx/queue.mjs"; import { ExecutionMode, MarketQueueState } from "./reads/queue.mjs"; import { OpenPosition } from "./reads/positions.mjs"; import { PricerSnapshot } from "./reads/pricing.mjs"; import { Transaction } from "@mysten/sui/transactions"; import { ClientWithCoreApi, SuiClientRegistration } from "@mysten/sui/client"; //#region src/predict/client.d.ts /** * Testnet's `position_lot_size`, read from the deployment record. Validation uses the lot * size of the config actually in play; this is the convenience constant for testnet callers. */ declare const POSITION_LOT_SIZE: bigint; /** A live/settled market addressed by its human coordinates: a binary position * (single strike + side) or a two-strike range position. */ type MarketDescriptor = { underlying: string; expiryMs: number | bigint; /** * Pin resolution to this exact `ExpiryMarket` object, skipping the * underlying+expiry lookup — a caller that reviewed a specific market object * mints against exactly that object, not whatever resolves at submit time. */ marketId?: string; } & ({ side: Side; /** * Strike in USD, or "reference" to trade at the market's on-chain reference * price (the Polymarket-style anchor: derived from the exact previous-window * oracle observation, so consecutive windows chain settlement → next strike). */ strike: number | 'reference'; } | { /** A range position: pays out when settlement lands inside `(lower, upper]` * (left-open, right-closed — same convention as the on-chain range key). */ side: 'range'; /** Lower strike bound in USD — finite, on the tick grid. */ lower: number; /** Upper strike bound in USD — finite, on the tick grid, above `lower`. */ upper: number; }); /** Options for the friendly `mint` (exact payout quantity). */ interface MintOptions { quantity: number; maxCost?: number; maxProbability?: number; } /** Options for `mintAmount` (spend up to a premium budget, floor the quantity received). */ interface MintAmountOptions { /** Premium budget in quote units — the max premium paid (chain also caps it at the account balance). */ spend: number; minQuantity: number; /** All-in cost ceiling in quote units (premium + fees). Omitted → uncapped. */ maxCost?: number; } /** Options for `mintCost`: all-in budget. Requires Predict v2 or later. */ interface MintCostOptions { /** All-in USDC budget; the chain also caps it at the account balance. */ spend: number; /** Minimum payout received. Zero disables this slippage floor. */ minQuantity: number; } /** Options for `redeem`: which order and how much to close. `claimSettled` takes only * `orderId` — a settled claim closes the order in full. */ interface CloseOptions { orderId: bigint; quantity: number; } /** Options for `supplyPlp`. */ interface PlpSupplyOptions { /** * Floor on the PLP minted for the whole request, as raw `bigint` shares — PLP is raw * everywhere in this SDK. It is a floor on the MARK, not a share count: a flush quoting * less does not fill smaller, it declines. Omitted → `0n`, no floor. * * How a miss is handled is the deployment's `lp_request_limit_flush_attempts`: at the * shipped count of one the first flush below the floor cancels and refunds the request. */ minPlpOut?: bigint; } /** Options for `withdrawPlp`. */ interface PlpWithdrawOptions { /** * Floor on the USDC paid for the whole request, in USD decimals like every other amount * here. A floor on the MARK, not an amount: a flush quoting less declines rather than * paying out smaller. Omitted → no floor. Measured after the protocol's withdraw fee. */ minUsdcOut?: number | string; } /** One tradeable market as returned by read.markets(). */ interface ActiveMarket { id: string; expiryMs: bigint; /** Strike granularity in USD (e.g. 0.01). */ tickSize: number; /** * Coarser step new mint strikes must align to. A numeric strike must be a whole * multiple of this (the market's `referencePrice` is the one exception the chain * admits off-grid); otherwise the mint aborts `EInvalidAdmissionTick`. */ admissionTickSize: number; mintPaused: boolean; /** The window's anchor strike in USD, or null until the keeper seeds it. */ referencePrice: number | null; } /** A resolved live market: its on-chain state summary for the caller. */ interface MarketSummary { id: string; expiryMs: bigint; tickSize: number; /** * Coarser step new mint strikes must align to. A numeric strike must be a whole * multiple of this (the market's `referencePrice` is the one exception the chain * admits off-grid); otherwise the mint aborts `EInvalidAdmissionTick`. */ admissionTickSize: number; mintPaused: boolean; nav: number; /** The window's anchor strike in USD, or null until the keeper seeds it. */ referencePrice: number | null; } /** * A market's settlement, from `read.settlement`. Pass `settlementPriceRaw` and `tickSizeRaw` to * `cost.settledPayout` to show what a position paid. */ interface MarketSettlement { marketId: string; expiryMs: bigint; /** Whether Predict has recorded the settlement price. */ settled: boolean; /** The settlement price in USD, or null until the market settles. */ settlementPrice: number | null; /** The settlement price at the 1e9 price scale, or null until the market settles. */ settlementPriceRaw: bigint | null; /** The market's raw tick size, which `cost.settledPayout` rounds the price against. */ tickSizeRaw: bigint; } /** Aggregate pool figures. Balances in human units (shares raw); the pending fields * are request COUNTS, not amounts — the on-chain getters expose queue lengths, and * the escrowed USDC/PLP behind them is tracked separately. */ interface PoolSummary { plpTotalSupply: bigint; idleUsdc: number; /** Number of LP supply requests queued for the next flush. */ supplyRequestsPending: number; /** Number of LP withdraw requests queued for the next flush. */ withdrawRequestsPending: number; } /** Exact pre-trade quote: the dry-run receipt of the mint you are about to send. */ interface MintQuote { /** Fill price, 0..1 per $1 payout. */ entryProbability: number; /** Premium paid into LP backing (quote units). */ premium: number; /** * Fee breakdown. `referral` is a PORTION of the trader-paid trading fee and * congestion surcharge routed to the referrer — it is already inside those * numbers and is NOT an extra debit. `inventoryImpact` is a separate charge and * IS part of `cost`. */ fees: { trading: number; subsidy: number; builder: number; penalty: number; referral: number; inventoryImpact: number; }; /** * All-in account debit: premium + (trading − subsidy) + builder + penalty + * inventoryImpact — exactly what the chain withdraws (the deployed * `compute_mint_quote`'s `all_in_cost`); pass this (plus your buffer) as maxCost. */ cost: number; quantity: number; raw: { premium: bigint; cost: bigint; quantity: bigint; entryProbability: bigint; }; /** True: computed by the real mint code path against real account state. */ feesExact: true; /** * True when this previews a queued (delayed-execution) fill: read from the chain's * `quote_*` functions with the congestion penalty removed, since a queued fill pays none. * Set when the network's config records delayed execution. */ queued?: boolean; /** * Queued previews only: the flat order fee, charged once at enqueue on top of `cost`. Show * it once per order, not per contract. */ orderFee?: number; } /** Exact pre-close quote: the dry-run receipt of the redeem you are about to send. */ interface RedeemQuote { /** NET quote credited to the account. */ proceeds: number; /** Gross close value before fees. */ gross: number; /** `inventoryImpactRebate` is credited back on the close, so `proceeds` is * gross + rebate − trading − builder − penalty. */ fees: { trading: number; builder: number; penalty: number; inventoryImpactRebate: number; }; quantityClosed: number; remaining: number; raw: { proceeds: bigint; gross: bigint; quantityClosed: bigint; }; feesExact: true; } /** A market by its underlying and expiry, optionally pinned to an exact object. */ type MarketCoordinates = Pick; /** Options for `enqueueMint`: a queued mint of an exact payout quantity. */ interface EnqueueMintOptions { quantity: number; /** All-in USDC cap (premium + fees). Required: a queued mint has no "unlimited" cap. */ maxCost: number; /** Entry-probability cap at τ, in (0, 1]. Required. See `queue.slippageBand`. */ maxProbability: number; } /** Options for `enqueueMintAmount`: a queued premium-budget mint. */ interface EnqueueMintAmountOptions { /** Premium budget in USDC. */ spend: number; /** Floor on the payout received. */ minQuantity: number; /** All-in USDC cap (premium + fees). Required. */ maxCost: number; } /** Options for `enqueueMintCost`: a queued all-in-budget mint. */ interface EnqueueMintCostOptions { /** All-in USDC budget, fees included. Escrowed at enqueue, less what the fill doesn't use. */ spend: number; /** Floor on the payout received. Zero disables this slippage floor. */ minQuantity: number; } /** Options for `enqueueSell`: a queued early sell of an Open record. */ interface EnqueueSellOptions { /** The Open record to sell from: its queue record ID, not the position's order ID. */ recordId: bigint; /** Payout quantity to close. A partial sell must leave at least the policy minimum. */ quantity: number; /** Close-side probability floor at τ, in [0, 1]. Pass 0 on purpose to disable it. */ minProbability: number; /** Floor on the proceeds before the order fee, in USDC. Pass 0 on purpose to disable it. */ minProceeds: number; /** * Add `rebalance_expiry_cash` after the enqueue so the market is funded for this sell at once. * `'auto'` (default) adds it only when the sell's cash need is above spare cash, `'always'` * always, `'never'` never. It takes the hot `PoolVault`, so keep it conditional. */ fundMarket?: 'auto' | 'always' | 'never'; } /** What a queued order builder previews alongside the transaction. Display only. */ interface QueuedOrderPreview { marketId: string; kind: number; kindName: OrderKindName; /** τ, deadline and cutoff for an order placed now, from the local clock. */ timing: TimingPreview; /** The flat order fee, charged once at enqueue. */ orderFee: number; /** USDC escrowed for the premium and fees; 0 for a sell. Unused budget returns at the fill. */ budget: number; /** What enqueue debits: budget + order fee. */ totalDebit: number; /** The order's worst-case cash need against the market's spare cash. */ cashNeedRaw: bigint; spareCashRaw: bigint; /** * Sells only: the cash need is above spare cash, so the sell may be refunded in full * (reason 8) unless the market is funded before the fill. */ needsFunding: boolean; /** Whether the builder added `rebalance_expiry_cash` after the enqueue. */ fundedInTransaction: boolean; raw: { orderFee: bigint; budget: bigint; totalDebit: bigint; }; } /** A queued order's transaction and its preview. */ interface QueuedOrderPlan { transaction: Transaction; preview: QueuedOrderPreview; } /** * How much the price may move against a queued order between its quote and its fill, in cents per * contract. A contract pays $1, so its price in cents is its probability: 10¢ of slippage lets * a 42¢ contract fill at up to 52¢, fees included. It is never a percentage. */ interface SlippageOptions { /** * Cents per contract: `10` is 10¢. `'auto'` (the default) sizes it with `queue.slippageBand` * from the time to expiry and the policy's delay. */ slippageCents?: number | 'auto'; /** Standard deviations of movement for `'auto'`. Default 2. */ k?: number; } /** * Options for `read.planMint`. `amount` plans a purchase form's spend (an all-in budget mint), * and `quantity` plans an exact payout. */ type PlanMintOptions = SlippageOptions & ({ /** The purchase amount in USDC. */amount: number; /** * Whether `amount` is the whole debit, order fee included (`'inclusive'`, the default), * or the order fee is charged on top (`'exclusive'`). */ orderFee?: 'inclusive' | 'exclusive'; } | { quantity: number; }); /** The slippage a plan applied. */ interface AppliedSlippage { /** Cents per contract. */ cents: number; source: 'input' | 'auto'; /** The model band when `source` is `'auto'`. */ band: ReturnType | null; } /** * `read.planMint`: everything a purchase form shows, and the enqueue options that carry its * slippage. Display only: the fill prices at τ, within the limits in `order`. */ interface MintPlan { shape: 'budget' | 'exact-quantity'; /** The owner, market and strike range the plan was quoted for. */ target: PlanTarget; /** The quote at the current price. */ quote: MintQuote; /** * Whether the quote is the account's own (`quote_mint_*_for_account`, with its builder fee). A * visitor without an account, or a balance below the order, gets `quote_mint`'s quote instead, * with a budget's quantity found by a short search. */ quoteForAccount: boolean; slippage: AppliedSlippage; /** The payout if it wins, at the current price ("Potential payout"). */ potentialPayout: number; /** The smallest payout the order accepts, at the worst price. A smaller fill is refunded. */ minPayout: number; /** `potentialPayout / expectedDebit` ("Payout multiple"), order fee included. */ payoutMultiple: number; /** `minPayout / totalDebit`: the multiple at the worst price. */ minPayoutMultiple: number; /** All-in price per contract now in USDC (0.42 is 42¢), after the fee subsidy, order fee excluded. */ pricePerContract: number; /** * The worst price the limits admit: the price per contract without the fee subsidy, plus the * slippage. Enqueue admission checks the order without the subsidy, and the subsidy can run out * before the fill, so the limits never count on it. */ worstPricePerContract: number; /** The flat order fee, read from the order desk, charged once per order. */ orderFee: number; /** USDC escrowed for the premium and fees. Unused budget comes back at the fill. */ budget: number; /** `budget + orderFee`: what enqueue debits. */ totalDebit: number; /** `quote.cost + orderFee`: what the order costs if it fills at the current price. */ expectedDebit: number; balance: { /** Whether the owner has a Predict account yet. */hasAccount: boolean; /** The account's USDC, or null without an account. */ available: number | null; /** Whether the balance covers `totalDebit`, or null without an account. */ covers: boolean | null; }; /** * The largest `amount` (budget plans) or `quantity` (exact plans) the market's spare cash and, * with an account, the balance allow now. An exact plan's balance bound prices each contract * at the plan's `worstPricePerContract`. Null when neither binds. */ maxNow: number | null; /** τ, deadline and cutoff for an order placed now, from the local clock. */ timing: TimingPreview; /** * Whether `tx.enqueuePlan` would build the order now and admission would take it at the current * price: the builder's preflight (the queue gates, the order fee, the minimum premium and the * market's cash), the balance against `totalDebit`, the payout bound and, for a budget, the * floor admission buys without the fee subsidy. Two admission conditions are checked only on * chain, at placement: the market's SVI age under the order desk's `svi_max_age_ms`, and room in * the payout tree for a new strike's boundary nodes. */ accepting: boolean; /** * The `PredictPreflightError` code the order would get now, or null. `'fee'` also covers a * missing account or a balance below `totalDebit`. */ refusal: PredictPreflightCode | null; /** Pass `order.options` to `tx[order.builder]`. */ order: { builder: 'enqueueMintCost'; options: EnqueueMintCostOptions; } | { builder: 'enqueueMint'; options: EnqueueMintOptions; }; raw: { budget: bigint; orderFee: bigint; totalDebit: bigint; slippage: bigint; minQuantity: bigint; maxCost: bigint | null; maxProbability: bigint | null; pricePerContract: bigint; worstPricePerContract: bigint; }; } /** * What a plan was quoted for. Its limits are sized for that one order, so `tx.enqueuePlan` refuses * the plan for any other owner, market, strike or record. */ interface PlanTarget { owner: string; expiryMarketId: string; /** A mint's strike range, as the market's admission ticks. */ lowerTick?: bigint; higherTick?: bigint; /** A sell's Open record. Record IDs restart in every market. */ recordId?: bigint; } /** Options for `read.planSell`. */ type PlanSellOptions = SlippageOptions & { /** The Open record to sell from. */recordId: bigint; /** Payout quantity to close. */ quantity: number; }; /** `read.planSell`: what an early sell shows, and the enqueue options that carry its slippage. */ interface SellPlan { /** The owner, market and record the plan was quoted for. */ target: PlanTarget; /** The quote at the current price. */ quote: SellQuote; slippage: AppliedSlippage; /** Proceeds at the current price, before the order fee. */ proceeds: number; /** `proceeds − orderFee`. */ net: number; /** The proceeds floor the order carries, before the order fee. A smaller fill is refunded. */ minProceeds: number; /** * `minProceeds − orderFee`: the worst the sell nets if it fills. Negative when the order fee is * above the proceeds floor. */ minNet: number; orderFee: number; timing: TimingPreview; /** * Whether `tx.enqueuePlan` would build the sell now: the builder's preflight, which checks the * queue gates, that the record is Open and the owner's, the order fee and the minimum sell. The * market's SVI age under the order desk's `svi_max_age_ms` is checked only on chain, at * placement. */ accepting: boolean; /** The `PredictPreflightError` code the sell would get now, or null. */ refusal: PredictPreflightCode | null; /** Pass `order.options` to `tx.enqueueSell`. */ order: { builder: 'enqueueSell'; options: EnqueueSellOptions; }; raw: { slippage: bigint; minProceeds: bigint; minProbability: bigint; orderFee: bigint; }; } /** `read.queue`: a market's queue state plus the derived figures the app shows. */ interface MarketQueueView extends MarketQueueState { mode: ExecutionMode; /** τ, deadline and cutoff for an order placed now, from the local clock. */ timing: TimingPreview; /** * Whether a new mint would pass the queue gates now: the same gates `enqueueMint*` checks * before its fee and cash checks (the order-flow allowlist, the cutover, pauses, stuck, mint * capacity, the cutoff, and the account cap when an owner was given). One side can be full * while the other is open. */ acceptingMints: boolean; /** Whether a new sell would pass the queue gates now (sells skip the mint pauses). */ acceptingSells: boolean; /** * Why each side refuses now, or null: the `PredictPreflightError` code the builder would * throw for the queue gates. */ refusal: { mint: PredictPreflightCode | null; sell: PredictPreflightCode | null; }; /** The largest mint the market's spare cash admits now. */ maxMint: { exactQuantity: MaxMintNow; budget: MaxMintNow; }; } /** A queue record and its display state. */ interface QueuedOrderView { recordId: bigint; record: QueuedOrder; view: OrderView; } /** How `read.waitForOutcome` ended. */ interface QueuedOrderOutcome { /** `'gone'`: the record is missing (cleaned up, or not landed). `'timeout'`: still waiting. */ outcome: 'filled' | 'refunded' | 'closed' | 'gone' | 'timeout'; order: QueuedOrderView | null; } /** A quote for selling an Open record early (`quote_redeem_open`). */ interface SellQuote { /** The live per-contract probability. */ probability: number; /** Proceeds before the order fee, with no congestion penalty. */ proceeds: number; /** * `proceeds − orderFee`: what the account nets. Negative when the order fee is above the * proceeds, since the fee is charged at enqueue whatever the sell returns. */ net: number; fees: { trading: number; builder: number; inventoryImpactRebate: number; order: number; }; quantityClosed: number; raw: { probability: bigint; proceeds: bigint; orderFee: bigint; quantityClosed: bigint; }; } type BinaryMarketCoordinates = Pick & { strike: number | 'reference'; }; /** The Sui client surface PredictClient reads through: any `ClientWithCoreApi` * (gRPC or GraphQL) provides both the `simulateTransaction` the reads/quotes * sit on and the `core` object methods position enumeration needs. */ interface PredictCompatibleClient extends ClientWithCoreApi {} /** * Register PredictClient as a `client.predict` extension, mirroring * `@mysten/deepbook-v3`'s `deepbook(...)`: `client.$extend(predict({ network }))`. */ declare function predict({ name, network, config }: { name?: Name; network: 'testnet' | 'mainnet'; config?: PredictConfig; }): SuiClientRegistration; declare class PredictClient { #private; readonly cfg: PredictConfig; constructor(opts: { network: 'testnet' | 'mainnet'; client: PredictCompatibleClient; config?: PredictConfig; }); /** The deterministic id of an owner's canonical account wrapper — no chain read. */ wrapperIdFor(owner: string): string; /** * The deterministic id of a market's `MarketQueue` under the config's queue registry, whether * or not it exists yet — no chain read. Throws `PredictInputError` while the config doesn't * record delayed execution. */ queueIdFor(marketId: string): string; readonly tx: { createManager: () => Transaction; deposit: (owner: string, amountUsdc: number | string, opts?: { create?: boolean; }) => Transaction; withdraw: (owner: string, amountUsdc: number | string, opts?: { toCoinObject?: boolean; }) => Transaction; /** * Immediate exact-quantity mint (`mint_exact_quantity`). * @deprecated Retired by delayed execution (DBU-885): Predict v4 always aborts it * (`EDelayedExecutionRequired`), so it works only while the config calls a pre-v4 package. * Use {@link PredictClient.tx.enqueueMint}, and `read.executionMode()` to know which path a * network is on. */ mint: (owner: string, m: MarketDescriptor, opts: MintOptions) => Promise; /** * V2 all-in budget mint; use minQuantity to protect the fill against slippage. * @deprecated Retired by delayed execution (DBU-885): Predict v4 always aborts it * (`EDelayedExecutionRequired`). Use `tx.enqueueMintCost`. */ mintCost: (owner: string, m: MarketDescriptor, opts: MintCostOptions) => Promise; /** * Immediate premium-budget mint (`mint_exact_amount`). * @deprecated Retired by delayed execution (DBU-885): Predict v4 always aborts it * (`EDelayedExecutionRequired`). Use `tx.enqueueMintAmount`. */ mintAmount: (owner: string, m: MarketDescriptor, opts: MintAmountOptions) => Promise; /** * Immediate close of an account position (`redeem_live`). * @deprecated Retired by delayed execution (DBU-885): Predict v4 always aborts it * (`EDelayedExecutionRequired`). A position held in the account then has no early exit and * is paid at settlement with `claimSettled`. Queued fills are Open records in the market's * queue, sold with `tx.enqueueSell`. */ redeem: (owner: string, m: MarketDescriptor, opts: CloseOptions) => Promise; /** * Pay a settled position held in the ACCOUNT (`redeem_settled`), in full. Unchanged by delayed * execution, for positions minted before it. It doesn't pay Open queue records: the queue's * settlement walk (`settle_step`) pays those to the account's wrapper address. */ claimSettled: (owner: string, m: Pick, opts: Pick) => Promise; /** * Queue a mint of an exact payout quantity, filled at Pyth's price for its τ. Escrows * `min(maxCost, quantity, available − fee)` plus the order fee. `maxCost` and * `maxProbability` are required caps (see `queue.slippageBand`). Size against * `read.queue(...).maxMint`. The record ID is in the enqueue's `OrderEnqueued` * (`decode.enqueue`). */ enqueueMint: (owner: string, m: MarketDescriptor, opts: EnqueueMintOptions) => Promise; /** * Queue a premium-budget mint: sized at τ under `spend`, at least `minQuantity`, with the * all-in debit capped by the required `maxCost`. */ enqueueMintAmount: (owner: string, m: MarketDescriptor, opts: EnqueueMintAmountOptions) => Promise; /** * Queue an all-in-budget mint (the default mint): sized at τ so the all-in cost fits * `spend`, at least `minQuantity`. Escrows `min(spend, available − fee)` plus the order fee. */ enqueueMintCost: (owner: string, m: MarketDescriptor, opts: EnqueueMintCostOptions) => Promise; /** * Queue an early sell of an Open record (`enqueue_redeem_open`), the only early sell in v4. * The record must be Open and the owner's. Sells are never refused for market cash: when the * sell's cash need is above spare cash the preview sets `needsFunding`, and by default the * builder adds `rebalance_expiry_cash` after the enqueue (see `fundMarket`). A sell the market * still can't cover at the fill is refunded in full (reason 8) and the position returns to an * Open record. */ enqueueSell: (owner: string, m: MarketCoordinates, opts: EnqueueSellOptions) => Promise; /** * Queue the order a `read.planMint` or `read.planSell` plan describes, with its limits: * `enqueueMintCost`, `enqueueMint` or `enqueueSell`, by `plan.order.builder`. Pass the * market the plan was made for: the descriptor a mint plan was planned with, or the * coordinates `read.planSell` took for a sell plan. Throws the plan's `refusal` as a * `PredictPreflightError`, and `'fee'` when the balance now escrows less than the plan's * budget. */ enqueuePlan:

(owner: string, m: P extends SellPlan ? MarketCoordinates : MarketDescriptor, plan: P) => Promise; /** * Refund this market's orders past their deadline. For the app's "Refund my order" button * only (`OrderView.canRequestRefund`), never prepended to other transactions: keepers * refund on their own. Needs no account, session or Pyth key, and works during a freeze. * `maxOrders` (default 100) bounds the records visited. */ refund: (m: MarketCoordinates, opts?: { maxOrders?: number; }) => Promise; /** * Send a finished record's parked funds to its receive address (`queue::claim_parked`): a * refund or change the address couldn't take while it was on USDC's deny list or USDC was * paused (`OrderView` `parkedRaw`). A skipped settlement payout isn't parked: pay it with * `payOpen`. Permissionless, and a no-op returning 0 while * the address is still denied. Needs no account, session or Pyth key. */ claimParked: (m: MarketCoordinates, recordId: bigint) => Promise; /** * Pay a settled market's Open record that the payout walk skipped (`queue::pay_open`), for * example while its receive address was denied. Permissionless: the payout goes only to the * record's own receive address. Aborts `EMarketNotSettled` before settlement. */ payOpen: (m: MarketCoordinates, recordId: bigint) => Promise; /** * The open filler: verify signed Pyth Lazer payloads, commit them to the market's waiting * cohorts, then resolve up to `maxOrders` (default 15) records. Reads the current Lazer * package from Lazer's `State` first (`lazerStateId`, or `config.oracle.pythLazerState`). */ fill: (m: MarketCoordinates, opts: { payloads: readonly Uint8Array[]; maxOrders?: number; refundOverdue?: boolean; lazerStateId?: string; }) => Promise; supplyPlp: (owner: string, amountUsdc: number | string, options?: PlpSupplyOptions) => Transaction; withdrawPlp: (owner: string, shares: bigint, options?: PlpWithdrawOptions) => Transaction; cancelSupplyPlp: (owner: string, index: bigint) => Transaction; cancelWithdrawPlp: (owner: string, index: bigint) => Transaction; setBuilderCode: (owner: string, builderCodeId: string) => Transaction; unsetBuilderCode: (owner: string) => Transaction; }; readonly read: { markets: () => Promise; hasPosition: (owner: string, marketId: string, orderId: bigint) => Promise; positions: (owner: string) => Promise; price: (m: BinaryMarketCoordinates) => Promise<{ up: number; down: number; }>; pricer: (m: Pick) => Promise; /** * Exact pre-trade quote for an exact-quantity mint. Requires a funded account. * * Where the config records the delayed-execution upgrade (`packages.predictDelayedExecution`), * this reads Predict's own `quote_mint_for_account` (the immediate mint is retired there) and * the order desk's fee, and previews a QUEUED fill at the clock: `queued: true`, no * congestion penalty in `cost`, and the order fee in `orderFee`. The fill itself prices at * its committed Pyth tick. It throws `PredictInputError` when that config lacks the * order-flow package or its desk. Elsewhere it dry-runs the immediate mint and decodes its * receipt, as before. */ quoteMint: (owner: string, m: MarketDescriptor, opts: Pick) => Promise; /** * Quote the all-in budget mint against current account and market state. Where the config * records the delayed-execution upgrade, it reads `quote_mint_exact_cost_for_account` at * `min(spend, available − fee)`, the budget enqueue escrows, and previews a queued fill as * `quoteMint` does (and throws as it does on a partial config). Elsewhere it simulates the * immediate v2 mint. */ quoteMintCost: (owner: string, m: MarketDescriptor, opts: MintCostOptions) => Promise; /** * Quote an early sell of an Open record (the queue's `quote_redeem_open`) at a fresh live * pricer. `proceeds` is before the order fee, with no congestion penalty, and `net` takes the * fee off. Throws `ERecordNotOpen` when the record isn't Open. */ quoteSell: (owner: string, m: MarketCoordinates, opts: { recordId: bigint; quantity: number; }) => Promise; /** * Which trade path the network is on, from `ProtocolConfig.version_watermark` and whether * this config records delayed execution (the Predict upgrade, the order-flow companion and * its desk). Flip the app between `mint*` and `enqueue*` on it, without a redeploy at the * watermark bump. */ executionMode: () => Promise; /** * A market's queue in one read: cash, the stuck gate ("pricing delayed"), cohorts, counters * against capacity, the desk's policy, a τ/deadline/cutoff preview, and the largest mint * spare cash admits now. With `owner` (who must have an account), also the account's * waiting orders and balance. Throws `PredictPreflightError` `'no-queue'` while the market * has no `MarketQueue`. */ queue: (m: MarketCoordinates, owner?: string) => Promise; /** * Plan a queued mint for a purchase form: the quote at the current price, the payout and * multiple, the order fee read from the desk, the escrow and debit, the balance, the most * the market takes now, the timing and the queue gates, plus the enqueue options that carry * the slippage. `amount` plans an all-in spend (`enqueueMintCost`, refunded below the payout * floor), and `quantity` an exact payout (`enqueueMint`, capped by probability and cost). * Works for a visitor without an account: the quote then comes from `quote_mint`. * * `slippageCents` is cents per contract, never a percentage: a 10¢ limit fills while the * all-in price per contract stays within 10¢ of the quote's price without its fee subsidy. */ planMint: (owner: string, m: MarketDescriptor, opts: PlanMintOptions) => Promise; /** * Plan a queued early sell of an Open record: the quote at the current price, net of the * order fee, the floors at the worst price the slippage allows, the timing and the * builder's preflight, plus the `enqueueSell` options that carry the floors. A record that * isn't Open has no quote, so it throws `PredictPreflightError` `'record-not-open'` instead. */ planSell: (owner: string, m: MarketCoordinates, opts: PlanSellOptions) => Promise; /** One queue record and its display state, or null when missing or cleaned up. */ order: (m: MarketCoordinates, recordId: bigint) => Promise; /** * Queue records by record ID, with their display states. The SDK has no indexer: the app * supplies record IDs from its enqueue receipts or its indexer. */ orders: (m: MarketCoordinates, recordIds: readonly bigint[]) => Promise<(QueuedOrderView | null)[]>; /** * Poll a record until it is filled, refunded or closed (`pollMs`, default 250), or until * `timeoutMs` (default 30 s). The fullnode a client reads can trail the enqueue's * execution, so a record not seen yet is polled again until the timeout, and ends as * `'gone'` only then. A record that disappears after it was seen ends as `'gone'` at once. * The record's result is enough for the UI; the fee breakdown is in the * `QueuedOrderFilled` event. */ waitForOutcome: (m: MarketCoordinates, recordId: bigint, opts?: { pollMs?: number; timeoutMs?: number; signal?: AbortSignal; }) => Promise; /** * USDC sent to the owner's account wrapper that the account hasn't settled yet: refunds, * sell proceeds and settled payouts of Open records. Already counted in `read.balance`; for * display. */ pendingFunds: (owner: string) => Promise; /** The current Pyth Lazer package, for a filler. Read it per batch and never cache it. */ lazerPackages: (stateId?: string) => Promise; /** * Exact pre-close quote for an ACCOUNT position: dry-runs the immediate redeem and decodes * the receipt. * @deprecated `redeem_live` is retired by delayed execution (DBU-885): Predict v4 always * aborts it. Queued fills are Open records: quote them with `read.quoteSell`. */ quoteRedeem: (owner: string, m: MarketDescriptor, opts: CloseOptions) => Promise; market: (m: Pick) => Promise; /** * The market's settlement price, or `null` until a keeper settles it. Unlike `market`, * `price` and the quotes, which abort `ELivePricingExpired` once the market expires, it * keeps working after expiry, when an app shows results. With delayed execution the * keeper settles a market, pays its Open records and cleans them up within about a second * of expiry, so `read.order` returns `null` by then. Keep each filled record's * `position.orderId` and pass it to `cost.settledPayout` with this price. */ settlement: (m: MarketCoordinates) => Promise; /** * The fee and exposure policy the market snapshotted at creation, ready to pass to the * `cost` functions as `fees`. A market keeps it for its whole life, so it can differ from * the protocol's current template, and neither recorded deployment's template matches * `cost.SHIPPED_FEE_POLICY` any more. One object read. */ feePolicy: (m: MarketCoordinates) => Promise; balance: (owner: string) => Promise; plpBalance: (owner: string) => Promise; pool: () => Promise; }; readonly decode: { mint: (r: DecodableTransactionResult) => MintReceipt; mints: (r: DecodableTransactionResult) => MintReceipt[]; redeem: (r: DecodableTransactionResult) => RedeemReceipt; redeems: (r: DecodableTransactionResult) => RedeemReceipt[]; claim: (r: DecodableTransactionResult) => ClaimReceipt; claims: (r: DecodableTransactionResult) => ClaimReceipt[]; createManager: (r: DecodableTransactionResult) => CreateManagerReceipt; deposit: (r: DecodableTransactionResult) => BalanceChangeReceipt; withdraw: (r: DecodableTransactionResult) => BalanceChangeReceipt; plpRequest: (r: DecodableTransactionResult) => PlpRequestReceipt; plpCancel: (r: DecodableTransactionResult) => PlpCancelReceipt; builderCode: (r: DecodableTransactionResult) => BuilderCodeReceipt; /** The trader's `OrderEnqueued` receipt: the record ID, τ, deadline, escrow and fee. */ enqueue: (r: DecodableTransactionResult) => EnqueueReceipt; enqueues: (r: DecodableTransactionResult) => EnqueueReceipt[]; /** Every queue event, tagged, in chain order: feed it to `queue.reduceOrderEvents`. */ queueEvents: (r: DecodableTransactionResult) => QueueEvent[]; cohortCommits: (r: DecodableTransactionResult) => CohortCommitReceipt[]; queuedFills: (r: DecodableTransactionResult) => QueuedFillReceipt[]; queuedRefunds: (r: DecodableTransactionResult) => QueuedRefundReceipt[]; openRecordPayouts: (r: DecodableTransactionResult) => OpenRecordPayoutReceipt[]; marketPayoutsCompleted: (r: DecodableTransactionResult) => MarketPayoutsCompletedReceipt[]; queueOps: (r: DecodableTransactionResult) => QueueOpsReceipt[]; /** `RecordFundsParked` and `RecordFundsClaimed`: USDC a record keeps until it can be sent. */ recordFunds: (r: DecodableTransactionResult) => RecordFundsReceipt[]; policyUpdates: (r: DecodableTransactionResult) => PolicyUpdateReceipt[]; /** * `ExpiryPnlRealized` changes in the pool's gross realized result, for P&L reporting. Sum * them with `realizedPnlRaw`. */ expiryPnlRealized: (r: DecodableTransactionResult) => ExpiryPnlRealizedReceipt[]; }; } //#endregion export { ActiveMarket, AppliedSlippage, CloseOptions, EnqueueMintAmountOptions, EnqueueMintCostOptions, EnqueueMintOptions, EnqueueSellOptions, MarketCoordinates, MarketDescriptor, MarketQueueView, MarketSettlement, MarketSummary, MintAmountOptions, MintCostOptions, MintOptions, MintPlan, MintQuote, POSITION_LOT_SIZE, PlanMintOptions, PlanSellOptions, PlpSupplyOptions, PlpWithdrawOptions, PoolSummary, PredictClient, PredictCompatibleClient, QueuedOrderOutcome, QueuedOrderPlan, QueuedOrderPreview, QueuedOrderView, RedeemQuote, SellPlan, SellQuote, SlippageOptions, predict }; //# sourceMappingURL=client.d.mts.map