Query editor
WITH native_deposits AS (SELECTevt_block_date AS block_date,chain,CAST(amount AS double) / 1e18 AS amount_decimal,evt_tx_hashFROM relay_multichain.relaydepository_evt_relaynativedepositWHERE evt_block_date >= CURRENT_DATE - INTERVAL '30' DAY),erc20_deposits AS (SELECTevt_block_date AS block_date,chain,token,amount,evt_tx_hashFROM relay_multichain.relaydepository_evt_relayerc20depositWHERE evt_block_date >= CURRENT_DATE - INTERVAL '30' DAY),native_priced AS (SELECTn.chain,n.amount_decimal * p.price AS amount_usd,n.evt_tx_hashFROM native_deposits nLEFT JOIN prices.usd_daily pON p.blockchain = n.chainAND p.contract_address = 0x0000000000000000000000000000000000000000AND p.day = n.block_date),erc20_priced AS (SELECTe.chain,CAST(e.amount AS double) / POWER(10, COALESCE(t.decimals, 18)) * p.price AS amount_usd,e.evt_tx_hashFROM erc20_deposits eLEFT JOIN tokens.erc20 tON t.blockchain = e.chain AND t.contract_address = e.tokenLEFT JOIN prices.usd_daily pON p.blockchain = e.chain AND p.contract_address = e.token AND p.day = e.block_date),combined AS (SELECT chain, amount_usd, evt_tx_hash FROM native_pricedUNION ALLSELECT chain, amount_usd, evt_tx_hash FROM erc20_priced)SELECTchain,COUNT(DISTINCT evt_tx_hash) AS tx_count,COALESCE(SUM(amount_usd), 0) AS volume_usd,ROUND(COALESCE(SUM(amount_usd), 0) * 100.0 / SUM(COALESCE(SUM(amount_usd), 0)) OVER (), 2) AS pct_of_totalFROM combinedGROUP BY 1ORDER BY 3 DESC