nsa2000Top 10 SCRT swap users who profit the most
Updated 2022-10-13Copy Reference Fork
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
›
⌄
with SCRTPricet as (
select recorded_at::date as day,
avg (price) as SCRTPrice
from osmosis.core.dim_prices
where symbol = 'SCRT'
and recorded_at >= CURRENT_DATE - 7
group by 1),
swaptotable as (
select trader,
sum ((from_amount/1e6)*SCRTprice) as USD_Volume
from osmosis.core.fact_swaps t1 join SCRTpricet t2 on t1.block_timestamp::date = t2.day
where from_currency = 'ibc/0954E1C28EB7AF5B72D24F3BC2B47BBB2FDF91BDDFD57B74B99E133AED40972A'
and block_timestamp >= CURRENT_DATE - 7
and tx_status = 'SUCCEEDED'
group by 1),
swapfromtable as (
select trader,
sum ((to_amount/1e6)*SCRTprice) as USD_Volume
from osmosis.core.fact_swaps t1 join SCRTpricet t2 on t1.block_timestamp::date = t2.day
where to_currency = 'ibc/0954E1C28EB7AF5B72D24F3BC2B47BBB2FDF91BDDFD57B74B99E133AED40972A'
and block_timestamp >= CURRENT_DATE - 7
and tx_status = 'SUCCEEDED'
group by 1)
select t1.trader,
sum (t1.usd_volume - t2.usd_volume) as Profit
from swaptotable t1 join swapfromtable t2 on t1.trader = t2.trader
group by 1
order by 2 DESC
limit 10
Run a query to Download Data