Dollar value at today's POL price on the member's own pages (Marty, 2026-10-22, Brian's ask; US dollars, not a dollar token): /api/public/polusd serves the contract's own package rate (Chainlink POL/USD) cached 5 min on the server; Overview 'POL earned' shows '≈ $x.xx today', every Earnings line gets '≈ $x.xx', and a note under Earnings gives the rate, when it was updated, and that it is today's value, not the payout-day value. Browser re-reads at most every 2 min; no outside price service. QA member walk 0 bugs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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) {}
|
||||
|
||||
Reference in New Issue
Block a user