Query editor
with raw as (SELECTfrom_unixtime(CAST(item['date'] AS double)) AS dt,CAST(item['tvl'] AS double) AS tvlFROM UNNEST(CAST(json_parse(HTTP_GET('https://api.llama.fi/v2/historicalChainTvl/Mantle'))AS ARRAY(MAP(VARCHAR, JSON)))) AS t (item)), t1 as (SELECT *, tvl / 1000000 AS tvl_m, LAG(tvl, 1) OVER (ORDER BY dt) AS tvl_1, LAG(tvl, 7) OVER (ORDER BY dt) AS tvl_7, LAG(tvl, 30) OVER (ORDER BY dt) AS tvl_30FROM raw)SELECTdt, tvl AS def_tvl, tvl_m, (tvl / tvl_1 - 1) * 100 AS change_1d, (tvl / tvl_7 - 1) * 100 AS change_7d, (tvl / tvl_30 - 1) * 100 AS change_30d, ROUND(tvl_7 / 1000000, 0) AS tvl_7d_m, ROUND(tvl_30 / 1000000, 0) AS tvl_30d_mFROM t1WHERE dt < current_dateORDER BY 1 DESC