Query editor
-- Base Curation TVL Tracker — Master (Q3)-- Daily end-of-day TVL per vault, forward-filled, in underlying units and USD.-- Euler: last VaultStatus/day -> cash + totalBorrows. Morpho V2: last AccrueInterest.newTotalAssets/day.-- Both balance and price are forward-filled across gap days (incl. today's unfinalized close).WITH entities AS (SELECT vault, label, protocol, role, underlying, decimals, underlying_addrFROM (VALUES(from_hex('91a9ed5d4368499b1fe41f721ab13e64760b3f05'), 'USDC', 'euler', 'borrowable', 'USDC', 6, from_hex('833589fcd6edb6e08f4c7c32d4f71b54bda02913')),(from_hex('dc4efb20ce286b421f6361734a2a006a1f24af8d'), 'WETH', 'euler', 'borrowable', 'WETH', 18, from_hex('4200000000000000000000000000000000000006')),(from_hex('6d6021ff46b0d4b800c210aab3ad10b9e3e53113'), 'cbBTC', 'euler', 'collateral', 'cbBTC', 8, from_hex('cbb7c0000ab88b473b1f5afd9ef808440eed33bf')),(from_hex('60c61a47804283a514bfcdf163138b7528720d0f'), 'cbETH', 'euler', 'collateral', 'cbETH', 18, from_hex('2ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22')),(from_hex('b45e4f1003d11a563bc4f7486edfafd7dfaa8b4a'), 'cbLTC', 'euler', 'collateral', 'cbLTC', 8, from_hex('cb17c9db87b595717c857a08468793f5bab6445f')),(from_hex('82d49919d3ea4323cd96f9c6e41d9386f36439b2'), 'cbXRP', 'euler', 'collateral', 'cbXRP', 6, from_hex('cb585250f852c6c6bf90434ab21a00f02833a4af')),(from_hex('779225f3d7b6fed3ae3b140815fd338ba974e2c6'), 'cbADA', 'euler', 'collateral', 'cbADA', 6, from_hex('cbada732173e39521cdbe8bf59a6dc85a9fc7b8c')),(from_hex('91c056b6d4311a743614fbc03ac32d4e6a2d3a3c'), 'Morpho V2 USDC', 'morpho_v2', 'vault', 'USDC', 6, from_hex('833589fcd6edb6e08f4c7c32d4f71b54bda02913'))) AS t(vault, label, protocol, role, underlying, decimals, underlying_addr)),-- Euler: last VaultStatus per vault per day. total = cash + totalBorrows; cash tracked-- separately for the double-count-free cluster headline (see cash_underlying/cash_usd).euler_daily AS (SELECT v.contract_address AS vault, v.evt_block_date AS day,max_by(CAST(v.cash AS double) + CAST(v.totalborrows AS double),(v.evt_block_number, v.evt_index)) AS total_raw,max_by(CAST(v.cash AS double),(v.evt_block_number, v.evt_index)) AS cash_rawFROM euler_v2_base.evault_evt_vaultstatus vWHERE v.contract_address IN (SELECT vault FROM entities WHERE protocol = 'euler')GROUP BY 1, 2),-- Morpho V2: last AccrueInterest.newTotalAssets per day (absolute total, incl. accrued yield).-- Vault V2 holds no borrows, so cash == total for cluster-sum purposes.morpho_daily AS (SELECT a.contract_address AS vault, a.evt_block_date AS day,max_by(CAST(a.newtotalassets AS double),(a.evt_block_number, a.evt_index)) AS total_raw,max_by(CAST(a.newtotalassets AS double),(a.evt_block_number, a.evt_index)) AS cash_rawFROM morpho_v2_base.vaultv2_evt_accrueinterest aWHERE a.contract_address = from_hex('91c056b6d4311a743614fbc03ac32d4e6a2d3a3c')GROUP BY 1, 2),snap AS (SELECT * FROM euler_dailyUNION ALLSELECT * FROM morpho_daily),bounds AS (SELECT vault, min(day) AS first_day FROM snap GROUP BY vault),spine AS (SELECT b.vault, d.dayFROM bounds bCROSS JOIN UNNEST(sequence(b.first_day, current_date, interval '1' day)) AS d(day)),-- daily close prices for the 8 underlyingsprice_daily AS (SELECT p.contract_address, p.day, p.priceFROM prices.usd_daily pWHERE p.blockchain = 'base'AND p.contract_address IN (SELECT underlying_addr FROM entities)