Query editor
WITH inflows AS (SELECTdate_trunc('day', t.block_time) AS day,SUM(t.amount) / 1e18 AS eth_inFROM tokens_ethereum.transfers tINNER JOIN dune.hildobby.dataset_ethereum_etf_addresses aON a.address = t.to AND a.track_inflow = trueWHERE t.token_standard = 'native'AND t.block_time >= date('2024-07-24')GROUP BY 1),outflows AS (SELECTdate_trunc('day', t.block_time) AS day,SUM(t.amount) / 1e18 AS eth_outFROM tokens_ethereum.transfers tINNER JOIN dune.hildobby.dataset_ethereum_etf_addresses aON a.address = t."from" AND a.track_outflow = trueWHERE t.token_standard = 'native'AND t.block_time >= date('2024-07-24')GROUP BY 1),daily_flows AS (SELECTCOALESCE(i.day, o.day) AS day,COALESCE(eth_in, 0) - COALESCE(eth_out, 0) AS flow_ethFROM inflows iFULL OUTER JOIN outflows o ON i.day = o.day)SELECTdf.day,df.flow_eth,df.flow_eth * p.price AS flow_usdFROM daily_flows dfLEFT JOIN prices.usd_forward_fill pON p.blockchain IS NULLAND p.symbol = 'ETH'AND p.minute = df.day -- минута ровно в полночь UTC, данные forward-fill сами заполнят последнюю ценуORDER BY df.day DESC