Merge pull request #2500 from 0xProject/fix/asset-swapper/native-order-prune
[asset-swapper] Fix native fill prune
This commit is contained in:
commit
e1a061789f
@ -1,4 +1,13 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
|
"version": "4.3.2",
|
||||||
|
"changes": [
|
||||||
|
{
|
||||||
|
"note": "Fix order native pruning by fill amount",
|
||||||
|
"pr": 2500
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"timestamp": 1582677073,
|
"timestamp": 1582677073,
|
||||||
"version": "4.3.1",
|
"version": "4.3.1",
|
||||||
|
@ -386,8 +386,8 @@ function createBuyPathFromNativeOrders(
|
|||||||
|
|
||||||
function pruneNativeFills(fills: Fill[], fillAmount: BigNumber, dustFractionThreshold: number): Fill[] {
|
function pruneNativeFills(fills: Fill[], fillAmount: BigNumber, dustFractionThreshold: number): Fill[] {
|
||||||
const minInput = fillAmount.times(dustFractionThreshold);
|
const minInput = fillAmount.times(dustFractionThreshold);
|
||||||
const totalInput = ZERO_AMOUNT;
|
|
||||||
const pruned = [];
|
const pruned = [];
|
||||||
|
let totalInput = ZERO_AMOUNT;
|
||||||
for (const fill of fills) {
|
for (const fill of fills) {
|
||||||
if (totalInput.gte(fillAmount)) {
|
if (totalInput.gte(fillAmount)) {
|
||||||
break;
|
break;
|
||||||
@ -395,6 +395,7 @@ function pruneNativeFills(fills: Fill[], fillAmount: BigNumber, dustFractionThre
|
|||||||
if (fill.input.lt(minInput)) {
|
if (fill.input.lt(minInput)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
totalInput = totalInput.plus(fill.input);
|
||||||
pruned.push(fill);
|
pruned.push(fill);
|
||||||
}
|
}
|
||||||
return pruned;
|
return pruned;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user