Query editor
with t as (select contract_address tok, "to" a, cast(value as double) v from erc20_ethereum.evt_Transferwhere contract_address in (0x7712c34205737192402172409a8f7ccef8aa2aec, 0x43415eb6ff9db7e26a15b704e7a3edce97d31c4e)union allselect contract_address, "from", -cast(value as double) from erc20_ethereum.evt_Transferwhere contract_address in (0x7712c34205737192402172409a8f7ccef8aa2aec, 0x43415eb6ff9db7e26a15b704e7a3edce97d31c4e)), b as (select tok, a, sum(v)/1e6 units from t where a <> 0x0000000000000000000000000000000000000000 group by 1, 2 having sum(v) > 0), r as (select *, row_number() over (partition by tok order by units desc) rk, 100*units/sum(units) over (partition by tok) pct from b), l as (select address, array_join(array_agg(distinct name), '; ') names from labels.addresses where blockchain = 'ethereum' and address in (select a from r where rk <= 10) group by 1)select case when tok = 0x43415eb6ff9db7e26a15b704e7a3edce97d31c4e then 'USTB' else 'BUIDL' end fund, rk, a, round(units, 0) units, round(pct, 1) pct, l.namesfrom r left join l on l.address = r.a where rk <= 10 order by 1, 2