Query editor
-- Base RWA Cluster — Merkl campaigns registry-- One row per Clearstar RWA campaign. Metadata parsed live from the Merkl campaign JSON.-- tvl_metric = which column in the daily report this campaign is meant to move.-- To track a new RWA campaign, append its campaignId (+ side/metric) to the allowlist.WITH allow AS (SELECT * FROM (VALUES('0x50efd57ffb4f48c2bc3abbddfef71ae3d50304227de2e108a5282c13be922b6e', 'Supply USDC', 'supply', 'usdc_supplied_usd', 'eUSDC-86', 6, from_hex('833589fcd6edb6e08f4c7c32d4f71b54bda02913')),('0x16d8d904899e2404b7e762bcd7b6d9610ff2f098410c01dcc8f7415390d5c820', 'Borrow USDC', 'borrow', 'usdc_borrowed_usd', 'USDC', 6, from_hex('833589fcd6edb6e08f4c7c32d4f71b54bda02913'))) AS t(campaign_id, opportunity, side, tvl_metric, reward_symbol, reward_decimals, price_token)),raw AS (SELECT a.campaign_id, a.opportunity, a.side, a.tvl_metric, a.reward_symbol, a.reward_decimals, a.price_token,CAST(json_extract_scalar(n.campaign, '$.amount') AS double) AS amount_raw,CAST(json_extract_scalar(n.campaign, '$.startTimestamp') AS bigint) AS start_ts,CAST(json_extract_scalar(n.campaign, '$.duration') AS bigint) AS duration_secFROM allow aJOIN merkl_base.distributioncreator_evt_newcampaign nON lower(json_extract_scalar(n.campaign, '$.campaignId')) = a.campaign_id),priced AS (SELECT r.*,date(from_unixtime(r.start_ts)) AS start_day,date(from_unixtime(r.start_ts + r.duration_sec)) AS end_day,r.duration_sec / 86400.0 AS duration_days,r.amount_raw / power(10, r.reward_decimals) AS budget_tokensFROM raw r)SELECTp.opportunity, p.side, p.tvl_metric, p.campaign_id, p.reward_symbol,p.start_day, p.end_day, p.duration_days,p.budget_tokens,p.budget_tokens * COALESCE(px.price, 1.0) AS budget_usd,p.budget_tokens / p.duration_days AS daily_reward_tokens,CASE WHEN current_date < p.start_day THEN 'upcoming'WHEN current_date < p.end_day THEN 'live'ELSE 'ended' END AS statusFROM priced pLEFT JOIN prices.usd_daily pxON px.blockchain = 'base' AND px.contract_address = p.price_token AND px.day = p.start_dayORDER BY p.start_day