Query editor
-- ======== PARAMETERS ========-- Output: daily TVL in USD (Eastern Time days) for selected protocols on Hyperliquid + HyperEVM (Chain).-- Time zone: America/New_York (DST-aware).-- Cutoff (exclusive): after 2024-11-30 → include 2024-12-01 and later (Eastern).-- Exclude the *current* Eastern day to avoid partial data artifacts.WITH endpoints AS (SELECT * FROM (VALUES-- Protocols('hypurrfi', 'https://api.llama.fi/updatedProtocol/hypurrfi'),('hyperdrive_hl', 'https://api.llama.fi/updatedProtocol/hyperdrive-hl'),('project_x', 'https://api.llama.fi/updatedProtocol/project-x'),('sentiment', 'https://api.llama.fi/updatedProtocol/sentiment'),('hyperlend', 'https://api.llama.fi/updatedProtocol/hyperlend'),('felix', 'https://api.llama.fi/updatedProtocol/felix'),('valantis', 'https://api.llama.fi/updatedProtocol/valantis'),('morpho', 'https://api.llama.fi/updatedProtocol/morpho'),('hyperswap', 'https://api.llama.fi/updatedProtocol/hyperswap'),('upheaval_finance', 'https://api.llama.fi/updatedProtocol/upheaval-finance'),-- Chain TVL (HyperEVM / Hyperliquid L1)('chain_tvl', 'https://api.llama.fi/v2/historicalChainTvl/Hyperliquid%20L1')) AS t(name, url)),raw AS (SELECT name, url, JSON_PARSE(HTTP_GET(url)) AS jFROM endpoints),-- Eastern "today" to exclude partial daytoday_est AS (SELECT CAST( (current_timestamp AT TIME ZONE 'America/New_York') AS DATE ) AS today_est),-- Chain TVL (HyperEVM total), bucketed by US/Eastern daychain_tvl_raw AS (SELECT j FROM raw WHERE name = 'chain_tvl'),chain_tvl_points AS (SELECTCAST( ((from_unixtime(CAST(JSON_EXTRACT_SCALAR(pt,'$.date') AS BIGINT)) AT TIME ZONE 'UTC')AT TIME ZONE 'America/New_York') AS DATE) AS day_est,CAST(JSON_EXTRACT_SCALAR(pt,'$.tvl') AS DOUBLE) AS tvl_usdFROM chain_tvl_rawCROSS JOIN UNNEST(CAST(j AS ARRAY(JSON))) AS u(pt)),chain_tvl_daily AS (SELECT 'HyperEVM (Chain)' AS entity, p.day_est, SUM(p.tvl_usd) AS tvl_usdFROM chain_tvl_points pCROSS JOIN today_est tWHERE p.day_est > DATE '2024-11-30'AND p.day_est < t.today_estGROUP BY 1,2),-- ======== PROTOCOL TVLs (Hyperliquid-only, non-borrowed, de-duped across aliases) ========protocol_chain_rows AS (SELECTr.name,CASE WHEN chain_key IN ('Hyperliquid L1','Hyperliquid') THEN 'Hyperliquid' END AS chain_alias,JSON_EXTRACT(chain_value, '$.tvl') AS tvl_array