Repository navigation
Conversation
|
@Emmazlee Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
👋 Thanks for the contribution! This repository only accepts contributor pull requests into the Please re-open your PR with base: |
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.
Overview
This PR adds
splitandmergeentrypoints tomarket-core, giving holders a fee-free way to mint and burn complete sets of YES + NO shares against collateral without touching the FPMM pool. It also adds theSetsSplit/SetsMergedevents, amerge_maxhelper (Rust, Python, TS), aquote_merge_maxview, tightenssell'ssets_mintedaccounting tochecked_sub, and documents the new lifecycle rules, invariants, and MAX_SETS griefing trade-off.Related Issue
Changes
🔀 Split / Merge Primitives
[MODIFY]
oracledesk-stellar/contracts/market-core/src/lib.rssplit(holder, market_id, amount)— requiresassert_not_paused+assert_tradable(Open, before close), pullsamountcollateral, creditsamountYES andamountNO, bumpssets_mintedwithchecked_addand enforcesMAX_SETS. Effects-before-interaction, matchingbuy.merge(holder, market_id, amount)— requiresMarketStatus::Openbut is allowed afterclose_timeand while paused; checks both legs withInsufficientShares(Make positions and LP ownership transferable to enable treasury migration #13), decrementssets_mintedviachecked_sub, paysamountcollateral back at par.reserve_yes,reserve_no, orfees_accrued.SetsSplit/SetsMerged#[contractevent]s with#[topic] market_idand#[topic] holder.quote_merge_max(market_id, holder) -> i128view wrappingmath::merge_maxoverget_position.sellnow useschecked_subform.sets_mintedinstead of the previous unchecked-=.[MODIFY]
oracledesk-stellar/contracts/market-core/src/math.rsmerge_max(yes, no) -> i128returningmin(yes, no)so frontends can offer "merge all".[MODIFY]
oracledesk-stellar/agents/core/fpmm.tsmerge_maxfor the TS agent stack.[MODIFY]
oracledesk-stellar/packages/bindings/market-core/src/index.tssplit,merge,quote_merge_max, and the new event spec.📚 Docs & Security
[MODIFY]
oracledesk-stellar/docs/architecture.mdsplit(Open + before close + unpaused) vsmerge(Open, allowed after close and while paused) with the asymmetry rationale.reserve_yes + Σpos.yes == sets_minted(and NO),balance == sets_minted + fees_accrued, and the resolved/void payout bounds including the flooring argument.MAX_SETSand block furtherbuycalls at the cost of locked capital, then merge out risk-free; decision recorded (no separate split cap in this PR).[MODIFY]
oracledesk-stellar/docs/frontend-integration.mdsplit/merge/quote_merge_maxfor integrators.[MODIFY]
oracledesk-stellar/SECURITY.mdmergeremains callable while paused because it is a pure exit that cannot harm the pool.Verification Results
splitandmergeexist with documented auth, pause and lifecycle rulesrequire_auth,assert_not_paused/assert_tradableper the asymmetry abovereserve_yes,reserve_noorfees_accruedSetsSplit/SetsMergedevents published and in regenerated bindings specpackages/bindings/market-coreinvariant_holds_after_mixed_split_buy_sell_merge,void_total_payout_never_exceeds_sets_with_splitselluseschecked_subforsets_mintedwrong_caller_cannot_*tests with targetedmock_authsforsplitandmergedocs/architecture.mdpackages/bindings/market-coreregeneratedmake build+make bindingscargo test --workspace,make lint, Python model, agents tests passdocs/architecture.mdlifecycle/invariant sections anddocs/frontend-integration.mdupdatedNon-goals
agent_split/agent_mergeforwarders — deferred to a follow-up.redeemalready covers that path.docs/wave-issues/02) — split/merge never touch the pool.Marketstruct layout.Closes #5