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]);