maybeyonassushi_top_10_swap_size
    Updated 2022-02-07
    with
    pools as (
    select * from (
    select
    pool_name,
    pool_address
    from ethereum.dex_swaps
    where platform = 'sushiswap'
    and direction = 'IN'
    )
    ),
    pool_bals as (
    select
    address_name,
    user_address,
    sum(amount_usd) as tvl
    from ethereum.erc20_balances
    where user_address in (select pool_address from pools)
    and balance_date in (select balance_date from ethereum.erc20_balances where amount_usd is not null order by balance_date desc limit 1)
    and amount_usd is not null
    and address_name is not null
    group by 1,2
    ),
    top10 as (
    select * from pool_bals
    order by tvl desc
    limit 10
    )

    select
    -- date(block_timestamp) as date,
    pool_address,
    -- pool_name,
    split(pool_name,' ')[0]::string as pool_name,
    count(distinct tx_id) as swaps,
    avg(amount_usd) as swap_size,
    Run a query to Download Data