Query editor
-- ENS DAO — Treasury wallet outflows by recipient and controller sweeps (monthly, native units) v1-- Owner: coltron (public). Repo: ens-foundation-skill/pipeline/financials/sql/ens_dao_wallet_outflows.sql---- Independent second source for Part A's Level-1 table (built from Etherscan txlist/txlistinternal/tokentx):-- kind = 'outflow' : every successful value transfer OUT of wallet.ensdao.eth, by recipient, month and asset-- (ETH from ethereum.traces; USDC / USDCx / ENS / WETH / DAI / USDT from erc20 Transfer events)-- kind = 'sweep' : protocol cash swept from the ETHRegistrarControllers (v1–v5) into wallet.ensdao.eth, and from the-- Registrar Manager (EP 6.39) into endowment.ensdao.eth, as ETH traces-- kind = 'fee' : ETH leaving endowment.ensdao.eth to karpatkey's fee wallet treasury.kpk.eth (Safe allowance-module pulls)-- Native units only: USD is applied by the consumer at the same DeFiLlama daily price basis as the Etherscan series, so the-- comparison tests the transfer record, not the price feed. Compared in data/scripts/dune_outflows_check.py (2% per class-year).-- Parameters: {{period_start}} / {{period_end}} (text, 'YYYY-MM-DD'; end exclusive).with params as (select timestamp '{{period_start}}' as t0, timestamp '{{period_end}}' as t1),wallet as (select 0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7 as addr),endowment as (select 0x4f2083f5fBede34c2714AfFb3105539775f7FE64 as addr),controllers as (select * from (values(0xF0AD5cAd05e10572EfcEB849f6Ff0c68f9700455, 'controller-v1'),(0xB22c1C159d12461EA124b0deb4b5b93020E6Ad16, 'controller-v2'),(0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5, 'controller-v3'),(0x253553366Da8546fC250F225fe3d25d0C782303b, 'controller-v4'),(0x59E16fcCd424Cc24e280Be16E11Bcd56fb0CE547, 'controller-v5'),(0x62627681d92e36b9aee1d9a6bf181373ccd42552, 'registrar-manager')) as t(addr, label)),tokens as (select * from (values(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, 'USDC', 6),(0x1BA8603DA702602A8657980e825A6DAa03Dee93a, 'USDCx', 18),(0xC18360217D8F7Ab5e7c516566761Ea12Ce7F9D72, 'ENS', 18),(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, 'WETH', 18),(0x6B175474E89094C44Da98b954EedeAC495271d0F, 'DAI', 18),(0xdAC17F958D2ee523a2206206994597C13D831ec7, 'USDT', 6)) as t(addr, symbol, decimals)),eth_out as (select 'outflow' as kind, date_trunc('month', t.block_time) as month, date(t.block_time) as day, t."to" as counterparty, 'ETH' as asset,cast(t.value as double) / 1e18 as amount, t.tx_hashfrom ethereum.traces t, wallet w, params pwhere t."from" = w.addr and t.block_time >= p.t0 and t.block_time < p.t1and t.tx_success and t.success and t.value > uint256 '0' and t.call_type = 'call'),erc20_out as (select 'outflow' as kind, date_trunc('month', e.evt_block_time) as month, date(e.evt_block_time) as day, e."to" as counterparty, k.symbol as asset,cast(e.value as double) / power(10, k.decimals) as amount, e.evt_tx_hash as tx_hashfrom erc20_ethereum.evt_transfer ejoin tokens k on e.contract_address = k.addr, wallet w, params pwhere e."from" = w.addr and e.evt_block_time >= p.t0 and e.evt_block_time < p.t1),sweeps as (select 'sweep' as kind, date_trunc('month', t.block_time) as month, date(t.block_time) as day, t."from" as counterparty, 'ETH' as asset,cast(t.value as double) / 1e18 as amount, t.tx_hashfrom ethereum.traces tjoin controllers c on t."from" = c.addr, wallet w, endowment e, params pwhere (t."to" = w.addr or (t."to" = e.addr and c.label = 'registrar-manager'))and t.block_time >= p.t0 and t.block_time < p.t1and t.tx_success and t.success and t.value > uint256 '0' and t.call_type = 'call'