{"record":{"id":"2ff0eea08a7d1184","repo":"nautechsystems/nautilus_trader","slug":"liquidity-exceeds-i128-max","errorCode":null,"errorMessage":"Liquidity {} exceeds i128::MAX","messagePattern":"Liquidity (.+?) exceeds i128::MAX","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/model/src/defi/pool_analysis/profiler.rs","lineNumber":1058,"sourceCode":"    /// # Errors\n    ///\n    /// This function returns an error if:\n    /// - Pool is not initialized.\n    /// - Tick range is invalid.\n    /// - Position updates fail.\n    pub fn process_burn(&mut self, update: &PoolLiquidityUpdate) -> anyhow::Result<()> {\n        self.check_if_initialized(PoolEventKind::Burn)?;\n\n        if self.check_if_already_processed(update.block, update.transaction_index, update.log_index)\n        {\n            return Ok(());\n        }\n\n        self.validate_ticks(update.tick_lower, update.tick_upper)?;\n\n        // Update the position with a negative liquidity delta for the burn\n        let liquidity_delta = i128::try_from(update.position_liquidity).map_err(|_| {\n            anyhow::anyhow!(\"Liquidity {} exceeds i128::MAX\", update.position_liquidity)\n        })?;\n        let location = self.event_location(\n            PoolEventKind::Burn,\n            update.block,\n            update.transaction_index,\n            update.log_index,\n        );\n\n        self.update_position(\n            &update.owner,\n            update.tick_lower,\n            update.tick_upper,\n            -liquidity_delta,\n            update.amount0,\n            update.amount1,\n        )\n        .map_err(|e| Self::wrap_liquidity_error(e, location))?;\n","sourceCodeStart":1040,"sourceCodeEnd":1076,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/defi/pool_analysis/profiler.rs#L1040-L1076","documentation":"`PoolProfiler::process_burn` applies a burn by subtracting a signed `i128` liquidity delta from the position. The burn's `position_liquidity` (u128) must fit in `i128`; otherwise `i128::try_from` fails with this error. Like the mint counterpart, this indicates event data whose liquidity is implausibly large (corrupt decode or adversarial input).","triggerScenarios":"Calling `process_burn` (e.g. via `PoolProfiler::process` on a Burn event) where `update.position_liquidity > i128::MAX`.","commonSituations":"Malformed Burn event decoding during chain indexing; fuzzed/test data with extreme u128 values; wrong word offset when parsing burn liquidity.","solutions":["Check the ABI/log decoding path that produces `position_liquidity` for the Burn event.","Pre-validate burns and skip those with liquidity > i128::MAX (real pools never reach this).","Handle the error per-event and continue profiling instead of aborting.","If this reproduces on known-good pools, file/inspect the decoder — the data source, not the profiler, is at fault."],"exampleFix":"// before\nprofiler.process(update)?; // burns with corrupt liquidity abort the run\n// after\nif update.position_liquidity > i128::MAX as u128 {\n    warn!(\"skip burn: liquidity {} exceeds i128::MAX\", update.position_liquidity);\n} else {\n    profiler.process(update)?;\n}","handlingStrategy":"validation","validationCode":"fn burn_liquidity_representable(l: u128) -> bool { l <= i128::MAX as u128 }","typeGuard":null,"tryCatchPattern":"if let Err(e) = profiler.process(update) {\n    if e.to_string().contains(\"exceeds i128::MAX\") { warn!(\"skipping bad burn event\"); }\n    else { return Err(e); }\n}","preventionTips":["Validate event payloads against protocol-plausible ranges before state application","Use typed ABI decoding libraries rather than manual word extraction","Isolate per-event errors in replay loops so one corrupt log doesn't kill the batch"],"tags":["defi","overflow","liquidity"],"backgroundTag":"value-out-of-range","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"}