Skip to content

Vault cooldown/pause, TTL on write, oracle thresholds - #2269

Merged
Olowodarey merged 1 commit into
Arena1X:mainfrom
nafiisatu:handsoff/issues-2198-2200-2201-2202-d142f5
Nov 23, 2026
Merged

Olowodarey merged 1 commit into
Arena1X:mainfrom
nafiisatu:handsoff/issues-2198-2200-2201-2202-d142f5

Conversation

@nafiisatu

Copy link
Copy Markdown
Contributor

Closes #2198, closes #2200, closes #2201, closes #2202.

#2198 — Unstake cooldown for the staking vault

  • New contracts/staking-vault/src/config.rs module for admin-controlled vault settings.
  • set_unstake_cooldown(cooldown) (admin only) stores a cooldown in seconds. It is capped at MAX_UNSTAKE_COOLDOWN (90 days); anything higher is rejected with InvalidCooldown. get_unstake_cooldown() returns the stored value, or 0 if none is set.
  • New two-step flow:
    • request_unstake(staker, amount) checks that the lock has elapsed. The amount then leaves the position right away: its shares are burned, so it stops earning rewards, and any rewards already earned are paid out. The principal is held in an UnstakeRequest until available_at = now + cooldown. Emits ("unstake", "requested").
    • complete_unstake(staker) is rejected with WithdrawalLocked before available_at. The request is removed before the token transfer, so it cannot be paid twice. Emits ("unstake", "completed").
  • While a non-zero cooldown is set, the immediate unstake path returns CooldownRequired, so stakers can't time an exit around a reward deposit. With the default cooldown of 0, unstake works as before.
  • New errors: InvalidCooldown, UnstakeRequestPending, CooldownRequired.
  • Tests (tests/cooldown_pause_tests.rs):
    • withdrawal before the cooldown is rejected
    • withdrawal after the cooldown succeeds
    • request and completion emit events
    • immediate unstake is blocked while a cooldown is set
    • out-of-range cooldown is rejected
    • a second request while one is pending is rejected

#2200 — Emergency pause for the staking vault

  • Pause logic moved into config.rs. New admin-only pause() and unpause() entry points, plus is_paused(). The existing set_paused now delegates to the same code. Each change emits ("vault", "paused") or ("vault", "unpaused").
  • Policy, documented in the module docs: while paused, every user-facing state change is clearly blocked with Paused. That covers stake, unstake, unlock requests, withdraw, request/complete unstake, reward claims and fee deposits. Funds stay in the vault and can be withdrawn again as soon as the admin unpauses.
  • Tests:
    • a paused vault rejects stake and unstake
    • a paused vault blocks completing a pending unstake, which then succeeds after unpause
    • only the admin can pause or unpause (non-admin calls fail and leave the flag unchanged)
    • unpausing restores normal operation

#2201 — Extend storage TTL on write (creator-event-manager)

  • Previously, most setters in storage.rs extended an entry's TTL only while its event was active. A write made after that (for example the final set_event during finalization, or a write to a list of a finalized event) could leave the entry with the minimum TTL, so it could expire and the data would be lost.
  • New extend_on_write helper, using the configured TTL_THRESHOLD / TTL_BUMP. Every set_* / add_* helper now calls it unconditionally.
  • The counter helpers (next_*_id) now also extend the contract instance TTL when they write.
  • Read policy is unchanged. Event-scoped reads extend the TTL only while the event is active, so finalized or cancelled state can still expire once nothing writes to it. The module docs now describe both rules.
  • Tests (tests/storage_ttl_write_tests.rs):
    • writing an entry extends its TTL, including after finalization
    • an entry survives more than a full TTL window when it is written periodically
    • read-only ops follow the policy (active reads extend, finalized reads don't)

#2202 — Configurable oracle consensus threshold

  • New set_event_consensus_threshold(caller, event_id, threshold) (admin only). The threshold must be within MIN_ORACLE_CONSENSUS_THRESHOLD (1)..= the number of configured oracle sources; anything outside that range is rejected with invalid_consensus_threshold. Emits ("oracle", "threshold_set").
  • The value is stored under the new DataKey::EventConsensusThreshold(event_id).
  • get_event_consensus_threshold(event_id) returns the event's own threshold, or the global min_sources if none is set.
  • propose_match_result now finalizes a match only when the number of agreeing sources reaches the event's threshold.
  • Tests (tests/oracle_threshold_tests.rs):
    • the default threshold applies when none is set
    • a stricter threshold is enforced at finalization
    • a looser threshold is enforced at finalization
    • 0, a value above the source count, a non-admin caller and an unknown event are all rejected

Notes

  • Nothing was built or run here. The changes were made by reading and editing the code only.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

Closes #2198
Closes #2200
Closes #2201
Closes #2202

@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@nafiisatu 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

@vercel

vercel Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
insight-arena-4rll Error Error Nov 23, 2026 12:49pm UTC

@Olowodarey
Olowodarey merged commit ff16ae0 into Arena1X:main Nov 23, 2026
1 of 5 checks passed

This branch had an error being deployed

1 failed deployment
Preview — 0e4161f2 Deployed Nov 23, 2026 by vercel[bot]
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