Stack POL: Video App Income program (live 2026-11-20, standing rule): programs.js 'vai' (/earn/video-app-income, direct join link with the network username), card image vai.jpg, netsites list, layout ref swap for videoappincome.com, indexer vai_rows (VideoAppIncome Paid events: sponsor 30% + five matrix levels 8%, position wallets looked up on chain; company shares not read, cache vai-chain.json)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
+65
-1
@@ -9,7 +9,7 @@
|
||||
weekly prize transfers listed in VBB's prizes.json, each checked on chain (sent by the prize wallet, to that winner, succeeded).
|
||||
The scan position and the checked prize transfers are cached in /root/stackpol-indexer/vbb-chain.json.
|
||||
- ViralAdBlitz (2026-11-15): VABShop Paid (level 1-5 shares) and Claimed logs read from Polygon the same way, cached in
|
||||
/root/stackpol-indexer/vab-chain.json (ViralAdSource 2026-11-17: + resharer cut and pot rewards, vas-chain.json; YourProgramBuilder ypb-chain.json). These caches are the only files it writes.
|
||||
/root/stackpol-indexer/vab-chain.json (ViralAdSource 2026-11-17: + resharer cut and pot rewards, vas-chain.json; YourProgramBuilder ypb-chain.json; Video App Income vai-chain.json, its own reader vai_rows). These caches are the only files it writes.
|
||||
It builds one snapshot (network totals, per-program totals, last 7 days, latest 300 payouts, a stack per opted-in member) and
|
||||
POSTs it to https://stackpol.com/api/ingest with the key in /root/.stackpol-ingest-key. Nothing is written anywhere else.
|
||||
The ledger shows each payout's username (Marty 2026-11-09); only opted-in members get a public stack page.
|
||||
@@ -68,6 +68,13 @@ FX_HOUSE = {FX_SHOP, '0x7627fc78876948ac9d95c1c9eb061e7d6d647b70', '0x818daeedef
|
||||
# failed in that tx: then the later Claimed counts it), and Claimed by a member. Kind 0 = company; contract, company, keeper and relay excluded.
|
||||
# YourProgramBuilder (2026-11-17): YPBShop on Polygon, read-only; same Paid/Claimed events as VABShop. Member payouts = Paid kind 1-5
|
||||
# (sponsor 20% + four levels 5%) + Claimed by a member (a failed push is owed and counted when claimed). Kind 0 = company; contract, company, keeper excluded.
|
||||
# Video App Income (2026-11-20): VideoAppIncome contract on Polygon, read-only. Its Paid event names the receiving POSITION, not a
|
||||
# wallet: Paid(uint32 buyerId, uint32 toId, uint8 kind, uint256 amount), kind 0 = the 30% sponsor share, 1-5 = the 8% matrix levels.
|
||||
# Every Paid event is a member payout (company shares are a separate CompanySplit event and are not read). The position's wallet is
|
||||
# looked up once with member(toId) when the log is first seen and stored with it. Cache: vai-chain.json.
|
||||
VAI_SHOP = '0x0cff5d57933812b0fbac4d1138aa6b0ce5bac201'
|
||||
VAI_START = 97669974 # deploy block
|
||||
VAI_PAID = '0x1953924ceb3951f9e9936e1ed523923640c00c51daa472fb1ab22b924f42f564'
|
||||
YPB_SHOP = '0x44a02c5ece4e6eb0edc406a8020f289956803e2a'
|
||||
YPB_START = 97486277 # deploy block (the app's SHOP_START_BLOCK)
|
||||
YPB_HOUSE = {YPB_SHOP, '0x7627fc78876948ac9d95c1c9eb061e7d6d647b70', '0x5453a3973ed54cd2687c1675b73f1be5dacf26c4'} # + company (Tangem), keeper
|
||||
@@ -282,6 +289,60 @@ def vab_rows(dry=False, k='vab', shop=VAB_SHOP, start=VAB_START, house=VAB_HOUSE
|
||||
last, len(logs), allwei / 1e18, len(rows), sum(r['pol'] for r in rows), ('; ' + note) if note else '')
|
||||
|
||||
|
||||
def vai_rows(dry=False):
|
||||
"""Video App Income member payouts (sponsor 30% + five matrix levels 8%), read-only on chain. Returns (rows, note)."""
|
||||
cpath = os.path.join(HERE, 'vai-chain.json')
|
||||
cache = load(cpath, {}) or {}
|
||||
last = int(cache.get('lastBlock') or VAI_START - 1)
|
||||
logs = cache.get('logs') or []
|
||||
bts, accts = {}, {}
|
||||
|
||||
def btime(n):
|
||||
if n not in bts:
|
||||
b = rpc('eth_getBlockByNumber', [hex(n), False])
|
||||
bts[n] = int(b['timestamp'], 16) if b and b.get('timestamp') else 0
|
||||
return bts[n]
|
||||
|
||||
def account(pid):
|
||||
if pid not in accts:
|
||||
r = rpc('eth_call', [{'to': VAI_SHOP, 'data': '0xbfca75d1' + '%064x' % pid}, 'latest']) or '0x' # member(uint32): first word = wallet
|
||||
accts[pid] = '0x' + r[2:66][-40:].lower() if len(r) >= 66 else ''
|
||||
return accts[pid]
|
||||
note = ''
|
||||
try:
|
||||
head = int(rpc('eth_blockNumber', []), 16) - VBB_CONFIRM
|
||||
seen = {(x['tx'], x['li']) for x in logs}
|
||||
spans = 0
|
||||
while last < head and spans < VBB_MAX_SPANS:
|
||||
frm, to = last + 1, min(head, last + VBB_SPAN)
|
||||
for l in rpc('eth_getLogs', [{'address': VAI_SHOP, 'topics': [VAI_PAID], 'fromBlock': hex(frm), 'toBlock': hex(to)}]) or []:
|
||||
if l.get('removed') or str(l.get('address', '')).lower() != VAI_SHOP:
|
||||
continue
|
||||
t, data = l['topics'], l.get('data') or '0x'
|
||||
key = (l['transactionHash'].lower(), int(l['logIndex'], 16))
|
||||
if key in seen or len(t) < 3:
|
||||
continue
|
||||
n, pid = int(l['blockNumber'], 16), int(t[2], 16)
|
||||
w = account(pid)
|
||||
if not w or int(w, 16) == 0:
|
||||
raise RuntimeError('no wallet for position %d' % pid) # stop before this span is marked done; retried next run
|
||||
logs.append({'ev': 'Paid', 'pos': pid, 'to': w, 'kind': int(data[2:66], 16), 'wei': str(int(data[66:130], 16)), 'tx': key[0], 'li': key[1], 'block': n, 'ts': btime(n)})
|
||||
seen.add(key)
|
||||
last = to
|
||||
spans += 1
|
||||
if last < head:
|
||||
note = 'catching up, %d blocks to go' % (head - last)
|
||||
except Exception as e:
|
||||
note = 'chain read failed (kept the cached logs): %s' % e
|
||||
if not dry:
|
||||
tmp = cpath + '.tmp'
|
||||
with open(tmp, 'w', encoding='utf-8', newline='\n') as f:
|
||||
json.dump({'lastBlock': last, 'logs': logs, 'at': int(time.time())}, f)
|
||||
os.replace(tmp, cpath)
|
||||
rows = [{'k': 'vai', 'pol': int(x['wei']) / 1e18, 'tx': x['tx'], 'ts': ms(x['ts']), 'w': x['to'], 'gu': ''} for x in logs if int(x['wei']) > 0 and x['to'] != VAI_SHOP]
|
||||
return rows, 'vai: scanned to block %d, %d Paid logs, %d member payouts %.4f POL%s' % (last, len(logs), len(rows), sum(r['pol'] for r in rows), ('; ' + note) if note else '')
|
||||
|
||||
|
||||
def iap_wallet_users():
|
||||
"""{address_lower: username} from IAP accounts + positions, via the IAP container (its DATABASE_URL never leaves it)."""
|
||||
c = subprocess.run(['docker', 'ps', '--format', '{{.Names}}'], capture_output=True, text=True).stdout.split()
|
||||
@@ -379,6 +440,9 @@ def main():
|
||||
yr, ynote = vab_rows(dry, 'ypb', YPB_SHOP, YPB_START, YPB_HOUSE, 'ypb-chain.json')
|
||||
rows += yr
|
||||
print(ynote)
|
||||
ir, inote = vai_rows(dry)
|
||||
rows += ir
|
||||
print(inote)
|
||||
# wallet -> username
|
||||
wu = iap_wallet_users()
|
||||
lsd = voldir(CHAINS['ls'])
|
||||
|
||||
Reference in New Issue
Block a user