Ali3NTrader Joe TVL
    Updated 2024-07-17
    -- TVL Changes

    with
    top_lp as (
    select
    sum(case when amount_in_usd is null then 0 else amount_in_usd end) as total,
    sum(case when token_in='0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7' then amount_in
    when token_out='0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7' then amount_out else 0
    end
    ) as total_eth,
    contract_address as pool_address,
    pool_name
    from avalanche.defi.ez_dex_swaps
    where
    1=1--date(block_timestamp)>= current_date() - 365
    and contract_address in (
    select pool_address from avalanche.defi.dim_dex_liquidity_pools where platform like '%trader%'
    --and date(creation_time)>='2023-01-01'
    )
    and (pool_name not like ('0x%') or pool_name not like ('%-0x%'))

    group by contract_address, pool_name
    order by total desc, total_eth desc
    limit 500
    ),

    lps as (
    select
    pool_name, pool_address, tokens:token0 as token0, tokens:token1 as token1
    from
    avalanche.defi.dim_dex_liquidity_pools
    where
    1=1
    and pool_address in (select pool_address from top_lp where pool_name not like ('0x%'))
    ),

    QueryRunArchived: QueryRun has been archived