{"record":{"id":"bc06f493cfb19c88","repo":"nautechsystems/nautilus_trader","slug":"failed-to-decode-collect-event-data-e","errorCode":null,"errorMessage":"Failed to decode collect event data: {e}","messagePattern":"Failed to decode collect event data: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/collect.rs","lineNumber":92,"sourceCode":"        Some(topic) => {\n            let tick_upper_bytes: [u8; 32] = topic.as_ref().try_into()?;\n            i32::from_be_bytes(tick_upper_bytes[28..32].try_into()?)\n        }\n        None => anyhow::bail!(\"Missing tickUpper in topic3 when parsing collect event\"),\n    };\n\n    if let Some(data) = &log.data {\n        let data_bytes = data.as_ref();\n\n        // Validate if data contains 3 parameters of 32 bytes each\n        if data_bytes.len() < 3 * 32 {\n            anyhow::bail!(\"Collect event data is too short\");\n        }\n\n        // Decode the data using the CollectEventData struct\n        let decoded = match <CollectEventData as SolType>::abi_decode(data_bytes) {\n            Ok(decoded) => decoded,\n            Err(e) => anyhow::bail!(\"Failed to decode collect 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        Ok(CollectEvent::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            owner,\n            decoded.recipient,","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/collect.rs#L74-L110","documentation":"Raised when ABI-decoding the 96+ byte Collect event data with CollectEventData::abi_decode fails; the underlying alloy-sol error is embedded in the message. The length pre-check passed but the byte layout does not conform to the expected (uint256, uint256, uint256) tuple.","triggerScenarios":"Data from a different event signature decoded as Collect data; stray extra/offset encoding; non-standard contracts emitting a same-named event with different parameter types.","commonSituations":"Forked or modified Uniswap V3 deployments with altered Collect events; decoding logs fetched with a stale ABI; mixing big-endian/hex formatting bugs when constructing test data.","solutions":["Compare the embedded error against the expected CollectEventData types to find the mismatch","Verify topic0 equals the canonical Collect(event signature for V3 pools","Re-fetch logs with the correct ABI/event filter from HyperSync","Print data_bytes hex and decode manually (e.g. cast abi-decode) to diagnose"],"exampleFix":"// before\nlet decoded = <CollectEventData as SolType>::abi_decode(data_bytes)?;\n// after\nlet expected_topic0 = <Collect as SolEvent>::SIGNATURE_HASH;\nanyhow::ensure!(log.topics[0].as_ref().map(|t| **t) == Some(expected_topic0), \"not a Collect event\");\nlet decoded = <CollectEventData as SolType>::abi_decode(data_bytes)?;","handlingStrategy":"try-catch","validationCode":"fn topic0_matches(log: &Log, sig: [u8; 32]) -> bool {\n    log.topics.first().and_then(|t| t.as_deref()) == Some(&sig)\n}\n// ensure topic0_matches(&log, <Collect as SolEvent>::SIGNATURE_HASH)","typeGuard":"fn is_canonical_collect(log: &Log) -> bool {\n    log.topics.first().and_then(|t| t.as_deref()) == Some(&COLLECT_TOPIC0)\n}","tryCatchPattern":"let decoded = <CollectEventData as SolType>::abi_decode(data_bytes)\n    .with_context(|| format!(\"collect decode failed, topic0={:?}, data_len={}\", log.topics.first(), data_bytes.len()))?;\n// surface topic0+hex data in logs for diagnosis","preventionTips":["Match topic0 against the canonical signature before decoding","Keep adapter ABIs in sync with deployed contract versions","Decode a known-good fixture in CI to catch ABI drift","Log failing data hex for offline decoding with cast"],"tags":["blockchain","uniswap-v3","abi","decode-failure"],"backgroundTag":"protobuf-unmarshal-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}