WITH
daily_tvl AS (
SELECT
date,
chain,
protocol_name,
SUM(token_value_usd) AS usd
FROM
DEFILLAMA.TVL.HISTORICAL_TOKEN_VALUES_PER_CHAIN
WHERE
1 = 1
AND protocol_name LIKE '%Uniswap%'
GROUP BY
ALL
)
SELECT
DATE_TRUNC('month', date) AS date,
chain,
protocol_name,
MEDIAN(usd) AS tvl_usd
FROM
daily_tvl
GROUP BY
ALL
ORDER BY
1 DESC
LIMIT
500000