fix: fixed dust left when trying to buy max amount without leverage (#565)

This commit is contained in:
Linkie Link 2023-10-21 11:11:40 +02:00 committed by GitHub
parent 2b0173f01e
commit 40c2e8039a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 (
<>
<Divider />