Moelpoms0
Updated 2023-02-09
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 bs as (with prices as (
select
RECORDED_HOUR::date as days , SYMBOL,CURRENCY,
avg(price) as prices
from
osmosis.core.ez_prices
group by 1 ,2,3
)
,fin as (
select
b.*,prices,AMOUNT/pow(10,decimal) as AMOUNTs ,
AMOUNTs*prices as AMOUNT_usd
from
osmosis.core.fact_liquidity_provider_actions b,prices p
where
block_timestamp::date = days and b.CURRENCY = p.CURRENCY
and AMOUNT is not null
)
select
date_trunc (week,BLOCK_TIMESTAMP)::date as weeks ,
POOL_ID ,
sum(case when action = 'pool_joined' then AMOUNT_usd end ) as deposit,
sum(case when action = 'pool_exited' then AMOUNT_usd end ) as withdraw,
deposit-withdraw as net_usd
from
fin
where action in ('pool_joined','pool_exited')
group by 1,2
Run a query to Download Data