Skip to content

Commit

Permalink
fix: BOOT token invalid swaps (#3822)
Browse files Browse the repository at this point in the history
* fix: 0 decimal coin denom error

* chore: readd spacing
  • Loading branch information
crnbarr93 committed Sep 3, 2024
1 parent 0e2b361 commit 1356272
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/web/hooks/use-swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,6 @@ function useQueryRouterBestQuote(

const quoteResult =
quoteType === "out-given-in" ? outGivenInQuote : inGivenOutQuote;

const {
data: quote,
isSuccess,
Expand All @@ -1543,7 +1542,13 @@ function useQueryRouterBestQuote(
}, [quoteResult]);

const acceptedQuote = useMemo(() => {
if (!quote || !input.tokenIn || !input.tokenOut) return;
if (
!quote ||
!input.tokenIn ||
!input.tokenOut ||
quote.amount.toDec().isZero()
)
return;
return {
...quote,
amountIn:
Expand All @@ -1564,17 +1569,17 @@ function useQueryRouterBestQuote(
const tokenOutCoinMinimalDenom = input.tokenOut?.coinMinimalDenom;
if (
!quote ||
!tokenOutCoinDecimals ||
typeof tokenOutCoinDecimals === "undefined" ||
!tokenInCoinMinimalDenom ||
!tokenOutCoinMinimalDenom ||
!tokenInCoinDecimals
typeof tokenInCoinDecimals === "undefined"
)
return undefined;
const messages = await getSwapMessages({
quote: quote,
tokenOutCoinMinimalDenom,
tokenInCoinDecimals,
tokenOutCoinDecimals,
tokenInCoinDecimals: tokenInCoinDecimals!,
tokenOutCoinDecimals: tokenOutCoinDecimals!,
tokenInCoinMinimalDenom,
maxSlippage: input.maxSlippage?.toString(),
coinAmount: input.tokenInAmount,
Expand Down

0 comments on commit 1356272

Please sign in to comment.