{"record":{"id":"d684b8e990fb74ad","repo":"nautechsystems/nautilus_trader","slug":"pool-instrument-id-tokens-share-a-token-priority","errorCode":null,"errorMessage":"Pool {instrument_id} tokens share a token priority; base and quote orientation is ambiguous","messagePattern":"Pool (.+?) tokens share a token priority; base and quote orientation is ambiguous","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/execution/client.rs","lineNumber":836,"sourceCode":"        if !pool_identifier.is_address() {\n            anyhow::bail!(\n                \"Pool identifier {pool_identifier} is a pool ID; only address identifiers are supported\"\n            );\n        }\n\n        let pool = self\n            .core\n            .cache()\n            .pool(instrument_id)\n            .cloned()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Unknown pool {instrument_id}; not found in the shared engine cache\"\n                )\n            })?;\n\n        if pool.token0.get_token_priority() == pool.token1.get_token_priority() {\n            anyhow::bail!(\n                \"Pool {instrument_id} tokens share a token priority; base and quote orientation is ambiguous\"\n            );\n        }\n\n        Ok(pool)\n    }\n\n    /// Authenticates every persisted signed transaction in this execution database.\n    ///\n    /// Run this while the execution client is disconnected. The check takes a stable table lock,\n    /// reads in bounded batches, and returns counts, deployment identity, key IDs, and database\n    /// roles with direct ownership or `SELECT` grants.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error for inconsistent storage state, missing keys, or any payload which cannot\n    /// be opened and authenticated against its durable intent.\n    pub async fn check_payload_storage(","sourceCodeStart":818,"sourceCodeEnd":854,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/execution/client.rs#L818-L854","documentation":"resolve_pool() loads a Uniswap V3 pool from the shared engine cache and validates that its two tokens can be oriented as base and quote. This error is thrown when both tokens report the same get_token_priority(), so the client cannot unambiguously decide which token is base and which is quote for order-side (buy/sell) semantics. It is a deliberate fail-fast to prevent swaps being built with inverted base/quote direction.","triggerScenarios":"Calling resolve_pool — directly via preflight, or indirectly via prepare_swap or restore_swap_plan — with an instrument_id for a pool whose token0 and token1 have identical token priority values (e.g. a same-priority token pair like two stablecoins with equal configured priority, or a pool created from a misconfigured token registry).","commonSituations":"A token priority table/registry that assigns the same priority to two tokens in a pool; a pool instrument added to the cache whose tokens were not ranked (both default priority); wrapping two identical or mirrored tokens into one pool; stale cache entries after a token registry update changed priorities to collide.","solutions":["Fix the token priority configuration so the pool's two tokens have distinct priorities (e.g. rank the intended quote token lower/higher than the base token).","Verify the pool address in the instrument_id is correct — a wrong pool may legitimately contain two equal-priority tokens.","Re-sync/rebuild the pool entry in the shared engine cache so token0/token1 metadata carries the correct priorities.","If the pair genuinely has no meaningful priority ordering (e.g. two equal stablecoins), use a different pool or explicit base/quote instrument definition that this client supports."],"exampleFix":"// before: both tokens share default priority 0\n// token_registry: { USDC: 0, DAI: 0 }\n\n// after: assign distinct priorities so orientation is unambiguous\n// token_registry: { USDC: 1, DAI: 0 }","handlingStrategy":"validation","validationCode":"// Rust: validate pool token priorities before requesting a swap\nfn pool_orientation_ok(pool: &Pool) -> bool {\n    pool.token0.get_token_priority() != pool.token1.get_token_priority()\n}\n// call before prepare_swap; skip/reject instruments where it returns false","typeGuard":"fn has_distinct_priorities(pool: &Pool) -> bool {\n    pool.token0.get_token_priority() != pool.token1.get_token_priority()\n}","tryCatchPattern":null,"preventionTips":["Assign unique, documented token priorities in your token registry and validate no two tokens in a supported pool share one.","Add a startup check over cached pools that flags equal-priority pairs before trading begins.","Prefer address-based pool identifiers from a trusted source so the correct pool is loaded."],"tags":["blockchain","uniswap-v3","token-priority","configuration"],"backgroundTag":"invalid-config-value","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"}