Query editor
withaave_v3 as (selectdate_trunc('minute',s.evt_block_time) as time, s.reserve as reserve, tk.symbol as symbol, tk.decimals as decimals, case when s.user = 0xb748952c7bc638f31775245964707bcc5ddfabfcthen 'migrated'else 'new' end as new_migrated, sum(cast(s.amount as double)) as amount_supplyfrom aave_v3_ethereum.Pool_evt_Supply as sLEFT JOIN tokens.erc20 tk ON tk.contract_address = s.reservegroup by 1, 2, 3, 4,5), aave_v3_usd as (selectv3.time as time, v3.reserve as reserve, v3.symbol as symbol, v3.amount_supply as amount_supply, tk.decimals as decimals, v3.new_migrated as new_migrated, sum(v3.amount_supply / pow(10,COALESCE(tk.decimals,18)) * p.price) as token_supplied_v3_usdfrom aave_v3 as v3LEFT JOIN tokens.erc20 tk ON tk.contract_address = v3.reserveLEFT JOIN prices.usd p ON p.minute = date_trunc('minute',v3.time) AND p.blockchain = 'ethereum' AND p.contract_address = v3.reservegroup by 1, 2, 3, 4, 5,6)-- Create empty time series, days as (with days_seq as (SELECT sequence(date_trunc('day', cast('{{start_date}}' as timestamp)), date_trunc('day', cast(now() as timestamp)), interval '1' day) as day)SELECTdays.dayFROM days_seqCROSS JOIN unnest(day) as days(day)), aave_v3_ts as (selectd.day, sum(token_supplied_v3_usd) as token_supplied_v3_usd, v3.new_migrated as new_migratedfrom days dLeft JOIN aave_v3_usd v3 ON date_trunc('day',v3.time) = d.daygroup by 1,3), aave_v3_cumulative as (selectday as day