Ali3NDistribution of Days by Failure Rates
    Updated 2022-10-02
    with sushipools as (select distinct pool_address from ethereum.core.dim_dex_liquidity_pools where platform ilike 'sushiswap'),

    sushiswaps as (select distinct origin_function_signature from ethereum.sushi.ez_swaps),

    sushilends as (select distinct origin_function_signature from ethereum.sushi.ez_lending),

    sushiborrows as (select distinct origin_function_signature from ethereum.sushi.ez_borrowing),

    Swapt as (
    select 'Swap' as Action_Type,
    block_timestamp::date as date,
    count (case when STATUS != 'SUCCESS' then 1 end) as Failed_TX,
    count (case when STATUS = 'SUCCESS' then 1 end) as Success_TX,
    (Failed_TX / (Success_TX + Failed_TX)) * 100 as Failure_Rate
    from ethereum.core.fact_transactions
    where origin_function_signature in (select origin_function_signature from sushiswaps)
    group by 1,2),

    Lendingt as (
    select 'Lending' as Action_Type,
    block_timestamp::date as date,
    count (case when STATUS != 'SUCCESS' then 1 end) as Failed_TX,
    count (case when STATUS = 'SUCCESS' then 1 end) as Success_TX,
    (Failed_TX / (Success_TX + Failed_TX)) * 100 as Failure_Rate
    from ethereum.core.fact_transactions
    where origin_function_signature in (select origin_function_signature from sushilends)
    group by 1,2),

    Borrowt as (
    select 'Borrow' as Action_Type,
    block_timestamp::date as date,
    count (case when STATUS != 'SUCCESS' then 1 end) as Failed_TX,
    count (case when STATUS = 'SUCCESS' then 1 end) as Success_TX,
    (Failed_TX / (Success_TX + Failed_TX)) * 100 as Failure_Rate
    from ethereum.core.fact_transactions
    where origin_function_signature in (select origin_function_signature from sushiborrows)
    Run a query to Download Data