Skip to content

refactor(predict): group expiry-market creation params into ExpiryTerms#1066

Draft
tonylee08 wants to merge 1 commit into
mainfrom
tlee/predict-expiry-terms
Draft

refactor(predict): group expiry-market creation params into ExpiryTerms#1066
tonylee08 wants to merge 1 commit into
mainfrom
tlee/predict-expiry-terms

Conversation

@tonylee08

Copy link
Copy Markdown
Collaborator

Summary

  • create_expiry_market passed the strike grid minimum, tick size, preallocation, fee window/multiplier, and leverage values through expiry_market::create_and_share and strike_exposure::new as a long list of same-typed, unlabeled u64s. Two of them could be swapped by accident with no compiler error.
  • Added a public struct ExpiryTerms has copy, drop in strike_exposure holding the 8 immutable creation terms, plus an expiry_terms(...) constructor and an expiry_ms() getter.
  • expiry_market::create_and_share now takes a single terms: ExpiryTerms instead of 6 numeric params, and no longer reaches into config.leverage_config() — it's a pass-through assembler.
  • registry::create_expiry_market builds ExpiryTerms once (gathering the two leverage values alongside the grid/fee/expiry values it already collected) and passes the labeled value through both helpers. Its public signature is unchanged.

Key decisions

  • ExpiryTerms lives in strike_exposure (the leaf), not in registry/expiry_market. Those are higher in the module DAG (registryexpiry_marketstrike_exposure), so defining the struct there and having strike_exposure::new consume it would create a dependency cycle. The 8 values are exactly strike_exposure::new's inputs, so that's its natural home.
  • Built once in registry, where every term is already gathered. This is what lets both helper boundaries pass a single labeled value rather than re-listing the numbers twice.
  • One positional list remains — the strike_exposure::expiry_terms(...) constructor call in registry. Move only allows field-labeled struct literals inside the defining module, so the orchestrator can't write a labeled literal. This is down from two such lists before, and each argument there is a well-named local or a self-documenting config.leverage_config().*() call, reviewable in one place.
  • Moving the two config.leverage_config() reads up into registry mirrors the existing pattern (registry already snapshots expiry_fee_window_ms/expiry_fee_max_multiplier from the Pyth feed config), so all creation terms are now gathered in one place.

Test plan

  • sui move build --path packages/predict — clean, no errors or warnings
  • sui move test --path packages/predict --gas-limit 100000000000 — 491/491 pass
  • bunx prettier-move -c <changed files> --write — all files formatted
  • Public create_expiry_market signature unchanged; its 3 registry test call sites unaffected

The strike-grid, preallocation, leverage, and fee values flowed through
create_and_share and strike_exposure::new as a long list of same-typed,
unlabeled u64s, so two of them could be swapped without a compiler error.
Bundle them into a labeled ExpiryTerms struct built once in
create_expiry_market and passed through both helpers as a single value.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tonylee08 tonylee08 marked this pull request as draft June 3, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant