Query editor
-- =========================================-- Daily (Perps) Fees: Aster DEX vs Hyperliquid (DefiLlama)-- Output: day, platform, fees_usd-- Window: last 90 days (discrete daily values)-- =========================================WITH-- 1) Parametersparams AS (SELECTcurrent_date - interval '90' day AS start_day,current_date AS end_day),-- 2) Fetch + parse JSONraw_aster AS (SELECT json_parse(http_get('https://api.llama.fi/summary/fees/aster-perps')) AS parsed_json),raw_hl AS (SELECT json_parse(http_get('https://api.llama.fi/summary/fees/hyperliquid')) AS parsed_json),-- 3) Extract totalDataChart arraysaster_chart AS (SELECT json_extract(parsed_json, '$.totalDataChart') AS chart_arrayFROM raw_aster),hl_chart AS (SELECT json_extract(parsed_json, '$.totalDataChart') AS chart_arrayFROM raw_hl),-- 4) Unnest into daily rowsfees_long AS (SELECTdate_trunc('day',from_unixtime(CAST(json_extract_scalar(point, '$[0]') AS bigint))) AS day,'Aster Perps' AS platform,CAST(json_extract_scalar(point, '$[1]') AS double) AS fees_usdFROM aster_chartCROSS JOIN UNNEST(CAST(chart_array AS array(json))) AS t(point)WHERE json_extract_scalar(point, '$[1]') IS NOT NULLUNION ALLSELECTdate_trunc('day',from_unixtime(CAST(json_extract_scalar(point, '$[0]') AS bigint))) AS day,'Hyperliquid' AS platform,CAST(json_extract_scalar(point, '$[1]') AS double) AS fees_usdFROM hl_chartCROSS JOIN UNNEST(CAST(chart_array AS array(json))) AS t(point)WHERE json_extract_scalar(point, '$[1]') IS NOT NULL)-- 5) Filter to last 90 days