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 Hypersync-decoded Swap event payload is None, so amount1, sqrt_price_x96, liquidity, and tick cannot be populated for the swap. The library requires a full decode because these fields drive price/liquidity state and cannot be defaulted. It is the standard else-branch guard of the uniswap_v3 hypersync parsers.

Source

Thrown at crates/adapters/blockchain/src/exchanges/parsing/uniswap_v3/swap.rs:100

        );
        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 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)?;

    // Validate if data contains 5 parameters of 32 bytes each
    if data_bytes.len() < 5 * 32 {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Confirm the log's data section is present and correctly sized for the canonical V3 Swap event.
  2. Verify the Hypersync Swap ABI registration so decoding returns Some(decoded).
  3. Filter empty-data logs upstream and log them rather than failing the ingestion batch.
  4. Re-align adapter/Hypersync client versions and re-fetch the affected range.
Defensive patterns

Strategy: validation

Validate before calling

fn can_parse_swap(log: &Log) -> bool {
    log.data.len() >= 128 // amount0, amount1, sqrtPriceX96, liquidity, tick words
}

Type guard

fn has_decoded_swap(decoded: &Option<SwapDecoded>) -> bool {
    decoded.is_some()
}

Try / catch

match parse_swap_event_hypersync(&log) {
    Ok(event) => handle(event),
    Err(e) if e.to_string().contains("Missing data in swap event log") => {
        tracing::warn!("skipping malformed swap log");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling parse_swap_event_hypersync with a log whose decoded field is None — topic0 matched the Swap signature but the data section (amount0/amount1, sqrtPriceX96, liquidity, tick) was missing, truncated, or failed Hypersync decoding.

Common situations: Non-standard pools emitting Swap-shaped topic0 with empty data; Hypersync ABI drift after dependency updates; partially indexed logs during reorgs; hand-crafted test logs lacking data.

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/57c0ed2e95e8fbc7. Report an issue: GitHub.