Query editor
/* ===================================================STAGE 1d: PAYOUT RECIPIENTS (TWO-HOP LINKS, WITHDRAWAL SIDE)Save as dune.boc.result_payout_recipients.Wallets paid by Stage 1c's payout wallets are the customers behind them,linked to the same country. Each transfer from a payout wallet is onecustomer withdrawal, so the same 5-transfer rule as Stage 1a applies.One row per (recipient wallet, country). Same transfer rule as Stage 1a.Never a recipient: the zero address, labelled exchange addresses, block feerecipients, deposit addresses and forwarding services (Stage 1b), otherpayout wallets.=================================================== */WITH payout AS (SELECT DISTINCT wallet AS address, countryFROM dune.boc.result_payout_walletsWHERE is_payout),deposit_candidates AS (-- deposit addresses and forwarding services (exchange plumbing)SELECT DISTINCT addressFROM dune.boc.result_deposit_addressesWHERE role IN ('deposit_address', 'forwarding_service', 'unmeasured')),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)),payouts AS (SELECT x.dst AS wallet, p.country, p.address AS payout_wallet,x.block_date, x.amount_usdFROM xfers xINNER JOIN payout p ON x.src = p.addressWHERE x.dst <> 0x0000000000000000000000000000000000000000AND NOT EXISTS (SELECT 1 FROM all_cex c WHERE c.address = x.dst)AND NOT EXISTS (SELECT 1 FROM fee_recipients f WHERE f.address = x.dst)AND NOT EXISTS (SELECT 1 FROM deposit_candidates d WHERE d.address = x.dst)AND NOT EXISTS (SELECT 1 FROM payout o WHERE o.address = x.dst))SELECTwallet,