Crazy_KidStablecoin Popularity for Swaps - Algorand
    Updated 2022-04-07
    WITH swap_from AS (SELECT 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 stablecoin1,
    COUNT(DISTINCT swapper) as swap_from_users, COUNT(swap_from_asset_id) as swap_from_count,
    sum(swap_from_amount) as swap_from_volume
    FROM algorand.swaps
    WHERE date(block_timestamp) BETWEEN '2022-03-01' and '2022-03-31' AND swap_from_asset_id IN ('31566704', '312769', '465865291')
    GROUP by stablecoin1),

    swap_to AS (SELECT 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 stablecoin2,
    COUNT(DISTINCT swapper) as swap_to_users, COUNT(swap_to_asset_id) as swap_to_count,
    sum(swap_to_amount) as swap_to_volume
    FROM algorand.swaps
    WHERE date(block_timestamp) BETWEEN '2022-03-01' and '2022-03-31' AND swap_to_asset_id IN ('31566704', '312769', '465865291')
    GROUP by stablecoin2)

    SELECT stablecoin1 as stablecoin, swap_from_users, swap_from_count, swap_from_volume, swap_to_users, swap_to_count, swap_to_volume
    FROM swap_from JOIN swap_to ON stablecoin1 = stablecoin2
    Run a query to Download Data