Specterproject bytrend
Updated 2024-10-05Copy Reference Fork
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 nearproject AS (
SELECT
Address,
INITCAP(Address_name) AS Address_name,
INITCAP(label_type) AS label,
INITCAP(Project_name) AS Project_name
FROM
near.core.dim_address_labels
WHERE
label_type NOT IN ('cex', 'token')
AND Project_name IS NOT NULL
),
nearprice AS (
SELECT
TRUNC(hour, 'day') AS day,
AVG(price) AS price
FROM
near.price.ez_prices_hourly
WHERE
symbol = 'NEAR'
GROUP BY
day
),
top_projects AS (
-- Calculate total fee for each project and get the top 10 projects
SELECT
npj.Project_name,
SUM((nf.transaction_fee / 1e24) * np.price) AS total_fee_usd
FROM
near.core.fact_transactions nf
JOIN
nearprice np
ON DATE_TRUNC('day', nf.block_timestamp) = np.day
JOIN
nearproject npj
ON nf.tx_receiver = npj.Address
QueryRunArchived: QueryRun has been archived