Pine Analyticsredundant-indigo
Updated 2025-02-17
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
WITH eth_prices AS (
SELECT
DATE(hour) AS day,
MEDIAN(price) AS eth_price
FROM ethereum.price.ez_prices_hourly
WHERE token_address = LOWER('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')
GROUP BY 1
),
chain_metrics AS (
SELECT
date_trunc('week', block_timestamp) as week,
'Base' AS chain_name,
COUNT(DISTINCT from_address) AS active_users,
COUNT(*) AS transaction_count,
SUM(tx_fee) AS gas_fees_eth,
SUM(tx_fee * ep.eth_price) AS gas_fees_usd
FROM base.core.fact_transactions ft
LEFT JOIN eth_prices ep ON DATE(ft.block_timestamp) = ep.day
WHERE ft.block_timestamp >= '2024-03-13'
GROUP BY 1,2
UNION ALL
SELECT
date_trunc('week', block_timestamp) as week,
'Blast' AS chain_name,
COUNT(DISTINCT from_address) AS active_users,
COUNT(*) AS transaction_count,
SUM(tx_fee) AS gas_fees_eth,
SUM(tx_fee * ep.eth_price) AS gas_fees_usd
FROM blast.core.fact_transactions ft
LEFT JOIN eth_prices ep ON DATE(ft.block_timestamp) = ep.day
WHERE ft.block_timestamp >= '2024-03-13'
GROUP BY 1,2
UNION ALL