Skip to content

Commit 0522436

Browse files
authored
Merge pull request #21 from cryptomkt/feat/update-january-2025
Feat/update january 2025
2 parents 0c1667e + 65aff58 commit 0522436

File tree

8 files changed

+206
-22
lines changed

8 files changed

+206
-22
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.cryptomarket.sdk.models;
2+
3+
/**
4+
* Whitelisted address
5+
*/
6+
public class WhitelistedAddress {
7+
/** Name of the whitelist item */
8+
private String name;
9+
10+
/** Currency code */
11+
private String currency;
12+
13+
/** Code of the currency of the hosting network */
14+
private String network;
15+
16+
/** Address for deposits */
17+
private String address;
18+
19+
public String getName() {
20+
return name;
21+
}
22+
23+
public void setName(String name) {
24+
this.name = name;
25+
}
26+
27+
public String getCurrency() {
28+
return currency;
29+
}
30+
31+
public void setCurrency(String currency) {
32+
this.currency = currency;
33+
}
34+
35+
public String getNetwork() {
36+
return network;
37+
}
38+
39+
public void setNetwork(String network) {
40+
this.network = network;
41+
}
42+
43+
public String getAddress() {
44+
return address;
45+
}
46+
47+
public void setAddress(String address) {
48+
this.address = address;
49+
}
50+
51+
@Override
52+
public String toString() {
53+
return "WhitelistedAddress [name=" + name + ", currency=" + currency + ", network=" + network + ", address="
54+
+ address + "]";
55+
}
56+
}

src/main/java/com/cryptomarket/sdk/rest/CryptomarketRestClient.java

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import com.cryptomarket.sdk.models.TickerPrice;
4848
import com.cryptomarket.sdk.models.Trade;
4949
import com.cryptomarket.sdk.models.Transaction;
50+
import com.cryptomarket.sdk.models.WhitelistedAddress;
5051

5152
/**
5253
* Rest Client Interface for cryptomarket API V3.
@@ -940,6 +941,9 @@ public List<Order> createSpotOrderList(
940941
* the symbol's tick_size and quantity_increment
941942
* @param price Required if order type is 'limit', 'stopLimit', or
942943
* 'takeProfitLimit'. Order price
944+
* @param stopPrice Required if order type is 'stopLimit', 'stopMarket',
945+
* 'takeProfitLimit', or 'takeProfitMarket'. Order stop
946+
* price
943947
* @return The new spot order
944948
* @throws CryptomarketSDKException
945949
*/
@@ -948,6 +952,7 @@ public Order replaceSpotOrder(
948952
String newClientOrderId,
949953
String quantity,
950954
@Nullable String price,
955+
@Nullable String stopPrice,
951956
@Nullable Boolean strictValidate) throws CryptomarketSDKException;
952957

953958
/**
@@ -1124,6 +1129,7 @@ public List<Trade> getSpotTradesHistory(
11241129
public List<Trade> getSpotTradesHistory(ParamsBuilder paramsBuilder)
11251130
throws CryptomarketSDKException;
11261131

1132+
11271133
// WALLET MANAGEMENT
11281134

11291135
/**
@@ -1169,6 +1175,18 @@ public List<Trade> getSpotTradesHistory(ParamsBuilder paramsBuilder)
11691175
*/
11701176
public Balance getWalletBalance(String currency) throws CryptomarketSDKException;
11711177

1178+
/**
1179+
* Gets the list of whitelisted addresses
1180+
* <p>
1181+
* Requires the "Payment information" API key Access Right
1182+
* <p>
1183+
* https://api.exchange.cryptomkt.com/#get-whitelisted-addresses
1184+
*
1185+
* @return the list of white listed addresses
1186+
* @throws CryptomarketSDKException
1187+
*/
1188+
public List<WhitelistedAddress> getWhitelistedAddresses() throws CryptomarketSDKException;
1189+
11721190
/**
11731191
* Get the current addresses of the user
11741192
* <p>
@@ -1401,6 +1419,18 @@ public String getEstimateWithdrawalFee(String currency, String amount, @Nullable
14011419
*/
14021420
public List<Fee> getBulkEstimateWithdrawalFees(List<FeeRequest> feeRequests) throws CryptomarketSDKException;
14031421

1422+
/**
1423+
* Gets the hash of withdrawal fees
1424+
* <p>
1425+
* Requires the "Payment information" API key Access Right
1426+
* <p>
1427+
* https://api.exchange.cryptomkt.com/#get-withdrawal-fees-hash
1428+
*
1429+
* @return the fees hash
1430+
* @throws CryptomarketSDKException
1431+
*/
1432+
public String getWithdrawalFeesHash() throws CryptomarketSDKException;
1433+
14041434
/**
14051435
* Get an estimate of the deposit fee
14061436
* <p>
@@ -1785,6 +1815,50 @@ public String transferFunds(String subAccountId, String amount, String currency,
17851815
SubAccountTransferType transferType)
17861816
throws CryptomarketSDKException;
17871817

1818+
/**
1819+
* Creates and commits a transfer from a subaccount to its super account
1820+
* <p>
1821+
* Call is being sent by a subaccount
1822+
* <p>
1823+
* Created but not committed transfer will reserve pending amount on the sender
1824+
* wallet affecting their ability to withdraw or transfer crypto to another
1825+
* account. Incomplete withdrawals affect subaccount transfers the same way
1826+
* <p>
1827+
* Requires the "Withdraw cryptocurrencies" API key Access Right
1828+
* <p>
1829+
* https://api.exchange.cryptomkt.com/#transfer-to-super-account
1830+
*
1831+
* @param amount the amount of currency to transfer
1832+
* @param currency the currency to transfer
1833+
* @return The transaction id of the tranfer
1834+
* @throws CryptomarketSDKException
1835+
*/
1836+
public String transferToSuperAccount(String amount, String currency)
1837+
throws CryptomarketSDKException;
1838+
1839+
/**
1840+
* Creates and commits a transfer between the user (subaccount) and another
1841+
* subaccount.
1842+
* <p>
1843+
* Call is being sent by a subaccount
1844+
* <p>
1845+
* Created but not committed transfer will reserve pending amount on the sender
1846+
* wallet affecting their ability to withdraw or transfer crypto to another
1847+
* account. Incomplete withdrawals affect subaccount transfers the same way
1848+
* <p>
1849+
* Requires the "Withdraw cryptocurrencies" API key Access Right
1850+
* <p>
1851+
* https://api.exchange.cryptomkt.com/#transfer-across-subaccounts
1852+
*
1853+
* @param amount the amount of currency to transfer
1854+
* @param currency the currency to transfer
1855+
* @return The transaction id of the tranfer
1856+
* @throws CryptomarketSDKException
1857+
*/
1858+
1859+
public String transferToAnotherSubAccount(String subAccountId, String amount, String currency)
1860+
throws CryptomarketSDKException;
1861+
17881862
/**
17891863
* Returns a list of withdrawal settings for sub-accounts listed
17901864
* <p>

src/main/java/com/cryptomarket/sdk/rest/CryptomarketRestClientImpl.java

Lines changed: 61 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import com.cryptomarket.sdk.models.TickerPrice;
5252
import com.cryptomarket.sdk.models.Trade;
5353
import com.cryptomarket.sdk.models.Transaction;
54+
import com.cryptomarket.sdk.models.WhitelistedAddress;
5455
import com.cryptomarket.sdk.requests.OrderListRequest;
5556
import com.cryptomarket.sdk.requests.WithdrawRequest;
5657

@@ -606,11 +607,13 @@ public Order replaceSpotOrder(
606607
String newClientOrderId,
607608
String quantity,
608609
String price,
610+
String stopPrice,
609611
Boolean strictValidate) throws CryptomarketSDKException {
610612
return replaceSpotOrder(new ParamsBuilder()
611613
.newClientOrderId(newClientOrderId)
612614
.quantity(quantity)
613615
.price(price)
616+
.stopPrice(stopPrice)
614617
.strictValidate(strictValidate));
615618
}
616619

@@ -739,7 +742,7 @@ public List<Trade> getSpotTradesHistory(ParamsBuilder paramsBuilder)
739742
paramsBuilder.build());
740743
return adapter.listFromJson(jsonResponse, Trade.class);
741744
}
742-
745+
743746
// WALLET MANAGEMENT
744747

745748
@Override
@@ -764,6 +767,12 @@ public Balance getWalletBalance(String currency) throws CryptomarketSDKException
764767
return getWalletBalanceByCurrency(currency);
765768
}
766769

770+
@Override
771+
public List<WhitelistedAddress> getWhitelistedAddresses() throws CryptomarketSDKException {
772+
String jsonResponse = httpClient.get("wallet/crypto/address/white-list", null);
773+
return adapter.listFromJson(jsonResponse, WhitelistedAddress.class);
774+
}
775+
767776
@Override
768777
public List<Address> getDepositCryptoAddresses(String currency, String networkCode) throws CryptomarketSDKException {
769778
Map<String, String> params = new ParamsBuilder()
@@ -912,7 +921,6 @@ public List<Fee> getEstimateWithdrawalFees(List<FeeRequest> feeRequests) throws
912921
return adapter.listFromJson(jsonResponse, Fee.class);
913922
}
914923

915-
916924
@Override
917925
public List<Fee> getBulkEstimateWithdrawalFees(List<FeeRequest> feeRequests) throws CryptomarketSDKException {
918926
var payload = adapter.listToJson(feeRequests, FeeRequest.class);
@@ -922,33 +930,42 @@ public List<Fee> getBulkEstimateWithdrawalFees(List<FeeRequest> feeRequests) thr
922930
return adapter.listFromJson(jsonResponse, Fee.class);
923931
}
924932

933+
@Override
934+
public String getWithdrawalFeesHash() throws CryptomarketSDKException {
935+
String jsonResponse = httpClient.get("wallet/crypto/fee/withdraw/hash", null);
936+
return adapter.objectFromJsonValue(jsonResponse, "hash", String.class);
937+
}
938+
925939
// @Override
926-
// public String getEstimateDepositFee(String currency, String amount, String networkCode)
927-
// throws CryptomarketSDKException {
928-
// return getEstimateDepositFee(new ParamsBuilder()
929-
// .currency(currency)
930-
// .networkCode(networkCode)
931-
// .amount(amount));
940+
// public String getEstimateDepositFee(String currency, String amount, String
941+
// networkCode)
942+
// throws CryptomarketSDKException {
943+
// return getEstimateDepositFee(new ParamsBuilder()
944+
// .currency(currency)
945+
// .networkCode(networkCode)
946+
// .amount(amount));
932947
// }
933948

934949
// @Override
935-
// public String getEstimateDepositFee(ParamsBuilder paramsBuilder) throws CryptomarketSDKException {
936-
// paramsBuilder.checkRequired(Arrays.asList(
937-
// ArgNames.CURRENCY,
938-
// ArgNames.AMOUNT));
939-
// String jsonResponse = httpClient.get(
940-
// "wallet/crypto/fee/deposit/estimate",
941-
// paramsBuilder.build());
942-
// return adapter.objectFromJsonValue(jsonResponse, "fee", String.class);
950+
// public String getEstimateDepositFee(ParamsBuilder paramsBuilder) throws
951+
// CryptomarketSDKException {
952+
// paramsBuilder.checkRequired(Arrays.asList(
953+
// ArgNames.CURRENCY,
954+
// ArgNames.AMOUNT));
955+
// String jsonResponse = httpClient.get(
956+
// "wallet/crypto/fee/deposit/estimate",
957+
// paramsBuilder.build());
958+
// return adapter.objectFromJsonValue(jsonResponse, "fee", String.class);
943959
// }
944960

945961
// @Override
946-
// public List<Fee> getBulkEstimateDepositFees(List<FeeRequest> feeRequests) throws CryptomarketSDKException {
947-
// var payload = adapter.listToJson(feeRequests, FeeRequest.class);
948-
// String jsonResponse = httpClient.post(
949-
// "wallet/crypto/fee/deposit/estimate/bulk",
950-
// payload);
951-
// return adapter.listFromJson(jsonResponse, Fee.class);
962+
// public List<Fee> getBulkEstimateDepositFees(List<FeeRequest> feeRequests)
963+
// throws CryptomarketSDKException {
964+
// var payload = adapter.listToJson(feeRequests, FeeRequest.class);
965+
// String jsonResponse = httpClient.post(
966+
// "wallet/crypto/fee/deposit/estimate/bulk",
967+
// payload);
968+
// return adapter.listFromJson(jsonResponse, Fee.class);
952969
// }
953970

954971
@Override
@@ -1199,6 +1216,28 @@ public String transferFunds(String subAccountId, String amount, String currency,
11991216
return adapter.objectFromJsonValue(jsonResponse, "result", String.class);
12001217
}
12011218

1219+
@Override
1220+
public String transferToSuperAccount(String amount, String currency)
1221+
throws CryptomarketSDKException {
1222+
ParamsBuilder params = new ParamsBuilder()
1223+
.amount(amount)
1224+
.currency(currency);
1225+
String jsonResponse = httpClient.get("sub-account/transfer/sub-to-super", params.build());
1226+
return adapter.objectFromJsonValue(jsonResponse, "result", String.class);
1227+
1228+
}
1229+
1230+
@Override
1231+
public String transferToAnotherSubAccount(String subAccountId, String amount, String currency)
1232+
throws CryptomarketSDKException {
1233+
ParamsBuilder params = new ParamsBuilder()
1234+
.subAccountId(subAccountId)
1235+
.amount(amount)
1236+
.currency(currency);
1237+
String jsonResponse = httpClient.get("sub-account/transfer/sub-to-sub", params.build());
1238+
return adapter.objectFromJsonValue(jsonResponse, "result", String.class);
1239+
}
1240+
12021241
@Override
12031242
public List<SubAccountSettings> getACLSettings(List<String> subAccountIds) throws CryptomarketSDKException {
12041243
ParamsBuilder params = new ParamsBuilder()

src/main/java/com/cryptomarket/sdk/rest/HttpClientImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ private String makeRequest(HttpUriRequest request) throws CryptomarketSDKExcepti
282282
try {
283283
response.close();
284284
} catch (IOException e) {
285+
throw new CryptomarketSDKException("unable to close api response. " + e.getMessage(), e);
285286
}
286287
if (isSuccessful)
287288
return responseBody;

src/main/java/com/cryptomarket/sdk/websocket/CryptomarketWSSpotTradingClient.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ public void cancelSpotOrder(String clientOrderId,
275275
* be unique within the trading day
276276
* @param quantity new order quantity
277277
* @param price new order price
278+
* @param stopPrice Required if order type is 'stopLimit', 'stopMarket',
279+
* 'takeProfitLimit', or 'takeProfitMarket'. Order stop
280+
* price
278281
* @param strictValidate price and quantity will be checked for the
279282
* incrementation with tick size and quantity step. See
280283
* symbol's tick_size and quantity_increment
@@ -288,6 +291,7 @@ public void replaceSpotOrder(
288291
String newClientOrderId,
289292
@Nullable String quantity,
290293
@Nullable String price,
294+
@Nullable String stopPrice,
291295
@Nullable Boolean strictValidate,
292296
@Nullable BiConsumer<Report, CryptomarketSDKException> resultBiConsumer);
293297

src/main/java/com/cryptomarket/sdk/websocket/CryptomarketWSSpotTradingClientImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,14 @@ public void cancelSpotOrder(String clientOrderId, BiConsumer<Report, Cryptomarke
212212

213213
@Override
214214
public void replaceSpotOrder(String clientOrderId, String newClientOrderId, String quantity, String price,
215+
String stopPrice,
215216
Boolean strictValidate, BiConsumer<Report, CryptomarketSDKException> resultBiConsumer) {
216217
ParamsBuilder paramsBuilder = new ParamsBuilder()
217218
.clientOrderId(clientOrderId)
218219
.newClientOrderId(newClientOrderId)
219220
.quantity(quantity)
220221
.price(price)
222+
.stopPrice(stopPrice)
221223
.strictValidate(strictValidate);
222224
Interceptor interceptor = (resultBiConsumer == null)
223225
? null

src/test/java/com/cryptomarket/sdk/TestRestClientWalletManagement.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ public void testGetEstimateWithdrawFee() throws CryptomarketSDKException {
142142
fail();
143143
}
144144
}
145+
@Test
146+
public void testGetEstimateWithdrawFeesHash() throws CryptomarketSDKException {
147+
String estimate = client.getWithdrawalFeesHash();
148+
if (estimate.equals("")) {
149+
fail();
150+
}
151+
}
145152

146153
// @Test
147154
// public void testGetEstimateDepositFees() throws CryptomarketSDKException {

src/test/java/com/cryptomarket/sdk/TestWSSpotTradingClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public void testOrderFlow() {
110110
"0.02",
111111
"2000",
112112
null,
113+
null,
113114
(report, exception) -> {
114115
if (exception != null) {
115116
fail();

0 commit comments

Comments
 (0)