SalehStablecoin Popularity for Swaps-Total volume
    Updated 2022-04-04
    with stablecoin_from as ( select
    block_timestamp::date as date ,
    case when swap_from_asset_id=31566704 then 'USDC'
    when swap_from_asset_id =312769 then 'USDT'
    when swap_from_asset_id = 465865291 then 'STBL'
    end as Token,
    count (DISTINCT tx_group_id) as transactions,
    sum (swap_from_amount) as volume
    from algorand.swaps
    where block_timestamp::date >= '2022-03-01'
    group by 1,2 having Token is not null
    ),
    stablecoin_to as ( select
    block_timestamp::date as date ,
    case when swap_to_asset_id=31566704 then 'USDC'
    when swap_to_asset_id =312769 then 'USDT'
    when swap_to_asset_id = 465865291 then 'STBL'
    end as Token,
    count (DISTINCT tx_group_id) as transactions,
    sum (swap_to_amount) as volume
    from algorand.swaps
    where block_timestamp::date >= '2022-03-01'
    group by 1,2 having Token is not null
    ),
    all_ as (
    select * from stablecoin_from
    UNION ALL
    select * from stablecoin_to
    )
    select date , Token , sum(Transactions) as transactions
    ,sum(volume ) as volume
    from all_
    group by 1, 2
    order by 1

    Run a query to Download Data