Query editor
withraw as (select "from" as address, sum(cast(value as double)*-1) as amountfrom erc20_{{Blockchain}}.evt_Transferwhere contract_address = {{Token Contract Address}}group by 1union allselect "to" as address, sum(cast(value as double)) as amountfrom erc20_{{Blockchain}}.evt_Transferwhere contract_address = {{Token Contract Address}}group by 1),fund_address as (select distinct address, name from labels.funds),labels as (select distinct address,name from labels.allwhere blockchain = '{{Blockchain}}'and category in ('contract','social','institution','hackers','infrastructure','dao','ofac_sanction','bridge','dao','project wallet','hackers','Rollup','infrastructure')and (label_type = 'identifier' or (label_type = 'persona' and model_name = 'dao_framework'))union allselect * from fund_addressunion allselect address, exchange as namefrom query_2296923union allselect address, namespace as namefrom {{Blockchain}}.contracts)selecta.address,array_Agg(distinct name) as labels,type,amount,percent_holdings,percent_holdings*100 as percent_holdings_counterfrom (selectaddress,casewhen address in (select distinct address from labels.cex_ethereum)or address in (select distinct address from query_2296923)then 'CEX'when address in (select distinct project_contract_address from dex.trades) then 'DEX'when address in (select distinct address from {{Blockchain}}.creation_traces)and address not in (select distinct project_contract_address from dex.trades)and address not in (select distinct address from fund_address) then 'Other Smart Contracts'when address in (select distinct address from fund_address) then 'VCs/Fund'else 'Individual Address'end as type,sum(amount/power(10,18)) as amount,sum(amount)/(select sum(amount) from raw where address not in (0x0000000000000000000000000000000000000000,0x000000000000000000000000000000000000dEaD)) as percent_holdingsfrom rawwhere address not in (0x0000000000000000000000000000000000000000,0x000000000000000000000000000000000000dEaD)group by 1,2order by 4 desclimit 100)a