Query editor
-- tETH deposits over time, split by deposit asset-- Source: TreehouseRouter Deposited event (_asset, _amountInUnderlying, _shares)-- ETH vs WETH is resolved via a successful depositETH call in the same tx-- Amounts are in wstETH-equivalent (gross router inflow, redemptions not netted)WITH router_deposits AS (SELECTevt_block_time,evt_tx_hash,evt_index,_asset,CAST(_amountInUnderlying AS double) / 1e18 AS amount_wsteth_eq,CAST(_shares AS double) / 1e18 AS teth_mintedFROM treehouse_ethereum.treehouserouter_evt_deposited),eth_txs AS (SELECT DISTINCT call_tx_hashFROM treehouse_ethereum.treehouserouter_call_depositethWHERE call_success),labeled AS (SELECTr.evt_block_time,r.evt_tx_hash,CASEWHEN e.call_tx_hash IS NOT NULLOR r._asset IN (0x0000000000000000000000000000000000000000,0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE) THEN 'ETH'WHEN r._asset = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 THEN 'WETH'WHEN r._asset = 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0 THEN 'wstETH'WHEN r._asset = 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84 THEN 'stETH'ELSE 'other'END AS asset,r.amount_wsteth_eq,r.teth_mintedFROM router_deposits rLEFT JOIN eth_txs e ON e.call_tx_hash = r.evt_tx_hash),bucketed AS (SELECTCAST(date_trunc(CASE WHEN '{{granularity}}' IN ('day', 'week', 'month') THEN '{{granularity}}' ELSE 'week' END,evt_block_time) AS date) AS period,SUM(IF(asset = 'ETH', amount_wsteth_eq, 0)) AS eth,SUM(IF(asset = 'WETH', amount_wsteth_eq, 0)) AS weth,SUM(IF(asset = 'wstETH', amount_wsteth_eq, 0)) AS wsteth,SUM(IF(asset = 'stETH', amount_wsteth_eq, 0)) AS steth,SUM(IF(asset = 'other', amount_wsteth_eq, 0)) AS other,SUM(amount_wsteth_eq) AS total,COUNT(*) AS n_depositsFROM labeledGROUP BY 1),-- calendar spine so periods with no deposits show as 0 instead of being skippedspine AS (