Skip to content

Emergency pause and withdrawal mechanism - #38

Merged
Queenode merged 2 commits into
Kolo-Org:mainfrom
AbolareRoheemah:emergency-pause
Aug 29, 2026
Merged

Emergency pause and withdrawal mechanism#38
Queenode merged 2 commits into
Kolo-Org:mainfrom
AbolareRoheemah:emergency-pause

Conversation

@AbolareRoheemah

Copy link
Copy Markdown
Contributor

Closes #24

Summary
Adds an emergency pause mechanism so the admin can halt the contract if a bug is found or the group needs to be frozen, plus a trustless escape hatch so members aren't stuck if the admin goes unresponsive.

Changes

  • DataKey::IsPaused (instance storage, defaults to false)
  • pause() / unpause() — admin-only
  • Guard added to contribute(), payout(), add_member(), reset_cycle() — all panic with "Contract is paused for emergency" while paused
  • emergency_withdraw() — callable only while paused; lets a member reclaim exactly what they contributed in the current cycle (tracked via new MemberState.current_cycle_contribution field), and decrements CycleMemberCount so pool math stays valid if the contract is later unpaused
  • Payout order (NextPayoutIndex) is intentionally untouched by emergency withdraw — it only unwinds contribution/pool state, it doesn't let anyone jump the rotation queue

Tests added

  • Admin pause blocks contribute
  • Unpause restores normal contribute flow
  • Non-admin pause call fails auth
  • Emergency withdraw refunds exactly the member's contribution, adjusts CycleMemberCount, and rotation/payout math still checks out after unpause
  • Double emergency-withdraw in the same cycle panics

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: daeb5039-b101-4095-b039-1d470166e69e


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Queenode

Copy link
Copy Markdown
Contributor

Thank you for your contribution @AbolareRoheemah

@Queenode
Queenode merged commit 7a3c08b into Kolo-Org:main Aug 29, 2026
3 checks passed
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.

[FEAT] Implement Emergency Pause (Circuit Breaker) Functionality

2 participants