Query editor
-- Step 1: Get all Enso transactions from the last 7 daysWITH recent_enso_transactions AS (SELECT *FROM evms.transactionsWHERE to = 0x80eba3855878739f4710233a8a19d89bdd2ffb8eAND block_time >= NOW() - interval '7' day),-- Step 2: Filter SushiSwap routes where the tx hash matches and is from the last 7 dayssushi_routes AS (SELECT 'ethereum' AS blockchain, evt_block_time, evt_tx_hash, tokenOut, amountOutFROM sushiswap_ethereum.RouteProcessor5_evt_RouteWHERE evt_tx_hash IN (SELECT hashFROM recent_enso_transactions)AND evt_block_time >= NOW() - interval '7' dayUNION ALLSELECT 'base' AS blockchain, evt_block_time, evt_tx_hash, tokenOut, amountOutFROM sushiswap_base.RouteProcessor5_evt_RouteWHERE evt_tx_hash IN (SELECT hashFROM recent_enso_transactions)AND evt_block_time >= NOW() - interval '7' dayUNION ALLSELECT 'arbitrum' AS blockchain, evt_block_time, evt_tx_hash, tokenOut, amountOutFROM sushiswap_arbitrum.RouteProcessor5_evt_RouteWHERE evt_tx_hash IN (SELECT hashFROM recent_enso_transactions)AND evt_block_time >= NOW() - interval '7' dayUNION ALLSELECT 'polygon' AS blockchain, evt_block_time, evt_tx_hash, tokenOut, amountOutFROM sushiswap_polygon.RouteProcessor5_evt_RouteWHERE evt_tx_hash IN (SELECT hashFROM recent_enso_transactions)AND evt_block_time >= NOW() - interval '7' day),token_prices AS (SELECTDATE(minute) as day, -- Extracting the date partcontract_address,decimals,symbol,blockchain,AVG(price) AS usd_priceFROMprices.usdWHERE minute >= NOW() - interval '7' dayGROUP BYDATE(minute), contract_address, decimals, blockchain, symbol