Afonso_Diazsushiswap-4-gnosis
Updated 2023-03-18
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 t1 as (
select
avg(swaps) as daily_average_swaps,
avg(swappers) as daily_average_swappers
from (
select
block_timestamp::date as day,
count(distinct tx_hash) as swaps,
count(distinct origin_from_address) as swappers,
sum(iff(symbol_in in ('FRAX', 'LUSD', 'BUSD', 'TUSD', 'USDN', 'GUSD', 'USDC', 'DAI', 'USDP', 'FEI', 'sUSD', 'AMUSDC', 'USDD', 'USDT', 'MIM'), amount_in, amount_out)) as swap_volume_usd,
sum(swaps) over (order by day) as cumulative_swaps,
sum(swap_volume_usd) over (order by day) as cumulative_swap_volume_usd
from gnosis.sushi.ez_swaps
where (
symbol_in in ('FRAX', 'LUSD', 'BUSD', 'TUSD', 'USDN', 'GUSD', 'USDC', 'DAI', 'USDP', 'FEI', 'sUSD', 'AMUSDC', 'USDD', 'USDT', 'MIM') or
symbol_out in ('FRAX', 'LUSD', 'BUSD', 'TUSD', 'USDN', 'GUSD', 'USDC', 'DAI', 'USDP', 'FEI', 'sUSD', 'AMUSDC', 'USDD', 'USDT', 'MIM')
)
and block_timestamp > current_date - interval '3 months'
group by 1
)
),
t2 as (
select
count(distinct tx_hash) as total_swaps,
count(distinct origin_from_address) as total_swappers,
sum(iff(symbol_in in ('FRAX', 'LUSD', 'BUSD', 'TUSD', 'USDN', 'GUSD', 'USDC', 'DAI', 'USDP', 'FEI', 'sUSD', 'AMUSDC', 'USDD', 'USDT', 'MIM'), amount_in, amount_out)) as total_swap_volume_usd,
avg(iff(symbol_in in ('FRAX', 'LUSD', 'BUSD', 'TUSD', 'USDN', 'GUSD', 'USDC', 'DAI', 'USDP', 'FEI', 'sUSD', 'AMUSDC', 'USDD', 'USDT', 'MIM'), amount_in, amount_out)) as average_swap_volume_usd,
median(iff(symbol_in in ('FRAX', 'LUSD', 'BUSD', 'TUSD', 'USDN', 'GUSD', 'USDC', 'DAI', 'USDP', 'FEI', 'sUSD', 'AMUSDC', 'USDD', 'USDT', 'MIM'), amount_in, amount_out)) as median_swap_volume_usd,
sum(tx_fee) as total_fee_xdai,
avg(tx_fee) as average_fee_xdai
from gnosis.sushi.ez_swaps
join gnosis.core.fact_transactions
using (tx_hash)
where (
symbol_in in ('FRAX', 'LUSD', 'BUSD', 'TUSD', 'USDN', 'GUSD', 'USDC', 'DAI', 'USDP', 'FEI', 'sUSD', 'AMUSDC', 'USDD', 'USDT', 'MIM') or
Run a query to Download Data