// Live ledger: every Boost with its split (resharer, sponsor levels, pot, company) and every sign-up reward, refreshed every 30 s. (function () { const $ = VAS.$, esc = VAS.esc; const pol = w => VAS.polOf(w) + ' POL'; const who = (a, nm) => nm ? '@' + esc(nm) : '' + esc(VAS.short(a || '')) + ''; async function load() { const d = await VAS.getJSON('/api/ledger?n=100').catch(() => null); if (!d || !d.items) return; const ex = d.explorer || 'https://polygonscan.com'; const t = d.totals || {}; $('ledStats').innerHTML = [[VAS.n(t.boosts), 'Boosts on chain'], [pol(t.resharerWei), 'paid to resharers'], [pol(t.potWei), 'added to the reward pot'], [VAS.n((d.rewards || []).filter(r => r.status === 'paid').length), 'sign-up rewards paid']].map(x => '
' + x[0] + '' + x[1] + '
').join(''); const tx = h => h ? 'verify' : ''; if (d.items.length) $('rows').innerHTML = d.items.map(r => { const lv = (r.pays || []).filter(p => p.kind >= 1 && p.kind <= 5).map(p => 'L' + p.kind + ' ' + pol(p.wei) + ' ' + who(p.to, p.name)).join('
') || 'no sponsor line'; const co = (r.pays || []).find(p => p.kind === 0); return '' + VAS.when(r.at) + '' + who(r.buyer, r.buyerName) + '' + VAS.usd(r.usdCents) + '
' + pol(r.weiPaid) + '' + (r.resharer ? who(r.resharer.to, r.resharer.name) + '
' + pol(r.resharer.wei) : 'none') + '' + lv + '' + pol(r.potWei) + '' + (co ? pol(co.wei) : '') + '' + tx(r.tx) + ''; }).join(''); $('payNote').textContent = d.payoutsOn ? '' : 'Payouts are switched off for now: verified rewards wait here as pending until the amounts are confirmed.'; if ((d.rewards || []).length) $('rrows').innerHTML = d.rewards.map(r => '' + VAS.when(r.at) + '' + (r.name ? '@' + esc(r.name) : esc(r.to)) + '' + (r.kind === 'tier' ? 'tier bonus' : 'new member') + '' + VAS.usd(r.cents) + '' + esc(r.status) + '' + (r.unlockAt && r.unlockAt > Date.now() ? '
withdrawable ' + VAS.when(r.unlockAt) + '' : '') + '' + tx(r.tx) + '').join(''); } VAS.wire('other').catch(() => {}); load(); setInterval(load, 30000); })();