Skip to content

feat: implement timelocked emergency admin controls - #32

Merged
Divineifed1 merged 1 commit into
Exquisitech:mainfrom
dubemoyibe-star:feature/emergency-admin-controls
Jul 19, 2026
Merged

feat: implement timelocked emergency admin controls#32
Divineifed1 merged 1 commit into
Exquisitech:mainfrom
dubemoyibe-star:feature/emergency-admin-controls

Conversation

@dubemoyibe-star

Copy link
Copy Markdown
Contributor

Emergency Safety Mechanisms for Renaissance Vault

Summary

Adds timelocked admin operations and token recovery safety mechanisms to the Renaissance vault contract to handle platform bugs and accidental token transfers.

Changes

vault/src/lib.rs

  • emergency_withdraw — 24-hour timelocked admin withdrawal. First call schedules the withdrawal (pending_until = now + 24h), second call after expiry executes the transfer. Emits EmergencyAction event with reason hash.
  • cancel_emergency_withdraw — Allows admin to cancel a pending emergency withdrawal before execution.
  • recover_token — Recovers accidentally sent tokens that are not tracked by the vault (i.e., have no VaultBalance deposits/locks). Emits EmergencyAction event with reason hash.
  • set_admin — 48-hour timelocked admin transfer. First call schedules the new admin (pending_until = now + 48h), second call after expiry completes the transfer. Emits EmergencyAction event with reason hash.
  • cancel_set_admin — Allows current admin to cancel a pending admin transfer before expiry.

vault/src/test.rs

  • test_emergency_withdraw_schedule_and_execute — Simulates 24h timelock expiry and successful execution.
  • test_emergency_withdraw_cancel — Verifies cancellation prevents execution after timelock expiry.
  • test_set_admin_schedule_and_execute — Simulates 48h confirmation period and successful admin transfer.
  • test_set_admin_cancel — Verifies pending admin transfer can be cancelled.
  • test_recover_token — Verifies tracked tokens cannot be recovered, while untracked tokens can.

Acceptance Criteria

  • emergency_withdraw has 24-hour timelock (pending_until)
  • recover_token only works for tokens not owned by the contract's intended logic
  • All emergency ops emit EmergencyAction event with reason hash
  • Admin transfer requires 48-hour confirmation period
  • Tests simulate timelock expiry and cancellation

Security Considerations

  • All emergency operations require admin authentication.
  • Timelocks prevent rushed or malicious fund movements.
  • Token recovery is restricted to untracked assets to protect user funds.
  • EmergencyAction events provide transparent on-chain audit trail.

Closes #24

@dubemoyibe-star

dubemoyibe-star commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

hey!!!!
My main implemetation is in vault/src/lib.rs and vault/src/test.rs
The remaining changed files are due to formatting which i ran on the codebase cargo fmt --all and my implementation has been tested and passes without errors
Any current error is due to pre-existing errors or problem not related to my implementation

@Divineifed1
Divineifed1 merged commit 3fa9c71 into Exquisitech:main Jul 19, 2026
2 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.

*Title:** `feat(contracts): implement stuck funds recovery and emergency admin operations

2 participants