Query editor
WITH swaps AS (SELECTdate_trunc('hour', block_time) AS hour,block_time,-- RVH per WETH = (sqrtPriceX96 / 2^96)^2 ; both tokens are 18 decimals1.0 / power(CAST(bytearray_to_uint256(bytearray_substring(data, 65, 32)) AS double) / power(2, 96), 2) AS rvh_price_wethFROM robinhood.logsWHERE contract_address = 0xfbd1b5e73760b59b65c63cf8214bfd96eb4f4870AND topic0 = 0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67),hourly AS (SELECT hour, max_by(rvh_price_weth, block_time) AS price_wethFROM swapsGROUP BY 1),eth AS (SELECT date_trunc('hour', minute) AS hour, avg(price) AS eth_usdFROM prices.usdWHERE blockchain = 'ethereum' AND symbol = 'WETH'AND minute >= now() - interval '90' dayGROUP BY 1)SELECT h.hour, h.price_weth, h.price_weth * e.eth_usd AS price_usdFROM hourly hLEFT JOIN eth e ON e.hour = h.hourORDER BY h.hour