hmxinternRetroactive for HLP
    Updated 2024-04-24
    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