Skip to content

feat(#45): emergency pause admin role for BlendLeverageStrategy#232

Open
obanai9 wants to merge 2 commits into
Dgetsylver:mainfrom
obanai9:feat/45-emergency-pause
Open

feat(#45): emergency pause admin role for BlendLeverageStrategy#232
obanai9 wants to merge 2 commits into
Dgetsylver:mainfrom
obanai9:feat/45-emergency-pause

Conversation

@obanai9

@obanai9 obanai9 commented Jun 1, 2026

Copy link
Copy Markdown

Summary

Implements issue #45 — D4: Emergency pause admin role.

  • storage.rs: adds Admin and Paused keys to DataKey; new helpers set_admin, get_admin, set_paused, is_paused.
  • lib.rs: ninth constructor arg admin: Address; new public methods pause(), unpause(), paused(), get_admin().
  • pause() and unpause() are gated by the admin address set at init and emit an on-chain event (pause, state) → bool.
  • deposit() and harvest() return StrategyError::NotAuthorized when paused; withdraw() is unaffected so users can always exit.

Test plan

  • Verify BlendLeverageStrategy::pause() blocks deposit() and harvest(); withdraw() succeeds while paused.
  • Verify unpause() restores normal operation.
  • Confirm PauseStateChange events are emitted on every state transition.
  • Confirm non-admin callers are rejected by pause() and unpause().

Closes #45

🤖 Generated with Claude Code

obanai9 and others added 2 commits June 1, 2026 18:53
…trategy

Adds Admin and Paused storage keys with helpers. Constructor gains a
ninth `admin: Address` arg. `pause()` and `unpause()` are admin-gated
and emit an on-chain event; `deposit()` and `harvest()` return
NotAuthorized when paused while `withdraw()` is unaffected.

Closes Dgetsylver#45

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Dgetsylver

Copy link
Copy Markdown
Owner

The core mechanism is sound: pause()/unpause() both resolve the stored admin and call require_auth(), deposits and harvest are gated before any transfer, withdrawals stay open, and is_paused fail-opens to normal for fresh deploys. Two blockers before this can merge:

  1. scripts/deploy_strategy.ts is not updated. The constructor now requires a 9th arg (init_args[8] admin, with .expect("Missing: admin")), but the deploy script still builds args [0..7] — every deploy panics. Please update the script in this PR.
  2. No tests. The PR's own test plan is unchecked. Minimum set: non-admin pause/unpause rejected; deposit blocked while paused; withdraw succeeds while paused; unpause restores deposit.

Nice-to-haves (not blocking): a dedicated Paused error variant instead of NotAuthorized so callers can distinguish the two; consider an admin-rotation path (admin is currently immutable while keeper has set_keeper).

@Dgetsylver

Copy link
Copy Markdown
Owner

Thanks! Heads-up: the admin role landed on main via D3, but pause/unpause is still unique and wanted. Could you rebase the pause logic onto latest main (the constructor signature changed)? (closes #45)

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.

D4: Emergency pause admin role

2 participants