Unit Zero LabsClaim Stats By ENA Claimed copy
    Updated 2024-04-24
    -- forked from kida / Claim Stats By ENA Claimed @ https://flipsidecrypto.xyz/kida/q/TgbCX4NLUzIq/claim-stats-by-ena-claimed

    with claims as (
    select
    decoded_log:to as claimer,
    sum(decoded_log:value) / 1e18 as claimed_amount
    from ethereum.core.ez_decoded_event_logs
    where contract_address = lower('0x57e114B691Db790C35207b2e685D4A43181e6061')
    and origin_function_signature = '0x8132b321'
    group by 1
    ),

    liquidity_actions as (
    select
    claimer,
    claimed_amount,
    sum(
    iff(
    action = 'INCREASE_LIQUIDITY',
    case when token0_address = lower('0x57e114B691Db790C35207b2e685D4A43181e6061')
    then amount0_adjusted
    else amount1_adjusted
    end,
    0
    )
    ) as ena_added,
    sum(
    iff(
    action = 'DECREASE_LIQUIDITY',
    case when token0_address = lower('0x57e114B691Db790C35207b2e685D4A43181e6061')
    then amount0_adjusted
    else amount1_adjusted
    end,
    0
    )
    ) as ena_removed,
    QueryRunArchived: QueryRun has been archived