import { ArrowDownUpIcon, ExternalLinkIcon } from "lucide-react"; import { Alert, AlertDescription, AlertTitle } from "src/components/ui/alert"; import { useBalances } from "src/hooks/useBalances"; import { useChannels } from "src/hooks/useChannels"; import { ExternalLinkButton } from "../ui/custom/external-link-button"; import { LinkButton } from "../ui/custom/link-button"; type SwapAlertProps = { className?: string; minChannels?: number; swapType?: "in" | "out"; }; export function SwapAlert({ className, minChannels = 2, swapType, }: SwapAlertProps) { const { data: channels } = useChannels(); const { data: balances } = useBalances(); if (!channels || !balances) { return null; } if (minChannels && channels.length < minChannels) { return null; } const isSwapOut = swapType ? swapType === "out" : balances.lightning.totalSpendableMsat > balances.lightning.totalReceivableMsat; const directionText = isSwapOut ? "out from" : "into"; return ( Swap {directionText} existing channels

It can be more economic to swap funds {directionText} existing channels rather than opening new channels or closing existing ones.

Learn more Swap {isSwapOut ? "Out" : "In"}
); }