Query editor
with price_ron as (selectdate_trunc('day', timestamp) as day,max(price) as pricefrom prices.daywhere blockchain = 'ronin' and contract_address in (0xe514d9deb7966c8be0ca922de8a064264ea6bcd4) -- RONand timestamp < date_trunc('hour', now())and timestamp >= now() - interval '{{hours}}' hour - interval '25' hourGROUP BY 1),price_eth as (selectdate_trunc('day', timestamp) as day,pricefrom prices.daywhere blockchain = 'ethereum' and contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 -- ETHand timestamp < date_trunc('hour', now())and timestamp >= now() - interval '{{hours}}' hour - interval '25' hour),prices as (selectron.day,ron.price as price_ron,eth.price as price_eth,ron.price/eth.price as ron_per_ethfrom price_ron roninner join price_eth eth on ron.day = eth.day)selectdate_trunc('hour', block_time) as "timestamp",'ronin' as origin_key,--count(*) FILTER (WHERE gas_price > 0) as txcount,count(*) as txcount,count(*) as txcount_plain,count(*) as txcount_comparison,SUM(gas_used) / (60 * 60) AS gas_per_second,--COUNT(distinct "from") AS daa,SUM((gas_used * (gas_price / 1e18) + coalesce(l1_fee / 1e18, 0)) * ron_per_eth) AS fees_paid_eth,approx_percentile((gas_used * (gas_price / 1e18) + coalesce(l1_fee / 1e18, 0)) * ron_per_eth, 0.5) FILTER (WHERE gas_price > 0) as txcosts_median_eth,count(distinct "from") as daafrom ronin.transactions tleft join prices p on t.block_date = p.daywhere block_date >= date_trunc('day', now() - interval '{{hours}}' hour) -- for better partitioningand block_time < date_trunc('hour', now())and block_time >= date_trunc('hour', now() - interval '{{hours}}' hour)group by 1