Skip to content

Commit

Permalink
Leverage V3 endpoint support
Browse files Browse the repository at this point in the history
  • Loading branch information
blazeTan committed Jun 26, 2024
1 parent 77354c2 commit 92f631d
Show file tree
Hide file tree
Showing 47 changed files with 1,598 additions and 164 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The detailed document [https://docs.kucoin.com](https://docs.kucoin.com).
<dependency>
<groupId>com.kucoin</groupId>
<artifactId>kucoin-java-sdk</artifactId>
<version>1.0.11</version>
<version>1.0.12</version>
</dependency>
```
## Usage
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.kucoin</groupId>
<artifactId>kucoin-java-sdk</artifactId>
<version>1.0.11</version>
<version>1.0.12</version>

<name>kucoin-java-sdk</name>
<description>kucoin-java-sdk</description>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/kucoin/sdk/KucoinObjectMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;

public class KucoinObjectMapper {
Expand All @@ -10,6 +11,7 @@ public class KucoinObjectMapper {

static {
INSTANCE = new ObjectMapper();
INSTANCE.setSerializationInclusion(JsonInclude.Include.NON_NULL);
INSTANCE.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);
}

Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/kucoin/sdk/enums/AccountTypeEnum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.kucoin.sdk.enums;

/**
* @author blazetan
*/
public enum AccountTypeEnum {
MAIN,
TRADE,
CONTRACT,
MARGIN,
ISOLATED,
TRADE_HF,
MARGIN_V2,
ISOLATED_V2;
}
8 changes: 8 additions & 0 deletions src/main/java/com/kucoin/sdk/enums/LendingStatusEnum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.kucoin.sdk.enums;

/**
* @author blazetan
*/
public enum LendingStatusEnum {
DONE,PENDING
}
8 changes: 8 additions & 0 deletions src/main/java/com/kucoin/sdk/enums/TimeInForceEnum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.kucoin.sdk.enums;

/**
* @author blazetan
*/
public enum TimeInForceEnum {
IOC,FOK
}
5 changes: 2 additions & 3 deletions src/main/java/com/kucoin/sdk/factory/HttpClientFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
package com.kucoin.sdk.factory;

import com.kucoin.sdk.rest.interceptor.AuthenticationInterceptor;
import okhttp3.Dispatcher;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.*;

/**
* Created by chenshiwei on 2019/1/18.
Expand All @@ -30,6 +28,7 @@ private static OkHttpClient buildHttpClient(Interceptor interceptor) {
if (interceptor != null) {
builder.addInterceptor(interceptor);
}

return builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public Map<String, String> innerTransfer2(AccountTransferV2Request request) thro
return super.executeSync(getAPIImpl().applyTransfer2(request));
}

@Override
public UniversalTransferResponse universalTransfer(UniversalTransferRequest request) throws IOException {
return super.executeSync(getAPIImpl().universalTransfer(request));
}

@Override
public List<SubAccountBalanceResponse> listSubAccounts() throws IOException {
return super.executeSync(getAPIImpl().getSubAccountList());
Expand Down
82 changes: 63 additions & 19 deletions src/main/java/com/kucoin/sdk/rest/adapter/LoanAPIAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,11 @@
import com.kucoin.sdk.rest.impl.retrofit.AuthRetrofitAPIImpl;
import com.kucoin.sdk.rest.interfaces.LoanAPI;
import com.kucoin.sdk.rest.interfaces.retrofit.LoanAPIRetrofit;
import com.kucoin.sdk.rest.request.BorrowRecordQueryRequest;
import com.kucoin.sdk.rest.request.BorrowRequest;
import com.kucoin.sdk.rest.request.LendRequest;
import com.kucoin.sdk.rest.request.RepayAllRequest;
import com.kucoin.sdk.rest.request.RepaySingleRequest;
import com.kucoin.sdk.rest.request.ToggleAutoLendRequest;
import com.kucoin.sdk.rest.response.ActiveLendItem;
import com.kucoin.sdk.rest.response.BorrowOutstandingResponse;
import com.kucoin.sdk.rest.response.BorrowQueryResponse;
import com.kucoin.sdk.rest.response.BorrowRepaidResponse;
import com.kucoin.sdk.rest.response.BorrowResponse;
import com.kucoin.sdk.rest.response.DoneLendItem;
import com.kucoin.sdk.rest.response.LastTradeResponse;
import com.kucoin.sdk.rest.response.LendAssetsResponse;
import com.kucoin.sdk.rest.response.LendResponse;
import com.kucoin.sdk.rest.response.MarketItemResponse;
import com.kucoin.sdk.rest.response.Pagination;
import com.kucoin.sdk.rest.response.SettledTradeItem;
import com.kucoin.sdk.rest.response.UnsettledTradeItem;
import com.kucoin.sdk.rest.request.*;
import com.kucoin.sdk.rest.response.*;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;

/**
Expand All @@ -42,6 +26,66 @@ public LoanAPIAdapter(String baseUrl, String apiKey, String secret, String passP
this.apiKeyVersion = apiKeyVersion;
}

@Override
public BorrowV3Response borrowV3(BorrowV3Request request) throws IOException {
return executeSync(getAPIImpl().borrowV3(request));
}

@Override
public Pagination<BorrowQueryV3Response> queryBorrowV3(BorrowQueryV3Request request) throws IOException {
return executeSync(getAPIImpl().queryBorrowV3(request.getMapParams()));
}

@Override
public RepayV3Response repayV3(RepayV3Request request) throws IOException {
return executeSync(getAPIImpl().repayV3(request));
}

@Override
public Pagination<RepayQueryV3Response> queryRepayV3(RepayQueryV3Request request) throws IOException {
return executeSync(getAPIImpl().queryRepayV3(request.getMapParams()));
}

@Override
public Pagination<InterestQueryV3Response> queryInterestV3(InterestQueryV3Request request) throws IOException {
return executeSync(getAPIImpl().queryInterestV3(request.getMapParams()));
}

@Override
public List<MarginProjectListResponse> getProjectList(String currency) throws IOException {
return executeSync(getAPIImpl().getProjectList(currency));
}

@Override
public List<MarginMarketInterestRateResponse> getMarketInterestRate(String currency) throws IOException {
return executeSync(getAPIImpl().getProjectMarketInterestRate(currency));
}

@Override
public PurchaseResponse purchase(PurchaseRequest request) throws IOException {
return executeSync(getAPIImpl().purchase(request));
}

@Override
public void updatePurchase(UpdatePurchaseRequest request) throws IOException {
executeSync(getAPIImpl().updatePurchase(request));
}

@Override
public Pagination<PurchaseQueryResponse> queryPurchase(PurchaseQueryRequest request) throws IOException {
return executeSync(getAPIImpl().queryPurchase(request.getMapParams()));
}

@Override
public RedeemResponse redeem(RedeemRequest request) throws IOException {
return executeSync(getAPIImpl().redeem(request));
}

@Override
public Pagination<RedeemQueryResponse> queryRedeem(RedeemQueryRequest request) throws IOException {
return executeSync(getAPIImpl().queryRedeem(request.getMapParams()));
}

@Override
public BorrowResponse borrow(BorrowRequest request) throws IOException {
return executeSync(getAPIImpl().borrow(request));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public MarginOrderCreateResponse createMarginOrder(MarginOrderCreateRequest requ
return executeSync(getAPIImpl().createMarginOrder(request));
}

@Override
public MarginOrderCreateResponse createMarginOrderTest(MarginOrderCreateRequest request) throws IOException {
return executeSync(getAPIImpl().createMarginOrderTest(request));
}

@Override
public List<MarginPriceStrategyResponse> getMarginPriceStrategy(String marginModel) throws IOException {
return executeSync(getAPIImpl().getMarginPriceStrategy(marginModel));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ public HFOrderCreateResponse createHFOrder(HFOrderCreateRequest createRequest) t
return executeSync(getAPIImpl().createHFOrder(createRequest));
}

@Override
public HFOrderCreateResponse createHFOrderTest(HFOrderCreateRequest createRequest) throws IOException {
return executeSync(getAPIImpl().createHFOrderTest(createRequest));
}

@Override
public HFOrderSyncCreateResponse syncCreateHFOrder(HFOrderCreateRequest createRequest) throws IOException {
return executeSync(getAPIImpl().syncCreateHFOrder(createRequest));
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/kucoin/sdk/rest/interfaces/AccountAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ Pagination<AccountDetailResponse> getAccountLedgers(String currency, String dire
*/
Map<String, String> innerTransfer2(AccountTransferV2Request request) throws IOException;

/**
* FlexTransfer
*
* @param request
* @return
* @throws IOException
*/
UniversalTransferResponse universalTransfer(UniversalTransferRequest request) throws IOException;

/**
* Get a list of sub-accounts.
* <p>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/kucoin/sdk/rest/interfaces/IsolatedAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public interface IsolatedAPI {
* @param period [Optional] The term in days. Defaults to all terms if left blank. 7,14,28
* @return The isolated borrow result;
*/
@Deprecated
IsolatedBorrowResponse borrow(String symbol, String currency, BigDecimal size, String borrowStrategy, BigDecimal maxRate, String period) throws IOException;

/**
Expand All @@ -58,6 +59,7 @@ public interface IsolatedAPI {
* @param currentPage [Optional] Current page number [1-100]
* @return The outstanding repayment records
*/
@Deprecated
Pagination<IsolatedBorrowOutstandingResponse> queryBorrowOutstanding(String symbol, String currency, int pageSize, int currentPage) throws IOException;

/**
Expand All @@ -69,6 +71,7 @@ public interface IsolatedAPI {
* @param currentPage [Optional] Current page number [1-100]
* @return The repayment records
*/
@Deprecated
Pagination<IsolatedBorrowRepaidResponse> queryBorrowRepaid(String symbol, String currency, int pageSize, int currentPage) throws IOException;

/**
Expand All @@ -79,6 +82,7 @@ public interface IsolatedAPI {
* @param size Repayment amount
* @param seqStrategy Repayment sequence strategy, RECENTLY_EXPIRE_FIRST: Maturity date priority (the loan with the closest maturity is repaid first), HIGHEST_RATE_FIRST: Interest rate priority (the loan with the highest interest rate is repaid first)
*/
@Deprecated
void repayAll(String symbol, String currency, BigDecimal size, String seqStrategy) throws IOException;

/**
Expand All @@ -89,6 +93,7 @@ public interface IsolatedAPI {
* @param size Repayment amount
* @param loanId Trade order number; when this field is configured, the sequence strategy is invalidated
*/
@Deprecated
void repaySingle(String symbol, String currency, BigDecimal size, String loanId) throws IOException;

/**
Expand Down
Loading

0 comments on commit 92f631d

Please sign in to comment.