Query editor
WITH daily_cbbtc_deposits AS (-- First, find all CBBTC transfers that were part of a successful executeSwapSELECTdate_trunc('day', t.block_time) AS day,SUM(CAST(transfer.value AS DOUBLE) / 1e8) AS total_cbbtc_on_dayFROMbase.traces tINNER JOIN-- Link the function call to the token transfererc20_base.evt_Transfer transfer ON transfer.evt_tx_hash = t.tx_hashWHEREt."to" = 0x1D3F8fcfE508D7031c242E213B27FbE432f52c67AND substring(t.input from 1 for 4) = 0x37941a72 -- executeSwap()AND t.success = true-- Make sure it's the CBBTC token transfer TO your contractAND transfer."to" = 0x1D3F8fcfE508D7031c242E213B27FbE432f52c67AND transfer.contract_address = 0xcbb7c0000ab88b473b1f5afd9ef808440eed33bfAND t.block_time >= now() - interval '30' day -- For the last 30 daysGROUP BY1)-- Now, join with the price table to get the USD value for each daySELECTd.day,-- If price is NULL, show 0 to avoid blanksCOALESCE(d.total_cbbtc_on_day * p.price, 0) AS daily_usd_volumeFROMdaily_cbbtc_deposits dLEFT JOIN-- Get the historical price of CBBTCprices.usd p ON p.minute = date_trunc('minute', d.day)AND p.contract_address = 0xcbb7c0000ab88b473b1f5afd9ef808440eed33bfAND p.blockchain = 'base'ORDER BYd.day