P&L: Game payouts card, an all-time running total of every game wallet's payouts read from Polygon (incremental, cached); PolHunter ledger detail folded under it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-18 07:11:25 -05:00
parent 017017ad63
commit 34a1de0b15
4 changed files with 70 additions and 8 deletions
+17 -1
View File
@@ -762,7 +762,23 @@
+ '<tr><td class="muted small">Hunters paid</td><td class="mono">' + Number(t.hunters || 0) + '</td><td class="muted small">today ' + Number(t.today || 0).toFixed(3) + ' POL</td></tr>';
}
}
$('pnlSplit').innerHTML = '<tr><th>Line</th><th>POL</th><th>USD now</th></tr>'
// every game's payouts, all time, running total (Marty, 2026-10-18). PassiveDrip is a drip
// program rather than a game, so it sits under the total instead of inside it.
const ga = r.gamesAll, gaEl = $('pnlGames');
if (gaEl) {
if (!ga || ga.error || !Array.isArray(ga.games) || !ga.games.length) gaEl.innerHTML = '<tr><td colspan="4" class="muted small">' + (ga && ga.scanning ? 'Reading the game wallets from Polygon for the first time. Refresh in a minute.' : 'Game payout figures unavailable' + (ga && ga.error ? ' (' + esc(ga.error) + ')' : '') + '.') + '</td></tr>';
else {
const wp = w => Number(BigInt(w) / 10n ** 12n) / 1e6, games = ga.games.filter(g => g.slug !== 'passivedrip'), pd = ga.games.find(g => g.slug === 'passivedrip');
const row = (name, w, n, pl, cls) => '<tr' + (cls ? ' class="' + cls + '"' : '') + '><td>' + name + '</td><td class="mono">' + wp(w).toFixed(4) + '</td><td class="mono">$' + (wp(w) * px).toFixed(2) + '</td><td class="mono small">' + Number(n).toLocaleString() + ' to ' + Number(pl).toLocaleString() + '</td></tr>';
const tw = games.reduce((t, g) => t + BigInt(g.wei), 0n), tn = games.reduce((t, g) => t + g.count, 0);
gaEl.innerHTML = '<tr><th>Game</th><th>POL</th><th>USD now</th><th>Payouts to players</th></tr>'
+ games.map(g => row(esc(g.name) + (g.error ? ' <span class="chip flat">stale</span>' : ''), g.wei, g.count, g.players)).join('')
+ '<tr><td><b>All game payouts</b></td><td class="mono"><b>' + wp(tw).toFixed(4) + '</b></td><td class="mono"><b>$' + (wp(tw) * px).toFixed(2) + '</b></td><td class="mono small">' + tn.toLocaleString() + ' payouts</td></tr>'
+ (pd ? row('<span class="muted">PassiveDrip (not a game)</span>', pd.wei, pd.count, pd.players) : '')
+ '<tr><td colspan="4" class="muted small">Read ' + (ga.at ? new Date(ga.at).toLocaleString('en-US', { timeZone: 'America/Chicago', hour: 'numeric', minute: '2-digit', month: 'short', day: 'numeric' }) + ' CT' : 'just now') + (ga.scanning ? ', refreshing' : '') + '. Updates every 10 minutes.</td></tr>';
}
}
$('pnlSplit').innerHTML ='<tr><th>Line</th><th>POL</th><th>USD now</th></tr>'
+ [['Level 1 (50%)', r.byTier[1]], ['Level 2 (20%)', r.byTier[2]], ['Level 3 (10%)', r.byTier[3]], ['Platform (20% + pass-ups)', r.platformWei]].map(x => '<tr><td>' + x[0] + '</td><td class="mono">' + pol(x[1]) + '</td><td class="mono">' + usdOf(x[1], px) + '</td></tr>').join('');
const W = r.wallets || {}, B = r.balances || {};
$('pnlWallets').innerHTML = '<tr><th>Wallet</th><th>Address</th><th>Balance</th></tr>'