Files

25 lines
3.1 KiB
JavaScript

// Contract proof page (trust pack): live facts from /api/contract (read from Polygon, cached 5 minutes on the server).
(async function () {
FX.renderNav('/contract'); FX.renderFooter();
const el = document.getElementById('facts'); const esc = FX.esc;
let d; try { d = await FX.getJSON('/api/contract'); } catch (e) { d = {}; }
const ex = d.explorer || 'https://polygonscan.com';
const addr = (a, note) => a ? '<a href="' + esc(ex) + '/address/' + esc(a) + '" target="_blank" rel="noopener">' + esc(a) + '</a>' + (note ? '<br><span class="small">' + note + '</span>' : '') : '<span class="muted">not read yet</span>';
const sp = d.split || { sponsorPct: 25, levelPct: 5, potPct: 10, companyPct: 45, maxDepth: 20 };
const splitRow = ['The split', 'Sponsor ' + sp.sponsorPct + '%, levels 2 to 5 ' + sp.levelPct + '% each, Best Coach pot ' + sp.potPct + '%, 5xYourTeam ' + sp.companyPct + '%. Someone in the line with no position is passed over and the share goes up to the next person who holds one, up to ' + sp.maxDepth + ' places. Fixed in the code: no setter can change it.'];
if (!d.address) { el.innerHTML = '<tbody><tr><th>Status</th><td class="muted">The contract is not live yet. Its address, owner, prize pot wallet and every position will show here, read straight from Polygon.</td></tr><tr><th>' + splitRow[0] + '</th><td>' + splitRow[1] + '</td></tr></tbody>'; return; }
const rows = [
['Contract', addr(d.address, 'DraftPosition on ' + (d.chainId === 137 ? 'Polygon' : 'chain ' + d.chainId))],
['Source code', 'Verified source: Sourcify ' + esc(d.verified && d.verified.sourcify ? 'done' : 'pending') + ', Polygonscan ' + esc(d.verified && d.verified.polygonscan === 'done' ? 'done' : 'pending')],
['Owner', addr(d.owner, 'A Tangem hardware wallet. It can pause new sales, set the price of future positions and change the keeper. It cannot move anyone\'s money or change the split.')],
['Company', addr(d.company, '5xYourTeam. Fixed in the contract when it was deployed.')],
['Best Coach pot', addr(d.prizeWallet, 'Receives 10% of every position in the same transaction. Fixed in the contract when it was deployed. Each payout from it is listed on the ledger.')],
['Keeper', addr(d.keeper, 'The site\'s signing key. It only signs a buyer\'s sponsor line from the network hub, once, on their first position.')],
splitRow,
['Position', '$' + esc(d.position && d.position.usd) + ' one-time, paid in POL at the live Chainlink price' + (d.priceCents ? ' (contract price: $' + (d.priceCents / 100).toFixed(2) + ')' : '')],
['Sales', d.live ? (d.paused ? '<b>Paused</b>' : 'Open') + ' · ' + FX.n(d.orderCount) + ' orders so far' : '<span class="muted">' + esc(d.error || 'not read yet') + '</span>'],
['Held by the contract', d.live ? FX.polOf(d.balanceWei) + ' POL' + (BigInt(d.totalOwedWei || 0) > 0n ? ' (all of it owed to wallets whose payment bounced, waiting for them to claim)' : ' (nothing is kept: every position is paid out in the same transaction)') : '<span class="muted">not read yet</span>']
];
el.innerHTML = '<tbody>' + rows.map(r => '<tr><th>' + r[0] + '</th><td>' + r[1] + '</td></tr>').join('') + '</tbody>';
})();