Query editor
WITH successful_claims AS (SELECTcall_tx_hash AS tx_hash,call_tx_from AS transaction_sender,_receiver AS receiver,_tokenId AS token_id,_quantity AS quantityFROM moodymadness_abstract.moodymadnessassets_call_claimWHERE contract_address = 0x35ffe9d966e35bd1b0e79f0d91e438701ea1c644AND call_successAND call_block_date >= DATE '2025-01-01'),claim_events AS (SELECTevt_tx_hash AS tx_hash,claimer,receiver,tokenId AS token_id,quantityClaimed AS quantityFROM moodymadness_abstract.moodymadnessassets_evt_tokensclaimedWHERE contract_address = 0x35ffe9d966e35bd1b0e79f0d91e438701ea1c644AND evt_block_date >= DATE '2025-01-01'),reconciled AS (SELECTc.tx_hash AS call_tx_hash,e.tx_hash AS event_tx_hash,c.transaction_sender,e.claimer,c.quantity AS call_quantity,e.quantity AS event_quantity,CASEWHEN c.tx_hash IS NULL THEN 'ORPHAN_EVENT'WHEN e.tx_hash IS NULL THEN 'MISSING_EVENT'WHEN c.receiver <> e.receiver OR c.token_id <> e.token_id OR c.quantity <> e.quantity THEN 'FIELD_MISMATCH'ELSE 'MATCH'END AS evidence_statusFROM successful_claims cFULL OUTER JOIN claim_events e ON e.tx_hash = c.tx_hash)SELECTCOUNT_IF(call_tx_hash IS NOT NULL) AS successful_claim_calls,COUNT_IF(event_tx_hash IS NOT NULL) AS tokens_claimed_events,CAST(SUM(CASE WHEN call_tx_hash IS NOT NULL THEN call_quantity ELSE UINT256 '0' END) AS DECIMAL(38,0)) AS call_units,CAST(SUM(CASE WHEN event_tx_hash IS NOT NULL THEN event_quantity ELSE UINT256 '0' END) AS DECIMAL(38,0)) AS event_units,COUNT_IF(evidence_status = 'MISSING_EVENT') AS missing_events,COUNT_IF(evidence_status = 'ORPHAN_EVENT') AS orphan_events,COUNT_IF(evidence_status = 'FIELD_MISMATCH') AS field_mismatches,COUNT_IF(transaction_sender <> claimer) AS account_abstraction_attribution_rows,CASE WHEN COUNT_IF(evidence_status <> 'MATCH') = 0 THEN 'PASS' ELSE 'REVIEW' END AS evidence_audit_result,CURRENT_TIMESTAMP AS checked_at_utcFROM reconciled