Query editor
-- @title Steakhouse Prime ETH (Vault V2) — Daily TVL-- @description Daily TVL of Steakhouse Prime ETH (Morpho Vault V2, Ethereum) taken from the last AccrueInterest.newTotalAssets of each day, forward-filled across days with no accrual, and priced in USD via WETH daily price.-- @author Steakhouse Financial-- @notes Vault: 0xbeef0046fcab1de47e41fb75bb3dc4dfc94108e3. Underlying asset assumed WETH (18 decimals).-- @version 1.0with vault as (select 0xbeef0046fcab1de47e41fb75bb3dc4dfc94108e3 as vault_address), accruals as (selectevt_block_date as day, cast(newTotalAssets as double) / 1e18 as total_assets_eth, row_number() over (partition by evt_block_date order by evt_block_number desc, evt_index desc) as rnfrom morpho_v2_ethereum.vaultv2_evt_accrueinterestwhere contract_address = (select vault_address from vault)), daily_last as (selectday, total_assets_ethfrom accrualswhere rn = 1), day_spine as (select cast(d as date) as dayfrom unnest(sequence((select min(day) from daily_last), current_date, interval '1' day)) as t(d)), filled as (selects.day, last_value(l.total_assets_eth) ignore nulls over (order by s.day rows between unbounded preceding and current row) as total_assets_ethfrom day_spine sleft join daily_last l on l.day = s.day), weth_price as (selectcast(timestamp as date) as day, pricefrom prices.daywhere blockchain = 'ethereum'and contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2and timestamp >= (select min(day) from daily_last))selectf.day, f.total_assets_eth, f.total_assets_eth * p.price as tvl_usdfrom filled fleft join weth_price p on p.day = f.day