Query editor
-- Native Dune volume; Balancer V1 anomaly guard added 2026-10-13.-- Scope: Ethereum Balancer V1 only. No DefiLlama or external volume replacements.-- Flag a transaction if either: (1) a V1 swap's positive two-sided Dune minute-price-- valuations differ by >100x; or (2) the same pool/token pair trades in both directions-- within that transaction and its positive execution rates span >100x.-- Exclude ONLY that transaction's Ethereum Balancer V1 USD volume (NULL, not repriced).-- Keep all rows, wallet counts, transaction counts, and retention; keep all other volume.-- Missing/nonpositive prices or quantities do not by themselves trigger this guard.-- This is a conservative anomaly quarantine, not a reconstruction of true economic volume.-- Other original dashboard filters remain removed. See dashboard methodology.WITH balancer_v1 AS (SELECT block_date,block_time,tx_hash,project_contract_address,amount_usd,token_bought_address,token_sold_address,token_bought_amount,token_sold_amountFROM dex.tradesWHERE blockchain='ethereum' AND project='balancer' AND CAST(version AS VARCHAR)='1'AND block_date>CURRENT_DATE-INTERVAL '180' DAY), balancer_tokens AS (SELECT token_bought_address address FROM balancer_v1UNION SELECT token_sold_address FROM balancer_v1), balancer_prices AS (SELECT p.contract_address,p.minute,MAX(p.price) priceFROM prices.usd p JOIN balancer_tokens t ON p.contract_address=t.addressWHERE p.blockchain='ethereum' AND p.minute>=CAST(CURRENT_DATE-INTERVAL '180' DAY AS TIMESTAMP)AND p.price>0 AND is_finite(p.price)GROUP BY 1,2), balancer_valued AS (SELECT b.tx_hash,b.token_bought_amount*pb.price bought_usd,b.token_sold_amount*ps.price sold_usdFROM balancer_v1 bJOIN balancer_prices pb ON pb.contract_address=b.token_bought_address AND pb.minute=date_trunc('minute',b.block_time)JOIN balancer_prices ps ON ps.contract_address=b.token_sold_address AND ps.minute=date_trunc('minute',b.block_time)), balancer_bad_price_tx AS (SELECT DISTINCT tx_hash FROM balancer_valuedWHERE bought_usd>0 AND sold_usd>0AND GREATEST(bought_usd,sold_usd)/LEAST(bought_usd,sold_usd)>100), balancer_pool_rates AS (SELECT tx_hash,project_contract_address,LEAST(token_bought_address,token_sold_address) token_a,GREATEST(token_bought_address,token_sold_address) token_b,MAX(rate)/NULLIF(MIN(rate),0) rate_spread,COUNT_IF(token_bought_address<token_sold_address)>0 AND COUNT_IF(token_bought_address>token_sold_address)>0 round_tripFROM (SELECT b.*,CASE WHEN token_bought_address<token_sold_address THEN token_bought_amount/NULLIF(token_sold_amount,0)ELSE token_sold_amount/NULLIF(token_bought_amount,0) END rateFROM balancer_v1 b) a WHERE rate>0 AND is_finite(rate)GROUP BY 1,2,3,4), balancer_bad_cycle_tx AS (SELECT DISTINCT tx_hash FROM balancer_pool_rates WHERE round_trip AND rate_spread>100), balancer_anomaly_tx AS (SELECT tx_hash FROM balancer_bad_price_txUNION SELECT tx_hash FROM balancer_bad_cycle_tx), native_trades AS (SELECTblock_date,block_time,project,CAST(version AS VARCHAR) AS version,token_pair,blockchain,tx_from,a.tx_hash,