Query editor
with-- 1) ETHFI bought by the buyback wallets on CoW Protocol (Ethereum)bought as (selectdate_trunc('week', block_date) as week,sum(units_bought) as ethfi_bought,sum(usd_value) as usd_spentfrom cow_protocol_ethereum.tradeswhere block_date >= date '2026-09-06'and trader in (0x43F4cA92F7F378bCdcF1508b866b5B6c47D6408C,0xa7b1d3a045fE9566513f3ECc858469640C88BE29)and upper(buy_token) = 'ETHFI'group by 1),-- 2) ETHFI paid out by the Cash cashback distributor (Optimism) to Cash accountsdist_raw as (selectevt_block_date as block_date,value / 1e18 as ethfi_amountfrom erc20_optimism.evt_transferwhere evt_block_date >= date '2026-09-08'and "from" = 0x38F2fBb259F042DE3A601E0f7135f768DE08F5A2 -- cashback distributorand contract_address = 0xe0080d2F853ecDdbd81A643dC10DA075Df26fD3f -- ETHFI (Optimism)and to not in (0x43F4cA92F7F378bCdcF1508b866b5B6c47D6408C,0x3FB6784E263643656f386A0371644931133D7b78)and to in (select address from dune.ether_fi.result_etherfi_cash_addresses)),dist as (selectdate_trunc('week', d.block_date) as week,sum(d.ethfi_amount) as ethfi_distributed,sum(d.ethfi_amount * p.price) as usd_distributedfrom dist_raw dleft join dune.ether_fi.result_tokens_prices_usd_daily pon p.contract_address = 0xFe0c30065B384F05761f15d0CC899D4F9F9Cc0eBand p.blockchain = 'ethereum'and p.day = d.block_dategroup by 1),weeks as (select week from boughtunionselect week from dist),weekly as (selectw.week,coalesce(b.ethfi_bought, 0) as ethfi_bought,coalesce(d.ethfi_distributed, 0) as ethfi_distributed,coalesce(b.usd_spent, 0) as usd_spent,coalesce(d.usd_distributed, 0) as usd_distributed