Multipartite(Auto-updating) AVAX.USDC pool depths
Updated 2023-04-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
27
28
29
30
31
32
33
›
⌄
WITH
dim_convert AS (
SELECT block_timestamp, block_id
FROM thorchain.core.dim_block
),
for_row_sampling AS
(
SELECT depths.block_timestamp, block_id,
POWER(10,-8) * asset_e8 AS asset_depth,
POWER(10,-8) * rune_e8 AS rune_depth
FROM (thorchain.core.fact_block_pool_depths AS depths INNER JOIN dim_convert ON depths.block_timestamp = dim_convert.block_timestamp)
WHERE pool_name = 'AVAX.USDC-0XB97EF9EF8734C71904D8002F8B6BC66DD9C48A6E'
),
rowcounting AS
(
SELECT
COUNT(*) AS rowcount,
10000 AS target_rows
FROM for_row_sampling
)
SELECT for_row_sampling.*
FROM for_row_sampling, rowcounting
QUALIFY (
(MOD((ROW_NUMBER() OVER(ORDER BY block_id ASC)), CEIL(rowcount/target_rows)) = 0)
--Row-sampling.
OR (ROW_NUMBER() OVER(ORDER BY block_id ASC) = 1)
--Include the first data point.
OR (ROW_NUMBER() OVER(ORDER BY block_id DESC) = 1)
--Include the last data point.
)
ORDER BY block_id DESC
Run a query to Download Data