Query editor
/* ===================================================STAGE 1b (part 2): DEPOSIT FUNDERS (TWO-HOP LINKS)Save as dune.boc.result_deposit_funders.The wallets that send into the deposit addresses from part 1(role = 'deposit_address') are the customers behind them, linked to thesame country. A funder needs 5+ transfers into the country's depositaddresses (same rule as Stage 1a). Same transfer rule as Stage 1a.Never a funder: the zero address, labelled exchange addresses (this alsodrops gas top-ups), block fee recipients, deposit addresses andforwarding services. Candidates classed as users can be funders.=================================================== */WITH deposit_addresses AS (SELECT DISTINCT address, countryFROM dune.boc.result_deposit_addressesWHERE role = 'deposit_address'),plumbing AS (SELECT DISTINCT addressFROM dune.boc.result_deposit_addressesWHERE role IN ('deposit_address', 'forwarding_service')),all_cex AS (SELECT DISTINCT address FROM cex.addresses WHERE blockchain = 'ethereum'),fee_recipients AS (SELECT DISTINCT miner AS addressFROM ethereum.blocksWHERE date >= DATE '2021-01-01' AND date < DATE '2026-01-01'),xfers AS (SELECT block_date, "from" AS src, "to" AS dst, amount_usdFROM tokens_ethereum.transfersWHERE block_month >= DATE '2021-01-01'AND block_month < DATE '2026-01-01'AND amount > 0AND (token_standard = 'native' OR amount_usd IS NOT NULL)),funding AS (SELECT x.src AS wallet, d.country, d.address AS deposit_address,x.block_date, x.amount_usdFROM xfers xINNER JOIN deposit_addresses d ON x.dst = d.addressWHERE x.src <> 0x0000000000000000000000000000000000000000AND NOT EXISTS (SELECT 1 FROM all_cex c WHERE c.address = x.src)AND NOT EXISTS (SELECT 1 FROM fee_recipients f WHERE f.address = x.src)AND NOT EXISTS (SELECT 1 FROM plumbing p WHERE p.address = x.src))SELECTwallet,country,COUNT(*) AS n_via_deposit,