Documentation
    Preparing search index...
    Index
    decode: {
        builderCode: (r: DecodableTransactionResult) => BuilderCodeReceipt;
        claim: (r: DecodableTransactionResult) => ClaimReceipt;
        claims: (r: DecodableTransactionResult) => ClaimReceipt[];
        cohortCommits: (r: DecodableTransactionResult) => CohortCommitReceipt[];
        createManager: (r: DecodableTransactionResult) => CreateManagerReceipt;
        deposit: (r: DecodableTransactionResult) => BalanceChangeReceipt;
        enqueue: (r: DecodableTransactionResult) => EnqueueReceipt;
        enqueues: (r: DecodableTransactionResult) => EnqueueReceipt[];
        expiryPnlRealized: (
            r: DecodableTransactionResult,
        ) => ExpiryPnlRealizedReceipt[];
        marketPayoutsCompleted: (
            r: DecodableTransactionResult,
        ) => MarketPayoutsCompletedReceipt[];
        mint: (r: DecodableTransactionResult) => MintReceipt;
        mints: (r: DecodableTransactionResult) => MintReceipt[];
        openRecordPayouts: (
            r: DecodableTransactionResult,
        ) => OpenRecordPayoutReceipt[];
        plpCancel: (r: DecodableTransactionResult) => PlpCancelReceipt;
        plpRequest: (r: DecodableTransactionResult) => PlpRequestReceipt;
        policyUpdates: (r: DecodableTransactionResult) => PolicyUpdateReceipt[];
        queuedFills: (r: DecodableTransactionResult) => QueuedFillReceipt[];
        queuedRefunds: (r: DecodableTransactionResult) => QueuedRefundReceipt[];
        queueEvents: (r: DecodableTransactionResult) => QueueEvent[];
        queueOps: (r: DecodableTransactionResult) => QueueOpsReceipt[];
        recordFunds: (r: DecodableTransactionResult) => RecordFundsReceipt[];
        redeem: (r: DecodableTransactionResult) => RedeemReceipt;
        redeems: (r: DecodableTransactionResult) => RedeemReceipt[];
        withdraw: (r: DecodableTransactionResult) => BalanceChangeReceipt;
    } = ...

    Type Declaration

    read: {
        balance: (owner: string) => Promise<number>;
        executionMode: () => Promise<ExecutionMode>;
        feePolicy: (m: MarketCoordinates) => Promise<FeePolicy>;
        hasPosition: (
            owner: string,
            marketId: string,
            orderId: bigint,
        ) => Promise<boolean>;
        lazerPackages: (stateId?: string) => Promise<LazerPackages>;
        market: (
            m: Pick<MarketDescriptor, "underlying" | "expiryMs">,
        ) => Promise<MarketSummary | null>;
        markets: () => Promise<ActiveMarket[]>;
        order: (
            m: MarketCoordinates,
            recordId: bigint,
        ) => Promise<QueuedOrderView | null>;
        orders: (
            m: MarketCoordinates,
            recordIds: readonly bigint[],
        ) => Promise<(QueuedOrderView | null)[]>;
        pendingFunds: (owner: string) => Promise<number>;
        planMint: (
            owner: string,
            m: MarketDescriptor,
            opts: PlanMintOptions,
        ) => Promise<MintPlan>;
        planSell: (
            owner: string,
            m: MarketCoordinates,
            opts: PlanSellOptions,
        ) => Promise<SellPlan>;
        plpBalance: (owner: string) => Promise<bigint>;
        pool: () => Promise<PoolSummary>;
        positions: (owner: string) => Promise<OpenPosition[]>;
        price: (
            m: BinaryMarketCoordinates,
        ) => Promise<{ down: number; up: number }>;
        pricer: (
            m: Pick<MarketDescriptor, "underlying" | "expiryMs">,
        ) => Promise<
            BoardPricer & {
                asOf: {
                    blockScholesForwardMs: number;
                    blockScholesSpotMs: number;
                    blockScholesSviMs: number;
                    pythSpotMs: number;
                };
            },
        >;
        queue: (m: MarketCoordinates, owner?: string) => Promise<MarketQueueView>;
        quoteMint: (
            owner: string,
            m: MarketDescriptor,
            opts: Pick<MintOptions, "quantity">,
        ) => Promise<MintQuote>;
        quoteMintCost: (
            owner: string,
            m: MarketDescriptor,
            opts: MintCostOptions,
        ) => Promise<MintQuote>;
        quoteRedeem: (
            owner: string,
            m: MarketDescriptor,
            opts: CloseOptions,
        ) => Promise<RedeemQuote>;
        quoteSell: (
            owner: string,
            m: MarketCoordinates,
            opts: { quantity: number; recordId: bigint },
        ) => Promise<SellQuote>;
        settlement: (m: MarketCoordinates) => Promise<MarketSettlement>;
        waitForOutcome: (
            m: MarketCoordinates,
            recordId: bigint,
            opts?: { pollMs?: number; signal?: AbortSignal; timeoutMs?: number },
        ) => Promise<QueuedOrderOutcome>;
    } = ...

    Type Declaration

    • balance: (owner: string) => Promise<number>
    • executionMode: () => Promise<ExecutionMode>

      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.

    • feePolicy: (m: MarketCoordinates) => Promise<FeePolicy>

      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.

    • hasPosition: (owner: string, marketId: string, orderId: bigint) => Promise<boolean>
    • lazerPackages: (stateId?: string) => Promise<LazerPackages>

      The current Pyth Lazer package, for a filler. Read it per batch and never cache it.

    • market: (
          m: Pick<MarketDescriptor, "underlying" | "expiryMs">,
      ) => Promise<MarketSummary | null>
    • markets: () => Promise<ActiveMarket[]>
    • order: (m: MarketCoordinates, recordId: bigint) => Promise<QueuedOrderView | null>

      One queue record and its display state, or null when missing or cleaned up.

    • orders: (
          m: MarketCoordinates,
          recordIds: readonly bigint[],
      ) => Promise<(QueuedOrderView | null)[]>

      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.

    • pendingFunds: (owner: string) => Promise<number>

      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.

    • planMint: (owner: string, m: MarketDescriptor, opts: PlanMintOptions) => Promise<MintPlan>

      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.

    • planSell: (
          owner: string,
          m: MarketCoordinates,
          opts: PlanSellOptions,
      ) => Promise<SellPlan>

      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.

    • plpBalance: (owner: string) => Promise<bigint>
    • pool: () => Promise<PoolSummary>
    • positions: (owner: string) => Promise<OpenPosition[]>
    • price: (m: BinaryMarketCoordinates) => Promise<{ down: number; up: number }>
    • pricer: (
          m: Pick<MarketDescriptor, "underlying" | "expiryMs">,
      ) => Promise<
          BoardPricer & {
              asOf: {
                  blockScholesForwardMs: number;
                  blockScholesSpotMs: number;
                  blockScholesSviMs: number;
                  pythSpotMs: number;
              };
          },
      >
    • queue: (m: MarketCoordinates, owner?: string) => Promise<MarketQueueView>

      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.

    • quoteMint: (
          owner: string,
          m: MarketDescriptor,
          opts: Pick<MintOptions, "quantity">,
      ) => Promise<MintQuote>

      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.

    • quoteMintCost: (
          owner: string,
          m: MarketDescriptor,
          opts: MintCostOptions,
      ) => Promise<MintQuote>

      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.

    • quoteRedeem: (owner: string, m: MarketDescriptor, opts: CloseOptions) => Promise<RedeemQuote>

      Exact pre-close quote for an ACCOUNT position: dry-runs the immediate redeem and decodes the receipt.

      redeem_live is retired by delayed execution (DBU-885): Predict v4 always aborts it. Queued fills are Open records: quote them with read.quoteSell.

    • quoteSell: (
          owner: string,
          m: MarketCoordinates,
          opts: { quantity: number; recordId: bigint },
      ) => Promise<SellQuote>

      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.

    • settlement: (m: MarketCoordinates) => Promise<MarketSettlement>

      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.

    • waitForOutcome: (
          m: MarketCoordinates,
          recordId: bigint,
          opts?: { pollMs?: number; signal?: AbortSignal; timeoutMs?: number },
      ) => Promise<QueuedOrderOutcome>

      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.

    tx: {
        cancelSupplyPlp: (owner: string, index: bigint) => Transaction;
        cancelWithdrawPlp: (owner: string, index: bigint) => Transaction;
        claimParked: (
            m: MarketCoordinates,
            recordId: bigint,
        ) => Promise<Transaction>;
        claimSettled: (
            owner: string,
            m: Pick<MarketDescriptor, "underlying" | "expiryMs" | "marketId">,
            opts: Pick<CloseOptions, "orderId">,
        ) => Promise<Transaction>;
        createManager: () => Transaction;
        deposit: (
            owner: string,
            amountUsdc: string | number,
            opts?: { create?: boolean },
        ) => Transaction;
        enqueueMint: (
            owner: string,
            m: MarketDescriptor,
            opts: EnqueueMintOptions,
        ) => Promise<QueuedOrderPlan>;
        enqueueMintAmount: (
            owner: string,
            m: MarketDescriptor,
            opts: EnqueueMintAmountOptions,
        ) => Promise<QueuedOrderPlan>;
        enqueueMintCost: (
            owner: string,
            m: MarketDescriptor,
            opts: EnqueueMintCostOptions,
        ) => Promise<QueuedOrderPlan>;
        enqueuePlan: <P extends MintPlan | SellPlan>(
            owner: string,
            m: P extends SellPlan ? MarketCoordinates : MarketDescriptor,
            plan: P,
        ) => Promise<QueuedOrderPlan>;
        enqueueSell: (
            owner: string,
            m: MarketCoordinates,
            opts: EnqueueSellOptions,
        ) => Promise<QueuedOrderPlan>;
        fill: (
            m: MarketCoordinates,
            opts: {
                lazerStateId?: string;
                maxOrders?: number;
                payloads: readonly Uint8Array<ArrayBufferLike>[];
                refundOverdue?: boolean;
            },
        ) => Promise<Transaction>;
        mint: (
            owner: string,
            m: MarketDescriptor,
            opts: MintOptions,
        ) => Promise<Transaction>;
        mintAmount: (
            owner: string,
            m: MarketDescriptor,
            opts: MintAmountOptions,
        ) => Promise<Transaction>;
        mintCost: (
            owner: string,
            m: MarketDescriptor,
            opts: MintCostOptions,
        ) => Promise<Transaction>;
        payOpen: (m: MarketCoordinates, recordId: bigint) => Promise<Transaction>;
        redeem: (
            owner: string,
            m: MarketDescriptor,
            opts: CloseOptions,
        ) => Promise<Transaction>;
        refund: (
            m: MarketCoordinates,
            opts?: { maxOrders?: number },
        ) => Promise<Transaction>;
        setBuilderCode: (owner: string, builderCodeId: string) => Transaction;
        supplyPlp: (
            owner: string,
            amountUsdc: string | number,
            options?: PlpSupplyOptions,
        ) => Transaction;
        unsetBuilderCode: (owner: string) => Transaction;
        withdraw: (
            owner: string,
            amountUsdc: string | number,
            opts?: { toCoinObject?: boolean },
        ) => Transaction;
        withdrawPlp: (
            owner: string,
            shares: bigint,
            options?: PlpWithdrawOptions,
        ) => Transaction;
    } = ...

    Type Declaration

    • cancelSupplyPlp: (owner: string, index: bigint) => Transaction
    • cancelWithdrawPlp: (owner: string, index: bigint) => Transaction
    • claimParked: (m: MarketCoordinates, recordId: bigint) => Promise<Transaction>

      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.

    • claimSettled: (
          owner: string,
          m: Pick<MarketDescriptor, "underlying" | "expiryMs" | "marketId">,
          opts: Pick<CloseOptions, "orderId">,
      ) => Promise<Transaction>

      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.

    • createManager: () => Transaction
    • deposit: (
          owner: string,
          amountUsdc: string | number,
          opts?: { create?: boolean },
      ) => Transaction
    • enqueueMint: (
          owner: string,
          m: MarketDescriptor,
          opts: EnqueueMintOptions,
      ) => Promise<QueuedOrderPlan>

      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).

    • enqueueMintAmount: (
          owner: string,
          m: MarketDescriptor,
          opts: EnqueueMintAmountOptions,
      ) => Promise<QueuedOrderPlan>

      Queue a premium-budget mint: sized at τ under spend, at least minQuantity, with the all-in debit capped by the required maxCost.

    • enqueueMintCost: (
          owner: string,
          m: MarketDescriptor,
          opts: EnqueueMintCostOptions,
      ) => Promise<QueuedOrderPlan>

      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.

    • enqueuePlan: <P extends MintPlan | SellPlan>(
          owner: string,
          m: P extends SellPlan ? MarketCoordinates : MarketDescriptor,
          plan: P,
      ) => Promise<QueuedOrderPlan>

      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.

    • enqueueSell: (
          owner: string,
          m: MarketCoordinates,
          opts: EnqueueSellOptions,
      ) => Promise<QueuedOrderPlan>

      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.

    • fill: (
          m: MarketCoordinates,
          opts: {
              lazerStateId?: string;
              maxOrders?: number;
              payloads: readonly Uint8Array<ArrayBufferLike>[];
              refundOverdue?: boolean;
          },
      ) => Promise<Transaction>

      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).

    • mint: (owner: string, m: MarketDescriptor, opts: MintOptions) => Promise<Transaction>

      Immediate exact-quantity mint (mint_exact_quantity).

      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 PredictClient.tx.enqueueMint, and read.executionMode() to know which path a network is on.

    • mintAmount: (
          owner: string,
          m: MarketDescriptor,
          opts: MintAmountOptions,
      ) => Promise<Transaction>

      Immediate premium-budget mint (mint_exact_amount).

      Retired by delayed execution (DBU-885): Predict v4 always aborts it (EDelayedExecutionRequired). Use tx.enqueueMintAmount.

    • mintCost: (
          owner: string,
          m: MarketDescriptor,
          opts: MintCostOptions,
      ) => Promise<Transaction>

      V2 all-in budget mint; use minQuantity to protect the fill against slippage.

      Retired by delayed execution (DBU-885): Predict v4 always aborts it (EDelayedExecutionRequired). Use tx.enqueueMintCost.

    • payOpen: (m: MarketCoordinates, recordId: bigint) => Promise<Transaction>

      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.

    • redeem: (owner: string, m: MarketDescriptor, opts: CloseOptions) => Promise<Transaction>

      Immediate close of an account position (redeem_live).

      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.

    • refund: (m: MarketCoordinates, opts?: { maxOrders?: number }) => Promise<Transaction>

      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.

    • setBuilderCode: (owner: string, builderCodeId: string) => Transaction
    • supplyPlp: (
          owner: string,
          amountUsdc: string | number,
          options?: PlpSupplyOptions,
      ) => Transaction
    • unsetBuilderCode: (owner: string) => Transaction
    • withdraw: (
          owner: string,
          amountUsdc: string | number,
          opts?: { toCoinObject?: boolean },
      ) => Transaction
    • withdrawPlp: (owner: string, shares: bigint, options?: PlpWithdrawOptions) => Transaction
    • 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.

      Parameters

      • marketId: string

      Returns string

    • The deterministic id of an owner's canonical account wrapper — no chain read.

      Parameters

      • owner: string

      Returns string