Query editor
WITH-- Define parametersparams AS (SELECTcast('{{from}}' as timestamp) as from_timetsamp,to_unixtime(cast('{{from}}' as timestamp)) as period_start,cast('{{to}}' as timestamp) as to_timetsamp,to_unixtime(cast('{{to}}' as timestamp)) as period_end,-- 1742169600 AS period_start, -- Mon Mar 17 2025 00:00:00-- 1742774400 AS period_end, -- Mon Mar 24 2025 00:00:00'superstate,solera,nest-staking,rooster-protocol,mystic-finance,satori-finance,morpho,canary-protocol,multichainz,dinari,credbull,orderly' AS ton_projects),-- Split projects into rowsprojects AS (SELECT TRIM(value) AS projectFROM params,UNNEST(SPLIT(ton_projects, ',')) AS t(value)),-- Get TVL data for each projectproject_data_nested AS (SELECTproject,-- HTTP_GET(CONCAT('https://api.llama.fi/protocol/', project)) AS response_dataTRY_CAST(JSON_EXTRACT(HTTP_GET(CONCAT('https://api.llama.fi/protocol/', project)), '$.chainTvls["plume-mainnet"].tvl') AS ARRAY(JSON)) as response_dataFROMprojects),project_data as (SELECTproject,unnnested_itemFROMproject_data_nestedCROSS JOINUNNEST(cast(response_data as array(json))) AS t(unnnested_item)),-- all_data_json as (-- select-- id,-- name,-- TRY_CAST(JSON_EXTRACT(response_data, '$.data.quotes') AS ARRAY(JSON)) as quotes_data-- FROM-- all_data-- ),-- Extract and parse TVL informationparsed_tvl AS (SELECT