feyikemi2024-05-15 01:45 AM
Updated 2024-05-15
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 tab0 as (
select
date_trunc('day', block_timestamp) as Date,
sum(case
when swap_from_mint like '8wXtPeU6557ETkp9WHFY1n1EcU6NxDvbAggHGsMYiHsB' then swap_from_amount
else swap_to_amount END) as Swap_amount,
count(*) as Swaps,
count(distinct swapper) as Swappers
from solana.defi.fact_swaps
where swap_from_mint like '8wXtPeU6557ETkp9WHFY1n1EcU6NxDvbAggHGsMYiHsB'
or swap_to_mint like '8wXtPeU6557ETkp9WHFY1n1EcU6NxDvbAggHGsMYiHsB'
group by 1
)
, tab1 as (
select
date_trunc('day', hour) as Date,
avg(price) as price
from solana.price.ez_prices_hourly
where TOKEN_ADDRESS like '8wXtPeU6557ETkp9WHFY1n1EcU6NxDvbAggHGsMYiHsB'
group by 1
)
select
tab0.date as Date,
Swap_amount * price as Swap_Volume_USD,
SUM(Swap_amount * price) OVER (ORDER BY tab0.Date) AS Cumulative_Swap_Volume_USD,
Swaps,
Swappers
from tab0 left outer join tab1 on tab0.date = tab1.date
QueryRunArchived: QueryRun has been archived