feat(dispute): add per-pair dispute flag with view, event, and boundary tests - #441
Merged
mikewheeleer merged 1 commit intoJul 30, 2026
Conversation
…ry tests Adds a minimal dispute-flagging model: flag_pair_dispute/resolve_pair_dispute (admin-gated), is_pair_disputed (read-only view), a disp_set event guarded against duplicate emission, and a shared read_pair_disputed helper used by both quote_route and compute_route_fee instead of inlining the check twice. Closes StableRoute-Org#414 Closes StableRoute-Org#415 Closes StableRoute-Org#416 Closes StableRoute-Org#417
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.
Summary
The router previously had no dispute concept at all. Issues #414-#417 each describe an incremental slice of a dispute model that would need to already exist (a view onto its state, an event on its state changes, boundary tests for its logic, a helper extracted from its repeated check) — so this PR builds the minimal model those four issues collectively assume, in one cohesive change rather than four PRs that would each be incomplete/non-functional in isolation:
DataKey::PairDisputed(Symbol, Symbol)(persistent, defaults tofalse)flag_pair_dispute/resolve_pair_dispute— admin-gated, require the pair to already be registered, guarded against duplicatedisp_setevent emission on idempotent re-calls (mirrors the pattern from Emit a dedicated event when config state changes #410)is_pair_disputed— read-only view (Add a read-only view exposing the current dispute state #414)disp_setevent carrying(source, destination, disputed)(Emit a dedicated event when dispute state changes #415)read_pair_disputedhelper used by bothquote_routeandcompute_route_feeinstead of each inlining its own storage read (Extract the repeated dispute check into a helper #417) — mirrors the existingread_pair_registeredpatternunregister_pairnow also clears a pair's dispute flag, consistent with how it already clears min/max/liquidity/cooldownRouterError::PairDisputed = 22Tests (#416)
Boundary/behavioral coverage: default-false, flag blocks
quote_route/compute_route_fee, resolve restores routing, flagging an unregistered pair panicsPairNotRegistered, re-flagging doesn't duplicate the event, resolving an undisputed pair is a silent no-op, and unregister+re-register doesn't leak a stale flag.Documentation for this model is filed separately (closes #418) since it's cleanly independent of the code change.
Test output
Same pre-existing
main-at-HEAD build breakage as #409/#410/#411 (103 unrelated errors, reproducible viagit stash). Confirmed this change adds zero additional errors — identical error count/set before and after.Closes #414
Closes #415
Closes #416
Closes #417