Query editor
-- FOUR.MEME KOL P&L · RUNTIME REVALUATION-- Every Run reads new trades/transfers up to execution time and revalues current holdings.-- Historical ledger boundary: 2026-11-01 00:00:00 UTC (quantities/costs/reconciliation state).-- Current P&L and current holding values are NOT taken from a previous result or snapshot.-- Gross P&L = verified sells - verified buys + current holdings × fresh market price.-- Late corrections before the ledger boundary require rebuilding that historical base.-- Dune ingestion lag applies; see cutoff_utc for each table's execution time.WITH token_params(symbol, token, start_utc, quote_asset) /* 01 · 精确合约名单与每币起点 / Token allowlist and launch times */ AS (SELECT*FROM (VALUES('MUBARAK',0x5c85d6c6825ab4032337f11ee92a72df936b46f6,TIMESTAMP '2025-03-13 09:21:28',0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c)) AS _values), wallets /* 02 · KOL—钱包身份映射 / Maintained identity reference */ AS (SELECTFROM_HEX(SUBSTR(wallet_address, 3)) AS address,kol_id,kol_name,x_handle,avatar_urlFROM query_9074278), dex_events /* Consolidation is allowed only for explicit identical GMGN X handles. */ /* 03 · 基数截止后新增 DEX 成交 / New DEX trades since the ledger boundary */ AS (SELECTc.token,w.kol_id,t.tx_hash,t.block_time,t.block_number,t.evt_index,CASE WHEN t.token_bought_address = c.token THEN t.token_bought_amount ELSE 0 END AS bought_qty,CASE WHEN t.token_sold_address = c.token THEN t.token_sold_amount ELSE 0 END AS sold_qty,CASE WHEN t.token_bought_address = c.token THEN t.amount_usd ELSE 0 END AS buy_usd,CASE WHEN t.token_sold_address = c.token THEN t.amount_usd ELSE 0 END AS sell_usd,CASE WHEN t.amount_usd IS NULL THEN 1 ELSE 0 END AS unpricedFROM dex.trades AS tJOIN wallets AS wON t.tx_from = w.addressJOIN token_params AS cON (t.token_bought_address = c.token OR t.token_sold_address = c.token)WHERE(t.token_bought_address IN (0x5c85d6c6825ab4032337f11ee92a72df936b46f6)OR t.token_sold_address IN (0x5c85d6c6825ab4032337f11ee92a72df936b46f6))AND t.blockchain = 'bnb'AND t.block_date BETWEEN CAST('2026-11-01' AS DATE) AND CAST(CAST(AT_TIMEZONE(CURRENT_TIMESTAMP, 'UTC') AS TIMESTAMP) AS DATE)AND t.block_time >= GREATEST(c.start_utc, TIMESTAMP '2026-11-01 00:00:00')AND t.block_time < CAST(AT_TIMEZONE(CURRENT_TIMESTAMP, 'UTC') AS TIMESTAMP)AND (t.token_bought_address = c.token OR t.token_sold_address = c.token)), curve_events /* 04 · Four.meme 内盘成交与实际报价币价格 / Bonding-curve trades */ AS (SELECT