0-MIDPer Swapper Average Swap From LUNA Stats
    Updated 2023-01-09
    with tab1 as (
    select TRADER
    ,case
    when BLOCK_TIMESTAMP>='2022-12-11' and BLOCK_TIMESTAMP<'2022-12-25' then 'TWO WEEKS BEFORE HOLIDAYS'
    when BLOCK_TIMESTAMP>='2022-12-25' and BLOCK_TIMESTAMP<='2023-01-07' then 'DURING THE HOLIDAYS' end as time_status
    ,count(distinct TX_ID) as "TX COUNT"
    ,sum(FROM_AMOUNT/1e6) as "SWAP VOLUME"
    from terra.core.ez_swaps
    where FROM_CURRENCY='uluna'
    and BLOCK_TIMESTAMP>='2022-12-11'
    and TX_SUCCEEDED='TRUE'
    and time_status is not null
    group by 1,2)
    select time_status
    , avg( "TX COUNT") as "SWAP FROM TX COUNT"
    ,avg("SWAP VOLUME") as "SWAP FROM VOLUME"
    from tab1
    group by 1

    Run a query to Download Data