Skip to content

feat: add emergency admin operations with timelocks - #33

Open
Ebuka321 wants to merge 1 commit into
Exquisitech:mainfrom
Ebuka321:feat/emergency-admin-operations
Open

feat: add emergency admin operations with timelocks#33
Ebuka321 wants to merge 1 commit into
Exquisitech:mainfrom
Ebuka321:feat/emergency-admin-operations

Conversation

@Ebuka321

Copy link
Copy Markdown

Summary

  • Adds stuck funds recovery and timelocked admin operations to the betting contract (emergency_withdraw, recover_token, set_admin)
  • Adds timelocked admin transfer (set_admin) to the rewards contract
  • Adds new error variants (TimelockNotExpired, MismatchPendingData, TokenIsTracked) to the shared core PlatformError

Key changes

Betting contract (betting/src/lib.rs)

  • emergency_withdraw(asset, to, amount) — 24h timelocked admin withdrawal for stuck funds
  • cancel_emergency_withdraw(asset) — cancel a pending emergency withdrawal
  • recover_token(asset, to, amount) — recover accidentally sent tokens (only non-tracked tokens; tracked tokens used in registered matches are protected)
  • set_admin(new_admin) — 48h timelocked admin transfer
  • cancel_set_admin() — cancel a pending admin transfer
  • TrackedTokens storage tracks tokens registered via register_match
  • All emergency ops emit EmergencyAction event with reason hash

Rewards contract (rewards/src/lib.rs)

  • set_admin(new_admin) — 48h timelocked admin transfer
  • cancel_set_admin() — cancel a pending admin transfer
  • Emits EmergencyAction event on completion

Core (core/src/lib.rs)

  • TimelockNotExpired = 8 — returned when a timelock has not yet elapsed
  • MismatchPendingData = 9 — returned when confirmation params don't match the pending request
  • TokenIsTracked = 10 — returned when attempting to recover a token used in registered matches

Tests

  • Simulate timelock expiry (execute before and after deadline)
  • Simulate cancellation of pending operations
  • Verify tracked token recovery is blocked
  • Verify mismatched parameters are rejected

Closes #21

@Divineifed1

Copy link
Copy Markdown
Contributor

@Ebuka321 resolve conflicts and make sure ci passes

Implement stuck funds recovery and emergency admin operations for the
betting and rewards contracts, matching the vault's existing safety
mechanisms.

Betting contract additions:
- emergency_withdraw: 24h timelocked admin withdrawal for stuck funds
- cancel_emergency_withdraw: cancel a pending emergency withdrawal
- recover_token: recover accidentally sent tokens (non-tracked only)
- set_admin: 48h timelocked admin transfer
- cancel_set_admin: cancel a pending admin transfer
- TrackedTokens storage to prevent recovering match settlement tokens
- All emergency ops emit EmergencyAction event with reason hash

Rewards contract additions:
- set_admin: 48h timelocked admin transfer
- cancel_set_admin: cancel a pending admin transfer
- EmergencyAction event emission

Core additions:
- TimelockNotExpired, MismatchPendingData, TokenIsTracked error variants

Closes Exquisitech#21
@Ebuka321
Ebuka321 force-pushed the feat/emergency-admin-operations branch from 642b399 to cd23eb1 Compare July 20, 2026 14:07
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.

implement stuck funds recovery and emergency admin operations

2 participants