sintenshinStats by New Criteria
Updated 2023-11-27
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
›
⌄
-- forked from Users by Points @ https://flipsidecrypto.xyz/edit/queries/8d3efb70-6d35-41b8-ad6b-542ec2d66dab
with tb AS (
select
SWAPPER AS user,
count(*) AS TX,
sum(case when SWAP_TO_AMOUNT*B.Close is not null then SWAP_TO_AMOUNT*B.Close
else SWAP_From_AMOUNT*C.Close end ) AS Volume,
count(DISTINCT date_trunc('Month',BLOCK_TIMESTAMP)) AS Months,
count(DISTINCT date_trunc('Week',BLOCK_TIMESTAMP)) AS Weeks,
sum(case when Swap_program like 'jupiter aggregator v2' then 1 else 0 end) AS "Before V3 upgrade TX",
rank() over (order by Volume desc) AS rank,
sum(case when Block_timestamp::date >= '2023-01-01' then 1 else 0 end) AS "2023 TXs",
sum(Case when Block_timestamp::date between '2021-01-01' and '2021-12-30' then 1 else 0 end) AS "2021 TXs"
from
solana.defi.fact_swaps
left join solana.price.ez_token_prices_hourly B on date_trunc('Hour',BLOCK_TIMESTAMP)=B.RECORDED_HOUR
and SWAP_TO_MINT=B.TOKEN_ADDRESS
left join solana.price.ez_token_prices_hourly C on date_trunc('Hour',BLOCK_TIMESTAMP)=C.RECORDED_HOUR
and SWAP_FROM_MINT=C.TOKEN_ADDRESS
where
Swap_program like 'jupiter%'
group by 1)
select
Volume,
TX,
rank,
case
when rank <= 2000 then 'Top 2K User'
when rank <= 10000 and rank > 2000 then 'Top 10K User'
when rank <= 50000 and rank > 10000 then 'Top 50K User'
when rank <= 150000 and rank > 50000 then 'Top 150K User'
when rank <= 500000 and rank > 150000 then 'Top 500K User'
when rank <= 1000000 and rank > 500000 then 'Top 1M User'
end AS Tire,
Run a query to Download Data