sepehrmhz8Untitled Query
    Updated 2022-10-04
    with main as (select distinct pool_address
    from ethereum.core.dim_dex_liquidity_pools
    where platform in ('sushiswap'))


    select 'swapping' as type_,
    count (case when status ilike 'success'
    then 1 end) as successed,
    count (case when status ilike 'fail'
    then 1 end) as failed,
    successed + failed as total,
    (successed/(total)) * 100 as successed_rate,
    (failed/(total)) * 100 as failed_rate
    from ethereum.core.fact_transactions
    where block_timestamp >= '2022-01-01'
    and origin_function_signature in (select origin_function_signature from (select distinct origin_function_signature from ethereum.sushi.ez_swaps))
    group by type_

    union

    select 'adding or removing liquidity' as type_,
    count (case when status ilike 'success'
    then 1 end) as successed,
    count (case when status ilike 'fail'
    then 1 end) as failed,
    successed + failed as total,
    (successed/(total)) * 100 as successed_rate,
    (failed/(total)) * 100 as failed_rate
    from ethereum.core.fact_transactions
    where block_timestamp >= '2022-01-01'
    and (to_address in (select pool_address from main)
    or from_address in (select pool_address from main))
    and tx_hash not in (select tx_hash from ethereum.sushi.ez_lending)
    and tx_hash not in (select tx_hash from ethereum.sushi.ez_swaps)
    and tx_hash not in (select tx_hash from ethereum.sushi.ez_borrowing)
    group by type_