Skip to content

Commit

Permalink
fix: [GSW-1987] Improve SwapRoute FE
Browse files Browse the repository at this point in the history
  • Loading branch information
tfrg committed Dec 23, 2024
1 parent af14ed9 commit f407c78
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions packages/web/src/react-query/router/use-get-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { SwapError } from "@common/errors/swap";
import { useGnoswapContext } from "@hooks/common/use-gnoswap-context";
import { TokenModel } from "@models/token/token-model";
import { GetRoutesResponse } from "@repositories/swap/response/get-routes-response";
import { wait } from "@utils/common";

import { QUERY_KEY } from "../query-keys";

Expand Down Expand Up @@ -39,21 +38,17 @@ export const useGetRoutes = (
const outputToken = request.outputToken;
const tokenAmount = Number(request.tokenAmount);

const result = await wait<GetRoutesResponse | null>(
async () =>
swapRouterRepository
.getRoutes({
inputToken,
outputToken,
exactType: request.exactType,
tokenAmount,
})
.catch(e => {
console.error(e);
return null;
}),
300,
);
const result = await swapRouterRepository
.getRoutes({
inputToken,
outputToken,
exactType: request.exactType,
tokenAmount,
})
.catch(e => {
console.error(e);
return null;
});

if (!result) {
throw new SwapError("NOT_FOUND_SWAP_POOL");
Expand All @@ -67,7 +62,7 @@ export const useGetRoutes = (

return result;
},
// retry: false,
retry: false,
refetchInterval: REFETCH_INTERVAL,
staleTime: STALE_TIME,
enabled: !!request?.inputToken?.path && !!request?.outputToken?.path,
Expand Down

0 comments on commit f407c78

Please sign in to comment.