Elprognerd4 - join and exit pool monthly
Updated 2022-12-14
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
›
⌄
with main as (select
date_trunc('month', block_timestamp) as date,
ACTION,
tx_id,
liquidity_provider_address,
CURRENCY,
amount,
decimal
from osmosis.core.fact_liquidity_provider_actions
where pool_id = [773] and action in ('pool_joined', 'pool_exited')
)
select
x.date,
ACTION AS "Action type",
count(distinct tx_id) as "Number of liquidity provides",
count(distinct liquidity_provider_address) as "Number of liquidity providers",
sum(amount*price/pow(10,decimal)) as "Total Volume",
avg(amount*price/pow(10,decimal)) as "Average Volume",
median(amount*price/pow(10,decimal)) as "Median Volume",
max(amount*price/pow(10,decimal)) as "Maximum Volume"
from main x join (
select date_trunc('month',block_timestamp) as date,
from_currency as tkn,
avg((to_amount / pow(10 , to_decimal)) / (from_amount / pow(10 , from_decimal))) as price
from osmosis.core.fact_swaps
where to_currency = 'ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858' and to_amount != 0 AND from_amount != 0
and (from_currency = 'ibc/3FF92D26B407FD61AE95D975712A7C319CDE28DE4D80BDC9978D935932B991D7' or from_currency = 'uosmo')
group by 1,2
) y
on x.date = y.date and x.currency = y.tkn
GROUP BY 1, 2
ORDER BY 1 ASC
Run a query to Download Data