Saleh2024-06-16 02:07 PM
    Updated 2024-06-17
    with lst_add_liquidity as (
    select
    *
    ,LP_ACTION as type
    , case when pool_name ilike '%-%' then (split(pool_name, '-')[0]) else pool_name end as Pair
    ,ZEROIFNULL(RUNE_AMOUNT_USD) as Amount_USD
    from thorchain.defi.fact_liquidity_actions
    where LP_ACTION='add_liquidity'
    )
    ,lst_remove_liquidity as (
    select
    *
    ,LP_ACTION as type
    , case when pool_name ilike '%-%' then (split(pool_name, '-')[0]) else pool_name end as Pair
    ,-1*ZEROIFNULL(RUNE_AMOUNT_USD) as Amount_USD
    from thorchain.defi.fact_liquidity_actions
    where LP_ACTION='remove_liquidity'
    )
    ,lst_all as (
    select * from lst_add_liquidity
    union all
    select * from lst_remove_liquidity
    )
    select
    Pair
    ,count(*) as "Liquidity Transactions"
    ,count(DISTINCT from_address) as Providers
    ,sum(Amount_USD ) as "Amount USD"
    from lst_all
    -- where Amount_USD>0
    group by 1

    QueryRunArchived: QueryRun has been archived