Query editor
-- part of a query repo-- query name: WC Stablecoin Holders Geo | Helper-- query link: https://dune.com/queries/6752947-- description: Base helper that joins WalletConnect address_countries with-- stablecoins_multichain.balances and dim_country.-- Outputs per-address stablecoin holdings with geo info.---- Parameters:-- {{min_balance}} : minimum total stablecoin balance per user in USD (default 100)-- {{region}} : multi-select world region filter (values from dim_country)-- {{country}} : multi-select country filter (values from dim_country)WITH _regions AS (SELECT TRIM(v) AS v FROM UNNEST(SPLIT('{{region}}', ',')) AS t(v)),_countries AS (SELECT TRIM(v) AS v FROM UNNEST(SPLIT('{{country}}', ',')) AS t(v)),geo AS (SELECT country_id, name AS country, alpha_3, region, sub_regionFROM dune.walletconnect.dim_country),cex_addrs AS (SELECT DISTINCT LOWER(CONCAT('0x', TO_HEX(address))) AS address FROM cex.addresses),wc_balances AS (SELECTb.address,b.blockchain,b.token_symbol,b.balance_usd,wa.country_idFROM stablecoins_multichain.balances bINNER JOIN dune.walletconnect.address_countries wa ON b.address = wa.addressLEFT JOIN cex_addrs cx ON b.address = cx.addressWHERE b.day = (SELECT MAX(day) FROM stablecoins_multichain.balances)AND cx.address IS NULL),user_totals AS (SELECTaddress,SUM(balance_usd) AS total_stablecoin_usd,COUNT(DISTINCT blockchain) AS chains_used,COUNT(DISTINCT token_symbol) AS tokens_heldFROM wc_balancesGROUP BY 1HAVING SUM(balance_usd) >= {{min_balance}})SELECTut.address,ut.total_stablecoin_usd,ut.chains_used,ut.tokens_held,g.country,