verex

Verex — Portfolio page + Market resolution (Jul 20 design)

There is no real auth — “admin” is just anvil account #0 by convention. A separate admin page would add a route + nav for what amounts to two buttons per market. Instead:

Fallback if this feels cluttered later: the same Resolve panel can be lifted into an /admin page listing OPEN markets — the API work is identical either way.

Feature 2 first — Resolution (it gates portfolio’s redeem UX)

API

  1. POST /markets/:slug/resolve — body {outcome: "Yes" | "No", accountIndex: number}.
    • Guards: market exists and status === "OPEN"; accountIndex === 0 (403 otherwise — convention-auth, same trust model as the rest of the demo API).
    • On-chain: ct.reportPayouts(questionId, outcome === "Yes" ? [1n, 0n] : [0n, 1n]) as operator (wallet 0). CTF rejects a second report (payout already set) — natural idempotency guard.
    • DB: status = "RESOLVED", resolvedOutcomeId = <winning outcome id>, winning outcome price → 1.00, losing → 0.00, plus a final PricePoint so the chart ends at the resolution.
  2. Trade guard (missing today): executeTrade rejects non-OPEN markets with 400 — currently nothing stops trading a resolved market against stale operator inventory.
  3. POST /redeem — body {accountIndex, slug}.
    • Guards: market RESOLVED; index 1–9.
    • On-chain: as the user, ct.redeem(usdc, conditionId, [1n, 2n]) (both index sets — losing tokens redeem for 0, so one call clears the position).
    • Returns USDC received (balance delta), for a toast in the UI.

Web (market page)

Feature 1 — Portfolio page

Order of work + verification

# Item Verify
1 /resolve route + DB update + trade guard curl: resolve → 200; second resolve → 4xx; trade on resolved → 400
2 /redeem route curl: winner redeems → USDC up by token count; loser → 0
3 Wallet picker: add operator #0 UI shows admin entry; #0 hides TradePanel
4 Market page: ResolvePanel + RESOLVED badge resolve via UI; badge + chart end-state
5 Portfolio page + nav + Redeem buttons buy on #1 → portfolio shows position; resolve → redeem → balance check

End-to-end demo script (the acceptance test): wallet #1 buys YES on a market → operator #0 resolves YES on the market page → wallet #1’s portfolio shows the win → Redeem → USDC balance increases by the token count. All on the running local stack.

Out of scope