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
The newest version!
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);
}
private final String SUB_ETH_STAKING = "/sapi/v2/eth-staking/eth/stake";
/**
* Stake ETH to get WBETH
*
*
* POST /sapi/v2/eth-staking/eth/stake
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* amount -- mandatory/decimal -- Amount in ETH, limit 4 decimals
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#subscribe-eth-staking-trade
*/
public String subEthStaking(Map parameters) {
ParameterChecker.checkRequiredParameter(parameters, "amount");
return requestHandler.sendSignedRequest(baseUrl, SUB_ETH_STAKING, parameters, HttpMethod.POST, showLimitUsage);
}
private final String REDEEM_ETH = "/sapi/v1/eth-staking/eth/redeem";
/**
* Redeem WBETH or BETH and get ETH
*
*
* POST /sapi/v1/eth-staking/eth/redeem
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* amount -- mandatory/decimal -- Amount in ETH, limit 4 decimals
* asset -- optional/string -- "BETH" or "WBETH", default "BETH"
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#redeem-eth-trade
*/
public String redeemEthStaking(Map parameters) {
ParameterChecker.checkRequiredParameter(parameters, "amount");
return requestHandler.sendSignedRequest(baseUrl, REDEEM_ETH, parameters, HttpMethod.POST, showLimitUsage);
}
private final String ETH_STAKING_HISTORY = "/sapi/v1/eth-staking/eth/history/stakingHistory";
/**
* GET /sapi/v1/eth-staking/eth/history/stakingHistory
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Currently querying page. Start from 1. Default:1
* size -- optional/long -- Default: 10, Max: 100
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#get-eth-staking-history-user_data
*/
public String ethStakingSubHistory(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_HISTORY, parameters, HttpMethod.GET, showLimitUsage);
}
private final String ETH_STAKING_REDEEM_HISTORY = "/sapi/v1/eth-staking/eth/history/redemptionHistory";
/**
* GET /sapi/v1/eth-staking/eth/history/redemptionHistory
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Currently querying page. Start from 1. Default:1
* size -- optional/long -- Default: 10, Max: 100
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#get-eth-redemption-history-user_data
*/
public String ethStakingRedeemHistory(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_REDEEM_HISTORY, parameters, HttpMethod.GET, showLimitUsage);
}
private final String ETH_STAKING_REWARDS_HISTORY = "/sapi/v1/eth-staking/eth/history/rewardsHistory";
/**
* GET /sapi/v1/eth-staking/eth/history/rewardsHistory
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Currently querying page. Start from 1. Default:1
* size -- optional/long -- Default: 10, Max: 100
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#get-beth-rewards-distribution-history-user_data
*/
public String ethStakingRewardsHistory(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_REWARDS_HISTORY, parameters, HttpMethod.GET, showLimitUsage);
}
private final String ETH_STAKING_QUOTA = "/sapi/v1/eth-staking/eth/quota";
/**
* GET /sapi/v1/eth-staking/eth/quota
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#get-current-eth-staking-quota-user_data
*/
public String ethStakingQuota(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_QUOTA, parameters, HttpMethod.GET, showLimitUsage);
}
private final String ETH_STAKING_RATE_HISTORY = "/sapi/v1/eth-staking/eth/history/rateHistory";
/**
* GET /sapi/v1/eth-staking/eth/history/rateHistory
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Currently querying page. Start from 1. Default:1
* size -- optional/long -- Default: 10, Max: 100
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#get-wbeth-rate-history-user_data
*/
public String ethStakingRateHistory(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_RATE_HISTORY, parameters, HttpMethod.GET, showLimitUsage);
}
private final String ETH_STAKING_ACCOUNT = "/sapi/v2/eth-staking/account";
/**
* GET /sapi/v2/eth-staking/account
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#eth-staking-account-v2-user_data
*/
public String ethStakingAccount(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_ACCOUNT, parameters, HttpMethod.GET, showLimitUsage);
}
private final String WRAP_WBETH = "/sapi/v1/eth-staking/wbeth/wrap";
/**
* POST /sapi/v1/eth-staking/wbeth/wrap
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* amount -- mandatory/decimal -- Amount in BETH, limit 4 decimals
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#wrap-beth-trade
*/
public String wrapEthStakingWbeth(Map parameters) {
ParameterChecker.checkRequiredParameter(parameters, "amount");
return requestHandler.sendSignedRequest(baseUrl, WRAP_WBETH, parameters, HttpMethod.POST, showLimitUsage);
}
private final String ETH_STAKING_WBETH_WRAP_HISTORY = "/sapi/v1/eth-staking/wbeth/history/wrapHistory";
/**
* GET /sapi/v1/eth-staking/wbeth/history/wrapHistory
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Currently querying page. Start from 1. Default:1
* size -- optional/long -- Default: 10, Max: 100
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#get-wbeth-wrap-history-user_data
*/
public String ethStakingWbethWrapHistory(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_WBETH_WRAP_HISTORY, parameters, HttpMethod.GET, showLimitUsage);
}
private final String ETH_STAKING_WBETH_UNWRAP_HISTORY = "/sapi/v1/eth-staking/wbeth/history/unwrapHistory";
/**
* GET /sapi/v1/eth-staking/wbeth/history/unwrapHistory
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Currently querying page. Start from 1. Default:1
* size -- optional/long -- Default: 10, Max: 100
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#get-wbeth-unwrap-history-user_data
*/
public String ethStakingWbethUnwrapHistory(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_WBETH_UNWRAP_HISTORY, parameters, HttpMethod.GET, showLimitUsage);
}
private final String ETH_STAKING_WBETH_REWARD_HISTORY = "/sapi/v1/eth-staking/eth/history/wbethRewardsHistory";
/**
* GET /sapi/v1/eth-staking/eth/history/wbethRewardsHistory
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* startTime -- optional/long
* endTime -- optional/long
* current -- optional/long -- Currently querying page. Start from 1. Default:1
* size -- optional/long -- Default: 10, Max: 100
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#get-wbeth-rewards-history-user_data
*/
public String ethStakingWbethRewardHistory(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, ETH_STAKING_WBETH_REWARD_HISTORY, parameters, HttpMethod.GET, showLimitUsage);
}
}