refactor(predict): group expiry-market creation params into ExpiryTerms#1066
Draft
tonylee08 wants to merge 1 commit into
Draft
refactor(predict): group expiry-market creation params into ExpiryTerms#1066tonylee08 wants to merge 1 commit into
tonylee08 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
create_expiry_marketpassed the strike grid minimum, tick size, preallocation, fee window/multiplier, and leverage values throughexpiry_market::create_and_shareandstrike_exposure::newas a long list of same-typed, unlabeledu64s. Two of them could be swapped by accident with no compiler error.public struct ExpiryTerms has copy, dropinstrike_exposureholding the 8 immutable creation terms, plus anexpiry_terms(...)constructor and anexpiry_ms()getter.expiry_market::create_and_sharenow takes a singleterms: ExpiryTermsinstead of 6 numeric params, and no longer reaches intoconfig.leverage_config()— it's a pass-through assembler.registry::create_expiry_marketbuildsExpiryTermsonce (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
ExpiryTermslives instrike_exposure(the leaf), not inregistry/expiry_market. Those are higher in the module DAG (registry→expiry_market→strike_exposure), so defining the struct there and havingstrike_exposure::newconsume it would create a dependency cycle. The 8 values are exactlystrike_exposure::new's inputs, so that's its natural home.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.strike_exposure::expiry_terms(...)constructor call inregistry. 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-documentingconfig.leverage_config().*()call, reviewable in one place.config.leverage_config()reads up intoregistrymirrors the existing pattern (registry already snapshotsexpiry_fee_window_ms/expiry_fee_max_multiplierfrom 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 warningssui move test --path packages/predict --gas-limit 100000000000— 491/491 passbunx prettier-move -c <changed files> --write— all files formattedcreate_expiry_marketsignature unchanged; its 3 registry test call sites unaffected