KARTODCurrent Provided Distribution
Updated 2022-06-26Copy Reference Fork
999
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 add_lp as (
select
from_address,
pool_name,
sum(rune_amount_usd + asset_amount_usd) as Total_Supplied
from thorchain.liquidity_actions
where lp_action = 'add_liquidity' and from_address is not null
group by 1,2
),
remove_lp as (
select
from_address,
pool_name,
sum(rune_amount_usd + asset_amount_usd) as total_removed
from thorchain.liquidity_actions
where lp_action = 'remove_liquidity' and from_address in (select from_address from add_lp)
group by 1,2
),
final as (
select
a.from_address,
a.pool_name,
a.total_supplied,
b.total_removed,
CASE
when b.total_removed is null then 0
else b.total_removed
end as rem_lp,
(a.total_supplied - rem_lp) as current_lp_position_usd
from add_lp a
left outer join remove_lp b on a.from_address = b.from_address and a.pool_name = b.pool_name
),
address AS (
Run a query to Download Data