Query editor
-- ============================================================-- API3 Monthly Revenue & Expenses — consolidated & optimized-- Drop-in replacement for query 6600734 ("Summary Revenue & Expenses Api3").-- Same output columns, self-contained (no query_NNN references).---- What changed vs the 7-sub-query chain:-- * ROLLING WINDOW: only the current + 2 previous months are computed;-- the tracker pipeline (04-fetch-dune.mjs) merges these rows into the-- committed full history, so older months stay frozen in the repo.-- (wstETH yield & daily prices still read from 2025-12-01 — they are-- cheap day-level series and the balance is cumulative.)-- * V2 accrual events scanned once, feeding both yield and curator fees-- * one USDC transfer scan feeding both OEV income and expenses-- * every scan keeps a single-contract-set filter so partition pruning-- stays tight (merging unrelated scans with OR raised credit cost)-- * all pricing via prices.day (daily) instead of minute-level prices.usd-- (claim-time pricing becomes claim-day pricing; negligible difference)---- WETH ADJUSTMENT (2026-07-31): the DAO now buys & holds WETH instead of-- native ETH (in preparation for WETH vaults). WETH is counted as ETH:-- * DAO's USDC->WETH purchases are asset conversions, NOT expenses/income.-- The USDC leg was already excluded (CoW settlement 0x9008D19f... is in-- the expense exclusion list); the incoming WETH leg is now explicitly-- excluded from income as well.-- * NEW single WETH transfer scan (mirrors the USDC scan) feeding:-- - WETH received by treasury wallets from external parties-- -> counted as income (oev_other_usdc) at the WETH day price-- - WETH sent from treasury wallets to external parties-- -> counted as expenses (expenses_usdc) at the WETH day price-- - WETH paid by the Uniswap V4 Pool Manager -> univ4_lp_usd-- (native-ETH fee claims keep coming from ethereum.traces)-- * FUTURE WETH VAULTS: v2_vaults carries (vault_address, asset). To-- onboard a WETH vault, add one row with asset='WETH' and its accrual-- yield & fees are scaled by 1e18 and priced via the WETH day price-- automatically (instead of the USDC 1e6 / $1 path). Vault addresses-- listed there are auto-excluded from WETH income/expenses, so deposits-- into / withdrawals from own vaults never count as flows.-- * DERIVED SHARE PRICES (2026-08-12): V2/Base curator-fee share prices-- are no longer hardcoded constants; each accrual's feeShares are valued-- at totalAssets/totalSupply at that event (supply reconstructed from-- the vault token's mint/burn history). v1.1 fees keep their constant.-- BASE ADJUSTMENT (2026-08-06): the DAO now operates two wallets on Base-- (Agent 0x26d9...B068, MERKL 0x7D02...84C9). Bridging WETH mainnet->Base-- (canonical bridge / LiFi / Relay) is an asset move: the outgoing WETH leg-- on Ethereum and the incoming leg on Base are both excluded from expenses-- and income. A new Base scan (USDC + WETH) feeds income/expenses for those-- wallets, WETH valued at the ETH day price.---- BASE VAULT ADJUSTMENT (2026-08-11): the bridged WETH arrived on Base via-- Across (LiFi routed through the Across SpokePool 0x09aea4...C64 — the-- incoming fillRelay is an asset move, not income), and 450 WETH was-- deposited into the first Base Morpho V2 vault, Kabu WETH-- (VaultV2 0x4D72Fed1...4E01; deposits are pulled by Morpho's-- GeneralAdapter1 0xb98c948C...46A, so both are excluded from expenses).-- The vault's accrual events on base.logs now feed the ETH-yield column-- (steth_yield, shown as "ETH Yield") and curator_fees_usdc, at the WETH day price. Future Base vaults:-- add one row to base_v2_vaults and the base_* exclusion lists.-- ACCURACY FIXES (2026-10-06, internal-operations#2123):-- 1. Purinta USDC VaultV2 (0xc92A...7528) added to v2_vaults (curator fees + yield).-- 2. Curator fees: share supply is taken immediately before each accrual log