adriaparcerisasSushi and Uni stablecoins analysis
    Updated 2022-06-08
    with
    global_data as (
    SELECT
    case when symbol_in in ('AMUSDC','BUSD','DAI','PUSD','TUSD','USDC','USDT','UST','alUSD','cDAI','sUSD','sUSD') then symbol_in
    else symbol_out end as symbol_in,
    count(distinct tx_hash) as swaps,
    --sum(amount_in_usd) as amount_in_usd,
    --sum(amount_out_usd) as amount_out_usd,
    --amount_in_usd-amount_out_usd as netflow,
    count(distinct pool_name) as n_pools,
    datediff('months',min(block_timestamp),max(block_timestamp)) as coin_age_months,
    count(distinct sender) as n_users
    from ethereum.core.ez_dex_swaps
    where platform like '%sushiswap%' and (symbol_in in ('AMUSDC','BUSD','DAI','PUSD','TUSD','USDC','USDT','UST','alUSD','cDAI','sUSD','sUSD') or symbol_out in ('AMUSDC','BUSD','DAI','PUSD','TUSD','USDC','USDT','UST','alUSD','cDAI','sUSD','sUSD'))
    group by 1
    ),
    inflow as (
    SELECT
    symbol_in,
    count(distinct tx_hash) as swaps_in,
    sum(amount_in_usd) as volume_inflow,
    count(distinct sender) as users_inflow
    from ethereum.core.ez_dex_swaps
    where platform like '%sushiswap%' and symbol_in in ('AMUSDC','BUSD','DAI','PUSD','TUSD','USDC','USDT','UST','alUSD','cDAI','sUSD','sUSD')
    and amount_in_usd<100000000 and amount_in_usd is not null
    group by 1
    ),
    outflow as (
    SELECT
    symbol_out,
    count(distinct tx_hash) as swaps_out,
    sum(amount_out_usd) as volume_outflow,
    count(distinct sender) as users_outflow
    from ethereum.core.ez_dex_swaps
    where platform like '%sushiswap%' and symbol_out in ('AMUSDC','BUSD','DAI','PUSD','TUSD','USDC','USDT','UST','alUSD','cDAI','sUSD','sUSD')
    and amount_out_usd<100000000 and amount_out_usd is not null
    Run a query to Download Data