Query editor
with iv_addrs as (select row_number() over (order by sum(cast(mm as double)/1000/60/60/24 * cumul_amount) desc) as rk,a.address,round(sum(cast(mm as double)/1000/60/60/24 * cumul_amount * a.boost)) as points,round(sum(case when a.name = 'ctStableUSDT' then cast(mm as double)/1000/60/60/24 * cumul_amount * a.boost end)) as usdt,round(sum(case when a.name = 'ctStablefrxUSD' then cast(mm as double)/1000/60/60/24 * cumul_amount * a.boost end)) as frax,round(sum(case when a.name = 'YT-ctStableUSDT-20251120' then cast(mm as double)/1000/60/60/24 * cumul_amount * a.boost end)) as pendle_yt_usdt,round(sum(case when a.name = 'YT-ctStablefrxUSD-20251120' then cast(mm as double)/1000/60/60/24 * cumul_amount * a.boost end)) as pendle_yt_frax,round(sum(case when a.name = 'Morpho' and last_one = 'Y' then cumul_amount end)) as morpho,round(sum(case when a.name = 'ctStableUSDT' and last_one = 'Y' then cumul_amount end)) as usdt2,round(sum(case when a.name = 'ctStablefrxUSD' and last_one = 'Y' then cumul_amount end)) as frax2,round(sum(case when a.name = 'YT-ctStableUSDT-20251120' and last_one = 'Y' then cumul_amount end)) as pendle_yt_usdt2,round(sum(case when a.name = 'YT-ctStablefrxUSD-20251120' and last_one = 'Y' then cumul_amount end)) as pendle_yt_frax2,round(sum(case when a.name = 'Morpho' and last_one = 'Y' then cumul_amount end)) as morpho2from query_6190101 aleft join query_6189532 b on b.address = a.addressand b.tp = 'EXCEPT'where b.address is nullgroup by 2having sum(cast(mm as double)/1000/60/60/24 * cumul_amount) > 0)select a.rk,a.address,get_href(concat('https://dune.com/sohwak_archive/stable-portfolio-by-address?address_t5cf90=',cast(a.address as varchar)), '[Portfolio]') as port_link,e.name as ens_name,a.points,points / sum(points) over () as point_shares,a.usdt,a.frax,a.pendle_yt_usdt,a.pendle_yt_frax,a.morpho,a.usdt2,a.frax2,a.pendle_yt_usdt2,a.pendle_yt_frax2,a.morpho2,sum(points) over () as tot_points,count(1) over () as user_cntfrom iv_addrs aleft join labels.ens e on e.blockchain = 'ethereum'and e.address = a.addresswhere a.points > 0order by 1