🟡 Priority: High
Difficulty: Hard
Estimated Effort: 2-3 days
Relevant Files: contracts/src/lib.rs
Labels: enhancement, priority:high, security
Requirements
-
Pausable State
- Add
DataKey::IsPaused to instance storage (boolean, defaults to false).
- Add
pub fn pause(env: Env) and pub fn unpause(env: Env) functions.
- Only the Admin can call
pause or unpause.
-
Function Modifiers
- In
contribute(), payout(), add_member(), and reset_cycle(), check IsPaused.
- If
true, panic with "Contract is paused for emergency".
-
Emergency Withdraw (Escape Hatch)
- Add
pub fn emergency_withdraw(env: Env) callable ONLY when the contract is paused.
- Only members can call it.
- It allows a member to withdraw exactly what they have contributed in the current active cycle.
- This provides a trustless exit if the admin abandons the group or a bug is discovered.
- It must update their
Contributions state and clear HasContributedThisCycle.
-
State Integrity during Pause
- The escape hatch must not allow draining more funds than the member put in.
- If a member uses
emergency_withdraw, the CycleMemberCount or CurrentCycleContributions counters must be decremented to keep the pool math valid if the contract is ever unpaused.
-
Testing
- Unit test: Admin pauses, contributions fail.
- Unit test: Admin unpauses, contributions succeed.
- Unit test: Non-admin tries to pause (panics).
- Integration test: Pause -> Member executes emergency withdraw -> Verify balance -> Unpause -> Contract math still works for remaining members.
- Target: >90% coverage on pausable flows.
🟡 Priority: High
Difficulty: Hard
Estimated Effort: 2-3 days
Relevant Files:
contracts/src/lib.rsLabels:
enhancement,priority:high,securityRequirements
Pausable State
DataKey::IsPausedto instance storage (boolean, defaults to false).pub fn pause(env: Env)andpub fn unpause(env: Env)functions.pauseorunpause.Function Modifiers
contribute(),payout(),add_member(), andreset_cycle(), checkIsPaused.true, panic with "Contract is paused for emergency".Emergency Withdraw (Escape Hatch)
pub fn emergency_withdraw(env: Env)callable ONLY when the contract is paused.Contributionsstate and clearHasContributedThisCycle.State Integrity during Pause
emergency_withdraw, theCycleMemberCountorCurrentCycleContributionscounters must be decremented to keep the pool math valid if the contract is ever unpaused.Testing