HosseinUntitled Query
Updated 2022-12-13
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
›
⌄
with prices as (
select trunc(block_timestamp::date, 'day') as day,
from_currency as currency,
avg ((to_amount / pow(10, to_decimal))/(from_amount/pow(10, from_decimal))) as price_usd
from osmosis.core.fact_swaps
where from_currency in ('uosmo', 'ibc/3FF92D26B407FD61AE95D975712A7C319CDE28DE4D80BDC9978D935932B991D7')
and to_currency in ('ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858', 'ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7') -- USDC, DAI
and to_amount > 0
and from_amount > 0
and tx_status = 'SUCCEEDED'
group by 1, 2
)
select count (distinct tx_id) as lprovicers_tx_count,
count (distinct (liquidity_provider_address)) as lproviders_count,
sum ((amount * price_usd) / pow(10,decimal)) as total_amount,
avg ((amount * price_usd) / pow(10,decimal)) as avg_amount,
median ((amount * price_usd) / pow(10,decimal)) as median_amount
from osmosis.core.fact_liquidity_provider_actions a
join prices
on prices.day = a.block_timestamp::date
and prices.currency = a.currency
where action = 'pool_joined'
and pool_id [0] = '773'
and day >= '2022-01-01'
and tx_status = 'SUCCEEDED'
Run a query to Download Data