Query editor
WITH stablecoins AS (SELECT dune_id, blockchain, issued_by, token_address, decimals, peg_typeFROM dune.gasweighing.dataset_evm_stablecoinsWHERE(('{{Show}}' = 'All') -- 'All': Show all recordsOR ('{{Show}}' = 'EUR' AND peg_type = 'EUR') -- 'EUR': Show only EUR assetsOR ('{{Show}}' = 'USD' AND peg_type = 'USD') -- 'USD': Show only USD assetsOR ('{{Show}}' = 'EUR and USD' -- 'EUR and USD': Show only chains where both EUR and USD assets are presentAND dune_id IN (SELECT dune_idFROM dune.gasweighing.dataset_evm_stablecoinsWHERE peg_type IN ('EUR', 'USD')GROUP BY dune_idHAVING COUNT(DISTINCT peg_type) = 2)))AND ('{{Issuer}}' = 'All' -- Include all issuersOR issued_by IN (SELECT issuerFROM UNNEST(SPLIT('{{Issuer}}', ',')) AS t(issuer) -- Select specific issuers))), date_parameter AS (SELECT CASEWHEN '{{Timeframe}}' = 'Show all time by month' THEN CAST('2014-01-01' AS DATE)WHEN '{{Timeframe}}' = 'Past one year by month' THEN NOW() - INTERVAL '1' YEARWHEN '{{Timeframe}}' = 'Past six months by week' THEN NOW() - INTERVAL '6' MONTHWHEN '{{Timeframe}}' = 'Past one month by day' THEN NOW() - INTERVAL '1' MONTHWHEN '{{Timeframe}}' = 'Past one week by hour' THEN NOW() - INTERVAL '7' DAYEND AS start_date, CASEWHEN '{{Timeframe}}' = 'Show all time by month' THEN 'month'WHEN '{{Timeframe}}' = 'Past one year by month' THEN 'month'WHEN '{{Timeframe}}' = 'Past six months by week' THEN 'week'WHEN '{{Timeframe}}' = 'Past one month by day' THEN 'day'WHEN '{{Timeframe}}' = 'Past one week by hour' THEN 'hour'END AS aggregation, CURRENT_DATE AS exclusion_date), arbitrum_o AS (/* Arbitrum One */SELECT DATE_TRUNC(date_parameter.aggregation, arb.evt_block_time) AS txn_date, stc.blockchain, CASEWHEN stc.peg_type = 'USD' THEN 'Arbitrum – USD'WHEN stc.peg_type = 'EUR' THEN 'Arbitrum – EUR'ELSE 'Arbitrum – Other'END AS pegged_currency, SUM(arb."value" / POWER(10, stc.decimals)) AS txn_volFROM erc20_arbitrum.evt_transfer arbJOIN stablecoins stc ON arb.contract_address = stc.token_address AND stc.dune_id = 'arbitrum'