Query editor
-- AAVEv3_ethereum_daily_events_vol_usdWITH prices AS (SELECTminute AS dt,contract_address,price usd_price,symbolFROM prices.usdWHERE blockchain = 'ethereum'-- AND minute(minute) % 5 = 0),-- Combine and aggregate 1 minute interval events, convert amounts to USDinterval_events_usd AS (SELECTdate_trunc('minute', evt.evt_block_time) AS dt,evt.event_type,borrower,t.symbol token,SUM(evt.amount) AS total_amount, -- Total amount of tokens involved in eventsSUM(evt.amount * p.usd_price / POWER(10, t.decimals)) AS total_usd -- Converted to USDFROM (SELECT evt_block_time, 'Deposit' AS event_type, reserve AS token_address, onBehalfOf borrower, amountFROM aave_v3_ethereum.Pool_evt_Supplywhere reserve in (0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) -- USDC, WETHUNION ALLSELECT evt_block_time, 'Borrow' AS event_type, reserve AS token_address, onBehalfOf borrower, amountFROM aave_v3_ethereum.Pool_evt_Borrowwhere reserve in (0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) -- USDC, WETHUNION ALLSELECT evt_block_time, 'Repay' AS event_type, reserve AS token_address, repayer borrower, amountFROM aave_v3_ethereum.Pool_evt_Repaywhere reserve in (0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) -- USDC, WETHUNION ALLSELECT evt_block_time, 'Withdraw' AS event_type, reserve AS token_address, "to" borrower, amountFROM aave_v3_ethereum.Pool_evt_Withdrawwhere reserve in (0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) -- USDC, WETH) AS evtJOIN prices p ON date_trunc('minute', evt.evt_block_time) = p.dt AND evt.token_address = p.contract_addressJOIN tokens.erc20 t ON evt.token_address = t.contract_address AND t.blockchain = 'ethereum'GROUP BY 1,2,3,4),-- Final Selectionresults AS (SELECTdt,borrower,event_type AS event,token,SUM(total_usd) AS total_usd_value -- Summing the total USD value by event typeFROM interval_events_usdGROUP BY 1,2,3,4),results_position as (SELECTborrower,dt,token,