Skip to content

Overturn window, claim guard, exact accrual, dispute gate - #2268

Merged
Olowodarey merged 2 commits into
Arena1X:mainfrom
ussyalfaks:handsoff/issues-2196-2197-2199-2205-d301db
Nov 23, 2026
Merged

Olowodarey merged 2 commits into
Arena1X:mainfrom
ussyalfaks:handsoff/issues-2196-2197-2199-2205-d301db

Conversation

@ussyalfaks

Copy link
Copy Markdown
Contributor

Summary

Four independent contract hardening changes.

#2196 — Bounded overturn window for match results (creator-event-manager)

  • New MATCH_RESULT_OVERTURN_WINDOW_SECONDS (1 day). overturn_match_result now rejects with overturn_window_closed once now >= submitted_at + window, or once the result has been marked final.
  • The window is measured from the original submission: overturning no longer resets submitted_at, so repeated overturns can't keep a result open forever.
  • New permissionless finalize_match_result(match_id) (in finalize.rs) marks a result final after the window closes and emits ("match", "result_final") with (match_id, event_id, home, away, finalized_at). finalize_event also marks every remaining result of the event final, so each result emits the event exactly once. New view: get_match_result_finalized_at.
  • Storage: a new DataKey::MatchResultFinalizedAt(match_id) plus get/set helpers.
  • Tests: an overturn inside the window succeeds, one after it is rejected, repeated overturns don't extend the window, finalizing before the window closes is rejected, and finality emits the event (both through finalize_match_result and through finalize_event).

#2197 — Guard prize claims against double-claim (creator-event-manager)

  • storage::set_prize_allocation now treats claimed as permanent: a settled allocation can never be written back to unclaimed, whatever order calls happen in.
  • New storage::mark_prize_allocation_claimed checks and sets the flag in one step. claim_prize calls it before the transfer (checks-effects-interactions), so a failed transfer reverts the claim along with it.
  • Tests: the first claim pays out and saves claimed = true; a second claim is rejected with no extra payout; exactly one ("prize", "claimed") event is emitted; trying to reset the flag in storage has no effect.

#2199 — Precise reward accrual in the staking vault (staking-vault)

  • Bug fixed: distribute kept leftover whole units in pending_rewards while the accumulator also held the fractional part of the same amount. That value was counted twice, so over many deposits stakers could claim more than was funded.
  • New src/config.rs documents the fixed-point model and what precision it guarantees. Distribution now works in scaled units and carries the sub-unit remainder forward in a new PoolState::reward_remainder, so the pool's books balance exactly after every distribution.
  • reward_debt is now kept in scaled units. The new pool::settle pays a position and moves it to its new share count while keeping any fraction it earned but hasn't been paid. Over its lifetime a position gets the floor of its exact share: short by less than one unit, however many deposits or claims happen.
  • A RewardLedger (funded / distributed) is updated on fee deposits, routed penalties and every reward payout (stake, unstake, withdraw, claim). Payouts are capped so that distributed <= funded always holds.
  • Tests: accrual over 5,000 steps stays within 1 unit of a reference, distributed never exceeds funded (including when shares change), precision holds for small and large stakes, the ledger cap works, a regression test covers the double-counting, and there is one integration test. One existing pool unit test asserted the double-counted leftover (pending_rewards == 1); it now checks the exact scaled accounting instead.

#2205 — Resolution dispute window for open-market (open-market)

  • config.rs adds dispute_window_end, is_dispute_window_open, has_open_dispute, ensure_payouts_unlocked and are_payouts_paused.
  • claim_payout and batch_distribute_payouts are blocked while a dispute against the resolution is open. They return DisputeAlreadyFiled, reused because the error enum is at its 50-case cap.
  • If the dispute is rejected, payouts resume on the original outcome. If it is upheld, the market reopens and payouts stay blocked until it is resolved again. With no dispute, payouts go ahead, and after the window closes the outcome can no longer be contested.
  • Opening and resolving a dispute already emit ("dsp", "raised") and ("dsp", "reslvd"). New views: are_payouts_paused and get_dispute_window_end.
  • Tests: a dispute inside the window pauses both payout paths; a rejected dispute releases payouts; an upheld one keeps them blocked; with no dispute, payouts go ahead after the window and late disputes are rejected; the dispute lifecycle emits both events.

Closes #2196
Closes #2197
Closes #2199
Closes #2205

Closes #2196
Closes #2197
Closes #2199
Closes #2205

@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@ussyalfaks 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 1:24pm UTC

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

This branch had an error being deployed

1 failed deployment
Preview — f6a23cbf 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