banbannardTop Liquidity Fee by Chain and Month
Updated 2024-09-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
›
⌄
-- forked from Top Swap Path by Month @ https://flipsidecrypto.xyz/edit/queries/415e45c4-8b22-409a-bf58-a3fb7e3caf6c
with base as (select
date_trunc('month', block_timestamp) as month,
tx_id,
split(from_asset, '-')[0] as from_chains,
case
when from_chains ilike '%/%' then split(from_chains, '/')[0]
else split(from_chains, '.')[0]
end as from_chain_names,
split(to_asset, '-')[0] as to_chains,
case
when to_chains ilike '%/%' then split(to_chains, '/')[0]
else split(to_chains, '.')[0]
end as to_chain_names,
iff(from_chain_names = 'THOR', to_chain_names, from_chain_names) as chain_names,
sum(liq_fee_rune) as liq_fee_rune,
sum(LIQ_FEE_RUNE_USD) as liq_fee_rune_usd
from thorchain.defi.fact_swaps
where --block_timestamp >= '2022-01-01'
block_timestamp <= '2023-12-31'
group by month, tx_id, from_asset, to_asset)
select month, chain_names, sum(liq_fee_rune) as liquidity_fee, sum(liq_fee_rune_usd) as liq_fee_usd,
sum(liq_fee_usd) over (partition by chain_names order by month) as cumulative_liquidity_fee_usd,
sum(liquidity_fee) over (partition by chain_names order by month) as cumulative_liquidity_fee,
(select sum(liq_fee_rune) from base) as total_liq_rune,
(select sum(liq_fee_rune_usd) from base) as total_liq_rune_usd
from base
group by 1,2
order by 3 desc
QueryRunArchived: QueryRun has been archived