maybeyonasthor_multipool
    Updated 2022-01-11
    with current_providers as (
    select * from (
    select
    from_address as user,
    pool_name,
    -- lp_action,
    sum(
    case
    when lp_action = 'add_liquidity'
    then stake_units
    when lp_action = 'remove_liquidity'
    then -stake_units
    end
    ) as net_stake_units
    from thorchain.liquidity_actions
    -- where lp_action = 'add_liquidity'
    group by 1,2
    )
    where
    net_stake_units > 0
    and user is not null
    ),
    user_pools as (
    select
    user,
    count(distinct pool_name) as pools
    from current_providers
    group by 1
    )

    select
    pools,
    count(distinct user) as no_of_users
    from user_pools
    group by 1
    limit 100
    Run a query to Download Data