Eman-RazVolume distribution of traders for each stablecoin(%Normalized)
Updated 2023-05-31
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 final_tab2 as (with final_tab as (with tab1 as (select trader, sum(token_in_amount) as selling_volume, token_in_contract
from flow.core.ez_swaps
where block_timestamp::date>='{{Start_Date}}' and block_timestamp::date<='{{End_Date}}'
and token_in_contract in ('A.3c5959b568896393.FUSD','A.b19436aae4d94622.FiatToken',
'A.cfdd90d4a00f7b5b.TeleportedTetherToken')
group by 1,3
order by 1),
tab2 as (select trader, sum(token_out_amount) as buying_volume, token_out_contract
from flow.core.ez_swaps
where block_timestamp::date>='{{Start_Date}}' and block_timestamp::date<='{{End_Date}}'
and token_out_contract in ('A.3c5959b568896393.FUSD','A.b19436aae4d94622.FiatToken',
'A.cfdd90d4a00f7b5b.TeleportedTetherToken')
group by 1,3
order by 1)
select tab1.trader as trader, case
when selling_volume is null and buying_volume is not null then buying_volume
when selling_volume is not null and buying_volume is null then selling_volume
when selling_volume is not null and buying_volume is not null then buying_volume+selling_volume
end as "Swap Volume", case
when token_in_contract='A.3c5959b568896393.FUSD' then 'FUSD'
when token_in_contract='A.b19436aae4d94622.FiatToken' then 'USDC'
when token_in_contract='A.cfdd90d4a00f7b5b.TeleportedTetherToken' then 'USDT'
end as "Stablecoin"
from tab1 left join tab2 on tab1.trader=tab2.trader and tab1.token_in_contract=tab2.token_out_contract
order by 1)
select "Stablecoin", trader, case
when "Swap Volume"<=1 then 'V<=1'
WHEN "Swap Volume">1 AND "Swap Volume"<=10 THEN '1<V<=10'
WHEN "Swap Volume">10 AND "Swap Volume"<=100 THEN '10<V<=100'
WHEN "Swap Volume">100 AND "Swap Volume"<=1000 THEN '100<V<=1K'
WHEN "Swap Volume">1000 AND "Swap Volume"<=10000 THEN '1K<V<=10K'
WHEN "Swap Volume">10000 AND "Swap Volume"<=100000 THEN '10K<V<=100K'
WHEN "Swap Volume">100000 THEN 'V>100K'
Run a query to Download Data