Query editor
-- Cohort wallets that DEPOSITED to Binance in the last 90 days (ETH + BSC)-- Deposit detection: a Binance deposit addr = any address that forwards into a Binance hot wallet.-- cohort deposit = cohort wallet sends to a deposit addr (or directly to a hot wallet).WITH cohort AS (SELECT address FROM dune."7002".dataset_wallets_81k),bin_eth AS (SELECT DISTINCT address FROM cex.addresses WHERE cex_name='Binance' AND blockchain='ethereum'),bin_bnb AS (SELECT DISTINCT address FROM cex.addresses WHERE cex_name='Binance' AND blockchain='bnb'),dep_eth AS (SELECT DISTINCT t."from" AS addr FROM erc20_ethereum.evt_Transfer t JOIN bin_eth b ON b.address=t.toWHERE t.evt_block_time > now()-interval '90' dayUNIONSELECT DISTINCT tx."from" FROM ethereum.transactions tx JOIN bin_eth b ON b.address=tx.toWHERE tx.block_time > now()-interval '90' day AND tx.value>0 AND tx.success),dep_bnb AS (SELECT DISTINCT t."from" AS addr FROM erc20_bnb.evt_Transfer t JOIN bin_bnb b ON b.address=t.toWHERE t.evt_block_time > now()-interval '90' dayUNIONSELECT DISTINCT tx."from" FROM bnb.transactions tx JOIN bin_bnb b ON b.address=tx.toWHERE tx.block_time > now()-interval '90' day AND tx.value>0 AND tx.success),tgt_eth AS (SELECT addr FROM dep_eth UNION SELECT address FROM bin_eth),tgt_bnb AS (SELECT addr FROM dep_bnb UNION SELECT address FROM bin_bnb),ev AS (SELECT t."from" AS wallet, t.evt_block_time AS tsFROM erc20_ethereum.evt_Transfer tJOIN cohort c ON c.address=t."from" JOIN tgt_eth g ON g.addr=t.toWHERE t.evt_block_time > now()-interval '90' dayUNION ALLSELECT tx."from", tx.block_time FROM ethereum.transactions txJOIN cohort c ON c.address=tx."from" JOIN tgt_eth g ON g.addr=tx.toWHERE tx.block_time > now()-interval '90' day AND tx.value>0 AND tx.successUNION ALLSELECT t."from", t.evt_block_time FROM erc20_bnb.evt_Transfer tJOIN cohort c ON c.address=t."from" JOIN tgt_bnb g ON g.addr=t.toWHERE t.evt_block_time > now()-interval '90' dayUNION ALLSELECT tx."from", tx.block_time FROM bnb.transactions txJOIN cohort c ON c.address=tx."from" JOIN tgt_bnb g ON g.addr=tx.toWHERE tx.block_time > now()-interval '90' day AND tx.value>0 AND tx.success)SELECT wallet, count(*) AS deposits, min(ts) AS first_seen, max(ts) AS last_seenFROM ev GROUP BY wallet ORDER BY deposits DESC