Skip to content

Commit

Permalink
dont count placeholder data as valid
Browse files Browse the repository at this point in the history
  • Loading branch information
tinaszheng committed Jan 8, 2025
1 parent 4643aa0 commit 2f3bd02
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/views/dialogs/DepositDialog2/DepositForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,20 @@ export const DepositForm = ({
const tokenBalance = useBalance(token.chainId, token.denom);

const debouncedAmount = useDebounce(amount);
const { data: routes, isFetching, error } = useRoutes(token, debouncedAmount);
const { data: routes, isFetching, error, isPlaceholderData } = useRoutes(token, debouncedAmount);

useEffect(() => {
if (debouncedAmount && !isFetching && !routes?.fast) setSelectedSpeed('slow');
}, [isFetching, routes, debouncedAmount]);

const selectedRoute = selectedSpeed === 'fast' ? routes?.fast : routes?.slow;
const hasSufficientBalance = selectedRoute
? tokenBalance.raw && BigInt(selectedRoute.amountIn) <= BigInt(tokenBalance.raw)
const depositRoute = !isPlaceholderData ? selectedRoute : undefined;

const hasSufficientBalance = depositRoute
? tokenBalance.raw && BigInt(depositRoute.amountIn) <= BigInt(tokenBalance.raw)
: true;

const depositDisabled = isFetching || !hasSufficientBalance || !selectedRoute;
const depositDisabled = isFetching || !hasSufficientBalance || !depositRoute;

const depositButtonInner = useMemo(() => {
if (isFetching) return <LoadingDots size={3} />;
Expand Down

0 comments on commit 2f3bd02

Please sign in to comment.