Updated 2023-12-31
    with t as (
    select
    tx_hash,
    action,
    block_timestamp,
    iff(block_timestamp::date >= '2023-08-27', 'Bull Market', 'Bear Market') as timespan,
    liquidity_provider,
    amount0_usd + amount1_usd as amount_usd
    from
    ethereum.uniswapv3.ez_lp_actions
    where amount_usd < 1e7
    )

    select
    timespan,
    count(distinct tx_hash) as transactions,
    count(distinct liquidity_provider) as liquidity_providers,
    sum(
    iff(action = 'INCREASE_LIQUIDITY', amount_usd, 0)
    ) as inflow_volume,
    avg(
    iff(action = 'INCREASE_LIQUIDITY', amount_usd, 0)
    ) as avg_inflow_volume,
    sum(
    iff(action = 'DECREASE_LIQUIDITY', amount_usd, 0)
    ) as outflow_volume,
    avg(
    iff(action = 'DECREASE_LIQUIDITY', amount_usd, 0)
    ) as avg_outflow_volume,
    inflow_volume - outflow_volume as netflow_volume,
    count(
    distinct iff(
    action = 'INCREASE_LIQUIDITY',
    liquidity_provider,
    null
    )
    QueryRunArchived: QueryRun has been archived