diff --git a/public/assets/my.js b/public/assets/my.js index 25d0989..0e2391b 100644 --- a/public/assets/my.js +++ b/public/assets/my.js @@ -686,6 +686,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str $('dbCredits').textContent = ((d.credits || 0) + earnedAv).toLocaleString(); $('dbCreditsSub').textContent = (d.credits || 0).toLocaleString() + ' purchased' + (d.creditedCredits ? ' (' + d.creditedCredits.toLocaleString() + ' credited to you)' : '') + ' · ' + earnedAv.toLocaleString() + ' earned' + (inCamp ? ' · ' + inCamp.toLocaleString() + ' in campaigns' : ''); $('dbEarned').textContent = IAP.fmtPol(d.earnedWei || '0'); + usdRate().then(r => { const el = $('dbEarnedUsd'); if (el) el.textContent = r.usd > 0 && d.earnedWei && d.earnedWei !== '0' ? usdOf(d.earnedWei, r) + ' today' : ''; }); $('dbBuyers').textContent = d.buyerCount || 0; if (d.buyerCountPositions) { const sub = $('dbBuyersSub'); if (sub) sub.textContent = '+' + d.buyerCountPositions + ' on your linked positions (count toward badges; levels pay on your main position)'; } $('dbTeam').textContent = (d.referrals || []).length; // trend chips: only real, computable facts @@ -939,6 +940,24 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str } } + // Dollar value at today's POL price (Marty, 2026-10-22): one cached rate from our own server (5 min there, 2 min here), + // shown as "≈ $x.xx" next to POL amounts on the member's own pages. It is today's value, not the value on the payout day. + let USD = null; + async function usdRate() { + if (USD && Date.now() - USD.got < 120000) return USD; + try { const r = await (await fetch('/api/public/polusd')).json(); USD = { usd: Number(r.usd) || 0, at: Number(r.at) || Date.now(), got: Date.now() }; } catch (e) { USD = USD || { usd: 0, at: 0, got: Date.now() }; } + return USD; + } + function usdOf(wei, r) { + let pol = 0; try { pol = Number(BigInt(wei || '0') / 10n ** 12n) / 1e6; } catch (e) {} + const v = pol * ((r && r.usd) || 0); + return '≈ $' + v.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }); + } + function usdNote(r) { + if (!r || !(r.usd > 0)) return ''; + const mins = Math.max(0, Math.round((Date.now() - r.at) / 60000)); + return '1 POL ≈ $' + r.usd.toLocaleString('en-US', { minimumFractionDigits: 4, maximumFractionDigits: 4 }) + ' at today’s price (updated ' + (mins < 1 ? 'just now' : mins + ' min ago') + '). Dollar amounts are what the POL is worth today, not on the day it was paid.'; + } async function loadActivity() { try { const c = await IAP.getConfig(); @@ -950,6 +969,12 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str for (const ev of evs) el.appendChild(IAP.feedRow(ev, c)); }; fill('earnFeed', a.earnings, 'No payouts yet. They appear here the moment one lands.'); + usdRate().then(r => { + const note = $('earnUsdNote'); if (note) note.textContent = usdNote(r); + if (!(r.usd > 0)) return; + const rows = $('earnFeed').querySelectorAll('.row'); let i = 0; + for (const ev of (a.earnings || [])) { const row = rows[i++]; if (!row || !ev.amountWei) continue; const s = document.createElement('span'); s.className = 'usd muted small'; s.textContent = usdOf(ev.amountWei, r); const tx = row.querySelector('.tx'); row.insertBefore(s, tx || null); } + }); fill('refFeed', a.referrals, 'No referral activity yet. Share your invite link.'); fill('buyFeed', a.purchases, 'No purchases from your wallet yet.'); } catch (e) {} diff --git a/public/my.html b/public/my.html index c242e3e..358b341 100644 --- a/public/my.html +++ b/public/my.html @@ -196,7 +196,7 @@
Every payout the contract has sent to your wallet. Each line links to the transaction.
+