{"record":{"id":"f5dd7721fbfc882c","repo":"nautechsystems/nautilus_trader","slug":"failed-to-decode-flash-event-data-e","errorCode":null,"errorMessage":"Failed to decode flash event data: {e}","messagePattern":"Failed to decode flash event data: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/flash.rs","lineNumber":76,"sourceCode":"    log: &HypersyncLog,\n) -> anyhow::Result<FlashEvent> {\n    validate_event_signature_hash(\"FlashEvent\", FLASH_EVENT_SIGNATURE_HASH, log)?;\n\n    let sender = extract_address_from_topic(log, 1, \"sender\")?;\n    let recipient = extract_address_from_topic(log, 2, \"recipient\")?;\n\n    if let Some(data) = &log.data {\n        let data_bytes = data.as_ref();\n\n        // Validate if data contains 4 parameters of 32 bytes each\n        if data_bytes.len() < 4 * 32 {\n            anyhow::bail!(\"Flash event data is too short\");\n        }\n\n        // Decode the data using the FlashEventData struct\n        let decoded = match <FlashEventData as SolType>::abi_decode(data_bytes) {\n            Ok(decoded) => decoded,\n            Err(e) => anyhow::bail!(\"Failed to decode flash event data: {e}\"),\n        };\n\n        let pool_address = Address::from_slice(\n            log.address\n                .clone()\n                .expect(\"Contract address should be set in logs\")\n                .as_ref(),\n        );\n        let pool_identifier = PoolIdentifier::Address(Ustr::from(&pool_address.to_string()));\n\n        Ok(FlashEvent::new(\n            dex,\n            pool_identifier,\n            extract_block_number(log)?,\n            extract_transaction_hash(log)?,\n            extract_transaction_index(log)?,\n            extract_log_index(log)?,\n            sender,","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/flash.rs#L58-L94","documentation":"Thrown by parse_flash_event_hypersync when the data length check passed but alloy's SolType::abi_decode of FlashEventData fails. The bytes do not represent four properly encoded parameters of the Flash event.","triggerScenarios":"abi_decode returns Err on a 128+ byte payload routed to this parser — wrong event's data, non-canonical encoding, or trailing bytes beyond the four words.","commonSituations":"Topic filtering by a colliding signature; decoding logs from forked/custom pools with a different Flash signature; corrupted test log data in test_parse_flash_event_hypersync.","solutions":["Log the underlying decode error {e} plus data length to identify the mismatch.","Strip trailing bytes so data is exactly 128 bytes before decoding.","Verify the topic0 filter matches the full Flash event signature.","Regenerate FlashEventData from the canonical Uniswap V3 pool ABI.","Run the same log through parse_flash_event_rpc to isolate hypersync data issues."],"exampleFix":"// before\nErr(e) => anyhow::bail!(\"Failed to decode flash event data: {e}\"),\n// after\nErr(e) => anyhow::bail!(\n    \"Failed to decode flash event data (len={}): {e}\",\n    data_bytes.len()\n),","handlingStrategy":"try-catch","validationCode":"if let Some(d) = &log.data {\n    if d.len() == 128\n        && <FlashEventData as SolType>::abi_decode(d).is_err()\n    {\n        // pre-screened: payload will not decode\n    }\n}","typeGuard":null,"tryCatchPattern":"match parse_flash_event_hypersync(dex, &log) {\n    Ok(event) => handle(event),\n    Err(e) if e.to_string().contains(\"Failed to decode flash event data\") => {\n        tracing::debug!(raw = ?log.data, \"flash decode failure: {e}\");\n        Ok(())\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Use the complete Flash event signature in topic filters","Keep FlashEventData in sync with the canonical pool ABI","Record inner decode errors with payload length","Cross-check against parse_flash_event_rpc for the same log"],"tags":["blockchain","uniswap-v3","hypersync","abi-decode"],"backgroundTag":"schema-validation-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}