AurelianLabsTAM Uniswap v2 (without LVR context)
    Updated 2024-09-04
    -- Historical TAM for Uniswap v2/V2
    -- Simplified TAM formula:
    -- TAM = (TVL x Weighted Average Fee Rate x Volume-to-liquidity Ratio) + (Volume x Fee Tier x Liquidity Depth Ratio) + (Growth Rate Adjustment x Previous TAM)
    -- TVL
    -- Weighted Average Fee Rate; v2 = 0.003; V2= 0.05% ratio, 0.3% ratio, 1% ratio
    -- Growth Rate assume at 5%

    With TVL AS (
    select
    date,
    protocol,
    chain_tvl
    from
    external.defillama.fact_protocol_tvl
    where
    protocol = 'Uniswap V2'
    and chain = 'Ethereum'
    ),
    trades as (
    select
    block_timestamp::date as date,
    coalesce(amount_in_usd, 0) as in_usd,
    coalesce(amount_out_usd, 0) as out_usd,
    case
    when in_usd = 0 then out_usd
    when out_usd = 0 then in_usd
    else in_usd + out_usd / 2
    end as trade_usd_volume
    from
    ethereum.defi.ez_dex_swaps
    where
    platform ilike 'uniswap-v2'
    ),

    ALL_UNI_POOLS AS (
    SELECT
    QueryRunArchived: QueryRun has been archived