Query editor
-- =====================================================================================-- Sablier Lockup — de-batching consolidation-- Resolves `funder = SablierBatchLockup` (an intermediary) back to the TRUE treasury.---- Two trace methods, coalesced:-- A) CreateLockupBatch event (v3.0/v4.0 batchers) -> deterministic per-stream funder-- B) ERC-20 inbound transfer into the batcher in the same tx (all versions; required-- for v1.2/v2.0 batchers, which emit no batch event) -> per-tx funder---- Consolidation model (Dune "query of queries"):-- * Save your all-versions creation query (Query 2) and reference it below as query_XXXXXX.-- REQUIREMENT: that query must expose `tx_hash` and `token` in its output (add them to-- its final SELECT — both are already available in its `unified` CTE).-- * Save THIS query, then run the edge-list wrapper at the bottom as a third query.-- =====================================================================================WITHunified AS (-- your saved all-versions creation dataset (must include: sender, funder, recipient,-- token, stream_id, contract_address, tx_hash, evt_block_time, amount, ...)SELECT * FROM query_7859713),-- known Sablier batch contracts (mainnet)batchers(addr) AS (VALUES(0xb5ec9706c3be9d22326d208f491e5deef7c8d9f0), -- v1.2 SablierV2BatchLockup(0x3f6e8a8cffe377c4649aceb01e6f20c60faa356c), -- v2.0 SablierBatchLockup(0x0636d83b184d65c242c43de6aad10535bfb9d45a), -- v3.0 SablierBatchLockup(0x4f3be262d1358a82b468cf81bfc5a9cc32cf9875) -- v4.0 SablierBatchLockup),-- all Sablier lockup + batch contracts, used to drop internal transfer legssablier_contracts(addr) AS (VALUES(0x3962f6585946823440d274ad7c719b02b49de51e),(0x9deabf7815b42bf4e9a03eec35a486ff74ee7459),(0xf86b359035208e4529686a1825f2d5bee38c28a8),(0x7c01aa3783577e15fd7e272443d44b92d5b21056),(0xcf8ce57fa442ba50acbc57147a62ad03873ffa73),(0x93b37bd5b6b278373217333ac30d7e74c85fbdcb),(0xb5ec9706c3be9d22326d208f491e5deef7c8d9f0),(0x3f6e8a8cffe377c4649aceb01e6f20c60faa356c),(0x0636d83b184d65c242c43de6aad10535bfb9d45a),(0x4f3be262d1358a82b468cf81bfc5a9cc32cf9875)),-- ---------- Method A: CreateLockupBatch event (v3.0 / v4.0) ------------ CreateLockupBatch(address indexed funder, address indexed lockup, uint256[] streamIds)batch_events AS (SELECT tx_hash,bytearray_substring(topic1, 13, 20) AS true_funder, -- funder = the batch caller (treasury)bytearray_substring(topic2, 13, 20) AS lockup,dataFROM ethereum.logsWHERE block_number >= 23500619AND contract_address IN (0x0636d83b184d65c242c43de6aad10535bfb9d45a, -- v3.0 batcher0x4f3be262d1358a82b468cf81bfc5a9cc32cf9875) -- v4.0 batcherAND topic0 = 0x730ba4cef0d228f6a65abf3647fb35ee36a79b6189151a2f55696352cf060f77),batch_ids AS ( -- unnest streamIds[] (w0=offset 0x20, w1=len, w2..=elems)SELECT tx_hash, true_funder, lockup,bytearray_to_uint256(bytearray_substring(data, 32*(i+1)+1, 32)) AS stream_idFROM batch_eventsCROSS JOIN UNNEST(sequence(1, CAST(bytearray_to_uint256(bytearray_substring(data, 33, 32)) AS INTEGER))) AS u(i)),