Skip to content

feat(contracts): fee rounding, pause reasons, dual-approval emergency, storage registry#669

Merged
Junirezz merged 1 commit into
Junirezz:mainfrom
miss-yusrah:feat/development
May 31, 2026
Merged

feat(contracts): fee rounding, pause reasons, dual-approval emergency, storage registry#669
Junirezz merged 1 commit into
Junirezz:mainfrom
miss-yusrah:feat/development

Conversation

@miss-yusrah
Copy link
Copy Markdown
Contributor

closes #639
closes #643
closes #647
closes #648

Summary

Implements four vault contract improvements for operator safety and auditability.

Task 1 — Deterministic fee rounding policy tests

  • Added fee_math.rs with floor-division fee policy (fee = amount * bps / 10_000)
  • Edge-case tests: zero amount/bps, max bps, sub-stroop truncation, boundary values, monotonicity
  • accrue_yield now uses calculate_protocol_fee() for consistent rounding

Task 2 — Paused-state reason codes + query endpoint

  • Added PauseReason enum (SecurityIncident, OracleFailure, LiquidityCrisis, Governance, Maintenance, Other)
  • pause(reason) stores reason on-chain; unpause() clears it
  • New read method: pause_reason() -> Option<PauseReason>

Task 3 — Dual-approval for critical emergency actions

  • Added emergency.rs with two-approver flow
  • set_emergency_approvers(primary, secondary) — admin configures distinct approvers
  • propose_emergency_action(...) — primary initiates (Pause, Unpause, EmergencyDivest, ForceUpgrade)
  • confirm_emergency_action(proposal_id) — secondary confirms and executes
  • emergency_proposal(proposal_id) — query pending/executed proposals

Task 4 — Storage key namespace registry + collision checks

  • Added storage_registry.rs with StorageNamespace and key catalog
  • validate_registry_no_collisions() enforces unique (namespace, name) pairs
  • New query: storage_key_registry() returns full registry + validity flag
  • Proxy ProxyDataKey kept separate from vault DataKey

Test plan

  • fee_math edge-case unit tests
  • feature_tests — pause reason, dual-approval pause, fee rounding integration, registry validity
  • storage_registry collision tests
  • emergency distinct-approver tests
  • Updated event_tests::test_pause_unpause_works for new pause(reason) signature

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 31, 2026

@miss-yusrah 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! 🚀

Learn more about application limits

@Junirezz Junirezz merged commit 6c46a42 into Junirezz:main May 31, 2026
10 of 15 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

2 participants