diff --git a/packages/asset-swapper/CHANGELOG.json b/packages/asset-swapper/CHANGELOG.json index 87c274ba46..732350903f 100644 --- a/packages/asset-swapper/CHANGELOG.json +++ b/packages/asset-swapper/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "4.3.2", + "changes": [ + { + "note": "Fix order native pruning by fill amount", + "pr": 2500 + } + ] + }, { "timestamp": 1582677073, "version": "4.3.1", diff --git a/packages/asset-swapper/src/utils/market_operation_utils/index.ts b/packages/asset-swapper/src/utils/market_operation_utils/index.ts index 60a6f1ad72..8b4ef86f89 100644 --- a/packages/asset-swapper/src/utils/market_operation_utils/index.ts +++ b/packages/asset-swapper/src/utils/market_operation_utils/index.ts @@ -386,8 +386,8 @@ function createBuyPathFromNativeOrders( function pruneNativeFills(fills: Fill[], fillAmount: BigNumber, dustFractionThreshold: number): Fill[] { const minInput = fillAmount.times(dustFractionThreshold); - const totalInput = ZERO_AMOUNT; const pruned = []; + let totalInput = ZERO_AMOUNT; for (const fill of fills) { if (totalInput.gte(fillAmount)) { break; @@ -395,6 +395,7 @@ function pruneNativeFills(fills: Fill[], fillAmount: BigNumber, dustFractionThre if (fill.input.lt(minInput)) { continue; } + totalInput = totalInput.plus(fill.input); pruned.push(fill); } return pruned;