Skip to content

Commit 8a4e8fd

Browse files
Leihynclaude
andcommitted
Fix: Use deterministic win rate for Limitless leaderboard
Replace Math.random() with position-based formula to ensure consistent scores between localhost and production. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 60b3563 commit 8a4e8fd

File tree

1 file changed

+9
-5
lines changed
  • frontend/app/api/limitless-leaderboard

1 file changed

+9
-5
lines changed

frontend/app/api/limitless-leaderboard/route.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,15 @@ export async function GET(request: NextRequest) {
351351
);
352352

353353
// Estimate win rate from position (top traders have higher win rates)
354-
const estimatedWinRate = trader.leaderboardPosition <= 1000
355-
? 65 + Math.random() * 15
356-
: trader.leaderboardPosition <= 10000
357-
? 55 + Math.random() * 15
358-
: 45 + Math.random() * 15;
354+
// Deterministic formula: higher position = higher estimated win rate
355+
const position = trader.leaderboardPosition;
356+
const estimatedWinRate = position <= 100
357+
? 75 + (100 - position) * 0.1 // 75-85% for top 100
358+
: position <= 1000
359+
? 65 + (1000 - position) * 0.01 // 65-75% for top 1000
360+
: position <= 10000
361+
? 55 + (10000 - position) * 0.001 // 55-65% for top 10000
362+
: 50 + Math.min(5, 50000 / position); // 50-55% for rest
359363

360364
const wins = Math.floor(trader.trades * (estimatedWinRate / 100));
361365
const losses = trader.trades - wins;

0 commit comments

Comments
 (0)