Query editor
WITHenrich_balances as (selectrv.*,COALESCE(en.label, 'Others') as protocol,en.category,va.project,va.token_type,va.token_address as replace_address,sv.address as sym_vault_addressfromquery_3910744 rvleft joinquery_3910656 enon rv.address = en.addressleft joinquery_4917479 sv -- symbiotic vaultsON rv.address = sv.addressinner joinquery_3911332 vaon (case when sv.address is null then rv.token_address else rv.address end) = va.addressand (case when sv.address is not null then rv.token_address else 0x end) = (case when sv.address is not null then va.token_address else 0x end)),symbiotic_col_tokens as ( -- some vaults have erc20 token receipts, this excludes the token balances in the strategy itself since we already count erc20 receiptsselectdistincttoken_address as filter_strategy_addressfromenrich_balanceswhere project = 'symbiotic'and address != coalesce(sym_vault_address, 0x)),aggregate_tvl as (selectday,project,casewhen sym_vault_address is null then token_addresselse addressend as strategy_address,address,replace_address as token_address,token_symbol,token_type,protocol,casewhen project = 'eigenlayer' and category is null and token_type != 'Native Staked ETH' then CONCAT(token_type, ' ', 'Restaking')when project = 'eigenlayer' AND category is null and token_type = 'Native Staked ETH' then 'Native Restaking'when project = 'eigenlayer' AND category is null and token_type = 'Native Staked ETH' then categorywhen project = 'eigenlayer' AND category is null and token_type != 'Native Staked ETH' then CONCAT('Liquid', ' ', token_type, ' Restaking')when project in ('symbiotic', 'karak') and category is null then CONCAT('Liquid', ' ', token_type, ' Restaking')else CONCAT(token_type, ' ', 'Restaking')end as category,sum(token_balance) as token_balancefrom (selecteb.*,