messariTHORChain TVL Breakdown
    Updated 2025-01-06
    WITH total_value_pooled AS (
    SELECT
    day,
    total_value_pooled,
    total_value_pooled_usd
    FROM thorchain.defi.fact_daily_tvl
    ORDER BY day DESC
    ),
    -- Synths
    daily_synth_depth AS (
    SELECT
    to_date(block_timestamp) as day,
    pool_name AS asset,
    avg(POWER(10,-8) * synth_e8) AS cumulative_depth
    FROM thorchain.defi.fact_block_pool_depths
    WHERE pool_name LIKE '%.%' AND synth_e8 <> 0
    GROUP BY day, asset
    ),
    synth_change AS (
    SELECT *, cumulative_depth - coalesce(lag(cumulative_depth) over (order by asset, day), 0) as asset_change
    FROM daily_synth_depth
    ),
    synth_prices AS (
    SELECT
    to_date(block_timestamp) as day,
    avg(asset_usd) as asset_usd,
    pool_name as asset
    FROM thorchain.price.fact_prices
    GROUP BY day, asset
    ORDER BY day DESC
    ),
    synth_joined AS (
    SELECT
    a.day,
    a.asset,
    a.asset_change,
    QueryRunArchived: QueryRun has been archived