{"record":{"id":"e38002978b7472ad","repo":"nautechsystems/nautilus_trader","slug":"replacement-venue-leg-price-does-not-match-si","errorCode":null,"errorMessage":"replacement venue-leg price {:?} does not match signed price {}","messagePattern":"replacement venue-leg price (.+?) does not match signed price (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/execution/reports.rs","lineNumber":721,"sourceCode":"            let promotion = self\n                .ws_dispatch_state\n                .lock()\n                .pending_modify_promotion(report.venue_order_id);\n            let Some(promotion) = promotion else {\n                continue;\n            };\n\n            let context = self\n                .order_contexts\n                .get(&promotion.old_venue_order_id)\n                .context(\"pending modification has no old-leg context\")?;\n            anyhow::ensure!(\n                report.quantity == promotion.leg_quantity,\n                \"replacement venue-leg quantity {} does not match signed quantity {}\",\n                report.quantity,\n                promotion.leg_quantity,\n            );\n            anyhow::ensure!(\n                report.price == Some(promotion.price),\n                \"replacement venue-leg price {:?} does not match signed price {}\",\n                report.price,\n                promotion.price,\n            );\n            anyhow::ensure!(\n                report.order_side == Some(context.identity.order_side),\n                \"replacement venue-leg side {:?} does not match logical order side {}\",\n                report.order_side,\n                context.identity.order_side,\n            );\n            let cached_order = self\n                .core\n                .cache()\n                .order_owned(&promotion.client_order_id)\n                .context(\"pending modification has no cached logical order\")?;\n\n            if report.order_status == OrderStatus::Rejected {","sourceCodeStart":703,"sourceCodeEnd":739,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/reports.rs#L703-L739","documentation":"During replacement-leg promotion, the venue report's price must equal the signed promotion price (as Some). This ensure! fires when the venue leg price differs from the price the adapter signed, indicating divergence between submitted replacement price and live venue state.","triggerScenarios":"generate_order_status_reports promotes a pending modification and the polled report.price is None or differs from promotion.price.","commonSituations":"Market order replacement (no price) being validated as a limit; venue amended the price before the status poll; price formatting/precision differences between signed payload and venue echo.","solutions":["Handle market-order replacements separately (price may legitimately be None)","Re-poll; venue state may still be settling after replace","Verify price Decimal precision when constructing the promotion payload","Check for third-party modification of the order on the venue"],"exampleFix":"// before\nanyhow::ensure!(report.price == Some(promotion.price), ...);\n// after\nmatch order.order_type() {\n    OrderType::Market => {} // no price expected\n    OrderType::Limit => anyhow::ensure!(report.price == Some(promotion.price), ...),\n    _ => {}\n}","handlingStrategy":"validation","validationCode":"if order.order_type() == OrderType::Limit {\n    anyhow::ensure!(promotion.price == order.price().context(\"limit order missing price\")?, \"promotion price mismatch\");\n}","typeGuard":"fn promotion_price_valid(promotion: &Promotion, report: &OrderStatusReport) -> bool {\n    report.price == Some(promotion.price)\n}","tryCatchPattern":"match report.price {\n    Some(p) if p != promotion.price => warn!(\"replace price diverged; re-poll before promoting\"),\n    None if order.order_type() == OrderType::Limit => warn!(\"venue returned no price for limit leg\"),\n    _ => {},\n}","preventionTips":["Use exact Decimal prices with venue-required precision when signing replacements","Skip price validation for market-type replacements","Compare freshly polled venue price before promoting a pending modification"],"tags":["rust","order-modification","price","venue-mismatch"],"backgroundTag":"internal-invariant-violation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}