zakkisyedSushi: Top Pools by liquidity
    Updated 2022-01-10
    with sushi_pools as ( select pool_address
    from ethereum.dex_liquidity_pools
    where platform = 'sushiswap'
    GROUP by pool_address
    ),
    pools_tx_ids as (
    select ethereum.transactions.* from ethereum.transactions INNER join sushi_pools
    on(lower(sushi_pools.pool_address) = lower(ethereum.transactions.to_address))
    where FUNCTION_NAME != 'approve' and FUNCTION_NAME != 'transfer'
    and success =true
    ),
    pools_liquidity as (
    select ethereum.udm_events.to_address as pool_address , sum(amount_usd) as liquidity
    from ethereum.udm_events INNER join pools_tx_ids
    on(ethereum.udm_events.tx_id =pools_tx_ids .tx_id and ethereum.udm_events.to_address = pools_tx_ids.to_address )
    GROUP by 1 HAVING liquidity is NOt NULL order by liquidity DESC
    )
    select pool_name , liquidity from ethereum.dex_liquidity_pools , pools_liquidity
    where (ethereum.dex_liquidity_pools.pool_address = pools_liquidity.pool_address)
    GROUP BY 1,2 ORDER by liquidity DESC limit 10
    Run a query to Download Data