headitmanagerPercentage of Qualified Pools of each DEX
    Updated 2022-07-03
    with tvl_in as (select sum(amount_in_usd) as amount_in,pool_name,platform from ethereum.core.ez_dex_swaps where platform in ('sushiswap','uniswap-v2')
    and amount_in_usd>0
    group by pool_name,platform)
    , tvl_out as (select sum(amount_out_usd) as amount_out,pool_name,platform from ethereum.core.ez_dex_swaps where platform in ('sushiswap','uniswap-v2')
    and amount_in_usd>0
    group by pool_name,platform)
    , tvl as (select (amount_in-amount_out) as amount,tvl_in.pool_name,tvl_in.platform from tvl_in inner join tvl_out
    on tvl_in.pool_name=tvl_out.pool_name and tvl_in.platform=tvl_out.platform
    and (amount_in-amount_out) > 100000)
    , total_pool as (select count(*) as total from tvl )
    , dex_pool as (select count(*) as dex,platform from tvl
    group by platform)
    , tvl_in_blocks as (select sum(amount_in_usd) as amount_in,pool_name,platform from ethereum.core.ez_dex_swaps where platform in ('sushiswap','uniswap-v2')
    and amount_in_usd>0 and block_number > 14968092 and pool_name in (select pool_name from tvl)
    group by pool_name,platform)
    , tvl_out_block as (select sum(amount_out_usd) as amount_out,pool_name,platform from ethereum.core.ez_dex_swaps where platform in ('sushiswap','uniswap-v2')
    and amount_in_usd>0 and block_number>14968092 and pool_name in (select pool_name from tvl)
    group by pool_name,platform)
    , tvl_block as (select (amount_in-amount_out) as amount,tvl_in_blocks.pool_name,tvl_in_blocks.platform from tvl_in_blocks inner join tvl_out_block
    on tvl_in_blocks.pool_name=tvl_out_block.pool_name and tvl_in_blocks.platform=tvl_out_block.platform)
    select dex/1243*100, platform from dex_pool
    Run a query to Download Data