From 2a96e05585c27c67585e7b71d916edd0cdd22ef5 Mon Sep 17 00:00:00 2001 From: Dmitrii Podlesnyi Date: Mon, 19 Feb 2024 16:11:47 +0400 Subject: [PATCH] fix: use token max amount limit after gas --- shared/hooks/use-token-max-amount.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shared/hooks/use-token-max-amount.ts b/shared/hooks/use-token-max-amount.ts index 0e9614b65..4c3a0d1d0 100644 --- a/shared/hooks/use-token-max-amount.ts +++ b/shared/hooks/use-token-max-amount.ts @@ -28,10 +28,6 @@ export const useTokenMaxAmount = ({ let maxAmount: BigNumber | undefined = balance; - if (limit && balance.gt(limit)) { - maxAmount = limit; - } - if (isPadded) { if (padding) { maxAmount = maxAmount.sub(padding); @@ -43,6 +39,10 @@ export const useTokenMaxAmount = ({ } else maxAmount = undefined; } + if (limit && maxAmount && maxAmount.gt(limit)) { + maxAmount = limit; + } + return maxAmount; }, [balance, gasLimit, padding, isLoading, isPadded, limit, maxGasPrice]);