Skip to content

Commit

Permalink
Merge pull request #860 from drocek/bugfix/BATM-4385_six_decimal_plac…
Browse files Browse the repository at this point in the history
…es_for_usdt_on_binance

BATM-4385: six decimal places for USDT on Binance exchange
  • Loading branch information
generalbytes authored Nov 7, 2023
2 parents 505fcfb + 9b525c7 commit 78627f4
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.binance;

import com.generalbytes.batm.common.currencies.CryptoCurrency;
import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.XChangeExchange;
import org.knowm.xchange.ExchangeSpecification;
import org.knowm.xchange.currency.CurrencyPair;
import org.knowm.xchange.dto.account.AccountInfo;
import org.knowm.xchange.dto.account.Wallet;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Set;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -91,6 +93,11 @@ protected BigDecimal getAmountRoundedToMinStep(BigDecimal cryptoAmount, BigDecim
public String sendCoins(String destinationAddress, BigDecimal amount, String cryptoCurrency, String description) {
BigDecimal withdrawalFee = getWithdrawalFee(cryptoCurrency);
amount = amount.add(withdrawalFee);

if (CryptoCurrency.USDT.getCode().equals(cryptoCurrency)) {
amount = amount.setScale(6, RoundingMode.FLOOR);
}

return super.sendCoins(destinationAddress, amount, cryptoCurrency, description);
}

Expand All @@ -110,8 +117,8 @@ protected BigDecimal getWithdrawalMinStep(String cryptoCurrency) {
}

protected static class SupportedCryptoCurrency {
private String cryptoCurrency;
private BigDecimal withdrawalMinStep;
private final String cryptoCurrency;
private final BigDecimal withdrawalMinStep;

public SupportedCryptoCurrency(String cryptoCurrency) {
this(cryptoCurrency, new BigDecimal("0.00000001"));
Expand Down

0 comments on commit 78627f4

Please sign in to comment.