Query editor
with raw as (select evt_block_time as t, "from" as f, "to" as r, cast(value as double) / 1e18 as amtfrom erc20_ethereum.evt_Transfer where contract_address = 0x86b5780b606940eb59a062aa85a07959518c0161union allselect evt_block_time, "from", "to", cast(value as double) / 1e18from erc20_optimism.evt_Transfer where contract_address = 0x86b5780b606940eb59a062aa85a07959518c0161union allselect evt_block_time, "from", "to", cast(value as double) / 1e18from erc20_arbitrum.evt_Transfer where contract_address = 0x86b5780b606940eb59a062aa85a07959518c0161union allselect evt_block_time, "from", "to", cast(value as double) / 1e18from erc20_scroll.evt_Transfer where contract_address = 0x86b5780b606940eb59a062aa85a07959518c0161),passthrough as (select * from (values(0x66753c4e3fc84f1ed0e3c267c927284e9d90c572), -- Cash Aave V4 hub (OP)(0x01f8cdfb1694ea8fe4ed6c38a0fd78d1188e03f4) -- Cash migration contract, Aug 2026 (OP)) as t(a)),-- ignore moves in/out of these contracts so collateral stays with the depositorclean as (select * from rawwhere f not in (select a from passthrough)and r not in (select a from passthrough)),legs as (select date_trunc('day', t) as day, r as addr, amt from cleanunion allselect date_trunc('day', t), f, -amt from clean),daily as (select addr, day, sum(amt) as chgfrom legswhere addr <> 0x0000000000000000000000000000000000000000group by 1, 2),bal as (select addr, day,sum(chg) over (partition by addr order by day) as bal,lead(day) over (partition by addr order by day) as next_dayfrom daily),snaps as (select cast(d as timestamp) as snap_dayfrom unnest(sequence(date '2026-05-04', cast(date_trunc('week', current_date) as date), interval '7' day)) as u(d)),rate as (select day, token_supply_underlying / nullif(token_supply, 0) as rfrom dune.ether_fi.result_etherfi_protocol_token_tvlwhere strategy_symbol = 'sETHFI'),snap_rate as (select s.snap_day, max_by(rt.r, rt.day) as rfrom snaps s join rate rt on rt.day <= s.snap_daygroup by 1),holdings as (select s.snap_day, b.addr, b.bal * sr.r as ethfi_eqfrom snaps sjoin bal b on b.day <= s.snap_day and (b.next_day > s.snap_day or b.next_day is null)