Commit 7b7c1de
committed
feat: Polymarket daily sports play + dailyPlayPicks scoreboard + Coinbase scaffold + CodeRabbit fixes
Implements the plan in /root/.claude/plans/sparkling-churning-dusk.md.
Targets the user's stated goal of arming live trading on both prediction
platforms while tracking the bot's daily sports-pick win/loss record.
Phase 0 — CodeRabbit correctness fixes (BLOCKING)
- kalshiSignals.calculateSignalPerformance: lazy-init each SignalType so
newly added types (linguistic_tell, wikipedia_edit) no longer crash on
the non-null assertion. Regression test added.
- wikipediaEditWatcher: breaker tightened to 30s/30s (CLAUDE.md profile),
cursor advance is now monotonic (no rollback on overlapping polls),
matchSignalsToMarkets gates by category when both sides expose it
(kills "musk" → music false positives). New regression tests.
- grokPersonas: getGrokPersona preserves caller's category;
${RULES_BLOCK} placeholder removed from cached mandate so
injectVerbatimRulesBlock remains the only splice path.
- linguistic-tells test: cap assertion tightened to 0.92.
Phase 1 — Polymarket Daily Sports Play (new)
- server/_core/polymarketDailySportsPlay.ts mirrors dailySportsPlay.ts.
Reuses operator's existing tradingPreferences gates so a single
liveTradingEnabled toggle arms BOTH Kalshi and Polymarket daily plays.
Sized 2.5% of bankroll (Kalshi capital proxy until USDC.e poll lands).
Filters Polymarket sports markets via category literal OR classifier
fallback (Polymarket's category strings are messier than Kalshi's).
AI-reviewed via reviewPolymarketSignalsWithTrader; full risk-gate
stack inline (existing position, drawdown breaker, portfolio + per-
category exposure caps). Per-user mutex wraps placement.
Phase 2 — dailyPlayPicks lifecycle table
- New table tracks each daily-play pick from entry to resolution across
BOTH platforms. Unique index on (userId, platform, playType, playDate)
makes inserts idempotent at the DB level.
- server/db.daily-play-picks.ts: insertDailyPlayPick (ON CONFLICT DO
NOTHING), linkPositionToPick, closeDailyPlayPickByPosition,
closeDailyPlayPickByMarketFallback, getDailyPlayPicks,
getTodayDailyPlayPicks, rollupScoreboard.
Phase 3 — Scheduler wiring
- maybeRunPolymarketDailySportsPlay added next to the Kalshi version,
same 5-min tick + per-user dedup (in-process Set + audit-log).
Phase 4 — Close-hook side effects
- closeKalshiPosition (Kalshi live + paper) closes matching daily picks
- polymarketPositionSync drift-close updates picks with estimated
exit price (snapshot mark) — flagged in audit
- paperTrading polymarket close closes matching paper picks
- upsertPolymarketPosition closes picks on transition-to-closed
(defensive — drift-close is the primary detector)
Phase 5 — tRPC daily.* namespace
- daily.getDailyPlayScoreboard returns today's picks + 30-day rollup +
lifetime win-rate by platform (Kalshi vs Polymarket).
- daily.getTodayDailyPlay returns today's row(s) only.
Phase 6 — Daily Pick Scoreboard widget
- client/src/components/widgets/DailyPlayScoreboard.tsx: 3-row compact
card (today's picks + last 30d split + lifetime tally) with per-day
table in full mode. Mounted on Dashboard.tsx after the equity chart.
Phase 7 — env vars
- ENABLE_POLYMARKET_DAILY_SPORTS_PLAY (default true)
- POLYMARKET_DAILY_SPORTS_PLAY_HOUR_UTC (default 14)
- POLYMARKET_DAILY_SPORTS_PLAY_PCT_OF_CAPITAL (default 0.025)
- ENABLE_COINBASE_LIVE (default false), COINBASE_SANDBOX_MODE (true)
Phase 8/9 — Operator pre-arm checklist + verification doc
- docs/POLYMARKET_DAILY_PLAY_VERIFICATION.md walks through every Railway
env var, per-user trading pref, funding step, self-test check, and an
11-step paper→live smoke test sequence.
Phase 10 — Coinbase scaffolding (architectural ONLY)
- drizzle/migrations/0014_coinbase_scaffold.sql + schema exports for
coinbaseCredentials, coinbaseOrders, coinbasePositions, coinbaseCapital
- server/_core/coinbaseAuth.ts (format validation only, balance fetch
stubbed), server/_core/coinbaseExecution.ts (THROWS on every call —
inert until Phase 10 build-out lands)
- server/db.coinbase-credentials.ts mirrors Polymarket creds (AES-GCM)
- coinbase.* tRPC namespace (connect/status/disconnect)
- CoinbaseConnectPanel on Connect.tsx — operator can connect now to be
ready when instruments + signal sources are decided
Verification: 1009 tests passing (up from 1002), typecheck clean.
https://claude.ai/code/session_01To82bdNQsUtCeAyGJFLQc31 parent 090cd34 commit 7b7c1de
28 files changed
Lines changed: 2740 additions & 25 deletions
File tree
- client/src
- components/widgets
- pages
- docs
- drizzle
- migrations
- server
- _core
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
0 commit comments