cypherRUNE LP-retention
Updated 2022-04-24
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 first_month_liquidity_adding as (select
date_trunc('month', min(block_timestamp)) as month,
from_address as address
from thorchain.liquidity_actions
where lp_action = 'add_liquidity'
and from_address is not null
group by address
),
n_users_month as (select month, count(*) as n_users
from first_month_liquidity_adding
group by month),
liquidity_add as (select
from_address,
sum(rune_amount) as total_rune_added
from thorchain.liquidity_actions
where lp_action = 'add_liquidity'
and from_address is not null
group by from_address
),
liquidity_remove as ( select
from_address,
sum(rune_amount) as total_rune_withdrawn
from thorchain.liquidity_actions
where lp_action = 'remove_liquidity'
and from_address is not null
group by from_address
),
net_liquidity_balance as (select
a.from_address as address,
a.total_rune_added - r.total_rune_withdrawn as lp_balance,
iff(lp_balance < 0, 0, lp_balance ) as real_lp_balance
from liquidity_add a, liquidity_remove r