Query editor
with tmp as (select"from" as addr,token_symbol,cast(value as double) / POW(10, decimals) as amountfrom erc20_ethereum.evt_Transfer etinner join dune.hashed_official.result_lst_tokens lst on et.to = lst.restaking_contract and et.contract_address = lst.token_contractUNION ALLselectto as addr,token_symbol,-cast(value as double) / POW(10, decimals) as amountfrom erc20_ethereum.evt_Transfer etinner join dune.hashed_official.result_lst_tokens lst on et."from" = lst.restaking_contract and et.contract_address = lst.token_contract),users as (selectaddr,token_symbol,sum(amount) as amountfrom tmpgroup by 1, 2having sum(amount) > 0),eth_price as (select pricefrom(selectprice,ROW_NUMBER() OVER (PARTITION BY contract_address ORDER BY minute DESC) AS indexfrom prices.usdwhere symbol = 'ETH') tmpwhere index = 1)selecttoken_symbol,sum(amount) as total_restaked_amount,sum(amount) * (select avg(price) from eth_price) as total_restaked_usd,count(distinct addr) as total_depositor,sum(amount/total_amount) as percentage,avg(total_amount) as total_amountfrom query_3298168left join users using(token_symbol)group by 1order by 2 desc