Pmisha-bmlMdxaverage
Updated 2022-05-03
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
›
⌄
with tx as(SELECT
pool_name as pool1,
sum(asset_amount_usd) as tvl
from thorchain.pool_block_balances
where block_timestamp>='2022-03-01'
group by 1 order by 2 desc
limit 15),
tt as(
with t1 as(select
pool_name,
from_address as add1,
block_timestamp as x1
from thorchain.liquidity_actions
where LP_ACTION='add_liquidity'
and pool_name in (select pool1 from tx)
),
t2 as(select
pool_name,
from_address as add2,
block_timestamp as x2
from thorchain.liquidity_actions
where LP_ACTION='remove_liquidity')
select
t1.add1 as address,
t1.pool_name as pools,
abs(DATEDIFF(day, x1,x2)) as average_time
from t1 inner join t2 on t1.add1=t2.add2
)
select pools, avg(average_time) as liquidity_hold from tt group by 1
Run a query to Download Data