Query editor
withsupply_v3 as(selectdate_trunc('day',s.evt_block_time) as time, s.reserve as reserve, sum(cast(s.amount as double)) as amountfrom aave_v3_ethereum.Pool_evt_Supply as sgroup by 1,2), withdrawals_v3 as(selectdate_trunc('day',w.evt_block_time) as time, w.reserve reserve, sum(cast(w.amount as double)) as amountfrom aave_v3_ethereum.Pool_evt_Withdraw wgroup by 1,2), net_supply_v3 as (selectCOALESCE(s.time, w.time) as time-- , COALESCE(s.reserve, w.reserve) as reserve-- , coalesce(s.amount,0) as amount_added-- , COALESCE(w.amount,0) as amount_removed, sum((s.amount - w.amount) / pow(10,COALESCE(tk.decimals,18)) * p.price) as net_supply_usd_v3from supply_v3 sfull outer join withdrawals_v3 won s.time = w.timeand s.reserve = w.reserveLEFT JOIN tokens.erc20 tk ON tk.contract_address = s.reserveLEFT JOIN prices.usd p ON p.minute = date_trunc('minute',s.time) AND p.blockchain = 'ethereum' AND p.contract_address = s.reservegroup by 1), supply_v2 as(selectdate_trunc('day',s.evt_block_time) as time, s.reserve as reserve, sum(cast(s.amount as double)) as amountfrom aave_v2_ethereum.LendingPool_evt_Deposit as sgroup by 1,2), withdrawals_v2 as(selectdate_trunc('day',w.evt_block_time) as time, w.reserve reserve, sum(cast(w.amount as double)) as amountfrom aave_v2_ethereum.LendingPool_evt_Withdraw wgroup by 1,2), net_supply_v2 as (selectCOALESCE(s.time, w.time) as time