Query editor
-- @title Coinbase tokenized-stock Morpho markets — daily market TVL (supply), Base + Ethereum, USDC/USDT-- @description Daily total supplied assets per Morpho Blue market whose collateral is a Coinbase tokenized stock-- (AAPLc, GOOGLc, NVDAc, METAc, SPCXc, MSFTc, TSLAc, AMZNc, MSTRc, SNDKc) and whose loan asset is USDC or USDT,-- on Base and Ethereum, from 5 Sep 2026. Long format: one row per (day, market) for a stacked area.-- @author Romana (Steakhouse Financial)-- @notes Markets discovered from CreateMarket events joined to tokens.erc20 symbols; as of 21 Sep 2026 all-- such markets are on Base with USDC as loan asset (none on Ethereum, none with USDT). Supply rebuilt as-- cum Supply − Withdraw + AccrueInterest.interest − Liquidate.badDebtAssets, forward-filled over a daily-- calendar. USDC/USDT = 6 decimals. Duplicate (collateral, loan, LLTV) combos with different oracles are-- disambiguated by the last 4 hex chars of the market id. Excludes markets created before 1 Aug 2026.-- @version 1.1with created as (select 'base' as chain, id, marketParams, evt_block_timefrom morpho_blue_base.morphoblue_evt_createmarketwhere evt_block_time >= timestamp '2026-08-01'union allselect 'ethereum', id, marketParams, evt_block_timefrom morpho_blue_ethereum.morphoblue_evt_createmarketwhere evt_block_time >= timestamp '2026-08-01'), markets as (select c.chain, c.id, c.evt_block_time as created_at, tc.symbol as collateral, tl.symbol as loan, cast(json_extract_scalar(c.marketParams, '$.lltv') as double) / 1e18 as lltv, concat(c.chain, ' · ', tc.symbol, '/', tl.symbol, ' ', cast(cast(round(cast(json_extract_scalar(c.marketParams, '$.lltv') as double) / 1e16, 1) as decimal(5,1)) as varchar), '%', ' (', substr(to_hex(c.id), 61, 4), ')') as marketfrom created cinner join tokens.erc20 tc on tc.blockchain = c.chain and tc.contract_address = from_hex(json_extract_scalar(c.marketParams, '$.collateralToken'))inner join tokens.erc20 tl on tl.blockchain = c.chain and tl.contract_address = from_hex(json_extract_scalar(c.marketParams, '$.loanToken'))where tc.symbol in ('AAPLc', 'GOOGLc', 'NVDAc', 'METAc', 'SPCXc', 'MSFTc', 'TSLAc', 'AMZNc', 'MSTRc', 'SNDKc')and tl.symbol in ('USDC', 'USDT')), deltas as (select 'base' as chain, id, evt_block_time, cast(assets as double) / 1e6 as dfrom morpho_blue_base.morphoblue_evt_supply where evt_block_time >= timestamp '2026-08-01'union allselect 'base', id, evt_block_time, - cast(assets as double) / 1e6from morpho_blue_base.morphoblue_evt_withdraw where evt_block_time >= timestamp '2026-08-01'union allselect 'base', id, evt_block_time, cast(interest as double) / 1e6from morpho_blue_base.morphoblue_evt_accrueinterest where evt_block_time >= timestamp '2026-08-01'union allselect 'base', id, evt_block_time, - cast(badDebtAssets as double) / 1e6from morpho_blue_base.morphoblue_evt_liquidate where evt_block_time >= timestamp '2026-08-01'union allselect 'ethereum', id, evt_block_time, cast(assets as double) / 1e6from morpho_blue_ethereum.morphoblue_evt_supply where evt_block_time >= timestamp '2026-08-01'union allselect 'ethereum', id, evt_block_time, - cast(assets as double) / 1e6from morpho_blue_ethereum.morphoblue_evt_withdraw where evt_block_time >= timestamp '2026-08-01'union allselect 'ethereum', id, evt_block_time, cast(interest as double) / 1e6from morpho_blue_ethereum.morphoblue_evt_accrueinterest where evt_block_time >= timestamp '2026-08-01'union all