DigitalDanStablecoin Trends
    Updated 2022-03-25
    --Describe trends in stablecoin usage on Uniswap over a time period of your choosing.
    --What is the most popular stablecoin? Have any stablecoins seen noticeable growth or decline?
    --Be sure to define what makes a stablecoin popular (number of swaps, transaction volume in USD, or other metric of your choosing), and visualize this over the time period.
    --Include at least the top 5 stable coins (USDT, USDC, BUSD, UST, DAI) in your analysis

    select date_trunc('day', block_timestamp) as days, count(distinct(tx_id)) as num_txns, sum(amount_usd) as stablecoin_volume,
    case when token0 = lower('0xdAC17F958D2ee523a2206206994597C13D831ec7') or token1 = lower('0xdAC17F958D2ee523a2206206994597C13D831ec7') then 'USDT'
    when token0 = lower('0xa47c8bf37f92aBed4A126BDA807A7b7498661acD') or token1 = lower('0xa47c8bf37f92aBed4A126BDA807A7b7498661acD') then 'UST'
    when token0 = lower('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48') or token1 = lower('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48') then 'USDC'
    when token0 = lower('0x4Fabb145d64652a948d72533023f6E7A623C7C53') or token1 = lower('0x4Fabb145d64652a948d72533023f6E7A623C7C53') then 'BUSD'
    when token0 = lower('0x6B175474E89094C44Da98b954EedeAC495271d0F') or token1 = lower('0x6B175474E89094C44Da98b954EedeAC495271d0F') then 'DAI'
    end as stablecoin
    from ethereum.dex_swaps s
    left join ethereum.dex_liquidity_pools dlp on dlp.pool_address = s.pool_address
    where (s.platform = 'uniswap-v2' or s.platform = 'uniswap-v3')
    and (token0 = lower('0xdAC17F958D2ee523a2206206994597C13D831ec7') or token1 = lower('0xdAC17F958D2ee523a2206206994597C13D831ec7') --USDT
    or token0 = lower('0xa47c8bf37f92aBed4A126BDA807A7b7498661acD') or token1 = lower('0xa47c8bf37f92aBed4A126BDA807A7b7498661acD') -- UST
    or token0 = lower('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48') or token1 = lower('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48') --USDC
    or token0 = lower('0x4Fabb145d64652a948d72533023f6E7A623C7C53') or token1 = lower('0x4Fabb145d64652a948d72533023f6E7A623C7C53') --BUSD
    or token0 = lower('0x6B175474E89094C44Da98b954EedeAC495271d0F') or token1 = lower('0x6B175474E89094C44Da98b954EedeAC495271d0F') --DAI
    ) and direction = 'IN'
    and days > current_date - interval '6 months' and days != '2021-10-01'
    group by days, stablecoin
    order by days

    Run a query to Download Data