Query editor
-- Reconcile Atlas contract events with actual USDT transfers in the same transaction.-- Base event ledger: https://dune.com/queries/8105258WITHledger AS (SELECT * FROM query_8105258),event_totals AS (SELECTtx_hash,user,MIN(block_time) AS block_time,ARRAY_JOIN(ARRAY_SORT(ARRAY_DISTINCT(ARRAY_AGG(contract_name))), ', ') AS contracts,ARRAY_JOIN(ARRAY_SORT(ARRAY_DISTINCT(ARRAY_AGG(event_type))), ', ') AS event_types,SUM(incoming_usdt) AS event_incoming_usdt,SUM(cycle_claim_usdt + partner_reward_usdt) AS event_gross_payout_usdt,SUM(platform_fee_usdt) AS event_platform_fee_usdtFROM ledgerWHERE user IS NOT NULLGROUP BY 1, 2),usdt_transfers AS (SELECTtx_hash,"from","to",amountFROM tokens.transfersWHERE blockchain = 'bnb'AND contract_address = 0x55d398326f99059ff775485246999027b3197955AND block_date >= DATE '2026-06-01'AND ("from" IN (0x8f6dac6f25a5038112e1a01f1cbbd682e4d64889,0x8e61483d45a822ccb59482c47e1b6d28465605ec,0x5a71807861dbfc41ab016271c3191bf96322d42e,0xef156690b98aec4f805ec820268b9092bd83b76f)OR "to" IN (0x8f6dac6f25a5038112e1a01f1cbbd682e4d64889,0x8e61483d45a822ccb59482c47e1b6d28465605ec,0x5a71807861dbfc41ab016271c3191bf96322d42e,0xef156690b98aec4f805ec820268b9092bd83b76f,0x20cdf9839fac80ccdc38ce74d41bd55a93dd87f2))),reconciled AS (SELECTe.block_time,e.tx_hash,e.user,e.contracts,e.event_types,e.event_incoming_usdt,e.event_gross_payout_usdt,e.event_platform_fee_usdt,COALESCE(SUM(CASEWHEN t."from" = e.user