06daa4ef0a
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
3.4 KiB
JavaScript
39 lines
3.4 KiB
JavaScript
// "Facts so you learn as you play" (SkyCash, 2026-09-30). Every number comes from InstantAdPay's live
|
||
// catalog (price in cents, credits, and the POL the contract quotes right now), never typed in, so the
|
||
// tips stay true as POL moves. Cached ten minutes; with no catalog only the price-free tips show.
|
||
'use strict';
|
||
const IAP = () => String(process.env.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, '');
|
||
const RATES = { visitCost: 3, featuredPerDay: 40 }; // IAP ads.js rates (visitCostPerVisit, featuredPerDay)
|
||
let cache = { at: 0, products: [] };
|
||
const fmt = n => Number(n).toLocaleString('en-US', { maximumFractionDigits: n < 10 ? 2 : 0 });
|
||
|
||
async function catalog() {
|
||
if (Date.now() - cache.at < 10 * 60000) return cache.products;
|
||
try {
|
||
const r = await fetch(IAP() + '/api/catalog', { signal: AbortSignal.timeout(6000) }); const j = await r.json();
|
||
const products = (j.products || []).filter(p => p.active && p.exists).map(p => ({ usd: p.priceCents / 100, credits: Number(p.creditAmount), pol: Number(BigInt(p.costWei) / 10n ** 12n) / 1e6 })).filter(p => p.pol > 0);
|
||
if (products.length) cache = { at: Date.now(), products };
|
||
} catch (e) { if (!cache.products.length) cache.at = Date.now() - 9 * 60000; } // retry in a minute
|
||
return cache.products;
|
||
}
|
||
|
||
async function list(settings) {
|
||
const ps = await catalog(); const by = usd => ps.find(p => p.usd === usd);
|
||
const p5 = by(5), p20 = by(20), p100 = by(100); const th = Number(settings.thresholdPol), drip = Number(settings.dripPol);
|
||
const tips = [
|
||
'Every refuel is a verified visit an advertiser paid for on InstantAdPay. A share of it funds everyone’s chapter drips.',
|
||
'Shield Core and Slow Field cost POL from your game balance, and that POL goes straight back into the pool.',
|
||
'Your game balance pays out at ' + fmt(th) + ' POL, to the wallet on your InstantAdPay account. Link one under Wallet if you have not.',
|
||
'Only the first clear of a chapter pays a drip (' + fmt(drip) + ' POL). Replays are for practice and for drips to spend in the hangar.',
|
||
'Your first $20 buyer on InstantAdPay pays you 50 percent. Your second opens level 2: 20 percent of everything their people buy.',
|
||
'InstantAdPay packages are bought with POL and pay your sponsor on the spot, on chain. Nothing to withdraw, nothing to wait for.',
|
||
'Share your Drip Runner link from the lobby. When the people you bring in refuel, ' + (Number(settings.refSharePct) || 0) + ' percent of what each refuel adds to the pool goes to your game balance.',
|
||
];
|
||
if (p20) tips.push('A $20 InstantAdPay package is about ' + fmt(p20.pol) + ' POL today. Half of it goes to the sponsor, on chain, the moment it is bought.');
|
||
if (p5) tips.push('$5 on InstantAdPay is ' + fmt(p5.credits) + ' credits, about ' + fmt(p5.pol) + ' POL today. That runs ' + Math.floor(p5.credits / RATES.visitCost) + ' verified visits to your own page.');
|
||
if (p5) tips.push('A Featured ad on InstantAdPay is ' + RATES.featuredPerDay + ' credits a day. A $5 pack keeps you featured for ' + Math.floor(p5.credits / RATES.featuredPerDay) + ' days.');
|
||
if (p100 && p100.credits > p100.usd * 100) tips.push('The $100 InstantAdPay pack is ' + fmt(p100.credits) + ' credits for about ' + fmt(p100.pol) + ' POL today: ' + fmt(p100.credits - p100.usd * 100) + ' bonus credits on top of the ' + fmt(p100.usd * 100) + ' you paid for.');
|
||
return tips;
|
||
}
|
||
module.exports = { list, catalog };
|