Implement cancel_market — cancel market and enable refunds#303
Merged
GoSTEAN merged 3 commits intoNetwalls:mainfrom Mar 27, 2026
Merged
Implement cancel_market — cancel market and enable refunds#303GoSTEAN merged 3 commits intoNetwalls:mainfrom
GoSTEAN merged 3 commits intoNetwalls:mainfrom
Conversation
…s/Dell/Desktop/Github/BOXMEOUT_STELLA/contracts/contracts/boxmeout/src/market.rs:1313:4-1363:5) and user [refund_position](cci:1://file:///c:/Users/Dell/Desktop/Github/BOXMEOUT_STELLA/contracts/contracts/boxmeout/src/market.rs:1365:4-1409:5) - Expose [get_admin](cci:1://file:///c:/Users/Dell/Desktop/Github/BOXMEOUT_STELLA/contracts/contracts/boxmeout/src/factory.rs:55:0-61:1) in [factory.rs](cci:7://file:///c:/Users/Dell/Desktop/Github/BOXMEOUT_STELLA/contracts/contracts/boxmeout/src/factory.rs:0:0-0:0) for external admin authorization queries. - Update [cancel_market](cci:1://file:///c:/Users/Dell/Desktop/Github/BOXMEOUT_STELLA/contracts/contracts/boxmeout/src/market.rs:1313:4-1363:5) in [market.rs](cci:7://file:///c:/Users/Dell/Desktop/Github/BOXMEOUT_STELLA/contracts/contracts/boxmeout/src/market.rs:0:0-0:0) to require protocol admin auth instead of creator auth. - Refactor [cancel_market](cci:1://file:///c:/Users/Dell/Desktop/Github/BOXMEOUT_STELLA/contracts/contracts/boxmeout/src/market.rs:1313:4-1363:5) to only update status to STATE_CANCELLED without forcing immediate transfers. - Add [refund_position](cci:1://file:///c:/Users/Dell/Desktop/Github/BOXMEOUT_STELLA/contracts/contracts/boxmeout/src/market.rs:1365:4-1409:5) allowing users to securely claim full collateral refunds on cancelled markets. - Add comprehensive integration tests in [market_test.rs](cci:7://file:///c:/Users/Dell/Desktop/Github/BOXMEOUT_STELLA/contracts/contracts/boxmeout/tests/market_test.rs:0:0-0:0) covering happy paths and unauthorized access.
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.
closes #263
Title: Implement
cancel_market
functionality and enable pull-based refunds
Description: This PR implements the ability for the protocol admin to cancel a prediction market before it resolves and introduces a pull-based refund mechanism for participants.
Key Changes:
Factory Updates: Added a public
get_admin
helper in
factory.rs
to allow the active prediction market to dynamically check the protocol-level admin.
Admin Kill-Switch: Modified
cancel_market
inside
market.rs
to enforce admin.require_auth(). It now acts as an emergency stop, immediately changing the market state to STATE_CANCELLED and emitting a refined
MarketCancelledEvent
.
Position Refunds: Shifted from an active push-transfer iteration (which is expensive and prone to reverting) to a robust pull-based
refund_position
function. Users can now independently retrieve their staked USDC by passing their authentication during a STATE_CANCELLED phase.
Testing: Added rigorous integration bounds in
market_test.rs
to validate unauthenticated panic boundaries, successful cancellation triggers, and refund ledger verification.