nautechsystems/nautilus_trader · error

invalid Uniswap V3 fee protocol update

Error message

invalid Uniswap V3 fee protocol update

What it means

On a fee-protocol update event, `process_fee_protocol_update` accepts packed Uniswap V3 protocol-fee values via `uniswap_v3_packed()` (which unpacks protocolFee0/1 from a single u24 word). For non-PancakeSwapV3 DEXes, if the update cannot be unpacked (wrong event kind, missing/invalid packed field), the update is rejected with this error. It signals the event doesn't actually carry valid Uniswap V3 fee protocol data.

Source

Thrown at crates/model/src/defi/pool_analysis/profiler.rs:1240

    ///
    /// This function does not currently return an error; the `Result` keeps the signature uniform
    /// with the other `process_*` event handlers.
    pub fn process_fee_protocol_update(
        &mut self,
        update: &PoolFeeProtocolUpdate,
    ) -> anyhow::Result<()> {
        if self.check_if_already_processed(update.block, update.transaction_index, update.log_index)
        {
            return Ok(());
        }

        if update.dex.name == DexType::PancakeSwapV3 {
            self.state
                .set_protocol_fee_basis_points(update.fee_protocol0_new, update.fee_protocol1_new);
        } else {
            let fee_protocol = update
                .uniswap_v3_packed()
                .ok_or_else(|| anyhow::anyhow!("invalid Uniswap V3 fee protocol update"))?;
            self.state.set_uniswap_v3_fee_protocol(fee_protocol);
        }

        self.last_processed_event = Some(
            BlockPosition::new(
                update.block,
                update.transaction_hash.clone(),
                update.transaction_index,
                update.log_index,
            )
            .with_block_hash(update.block_hash.clone()),
        );
        self.last_processed_ts = Some(update.ts_event);
        self.update_reporter_if_enabled(update.block);

        Ok(())
    }

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Verify the update event's DexType is actually Uniswap V3 (not PancakeSwapV3, which takes the other branch) and matches the event actually decoded.
  2. Check that the event decoder populates `uniswap_v3_packed` (protocolFee0/1) for this event; fix the decoder if the field is empty.
  3. Update decoding for the pool's deployed contract version if fee event layout changed.
  4. Handle the error per-event in replay and skip pools with unsupported fee-update formats.

Example fix

// before
profiler.process(update)?; // aborts on non-V3 fee update
// after
if let Err(e) = profiler.process(update) {
    if e.to_string().contains("invalid Uniswap V3 fee protocol update") {
        warn!("skipping unsupported fee protocol update: {e}");
    } else { return Err(e); }
}
Defensive patterns

Strategy: validation

Validate before calling

if update.dex.name != DexType::PancakeSwapV3 && update.uniswap_v3_packed().is_none() {
    anyhow::bail!("fee update lacks valid uniswap v3 packed field; skipping");
}
profiler.process_fee_protocol_update(update)?;

Try / catch

match profiler.process_fee_protocol_update(&update) {
    Ok(_) => {}
    Err(e) if e.to_string().contains("invalid Uniswap V3 fee protocol update") => warn!("skip fee update"),
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `process_fee_protocol_update` (or `process`/`process_defi_data` dispatching a FeeProtocolUpdate event) on a non-PancakeSwapV3 pool where the update's packed Uniswap V3 field is absent or malformed.

Common situations: Mapping a different DEX's fee-change event into a UniswapV3FeeProtocolUpdate by mistake; version drift where the event signature/word layout changed; misconfigured DexType so the PancakeSwapV3 branch is skipped.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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