sunshine-juliapool stables-stables - duration
Updated 2023-10-26
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 table_1 as (select case when
(token0_symbol in (select distinct symbol from external.defillama.dim_stablecoins
where chains[0] = 'Ethereum') or (token1_symbol in (select distinct symbol from external.defillama.dim_stablecoins
where chains[0] = 'Ethereum')))
and (token0_symbol = 'WETH' or token1_symbol = 'WETH') then 'pool Eth-stables'
when (token0_symbol in (select distinct symbol from external.defillama.dim_stablecoins
where chains[0] = 'Ethereum')) and (token1_symbol in (select distinct symbol from external.defillama.dim_stablecoins
where chains[0] = 'Ethereum')) then 'pool stable-stable'
else 'pool stable-other' end as pool_classification,
liquidity_provider as LPer_1, pool_address, pool_name, pool_address || pool_name,
min(block_timestamp) as enter_time
from (select *, amount0_usd+amount1_usd as add_liquidity
from ethereum.uniswapv3.ez_lp_actions
where not add_liquidity is NULL and add_liquidity >0 and add_liquidity < pow(10,9)
and action ilike 'INCREASE_LIQUIDITY')
group by 1,2,3,4,5),
table_2 as (select case when
(token0_symbol in (select distinct symbol from external.defillama.dim_stablecoins
where chains[0] = 'Ethereum') or (token1_symbol in (select distinct symbol from external.defillama.dim_stablecoins
where chains[0] = 'Ethereum')))
and (token0_symbol = 'WETH' or token1_symbol = 'WETH') then 'pool Eth-stables'
when (token0_symbol in (select distinct symbol from external.defillama.dim_stablecoins
where chains[0] = 'Ethereum')) and (token1_symbol in (select distinct symbol from external.defillama.dim_stablecoins
where chains[0] = 'Ethereum')) then 'pool stable-stable'
else 'pool stable-other' end as pool_classification,
liquidity_provider as LPer_2, pool_address, pool_name, pool_address || pool_name as pool,
max(block_timestamp) as leave_time
from (select *, amount0_usd+amount1_usd as remove_liquidity
from ethereum.uniswapv3.ez_lp_actions
where not remove_liquidity is NULL and remove_liquidity >0 and remove_liquidity < pow(10,9)
and action ilike 'DECREASE_LIQUIDITY')
group by 1,2,3,4,5),
table_3 as (select table_1.pool_classification, LPer_1 as liquidity_provider, table_1.pool_address, pool, datediff(days, enter_time, leave_time) as duration
from table_1 join table_2 on LPer_1 = LPer_2 and table_1.pool_address = table_1.pool_address)
select pool_classification,
case when duration > 0 and duration < 5 then 'Less than 5 days'
Run a query to Download Data