Query editor
-- Base RWA Cluster — Merkl incentive spend (daily)-- "Our spend" = campaigns funded by the Clearstar incentive wallet (0xF6C0..1F7F) on the two RWA opportunities.-- Basis: emission schedule (on-chain campaign amount / duration), priced in USD.-- Supply USDC opportunity (past): reward = eUSDC-86 vault share (~1 USDC each)-- Borrow USDC opportunity (live): reward = USDC-- NOTE: to track a new RWA campaign, add its campaignId row to the `campaigns` allowlist below.WITH campaigns AS (SELECT * FROM (VALUES('0x50efd57ffb4f48c2bc3abbddfef71ae3d50304227de2e108a5282c13be922b6e', 'Supply USDC', 'supply', 'eUSDC-86', 6, from_hex('833589fcd6edb6e08f4c7c32d4f71b54bda02913')),('0x16d8d904899e2404b7e762bcd7b6d9610ff2f098410c01dcc8f7415390d5c820', 'Borrow USDC', 'borrow', 'USDC', 6, from_hex('833589fcd6edb6e08f4c7c32d4f71b54bda02913'))) AS t(campaign_id, opportunity, side, reward_symbol, reward_decimals, price_token)),raw AS (SELECT c.campaign_id, c.opportunity, c.side, c.reward_symbol, c.reward_decimals, c.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 campaigns cJOIN merkl_base.distributioncreator_evt_newcampaign nON lower(json_extract_scalar(n.campaign, '$.campaignId')) = c.campaign_id),spread 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.amount_raw / power(10, r.reward_decimals)) / (r.duration_sec / 86400.0) AS daily_reward_tokensFROM raw r),days AS (SELECT s.opportunity, s.side, s.reward_symbol, s.price_token, s.daily_reward_tokens, d.dayFROM spread sCROSS JOIN UNNEST(sequence(s.start_day,LEAST(s.end_day - interval '1' day, current_date),interval '1' day)) AS d(day)WHERE s.start_day <= current_date),priced AS (SELECT d.day, d.opportunity, d.side, d.reward_symbol,d.daily_reward_tokens,d.daily_reward_tokens * COALESCE(p.price, 1.0) AS daily_spend_usdFROM days dLEFT JOIN prices.usd_daily pON p.blockchain = 'base' AND p.contract_address = d.price_token AND p.day = d.day)SELECT day, opportunity, side, reward_symbol,daily_reward_tokens, daily_spend_usdFROM pricedORDER BY day DESC, opportunity