Query editor
-- Daily PT deposits on Aave + Morpho combined, grouped by underlying asset family-- DEFINITION: "deposits" = any PT tokens deposited into either protocol, whether posted as-- collateral or supplied to a market as the loan asset.-- - Aave: supply events on PT tokens (net of withdraw)-- - Morpho: BOTH collat_amount (PT as collateral) AND supply_amount (PT as loan asset),-- keyed on which side of each market actually holds a PT tokenWITH symbol_mapping AS (SELECT * FROM (VALUES-- Ethena family (USDe, sUSDe, eUSDe, srUSDe, tUSDe, pUSDe, jrUSDe)--('sUSDE', 'USDe family'),('USDe', 'USDe'),('eUSDE', 'USDe'),('srUSDe', 'USDe'),('tUSDe', 'USDe'),('pUSDe', 'USDe'),('jrUSDe', 'USDe'),-- sUSDe('sUSDe', 'sUSDe'),-- USDai family('USDai', 'USDai'),('sUSDai', 'USDai'),-- USR / Resolv family('USR', 'USR'),('wstUSR', 'USR'),('stUSR', 'USR'),-- USDG family('USDG', 'USDG')) AS t(underlying, family)),-- Aave: standard supply events on PT tokensaave_events AS (SELECTCAST(block_time AS DATE) AS day,regexp_extract(symbol, '^PT-([A-Za-z0-9]+)-', 1) AS underlying,amount * 0.97 AS amount_usd -- $0.97 proxy for stablecoin-backed PTsFROM lending.supplyWHERE block_month >= DATE '2024-01-01'AND project = 'aave'AND symbol LIKE 'PT-%'),-- Morpho, collateral side: PT posted as collateral (borrower side)morpho_collat_events AS (SELECTCAST(time AS DATE) AS day,regexp_extract(collateral_symbol, '^PT-([A-Za-z0-9]+)-', 1) AS underlying,collat_amount_usd AS amount_usdFROM dune.morpho.result_morpho_interactions_multichain_all_chainsWHERE collateral_symbol LIKE 'PT-%'AND collat_amount_usd IS NOT NULLAND time >= TIMESTAMP '2024-01-01'),-- Morpho, loan-supply side: PT supplied as the loan asset of a market (lender side)-- Only counted when the LOAN side is the PT tokenmorpho_supply_events AS (SELECTCAST(time AS DATE) AS day,