@0x/asset-swapper: Sort native path fills by ADJUSTED rate.

This commit is contained in:
Lawrence Forman
2020-03-11 01:17:23 -04:00
parent 109d466260
commit 87999f402f

View File

@@ -94,8 +94,8 @@ function nativeOrdersToPath(
fillData: { order },
});
}
// Sort by descending rate.
path = path.sort((a, b) => b.rate.comparedTo(a.rate));
// Sort by descending adjusted rate.
path = path.sort((a, b) => b.adjustedRate.comparedTo(a.adjustedRate));
// Re-index fills.
for (let i = 0; i < path.length; ++i) {
path[i].parent = i === 0 ? undefined : path[i - 1];