From 40c2e8039ab48551cbf7b65c5a4907c7306c8abf Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Sat, 21 Oct 2023 11:11:40 +0200 Subject: [PATCH] fix: fixed dust left when trying to buy max amount without leverage (#565) --- src/components/Trade/TradeModule/SwapForm/index.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/Trade/TradeModule/SwapForm/index.tsx b/src/components/Trade/TradeModule/SwapForm/index.tsx index 0d5dc412..2e299ed8 100644 --- a/src/components/Trade/TradeModule/SwapForm/index.tsx +++ b/src/components/Trade/TradeModule/SwapForm/index.tsx @@ -241,6 +241,11 @@ export default function SwapForm(props: Props) { } }, [account?.id, swapTx, setIsConfirming]) + useEffect(() => { + if (sellAssetAmount.isEqualTo(maxSellAmount) || buyAssetAmount.isZero()) return + if (buyAssetAmount.isEqualTo(maxBuyableAmountEstimation)) setSellAssetAmount(maxSellAmount) + }, [sellAssetAmount, maxSellAmount, buyAssetAmount, maxBuyableAmountEstimation]) + return ( <>