Nige7777Terra 28 stablecoin volume & price
Updated 2021-07-28
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 cte_eswaps as (
select
sum( CASE when amount0_Adjusted <0 then amount0_Adjusted ELSE 0 END )as UST_SELL,
sum(CASE when amount0_Adjusted >0 then amount0_Adjusted ELSE 0 END) as UST_BUY,
date_trunc(day,block_timestamp) as block_hour,
'ETHEREUM' AS CHAIN
from uniswapv3.swaps s
where 1=1
and s.block_timestamp >= CURRENT_date - 120
and pool_address = '0x868b7bbbfe148516e5397f23982923686182c2d2'
group by block_hour, CHAIN
),
cte_tswaps as (
select
iff(ask_currency = 'UST','BUY','SELL') as TradeType,
iff(Token_0_currency = 'UST',token_0_amount,token_1_amount) as AmountUST,
date_trunc(day,block_timestamp) as block_hour
from terra.swaps s
where 1=1
and s.block_timestamp >= CURRENT_date - 120
and swap_pair like '%UST%'
)
, cte_tswaps_group as (
select
SUM(iff(TradeType ='SELL', -ABS(AmountUST), 0) )as T_UST_SELL,
SUM(iff(TradeType ='BUY', AmountUST, 0)) as T_UST_BUY,
'TERRA' as CHAIN,
block_hour
from cte_tswaps
group by 3,4
Run a query to Download Data