{"version":3,"file":"queue.mjs","names":["queue.enqueueExactQuantity","queue.enqueueExactAmount","queue.enqueueExactCost","queue.enqueueRedeemOpen","policy","desk.policy","delayedExecutionConfig.orderFee","plp.rebalanceExpiryCash","queue.createAndShare","queue.refund","queue.adminRefund","queue.cleanup","queue.settleStep","queue.payOpen","queue.claimParked","queue.commit","queue.resolve"],"sources":["../../../src/predict/tx/queue.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n// Delayed execution (DBU-885): composable thunks for queued orders. Each is\n// `(config, args) => (tx) => result`, like `tx/trade.ts`, so an app can put several into one\n// PTB. The `PredictClient.tx.enqueue*` facade adds the chain preflight on top.\n//\n// Every queued-order entry point lives in the order-flow companion, `deepbook_predict_orders`\n// (`queue::*`), and runs against one market's `MarketQueue` plus the companion's shared\n// `OrderDesk`. The queue's ID is derived from the companion's `QueueRegistry` and the market, so\n// each thunk takes it as an optional `queueId` and derives it otherwise. The thunks take\n// `OrdersGeneratedConfig` (`toOrdersConfig(cfg)`), which supplies the companion package, the desk,\n// the registry and Predict's shared objects.\n//\n// Every call that can send USDC (`resolve`, `refund`, `admin_refund`, `settle_step`, `pay_open`,\n// `claim_parked`) also reads Sui's shared `DenyList` (0x403), which the generated bindings inject\n// as a read-only shared input. Nothing sends USDC to an address on USDC's deny list, or while USDC\n// is globally paused: a fill for such a receive address is refused (reason 9), a refund or change\n// is parked in its record (`RecordFundsParked`), and a payout is skipped until `pay_open`.\n//\n// Queued orders read the oracle objects directly for their volatility snapshot, so unlike the\n// retired immediate trades there is no `load_live_pricer` command before them.\nimport type { Transaction, TransactionResult } from '@mysten/sui/transactions';\nimport type { GeneratedConfig, OrdersGeneratedConfig } from '../config/generated.js';\nimport { MIN_PREMIUM } from '../cost.js';\nimport { PredictInputError } from '../errors.js';\nimport { deriveQueueId } from '../queue-id.js';\nimport { U64_MAX } from '../units.js';\nimport * as plp from '../../contracts/deepbook_predict/plp.js';\nimport * as delayedExecutionConfig from '../../contracts/deepbook_predict_orders/delayed_execution_config.js';\nimport * as desk from '../../contracts/deepbook_predict_orders/desk.js';\nimport * as queue from '../../contracts/deepbook_predict_orders/queue.js';\nimport { withAuth } from './common.js';\nimport type { MarketFeeds } from './trade.js';\n\nconst FLOAT_SCALING = 1_000_000_000n;\n\n// The queued placements with their `auth` argument already supplied: auth → enqueue.\nconst authed = {\n\tenqueueExactQuantity: withAuth(queue.enqueueExactQuantity),\n\tenqueueExactAmount: withAuth(queue.enqueueExactAmount),\n\tenqueueExactCost: withAuth(queue.enqueueExactCost),\n\tenqueueRedeemOpen: withAuth(queue.enqueueRedeemOpen),\n};\n\n/** One market's queue. */\nexport interface QueueTarget {\n\texpiryMarketId: string;\n\t/**\n\t * The market's `MarketQueue`. Defaults to `deriveQueueId(config.queueRegistry, expiryMarketId)`,\n\t * the ID `queue::create_and_share` gives it, so pass it only to address another registry's\n\t * queue.\n\t */\n\tqueueId?: string;\n}\n\n/** The queue ID a thunk addresses: the given one, or the one derived from the config's registry. */\nexport function queueIdOf(\n\tconfig: Pick<OrdersGeneratedConfig, 'queueRegistry'>,\n\targs: QueueTarget,\n): string {\n\treturn args.queueId ?? deriveQueueId(config.queueRegistry, args.expiryMarketId);\n}\n\n/** The market, queue and account every queued order names. */\ninterface QueuedOrderTarget extends MarketFeeds, QueueTarget {\n\twrapperId: string;\n}\n\n// The leading arguments every placement shares, after `queue` and `market`.\nfunction placement(config: OrdersGeneratedConfig, args: QueuedOrderTarget) {\n\treturn {\n\t\tqueue: queueIdOf(config, args),\n\t\tmarket: args.expiryMarketId,\n\t\twrapper: args.wrapperId,\n\t\tpyth: args.pythFeed,\n\t\tbsValues: args.blockScholesValueStore,\n\t\tbsSvi: args.blockScholesSviStore,\n\t};\n}\n\n// The chain refuses a zero or \"unlimited\" cap (`EMintCostCapRequired`), so a queued mint always\n// carries a real one. Checked here so a bad cap never reaches a PTB.\nfunction assertMaxCost(maxCostRaw: bigint): void {\n\tif (typeof maxCostRaw !== 'bigint' || maxCostRaw <= 0n || maxCostRaw >= U64_MAX) {\n\t\tthrow new PredictInputError(\n\t\t\t`maxCostRaw must be above 0 and below u64::MAX (a queued mint requires a real cap), got ${String(maxCostRaw)}`,\n\t\t);\n\t}\n}\n\nfunction assertU64(value: bigint, name: string): void {\n\tif (typeof value !== 'bigint' || value < 0n || value > U64_MAX) {\n\t\tthrow new PredictInputError(`${name} must be a u64 bigint, got ${String(value)}`);\n\t}\n}\n\n/**\n * Queue a mint of an exact payout quantity, priced at Pyth's signed price for its τ\n * (`queue::enqueue_exact_quantity`). Returns the record ID (u64). `maxCostRaw` (all-in cap) and\n * `maxProbabilityRaw` (entry-probability cap, at most 1e9) are required: there is no \"unlimited\"\n * default on the queued path. Escrows `min(max_cost, quantity, available − fee)` plus the order\n * fee. Command order is auth → enqueue.\n */\nexport function enqueueExactQuantity(\n\tconfig: OrdersGeneratedConfig,\n\targs: QueuedOrderTarget & {\n\t\tlowerTick: bigint;\n\t\thigherTick: bigint;\n\t\tquantityRaw: bigint;\n\t\tmaxCostRaw: bigint;\n\t\tmaxProbabilityRaw: bigint;\n\t},\n): (tx: Transaction) => TransactionResult {\n\tassertMaxCost(args.maxCostRaw);\n\tassertU64(args.quantityRaw, 'quantityRaw');\n\tif (\n\t\ttypeof args.maxProbabilityRaw !== 'bigint' ||\n\t\targs.maxProbabilityRaw <= 0n ||\n\t\targs.maxProbabilityRaw > FLOAT_SCALING\n\t) {\n\t\tthrow new PredictInputError(\n\t\t\t`maxProbabilityRaw must be in (0, 1e9], got ${String(args.maxProbabilityRaw)}`,\n\t\t);\n\t}\n\treturn authed.enqueueExactQuantity({\n\t\tconfig,\n\t\targuments: {\n\t\t\t...placement(config, args),\n\t\t\tlowerTick: args.lowerTick,\n\t\t\thigherTick: args.higherTick,\n\t\t\tquantity: args.quantityRaw,\n\t\t\tmaxCost: args.maxCostRaw,\n\t\t\tmaxProbability: args.maxProbabilityRaw,\n\t\t},\n\t});\n}\n\n/**\n * Queue a premium-budget mint (`queue::enqueue_exact_amount`): sized at τ under\n * `maxPremiumRaw`, at least `minQuantityRaw`, with the all-in withdrawal capped by the required\n * `maxCostRaw`. Escrows `min(max_cost, available − fee)` plus the order fee. Returns the record\n * ID. Command order is auth → enqueue. `maxPremiumRaw` below the minimum premium (1 USDC) is\n * refused: the fill could never buy enough premium, so Predict's admission dry run would abort\n * `EOrderFailsLimits`.\n */\nexport function enqueueExactAmount(\n\tconfig: OrdersGeneratedConfig,\n\targs: QueuedOrderTarget & {\n\t\tlowerTick: bigint;\n\t\thigherTick: bigint;\n\t\tmaxPremiumRaw: bigint;\n\t\tminQuantityRaw: bigint;\n\t\tmaxCostRaw: bigint;\n\t},\n): (tx: Transaction) => TransactionResult {\n\tassertMaxCost(args.maxCostRaw);\n\tassertU64(args.maxPremiumRaw, 'maxPremiumRaw');\n\tassertU64(args.minQuantityRaw, 'minQuantityRaw');\n\tif (args.maxPremiumRaw < MIN_PREMIUM) {\n\t\tthrow new PredictInputError(\n\t\t\t`maxPremiumRaw ${args.maxPremiumRaw} is below the ${MIN_PREMIUM} minimum premium (EOrderFailsLimits)`,\n\t\t);\n\t}\n\treturn authed.enqueueExactAmount({\n\t\tconfig,\n\t\targuments: {\n\t\t\t...placement(config, args),\n\t\t\tlowerTick: args.lowerTick,\n\t\t\thigherTick: args.higherTick,\n\t\t\tmaxPremium: args.maxPremiumRaw,\n\t\t\tminQuantity: args.minQuantityRaw,\n\t\t\tmaxCost: args.maxCostRaw,\n\t\t},\n\t});\n}\n\n/**\n * Queue an all-in-budget mint (`queue::enqueue_exact_cost`): sized at τ so the all-in cost fits\n * `maxCostRaw`, at least `minQuantityRaw`. `maxCostRaw` is the budget and must be a real cap.\n * Escrows `min(max_cost, available − fee)` plus the order fee. Returns the record ID. Command\n * order is auth → enqueue.\n */\nexport function enqueueExactCost(\n\tconfig: OrdersGeneratedConfig,\n\targs: QueuedOrderTarget & {\n\t\tlowerTick: bigint;\n\t\thigherTick: bigint;\n\t\tmaxCostRaw: bigint;\n\t\tminQuantityRaw: bigint;\n\t},\n): (tx: Transaction) => TransactionResult {\n\tassertMaxCost(args.maxCostRaw);\n\tassertU64(args.minQuantityRaw, 'minQuantityRaw');\n\treturn authed.enqueueExactCost({\n\t\tconfig,\n\t\targuments: {\n\t\t\t...placement(config, args),\n\t\t\tlowerTick: args.lowerTick,\n\t\t\thigherTick: args.higherTick,\n\t\t\tmaxCost: args.maxCostRaw,\n\t\t\tminQuantity: args.minQuantityRaw,\n\t\t},\n\t});\n}\n\n/**\n * Queue an early sell of `closeQuantityRaw` from the Open record `recordId`\n * (`queue::enqueue_redeem_open`; the queue record ID, not the position's u256 order ID). The\n * only early sell: a position held in the account can't be sold early. The record must be Open\n * and belong to this account. `minProbabilityRaw` and `minProceedsRaw` are the close-side floors\n * at τ and are required (`0n` disables either, so pass it on purpose). Escrows only the order\n * fee. Returns the new record ID, which holds the position until the sell fills or refunds.\n * Command order is auth → enqueue.\n */\nexport function enqueueRedeemOpen(\n\tconfig: OrdersGeneratedConfig,\n\targs: QueuedOrderTarget & {\n\t\trecordId: bigint;\n\t\tcloseQuantityRaw: bigint;\n\t\tminProbabilityRaw: bigint;\n\t\tminProceedsRaw: bigint;\n\t},\n): (tx: Transaction) => TransactionResult {\n\tassertU64(args.recordId, 'recordId');\n\tassertU64(args.minProbabilityRaw, 'minProbabilityRaw');\n\tassertU64(args.minProceedsRaw, 'minProceedsRaw');\n\tif (typeof args.closeQuantityRaw !== 'bigint' || args.closeQuantityRaw <= 0n) {\n\t\tthrow new PredictInputError(\n\t\t\t`closeQuantityRaw must be above 0, got ${String(args.closeQuantityRaw)}`,\n\t\t);\n\t}\n\treturn authed.enqueueRedeemOpen({\n\t\tconfig,\n\t\targuments: {\n\t\t\t...placement(config, args),\n\t\t\trecordId: args.recordId,\n\t\t\tcloseQuantity: args.closeQuantityRaw,\n\t\t\tminProbability: args.minProbabilityRaw,\n\t\t\tminProceeds: args.minProceedsRaw,\n\t\t},\n\t});\n}\n\n/**\n * Abort the transaction unless the order desk's fee is at most `maxOrderFeeRaw` when it executes.\n * The enqueues charge the desk's fee at execution and take no fee bound, so add this BEFORE an\n * enqueue to hold it to the fee its preview showed. It reads the desk's policy, and\n * `0x1::u64::checked_sub(max, fee)` is none once the fee is above the bound, so\n * `0x1::option::destroy_some` aborts (`option::EOPTION_NOT_SET`, code 0x40001) before the\n * enqueue debits anything. Read-only on the desk.\n */\nexport function assertOrderFeeAtMost(\n\tconfig: OrdersGeneratedConfig,\n\tmaxOrderFeeRaw: bigint,\n): (tx: Transaction) => void {\n\tassertU64(maxOrderFeeRaw, 'maxOrderFeeRaw');\n\treturn (tx) => {\n\t\tconst policy = tx.add(desk.policy({ config }));\n\t\tconst fee = tx.add(delayedExecutionConfig.orderFee({ config, arguments: { policy } }));\n\t\tconst headroom = tx.moveCall({\n\t\t\ttarget: '0x1::u64::checked_sub',\n\t\t\targuments: [tx.pure.u64(maxOrderFeeRaw), fee],\n\t\t});\n\t\ttx.moveCall({\n\t\t\ttarget: '0x1::option::destroy_some',\n\t\t\ttypeArguments: ['u64'],\n\t\t\targuments: [headroom],\n\t\t});\n\t};\n}\n\n/**\n * Fund a live market from the pool vault to `max(required × (1 + rebalance %), initial cash,\n * required + waiting_cash_need)` (Predict's `plp::rebalance_expiry_cash`). Permissionless, and\n * takes no target. Add it AFTER a big sell's enqueue in the same PTB: the enqueue has already\n * added the sell's cash need to Predict's waiting total, so the rebalance funds it at once. It\n * takes the hot `PoolVault`, so add it only when a sell's cash need is above spare cash.\n */\nexport function rebalanceExpiryCash(\n\tconfig: GeneratedConfig,\n\targs: { expiryMarketId: string },\n): (tx: Transaction) => TransactionResult {\n\treturn plp.rebalanceExpiryCash({ config, arguments: { market: args.expiryMarketId } });\n}\n\n/**\n * Create and share a market's `MarketQueue` (`queue::create_and_share(registry, desk, market)`),\n * at the ID `deriveQueueId(config.queueRegistry, expiryMarketId)`. Takes the registry mutably and\n * the desk read-only, so it never contends with trading. Permissionless and once per market (a\n * second call aborts, since the ID is taken); the caller pays its storage. The market-creation\n * keeper sends it after each new `ExpiryMarket`. Returns the queue ID.\n */\nexport function createQueue(\n\tconfig: OrdersGeneratedConfig,\n\targs: { expiryMarketId: string },\n): (tx: Transaction) => TransactionResult {\n\treturn queue.createAndShare({ config, arguments: { market: args.expiryMarketId } });\n}\n\n/**\n * Refund this market's waiting orders at or past their deadline (`queue::refund`, reason 5),\n * visiting at most `maxOrders` records (the chain caps one call at 450). Permissionless: no auth,\n * session or Pyth key, and it works during a freeze. Returns how many it refunded, `0` without\n * aborting when none is due. Send it only from the app's refund button, never prepended to other\n * transactions: keepers refund on their own. Every visited record counts toward Sui's\n * per-transaction object limit.\n */\nexport function refund(\n\tconfig: OrdersGeneratedConfig,\n\targs: QueueTarget & { maxOrders: bigint | number },\n): (tx: Transaction) => TransactionResult {\n\treturn queue.refund({\n\t\tconfig,\n\t\targuments: {\n\t\t\tqueue: queueIdOf(config, args),\n\t\t\tmarket: args.expiryMarketId,\n\t\t\tmaxOrders: args.maxOrders,\n\t\t},\n\t});\n}\n\n/**\n * Refund the listed waiting orders at once (`queue::admin_refund`, reason 7), wherever they sit\n * in the queue. Takes Predict's `AdminCap`, and works while Predict is frozen. Missing and\n * finished record IDs are skipped.\n */\nexport function adminRefund(\n\tconfig: OrdersGeneratedConfig,\n\targs: QueueTarget & { adminCapId: string; recordIds: readonly bigint[] },\n): (tx: Transaction) => TransactionResult {\n\treturn queue.adminRefund({\n\t\tconfig,\n\t\targuments: {\n\t\t\tqueue: queueIdOf(config, args),\n\t\t\tmarket: args.expiryMarketId,\n\t\t\tAdminCap: args.adminCapId,\n\t\t\trecordIds: [...args.recordIds],\n\t\t},\n\t});\n}\n\n/**\n * Delete Refunded and Closed records of a settled market (`queue::cleanup`). Permissionless; the\n * storage rebate goes to the sender. Missing IDs, other statuses and records still holding a\n * receipt or funds (parked funds included, until `claimParked`) are skipped. Aborts\n * `EMarketNotSettled` before settlement.\n */\nexport function cleanup(\n\tconfig: OrdersGeneratedConfig,\n\targs: QueueTarget & { recordIds: readonly bigint[] },\n): (tx: Transaction) => TransactionResult {\n\treturn queue.cleanup({\n\t\tconfig,\n\t\targuments: {\n\t\t\tqueue: queueIdOf(config, args),\n\t\t\tmarket: args.expiryMarketId,\n\t\t\trecordIds: [...args.recordIds],\n\t\t},\n\t});\n}\n\n/**\n * Run one bounded settlement phase on a market's queue (`queue::settle_step`) and return the\n * phase the queue is in afterwards (u8, `queue.SETTLE_PHASE`): `0` DRAIN refunds the waiting\n * orders, `1` PAY pays the Open records once Predict has settled the market, `2` DONE once the\n * payout walk has reached the last record. Send one call per transaction until it returns `2` (or\n * `MarketPayoutsCompleted` is emitted), after Predict's `try_settle`. A record the market couldn't\n * pay stays Open with `OpenRecordPayoutSkipped`, even after DONE. Permissionless. Aborts\n * `EMarketNotExpired` before expiry.\n */\nexport function settleStep(\n\tconfig: OrdersGeneratedConfig,\n\targs: QueueTarget,\n): (tx: Transaction) => TransactionResult {\n\treturn queue.settleStep({\n\t\tconfig,\n\t\targuments: { queue: queueIdOf(config, args), market: args.expiryMarketId },\n\t});\n}\n\n/**\n * Pay one Open record of a settled market its settled payout (`queue::pay_open`), at any time\n * after settlement, before or after `settle_step` completes: a record the payout walk skipped\n * because the market was short of cash or its receive address was denied. Permissionless: the\n * payout goes only to the record's own receive address. Emits `OpenRecordSettled`, or\n * `OpenRecordPayoutSkipped` again while the cause persists. A missing or non-Open record is left\n * alone. Aborts `EMarketNotSettled` before Predict settles the market.\n */\nexport function payOpen(\n\tconfig: OrdersGeneratedConfig,\n\targs: QueueTarget & { recordId: bigint },\n): (tx: Transaction) => TransactionResult {\n\tassertU64(args.recordId, 'recordId');\n\treturn queue.payOpen({\n\t\tconfig,\n\t\targuments: {\n\t\t\tqueue: queueIdOf(config, args),\n\t\t\tmarket: args.expiryMarketId,\n\t\t\trecordId: args.recordId,\n\t\t},\n\t});\n}\n\n/**\n * Send a finished record's parked funds (`queue::claim_parked`): change or a refund its receive\n * address couldn't take while it was on USDC's deny list or USDC was paused. Permissionless: the\n * funds go only to the record's own receive address. Returns the amount sent (u64), or `0` and\n * changes nothing for a missing or unfinished record, one with nothing parked, or an address still\n * denied. Emits `RecordFundsClaimed`. Takes no market: `expiryMarketId` only derives the queue.\n */\nexport function claimParked(\n\tconfig: OrdersGeneratedConfig,\n\targs: QueueTarget & { recordId: bigint },\n): (tx: Transaction) => TransactionResult {\n\tassertU64(args.recordId, 'recordId');\n\treturn queue.claimParked({\n\t\tconfig,\n\t\targuments: { queue: queueIdOf(config, args), recordId: args.recordId },\n\t});\n}\n\n/** The current Pyth Lazer package and the original ID that types its `Update`. */\nexport interface LazerPackages {\n\t/** Lazer's shared `State`. */\n\tstateId: string;\n\t/** The package to call `parse_and_verify_le_ecdsa_update` on: `State.upgrade_cap.package`. */\n\tpackageId: string;\n\t/** The original package ID, which `update::Update` is typed by. */\n\toriginalId: string;\n}\n\n/**\n * Verify one signed Lazer payload with the current Lazer package. A positional call on purpose:\n * the oracle-construction packages are not generated (see `sui-codegen.config.ts`).\n */\nexport function parseLazerUpdate(\n\tlazer: Pick<LazerPackages, 'stateId' | 'packageId'>,\n\tpayload: Uint8Array,\n): (tx: Transaction) => TransactionResult {\n\treturn (tx) =>\n\t\ttx.moveCall({\n\t\t\ttarget: `${lazer.packageId}::pyth_lazer::parse_and_verify_le_ecdsa_update`,\n\t\t\targuments: [tx.object(lazer.stateId), tx.object.clock(), tx.pure.vector('u8', payload)],\n\t\t});\n}\n\n/**\n * Verify the signed Lazer payloads and commit them to the market's waiting cohorts\n * (`queue::commit`). Permissionless. Pass the payloads for a cohort's exact τ, or a backup tick\n * once τ + gap wait has passed with τ uncommitted (when the policy's price buffer is on). Commit\n * matches each update to its own cohort by τ and skips one that matches nothing, so no\n * head-of-line ordering is assumed. Resolve `lazer` per batch with `read.lazerPackages` and never\n * cache it: a Pyth upgrade retires the old package at once.\n */\nexport function commit(\n\tconfig: OrdersGeneratedConfig,\n\targs: QueueTarget & { payloads: readonly Uint8Array[]; lazer: LazerPackages },\n): (tx: Transaction) => TransactionResult {\n\tif (args.payloads.length === 0) {\n\t\tthrow new PredictInputError('commit needs at least one signed Lazer payload');\n\t}\n\treturn (tx) => {\n\t\tconst updates = args.payloads.map((payload) => tx.add(parseLazerUpdate(args.lazer, payload)));\n\t\tconst vector = tx.makeMoveVec({\n\t\t\ttype: `${args.lazer.originalId}::update::Update`,\n\t\t\telements: updates,\n\t\t});\n\t\treturn tx.add(\n\t\t\tqueue.commit({\n\t\t\t\tconfig,\n\t\t\t\targuments: { queue: queueIdOf(config, args), market: args.expiryMarketId, updates: vector },\n\t\t\t}),\n\t\t);\n\t};\n}\n\n/**\n * Fill or refund committed orders in τ order (`queue::resolve`), visiting at most `maxOrders`\n * records (the chain caps one call at 450, since a fill emits two events and Sui allows 1,024\n * per transaction). Permissionless. Returns how many orders it finished. An order the market\n * can't cover is refunded with reason 8. Size `maxOrders` against the payout tree\n * (`payoutTreeNodeCount`): about 10 to 15 fills fit one transaction in a full tree.\n */\nexport function resolve(\n\tconfig: OrdersGeneratedConfig,\n\targs: QueueTarget & { maxOrders: bigint | number },\n): (tx: Transaction) => TransactionResult {\n\treturn queue.resolve({\n\t\tconfig,\n\t\targuments: {\n\t\t\tqueue: queueIdOf(config, args),\n\t\t\tmarket: args.expiryMarketId,\n\t\t\tmaxOrders: args.maxOrders,\n\t\t},\n\t});\n}\n\n/**\n * The open filler (no cap exists): {@link commit} the signed Lazer payloads, then\n * {@link resolve} up to `maxOrders` records. Anyone with Pyth Lazer access can run it. With\n * `refundOverdue`, a final `refund` call sweeps orders past their deadline. Returns the resolve\n * result. Split commit from resolve when the payout tree is large.\n */\nexport function fill(\n\tconfig: OrdersGeneratedConfig,\n\targs: QueueTarget & {\n\t\tpayloads: readonly Uint8Array[];\n\t\tlazer: LazerPackages;\n\t\tmaxOrders: bigint | number;\n\t\trefundOverdue?: boolean;\n\t},\n): (tx: Transaction) => TransactionResult {\n\tif (args.payloads.length === 0) {\n\t\tthrow new PredictInputError('fill needs at least one signed Lazer payload');\n\t}\n\tconst target = { expiryMarketId: args.expiryMarketId, queueId: queueIdOf(config, args) };\n\treturn (tx) => {\n\t\ttx.add(commit(config, { ...target, payloads: args.payloads, lazer: args.lazer }));\n\t\tconst resolved = tx.add(resolve(config, { ...target, maxOrders: args.maxOrders }));\n\t\tif (args.refundOverdue) {\n\t\t\ttx.add(refund(config, { ...target, maxOrders: args.maxOrders }));\n\t\t}\n\t\treturn resolved;\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,gBAAgB;AAGtB,MAAM,SAAS;CACd,sBAAsB,SAASA,uBAA2B;CAC1D,oBAAoB,SAASC,qBAAyB;CACtD,kBAAkB,SAASC,mBAAuB;CAClD,mBAAmB,SAASC,oBAAwB;CACpD;;AAcD,SAAgB,UACf,QACA,MACS;AACT,QAAO,KAAK,WAAW,cAAc,OAAO,eAAe,KAAK,eAAe;;AAShF,SAAS,UAAU,QAA+B,MAAyB;AAC1E,QAAO;EACN,OAAO,UAAU,QAAQ,KAAK;EAC9B,QAAQ,KAAK;EACb,SAAS,KAAK;EACd,MAAM,KAAK;EACX,UAAU,KAAK;EACf,OAAO,KAAK;EACZ;;AAKF,SAAS,cAAc,YAA0B;AAChD,KAAI,OAAO,eAAe,YAAY,cAAc,MAAM,cAAc,QACvE,OAAM,IAAI,kBACT,0FAA0F,OAAO,WAAW,GAC5G;;AAIH,SAAS,UAAU,OAAe,MAAoB;AACrD,KAAI,OAAO,UAAU,YAAY,QAAQ,MAAM,QAAQ,QACtD,OAAM,IAAI,kBAAkB,GAAG,KAAK,6BAA6B,OAAO,MAAM,GAAG;;;;;;;;;AAWnF,SAAgB,qBACf,QACA,MAOyC;AACzC,eAAc,KAAK,WAAW;AAC9B,WAAU,KAAK,aAAa,cAAc;AAC1C,KACC,OAAO,KAAK,sBAAsB,YAClC,KAAK,qBAAqB,MAC1B,KAAK,oBAAoB,cAEzB,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