zakkisyedDaily Volumes & Transactions
Updated 2023-05-05
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 transfer_data AS (
SELECT
date_trunc('{{time-range}}', block_timestamp) AS date,
b.label_type,
project_name,
tx_hash,
origin_from_address,
event_inputs:value / 1e18 AS volume,
origin_to_address AS to_address
FROM ethereum.core.fact_event_logs a
LEFT JOIN ethereum.core.dim_labels b ON a.origin_to_address = b.address
LEFT JOIN crosschain.core.address_labels c ON a.origin_to_address = c.address
WHERE
contract_address = LOWER('{{token-contract}}')
AND event_name IN ('Transfer')
AND project_name IS NOT NULL
),
usd_price AS (
SELECT
date_trunc('hour', hour) AS date,
price
FROM crosschain.core.ez_hourly_prices
WHERE token_address = '{{token-contract}}'
ORDER BY date
)
SELECT
td.date,
td.label_type,
td.project_name,
COUNT(DISTINCT td.tx_hash) AS "Transaction count",
COUNT(DISTINCT td.origin_from_address) AS "User count",
SUM(td.volume) AS volume,
SUM(td.volume * usd_price.price) AS volume_usd
FROM transfer_data td
JOIN usd_price ON td.date = usd_price.date
GROUP BY td.date, td.label_type, td.project_name