Query editor
-- Cohort (81,934) wallets that deposited to / withdrew from Binance in the last 90 days-- Chains: Ethereum + BSC. Direction: deposit = cohort -> Binance ; withdraw = Binance -> cohort-- Sources: cohort = dune."7002".dataset_wallets_81k ; Binance addrs = cex.addresses (Dune CEX spellbook)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'),ev AS (-- ETH ERC20 depositsSELECT t."from" AS wallet, 'deposit' AS dir, t.evt_block_time AS tsFROM erc20_ethereum.evt_Transfer tJOIN cohort c ON c.address = t."from"JOIN bin_eth b ON b.address = t.toWHERE t.evt_block_time > now() - interval '90' dayUNION ALL-- ETH ERC20 withdrawalsSELECT t.to, 'withdraw', t.evt_block_timeFROM erc20_ethereum.evt_Transfer tJOIN cohort c ON c.address = t.toJOIN bin_eth b ON b.address = t."from"WHERE t.evt_block_time > now() - interval '90' dayUNION ALL-- ETH native depositsSELECT tx."from", 'deposit', tx.block_timeFROM ethereum.transactions txJOIN cohort c ON c.address = tx."from"JOIN bin_eth b ON b.address = tx.toWHERE tx.block_time > now() - interval '90' day AND tx.value > 0 AND tx.successUNION ALL-- ETH native withdrawalsSELECT tx.to, 'withdraw', tx.block_timeFROM ethereum.transactions txJOIN cohort c ON c.address = tx.toJOIN bin_eth b ON b.address = tx."from"WHERE tx.block_time > now() - interval '90' day AND tx.value > 0 AND tx.successUNION ALL-- BSC BEP20 depositsSELECT t."from", 'deposit', t.evt_block_timeFROM erc20_bnb.evt_Transfer tJOIN cohort c ON c.address = t."from"JOIN bin_bnb b ON b.address = t.toWHERE t.evt_block_time > now() - interval '90' dayUNION ALL-- BSC BEP20 withdrawalsSELECT t.to, 'withdraw', t.evt_block_timeFROM erc20_bnb.evt_Transfer tJOIN cohort c ON c.address = t.toJOIN bin_bnb b ON b.address = t."from"WHERE t.evt_block_time > now() - interval '90' dayUNION ALL-- BSC native depositsSELECT tx."from", 'deposit', tx.block_timeFROM bnb.transactions txJOIN cohort c ON c.address = tx."from"JOIN bin_bnb b ON b.address = tx.toWHERE tx.block_time > now() - interval '90' day AND tx.value > 0 AND tx.successUNION ALL-- BSC native withdrawalsSELECT tx.to, 'withdraw', tx.block_time