Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/knowm/XChange into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
timmolter committed Apr 20, 2024
2 parents a8794fc + 7dd2e5c commit 31cd4f5
Show file tree
Hide file tree
Showing 29 changed files with 967 additions and 239 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public BinanceKline(Instrument instrument, KlineInterval interval, Object[] obj)
this.numberOfTrades = Long.parseLong(obj[8].toString());
this.takerBuyBaseAssetVolume = new BigDecimal(obj[9].toString());
this.takerBuyQuoteAssetVolume = new BigDecimal(obj[10].toString());
this.closed = (Boolean) obj[11];
this.closed = Boolean.parseBoolean(obj[11].toString());
}

public BigDecimal getAveragePrice() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,27 @@
import jakarta.ws.rs.core.MediaType;
import java.io.IOException;
import java.math.BigDecimal;
import org.knowm.xchange.coinmate.dto.account.AmountType;
import org.knowm.xchange.coinmate.dto.account.CoinmateBalance;
import org.knowm.xchange.coinmate.dto.account.CoinmateDepositAddresses;
import org.knowm.xchange.coinmate.dto.account.CoinmateTradingFeesResponse;
import org.knowm.xchange.coinmate.dto.account.FeePriority;
import org.knowm.xchange.coinmate.dto.trade.*;
import org.knowm.xchange.coinmate.dto.account.TransferHistoryOrder;
import org.knowm.xchange.coinmate.dto.account.UnconfirmedDepositsResponse;
import org.knowm.xchange.coinmate.dto.trade.CoinmateBuyFixRateResponse;
import org.knowm.xchange.coinmate.dto.trade.CoinmateCancelOrderResponse;
import org.knowm.xchange.coinmate.dto.trade.CoinmateCancelOrderWithInfoResponse;
import org.knowm.xchange.coinmate.dto.trade.CoinmateOpenOrders;
import org.knowm.xchange.coinmate.dto.trade.CoinmateOrder;
import org.knowm.xchange.coinmate.dto.trade.CoinmateOrderHistory;
import org.knowm.xchange.coinmate.dto.trade.CoinmateOrders;
import org.knowm.xchange.coinmate.dto.trade.CoinmateReplaceResponse;
import org.knowm.xchange.coinmate.dto.trade.CoinmateSellFixRateResponse;
import org.knowm.xchange.coinmate.dto.trade.CoinmateTradeHistory;
import org.knowm.xchange.coinmate.dto.trade.CoinmateTradeResponse;
import org.knowm.xchange.coinmate.dto.trade.CoinmateTransactionHistory;
import org.knowm.xchange.coinmate.dto.trade.CoinmateTransferDetail;
import org.knowm.xchange.coinmate.dto.trade.CoinmateTransferHistory;
import si.mazi.rescu.ParamsDigest;
import si.mazi.rescu.SynchronizedValueFactory;

Expand Down Expand Up @@ -266,6 +282,42 @@ CoinmateTradeResponse sellQuickFix(

// withdrawal and deposits
// bitcoin

@POST
@Path("withdrawVirtualCurrency")
CoinmateTradeResponse withdrawVirtualCurrency(
@FormParam("publicKey") String publicKey,
@FormParam("clientId") String clientId,
@FormParam("signature") ParamsDigest signer,
@FormParam("nonce") SynchronizedValueFactory<Long> nonce,
@FormParam("currencyName") String currencyName,
@FormParam("amount") BigDecimal amount,
@FormParam("destinationTag") String destinationTag,
@FormParam("amountType") AmountType amountType,
@FormParam("address") String address,
@FormParam("feePriority") FeePriority feePriority)
throws IOException;

@POST
@Path("virtualCurrencyDepositAddresses")
CoinmateDepositAddresses virtualCurrencyDepositAddresses(
@FormParam("publicKey") String publicKey,
@FormParam("clientId") String clientId,
@FormParam("signature") ParamsDigest signer,
@FormParam("nonce") SynchronizedValueFactory<Long> nonce,
@FormParam("currencyName") String currencyName)
throws IOException;

@POST
@Path("unconfirmedVirtualCurrencyDeposits")
UnconfirmedDepositsResponse unconfirmedVirtualCurrencyDeposits(
@FormParam("publicKey") String publicKey,
@FormParam("clientId") String clientId,
@FormParam("signature") ParamsDigest signer,
@FormParam("nonce") SynchronizedValueFactory<Long> nonce,
@FormParam("currencyName") String currencyName)
throws IOException;

@POST
@Path("bitcoinWithdrawal")
CoinmateTradeResponse bitcoinWithdrawal(
Expand Down Expand Up @@ -352,28 +404,6 @@ CoinmateDepositAddresses rippleDepositAddresses(
@FormParam("nonce") SynchronizedValueFactory<Long> nonce)
throws IOException;

// dash

@POST
@Path("dashWithdrawal")
CoinmateTradeResponse dashWithdrawal(
@FormParam("publicKey") String publicKey,
@FormParam("clientId") String clientId,
@FormParam("signature") ParamsDigest signer,
@FormParam("nonce") SynchronizedValueFactory<Long> nonce,
@FormParam("amount") BigDecimal amount,
@FormParam("address") String address)
throws IOException;

@POST
@Path("dashDepositAddresses")
CoinmateDepositAddresses dashDepositAddresses(
@FormParam("publicKey") String publicKey,
@FormParam("clientId") String clientId,
@FormParam("signature") ParamsDigest signer,
@FormParam("nonce") SynchronizedValueFactory<Long> nonce)
throws IOException;

@POST
@Path("adaWithdrawal")
CoinmateTradeResponse adaWithdrawal(
Expand Down Expand Up @@ -452,7 +482,7 @@ CoinmateTransferHistory getTransferHistory(
@FormParam("nonce") SynchronizedValueFactory<Long> nonce,
@FormParam("limit") Integer limit,
@FormParam("lastId") Integer lastId,
@FormParam("sort") String sort,
@FormParam("sort") TransferHistoryOrder sort,
@FormParam("timestampFrom") Long timestampFrom,
@FormParam("timestampTo") Long timestampTo,
@FormParam("currency") String currency)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.knowm.xchange.coinmate.dto.account;

public enum AmountType {
NET,
GROSS
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.knowm.xchange.coinmate.dto.account;

public enum TransferHistoryOrder {
ASC, DESC
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.knowm.xchange.coinmate.dto.account;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.math.BigDecimal;

public class UnconfirmedDeposits {
private final Long id;

private final BigDecimal amount;

private final String address;

private final Long confirmations;

public UnconfirmedDeposits(
@JsonProperty Long id,
@JsonProperty BigDecimal amount,
@JsonProperty String address,
@JsonProperty Long confirmations) {
this.id = id;
this.amount = amount;
this.address = address;
this.confirmations = confirmations;
}

public Long getId() {
return id;
}

public BigDecimal getAmount() {
return amount;
}

public String getAddress() {
return address;
}

public Long getConfirmations() {
return confirmations;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.knowm.xchange.coinmate.dto.account;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import org.knowm.xchange.coinmate.dto.CoinmateBaseResponse;

public class UnconfirmedDepositsResponse
extends CoinmateBaseResponse<ArrayList<UnconfirmedDeposits>> {
public UnconfirmedDepositsResponse(
@JsonProperty("error") boolean error,
@JsonProperty("errorMessage") String errorMessage,
@JsonProperty("data") ArrayList<UnconfirmedDeposits> data) {

super(error, errorMessage, data);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class CoinmateTransferHistoryEntry {
private final String walletType;
private final String destination;
private final String destinationTag;
private final String txid;

public CoinmateTransferHistoryEntry(
@JsonProperty("transactionId") long id,
Expand All @@ -25,8 +26,9 @@ public CoinmateTransferHistoryEntry(
@JsonProperty("amountCurrency") String amountCurrency,
@JsonProperty("walletType") String walletType,
@JsonProperty("destination") String destination,
@JsonProperty("destinationTag") String destinationTag) {

@JsonProperty("destinationTag") String destinationTag,
@JsonProperty("txid") String txid
) {
this.fee = fee;
this.transferType = transferType;
this.timestamp = timestamp;
Expand All @@ -37,6 +39,7 @@ public CoinmateTransferHistoryEntry(
this.walletType = walletType;
this.destination = destination;
this.destinationTag = destinationTag;
this.txid = txid;
}

public long getId() {
Expand Down Expand Up @@ -78,4 +81,6 @@ public String getDestination() {
public String getDestinationTag() {
return destinationTag;
}

public String getTxid() { return txid; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@
import org.knowm.xchange.Exchange;
import org.knowm.xchange.coinmate.CoinmateAdapters;
import org.knowm.xchange.coinmate.CoinmateUtils;
import org.knowm.xchange.coinmate.dto.account.AmountType;
import org.knowm.xchange.coinmate.dto.account.CoinmateDepositAddresses;
import org.knowm.xchange.coinmate.dto.account.CoinmateTradingFeesResponseData;
import org.knowm.xchange.coinmate.dto.account.FeePriority;
import org.knowm.xchange.coinmate.dto.trade.CoinmateTradeResponse;
import org.knowm.xchange.coinmate.dto.trade.CoinmateTransactionHistory;
import org.knowm.xchange.coinmate.dto.trade.CoinmateTransferDetail;
import org.knowm.xchange.coinmate.dto.trade.CoinmateTransferHistory;
import org.knowm.xchange.currency.Currency;
import org.knowm.xchange.dto.account.AccountInfo;
import org.knowm.xchange.dto.account.AddressWithTag;
import org.knowm.xchange.dto.account.Fee;
import org.knowm.xchange.dto.account.FundingRecord;
import org.knowm.xchange.instrument.Instrument;
Expand Down Expand Up @@ -97,12 +100,13 @@ public String withdrawFunds(Currency currency, BigDecimal amount, String address
response = coinmateEthereumWithdrawal(amount, address);
} else if (currency.equals(Currency.XRP)) {
response = coinmateRippleWithdrawal(amount, address);
} else if (currency.equals(Currency.DASH)) {
response = coinmateDashWithdrawal(amount, address);
} else if (currency.equals(Currency.ADA)) {
response = coinmateCardanoWithdrawal(amount, address);
} else if (currency.equals(Currency.SOL)) {
response = coinmateSolanaWithdrawal(amount, address);
} else if (currency.equals(Currency.USDT)) {
Long tradeId = coinmateWithdrawVirtualCurrency(amount, address, Currency.USDT.getCurrencyCode(), AmountType.GROSS, FeePriority.HIGH, null);
return Long.toString(tradeId);
} else {
throw new IOException(
"Wallet for currency" + currency.getCurrencyCode() + " is currently not supported");
Expand All @@ -111,10 +115,27 @@ public String withdrawFunds(Currency currency, BigDecimal amount, String address
return Long.toString(response.getData());
}

@Override
public String withdrawFunds(Currency currency, BigDecimal amount, AddressWithTag address)
throws IOException {
if (currency.equals(Currency.XRP)) {
Long tradeId = coinmateWithdrawVirtualCurrency(amount, address.getAddress(), currency.getCurrencyCode(), AmountType.GROSS, FeePriority.HIGH, address.getAddressTag());
return Long.toString(tradeId);
} else {
return withdrawFunds(currency, amount, address.getAddress());
}
}

@Override
public String withdrawFunds(WithdrawFundsParams params) throws IOException {
if (params instanceof DefaultWithdrawFundsParams) {
DefaultWithdrawFundsParams defaultParams = (DefaultWithdrawFundsParams) params;

if (defaultParams.getCurrency().equals(Currency.XRP)) {
Long tradeId = coinmateWithdrawVirtualCurrency(defaultParams.getAmount(), defaultParams.getAddress(), defaultParams.getCurrency().getCurrencyCode(), AmountType.GROSS, FeePriority.HIGH, defaultParams.getAddressTag());
return Long.toString(tradeId);
}

return withdrawFunds(
defaultParams.getCurrency(), defaultParams.getAmount(), defaultParams.getAddress());
}
Expand All @@ -132,12 +153,16 @@ public String requestDepositAddress(Currency currency, String... args) throws IO
addresses = coinmateEthereumDepositAddresses();
} else if (currency.equals(Currency.XRP)) {
addresses = coinmateRippleDepositAddresses();
} else if (currency.equals(Currency.DASH)) {
addresses = coinmateDashDepositAddresses();
} else if (currency.equals(Currency.ADA)) {
addresses = coinmateCardanoDepositAddresses();
} else if (currency.equals(Currency.SOL)) {
addresses = coinmateSolanaDepositAddresses();
} else if (currency.equals(Currency.USDT)) {
List<String> addressesAll = coinmateVirtualCurrencyDepositAddresses(currency.getCurrencyCode());
if (addressesAll.isEmpty()) {
return null;
}
return addressesAll.get(0);
} else {
throw new IOException(
"Wallet for currency" + currency.getCurrencyCode() + " is currently not supported");
Expand Down
Loading

0 comments on commit 31cd4f5

Please sign in to comment.