CryptoLionlimit orders
Updated 2022-10-04
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 a as (
SELECT DISTINCT
date_trunc('day', block_timestamp) as day,
pool_name,
pool_address,
last_value(token0_balance_usd + token1_balance_usd) over (partition by pool_name order by day) as liq,
last_value(virtual_liquidity_adjusted) over (partition by pool_name order by day) as vliq,
last_value(price_0_1) over (partition by pool_name order by day) as cp
FROM uniswapv3.pool_stats ps1
WHERE block_timestamp >= getdate() - interval '2 day'
AND token0_balance_usd >= 0
AND token1_balance_usd >= 0
--
-- AND pool_name LIKE 'WBTC-WETH%'
--
HAVING day = '2021-06-12'
ORDER BY 4 DESC
LIMIT 15),
b as (
SELECT DISTINCT
-- block_timestamp,
last_value(liquidity_provider) over (partition by liquidity_provider, po.pool_name order by block_timestamp) as liq_provider,
last_value(po.pool_name) over (partition by liquidity_provider, po.pool_name order by block_timestamp) as pool_name,
last_value(liquidity_adjusted) over (partition by liquidity_provider, po.pool_name order by block_timestamp) as liq_adj,
last_value(price_lower_0_1) over (partition by liquidity_provider, po.pool_name order by block_timestamp) as pl,
last_value(price_upper_0_1) over (partition by liquidity_provider, po.pool_name order by block_timestamp) as pu
FROM uniswapv3.positions po
INNER JOIN a on po.pool_name = a.pool_name
WHERE
is_active = 'TRUE'
)
-- SELECT *
-- FROM a
Run a query to Download Data