{"record":{"id":"0819d1a7f80fbc58","repo":"nautechsystems/nautilus_trader","slug":"quote-spend-limit-max-amount-exceeds-the-u2","errorCode":null,"errorMessage":"Quote spend limit `max_amount` '{}' exceeds the U256 range","messagePattern":"Quote spend limit `max_amount` '(.+?)' exceeds the U256 range","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":317,"sourceCode":"                );\n            }\n\n            if spend_token != token_in {\n                anyhow::bail!(\n                    \"Quote spend limit for {token_in} -> {token_out} is denominated in {spend_token}; `spend_token` must match `token_in`\"\n                );\n            }\n\n            if limit.max_amount.is_empty()\n                || !limit.max_amount.bytes().all(|byte| byte.is_ascii_digit())\n            {\n                anyhow::bail!(\n                    \"Quote spend limit `max_amount` '{}' must be a base-10 unsigned integer string\",\n                    limit.max_amount\n                );\n            }\n            let max_amount = U256::from_str(&limit.max_amount).map_err(|_| {\n                anyhow::anyhow!(\n                    \"Quote spend limit `max_amount` '{}' exceeds the U256 range\",\n                    limit.max_amount\n                )\n            })?;\n            let ceiling = QuoteSpendCeiling {\n                spend_token,\n                spend_token_decimals: limit.spend_token_decimals,\n                max_amount,\n            };\n\n            if parsed_quote_spend_limits\n                .insert((token_in, token_out), ceiling)\n                .is_some()\n            {\n                anyhow::bail!(\n                    \"Duplicate quote spend limit for token pair {token_in} -> {token_out}\"\n                );\n            }","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L299-L335","documentation":"Thrown in the `transaction_limits` processing of `BlockchainExecutionClient` when a quote spend limit's `max_amount` string parses as base-10 but represents a number larger than U256::MAX. Spend ceilings are parsed into `U256`; values beyond that cannot represent a valid token amount and are rejected.","triggerScenarios":"Providing a quote spend limit config entry whose `max_amount` exceeds 2^256 - 1, e.g. an absurd value like 10^80, a placeholder string of many digits, or a misconfigured sentinel like \"unlimited\" spelled as a giant number.","commonSituations":"Hand-editing limits with a huge sentinel value; copy-pasting scientific notation expanded; generated config with an overflow default; mistyping decimals when converting from human-readable amounts.","solutions":["Lower `max_amount` to a value within the U256 range (<= 2^256 - 1, and realistically <= total token supply).","Compute the base-10 value from a Decimal/human amount using the token's decimals instead of typing a raw integer.","If the intent was 'no limit', omit the limit entry rather than using a giant sentinel."],"exampleFix":"// before (config)\n[[limits]]\nspend_token = \"0x4200000000000000000000000000000000000006\"\nmax_amount = \"115792089237316195423570985008687907853269984665640564039457584007913129639936\" # > U256::MAX\n// after\nmax_amount = \"115792089237316195423570985008687907853269984665640564039457584007913129639935\" # <= U256::MAX (or an actual sane ceiling)","handlingStrategy":"validation","validationCode":"fn is_valid_u256_amount(s: &str) -> bool {\n    s.chars().all(|c| c.is_ascii_digit())\n        && !s.is_empty()\n        && U256::from_str_radix(s, 10).is_ok()\n}","typeGuard":null,"tryCatchPattern":"match U256::from_str(&limit.max_amount) {\n    Ok(v) => apply_ceiling(v),\n    Err(_) if limit.max_amount.chars().all(|c| c.is_ascii_digit()) => {\n        anyhow::bail!(\"max_amount {} exceeds U256 range; use a realistic spend ceiling\", limit.max_amount);\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Compute max_amount from human-readable amounts using the token's decimals","Never use giant sentinel numbers for 'unlimited'; omit the limit instead","Validate all limit strings fit U256 at config load time"],"tags":["config","u256","overflow","validation"],"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"}