com.binance.connector.client.impl.spot.Staking Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of binance-connector-java Show documentation
Show all versions of binance-connector-java Show documentation
lightweight connector to API
package com.binance.connector.client.impl.spot;
import java.util.Map;
import com.binance.connector.client.enums.HttpMethod;
import com.binance.connector.client.utils.ParameterChecker;
import com.binance.connector.client.utils.ProxyAuth;
import com.binance.connector.client.utils.RequestHandler;
import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator;
import com.binance.connector.client.utils.signaturegenerator.SignatureGenerator;
/**
* Staking Endpoints
* All endpoints under the
* Staking Endpoint
* section of the API documentation will be implemented in this class.
*
* Response will be returned in String format.
*/
public class Staking {
private final String baseUrl;
private final RequestHandler requestHandler;
private final boolean showLimitUsage;
public Staking(String baseUrl, String apiKey, String secretKey, boolean showLimitUsage, ProxyAuth proxy) {
this.baseUrl = baseUrl;
this.requestHandler = new RequestHandler(apiKey, new HmacSignatureGenerator(secretKey), proxy);
this.showLimitUsage = showLimitUsage;
}
public Staking(String baseUrl, String apiKey, SignatureGenerator signatureGenerator, boolean showLimitUsage, ProxyAuth proxy) {
this.baseUrl = baseUrl;
this.requestHandler = new RequestHandler(apiKey, signatureGenerator, proxy);
this.showLimitUsage = showLimitUsage;
}
private final String PRODUCT_LIST = "/sapi/v1/staking/productList";
/**
* Get available Staking product list
*
* GET /sapi/v1/staking/productList
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* product -- mandatory/enum -- "STAKING" for Locked Staking, "F_DEFI" for flexible DeFi Staking, "L_DEFI" for locked DeFi Staking
* asset -- optional/string
* current -- optional/long -- Currently querying page. Start from 1. Default:1
* size -- optional/long -- Default: 50, Max: 100
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#get-staking-product-list-user_data
*/
public String productList(Map parameters) {
ParameterChecker.checkParameter(parameters, "product", String.class);
return requestHandler.sendSignedRequest(baseUrl, PRODUCT_LIST, parameters, HttpMethod.GET, showLimitUsage);
}
private final String PURCHASE = "/sapi/v1/staking/purchase";
/**
* POST /sapi/v1/staking/purchase
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* product -- mandatory/enum -- "STAKING" for Locked Staking, "F_DEFI" for flexible DeFi Staking, "L_DEFI" for locked DeFi Staking
* productId -- mandatory/STRING
* amount -- mandatory/decimal
* renewable -- optional/string -- true or false, default false. Active if product is "STAKING" or "L_DEFI"
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#purchase-staking-product-user_data
*/
public String purchase(Map parameters) {
ParameterChecker.checkParameter(parameters, "product", String.class);
ParameterChecker.checkParameter(parameters, "productId", String.class);
ParameterChecker.checkParameter(parameters, "amount", Double.class);
return requestHandler.sendSignedRequest(baseUrl, PURCHASE, parameters, HttpMethod.POST, showLimitUsage);
}
private final String REDEEM = "/sapi/v1/staking/redeem";
/**
* Redeem Staking product. Locked staking and Locked DeFI staking belong to early redemption, redeeming in advance will result in loss of interest that you have earned.
*
* POST /sapi/v1/staking/redeem
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* product -- mandatory/enum -- "STAKING" for Locked Staking, "F_DEFI" for flexible DeFi Staking, "L_DEFI" for locked DeFi Staking
* positionId -- optional/string -- "1234", Mandatory if product is "STAKING" or "L_DEFI"
* productId -- mandatory/STRING
* amount -- optional/decimal -- Mandatory if product is "F_DEFI"
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#redeem-staking-product-user_data
*/
public String redeem(Map parameters) {
ParameterChecker.checkParameter(parameters, "product", String.class);
ParameterChecker.checkParameter(parameters, "productId", String.class);
return requestHandler.sendSignedRequest(baseUrl, REDEEM, parameters, HttpMethod.POST, showLimitUsage);
}
private final String POSITION = "/sapi/v1/staking/position";
/**
* GET /sapi/v1/staking/position
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* product -- mandatory/enum -- "STAKING" for Locked Staking, "F_DEFI" for flexible DeFi Staking, "L_DEFI" for locked DeFi Staking
* productId -- mandatory/STRING
* asset -- optional/string
* current -- optional/long -- Currently querying page. Start from 1. Default:1
* size -- optional/long -- Default: 50, Max: 100
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#get-staking-product-position-user_data
*/
public String getPosition(Map parameters) {
ParameterChecker.checkParameter(parameters, "product", String.class);
return requestHandler.sendSignedRequest(baseUrl, POSITION, parameters, HttpMethod.GET, showLimitUsage);
}
private final String STAKING_RECORD = "/sapi/v1/staking/stakingRecord";
/**
* GET /sapi/v1/staking/stakingRecord
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* product -- mandatory/enum -- "STAKING" for Locked Staking, "F_DEFI" for flexible DeFi Staking, "L_DEFI" for locked DeFi Staking
* txnType -- mandatory/enum -- "SUBSCRIPTION", "REDEMPTION", "INTEREST"
* asset -- optional/string
* startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Currently querying page. Start from 1. Default:1
* size -- optional/long -- Default: 50, Max: 100
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#get-staking-history-user_data
*/
public String stakingRecord(Map parameters) {
ParameterChecker.checkParameter(parameters, "product", String.class);
ParameterChecker.checkParameter(parameters, "txnType", String.class);
return requestHandler.sendSignedRequest(baseUrl, STAKING_RECORD, parameters, HttpMethod.GET, showLimitUsage);
}
private final String AUTO_STAKING = "/sapi/v1/staking/setAutoStaking";
/**
* Set auto staking on Locked Staking or Locked DeFi Staking
*
* POST /sapi/v1/staking/setAutoStaking
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* product -- mandatory/enum -- "STAKING" for Locked Staking, "F_DEFI" for flexible DeFi Staking, "L_DEFI" for locked DeFi Staking
* positionId -- mandatory/STRING
* renewable -- mandatory/STRING
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#set-auto-staking-user_data
*/
public String setAutoStaking(Map parameters) {
ParameterChecker.checkParameter(parameters, "product", String.class);
ParameterChecker.checkParameter(parameters, "positionId", String.class);
ParameterChecker.checkParameter(parameters, "renewable", String.class);
return requestHandler.sendSignedRequest(baseUrl, AUTO_STAKING, parameters, HttpMethod.POST, showLimitUsage);
}
private final String LEFT_QUOTA = "/sapi/v1/staking/personalLeftQuota";
/**
* GET /sapi/v1/staking/personalLeftQuota
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* product -- mandatory/enum -- "STAKING" for Locked Staking, "F_DEFI" for flexible DeFi Staking, "L_DEFI" for locked DeFi Staking
* productId -- mandatory/string
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#get-personal-left-quota-of-staking-product-user_data
*/
public String personalLeftQuota(Map parameters) {
ParameterChecker.checkParameter(parameters, "product", String.class);
ParameterChecker.checkParameter(parameters, "productId", String.class);
return requestHandler.sendSignedRequest(baseUrl, LEFT_QUOTA, parameters, HttpMethod.GET, showLimitUsage);
}
}