MajorM111version splitted copy
Updated 2024-10-05
999
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
›
⌄
-- forked from version finale @ https://flipsidecrypto.xyz/studio/queries/b6997e02-827f-4395-9c93-329a6654bfe6
WITH Reserves AS (
SELECT
el.contract_address,
TRY_CAST(el.decoded_log:reserve0::STRING AS DECIMAL(38, 0)) / POWER(10, 18) AS reserve0,
TRY_CAST(el.decoded_log:reserve1::STRING AS DECIMAL(38, 0)) / POWER(10, 18) AS reserve1,
el.block_number,
el.event_index,
el.block_timestamp
FROM AVALANCHE.core.ez_decoded_event_logs el
WHERE
block_timestamp > '2022-12-01 00:00:00' and block_timestamp < '2024-05-03 00:00:00' and
el.contract_address IN (LOWER('0x41ab86eecbd110a82ca602d032a461f453066f1e'),
LOWER('0x0368780d62d7d6f75f943ecbccaa7bdbace57e49'),
LOWER('0xf419fd326e733b191b7f604f8126f3c67792720b'))
AND el.decoded_log:reserve0::STRING IS NOT NULL
AND el.decoded_log:reserve1::STRING IS NOT NULL
AND TRY_CAST(el.decoded_log:reserve0::STRING AS DECIMAL(38, 0)) > 0
AND TRY_CAST(el.decoded_log:reserve1::STRING AS DECIMAL(38, 0)) > 0
),
NumberedReserves AS (
SELECT
*,
ROW_NUMBER() OVER (
PARTITION BY contract_address
ORDER BY block_number, event_index
) AS RowNum
FROM
Reserves
),
Reserve2 AS (
SELECT
contract_address,
reserve0,
QueryRunArchived: QueryRun has been archived