Skip to content

feat: Oracle Safety Valve with DAO manual rate override (Issue #102)#256

Open
mgtmdccix-oss wants to merge 1 commit intoGrant-Stream:mainfrom
mgtmdccix-oss:main
Open

feat: Oracle Safety Valve with DAO manual rate override (Issue #102)#256
mgtmdccix-oss wants to merge 1 commit intoGrant-Stream:mainfrom
mgtmdccix-oss:main

Conversation

@mgtmdccix-oss
Copy link
Copy Markdown

@mgtmdccix-oss mgtmdccix-oss commented Mar 28, 2026

Closes #215


Summary

If the Price Oracle stops responding, inflation protection could freeze funds. This PR implements a Manual Safety Valve so the protocol remains antifragile.

Changes

  • oracle_heartbeat() — oracle signals liveness by recording a timestamp
  • propose_safety_rate() — any DAO member can propose a manual exchange rate after 48 hours of oracle silence
  • vote_on_safety_rate() — weighted DAO vote with double-vote protection
  • execute_safety_rate() — applies the rate if 90% supermajority is reached after the voting window closes; re-checks oracle is still silent at execution time
  • get_exchange_rate() — returns the manual rate, or (1, 1) if none is set

New types & storage

  • SafetyVoteProposal struct + SafetyVoteStatus enum
  • DataKey variants: OracleLastHeartbeat, SafetyVoteProposal, SafetyVoteVote, ManualExchangeRate, etc.
  • Error codes 304–309

Tests (test_oracle_safety_valve.rs)

  • Heartbeat blocks proposal creation
  • Full happy-path: propose → vote → execute → rate applied
  • Rejection when approval < 90%
  • Oracle recovery after proposal creation blocks execution

Labels

security reliability logic

…ant-Stream#102)

- oracle_heartbeat(): oracle signals liveness, records timestamp
- propose_safety_rate(): DAO member opens vote after 48h oracle silence
- vote_on_safety_rate(): weighted DAO vote with double-vote protection
- execute_safety_rate(): applies rate on 90% supermajority after voting ends
- get_exchange_rate(): returns manual rate or (1,1) fallback
- Added SafetyVoteProposal struct, SafetyVoteStatus enum, DataKey variants,
  error codes 304-309, and constants for timeouts/thresholds
- Tests: heartbeat blocks proposal, full flow, rejection below 90%,
  oracle recovery blocks execution
@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 28, 2026

@mgtmdccix-oss 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

@JerryIdoko
Copy link
Copy Markdown
Contributor

resolve conflicts

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.

137. Add Emergency_Manual_Revert_for_Oracle_Freeze

2 participants