maybeyonasthor_standard_vol_monthly
Updated 2022-05-16
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
latest_prices as (
select * from (
select
pool_name,
asset_usd,
price_asset_rune,
rune_usd,
rank() over(partition by pool_name order by block_id desc) as rank
from thorchain.prices
)
where rank = 1
),
swap_daily_data as (
select
last_day(block_timestamp,'month') as date,
split(s.pool_name,'-')[0]::string as pool_name,
asset_usd,
price_asset_rune,
rune_usd,
sum(case when from_asset = 'THOR.RUNE' then from_amount else to_amount end) as rune_amount,
sum(case when from_asset = 'THOR.RUNE' then to_amount else from_amount end) as asset_amount
from thorchain.swaps s join latest_prices l on s.pool_name = l.pool_name
group by 1,2,3,4,5
)
select
date,
pool_name,
rune_amount,
rune_amount*rune_usd as rune_amount_usd,
asset_amount,
asset_amount/price_asset_rune as asset_amount_rune,
asset_amount*asset_usd as asset_amount_usd
from swap_daily_data
-- limit 100
Run a query to Download Data