Query editor
-- Stock vs meme overview -- LIVE fork.-- Reads query_8609525 (the meme-facts source), which RE-EXECUTES against chain data,-- so this returns fresh numbers at ~70 credits per run.-- Query 8609536 is the identical view served from the matview for ~0.1 credits;-- use this one only when you need data newer than the last matview refresh.---- Pairing is one-to-one and authoritative: a meme belongs to the single stock it-- LAUNCHED against (Doppler numeraire, or a verified single-stock pool that trades).-- See query 8609525 for the full derivation and why counting all pools was wrong.WITH stocks AS (SELECT stock AS token_address, symbol, evt_block_time AS issued_atFROM rwa_stock_factory_robinhood.factory_deployer_evt_deployed),stock_px AS (SELECT s.token_address, s.symbol, s.issued_at,COALESCE(sl.supply * p.price, 0) AS stock_mcapFROM stocks sLEFT JOIN tokens.supply_latest slON sl.blockchain = 'robinhood' AND sl.token_address = s.token_addressLEFT JOIN prices.latest pON p.blockchain = 'robinhood' AND p.contract_address = s.token_address),mf AS (SELECT *,CASE WHEN holders >= {{min_holders}}AND price_usd IS NOT NULLAND price_usd * supply < 1e9THEN price_usd * supply ELSE 0 END AS meme_mcapFROM query_8609525),agg AS (SELECTstock_addr,COUNT(*) AS total_memes,MAX(meme_mcap) AS top_meme_mcap,MAX_BY(CASE WHEN meme_mcap > 0 THEN meme_symbol END, meme_mcap) AS top_meme,MAX_BY(holders, meme_mcap) AS top_meme_holders,MAX_BY(vol_usd, meme_mcap) AS top_meme_vol,MAX_BY(meme_symbol, holders) AS most_held,MAX(holders) AS most_held_n,MAX_BY(meme_symbol, vol_usd) AS most_traded,MAX(vol_usd) AS most_traded_vol,SUM(holders) AS total_holders,SUM(vol_usd) AS total_vol,COUNT(CASE WHEN holders >= 25 OR vol_usd >= 1000 THEN 1 END) AS memes_active,COUNT(CASE WHEN holders >= 250 OR vol_usd >= 50000OR meme_mcap >= 100000 THEN 1 END) AS memes_hotFROM mf GROUP BY 1)SELECTsp.symbol AS stock,sp.stock_mcap,CASEWHEN COALESCE(a.total_memes, 0) = 0 THEN 'NO_MEMES'WHEN COALESCE(a.memes_active, 0) = 0 THEN 'DEAD'WHEN COALESCE(a.top_meme_mcap, 0) >= 1000000OR COALESCE(a.total_vol, 0) >= 250000 THEN 'HOT'WHEN a.total_memes >= 5 AND COALESCE(a.memes_hot, 0) = 0 THEN 'CROWDED_NO_WINNER'WHEN sp.stock_mcap >= 500000AND COALESCE(a.top_meme_mcap, 0) < sp.stock_mcap * 0.05 THEN 'WIDE_OPEN'