// Live ledger (Marty 2026-11-13): /api/ledger, refreshed every 20 s. One row per spot sale: buyer, every member paid, company + fund. (async () => { BL.renderNav('/ledger'); BL.renderFooter(); const { $, esc, fmtPol, short } = BL; const who = (name, addr) => name ? '@' + esc(name) : '' + esc(short(addr)) + ''; const usd = (wei, rate) => rate ? ' ($' + (Number(BigInt(wei) / 10n ** 12n) / 1e6 * rate).toFixed(2) + ')' : ''; const KIND = { 0: 'bought by', 1: 'bought for', 2: 'gifted by the momentum fund to', 3: 'kept by the momentum fund' }; async function load() { const d = await BL.getJSON('/api/ledger?n=100'); if (d.error) return; const t = d.totals || {}; $('totals').innerHTML = [['Spots sold', t.spots || 0], ['Members', t.members || 0], ['POL paid out by the contract', fmtPol(t.paidOutWei || '0', 2)], ['Momentum fund', t.fundWei ? fmtPol(t.fundWei, 2) + ' POL' : '-']] .map(x => '
' + esc(x[1]) + '' + esc(x[0]) + '
').join(''); $('rows').innerHTML = d.items.length ? d.items.map(it => { const when = it.at ? new Date(it.at).toLocaleString() : ''; const pays = it.pays.map(p => '
  • ' + (p.failed ? 'Bounced (to the fund): ' : '') + (p.role === 'sponsor' ? 'Sponsor' : 'Line ' + p.level + ' (spot #' + (it.spotId - p.level) + ')') + ': ' + fmtPol(p.wei) + ' POL' + usd(p.wei, it.usd) + ' to ' + who(p.name, p.to) + '
  • ').join(''); return '
    Spot #' + it.spotId + ' ' + esc(KIND[it.kind] || '') + ' ' + who(it.ownerName, it.owner) + ' $5 = ' + fmtPol(it.valueWei) + ' POL
    ' + esc(when) + '
    ' + (pays ? '' : '

    No earlier spots or sponsor to pay yet.

    ') + '

    Company + momentum fund: ' + fmtPol(it.houseWei) + ' POL' + usd(it.houseWei, it.usd) + ' · Verify on Polygonscan

    '; }).join('') : '

    No spot sales yet.

    '; $('upd').textContent = 'Updated ' + new Date().toLocaleTimeString(); } await load(); setInterval(load, 20000); })();