nautechsystems/nautilus_trader · error

Missing data in initialize event log

Error message

Missing data in initialize event log

What it means

Thrown by `parse_initialize_event_hypersync` when the log has valid indexed topics but `log.data` is `None`. A Uniswap V4 Initialize event always carries non-indexed data (sqrtPriceX96, tick, fees, hooks), so the parser cannot construct a `PoolCreatedEvent` without it and returns an error instead of a partial event.

Source

Thrown at crates/adapters/blockchain/src/exchanges/parsing/uniswap_v4/initialize.rs:152

        let decoded = <InitializeEventData as SolType>::abi_decode(data_bytes)
            .map_err(|e| anyhow::anyhow!("Failed to decode initialize event data: {e}"))?;

        let mut event = PoolCreatedEvent::new(
            block_number,
            currency0,
            currency1,
            pool_manager_address, // V4 pools are managed by PoolManager
            PoolIdentifier::PoolId(pool_identifier), // Pool ID (bytes32 as hex string)
            Some(decoded.fee.to::<u32>()),
            Some(i32::try_from(decoded.tick_spacing)? as u32),
        );

        event.set_initialize_params(decoded.sqrtPriceX96, i32::try_from(decoded.tick)?);
        event.set_hooks(decoded.hooks);

        Ok(event)
    } else {
        Err(anyhow::anyhow!("Missing data in initialize event log"))
    }
}

/// Parses a UniswapV4 Initialize event from an RPC log.
///
/// # Errors
///
/// Returns an error if the log parsing fails or if the event data is invalid.
pub fn parse_initialize_event_rpc(log: &RpcLog) -> anyhow::Result<PoolCreatedEvent> {
    rpc_log::validate_event_signature(log, INITIALIZE_EVENT_SIGNATURE_HASH, "InitializeEvent")?;

    let block_number = rpc_log::extract_block_number(log)?;

    // Pool address is the PoolManager contract (event emitter)
    let pool_manager_bytes = rpc_log::decode_hex(&log.address)?;
    let pool_manager_address = Address::from_slice(&pool_manager_bytes);

    // Extract currency0 and currency1 from topics

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Include the `data` field in the HyperSync query's log field selection (field_selection.log: [data, topics, ...]).
  2. Ensure the topic0 filter exactly matches the Uniswap V4 Initialize signature so only real Initialize logs are parsed.
  3. Return Ok(None)/skip the log instead of erroring when data is absent, if partial logs are expected.
  4. Re-fetch the specific log by block/tx if the indexer omitted data.

Example fix

// before
} else {
    Err(anyhow::anyhow!("Missing data in initialize event log"))
}
// after
} else {
    tracing::warn!(?log, "Initialize log without data; skipping");
    return Ok(None);
}
Defensive patterns

Strategy: validation

Validate before calling

// ensure the HyperSync field selection includes log data
let field_selection = FieldSelection {
    log: [LogField::BlockNumber, LogField::Topic0, LogField::Topic1, LogField::Topic2, LogField::Topic3, LogField::Data].into(),
    ..Default::default()
};

Type guard

fn log_has_data(log: &HypersyncLog) -> bool {
    log.data.as_ref().map(|d| !d.as_ref().is_empty()).unwrap_or(false)
}

Try / catch

match parse_initialize_event_hypersync(&log) {
    Ok(ev) => store(ev),
    Err(e) if e.to_string().contains("Missing data") => skip_and_count(&log),
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `parse_initialize_event_hypersync` with a HyperSync log where `data` is null. Happens when the HyperSync query field selection omits the `data` column, or the log is an unrelated event matched by an over-broad topic filter.

Common situations: Building a HyperSync query with a reduced field selection that drops `log.data`; using a topic0 filter that matches anonymous/partially-similar events; decoding archived logs where data was not requested.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/ebe97505eaf60136. Report an issue: GitHub.