binhachonCopy of LP Size Distribution - 10% rounded
    Updated 2022-04-29
    with stake_units as (
    select
    pool_name,
    coalesce(from_address, asset_address) as address,
    sum(case when lp_action = 'add_liquidity' then stake_units else - stake_units end) as stake_units
    from thorchain.liquidity_actions
    group by 1, 2
    ),
    pool_distribution as (
    select
    pool_name,
    address,
    stake_units,
    100 * ratio_to_report(stake_units) over (partition by pool_name) as percent
    from stake_units
    where stake_units > 0
    )
    select
    pool_name,
    floor(percent, 0) as rounded_percent,
    sum(percent) as total_percent
    from pool_distribution
    where pool_name = '{{pool_name}}'
    group by 1, 2

    Run a query to Download Data