/************************************************************** * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED * **************************************************************/ /** * Registry and creation entrypoints for the Predict protocol. * * This module creates shared setup objects, owns registry-level capabilities, and * exposes registry-owned governance/creation entrypoints. Market identity, cadence * policy, underlying watermarks, and market uniqueness live in the embedded * `market_manager`. Runtime pool accounting, expiry risk, oracle feeds, and user * positions stay in their owning modules. */ import { MoveStruct, MoveTuple, normalizeMoveArguments, type RawTransactionArgument, type ConfigValue, } from '../utils/index.js'; import { bcs } from '@mysten/sui/bcs'; import { type Transaction } from '@mysten/sui/transactions'; import * as market_manager from './market_manager.js'; import * as vec_set from './deps/sui/vec_set.js'; const $moduleName = '@local-pkg/deepbook_predict::registry'; export const Registry = new MoveStruct({ name: `${$moduleName}::Registry`, fields: { id: bcs.Address, /** * Market identity, cadence deployment terms, underlying watermarks, and * uniqueness. */ market_manager: market_manager.MarketManager, /** * IDs of `PauseCap` objects currently authorized to use pause-only entries. Admin * mints into this set and revokes from it. */ allowed_pause_caps: vec_set.VecSet(bcs.Address), /** * IDs of `MarketLifecycleCap` objects currently authorized to create expiry * markets. Admin mints into this set and revokes from it. */ allowed_lifecycle_caps: vec_set.VecSet(bcs.Address), /** * IDs of `PoolValuationCap` objects currently authorized to start the full-pool * valuation. Admin mints into this set and revokes from it. */ allowed_pool_valuation_caps: vec_set.VecSet(bcs.Address), }, }); export const CadencePeriodsKey = new MoveTuple({ name: `${$moduleName}::CadencePeriodsKey`, fields: [bcs.bool()], }); export interface IdArguments { registry?: RawTransactionArgument; } export interface IdOptions { package?: string; arguments?: IdArguments; config?: { registry: ConfigValue; predictPackageId?: string; }; } /** Return the registry object ID for external discovery and PTB construction. */ export function id(options: IdOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['registry']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'id', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, }, argumentsTypes, parameterNames, ), }); } export interface ExpiryMarketIdArguments { registry?: RawTransactionArgument; propbookUnderlyingId: RawTransactionArgument; expiry: RawTransactionArgument; } export interface ExpiryMarketIdOptions { package?: string; arguments: ExpiryMarketIdArguments; config?: { registry: ConfigValue; predictPackageId?: string; }; } /** Resolve an expiry market ID for external discovery and PTB construction. */ export function expiryMarketId(options: ExpiryMarketIdOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, 'u32', 'u64'] satisfies (string | null)[]; const parameterNames = ['registry', 'propbookUnderlyingId', 'expiry']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'expiry_market_id', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, }, argumentsTypes, parameterNames, ), }); } export interface CadenceConfigArguments { registry?: RawTransactionArgument; propbookUnderlyingId: RawTransactionArgument; cadenceId: RawTransactionArgument; } export interface CadenceConfigOptions { package?: string; arguments: CadenceConfigArguments; config?: { registry: ConfigValue; predictPackageId?: string; }; } /** Return deployment policy for SDK and devInspect market discovery. */ export function cadenceConfig(options: CadenceConfigOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, 'u32', 'u8'] satisfies (string | null)[]; const parameterNames = ['registry', 'propbookUnderlyingId', 'cadenceId']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'cadence_config', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, }, argumentsTypes, parameterNames, ), }); } export interface CadenceConfigsArguments { registry?: RawTransactionArgument; propbookUnderlyingId: RawTransactionArgument; } export interface CadenceConfigsOptions { package?: string; arguments: CadenceConfigsArguments; config?: { registry: ConfigValue; predictPackageId?: string; }; } /** * Return one underlying's complete deployment policy as a single coherent * snapshot, for off-chain consumers (SDK and devInspect cadence discovery by the * keeper, price updater, and dashboard) that would otherwise need one read per * cadence. The vector holds one entry per cadence in `cadence_periods`, indexed by * cadence ID; disabled cadences are present as their all-zero configuration. * Aborts if the underlying is not registered. */ export function cadenceConfigs(options: CadenceConfigsOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, 'u32'] satisfies (string | null)[]; const parameterNames = ['registry', 'propbookUnderlyingId']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'cadence_configs', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, }, argumentsTypes, parameterNames, ), }); } export interface CadencePeriodsArguments { registry?: RawTransactionArgument; } export interface CadencePeriodsOptions { package?: string; arguments?: CadencePeriodsArguments; config?: { registry: ConfigValue; predictPackageId?: string; }; } /** * Return every cadence's period in milliseconds, indexed by cadence ID, for * devInspect cadence discovery by the keeper, price collector, and dashboard. The * table starts with the six built-in cadences and grows through `add_cadence`; * read it in the same transaction as `cadence_configs` for a consistent pair. */ export function cadencePeriods(options: CadencePeriodsOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null] satisfies (string | null)[]; const parameterNames = ['registry']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'cadence_periods', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, }, argumentsTypes, parameterNames, ), }); } export interface MintPauseCapArguments { registry?: RawTransactionArgument; AdminCap: RawTransactionArgument; } export interface MintPauseCapOptions { package?: string; arguments: MintPauseCapArguments; config?: { registry: ConfigValue; predictPackageId?: string; }; } /** * Mint a new `PauseCap`. This bypasses the version gate so emergency pause * authority remains available from a package version below the runtime floor. */ export function mintPauseCap(options: MintPauseCapOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['registry', 'AdminCap']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'mint_pause_cap', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, }, argumentsTypes, parameterNames, ), }); } export interface RevokePauseCapArguments { registry?: RawTransactionArgument; AdminCap: RawTransactionArgument; pauseCapId: RawTransactionArgument; } export interface RevokePauseCapOptions { package?: string; arguments: RevokePauseCapArguments; config?: { registry: ConfigValue; predictPackageId?: string; }; } /** Revoke a previously minted `PauseCap` by ID. Admin-only. */ export function revokePauseCap(options: RevokePauseCapOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, null, '0x2::object::ID'] satisfies (string | null)[]; const parameterNames = ['registry', 'AdminCap', 'pauseCapId']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'revoke_pause_cap', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, }, argumentsTypes, parameterNames, ), }); } export interface MintLifecycleCapArguments { registry?: RawTransactionArgument; config?: RawTransactionArgument; AdminCap: RawTransactionArgument; } export interface MintLifecycleCapOptions { package?: string; arguments: MintLifecycleCapArguments; config?: { registry: ConfigValue; protocolConfig: ConfigValue; predictPackageId?: string; }; } /** Mint a version-gated `MarketLifecycleCap` with market-creation authority. */ export function mintLifecycleCap(options: MintLifecycleCapOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, null, null] satisfies (string | null)[]; const parameterNames = ['registry', 'config', 'AdminCap']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'mint_lifecycle_cap', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, config: options.arguments?.config ?? options.config?.protocolConfig, }, argumentsTypes, parameterNames, ), }); } export interface RevokeLifecycleCapArguments { registry?: RawTransactionArgument; AdminCap: RawTransactionArgument; lifecycleCapId: RawTransactionArgument; } export interface RevokeLifecycleCapOptions { package?: string; arguments: RevokeLifecycleCapArguments; config?: { registry: ConfigValue; predictPackageId?: string; }; } /** Revoke a `MarketLifecycleCap` by ID without applying the version gate. */ export function revokeLifecycleCap(options: RevokeLifecycleCapOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, null, '0x2::object::ID'] satisfies (string | null)[]; const parameterNames = ['registry', 'AdminCap', 'lifecycleCapId']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'revoke_lifecycle_cap', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, }, argumentsTypes, parameterNames, ), }); } export interface MintPoolValuationCapArguments { registry?: RawTransactionArgument; AdminCap: RawTransactionArgument; config?: RawTransactionArgument; } export interface MintPoolValuationCapOptions { package?: string; arguments: MintPoolValuationCapArguments; config?: { registry: ConfigValue; protocolConfig: ConfigValue; predictPackageId?: string; }; } /** * Mint a version-gated `PoolValuationCap` with authority to start the full-pool * valuation. */ export function mintPoolValuationCap(options: MintPoolValuationCapOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, null, null] satisfies (string | null)[]; const parameterNames = ['registry', 'AdminCap', 'config']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'mint_pool_valuation_cap', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, config: options.arguments?.config ?? options.config?.protocolConfig, }, argumentsTypes, parameterNames, ), }); } export interface RevokePoolValuationCapArguments { registry?: RawTransactionArgument; AdminCap: RawTransactionArgument; poolValuationCapId: RawTransactionArgument; } export interface RevokePoolValuationCapOptions { package?: string; arguments: RevokePoolValuationCapArguments; config?: { registry: ConfigValue; predictPackageId?: string; }; } /** Revoke a `PoolValuationCap` by ID without applying the version gate. */ export function revokePoolValuationCap(options: RevokePoolValuationCapOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, null, '0x2::object::ID'] satisfies (string | null)[]; const parameterNames = ['registry', 'AdminCap', 'poolValuationCapId']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'revoke_pool_valuation_cap', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, }, argumentsTypes, parameterNames, ), }); } export interface GeneratePoolValuationProofArguments { registry?: RawTransactionArgument; poolValuationCap: RawTransactionArgument; } export interface GeneratePoolValuationProofOptions { package?: string; arguments: GeneratePoolValuationProofArguments; config?: { registry: ConfigValue; predictPackageId?: string; }; } /** * Generate a transaction-local proof that `pool_valuation_cap` is currently * allowlisted. `plp::start_pool_valuation` takes the proof by value so a revoked * cap cannot start a valuation. */ export function generatePoolValuationProof(options: GeneratePoolValuationProofOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, null] satisfies (string | null)[]; const parameterNames = ['registry', 'poolValuationCap']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'generate_pool_valuation_proof', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, }, argumentsTypes, parameterNames, ), }); } export interface PauseTradingPauseCapArguments { config?: RawTransactionArgument; registry?: RawTransactionArgument; pauseCap: RawTransactionArgument; } export interface PauseTradingPauseCapOptions { package?: string; arguments: PauseTradingPauseCapArguments; config?: { protocolConfig: ConfigValue; registry: ConfigValue; predictPackageId?: string; }; } /** Force `trading_paused = true` via a valid `PauseCap`. One-way. */ export function pauseTradingPauseCap(options: PauseTradingPauseCapOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, null, null] satisfies (string | null)[]; const parameterNames = ['config', 'registry', 'pauseCap']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'pause_trading_pause_cap', arguments: normalizeMoveArguments( { ...options.arguments, config: options.arguments?.config ?? options.config?.protocolConfig, registry: options.arguments?.registry ?? options.config?.registry, }, argumentsTypes, parameterNames, ), }); } export interface FreezeProtocolPauseCapArguments { config?: RawTransactionArgument; registry?: RawTransactionArgument; pauseCap: RawTransactionArgument; } export interface FreezeProtocolPauseCapOptions { package?: string; arguments: FreezeProtocolPauseCapArguments; config?: { protocolConfig: ConfigValue; registry: ConfigValue; predictPackageId?: string; }; } /** * Force the protocol-wide emergency freeze via a valid `PauseCap`. One-way; * admin's `protocol_config::set_frozen` is needed to lift the freeze. */ export function freezeProtocolPauseCap(options: FreezeProtocolPauseCapOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, null, null] satisfies (string | null)[]; const parameterNames = ['config', 'registry', 'pauseCap']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'freeze_protocol_pause_cap', arguments: normalizeMoveArguments( { ...options.arguments, config: options.arguments?.config ?? options.config?.protocolConfig, registry: options.arguments?.registry ?? options.config?.registry, }, argumentsTypes, parameterNames, ), }); } export interface PauseExpiryMarketMintPauseCapArguments { market: RawTransactionArgument; registry?: RawTransactionArgument; pauseCap: RawTransactionArgument; } export interface PauseExpiryMarketMintPauseCapOptions { package?: string; arguments: PauseExpiryMarketMintPauseCapArguments; config?: { registry: ConfigValue; predictPackageId?: string; }; } /** * Force `mint_paused = true` on a single expiry market via a valid `PauseCap`. * One-way; admin's `expiry_market::set_mint_paused` is needed to unpause. */ export function pauseExpiryMarketMintPauseCap(options: PauseExpiryMarketMintPauseCapOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, null, null] satisfies (string | null)[]; const parameterNames = ['market', 'registry', 'pauseCap']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'pause_expiry_market_mint_pause_cap', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, }, argumentsTypes, parameterNames, ), }); } export interface RegisterUnderlyingArguments { registry?: RawTransactionArgument; config?: RawTransactionArgument; AdminCap: RawTransactionArgument; propbookUnderlyingId: RawTransactionArgument; } export interface RegisterUnderlyingOptions { package?: string; arguments: RegisterUnderlyingArguments; config?: { registry: ConfigValue; protocolConfig: ConfigValue; predictPackageId?: string; }; } /** * Record admin approval of one Propbook underlying. Source IDs and canonical * oracle object IDs remain owned by Propbook; this row only gates which * underlyings Predict will build markets on and stores deployment watermarks. */ export function registerUnderlying(options: RegisterUnderlyingOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, null, null, 'u32'] satisfies (string | null)[]; const parameterNames = ['registry', 'config', 'AdminCap', 'propbookUnderlyingId']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'register_underlying', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, config: options.arguments?.config ?? options.config?.protocolConfig, }, argumentsTypes, parameterNames, ), }); } export interface AddCadenceArguments { registry?: RawTransactionArgument; config?: RawTransactionArgument; AdminCap: RawTransactionArgument; periodMs: RawTransactionArgument; } export interface AddCadenceOptions { package?: string; arguments: AddCadenceArguments; config?: { registry: ConfigValue; protocolConfig: ConfigValue; predictPackageId?: string; }; } /** * Append a cadence with period `period_ms` to the cadence table and return its ID. * The period is a whole number of minutes, at most one year, and not already in * the table, which holds at most 16 cadences. A new cadence is disabled on every * underlying until `set_template_cadence_config` sets its terms; periods never * change, so retire a cadence by disabling it. */ export function addCadence(options: AddCadenceOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, null, null, 'u64'] satisfies (string | null)[]; const parameterNames = ['registry', 'config', 'AdminCap', 'periodMs']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'add_cadence', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, config: options.arguments?.config ?? options.config?.protocolConfig, }, argumentsTypes, parameterNames, ), }); } export interface SetTemplateCadenceConfigArguments { registry?: RawTransactionArgument; config?: RawTransactionArgument; AdminCap: RawTransactionArgument; propbookUnderlyingId: RawTransactionArgument; cadenceId: RawTransactionArgument; tickSize: RawTransactionArgument; admissionTickSize: RawTransactionArgument; maxExpiryAllocation: RawTransactionArgument; initialExpiryCash: RawTransactionArgument; windowSize: RawTransactionArgument; } export interface SetTemplateCadenceConfigOptions { package?: string; arguments: SetTemplateCadenceConfigArguments; config?: { registry: ConfigValue; protocolConfig: ConfigValue; predictPackageId?: string; }; } /** * Set all deployment terms for one underlying's cadence. Passing zero for all five * values disables the cadence; otherwise all values must be nonzero and valid. * Aborts if the underlying's enabled windows would sum past the pool's live-market * cap. */ export function setTemplateCadenceConfig(options: SetTemplateCadenceConfigOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [ null, null, null, 'u32', 'u8', 'u64', 'u64', 'u64', 'u64', 'u64', ] satisfies (string | null)[]; const parameterNames = [ 'registry', 'config', 'AdminCap', 'propbookUnderlyingId', 'cadenceId', 'tickSize', 'admissionTickSize', 'maxExpiryAllocation', 'initialExpiryCash', 'windowSize', ]; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'set_template_cadence_config', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, config: options.arguments?.config ?? options.config?.protocolConfig, }, argumentsTypes, parameterNames, ), }); } export interface CreateAndShareExpiryMarketArguments { registry?: RawTransactionArgument; poolVault?: RawTransactionArgument; config?: RawTransactionArgument; propbookRegistry?: RawTransactionArgument; lifecycleCap: RawTransactionArgument; propbookUnderlyingId: RawTransactionArgument; cadenceId: RawTransactionArgument; } export interface CreateAndShareExpiryMarketOptions { package?: string; arguments: CreateAndShareExpiryMarketArguments; config?: { registry: ConfigValue; poolVault: ConfigValue; protocolConfig: ConfigValue; oracleRegistry: ConfigValue; predictPackageId?: string; }; } /** * Create the next deployable `ExpiryMarket` for one cadence on a Propbook * underlying. * * Requires an allowlisted lifecycle capability, a registered underlying with all * canonical feed objects bound, and an enabled cadence with a deployable slot. * Slots owned by a longer enabled cadence and existing markets are skipped. The * market snapshots cadence and expiry policy, starts with zero cash, and cannot * mint until pool rebalancing funds it. Live pricing reads current Propbook * bindings. */ export function createAndShareExpiryMarket(options: CreateAndShareExpiryMarketOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [ null, null, null, null, null, 'u32', 'u8', '0x2::clock::Clock', ] satisfies (string | null)[]; const parameterNames = [ 'registry', 'poolVault', 'config', 'propbookRegistry', 'lifecycleCap', 'propbookUnderlyingId', 'cadenceId', ]; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'create_and_share_expiry_market', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, poolVault: options.arguments?.poolVault ?? options.config?.poolVault, config: options.arguments?.config ?? options.config?.protocolConfig, propbookRegistry: options.arguments?.propbookRegistry ?? options.config?.oracleRegistry, }, argumentsTypes, parameterNames, ), }); } export interface CreateAndShareExpiryMarketAtArguments { registry?: RawTransactionArgument; poolVault?: RawTransactionArgument; config?: RawTransactionArgument; propbookRegistry?: RawTransactionArgument; lifecycleCap: RawTransactionArgument; propbookUnderlyingId: RawTransactionArgument; cadenceId: RawTransactionArgument; expectedExpiry: RawTransactionArgument; } export interface CreateAndShareExpiryMarketAtOptions { package?: string; arguments: CreateAndShareExpiryMarketAtArguments; config?: { registry: ConfigValue; poolVault: ConfigValue; protocolConfig: ConfigValue; oracleRegistry: ConfigValue; predictPackageId?: string; }; } /** * `create_and_share_expiry_market`, aborting unless the deployable expiry is * `expected_expiry`. A keeper that planned the expiry off chain uses this so that * a stale view of the cadence table fails instead of creating an unplanned market. */ export function createAndShareExpiryMarketAt(options: CreateAndShareExpiryMarketAtOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [ null, null, null, null, null, 'u32', 'u8', 'u64', '0x2::clock::Clock', ] satisfies (string | null)[]; const parameterNames = [ 'registry', 'poolVault', 'config', 'propbookRegistry', 'lifecycleCap', 'propbookUnderlyingId', 'cadenceId', 'expectedExpiry', ]; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'create_and_share_expiry_market_at', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, poolVault: options.arguments?.poolVault ?? options.config?.poolVault, config: options.arguments?.config ?? options.config?.protocolConfig, propbookRegistry: options.arguments?.propbookRegistry ?? options.config?.oracleRegistry, }, argumentsTypes, parameterNames, ), }); } export interface CreateAndShareExpiryMarketWithBandArguments { registry?: RawTransactionArgument; poolVault?: RawTransactionArgument; config?: RawTransactionArgument; propbookRegistry?: RawTransactionArgument; lifecycleCap: RawTransactionArgument; propbookUnderlyingId: RawTransactionArgument; cadenceId: RawTransactionArgument; expectedExpiry: RawTransactionArgument; minEntryProbability: RawTransactionArgument; maxEntryProbability: RawTransactionArgument; } export interface CreateAndShareExpiryMarketWithBandOptions { package?: string; arguments: CreateAndShareExpiryMarketWithBandArguments; config?: { registry: ConfigValue; poolVault: ConfigValue; protocolConfig: ConfigValue; oracleRegistry: ConfigValue; predictPackageId?: string; }; } /** * `create_and_share_expiry_market` with the new market's mint entry band narrowed * to `[min_entry_probability, max_entry_probability]`, aborting unless the * deployable expiry is `expected_expiry` when that is set. The other two creation * entrypoints call this with `[0, u64::MAX]`, which keeps the template's band. * * The band can only tighten: each side keeps the tighter of the requested value * and the template's, so a bound looser than the template leaves that side at the * template's, and the call aborts when the two bands do not overlap. Like every * snapshotted term, the band is fixed for the market's life, and `MarketCreated` * reports it. A keeper uses this to admit fewer mints in markets open across a * chosen window. */ export function createAndShareExpiryMarketWithBand( options: CreateAndShareExpiryMarketWithBandOptions, ) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [ null, null, null, null, null, 'u32', 'u8', '0x1::option::Option', 'u64', 'u64', '0x2::clock::Clock', ] satisfies (string | null)[]; const parameterNames = [ 'registry', 'poolVault', 'config', 'propbookRegistry', 'lifecycleCap', 'propbookUnderlyingId', 'cadenceId', 'expectedExpiry', 'minEntryProbability', 'maxEntryProbability', ]; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'create_and_share_expiry_market_with_band', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, poolVault: options.arguments?.poolVault ?? options.config?.poolVault, config: options.arguments?.config ?? options.config?.protocolConfig, propbookRegistry: options.arguments?.propbookRegistry ?? options.config?.oracleRegistry, }, argumentsTypes, parameterNames, ), }); } export interface CreateAndShareBuilderCodeArguments { registry?: RawTransactionArgument; config?: RawTransactionArgument; index: RawTransactionArgument; } export interface CreateAndShareBuilderCodeOptions { package?: string; arguments: CreateAndShareBuilderCodeArguments; config?: { registry: ConfigValue; protocolConfig: ConfigValue; predictPackageId?: string; }; } /** Create a derived shared BuilderCode for the caller and index. */ export function createAndShareBuilderCode(options: CreateAndShareBuilderCodeOptions) { const packageAddress = options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict'; const argumentsTypes = [null, null, 'u64'] satisfies (string | null)[]; const parameterNames = ['registry', 'config', 'index']; return (tx: Transaction) => tx.moveCall({ package: packageAddress, module: 'registry', function: 'create_and_share_builder_code', arguments: normalizeMoveArguments( { ...options.arguments, registry: options.arguments?.registry ?? options.config?.registry, config: options.arguments?.config ?? options.config?.protocolConfig, }, argumentsTypes, parameterNames, ), }); }