Query editor
/* ===================================================EXHIBIT: how wallets were identified (link route), by country and sampleFrom dune.boc.result_wallet_master and dune.boc.result_linked_wallets.Small output: download as data/link_route_by_country.csv.One route per wallet-country row (mutually exclusive; direct links takepriority over two-hop links):direct_both received from and sent to the exchange's labelled walletsdirect_withdraw_only only received from themdirect_deposit_only only sent to them (includes the deposit-only usersrecovered in Stage 1b)via_deposit_address linked only through a customer deposit addressvia_payout_wallet linked only through a payout walletvia_both deposit address and payout wallet, no direct linkalso_two_hop: direct wallets that were also found through a depositaddress or payout wallet (overlap, not a separate route).Samples: linked (all), validation_set (passes the non-retail filters,holder or not), main_sample (holders), pass_through, persistent.Rows for each country and for all countries combined.=================================================== */WITH m AS (SELECTw.country,w.dropped_at,w.in_sample,w.pass_through,w.persistent_gdp,(w.is_direct AND (w.is_via_deposit OR w.is_via_payout)) AS also_two_hop,CASEWHEN w.is_direct AND l.n_withdraw > 0 AND l.n_deposit > 0 THEN 'direct_both'WHEN w.is_direct AND l.n_withdraw > 0 THEN 'direct_withdraw_only'WHEN w.is_direct THEN 'direct_deposit_only'WHEN w.is_via_deposit AND w.is_via_payout THEN 'via_both'WHEN w.is_via_deposit THEN 'via_deposit_address'ELSE 'via_payout_wallet'END AS link_routeFROM dune.boc.result_wallet_master wINNER JOIN dune.boc.result_linked_wallets lON l.wallet = w.wallet AND l.country = w.country),s AS (SELECT m.country, m.link_route, m.also_two_hop, t.sampleFROM mCROSS JOIN UNNEST(ARRAY['linked',CASE WHEN m.dropped_at IS NULL OR m.dropped_at = 'never_held' THEN 'validation_set' END,CASE WHEN m.in_sample THEN 'main_sample' END,CASE WHEN m.pass_through THEN 'pass_through' END,CASE WHEN m.persistent_gdp THEN 'persistent' END]) AS t(sample)WHERE t.sample IS NOT NULL)SELECTCOALESCE(country, 'All countries') AS country,sample,COUNT(*) AS wallets,