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[] routes: RouteInfo[]
bestRoute: RouteInfo bestRoute: RouteInfo
}[] }[]
).sort( ).sort((a, b) =>
(a, b) => Number(b.bestRoute.outAmount) - Number(a.bestRoute.outAmount) swapMode === 'ExactIn'
? Number(b.bestRoute.outAmount) - Number(a.bestRoute.outAmount)
: Number(a.bestRoute.inAmount) - Number(b.bestRoute.inAmount)
) )
return { return {
routes: sortedByBiggestOutAmount[0].routes, routes: sortedByBiggestOutAmount[0].routes,