mucrypto24 hour change 2023-08-30 04:48 AM
    Updated 2023-12-28
    with resps as
    (select defillama.get('/v2/historicalChainTvl', {}) as resp),

    figure as (
    select
    value:date::timestamp as date,
    value:tvl as tvl
    from resps,
    lateral flatten (input => resp:data)),

    latest as (
    select
    date,
    tvl as latest_tvl
    from figure
    order by date desc
    limit 1),

    prior as (
    select
    tvl as prior_tvl
    from figure
    order by date desc
    offset 1
    fetch next 1)

    select
    date,
    latest_tvl,
    prior_tvl,
    (latest_tvl - prior_tvl) / prior_tvl * 100 as "24_h_change"
    from latest
    inner join prior
    QueryRunArchived: QueryRun has been archived