Query editor
-- Railgun USDT monitor — BACKFILL detection query.-- Same detection logic as live.sql, but parameterized by {{since}} (a date literal).---- Cost note: avoid setting {{since}} more than ~90 days back. Earlier ranges scan-- many daily partitions of tokens_ethereum.transfers and credits-per-execution-- climbs from ~0.5 (10-day window) toward several credits at multi-month windows.---- Python caller note: when invoking this query via the Dune REST API, pass the-- `since` parameter as `{"key":"since","type":"text","value":"YYYY-MM-DD"}`.-- The `date` parameter type serializes with a time component that the SQL-- DATE '...' literal rejects.WITH consts AS (SELECT0xFA7093CDD9EE6932B4eb2c9e1cde7CE00B1FA4b9 AS railgun_pool,0xAc9f360Ae85469B27aEDdEaFC579Ef2d052aD405 AS relay_adapt,0xE8A8B458BcD1Ececc6b6b58F80929b29cCecFF40 AS fee_treasury,0xdAC17F958D2ee523a2206206994597C13D831ec7 AS usdt),candidate_xfers AS (SELECTt.tx_hash,t.block_time,t.block_number,t.evt_index,t.contract_address,t.symbol,t.amount,-- USD fallback for stablecoins: tokens_ethereum.transfers.amount_usd lags-- the price feed by 30+ minutes after a block confirms, but for stables-- the amount itself equals USD value within ~0.1%. Coalesce so detection-- isn't blocked by stale pricing.CASEWHEN t.contract_address IN (0xdAC17F958D2ee523a2206206994597C13D831ec7, -- USDT0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, -- USDC0x6B175474E89094C44Da98b954EedeAC495271d0F -- DAI)THEN COALESCE(t.amount_usd, t.amount)ELSE t.amount_usdEND AS amount_usd,t."from" AS from_addr,t."to" AS to_addrFROM tokens_ethereum.transfers tWHERE t.block_date >= DATE '{{since}}'AND (t."from" IN (0xFA7093CDD9EE6932B4eb2c9e1cde7CE00B1FA4b9,0xAc9f360Ae85469B27aEDdEaFC579Ef2d052aD405)OR t."to" IN (0xFA7093CDD9EE6932B4eb2c9e1cde7CE00B1FA4b9,0xAc9f360Ae85469B27aEDdEaFC579Ef2d052aD405))),large_outflows AS (SELECT'C_large_outflow' AS category,x.tx_hash, x.block_time, x.block_number, x.evt_index,