Skip to content

Implement cancel_market — cancel market and enable refunds#303

Merged
GoSTEAN merged 3 commits intoNetwalls:mainfrom
utilityjnr:umaru
Mar 27, 2026
Merged

Implement cancel_market — cancel market and enable refunds#303
GoSTEAN merged 3 commits intoNetwalls:mainfrom
utilityjnr:umaru

Conversation

@utilityjnr
Copy link
Copy Markdown
Contributor

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.

Your Actual Name and others added 2 commits March 25, 2026 06:10
…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.
@utilityjnr utilityjnr changed the title Umaru Implement cancel_market — cancel market and enable refunds Mar 26, 2026
@GoSTEAN GoSTEAN merged commit 63b951c into Netwalls:main Mar 27, 2026
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.

Issue #13 — cancel_market

2 participants