Eman-RazTop 10 Liquidity Providers Based on the Liquidity Volume
    Updated 2024-05-29
    with seri3 as (with seri1 as (with table3 as (with table1 as (select liquidity_provider_address as lp_address, sum(token1_amount)/pow(10,6) as volume
    from sei.defi.fact_lp_actions
    where tx_succeeded='true' and token1_currency='usei' and lp_action='add_liquidity'
    group by 1),

    table2 as (select liquidity_provider_address as lp_address, sum(token2_amount)/pow(10,6) as volume
    from sei.defi.fact_lp_actions
    where tx_succeeded='true' and token2_currency='usei' and lp_action='add_liquidity'
    group by 1)

    select * from table1 union all
    select * from table2)

    select lp_address as "Liquidity Provider", sum(volume) as "Total Liquidity Provided"
    from table3
    group by 1
    order by 2 desc),


    seri2 as (with table3 as (with table1 as (select liquidity_provider_address as lp_address, sum(token1_amount)/pow(10,6) as volume
    from sei.defi.fact_lp_actions
    where tx_succeeded='true' and token1_currency='usei' and lp_action='remove_liquidity'
    group by 1),

    table2 as (select liquidity_provider_address as lp_address, sum(token2_amount)/pow(10,6) as volume
    from sei.defi.fact_lp_actions
    where tx_succeeded='true' and token2_currency='usei' and lp_action='remove_liquidity'
    group by 1)

    select * from table1 union all
    select * from table2)

    select lp_address as "Liquidity Remover", -sum(volume) as "Total Liquidity Removed"
    from table3
    group by 1
    order by 2 desc)
    QueryRunArchived: QueryRun has been archived