Query editor
WITH mrkt_config AS (SELECTLOWER('0:2E5AE99EC1F98602A3FF9A7712C5173E97C407D2893CAD65CCDC0924A59DA97B') AS mrkt_address,LOWER('0:0000000000000000000000000000000000000000000000000000000000000000') AS native_ton_address_for_price_lookup,9 AS ton_decimals),latest_ton_price_usd_cte AS (SELECTCOALESCE(tpd.price_usd * POW(10, (SELECT ton_decimals FROM mrkt_config)), 0.0) AS current_ton_price_usdFROM ton.prices_daily tpdWHERE LOWER(tpd.token_address) = (SELECT native_ton_address_for_price_lookup FROM mrkt_config)ORDER BY tpd.timestamp DESCLIMIT 1),mrkt_outflows AS (SELECTm.destination AS recipient_address,m.value / POW(10, (SELECT ton_decimals FROM mrkt_config)) AS ton_amountFROM ton.messages mWHERE LOWER(m.source) = (SELECT mrkt_address FROM mrkt_config)AND m.value > 0AND m.direction = 'out'AND m.destination IS NOT NULLAND LOWER(m.source) != LOWER(m.destination)),recipient_summary AS (SELECTmo.recipient_address,SUM(mo.ton_amount) AS total_ton_received,MAX(mo.ton_amount) AS max_ton_received_single_tx,AVG(mo.ton_amount) AS avg_ton_received_per_tx,COUNT(*) AS transactions_receivedFROM mrkt_outflows moGROUP BY mo.recipient_address),final_data AS (SELECTrs.recipient_address,rs.total_ton_received * ltp.current_ton_price_usd AS total_value_received_usd,rs.max_ton_received_single_tx * ltp.current_ton_price_usd AS max_value_received_usd_single_tx,rs.avg_ton_received_per_tx * ltp.current_ton_price_usd AS avg_value_received_usd_per_tx,rs.transactions_receivedFROM recipient_summary rsCROSS JOIN latest_ton_price_usd_cte ltp)SELECTROW_NUMBER() OVER (ORDER BY fd.total_value_received_usd DESC) AS "Rank #",CASEWHEN fd.total_value_received_usd >= 100000 THEN '🐳'WHEN fd.total_value_received_usd >= 10000 THEN '🦈'WHEN fd.total_value_received_usd >= 1000 THEN '🐬'WHEN fd.total_value_received_usd >= 100 THEN '🐠'ELSE '🦐'END AS "Type",GET_HREF(CONCAT('https://tonviewer.com/', TON_ADDRESS_RAW_TO_USER_FRIENDLY(UPPER(fd.recipient_address))),COALESCE(dl.label, dns.domain, TON_ADDRESS_RAW_TO_USER_FRIENDLY(UPPER(fd.recipient_address)))) AS "Recipient",ROUND(fd.total_value_received_usd, 2) AS "Total Value (USD)",fd.transactions_received AS "Transactions Received",