Query editor
with price as (select symbol , decimals, avg(token_price_usd) as pricefrom dex.prices_latest,tokens.erc20where token_address = 0x4498cd8Ba045E00673402353f5a4347562707e7Dand contract_address = 0x4498cd8Ba045E00673402353f5a4347562707e7Dand blockchain = 'base'group by 1,2),raw as (select "from" as address, sum(cast(value as double)*-1) as amountfromerc20_base.evt_Transferwhere contract_address = 0x4498cd8Ba045E00673402353f5a4347562707e7Dgroup by 1union allselect "to" as address, sum(cast(value as double)) as amountfrom erc20_base.evt_Transferwhere contract_address = 0x4498cd8Ba045E00673402353f5a4347562707e7Dgroup by 1),fund_address as (select addressFROM (VALUES(0x820fb25352bb0c5e03e07afc1d86252ffd2f0a18, 'Paradigm'),(0x0716a17fbaee714f1e6ab0f9d59edbc5f09815c0, 'Jump Trading')) AS t(address,name)union allselect distinct address from labels.funds)selecttype,sum(amount) as total_holdings from (selectaddress,casewhen address in (select distinct address from cex_evms.addresses)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 safe.safes_all) then 'Multi-Sig Wallet'when address in (select distinct address from base.creation_traces)and address not in (select distinct project_contract_address from dex.trades)and address not in (select distinct address from safe.safes_all)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,decimals)) as amount,sum(amount*price/power(10,decimals)) as valuefrom price, rawwhere address <> 0x0000000000000000000000000000000000000000group by 1,2)awhere value>1group by 1