From 9b32c6067aafea081152366e1f61797db94acc5e Mon Sep 17 00:00:00 2001 From: Khushboo-dev-cpp <60327365+Khushboo-dev-cpp@users.noreply.github.com> Date: Wed, 8 Feb 2023 16:22:50 +0530 Subject: [PATCH] fix: Fix issue where best routes with not enough balance is returned (#3164) --- services/wallet/router.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/wallet/router.go b/services/wallet/router.go index 8d4a6f4b7..6947da96a 100644 --- a/services/wallet/router.go +++ b/services/wallet/router.go @@ -570,6 +570,11 @@ func (r *Router) suggestedRoutes( } requiredNativeBalance := new(big.Int).Mul(gweiToWei(maxFees), big.NewInt(int64(gasLimit))) + // Removed the required fees from maxAMount in case of native token tx + if token.IsNative() { + maxAmountIn = (*hexutil.Big)(new(big.Int).Sub(maxAmountIn.ToInt(), requiredNativeBalance)) + } + if nativeBalance.Cmp(requiredNativeBalance) <= 0 { continue }