campBots and success rate
    Updated 2022-05-01
    with bots as (
    select date_trunc('minute',block_timestamp) as minute, trader, count(*) as txs
    from terra.swaps where block_timestamp::date >= current_date - 60 group by 1, 2 having txs >= 15),
    txs_bots as (
    select block_timestamp::date as date,
    count(case when tx_status = 'SUCCEEDED' then 1 else null end) as success,
    count(case when tx_status = 'FAILED' then 1 else null end) as failed,
    count(case when tx_status in ('FAILED','SUCCEEDED') then 1 else null end) as total
    from terra.msgs where block_timestamp::date > current_date - 60
    and msg_value:trader in (select distinct trader from bots) group by 1
    ),
    txs_users as (
    select block_timestamp::date as date,
    count(case when tx_status = 'SUCCEEDED' then 1 else null end) as success,
    count(case when tx_status = 'FAILED' then 1 else null end) as failed,
    count(case when tx_status in ('FAILED','SUCCEEDED') then 1 else null end) as total
    from terra.msgs where block_timestamp::date > current_date - 60
    and msg_value:trader not in (select distinct trader from bots) group by 1
    )
    select
    b.date as days,
    b.total as txs_bots_total,
    b.success as txs_bots_success,
    (txs_bots_success/txs_bots_total)*100 as success_rate_of_bot,
    u.total as txs_users_total,
    u.success as txs_users_success,
    (txs_users_success/txs_users_total)*100 as success_rate_of_users
    from txs_bots b join txs_users u on b.date = u.date
    order by 1
    Run a query to Download Data