Merge pull request #2500 from 0xProject/fix/asset-swapper/native-order-prune

[asset-swapper] Fix native fill prune
This commit is contained in:
Lawrence Forman 2020-02-27 13:38:49 -05:00 committed by GitHub
commit e1a061789f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;