Open
Conversation
…ional penalty; tests; minimal emergency-ui
…emergency modules
|
@Abidoyesimze is attempting to deploy a commit to the Edeh Victor's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Abidoyesimze Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Owner
|
@Abidoyesimze fix CI error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #119
Summary
Adds a guaranteed emergency withdrawal path to let users exit directly from idle vault reserves if the main app/strategies are compromised, plus a minimal independently hostable UI page.
Motivation
If the frontend fails or a strategy appears unsafe, users need a simple, reliable escape hatch that avoids strategy interactions and queues.
What’s Included
Contract: yield_vault
emergency_withdraw(to, shares): burns shares and pays from idle reserves only.
set_emergency_penalty(admin, bps): optional haircut during emergency exits.
Events: emg_wd, emg_pen.
Internal accounting updates to maintain invariants.
Tests
Emulates partial allocation to strategy; withdraws only the idle portion.
Validates penalty application.
Minimal UI: emergency-ui Next.js app
/emergency page with clear warning and simple form (contract id, address, shares).
Designed for independent hosting (Vercel/IPFS).
Security
Skips external strategy/oracle calls; uses only contract’s token balance.
Burns shares and clamps to idle reserves, preventing over-withdraws.
Optional penalty (bps) set by admin.
Note: If/when per-user debt is added, gate emergency_withdraw behind a “no-active-debt(user)” check.
How to Test
Contracts:
From contracts/: cargo test -p yield_vault emergency::tests::
UI (optional):
cd emergency-ui && npm install && npm run build && npm start
Acceptance Criteria Mapping
Implement an emergency_withdraw that bypasses strategies: done.
Pulls from idle reserves only: enforced via contract balance.
Minimal independent /emergency page with warnings: added.
Warning about penalties/slippage: present in UI.
Security: no strategy calls; penalty optional; future hook for debt checks.
Checklist
[x] Contract functions and events
[x] Tests for idle-only and penalty cases
[x] Minimal emergency UI with warning
[x] Docs/comments on usage and security caveats