Skip to main content

Registry

deepbook_predict::registry::Registry is the shared object that holds the market catalog and the cadence configuration for every registered underlying. It also holds the allowlists that decide which PauseCap, which MarketLifecycleCap, and which PoolValuationCap still carry authority.

Publishing the Predict package creates Registry and ProtocolConfig together and transfers the single AdminCap to the publisher at that moment. ProtocolConfig is the registry's sibling shared object and holds the pause and freeze flags and the fee and timing settings that Protocol configuration covers. The registry object ID for each deployment is on Contract Information, and getConfig(network).objects.registry in the SDK resolves the same ID. The Move snippets on this page pin DeepBookV3 at 046ffd1e, the protocol version 5 source that both networks run.

Most application integrations call only the read functions here. The rest are operator and governance surfaces. None of them is an entry fun: every function on this page is a public fun invoked as a moveCall. The capability-minting functions and generate_pool_valuation_proof return values that a later command in the same transaction must consume, because Sui lets a transaction leave a return value unused only when its type has drop. The creation functions each return an ID, which has drop, so a transaction can leave it unused.

Registry state​

The registry holds the market catalog inline rather than in a separate object:

The market_manager field is a deepbook_predict::market_manager::MarketManager, a store value embedded in the registry. It carries 2 tables: the per-underlying cadence configuration, and the map from an underlying and expiry to a market ID. MarketManager is not a separate shared object, so there is no second ID to pass. The 3 VecSet<ID> fields are the capability allowlists.

How do I look up a market?​

Each market is its own shared ExpiryMarket object, addressed by the underlying and the expiry:

expiry_market_id returns Option<ID>, which is empty when no market exists for that pair, including when the underlying is not registered at all. The expiry is a Unix millisecond timestamp on the cadence grid, so compute the exact expiry before looking a market up, or list the active markets with client.predict.read.markets() in the SDK, which reads them over simulated transactions with no server in the path.

The table key behind that lookup, market_manager::MarketKey, has no accessors and no exported constructor. Treat it as internal, and address markets through expiry_market_id or through read.markets().

What are the cadence IDs and terms?​

A cadence is one market schedule for one underlying. Cadence IDs index the registry's cadence table and never change. The table starts with 6 built-in cadences:

Cadence IDNamePeriod
01m1 minute
15m5 minutes
21h1 hour
31d1 day
41w1 week
51mo30 days

An admin appends more with add_cadence, up to 16 in all, so each network's table also holds a 15-minute cadence at ID 6, registered disabled. A cadence ID outside the table aborts with EInvalidCadence. Read the periods, indexed by cadence ID, with cadence_periods, and one cadence's terms or all of them with cadence_config and cadence_configs:

cadence_periods returns each cadence's period in milliseconds, and cadence_configs returns one entry for each of those cadences, in ID order, so index 3 is always the 1d cadence. Read both in the same transaction for a consistent pair. A disabled cadence comes back with every term set to zero, and registering a new underlying starts it with every cadence disabled. Both reads abort with EUnderlyingNotRegistered when the underlying has no row.

Both reads return CadenceConfig by value, and it carries the 5 terms a market snapshots at creation:

Read the terms with the accessors rather than by field:

cadence_enabled reads no stored flag: a cadence counts as enabled exactly when its window size is greater than zero. Both deployments register one underlying, BTC. Each network's registry enables its own cadences. Both enable the 1m and 5m cadences, each with the same terms on both networks, and leave the 15m cadence disabled:

CadenceEnabledtick_sizeadmission_tick_sizemax_expiry_allocationinitial_expiry_cashwindow_size
0 1mYes10000000 (0.01 USD)1000000000 (1 USD)500000000 (500 USDC)500000000 (500 USDC)2
1 5mYes10000000 (0.01 USD)1000000000 (1 USD)1000000000 (1,000 USDC)1000000000 (1,000 USDC)2
2 1h, 3 1d, 4 1w, 5 1mo, 6 15mNo00000

A window size of 2 means the registry can hold 2 open markets per enabled cadence at once, so each network's 2 enabled cadences hold 4 in total. When 2 enabled cadences could create the same expiry, the one with the longer period owns it and the shorter one skips it, even before the owner has created it: if the 15m cadence were enabled alongside 1m and 5m, quarter hours would go to 15m, other 5-minute marks to 5m, and every other minute to 1m. These are mutable protocol state: CadenceConfigUpdated fired once per cadence at deployment on each network, and a later update changes the grid for markets created afterward. Read them onchain before sizing a strike. The same table with the underlying and oracle IDs is on Contract Information.

Which capability gates each function?​

Privileged functions sit behind 4 capability types, and each one is a distinct owned object:

CapabilityTypeGates
AdminCapdeepbook_predict::admin::AdminCapProtocol configuration, underlying and cadence configuration, per-market mint pause and unpause, and the minting and revocation of the other 3 capabilities
PauseCapdeepbook_predict::pause_cap::PauseCapThe 3 one-way emergency stops
MarketLifecycleCapdeepbook_predict::market_lifecycle_cap::MarketLifecycleCapMarket creation
PoolValuationCapdeepbook_predict::pool_valuation_cap::PoolValuationCapStarting a pool flush, through generate_pool_valuation_proof

The MarketLifecycleCap and PoolValuationCap structs are the objects an admin mints and the registry allowlists by ID:

Publication mints AdminCap once, and it has no rotation or revocation path. An admin mints the other 3 on demand and revokes them by ID, so their authority is a row in the registry rather than possession of the object alone. Each has an id accessor and a destroy function the holder can call on a capability it no longer needs. Market creation and flush authority are deliberately separate objects, so an operator can hold one without the other.

Several functions on this page are version-gated: they abort with EPackageVersionDisabled when the running package version is below the configured version watermark, which bump_version_watermark advances, and with EProtocolFrozen while the protocol is frozen. Minting a pause capability is not version-gated; minting a lifecycle or pool valuation capability is, while revoking any of the 3 is not.

Mint and revoke a pause capability​

Pause capabilities are deliberately not version-gated, so an emergency stop still works when the running package version is below the configured watermark:

mint_pause_cap returns the new PauseCap by value, so the transaction must transfer it to a holder in a later command. Revocation removes the ID from allowed_pause_caps, after which every pause path using that object aborts with EPauseCapNotValid, even though the object still exists. A holder can also destroy their own capability with pause_cap::destroy.

Mint and revoke a lifecycle capability​

Minting a lifecycle capability is version-gated, unlike pause capabilities, and revoking one is not:

Revoking an ID that is not in allowed_lifecycle_caps aborts with ELifecycleCapNotFound, and using a revoked capability aborts with ELifecycleCapNotValid. create_and_share_expiry_market checks a lifecycle capability by reference and produces no proof object.

Mint and revoke a pool valuation capability​

Pool valuation capabilities follow the same version-gated mint and ungated revoke pattern. mint_pool_valuation_cap takes _admin_cap before config, the reverse of mint_lifecycle_cap:

Revoking an ID that is not in allowed_pool_valuation_caps aborts with EPoolValuationCapNotFound, and generate_pool_valuation_proof aborts with EPoolValuationCapNotValid for a capability that is not allowlisted.

generate_pool_valuation_proof converts an allowlisted capability into a plp::PoolValuationProof. That proof has no abilities, so no transaction can store, copy, or drop it: the same transaction must consume it, and its only consumer is plp::start_pool_valuation. Checking the allowlist at proof time lets a revoked capability fail before a flush starts. The transaction that starts a flush also has to snapshot every active market and seal the snapshot, while the later valuation and finish stages are permissionless and span as many transactions as they need. See Vault for the full sequence.

How do I pause or freeze the protocol?​

The registry has 3 emergency-stop functions, and each validates the capability ID against the registry allowlist before it acts:

Each takes no boolean, so each is one-way:

  • pause_trading_pause_cap: Sets trading_paused on ProtocolConfig. Flows guarded by the trading check then abort with ETradingPaused.
  • freeze_protocol_pause_cap: Engages the protocol freeze. Version-gated flows then abort with EProtocolFrozen.
  • pause_expiry_market_mint_pause_cap: Pauses minting on one market. Minting on that market aborts with EMintPaused, while redemption and settlement stay open.

Reversal is an AdminCap surface, not a PauseCap one. protocol_config::set_trading_paused, protocol_config::set_frozen, and expiry_market::set_mint_paused each take a boolean and can move the flag in either direction. set_frozen is intentionally not version-gated, so an admin can still unfreeze a frozen protocol. The 2 protocol_config reversal setters:

Both setters take a boolean, so the same call engages or clears its flag on ProtocolConfig.

Underlying and cadence administration​

An admin must register an underlying before any market on it can exist:

Registering the same underlying twice aborts with EUnderlyingAlreadyRegistered. Registration creates the row with every cadence disabled, so a follow-up set_template_cadence_config call per cadence actually turns a schedule on.

add_cadence appends a cadence length to the table and returns its ID. The period must be a whole number of minutes, at most one year, and new to the table, which holds at most 16 cadences: a period that breaks the first 2 rules aborts with EInvalidCadencePeriod, a repeat with ECadencePeriodExists, and a 17th cadence with ECadenceTableFull. A new cadence starts disabled on every underlying until set_template_cadence_config sets its terms. A period never changes, so retire a cadence by disabling it. The call is version-gated and emits CadenceAdded.

set_template_cadence_config validates the whole cadence as a unit. All 5 terms at zero disable the cadence. Otherwise every term must be nonzero, and the call aborts with EInvalidCadenceConfig when the terms mix zero and nonzero values, when the admission tick size is smaller than the tick size or not a whole multiple of it, or when initial_expiry_cash exceeds max_expiry_allocation. An enabled cadence takes any positive initial_expiry_cash up to that cap. Both tick sizes must also pass the market tick bounds in the configuration constants: a tick that is not a positive multiple of 10000 aborts with EInvalidMarketTickSize, and one too large to multiply by the top tick aborts with EMarketTickSizeTooLarge. A window size above the maximum of 10 aborts with EInvalidCadenceWindowSize. Each enabled cadence keeps up to its window size of markets live, so an update that would raise the sum of an underlying's enabled window sizes above the pool's live-market cap of 24 aborts with ECadenceWindowBudgetExceeded. A successful update emits CadenceConfigUpdated.

Changing a cadence does not touch markets that already exist. Each market snapshots its terms at creation, so the grid an open market admits is the grid from its creation.

Market creation​

Market creation is the only lifecycle-capability surface in the registry. create_and_share_expiry_market keeps its signature, and protocol version 5 adds 2 variants of it:

  • create_and_share_expiry_market_at: Takes one more argument, expected_expiry, and aborts with EUnexpectedExpiry unless the market manager selects exactly that expiry. A keeper that plans expiries offchain uses it, so a stale view of the cadence table fails instead of creating an unplanned market.
  • create_and_share_expiry_market_with_band: Takes expected_expiry as an Option<u64>, plus min_entry_probability and max_entry_probability, and narrows the new market's entry band to that range. Each side keeps the tighter of the request and the template, so the band can only narrow, and the call aborts with strike_exposure_config::EInvalidEntryProbabilityBound when the 2 bands do not overlap. The other 2 entrypoints call it with the open band, 0 to u64::MAX, which keeps the template's. Like every snapshotted term, the band is fixed for the market's life, and MarketCreated reports it.

The call passes 3 gates before it does anything: the package version must be at or above the watermark, the lifecycle capability must be on the allowlist, and the trading_paused flag must be false. A pool flush in flight does not block it: creation moves no cash, the new market is not in the flush's frozen expected set, and it joins the next flush's snapshot. It then picks the next deployable expiry inside the cadence's rolling window and aborts when no slot qualifies:

  • ECadenceDisabled: The cadence window size is zero.
  • ECadenceWindowExceeded: Every slot inside the rolling window is already deployed.
  • EMarketAlreadyCreated: A market already exists for that underlying and expiry.
  • EInvalidDeploymentExpiry: The expiry does not align with the cadence grid, or does not pass the last deployed watermark.
  • EPythFeedNotBoundToUnderlying and EBlockScholesStoresNotBoundToUnderlying: The underlying has no canonical oracle bindings in the Propbook registry.

The function takes &OracleRegistry but no feed objects, so market creation reads no live price. The absolute tick domain and the cadence terms, fixed in advance, decide strike admission entirely. The call sets the market's reference tick source timestamp to the expiry minus one cadence period, and expiry_market::set_reference_tick records the reference tick later from the exact Pyth observation at that timestamp.

The new market also copies the fee-band template, as Fee bands describes. The cadence carries 2 values into the new market: admission_tick_size becomes the market's admission grid, and max_expiry_allocation becomes both the vault's allocation cap for that expiry and the scale of the market's inventory-impact curve. The call returns the new market ID and emits MarketCreated.

A new market starts with zero cash and cannot mint until the permissionless plp::rebalance_expiry_cash funds it. The pool also caps live pre-expiry markets at 24 and aborts with EMaxLiveExpiryMarketsExceeded beyond that.

Builder codes​

A builder code is a shared object that an order names to pay a builder fee, which accrues to the code's address for its owner to claim. Builder-code creation is the only permissionless function in the registry that changes state. The reads on this page, expiry_market_id, cadence_periods, cadence_config, and cadence_configs, are permissionless too, but they mutate nothing:

Anyone can call it. The resulting BuilderCode is a shared object derived from the registry UID and keyed by the caller address plus the index you pass, so its address is deterministic and one address can hold many codes. The call returns the code ID and emits BuilderCodeCreated.

An order names a code through the _with_builder queued entrypoints, as Name a builder fee describes. predict_account::set_builder_code and predict_account::unset_builder_code still attach and detach a code on an account, but starting with protocol version 5, no fee reads the attachment. Builder fees accrue to the code address through the funds accumulator, and only the owner can call builder_code::claim_all_builder_fees, which returns a Coin<USDC>. Builder codes covers the fee, the cap, and the events, and Predict Accounts SDK creates a code and claims its fees from TypeScript.

Protocol configuration​

ProtocolConfig is the registry's sibling shared object. Its AdminCap setters cover fees, the builder fee cap, pricing freshness, the strike-exposure template, the fee-band template, the exponentially weighted moving average (EWMA) penalty, the liquidity provider (LP) request policy, and 2 timing windows that other pages depend on:

SetterFieldBoundsDeployedBlocked during a flushAbort
set_no_trade_window_msno_trade_window_ms0 to 15000 ms, where 0 disables the window15000 on both networks, the maximum, over a compiled default of 2000Noconfig_constants::EInvalidNoTradeWindowMs (24)
set_max_valuation_window_msmax_valuation_window_ms1 minute to 4 hours300000Yes, with EValuationInProgressconfig_constants::EInvalidMaxValuationWindowMs (23)

no_trade_window_ms is the interval before each expiry in which no queued order's price instant might fall. Predict covers it. A flush deliberately does not block it, matching set_trading_paused, so a stalled flush cannot trap a safety control. A change emits NoTradeWindowUpdated. max_valuation_window_ms is the deadline after which an in-flight flush can no longer finish and the operator must restart it, as Vault explains. The setter aborts while a flush is in flight, so no one can move a started flush's deadline under it.

They come with 2 permissionless reads: valuation_in_progress(config): bool reports whether a flush is in flight, and no_trade_window_ms(config): u64 returns the live window. The 2 deployments' values differ in places, and the full set for each is on Contract Information.

Protocol version 4 controls​

Protocol version 4 adds 4 admin controls to ProtocolConfig, each taking &AdminCap and each stored as a dynamic field so the published struct layout is unchanged:

FunctionEffectVersion-gatedEvent
set_order_flow<W>(config, admin_cap, enabled)Allowlists or removes the order-flow witness type W that the queued-order primitives accept. Enabling the deepbook_predict_orders witness, order_flow::OrderFlow, opens queued trading once the watermark reaches 4. is_order_flow<W> reads it.Enabling only, so a removal works while frozenOrderFlowUpdated
add_flush_operator, remove_flush_operatorEdits the allowlist of addresses that might call plp::finish_flush. is_flush_operator reads it.Adding only, so a removal works while frozenFlushOperatorUpdated
add_settled_redeem_keeper, remove_settled_redeem_keeperThrough protocol version 4, edited the allowlist of senders that might call expiry_market::redeem_settled_permissionless. From protocol version 5 both always abort with ESettledRedeemRetired and change nothing.Not applicableNone from protocol version 5
set_fee_incentive_subsidy_rate, set_fee_incentive_live_target_rate, set_template_fee_incentive_lifetime_cap_rateSet the 3 fee-incentive rates described on Vault.YesFeeIncentiveSubsidyRateUpdated for the subsidy rate, FeeIncentiveAllocationRatesUpdated for the other 2

Protocol version 5 adds 2 more, each version-gated and each stored as a dynamic field:

FunctionEffectEvent
set_builder_fee_cap(config, admin_cap, cap, clock)Sets builder_fee_cap, the most a builder fee charges per contract, from 0 to 1000000000, the whole 1 USDC payout, aborting with config_constants::EInvalidBuilderFeeCap outside that range. It defaults to 50000000, 5 cents, until set. Admission reads it, so a change reaches the next order, and a pool flush does not block it. builder_fee_cap reads it.BuilderFeeCapUpdated
set_template_fee_bands(config, admin_cap, bands, clock)Replaces the fee-band template with bands, flat [low, high, multiplier] triples in 1e9 scaling, aborting with config_constants::EInvalidFeeBands unless it holds at most 8 sorted, non-overlapping bands with low < high <= 1000000000 and a multiplier from 1000000000 to 10000000000. An empty vector clears it. Each market copies the template at creation, so a change reaches only later markets, and no public function returns a market's copy.FeeBandsUpdated with the full table

Protocol version 4 also retires the EWMA congestion penalty: set_ewma_params and set_ewma_enabled keep their signatures and abort with EEwmaRetired. The order-flow package's own policy lives on its OrderDesk, not on ProtocolConfig; see The order-desk policy.

Errors​

Abort codes restart at 0 in each module, so match a code together with the module that raised it. For example, code 0 is EPauseCapNotValid in registry, EUnderlyingNotRegistered in market_manager, and ETradingPaused in protocol_config. The tables in this section group the codes by module.

deepbook_predict::registry raises 5 capability errors and one creation error:

CodeNameRaised when
0EPauseCapNotValidThe pause capability ID is not in allowed_pause_caps
1ELifecycleCapNotValidThe lifecycle capability ID is not in allowed_lifecycle_caps
2ELifecycleCapNotFoundRevoking a lifecycle capability ID that the allowlist never held
3EPoolValuationCapNotValidgenerate_pool_valuation_proof with a capability ID that is not in allowed_pool_valuation_caps
4EPoolValuationCapNotFoundRevoking a pool valuation capability ID that the allowlist never held
5EUnexpectedExpirycreate_and_share_expiry_market_at or create_and_share_expiry_market_with_band named an expected expiry other than the one the market manager selects

deepbook_predict::market_manager raises the catalog and cadence errors:

CodeNameRaised when
0EUnderlyingNotRegisteredNo row exists for the underlying
1EUnderlyingAlreadyRegisteredregister_underlying called twice for one underlying
2ECadenceDisabledDeploying on a cadence whose window size is zero
3EMarketAlreadyCreatedA market already exists for that underlying and expiry
4EInvalidCadenceCadence ID outside the cadence table
5ECadenceWindowExceededNo deployable slot inside the rolling window
6EInvalidDeploymentExpiryExpiry not grid-aligned, or not past the watermark
7EInvalidCadenceConfigMixed zero and nonzero terms, admission tick smaller than or not a multiple of the tick, or initial expiry cash above the allocation cap
8EPythFeedNotBoundToUnderlyingNo canonical Pyth binding for the underlying
9EBlockScholesStoresNotBoundToUnderlyingNo Block Scholes store pair for the underlying
10ECadenceTableFulladd_cadence on a table that already holds 16 cadences
11EInvalidCadencePeriodadd_cadence with a period that is not a whole number of minutes, or longer than one year
12ECadencePeriodExistsadd_cadence with a period already in the table
13ECadenceWindowBudgetExceededset_template_cadence_config would raise the underlying's enabled window sizes above the pool's live-market cap of 24

deepbook_predict::protocol_config raises 16 gate errors on protocol version 5. The registry's own functions reach only the first and the 2 version gates. The rest surface through the trade and flush calls that read the same object:

CodeNameRaised when
0ETradingPausedA trading-gated flow ran while trading_paused
1EValuationInProgressA flow the flush mark reads, such as an LP cancel, a sponsorship, or a mark-affecting setter, ran while a flush was in flight
2EValuationNotInProgressA flush stage ran with no flush in flight
3EPackageVersionDisabledThe running package version is below the watermark
4EVersionWatermarkNotAdvancedbump_version_watermark did not strictly increase the watermark
5EProtocolFrozenA version-gated flow ran while frozen
6ESnapshotInProgressA trade or a second start_pool_valuation landed inside a flush's snapshot transaction
7ETradeWindowClosedRaised only by the retired immediate trades, inside the no-trade window. No live path raises it
10EFlushOperatorAlreadyAddedadd_flush_operator named an address already on the list
11EFlushOperatorNotFoundremove_flush_operator named an address not on the list
12ENotFlushOperatorfinish_flush from a sender off the flush-operator allowlist
13ECutoverNotReachedA queued order arrived before the watermark reached 4
14EEwmaRetiredA retired EWMA setter ran
15EOrderFlowNotAllowedAn order-flow call came from a witness that is not allowlisted
16EBuilderFeeCutoverNotReachedAn order named a builder before the watermark reached 5
17ESettledRedeemRetiredadd_settled_redeem_keeper or remove_settled_redeem_keeper ran. They always abort

Codes 8 and 9 were the settled-redeem keeper allowlist errors through protocol version 4, and protocol version 5 no longer declares them.

Setter bounds failures come from deepbook_predict::config_constants, codes 0 through 24, on protocol version 4 also EInvalidFeeIncentiveSubsidyRate (25), EInvalidFeeIncentiveLiveTargetRate (26), and EInvalidFeeIncentiveLifetimeCapRate (27), and on protocol version 5 also EInvalidBuilderFeeCap (28) and EInvalidFeeBands (29), including EMarketTickSizeTooLarge (16), EInvalidCadenceWindowSize (15), EInvalidMaxValuationWindowMs (23), and EInvalidNoTradeWindowMs (24).

Events​

Registry activity surfaces through deepbook_predict::config_events:

MarketCreated carries the snapshot a market took at creation, including its own entry band, so an indexer can build the market catalog from events alone. It does not carry the market's copy of the fee bands, which is the table of the last FeeBandsUpdated before the market's creation. CadenceAdded carries the registry ID, the new cadence ID, and its period, and the new cadence stays disabled until a CadenceConfigUpdated enables it. CadenceConfigUpdated carries the registry ID alongside the new terms, so an indexer can replay cadence history without re-reading the object. Its layout is unchanged from earlier deployments. NoTradeWindowUpdated carries the new window and the onchain timestamp of the change.