Moejan9th13
    Updated 2023-01-17
    with base as (select
    s.*, d.LABEL as swap_from_symbol , l.LABEL as swap_to_symbol
    from
    terra.core.ez_swaps s ,
    terra.core.dim_address_labels d , terra.core.dim_address_labels l
    where
    TO_CURRENCY = l.address
    and
    From_CURRENCY = d.address
    and
    BLOCK_TIMESTAMP between '2023-01-01' and CURRENT_DATE - 5

    )

    select
    'Luna out' as type ,
    iff(BLOCK_TIMESTAMP::date = '2023-01-09', 'Jan-9th', 'Other') as types,
    sum(from_AMOUNT/pow(10,6)) AS Volume,
    avg(from_AMOUNT/pow(10,6)) AS avg_Volume,
    count(distinct TRADER) as TRADERs
    from base
    where swap_from_symbol ilike 'luna'
    group by 2

    union all

    select
    'Luna in' as type ,
    iff(BLOCK_TIMESTAMP::date = '2023-01-09', 'Jan-9th', 'Other') as types,
    sum(to_AMOUNT/pow(10,6)) AS Volume,
    avg(to_AMOUNT/pow(10,6)) AS avg_Volume,
    count(distinct TRADER) as TRADERs
    from base
    where swap_to_symbol ilike 'luna'
    Run a query to Download Data