import { GeneratedConfig, OrdersGeneratedConfig } from "../config/generated.mjs"; import { MarketFeeds } from "./trade.mjs"; import { Transaction, TransactionResult } from "@mysten/sui/transactions"; //#region src/predict/tx/queue.d.ts declare namespace queue_d_exports { export { LazerPackages, QueueTarget, adminRefund, assertOrderFeeAtMost, claimParked, cleanup, commit, createQueue, enqueueExactAmount, enqueueExactCost, enqueueExactQuantity, enqueueRedeemOpen, fill, parseLazerUpdate, payOpen, queueIdOf, rebalanceExpiryCash, refund, resolve, settleStep }; } /** One market's queue. */ interface QueueTarget { expiryMarketId: string; /** * The market's `MarketQueue`. Defaults to `deriveQueueId(config.queueRegistry, expiryMarketId)`, * the ID `queue::create_and_share` gives it, so pass it only to address another registry's * queue. */ queueId?: string; } /** The queue ID a thunk addresses: the given one, or the one derived from the config's registry. */ declare function queueIdOf(config: Pick, args: QueueTarget): string; /** The market, queue and account every queued order names. */ interface QueuedOrderTarget extends MarketFeeds, QueueTarget { wrapperId: string; } /** * Queue a mint of an exact payout quantity, priced at Pyth's signed price for its τ * (`queue::enqueue_exact_quantity`). Returns the record ID (u64). `maxCostRaw` (all-in cap) and * `maxProbabilityRaw` (entry-probability cap, at most 1e9) are required: there is no "unlimited" * default on the queued path. Escrows `min(max_cost, quantity, available − fee)` plus the order * fee. Command order is auth → enqueue. */ declare function enqueueExactQuantity(config: OrdersGeneratedConfig, args: QueuedOrderTarget & { lowerTick: bigint; higherTick: bigint; quantityRaw: bigint; maxCostRaw: bigint; maxProbabilityRaw: bigint; }): (tx: Transaction) => TransactionResult; /** * Queue a premium-budget mint (`queue::enqueue_exact_amount`): sized at τ under * `maxPremiumRaw`, at least `minQuantityRaw`, with the all-in withdrawal capped by the required * `maxCostRaw`. Escrows `min(max_cost, available − fee)` plus the order fee. Returns the record * ID. Command order is auth → enqueue. `maxPremiumRaw` below the minimum premium (1 USDC) is * refused: the fill could never buy enough premium, so Predict's admission dry run would abort * `EOrderFailsLimits`. */ declare function enqueueExactAmount(config: OrdersGeneratedConfig, args: QueuedOrderTarget & { lowerTick: bigint; higherTick: bigint; maxPremiumRaw: bigint; minQuantityRaw: bigint; maxCostRaw: bigint; }): (tx: Transaction) => TransactionResult; /** * Queue an all-in-budget mint (`queue::enqueue_exact_cost`): sized at τ so the all-in cost fits * `maxCostRaw`, at least `minQuantityRaw`. `maxCostRaw` is the budget and must be a real cap. * Escrows `min(max_cost, available − fee)` plus the order fee. Returns the record ID. Command * order is auth → enqueue. */ declare function enqueueExactCost(config: OrdersGeneratedConfig, args: QueuedOrderTarget & { lowerTick: bigint; higherTick: bigint; maxCostRaw: bigint; minQuantityRaw: bigint; }): (tx: Transaction) => TransactionResult; /** * Queue an early sell of `closeQuantityRaw` from the Open record `recordId` * (`queue::enqueue_redeem_open`; the queue record ID, not the position's u256 order ID). The * only early sell: a position held in the account can't be sold early. The record must be Open * and belong to this account. `minProbabilityRaw` and `minProceedsRaw` are the close-side floors * at τ and are required (`0n` disables either, so pass it on purpose). Escrows only the order * fee. Returns the new record ID, which holds the position until the sell fills or refunds. * Command order is auth → enqueue. */ declare function enqueueRedeemOpen(config: OrdersGeneratedConfig, args: QueuedOrderTarget & { recordId: bigint; closeQuantityRaw: bigint; minProbabilityRaw: bigint; minProceedsRaw: bigint; }): (tx: Transaction) => TransactionResult; /** * Abort the transaction unless the order desk's fee is at most `maxOrderFeeRaw` when it executes. * The enqueues charge the desk's fee at execution and take no fee bound, so add this BEFORE an * enqueue to hold it to the fee its preview showed. It reads the desk's policy, and * `0x1::u64::checked_sub(max, fee)` is none once the fee is above the bound, so * `0x1::option::destroy_some` aborts (`option::EOPTION_NOT_SET`, code 0x40001) before the * enqueue debits anything. Read-only on the desk. */ declare function assertOrderFeeAtMost(config: OrdersGeneratedConfig, maxOrderFeeRaw: bigint): (tx: Transaction) => void; /** * Fund a live market from the pool vault to `max(required × (1 + rebalance %), initial cash, * required + waiting_cash_need)` (Predict's `plp::rebalance_expiry_cash`). Permissionless, and * takes no target. Add it AFTER a big sell's enqueue in the same PTB: the enqueue has already * added the sell's cash need to Predict's waiting total, so the rebalance funds it at once. It * takes the hot `PoolVault`, so add it only when a sell's cash need is above spare cash. */ declare function rebalanceExpiryCash(config: GeneratedConfig, args: { expiryMarketId: string; }): (tx: Transaction) => TransactionResult; /** * Create and share a market's `MarketQueue` (`queue::create_and_share(registry, desk, market)`), * at the ID `deriveQueueId(config.queueRegistry, expiryMarketId)`. Takes the registry mutably and * the desk read-only, so it never contends with trading. Permissionless and once per market (a * second call aborts, since the ID is taken); the caller pays its storage. The market-creation * keeper sends it after each new `ExpiryMarket`. Returns the queue ID. */ declare function createQueue(config: OrdersGeneratedConfig, args: { expiryMarketId: string; }): (tx: Transaction) => TransactionResult; /** * Refund this market's waiting orders at or past their deadline (`queue::refund`, reason 5), * visiting at most `maxOrders` records (the chain caps one call at 450). Permissionless: no auth, * session or Pyth key, and it works during a freeze. Returns how many it refunded, `0` without * aborting when none is due. Send it only from the app's refund button, never prepended to other * transactions: keepers refund on their own. Every visited record counts toward Sui's * per-transaction object limit. */ declare function refund(config: OrdersGeneratedConfig, args: QueueTarget & { maxOrders: bigint | number; }): (tx: Transaction) => TransactionResult; /** * Refund the listed waiting orders at once (`queue::admin_refund`, reason 7), wherever they sit * in the queue. Takes Predict's `AdminCap`, and works while Predict is frozen. Missing and * finished record IDs are skipped. */ declare function adminRefund(config: OrdersGeneratedConfig, args: QueueTarget & { adminCapId: string; recordIds: readonly bigint[]; }): (tx: Transaction) => TransactionResult; /** * Delete Refunded and Closed records of a settled market (`queue::cleanup`). Permissionless; the * storage rebate goes to the sender. Missing IDs, other statuses and records still holding a * receipt or funds (parked funds included, until `claimParked`) are skipped. Aborts * `EMarketNotSettled` before settlement. */ declare function cleanup(config: OrdersGeneratedConfig, args: QueueTarget & { recordIds: readonly bigint[]; }): (tx: Transaction) => TransactionResult; /** * Run one bounded settlement phase on a market's queue (`queue::settle_step`) and return the * phase the queue is in afterwards (u8, `queue.SETTLE_PHASE`): `0` DRAIN refunds the waiting * orders, `1` PAY pays the Open records once Predict has settled the market, `2` DONE once the * payout walk has reached the last record. Send one call per transaction until it returns `2` (or * `MarketPayoutsCompleted` is emitted), after Predict's `try_settle`. A record the market couldn't * pay stays Open with `OpenRecordPayoutSkipped`, even after DONE. Permissionless. Aborts * `EMarketNotExpired` before expiry. */ declare function settleStep(config: OrdersGeneratedConfig, args: QueueTarget): (tx: Transaction) => TransactionResult; /** * Pay one Open record of a settled market its settled payout (`queue::pay_open`), at any time * after settlement, before or after `settle_step` completes: a record the payout walk skipped * because the market was short of cash or its receive address was denied. Permissionless: the * payout goes only to the record's own receive address. Emits `OpenRecordSettled`, or * `OpenRecordPayoutSkipped` again while the cause persists. A missing or non-Open record is left * alone. Aborts `EMarketNotSettled` before Predict settles the market. */ declare function payOpen(config: OrdersGeneratedConfig, args: QueueTarget & { recordId: bigint; }): (tx: Transaction) => TransactionResult; /** * Send a finished record's parked funds (`queue::claim_parked`): change or a refund its receive * address couldn't take while it was on USDC's deny list or USDC was paused. Permissionless: the * funds go only to the record's own receive address. Returns the amount sent (u64), or `0` and * changes nothing for a missing or unfinished record, one with nothing parked, or an address still * denied. Emits `RecordFundsClaimed`. Takes no market: `expiryMarketId` only derives the queue. */ declare function claimParked(config: OrdersGeneratedConfig, args: QueueTarget & { recordId: bigint; }): (tx: Transaction) => TransactionResult; /** The current Pyth Lazer package and the original ID that types its `Update`. */ interface LazerPackages { /** Lazer's shared `State`. */ stateId: string; /** The package to call `parse_and_verify_le_ecdsa_update` on: `State.upgrade_cap.package`. */ packageId: string; /** The original package ID, which `update::Update` is typed by. */ originalId: string; } /** * Verify one signed Lazer payload with the current Lazer package. A positional call on purpose: * the oracle-construction packages are not generated (see `sui-codegen.config.ts`). */ declare function parseLazerUpdate(lazer: Pick, payload: Uint8Array): (tx: Transaction) => TransactionResult; /** * Verify the signed Lazer payloads and commit them to the market's waiting cohorts * (`queue::commit`). Permissionless. Pass the payloads for a cohort's exact τ, or a backup tick * once τ + gap wait has passed with τ uncommitted (when the policy's price buffer is on). Commit * matches each update to its own cohort by τ and skips one that matches nothing, so no * head-of-line ordering is assumed. Resolve `lazer` per batch with `read.lazerPackages` and never * cache it: a Pyth upgrade retires the old package at once. */ declare function commit(config: OrdersGeneratedConfig, args: QueueTarget & { payloads: readonly Uint8Array[]; lazer: LazerPackages; }): (tx: Transaction) => TransactionResult; /** * Fill or refund committed orders in τ order (`queue::resolve`), visiting at most `maxOrders` * records (the chain caps one call at 450, since a fill emits two events and Sui allows 1,024 * per transaction). Permissionless. Returns how many orders it finished. An order the market * can't cover is refunded with reason 8. Size `maxOrders` against the payout tree * (`payoutTreeNodeCount`): about 10 to 15 fills fit one transaction in a full tree. */ declare function resolve(config: OrdersGeneratedConfig, args: QueueTarget & { maxOrders: bigint | number; }): (tx: Transaction) => TransactionResult; /** * The open filler (no cap exists): {@link commit} the signed Lazer payloads, then * {@link resolve} up to `maxOrders` records. Anyone with Pyth Lazer access can run it. With * `refundOverdue`, a final `refund` call sweeps orders past their deadline. Returns the resolve * result. Split commit from resolve when the payout tree is large. */ declare function fill(config: OrdersGeneratedConfig, args: QueueTarget & { payloads: readonly Uint8Array[]; lazer: LazerPackages; maxOrders: bigint | number; refundOverdue?: boolean; }): (tx: Transaction) => TransactionResult; //#endregion export { LazerPackages, queue_d_exports }; //# sourceMappingURL=queue.d.mts.map