hmxinternRetroactive for HLP
Updated 2024-04-24
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 RECURSIVE date_series AS (
SELECT
'2024-03-01'::date AS time
UNION ALL
SELECT
DATEADD(day, 1, time)
FROM
date_series
WHERE
time < '2024-04-23'
),
hlp_log as (
select
BLOCK_TIMESTAMP,
DECODED_LOG['account'] as account,
case
when EVENT_NAME = 'AddLiquidity' then DECODED_LOG['mintAmount']
when EVENT_NAME = 'RemoveLiquidity' then -DECODED_LOG['liquidity']
end as hlp
from blast.core.fact_decoded_event_logs
where CONTRACT_ADDRESS = lower('0xF0D92907236418Fa8Ee900E384b4c6928f7cADfc')
and BLOCK_TIMESTAMP <= timestamp '2024-04-24 00:00:01'
and EVENT_NAME in ('AddLiquidity', 'RemoveLiquidity')
),
hlp_net_flow as (
select
account,
date_trunc('day', BLOCK_TIMESTAMP) as time,
sum(hlp) as hlp_flow
from hlp_log
group by account, date_trunc('day', BLOCK_TIMESTAMP)
),
hlp_account as (
select distinct account from hlp_net_flow
),
QueryRunArchived: QueryRun has been archived