binhachon11. [Easy] Liquidity provision - Add_amount_usd
Updated 2021-10-30
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
›
⌄
with lp_actions as(
select date_trunc('day', block_timestamp) as blocktime,
case when position('-', pool_name, 1) = 0 then pool_name else
substr(pool_name, 1, position('-', pool_name, 1) - 1) end as pool_name,
lp_action, rune_amount_usd + asset_amount_usd as amount_usd
from thorchain.liquidity_actions
),
add_remove_liquidity as(
select blocktime, pool_name, sum(amount_usd) as add_amount_usd, 0 as withdraw_amount_usd from lp_actions
where lp_action = 'add_liquidity'
group by blocktime, pool_name
union all
select blocktime, pool_name, 0 as add_amount_usd, sum(amount_usd) as withdraw_amount_usd from lp_actions
where lp_action = 'remove_liquidity'
group by blocktime, pool_name
)
select blocktime, pool_name, sum(add_amount_usd) as add_amount_usd, sum(withdraw_amount_usd) from add_remove_liquidity
where blocktime > getdate() - interval'30 days'
group by blocktime, pool_name
order by blocktime desc, add_amount_usd
Run a query to Download Data