MLDZMNsdx2
Updated 2023-05-12
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
›
⌄
with tb2 AS (
select
RECORDED_HOUR::date as day,
SYMBOL,
TOKEN_ADDRESS,
avg(close) as price_token
from solana.core.ez_token_prices_hourly
group by 1,2,3)
select
date_trunc('{{Time_basis}}',BLOCK_TIMESTAMP) as date,
count(distinct tx_id) as no_swaps,
count(distinct SWAPPER) as no_trader,
--count(distinct POOL_NAME) as no_pools
sum(SWAP_TO_AMOUNT*price_token) as volume_usd,
avg(SWAP_TO_AMOUNT*price_token) as average_volume,
Median(SWAP_TO_AMOUNT*price_token) as median_volume,
avg(average_volume) OVER (ORDER BY date ROWS BETWEEN 7 PRECEDING AND CURRENT ROW) as MA_7_Days_volume,
sum(no_trader) over (order by date) as total_traders,
sum(no_swaps) over (order by date) as Total_swap,
sum(volume_usd) over (order by date) as total_volume
from solana.core.fact_swaps x
join tb2 y on x.SWAP_to_MINT=y.TOKEN_ADDRESS and x.BLOCK_TIMESTAMP::date=y.day
where SUCCEEDED='TRUE'
and PROGRAM_ID ilike 'JUP%'
and SWAP_to_AMOUNT*price_token < 1e6
AND block_timestamp >=CURRENT_DATE- {{Time_period_days}}
group by 1
Run a query to Download Data