Fixes Binance withdrawals failing due to additive fee - #1137
Open
Jackb-03 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes Binance withdrawals failing with "User has insufficient balance" when using USDT as the preferred fiat currency.
The previous implementation unconditionally added the Binance withdrawal fee on top of the withdrawal amount in sendCoins(). After purchasing crypto with USDT, Binance's trading fee reduces the actual balance received below the ordered amount. This meant the code was attempting to withdraw more than the available balance every time.
The fix replaces the unconditional fee addition with a balance-aware approach:
When balance >= amount + fee, the fee is added to the withdrawal so the customer receives the full requested amount.
When balance >= amount but less than amount + fee, the amount is sent as-is and the customer receives the amount minus the fee that Binance deducts automatically.
When balance < amount (common after trading fees reduce the purchased amount), the entire available balance is sent instead of failing.
This preserves the original intent of covering the withdrawal fee when possible while preventing the withdrawal from failing when the balance is tight. Tested with real Binance transactions confirming both the fee-inclusive and fee-exclusive withdrawal paths succeed.