{"version":3,"file":"desk.mjs","names":["delayed_execution_config.DelayedExecutionPolicy"],"sources":["../../../src/contracts/deepbook_predict_orders/desk.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * The order-flow companion's shared `OrderDesk`: the delayed-execution policy\n * every market queue runs under, and the companion's version floor. Also the\n * desk's `QueueRegistry`, the parent every market's queue ID derives from.\n *\n * One desk and one registry per deployment: `init` creates and shares both when\n * the package is published, and nothing else builds one. Each market's\n * `MarketQueue` sits at an ID derived from the registry and the market\n * (`queue::create_and_share`), so a deployment gives each market exactly one\n * queue, and with it one per-account cap, stuck gate, policy, and version floor.\n * The desk exists before Predict allowlists this package's witness; until\n * `protocol_config::set_order_flow` does, Predict's admission, commit, and fill\n * primitives refuse the companion.\n *\n * Predict's `AdminCap` administers the desk. Its setters check the desk floor and\n * refuse while Predict is frozen, through the public `protocol_config::frozen`;\n * the policy cannot move funds, and every Predict invariant holds inside Predict's\n * primitives whatever it says. Every trading call reads the desk, and only those\n * admin setters write it. Queue creation, which anyone may call, writes the\n * registry instead, which no trading call reads, so creation cannot contend with\n * trading.\n */\n\nimport {\n\tMoveStruct,\n\tnormalizeMoveArguments,\n\ttype RawTransactionArgument,\n\ttype ConfigValue,\n} from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport { U64 } from '../../bcs/integers.js';\nimport { type Transaction } from '@mysten/sui/transactions';\nimport * as delayed_execution_config from './delayed_execution_config.js';\nconst $moduleName = '@local-pkg/deepbook_predict_orders::desk';\nexport const OrderDesk = new MoveStruct({\n\tname: `${$moduleName}::OrderDesk`,\n\tfields: {\n\t\tid: bcs.Address,\n\t\tpolicy: delayed_execution_config.DelayedExecutionPolicy,\n\t\t/**\n\t\t * Minimum companion version permitted to run. Monotonic; `bump_version_watermark`\n\t\t * advances it to the running `current_version!()`, retiring older companion code.\n\t\t */\n\t\tversion_watermark: U64,\n\t},\n});\nexport const QueueRegistry = new MoveStruct({\n\tname: `${$moduleName}::QueueRegistry`,\n\tfields: {\n\t\tid: bcs.Address,\n\t\tdesk_id: bcs.Address,\n\t},\n});\nexport interface IdArguments {\n\tdesk?: RawTransactionArgument<string>;\n}\nexport interface IdOptions {\n\tpackage?: string;\n\targuments?: IdArguments;\n\tconfig?: {\n\t\torderDesk: ConfigValue;\n\t\tpredictOrdersPackageId?: string;\n\t};\n}\n/** Return the desk object ID for external discovery and PTB construction. */\nexport function id(options: IdOptions) {\n\tconst packageAddress =\n\t\toptions.package ??\n\t\toptions.config?.predictOrdersPackageId ??\n\t\t'@local-pkg/deepbook_predict_orders';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['desk'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'desk',\n\t\t\tfunction: 'id',\n\t\t\targuments: normalizeMoveArguments(\n\t\t\t\t{\n\t\t\t\t\t...options.arguments,\n\t\t\t\t\tdesk: options.arguments?.desk ?? options.config?.orderDesk,\n\t\t\t\t},\n\t\t\t\targumentsTypes,\n\t\t\t\tparameterNames,\n\t\t\t),\n\t\t});\n}\nexport interface PolicyArguments {\n\tdesk?: RawTransactionArgument<string>;\n}\nexport interface PolicyOptions {\n\tpackage?: string;\n\targuments?: PolicyArguments;\n\tconfig?: {\n\t\torderDesk: ConfigValue;\n\t\tpredictOrdersPackageId?: string;\n\t};\n}\n/** Return the policy, for SDK and devInspect reads. */\nexport function policy(options: PolicyOptions) {\n\tconst packageAddress =\n\t\toptions.package ??\n\t\toptions.config?.predictOrdersPackageId ??\n\t\t'@local-pkg/deepbook_predict_orders';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['desk'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'desk',\n\t\t\tfunction: 'policy',\n\t\t\targuments: normalizeMoveArguments(\n\t\t\t\t{\n\t\t\t\t\t...options.arguments,\n\t\t\t\t\tdesk: options.arguments?.desk ?? options.config?.orderDesk,\n\t\t\t\t},\n\t\t\t\targumentsTypes,\n\t\t\t\tparameterNames,\n\t\t\t),\n\t\t});\n}\nexport interface VersionWatermarkArguments {\n\tdesk?: RawTransactionArgument<string>;\n}\nexport interface VersionWatermarkOptions {\n\tpackage?: string;\n\targuments?: VersionWatermarkArguments;\n\tconfig?: {\n\t\torderDesk: ConfigValue;\n\t\tpredictOrdersPackageId?: string;\n\t};\n}\n/** Return the desk's version floor, for SDK and devInspect reads. */\nexport function versionWatermark(options: VersionWatermarkOptions) {\n\tconst packageAddress =\n\t\toptions.package ??\n\t\toptions.config?.predictOrdersPackageId ??\n\t\t'@local-pkg/deepbook_predict_orders';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['desk'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'desk',\n\t\t\tfunction: 'version_watermark',\n\t\t\targuments: normalizeMoveArguments(\n\t\t\t\t{\n\t\t\t\t\t...options.arguments,\n\t\t\t\t\tdesk: options.arguments?.desk ?? options.config?.orderDesk,\n\t\t\t\t},\n\t\t\t\targumentsTypes,\n\t\t\t\tparameterNames,\n\t\t\t),\n\t\t});\n}\nexport interface RegistryIdArguments {\n\tregistry?: RawTransactionArgument<string>;\n}\nexport interface RegistryIdOptions {\n\tpackage?: string;\n\targuments?: RegistryIdArguments;\n\tconfig?: {\n\t\tqueueRegistry: ConfigValue;\n\t\tpredictOrdersPackageId?: string;\n\t};\n}\n/**\n * Return the queue registry's object ID, for discovery and for deriving each\n * market's queue ID (`queue::queue_id`) in PTB construction.\n */\nexport function registryId(options: RegistryIdOptions) {\n\tconst packageAddress =\n\t\toptions.package ??\n\t\toptions.config?.predictOrdersPackageId ??\n\t\t'@local-pkg/deepbook_predict_orders';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['registry'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'desk',\n\t\t\tfunction: 'registry_id',\n\t\t\targuments: normalizeMoveArguments(\n\t\t\t\t{\n\t\t\t\t\t...options.arguments,\n\t\t\t\t\tregistry: options.arguments?.registry ?? options.config?.queueRegistry,\n\t\t\t\t},\n\t\t\t\targumentsTypes,\n\t\t\t\tparameterNames,\n\t\t\t),\n\t\t});\n}\nexport interface SetTimingArguments {\n\tdesk?: RawTransactionArgument<string>;\n\tAdminCap: RawTransactionArgument<string>;\n\tconfig?: RawTransactionArgument<string>;\n\tdelayMs: RawTransactionArgument<number | bigint>;\n\tstallTimeoutMs: RawTransactionArgument<number | bigint>;\n\tstuckThresholdMs: RawTransactionArgument<number | bigint>;\n\tgapWaitMs: RawTransactionArgument<number | bigint>;\n\tpythPriceBufferMs: RawTransactionArgument<number | bigint>;\n\tpythChannel: RawTransactionArgument<number>;\n\tsviMaxAgeMs: RawTransactionArgument<number | bigint>;\n}\nexport interface SetTimingOptions {\n\tpackage?: string;\n\targuments: SetTimingArguments;\n\tconfig?: {\n\t\torderDesk: ConfigValue;\n\t\tprotocolConfig: ConfigValue;\n\t\tpredictOrdersPackageId?: string;\n\t};\n}\n/**\n * Set every timing field and the Pyth channel in one call, so the relational rules\n * hold on the final state (`delayed_execution_config::set_timing`). Waiting orders\n * keep the τ, deadline, and channel they were placed with, so a new delay, stall\n * timeout, or channel reaches only new orders. Commit reads the buffer and gap\n * wait when it runs, so those also apply to waiting cohorts.\n */\nexport function setTiming(options: SetTimingOptions) {\n\tconst packageAddress =\n\t\toptions.package ??\n\t\toptions.config?.predictOrdersPackageId ??\n\t\t'@local-pkg/deepbook_predict_orders';\n\tconst argumentsTypes = [\n\t\tnull,\n\t\tnull,\n\t\tnull,\n\t\t'u64',\n\t\t'u64',\n\t\t'u64',\n\t\t'u64',\n\t\t'u64',\n\t\t'u8',\n\t\t'u64',\n\t\t'0x2::clock::Clock',\n\t] satisfies (string | null)[];\n\tconst parameterNames = [\n\t\t'desk',\n\t\t'AdminCap',\n\t\t'config',\n\t\t'delayMs',\n\t\t'stallTimeoutMs',\n\t\t'stuckThresholdMs',\n\t\t'gapWaitMs',\n\t\t'pythPriceBufferMs',\n\t\t'pythChannel',\n\t\t'sviMaxAgeMs',\n\t];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'desk',\n\t\t\tfunction: 'set_timing',\n\t\t\targuments: normalizeMoveArguments(\n\t\t\t\t{\n\t\t\t\t\t...options.arguments,\n\t\t\t\t\tdesk: options.arguments?.desk ?? options.config?.orderDesk,\n\t\t\t\t\tconfig: options.arguments?.config ?? options.config?.protocolConfig,\n\t\t\t\t},\n\t\t\t\targumentsTypes,\n\t\t\t\tparameterNames,\n\t\t\t),\n\t\t});\n}\nexport interface SetLimitsArguments {\n\tdesk?: RawTransactionArgument<string>;\n\tAdminCap: RawTransactionArgument<string>;\n\tconfig?: RawTransactionArgument<string>;\n\tmintCapacity: RawTransactionArgument<number | bigint>;\n\tsellCapacity: RawTransactionArgument<number | bigint>;\n\tperAccountCap: RawTransactionArgument<number | bigint>;\n\tminSellQuantity: RawTransactionArgument<number | bigint>;\n\tsettleRefundBatch: RawTransactionArgument<number | bigint>;\n\tsettlePayoutBatch: RawTransactionArgument<number | bigint>;\n}\nexport interface SetLimitsOptions {\n\tpackage?: string;\n\targuments: SetLimitsArguments;\n\tconfig?: {\n\t\torderDesk: ConfigValue;\n\t\tprotocolConfig: ConfigValue;\n\t\tpredictOrdersPackageId?: string;\n\t};\n}\n/**\n * Set the queue capacities, the per-account cap, the minimum early sell, and the\n * two `settle_step` batch sizes. Lowering a capacity below the current pending\n * count only blocks new orders.\n */\nexport function setLimits(options: SetLimitsOptions) {\n\tconst packageAddress =\n\t\toptions.package ??\n\t\toptions.config?.predictOrdersPackageId ??\n\t\t'@local-pkg/deepbook_predict_orders';\n\tconst argumentsTypes = [\n\t\tnull,\n\t\tnull,\n\t\tnull,\n\t\t'u64',\n\t\t'u64',\n\t\t'u64',\n\t\t'u64',\n\t\t'u64',\n\t\t'u64',\n\t\t'0x2::clock::Clock',\n\t] satisfies (string | null)[];\n\tconst parameterNames = [\n\t\t'desk',\n\t\t'AdminCap',\n\t\t'config',\n\t\t'mintCapacity',\n\t\t'sellCapacity',\n\t\t'perAccountCap',\n\t\t'minSellQuantity',\n\t\t'settleRefundBatch',\n\t\t'settlePayoutBatch',\n\t];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'desk',\n\t\t\tfunction: 'set_limits',\n\t\t\targuments: normalizeMoveArguments(\n\t\t\t\t{\n\t\t\t\t\t...options.arguments,\n\t\t\t\t\tdesk: options.arguments?.desk ?? options.config?.orderDesk,\n\t\t\t\t\tconfig: options.arguments?.config ?? options.config?.protocolConfig,\n\t\t\t\t},\n\t\t\t\targumentsTypes,\n\t\t\t\tparameterNames,\n\t\t\t),\n\t\t});\n}\nexport interface SetOrderFeeArguments {\n\tdesk?: RawTransactionArgument<string>;\n\tAdminCap: RawTransactionArgument<string>;\n\tconfig?: RawTransactionArgument<string>;\n\torderFee: RawTransactionArgument<number | bigint>;\n}\nexport interface SetOrderFeeOptions {\n\tpackage?: string;\n\targuments: SetOrderFeeArguments;\n\tconfig?: {\n\t\torderDesk: ConfigValue;\n\t\tprotocolConfig: ConfigValue;\n\t\tpredictOrdersPackageId?: string;\n\t};\n}\n/**\n * Set the flat fee charged per queued order, in USDC base units. Applies to orders\n * placed after the call; waiting orders keep the fee they paid.\n */\nexport function setOrderFee(options: SetOrderFeeOptions) {\n\tconst packageAddress =\n\t\toptions.package ??\n\t\toptions.config?.predictOrdersPackageId ??\n\t\t'@local-pkg/deepbook_predict_orders';\n\tconst argumentsTypes = [null, null, null, 'u64', '0x2::clock::Clock'] satisfies (string | null)[];\n\tconst parameterNames = ['desk', 'AdminCap', 'config', 'orderFee'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'desk',\n\t\t\tfunction: 'set_order_fee',\n\t\t\targuments: normalizeMoveArguments(\n\t\t\t\t{\n\t\t\t\t\t...options.arguments,\n\t\t\t\t\tdesk: options.arguments?.desk ?? options.config?.orderDesk,\n\t\t\t\t\tconfig: options.arguments?.config ?? options.config?.protocolConfig,\n\t\t\t\t},\n\t\t\t\targumentsTypes,\n\t\t\t\tparameterNames,\n\t\t\t),\n\t\t});\n}\nexport interface BumpVersionWatermarkArguments {\n\tdesk?: RawTransactionArgument<string>;\n\tAdminCap: RawTransactionArgument<string>;\n}\nexport interface BumpVersionWatermarkOptions {\n\tpackage?: string;\n\targuments: BumpVersionWatermarkArguments;\n\tconfig?: {\n\t\torderDesk: ConfigValue;\n\t\tpredictOrdersPackageId?: string;\n\t};\n}\n/**\n * Advance the desk floor to this package's compiled `current_version!()`, retiring\n * older companion code. Aborts unless the executing version is above the floor.\n */\nexport function bumpVersionWatermark(options: BumpVersionWatermarkOptions) {\n\tconst packageAddress =\n\t\toptions.package ??\n\t\toptions.config?.predictOrdersPackageId ??\n\t\t'@local-pkg/deepbook_predict_orders';\n\tconst argumentsTypes = [null, null] satisfies (string | null)[];\n\tconst parameterNames = ['desk', 'AdminCap'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'desk',\n\t\t\tfunction: 'bump_version_watermark',\n\t\t\targuments: normalizeMoveArguments(\n\t\t\t\t{\n\t\t\t\t\t...options.arguments,\n\t\t\t\t\tdesk: options.arguments?.desk ?? options.config?.orderDesk,\n\t\t\t\t},\n\t\t\t\targumentsTypes,\n\t\t\t\tparameterNames,\n\t\t\t),\n\t\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,cAAc;AACpB,MAAa,YAA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