Ali3NTotal Inflow / Outflow / Net Flow From/To CEX (Solana) METRICS
Updated 2022-11-21
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 pricet as (
select block_timestamp::date as day,
swap_from_mint as token,
median (swap_to_amount/swap_from_amount) as USDPrice
from solana.fact_swaps
where swap_to_mint in ('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v','Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB') --USDC,USDT
and swap_to_amount > 0
and swap_from_amount > 0
and block_timestamp >= CURRENT_DATE - 21
and succeeded = 'TRUE'
group by 1,2),
cext as (
select *
from solana.core.dim_labels
where label_type ilike '%cex%'),
Inflowt as (
select sum (amount*USDPrice) as Inflow_Volume
from solana.core.fact_transfers t1 join pricet t2 on t1.block_timestamp::date = t2.day and t1.mint = t2.token
where tx_to in (select distinct address from cext)
and tx_from not in (select distinct address from cext)
and block_timestamp >= CURRENT_DATE - 21),
Outflowt as (
select sum (amount*USDPrice) as Outflow_Volume
from solana.core.fact_transfers t1 join pricet t2 on t1.block_timestamp::date = t2.day and t1.mint = t2.token
where tx_from in (select distinct address from cext)
and tx_to not in (select distinct address from cext)
and block_timestamp >= CURRENT_DATE - 21)
select inflow_volume as Inflow,
outflow_volume*-1 as Outflow,
inflow_volume - outflow_volume as Net_Flow
from Inflowt t1 join Outflowt t2
Run a query to Download Data