Query editor
withETH_price as (SELECT avg(price) AS price,contract_address AS tokenAddress,date_trunc('day', minute) AS block_dateFROM prices.usdWHERE contract_address = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2AND minute > cast('2025-06-01 00:00' as timestamp)GROUP BY 2, 3order by block_date desc)selectday,146 as chain_id,pool_address,holder as user_address,0x3bcE5CB273F0F148010BbEa2470e7b5df84C7812 as underlying_token_address,0 as underlying_token_index,balance as underlying_token_amount,balance * price as underlying_token_amount_usd,daily_fees as total_fees_usdfrom query_5652637 t1left join ETH_price t2 on date(t1.day) = date(t2.block_date)WHERE DATE(t1.day) IN (SELECT DISTINCT DATE(block_date)FROM ETH_price)order by day desc, underlying_token_amount desc