Query editor
-- This query used incompatible data types from Dune SQL alpha and may need to be updated.-- More details can be found on https://dune.com/docs/query/dunesql-changes/withaave_v3_deposit as (selects.reserve as reserve, tk.symbol as symbol, sum(cast(s.amount as double)) as amount_supply, tk.decimals as decimalsfrom aave_v3_ethereum.Pool_evt_Supply as sLEFT JOIN tokens.erc20 tk ON tk.contract_address = s.reservewhere date_trunc('day',s.evt_block_time) >= cast('{{start_date}}' as timestamp)group by 1, 2, 4), aave_v2_deposit as (selects.reserve as reserve, tk.symbol as symbol, sum(cast(s.amount as double)) as amount_supply, tk.decimals as decimalsfrom aave_v2_ethereum.LendingPool_evt_Deposit as sLEFT JOIN tokens.erc20 tk ON tk.contract_address = s.reservewhere date_trunc('day',s.evt_block_time) >= cast('{{start_date}}' as timestamp)group by 1,2, 4), aave_v2_v3_deposit as (selectv3.reserve as reserve_v3, v2.reserve as reserve_v2, v3.symbol as symbol_v3, v2.symbol as symbol_v2, v3.amount_supply as amount_supply_v3, v2.amount_supply as amount_supply_v2, v3.amount_supply / pow(10,COALESCE(v3.decimals,18)) as token_supplied_v3, v2.amount_supply / pow(10,COALESCE(v2.decimals,18)) as token_supplied_v2from aave_v3_deposit v3LEFT JOIN aave_v2_deposit v2 ON v2.reserve = v3.reserveLEFT JOIN tokens.erc20 tk ON tk.contract_address = v3.reserve),aave_v3_withdraw as (selectw.reserve as reserve, tk.symbol as symbol, sum(cast(w.amount as double)) as amount_withdraw, tk.decimals as decimalsfrom aave_v3_ethereum.Pool_evt_Withdraw wLEFT JOIN tokens.erc20 tk ON tk.contract_address = w.reservewhere date_trunc('day',w.evt_block_time) >= cast('{{start_date}}' as timestamp)group by 1, 2, 4)