[asset-swapper] Fix native fill prune

This commit is contained in:
Jacob Evans
2020-02-27 16:39:42 +11:00
parent 880b9413f6
commit 28573ba772
2 changed files with 11 additions and 1 deletions

View File

@@ -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",

View File

@@ -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;