KaskoazulBot swappers - swap stats hour distribution
    Updated 2022-04-27
    with swaps as (
    select block_timestamp,
    tx_status,
    tx_id,
    trader,
    swap_pair,
    token_0_amount_usd,
    token_1_amount_usd,
    swap_fee_amount_usd,
    token_0_amount_usd - token_1_amount_usd as delta_amount_usd
    from terra.swaps
    where block_timestamp >= CURRENT_DATE - {{last_days}} - 1
    and block_timestamp < CURRENT_DATE - 1
    and swap_pair is not NULL
    ),
    daily_count as (
    select block_timestamp::date as fecha,
    trader,
    count (distinct tx_id) as txs
    from swaps
    group by 1,2
    order by 3 desc
    ),
    max_number as (
    select trader,
    max (txs) as max_txs
    from daily_count
    group by 1
    )
    select hour (swaps.block_timestamp) as hour_day,
    dayname (swaps.block_timestamp) as day_week,
    case
    when max_number.max_txs > {{max_txs_human}} then 'BOT'
    when max_number.max_txs <= {{max_txs_human}} then 'HUMAN'
    end as type,
    count (swaps.tx_id) as number_of_swaps
    Run a query to Download Data