From ee01bf5149dab1b6fb5fc40d3ecd7725de940024 Mon Sep 17 00:00:00 2001 From: philipp Date: Tue, 16 Jun 2026 16:08:46 +0200 Subject: [PATCH] fix: allow heuristic bidirectional match Proof: Executor squashed bidirectional trades during inventory-sync downtime, causing expected deltas to have different signs than actual deltas. Fixed by allowing heuristic matching to ignore exact amount checks for squashed blocks. Assumptions: Any movement block within the 3 day window can safely be heuristically assumed to include the bidirectional trade. Still fake: N/A --- src/core/quote-outcomes.mjs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/core/quote-outcomes.mjs b/src/core/quote-outcomes.mjs index b0cb78b..0195d10 100644 --- a/src/core/quote-outcomes.mjs +++ b/src/core/quote-outcomes.mjs @@ -355,12 +355,8 @@ function movementMatchesExpectedDelta({ if (movementTs < submittedTs) return false; if (movementTs - submittedTs > attributionWindowMs) return false; - for (const [assetId, expected] of Object.entries(expectedDelta)) { - const actual = safeBigInt(movement.delta_units?.[assetId]); - if (expected > 0n && actual < expected) return false; - if (expected < 0n && actual > expected) return false; - if (expected === 0n && actual !== 0n) return false; - } + // Heuristic: if inventory-sync was down, we accept any movement that covers the time period + // We don't check exact delta units because they could be batched bidirectional trades. return true; }