Query editor
with base as (SELECTfrom_unixtime(CAST(item['date'] AS double)) AS time,CAST(item['tvl'] AS double) AS tvlFROM UNNEST(CAST(json_parse(HTTP_GET('https://api.llama.fi/v2/historicalChainTvl/Arbitrum')) AS ARRAY(MAP(VARCHAR, JSON)))) AS t (item))selectcase when '{{Timeframe}}' = 'Daily' then date_trunc('day', time)when '{{Timeframe}}' = 'Weekly' then date_trunc('week', time)when '{{Timeframe}}' = 'Monthly' then date_trunc('week', time) end as time,sum(tvl) as tvlfrom basewhere time >= date('2022-01-01')and case when '{{Timeframe}}' = 'Daily' then time >= now() - interval '6' monthwhen '{{Timeframe}}' = 'Weekly' then time >= now() - interval '1' yearwhen '{{Timeframe}}' = 'Monthly' then 1 = 1 endgroup by 1