Reward tiers off by default (flat $0.25 at launch); hub-blocked sponsors are skipped (pass-up)
- config: REWARD_TIERS defaults to none (the every-25th $2.50 tier stays available as a setting); the "bigger tiers" sentence only shows when a tier is configured. - hubline: the walk reads the raw hub answer so it continues past a blocked sponsor instead of stopping; entries carry `blocked`. /api/my/order skips blocked members like no-wallet ones, so the level passes up. - e2e: B -> no-wallet -> hub-blocked (with a wallet) -> O -> S: both skipped, O and S each get 10%, the blocked one gets nothing; tiers off checked. 63/63. Chatbot QA 108/108. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,11 +7,11 @@ Launch numbers APPROVED by Marty 2026-11-17: Boost $5 = a 7-day board spot (plac
|
||||
their branch (paid by the contract in the same tx); reward pot 10% of every Boost; 5 sponsor levels x 10% (company keeps 20%); split
|
||||
immutable on chain; new-member reward $0.25 in POL per verified brand-new network member through a branch, cap 10/day per person;
|
||||
10 ad credits per 100 verified views. Still proposals: the global pot cap figure ($25/day, `POT_DAILY_CENTS` display + the contract's
|
||||
`potDailyMaxCents`) and the tier bonus (every 25th sign-up $2.50 locked 14 days). Payouts of sign-up rewards are OFF on staging
|
||||
`potDailyMaxCents`). Reward tiers are OFF at launch (flat $0.25 only; `REWARD_TIERS` can turn one on later). Payouts of sign-up rewards are OFF on staging
|
||||
(`REWARD_PAYOUTS`).
|
||||
|
||||
**Members earn for free.** A Boost buys placement only. Level shares and the resharer cut need only a network sign-in (hub member) and a
|
||||
linked wallet. Compression: `/api/my/order` drops everyone in the hub sponsor line without a wallet, so each level passes up to the next
|
||||
linked wallet. Compression: `/api/my/order` drops everyone in the hub sponsor line without a wallet or hub-blocked, so each level passes up to the next
|
||||
eligible person; levels left when the line runs out go to the company; with no resharer, the 20% resharer cut goes to the company.
|
||||
|
||||
## What it does
|
||||
@@ -59,7 +59,7 @@ eligible person; levels left when the line runs out go to the company; with no r
|
||||
npm install
|
||||
node tools/pages.mjs # regenerate public/*.html (one source of copy + legal facts)
|
||||
node tools/art.mjs # icon, OG image, proof cards, kit creatives (Playwright)
|
||||
node qa/e2e.mjs # 61 checks: real VASShop on a local anvil chain + stand-in hub (needs ../contracts built)
|
||||
node qa/e2e.mjs # 63 checks: real VASShop on a local anvil chain + stand-in hub (needs ../contracts built)
|
||||
node qa/chatbot.test.mjs # the site assistant
|
||||
```
|
||||
Env: `.env.example`.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
// Launch numbers APPROVED by Marty 2026-11-17: Boost $5 = a 7-day board spot; resharer 20%, pot 10%, 5 sponsor levels x 10%
|
||||
// (company 20%), split immutable on chain; $0.25 POL new-member reward, 10 a day per person; 10 ad credits per 100 verified views.
|
||||
// Members earn for free: a Boost buys placement only. Level shares and the resharer cut need a network sign-in + a linked wallet.
|
||||
// Still a proposal: the $25/day global pot cap figure and the reward tiers.
|
||||
// Still a proposal: the $25/day global pot cap figure. Reward tiers are OFF at launch (flat $0.25 only, Marty 2026-11-17).
|
||||
const path = require('path');
|
||||
|
||||
let cfg = null;
|
||||
@@ -22,7 +22,10 @@ function get() {
|
||||
const addr = v => /^0x[0-9a-fA-F]{40}$/.test(String(v || '').trim()) ? require('ethers').getAddress(String(v).trim().toLowerCase()) : '';
|
||||
let tiers = [];
|
||||
try { tiers = JSON.parse(e.REWARD_TIERS || '[]'); } catch (x) { tiers = []; }
|
||||
if (!Array.isArray(tiers) || !tiers.length) tiers = [{ every: 25, cents: 250, lockDays: 14 }]; // PROPOSAL (not yet approved): each 25th verified sign-up from one resharer = a $2.50 bonus, withdrawable after 14 days
|
||||
// Tiers are OFF by default: launch pays the flat reward only (Marty 2026-11-17). To turn the idea on later, set e.g.
|
||||
// REWARD_TIERS=[{"every":25,"cents":250,"lockDays":14}] (each 25th verified sign-up from one resharer = a $2.50 bonus, withdrawable after 14 days).
|
||||
if (!Array.isArray(tiers)) tiers = [];
|
||||
tiers = tiers.filter(t => t && Number(t.every) > 0 && Number(t.cents) > 0);
|
||||
cfg = {
|
||||
port: Number(e.PORT || 3000),
|
||||
isProd: e.NODE_ENV === 'production',
|
||||
|
||||
+5
-2
@@ -15,10 +15,13 @@ async function walk(person, max) {
|
||||
for (let depth = 1; depth <= max; depth++) {
|
||||
if (!p.sponsor || !p.sponsor.id) return { ok: true, line };
|
||||
if (seen.has(p.sponsor.id)) return { ok: true, line, loop: true }; // a loop in the hub data: stop
|
||||
const r = await hubpeople.sponsorOf(p); if (!r.ok) return { ok: false, line };
|
||||
// the raw hub answer (blocked people included) so the walk goes on past a blocked sponsor; callers skip `blocked` entries
|
||||
// (Boost orders: a blocked member earns nothing and the level passes up, Marty 2026-11-17)
|
||||
if (!/^h_[0-9a-f]{16}$/.test(String(p.sponsor.id))) return { ok: true, line };
|
||||
const r = await hubpeople.resolve({ id: String(p.sponsor.id) }); if (!r.ok) return { ok: false, line };
|
||||
if (!r.person) return { ok: true, line };
|
||||
seen.add(r.person.id);
|
||||
line.push({ depth, id: r.person.id, username: r.person.username ? String(r.person.username) : null, wallet: hubpeople.wallet(r.person) });
|
||||
line.push({ depth, id: r.person.id, username: r.person.username ? String(r.person.username) : null, wallet: hubpeople.wallet(r.person), blocked: !!r.person.blocked });
|
||||
p = r.person;
|
||||
}
|
||||
return { ok: true, line };
|
||||
|
||||
@@ -115,7 +115,7 @@ window.VAS = (function () {
|
||||
const tier = (rw.tiers || [])[0] || {};
|
||||
const V = { cut: VAS.pct(sp.resharerBps), pot: VAS.pct(sp.potBps), levels: lvTxt, signup: VAS.usd(rw.cents), cap: String(rw.dailyCap), lockDays: String(tier.lockDays || 14),
|
||||
creditsPer: String(cr.per), creditsViews: String(cr.views), boostDays: String(b.days), boostUsd: '$' + b.usd, headline: String((c.ad || {}).headline || 60),
|
||||
proposalTag: '', proposalNote: '',
|
||||
proposalTag: '', proposalNote: '', tiersNote: tier.every ? 'Bigger tiers are credited at once and withdrawable after ' + (tier.lockDays || 14) + ' days.' : '',
|
||||
payoutsNote: rw.payouts ? '' : 'Sign-up reward payouts are switched off for now: verified rewards wait in the pending ledger.' };
|
||||
document.querySelectorAll('[data-cfg]').forEach(el => { const k = el.dataset.cfg; if (V[k] != null) el.textContent = V[k]; });
|
||||
}).catch(() => {});
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@
|
||||
<p>The buyer came in through your reshare link. The contract pays you <span data-cfg="cut">20%</span> of that Boost in POL in the same transaction as the sponsor line. Nobody holds it; anyone can check it on Polygonscan.</p></div>
|
||||
<div class="card-ink c2"><img src="/art/icons/verify-shield-check.svg" alt="" width="34" height="34"><p class="step">Level 2 · POL from the reward pot</p>
|
||||
<h3>A verified new member from your branch</h3>
|
||||
<p>Someone brand new to the whole network joins through your link and confirms their email. Once the checks pass, <span data-cfg="signup">$0.25</span> in POL is paid from the reward pot to your wallet, up to <span data-cfg="cap">10</span> a day. Bigger tiers are credited at once and withdrawable after <span data-cfg="lockDays">14</span> days.</p>
|
||||
<p>Someone brand new to the whole network joins through your link and confirms their email. Once the checks pass, <span data-cfg="signup">$0.25</span> in POL is paid from the reward pot to your wallet, up to <span data-cfg="cap">10</span> a day. <span data-cfg="tiersNote"></span></p>
|
||||
<p data-cfg="payoutsNote" class="mono" style="font-size:13px"></p></div>
|
||||
<div class="card-ink c3"><img src="/art/icons/ledger-list.svg" alt="" width="34" height="34"><p class="step">Level 3 · ad credits</p>
|
||||
<h3>Real views from your branch</h3>
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
<p>The buyer came in through your reshare link. The contract pays you <span data-cfg="cut">20%</span> of that Boost in POL in the same transaction as the sponsor line. Nobody holds it; anyone can check it on Polygonscan.</p></div>
|
||||
<div class="card-ink c2"><img src="/art/icons/verify-shield-check.svg" alt="" width="34" height="34"><p class="step">Level 2 · POL from the reward pot</p>
|
||||
<h3>A verified new member from your branch</h3>
|
||||
<p>Someone brand new to the whole network joins through your link and confirms their email. Once the checks pass, <span data-cfg="signup">$0.25</span> in POL is paid from the reward pot to your wallet, up to <span data-cfg="cap">10</span> a day. Bigger tiers are credited at once and withdrawable after <span data-cfg="lockDays">14</span> days.</p>
|
||||
<p>Someone brand new to the whole network joins through your link and confirms their email. Once the checks pass, <span data-cfg="signup">$0.25</span> in POL is paid from the reward pot to your wallet, up to <span data-cfg="cap">10</span> a day. <span data-cfg="tiersNote"></span></p>
|
||||
<p data-cfg="payoutsNote" class="mono" style="font-size:13px"></p></div>
|
||||
<div class="card-ink c3"><img src="/art/icons/ledger-list.svg" alt="" width="34" height="34"><p class="step">Level 3 · ad credits</p>
|
||||
<h3>Real views from your branch</h3>
|
||||
|
||||
+11
-5
@@ -6,7 +6,8 @@
|
||||
// the family tree sums it up; sign-ups through R2's link: a clean one passes every check (pending reward + keeper voucher),
|
||||
// a throwaway email is rejected, R2's own device is rejected, someone already in the network is rejected;
|
||||
// B arrives through R1's link and buys a Boost: the contract pays R1 the resharer cut, the pot, the company, to the wei, and the
|
||||
// sponsor levels with no Boost needed: B's hub line is B -> X (no wallet, not eligible) -> O -> S, so X is skipped (compression)
|
||||
// sponsor levels with no Boost needed: B's hub line is B -> X (no wallet) -> BL (hub-blocked, has a wallet) -> O -> S, so X and BL
|
||||
// are skipped (compression)
|
||||
// and O gets level 1, S level 2; levels 3..5 have nobody and go to the company;
|
||||
// rewards relay (payouts ON in this test only): claimReward pays R2 from the pot; a replay is refused by the contract;
|
||||
// the staging test switch works on a staging host and is refused on the real domain.
|
||||
@@ -46,7 +47,7 @@ http.createServer(async (q, r) => {
|
||||
const all = [...people.entries()];
|
||||
const w = j.wallet ? String(j.wallet).toLowerCase() : j.id ? (all.find(([, p]) => p.id === j.id) || [])[0] : j.ref ? (all.find(([a, p]) => a === String(j.ref).toLowerCase() || p.username === String(j.ref).toLowerCase()) || [])[0] : null;
|
||||
const p = w && people.get(w); const sp = p && p.sponsor && people.get(p.sponsor);
|
||||
r.end(JSON.stringify({ person: p ? { id: p.id, username: p.username, wallet: p.noWallet ? null : w, blocked: false, sponsor: sp ? { id: sp.id, username: sp.username } : null } : null }));
|
||||
r.end(JSON.stringify({ person: p ? { id: p.id, username: p.username, wallet: p.noWallet ? null : w, blocked: !!p.blocked, sponsor: sp ? { id: sp.id, username: sp.username } : null } : null }));
|
||||
}).listen(HPORT, '127.0.0.1').unref();
|
||||
|
||||
// a browser: its own cookie jar and user agent (so its own visitor key)
|
||||
@@ -82,7 +83,9 @@ async function main() {
|
||||
people.set(lc(O), { id: 'h_' + '0'.repeat(16), username: 'owner', sponsor: lc(S) });
|
||||
people.set(lc(R1), { id: 'h_' + '1'.repeat(16), username: 'reshareone', sponsor: lc(S) });
|
||||
people.set(lc(R2), { id: 'h_' + '2'.repeat(16), username: 'resharetwo', sponsor: lc(R1) });
|
||||
people.set('x-no-wallet', { id: 'h_' + 'c'.repeat(16), username: 'nowallet', sponsor: lc(O), noWallet: true }); // a hub member with no linked wallet
|
||||
const BL = ethers.Wallet.createRandom().address.toLowerCase(); // a hub-blocked member WITH a wallet
|
||||
people.set(BL, { id: 'h_' + 'd'.repeat(16), username: 'blockedone', sponsor: lc(O), blocked: true });
|
||||
people.set('x-no-wallet', { id: 'h_' + 'c'.repeat(16), username: 'nowallet', sponsor: BL, noWallet: true }); // a hub member with no linked wallet
|
||||
people.set(lc(B), { id: 'h_' + 'b'.repeat(16), username: 'buyerb', sponsor: 'x-no-wallet' });
|
||||
|
||||
const art = n => JSON.parse(fs.readFileSync(path.join(ART, n + '.sol', n + '.json'), 'utf8'));
|
||||
@@ -166,17 +169,20 @@ async function main() {
|
||||
const y = (await admin('/api/admin/signups')).signups.find(z => z.email === e); ok(y.status === 'rejected' && y.fail.includes(want), 'rejected: ' + want, y);
|
||||
}
|
||||
|
||||
{ const cfgJ = await (await fetch(BASE + '/api/config')).json(); const tierRows = (await admin('/api/admin/rewards')).rewards.filter(x => x.kind === 'tier');
|
||||
ok(Array.isArray(cfgJ.reward.tiers) && cfgJ.reward.tiers.length === 0 && tierRows.length === 0, 'reward tiers are off by default (flat $0.25 only)', cfgJ.reward); }
|
||||
console.log('\n-- Boost through R1\'s branch, to the wei');
|
||||
await cB.post('/api/my/ad', { headline: 'Buyer ad for testing here', line1: 'A line about it', link: 'https://example.org/b' });
|
||||
await cB.get('/s/' + s1.j.code); // B came through R1's reshare link
|
||||
const od = await cB.post('/api/my/order', { qty: 1 }); ok(od.j.to === CA && od.j.resharer === lc(R1) && od.j.line === 2 && od.j.resharerName === 'reshareone', 'signed order names R1 and the 2-wallet line (the no-wallet member is skipped)', od.j);
|
||||
const od = await cB.post('/api/my/order', { qty: 1 }); ok(od.j.to === CA && od.j.resharer === lc(R1) && od.j.line === 2 && od.j.resharerName === 'reshareone', 'signed order names R1 and the 2-wallet line (the no-wallet and the blocked member are skipped)', od.j);
|
||||
const rc = await (await B.sendTransaction({ to: od.j.to, data: od.j.data, value: od.j.value })).wait();
|
||||
const bal = (a, t) => provider.getBalance(a, t == null ? rc.blockNumber : t);
|
||||
const [c0, r10, o0, s0, b0] = await Promise.all([company, R1.address, O.address, S.address, B.address].map(a => bal(a, rc.blockNumber - 1)));
|
||||
const price = BigInt(od.j.wei); const res = price * 2000n / 10000n, pot = price * 1000n / 10000n, lvl = price * 1000n / 10000n;
|
||||
const [c1, r11, o1, s1b, b1] = await Promise.all([company, R1.address, O.address, S.address, B.address].map(a => bal(a)));
|
||||
ok(r11 - r10 === res, 'R1 got exactly 20% (' + ethers.formatEther(res) + ' POL)', (r11 - r10).toString());
|
||||
ok(o1 - o0 === lvl && s1b - s0 === lvl, 'O (level 1) and S (level 2) each got exactly 10% without ever buying a Boost (compression over the no-wallet member)', { o: (o1 - o0).toString(), s: (s1b - s0).toString() });
|
||||
ok(o1 - o0 === lvl && s1b - s0 === lvl, 'O (level 1) and S (level 2) each got exactly 10% without ever buying a Boost (compression over the no-wallet and the blocked member)', { o: (o1 - o0).toString(), s: (s1b - s0).toString() });
|
||||
ok((await provider.getBalance(BL)) === 0n, 'the blocked member got nothing');
|
||||
ok((await shopC.boostsBought(O.address)) === 0n && (await shopC.boostsBought(S.address)) === 0n, 'neither sponsor has bought a Boost');
|
||||
ok(c1 - c0 === price - res - pot - 2n * lvl, 'company got 20% + the 3 empty levels (50% in all)', (c1 - c0).toString());
|
||||
ok(b0 - b1 === price + rc.gasUsed * rc.gasPrice, 'the 1% overpay came back in the same transaction');
|
||||
|
||||
@@ -460,10 +460,10 @@ const server = http.createServer(async (req, res) => {
|
||||
const a = store.adOf(me); if (!a || a.status !== 'live') return json(res, 400, { error: 'Post your text ad first. A Boost is for your ad.' });
|
||||
const lo = await hubline.lineOf({ wallet: me }, shop.MAX_LINE);
|
||||
if (!lo.ok) return json(res, 503, { error: 'Your sponsor line could not be checked with the network just now. Try again in a minute, so your team gets paid.' });
|
||||
// eligibility (Marty 2026-11-17): a network member (hub) with a linked wallet earns a level, Boost or not. Dropping the
|
||||
// eligibility (Marty 2026-11-17): a network member (hub, not blocked) with a linked wallet earns a level, Boost or not. Dropping the
|
||||
// ineligible here IS the compression: each level passes up to the next eligible person; the contract pays places 1..5 and
|
||||
// whatever levels are left when the line runs out go to the company
|
||||
const line = lo.line.filter(x => x.wallet && x.wallet !== me).map(x => x.wallet);
|
||||
const line = lo.line.filter(x => x.wallet && !x.blocked && x.wallet !== me).map(x => x.wallet);
|
||||
// the resharer whose branch sold it: the reshare link this buyer came through (last touch), never the buyer
|
||||
const via = viaOf(req); const vs = via ? store.share(via.code) : null;
|
||||
const resharer = vs && vs.step > 0 && vs.owner !== me ? vs.owner : null;
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ const REWARDS = `
|
||||
<p>The buyer came in through your reshare link. The contract pays you ${cfg('cut', '20%')} of that Boost in POL in the same transaction as the sponsor line. Nobody holds it; anyone can check it on Polygonscan.</p></div>
|
||||
<div class="card-ink c2">${I('verify-shield-check')}<p class="step">Level 2 · POL from the reward pot</p>
|
||||
<h3>A verified new member from your branch</h3>
|
||||
<p>Someone brand new to the whole network joins through your link and confirms their email. Once the checks pass, ${cfg('signup', '$0.25')} in POL is paid from the reward pot to your wallet, up to ${cfg('cap', '10')} a day. Bigger tiers are credited at once and withdrawable after ${cfg('lockDays', '14')} days.</p>
|
||||
<p>Someone brand new to the whole network joins through your link and confirms their email. Once the checks pass, ${cfg('signup', '$0.25')} in POL is paid from the reward pot to your wallet, up to ${cfg('cap', '10')} a day. <span data-cfg="tiersNote"></span></p>
|
||||
<p data-cfg="payoutsNote" class="mono" style="font-size:13px"></p></div>
|
||||
<div class="card-ink c3">${I('ledger-list')}<p class="step">Level 3 · ad credits</p>
|
||||
<h3>Real views from your branch</h3>
|
||||
|
||||
Reference in New Issue
Block a user