order exactout swap amounts correctly

This commit is contained in:
tjs 2023-07-10 13:15:32 -04:00
parent 920a901a66
commit 94b8aec4d9
1 changed files with 4 additions and 2 deletions

View File

@ -160,8 +160,10 @@ export const handleGetRoutes = async (
routes: RouteInfo[]
bestRoute: RouteInfo
}[]
).sort(
(a, b) => Number(b.bestRoute.outAmount) - Number(a.bestRoute.outAmount)
).sort((a, b) =>
swapMode === 'ExactIn'
? Number(b.bestRoute.outAmount) - Number(a.bestRoute.outAmount)
: Number(a.bestRoute.inAmount) - Number(b.bestRoute.inAmount)
)
return {
routes: sortedByBiggestOutAmount[0].routes,