Query editor
withmine as (select * from (values(0xab6ed2602ea1c21c59eea142141ba8221f9952dc),(0xcb22c55dc79d0e4c741a298996507b3852dc1c1d),(0xa8bc4b4f00616deae466bce70c29336e5714b97c)) t(addr)),snap as (select d from unnest(sequence(date '2026-08-17', current_date - interval '1' day, interval '1' day)) as t(d)),docks as (select strategyHash as strategy_hash, min(evt_block_time) as docked_atfrom oneinch_multichain.aquarouter_evt_docked where chain='ethereum' group by 1),flows as (select maker, strategyHash as strategy_hash, token, evt_block_time as ts, cast(amount as int256) as amtfrom oneinch_multichain.aquarouter_evt_pushed where chain='ethereum' and maker in (select addr from mine)union allselect maker, strategyHash, token, evt_block_time, -cast(amount as int256)from oneinch_multichain.aquarouter_evt_pulled where chain='ethereum' and maker in (select addr from mine)),bal as (select s.d, f.maker, f.strategy_hash, f.token, sum(f.amt) as bal_rawfrom snap s join flows f on f.ts < s.d + interval '1' dayleft join docks dk on dk.strategy_hash = f.strategy_hashwhere dk.docked_at is null or dk.docked_at >= s.d + interval '1' daygroup by 1,2,3,4 having sum(f.amt) > 0),dedup as (select d, maker, token, max(bal_raw) as dedup_raw from bal group by 1,2,3),tok as (select contract_address, max(decimals) as decimals from tokens.erc20 where blockchain='ethereum' group by 1),px as (select date(minute) as day, contract_address, avg(price) as pricefrom prices.usd where blockchain='ethereum' and minute >= date '2026-08-17' group by 1,2),leg_usd as (select dd.d, dd.maker, cast(dd.dedup_raw as double)/power(10,coalesce(t.decimals,18))*p.price as usdfrom dedup dd left join tok t on t.contract_address=dd.tokenleft join px p on p.day=dd.d and p.contract_address=dd.token),backed as (select maker, avg(backed_usd) as avg_capital_usd from (select d, maker, sum(usd) as backed_usd from leg_usd where usd is not null and usd < 10000000 group by 1,2) x group by 1),maker_yield as (select maker, count(*) as positions, sum(volume_usd) as vol, sum(spread_yield_usd) as spread,sum(est_incentive_usd) as inc, sum(total_yield_usd) as yield, min(shipped_at) as first_shipfrom query_8308889where not unbounded and capital_days > 0 and maker in (select addr from mine)group by 1),ethpx as (select date(minute) as day, avg(price) as p from prices.usdwhere blockchain='ethereum' and contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 and minute >= date '2026-08-17' group by 1),gas as (select t."from" as maker, sum(t.gas_used * t.gas_price / 1e18 * ep.p) as gas_usdfrom ethereum.transactions t join ethpx ep on ep.day = date(t.block_time)where t."from" in (select addr from mine) and t.block_time >= date '2026-08-17' group by 1)selecty.maker as provider, 'ethereum' as chain, y.positions,round(b.avg_capital_usd,0) as capital_usd,round(y.vol,0) as volume_usd,round(y.spread,0) as spread_usd,round(y.inc,0) as incentive_usd,round(coalesce(g.gas_usd,0),0) as gas_usd,round(y.yield - coalesce(g.gas_usd,0),0) as total_yield_usd,round(100.0*(y.yield - coalesce(g.gas_usd,0))/nullif(b.avg_capital_usd,0)* 365.0/nullif(date_diff('day', y.first_ship, current_date),0),0) as est_apy_pctfrom maker_yield yleft join backed b on b.maker=y.makerleft join gas g on g.maker=y.makerorder by est_apy_pct desc