adriaparcerisasSeasonal Analysis on Sushiswap
    Updated 2022-11-28
    with
    sushiswap_volume as (
    SELECT
    trunc(block_timestamp,'month') as month,
    sum(amount_in_usd+amount_out_usd) as volume,
    count(distinct origin_from_address) as users,
    count(distinct tx_hash) as transactions
    from ethereum.core.ez_dex_swaps where platform ='sushiswap' and amount_in_usd<100000000 and amount_out_usd<100000000 --and date>=CURRENT_DATE-90
    group by 1
    ),
    table1 as (
    select
    user_address as address,
    pool_name as pool,
    avg(coalesce(amount_usd,0))*2 as tvl
    from ethereum.erc20_balances a
    join ethereum.core.dim_dex_liquidity_pools b
    on user_address = pool_address
    where b.platform = 'sushiswap'
    and a.balance_date = current_date
    group by 1,2
    order by 3 desc
    ),
    table2 as (select
    trunc(block_timestamp,'month') as month,
    address,
    pool,
    tx_hash,
    coalesce((amount_in_usd+amount_out_usd),0) as avg_per_tx
    from table1 x
    join ethereum.core.ez_dex_swaps y on x.pool = y.pool_name
    where --direction = 'OUT'
    platform = 'sushiswap'
    ),
    table3 as (
    select month,
    Run a query to Download Data