HosseinUntitled Query
Updated 2022-12-19
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
›
⌄
select * from(
(select --date_trunc('{{Period}}', BLOCK_TIMESTAMP) as date,
'In' as cat,
case when TO_CURRENCY = 'ibc/B3504E092456BA618CC28AC671A71FB08C6CA0FD0BE7C8A5B5A3E2DD933CC9E4' then 'axlUSDC'
when TO_CURRENCY = 'ibc/CBF67A2BCF6CAE343FDF251E510C8E18C361FC02B23430C121116E0811835DEF' then 'axlUSDT' end as currency,
count(DISTINCT tx_id) as tx_count,
sum(TO_AMOUNT/pow(10,FROM_DECIMAL)) as amount
from terra.core.ez_swaps
where TX_SUCCEEDED = 'TRUE'
and TO_CURRENCY in ('ibc/B3504E092456BA618CC28AC671A71FB08C6CA0FD0BE7C8A5B5A3E2DD933CC9E4', 'ibc/CBF67A2BCF6CAE343FDF251E510C8E18C361FC02B23430C121116E0811835DEF')
and BLOCK_TIMESTAMP >= CURRENT_DATE - {{DaysAgo}}
group by 1,2)
UNION ALL
(select --date_trunc('{{Period}}', BLOCK_TIMESTAMP) as date,
'Out' as cat,
case when FROM_CURRENCY = 'ibc/B3504E092456BA618CC28AC671A71FB08C6CA0FD0BE7C8A5B5A3E2DD933CC9E4' then 'axlUSDC'
when FROM_CURRENCY = 'ibc/CBF67A2BCF6CAE343FDF251E510C8E18C361FC02B23430C121116E0811835DEF' then 'axlUSDT' end as currency,
count(DISTINCT tx_id) as tx_count,
sum(FROM_AMOUNT/pow(10,FROM_DECIMAL)) as amount
from terra.core.ez_swaps
where TX_SUCCEEDED = 'TRUE'
and FROM_CURRENCY in ('ibc/B3504E092456BA618CC28AC671A71FB08C6CA0FD0BE7C8A5B5A3E2DD933CC9E4', 'ibc/CBF67A2BCF6CAE343FDF251E510C8E18C361FC02B23430C121116E0811835DEF')
and BLOCK_TIMESTAMP >= CURRENT_DATE - {{DaysAgo}}
group by 1,2))
Where currency = 'axlUSDT'
Run a query to Download Data