nautechsystems/nautilus_trader · error

Missing data in swap event log

Error message

Missing data in swap event log

What it means

parse_swap_event_hypersync throws this when the optional data field of the decoded swap event log is absent, so the swap's numeric parameters (amount0/amount1, sqrtPriceX96, liquidity, tick) cannot be produced. It is a guard against incomplete log records returned by the hypersync data source.

Source

Thrown at crates/adapters/blockchain/src/exchanges/parsing/pancakeswap_v3/swap.rs:101

        );
        let pool_identifier = PoolIdentifier::Address(Ustr::from(&pool_address.to_string()));
        Ok(SwapEvent::new(
            dex,
            pool_identifier,
            extract_block_number(log)?,
            extract_transaction_hash(log)?,
            extract_transaction_index(log)?,
            extract_log_index(log)?,
            sender,
            recipient,
            decoded.amount0,
            decoded.amount1,
            decoded.sqrt_price_x96,
            decoded.liquidity,
            decoded.tick.as_i32(),
        ))
    } else {
        Err(anyhow::anyhow!("Missing data in swap event log"))
    }
}

/// Parses a PancakeSwap V3 swap event from an RPC log.
///
/// # Errors
///
/// Returns an error if the log parsing fails or if the event data is invalid.
pub fn parse_swap_event_rpc(dex: SharedDex, log: &RpcLog) -> anyhow::Result<SwapEvent> {
    rpc_log::validate_event_signature(log, SWAP_EVENT_SIGNATURE_HASH, "Swap")?;

    let sender = rpc_log::extract_address_from_topic(log, 1, "sender")?;
    let recipient = rpc_log::extract_address_from_topic(log, 2, "recipient")?;

    let data_bytes = rpc_log::extract_data_bytes(log)?;

    if data_bytes.len() < 7 * 32 {
        anyhow::bail!("Swap event data is too short");

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Re-query the log without excluding the data field from the hypersync column selection
  2. Skip/requeue the incomplete record and retry later — the original log cannot be reconstructed client-side
  3. Verify the subscription/filter is set to fetch full log data, not just topics
  4. Check provider status; fetch the same block via RPC as a fallback

Example fix

// before
let parsed = parse_swap_event_hypersync(&log)?;
// after
match parse_swap_event_hypersync(&log) {
    Ok(p) => p,
    Err(e) if e.to_string().contains("Missing data") => { requeue_log(&log); continue; }
    Err(e) => return Err(e),
}
Defensive patterns

Strategy: try-catch

Validate before calling

fn hypersync_log_has_data(log: &Log) -> bool { log.data.is_some() }

Type guard

fn log_data(log: &Log) -> Option<&Bytes> { log.data.as_ref() }

Try / catch

match parse_swap_event_hypersync(&log) {
    Ok(p) => use(p),
    Err(e) if e.to_string() == "Missing data in swap event log" => { requeue(&log); Ok(()) },
    Err(e) => Err(e),
}

Prevention

When it happens

Trigger: A hypersync log for the PancakeSwap V3 Swap event arrives with data == None, e.g. the source filtered out the data field or the record is truncated/corrupt.

Common situations: Data-source misconfiguration excluding log data fields; partial ingestion during chain reorgs or outages; malformed records from an indexing provider outage.

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/464af324332698c0. Report an issue: GitHub.