fix: Fix issue where best routes with not enough balance is returned (#3164)

This commit is contained in:
Khushboo-dev-cpp 2023-02-08 16:22:50 +05:30 committed by GitHub
parent 8934426cbd
commit 9b32c6067a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -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
}