feyikemi2024-04-25 01:09 PM
Updated 2024-04-25
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
›
⌄
-- Credits to 0xHaM-d, his query on 'Top Projects Based on Transactions' helped put this query together
WITH Price as (
SELECT
hour :: date as p_date,
symbol,
avg(PRICE) as usd_price
FROM
aptos.price.ez_hourly_token_prices
WHERE
symbol = 'APT'
GROUP BY 1, 2
),
Fee AS (
SELECT
date_trunc('day', block_timestamp) AS Date,
label_type,
INITCAP(Label) as DEXs,
avg(EVENT_DATA:amount/pow(10,DECIMALS)) as amount,
FROM
aptos.core.fact_events a
JOIN aptos.core.dim_labels b on address = event_address
JOIN aptos.core.dim_tokens c on a.event_address = c.token_address
WHERE
b.label_type = 'dex'
--AND SUCCESS = true
AND tx_type = 'user_transaction'
AND date > current_date - 30
)
SELECT
Date,
DEXs,
SUM(amount *usd_price) as USD_Volume
QueryRunArchived: QueryRun has been archived