Skip to content

Outcome token reconciliation jhayniffy - #674

Merged
Mimah97 merged 2 commits into
Vatix-Protocol:devfrom
jhayniffy:outcome-token-reconciliation-jhayniffy
Jul 30, 2026
Merged

Outcome token reconciliation jhayniffy#674
Mimah97 merged 2 commits into
Vatix-Protocol:devfrom
jhayniffy:outcome-token-reconciliation-jhayniffy

Conversation

@jhayniffy

Copy link
Copy Markdown
Contributor

closes #660

This PR introduces position-to-token reconciliation to ensure market position shares always remain consistent with YES/NO outcome token balances. It adds parity validation, blocks trading and settlement when inconsistencies are detected, and provides an admin-only repair mechanism with full auditability.

Changes
Added get_position_token_parity(market_id, user) view to compare stored position shares with outcome token balances.
Added reconciliation guards to update_position and settle_position that reject operations when a mismatch is detected.
Implemented admin-gated reconcile_position_tokens to restore ledger consistency using a documented reconciliation policy.
Emitted events for mismatch detection and successful reconciliation.
Added tests covering ledger divergence, blocked trading/settlement, authorized repair, and successful recovery.
Updated outcome-token documentation and cross-contract call graph with the reconciliation flow.
Why

This prevents inconsistencies between market storage and outcome token balances from creating exploitable states or preventing users from settling positions. The reconciliation flow ensures dual ledgers remain consistent, making settlement deterministic, auditable, and production-ready.

jhayniffy and others added 2 commits July 30, 2026 03:56
Position (market storage) and OutcomeToken balances can diverge from a
historical bug, a partial upgrade, or a manual admin mint/burn issued
directly on the outcome-token contract. Trading and settlement previously
assumed the two ledgers always matched.

- get_position_token_parity(market_id, user): read-only view comparing
  Position shares against OutcomeToken balances.
- Guard on update_position and settle_position (plus batch/page settlement):
  reject with ContractError::PositionTokenMismatch on divergence, emitting
  PositionTokenMismatchDetected. No silent re-sync.
- Admin-gated reconcile_position_tokens(admin, market_id, user): mints/burns
  OutcomeToken balances to match Position (Position is the source of truth),
  emitting PositionTokensReconciled. No-op when already matched.
- Tests in contracts/market/src/reconciliation.rs force divergence via an
  out-of-band mint on the outcome-token contract and assert trading/
  settlement are blocked until repaired.
- Docs: contracts/outcome-token/README.md (new), cross-contract-call-graph.md,
  events-reference.md.

Also fixes two small pre-existing compile breaks uncovered while wiring this
up: a missing ContractError::InvalidThresholdQuorum variant referenced by
set_threshold_signers, and a Result-vs-Vec return type mismatch in
TreasuryContract::market_contract/list_markets.
@Mimah97
Mimah97 merged commit 58d1609 into Vatix-Protocol:dev Jul 30, 2026
0 of 4 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

Development

Successfully merging this pull request may close these issues.

Position vs outcome-token dual-ledger reconciliation and repair guards

2 participants