diff --git a/.changeset/weak-beds-cheer.md b/.changeset/weak-beds-cheer.md new file mode 100644 index 000000000..de6c1d388 --- /dev/null +++ b/.changeset/weak-beds-cheer.md @@ -0,0 +1,5 @@ +--- +'@reservoir0x/relay-kit-ui': patch +--- + +Improve ui when no route are available diff --git a/packages/ui/src/components/widgets/FeeBreakdown.tsx b/packages/ui/src/components/widgets/FeeBreakdown.tsx index ff467cadd..b7bd8323e 100644 --- a/packages/ui/src/components/widgets/FeeBreakdown.tsx +++ b/packages/ui/src/components/widgets/FeeBreakdown.tsx @@ -41,6 +41,7 @@ type Props = Pick< fromChainWalletVMSupported?: boolean isAutoSlippage: boolean slippageInputBps?: string + error?: any } const formatSwapRate = (rate: number) => { @@ -62,7 +63,8 @@ const FeeBreakdown: FC = ({ isSingleChainLocked, fromChainWalletVMSupported, isAutoSlippage, - slippageInputBps + slippageInputBps, + error }) => { const [isOpen, setIsOpen] = useState(false) const swapRate = quote?.details?.rate @@ -218,6 +220,7 @@ const FeeBreakdown: FC = ({ setUseExternalLiquidity(selected) }} canonicalTimeEstimate={canonicalTimeEstimate?.formattedTime} + error={error} trigger={ ) diff --git a/packages/ui/src/components/widgets/SwapWidget/index.tsx b/packages/ui/src/components/widgets/SwapWidget/index.tsx index e47d7849d..930518425 100644 --- a/packages/ui/src/components/widgets/SwapWidget/index.tsx +++ b/packages/ui/src/components/widgets/SwapWidget/index.tsx @@ -1548,6 +1548,7 @@ const SwapWidget: FC = ({ onExternalLiquidityChange={(selected) => { setUseExternalLiquidity(selected) }} + error={error} /> ) : null} @@ -1588,6 +1589,7 @@ const SwapWidget: FC = ({ canonicalTimeEstimate={canonicalTimeEstimate} isSingleChainLocked={isSingleChainLocked} fromChainWalletVMSupported={fromChainWalletVMSupported} + error={error} /> = ({ quote?.details?.currencyOut && (quote?.details?.currencyOut?.amountUsd === undefined || quote?.details?.currencyOut?.amountUsd === '0') + const isNoAvailableRoutesError = + error?.response?.data?.errorCode === 'NO_SWAP_ROUTES_FOUND' || + error?.response?.data?.errorCode === 'UNSUPPORTED_ROUTE' - if (isInsufficientLiquidityError) { + if (isInsufficientLiquidityError || isNoAvailableRoutesError) { return null }