Query editor
/* ===================================================STAGE 2f: FINAL SAMPLESave as dune.boc.result_sample_wallets.One row per (wallet, country) for every wallet that passes the fourscreens, with all flags, so each sample version is a WHERE clause:- stablecoin_user: held at least the country's GDP-adjusted threshold insome week (result_persistence_gdp.ever_held_gdp)- flag_transfers: more than 5,000 stablecoin transfers in a calendaryear (catches contract bots the 2b screens miss)- transacted_only: sent a stablecoin transfer worth more than $0, neverreached the threshold, not flag_transfers (pass-throughusers; reported separately)- in_sample: MAIN SAMPLE: stablecoin_user AND NOT flag_velocityAND NOT flag_transfers (no persistence filter)- in_sample_persistent: in_sample AND passes_persistence_gdp (robustness)Wallets that are not stablecoin users stay in the table for the adoptioncomparison (users vs non-users among linked wallets).Reads materialized tables only.=================================================== */WITH transfer_counts AS (-- stablecoin transfers per calendar year (in and out, no flash loans).-- Catches bots that run as contracts: they send no transactions-- themselves, so the 2b transaction screen (sent transactions) misses-- them, and they hold little at day end, so the contract screen misses-- them too.SELECT wallet, MAX(n) AS max_transfers_yearFROM (SELECT wallet, year(month) AS yr, SUM(n_transfers) AS nFROM dune.boc.result_stablecoin_flowsWHERE category <> 'flashloan'GROUP BY 1, 2) yGROUP BY wallet),tx_wallets AS (-- wallets that SENT a stablecoin transfer worth more than $0 (incoming-- transfers alone do not count: address-poisoning spam sends tiny or-- zero-value USDT to wallets that never use stablecoins)SELECT DISTINCT wallet FROM dune.boc.result_stablecoin_flowsWHERE direction = 'out'AND category <> 'flashloan'AND usd > 0)SELECTs.wallet,s.country,s.is_direct,s.is_via_deposit,s.is_via_payout,s.n_countries,s.has_domestic_tier_link,s.first_link_date,s.first_tx_time,s.observed_weeks,s.max_usd,s.max_tx_12m,