Skip to content

Commit

Permalink
feat(): added new endpoints, updated Readme, updated types
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ-Cro committed Oct 15, 2024
1 parent f8a8842 commit 68245d1
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Refer to the [examples](./examples) folder for implementation demos.
- Issues? Check the [issues tab](https://github.com/tiagosiebler/binance/issues).
- Discuss & collaborate with other node devs? Join our [Node.js Algo Traders](https://t.me/nodetraders) engineering community on telegram.
- Questions about Binance APIs & WebSockets? Ask in the official [Binance API](https://t.me/binance_api_english) group on telegram.
- Follow our announcement channel for real-time updates on [X/Twitter](https://x.com/QuantSDKs)

<!-- template_related_projects -->

Expand Down
15 changes: 15 additions & 0 deletions docs/endpointFunctionList.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ This table includes all endpoints from the official Exchange API docs and corres
| `queryMarginAccountTradeList()` | :closed_lock_with_key: | GET | `sapi/v1/margin/myTrades` |
| `submitSmallLiabilityExchange()` | :closed_lock_with_key: | POST | `sapi/v1/margin/exchange-small-liability` |
| `submitManualLiquidation()` | :closed_lock_with_key: | POST | `sapi/v1/margin/manual-liquidation` |
| `submitMarginOTOOrder()` | :closed_lock_with_key: | POST | `sapi/v1/margin/order/oto` |
| `submitMarginOTOCOOrder()` | :closed_lock_with_key: | POST | `sapi/v1/margin/order/otoco` |
| `createMarginSpecialLowLatencyKey()` | :closed_lock_with_key: | POST | `sapi/v1/margin/apiKey` |
| `deleteMarginSpecialLowLatencyKey()` | :closed_lock_with_key: | DELETE | `sapi/v1/margin/apiKey` |
| `updateMarginIPForSpecialLowLatencyKey()` | :closed_lock_with_key: | PUT | `sapi/v1/margin/apiKey/ip` |
| `getMarginSpecialLowLatencyKeys()` | :closed_lock_with_key: | GET | `sapi/v1/margin/api-key-list` |
| `getMarginSpecialLowLatencyKey()` | :closed_lock_with_key: | GET | `sapi/v1/margin/apiKey` |
| `getCrossMarginTransferHistory()` | :closed_lock_with_key: | GET | `sapi/v1/margin/transfer` |
| `queryMaxTransferOutAmount()` | :closed_lock_with_key: | GET | `sapi/v1/margin/maxTransferable` |
| `updateCrossMarginMaxLeverage()` | :closed_lock_with_key: | POST | `sapi/v1/margin/max-leverage` |
Expand Down Expand Up @@ -266,6 +273,14 @@ This table includes all endpoints from the official Exchange API docs and corres
| `getStakingProductPosition()` | :closed_lock_with_key: | GET | `sapi/v1/staking/position` |
| `getStakingHistory()` | :closed_lock_with_key: | GET | `sapi/v1/staking/stakingRecord` |
| `getPersonalLeftQuotaOfStakingProduct()` | :closed_lock_with_key: | GET | `sapi/v1/staking/personalLeftQuota` |
| `getSolStakingAccount()` | :closed_lock_with_key: | GET | `sapi/v1/sol-staking/account` |
| `getSolStakingQuota()` | :closed_lock_with_key: | GET | `sapi/v1/sol-staking/sol/quota` |
| `subscribeSolStaking()` | :closed_lock_with_key: | POST | `sapi/v1/sol-staking/sol/stake` |
| `redeemSol()` | :closed_lock_with_key: | POST | `sapi/v1/sol-staking/sol/redeem` |
| `getSolStakingHistory()` | :closed_lock_with_key: | GET | `sapi/v1/sol-staking/sol/history/stakingHistory` |
| `getSolRedemptionHistory()` | :closed_lock_with_key: | GET | `sapi/v1/sol-staking/sol/history/redemptionHistory` |
| `getBnsolRewardsHistory()` | :closed_lock_with_key: | GET | `sapi/v1/sol-staking/sol/history/bnsolRewardsHistory` |
| `getBnsolRateHistory()` | :closed_lock_with_key: | GET | `sapi/v1/sol-staking/sol/history/rateHistory` |
| `getFuturesLeadTraderStatus()` | :closed_lock_with_key: | GET | `sapi/v1/copyTrading/futures/userStatus` |
| `getFuturesLeadTradingSymbolWhitelist()` | :closed_lock_with_key: | GET | `sapi/v1/copyTrading/futures/leadSymbol` |
| `getMiningAlgos()` | | GET | `sapi/v1/mining/pub/algoList` |
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "binance",
"version": "2.13.5",
"version": "2.13.6",
"description": "Node.js & JavaScript SDK for Binance REST APIs & WebSockets, with TypeScript & end-to-end tests.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
94 changes: 91 additions & 3 deletions src/main-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,17 @@ import {
CreateSpecialLowLatencyKeyParams,
SpecialLowLatencyKeyResponse,
SpecialLowLatencyKeyInfo,
SolStakingAccount,
SolStakingQuota,
SubscribeSolStakingResponse,
RedeemSolResponse,
GetSolStakingHistoryReq,
SolStakingHistoryRecord,
SolRedemptionHistoryRecord,
GetBnsolRewardsHistoryReq,
BnsolRewardHistoryRecord,
BnsolRateHistoryRecord,
GetBnsolRateHistoryReq,
} from './types/spot';

import {
Expand Down Expand Up @@ -2125,7 +2136,7 @@ export class MainClient extends BaseRestClient {

/**
*
* STAKING Endpoints - Account
* STAKING Endpoints - ETH Staking - Account
*
**/

Expand All @@ -2146,7 +2157,7 @@ export class MainClient extends BaseRestClient {

/**
*
* STAKING Endpoints - Staking
* STAKING Endpoints - ETH Staking- Staking
*
**/

Expand Down Expand Up @@ -2175,7 +2186,7 @@ export class MainClient extends BaseRestClient {

/**
*
* STAKING Endpoints - History
* STAKING Endpoints - ETH Staking - History
*
**/

Expand Down Expand Up @@ -2288,6 +2299,83 @@ export class MainClient extends BaseRestClient {
return this.getPrivate('sapi/v1/staking/personalLeftQuota', params);
}

/**
*
* STAKING Endpoints - SOL Staking- Account
*
**/

getSolStakingAccount(): Promise<SolStakingAccount> {
return this.getPrivate('sapi/v1/sol-staking/account');
}

getSolStakingQuota(): Promise<SolStakingQuota> {
return this.getPrivate('sapi/v1/sol-staking/sol/quota');
}

/**
*
* STAKING Endpoints - SOL Staking - Staking
*
**/

subscribeSolStaking(params: {
amount: number;
}): Promise<SubscribeSolStakingResponse> {
return this.postPrivate('sapi/v1/sol-staking/sol/stake', params);
}

redeemSol(params: { amount: number }): Promise<RedeemSolResponse> {
return this.postPrivate('sapi/v1/sol-staking/sol/redeem', params);
}

/**
*
* STAKING Endpoints - SOL Staking- History
*
**/

getSolStakingHistory(params?: GetSolStakingHistoryReq): Promise<{
rows: SolStakingHistoryRecord[];
total: number;
}> {
return this.getPrivate(
'sapi/v1/sol-staking/sol/history/stakingHistory',
params,
);
}

getSolRedemptionHistory(params?: {
rows: SolRedemptionHistoryRecord[];
total: number;
}): Promise<SolRedemptionHistoryRecord> {
return this.getPrivate(
'sapi/v1/sol-staking/sol/history/redemptionHistory',
params,
);
}

getBnsolRewardsHistory(params?: GetBnsolRewardsHistoryReq): Promise<{
estRewardsInSOL: string;
rows: BnsolRewardHistoryRecord[];
total: number;
}> {
return this.getPrivate(
'sapi/v1/sol-staking/sol/history/bnsolRewardsHistory',
params,
);
}

getBnsolRateHistory(params?: GetBnsolRateHistoryReq): Promise<{
rows: BnsolRateHistoryRecord[];
total: string;
}> {
return this.getPrivate(
'sapi/v1/sol-staking/sol/history/rateHistory',
params,
);
}

/**
*
* COPY TRADING Endpoints - Future copy trading
Expand Down
27 changes: 27 additions & 0 deletions src/types/futures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,23 @@ export type FuturesOrderType =
| 'TAKE_PROFIT_MARKET'
| 'TRAILING_STOP_MARKET';

export type SelfTradePreventionMode =
| 'NONE'
| 'EXPIRE_TAKER'
| 'EXPIRE_MAKER'
| 'EXPIRE_BOTH';

export type PriceMatchMode =
| 'NONE'
| 'OPPONENT'
| 'OPPONENT_5'
| 'OPPONENT_10'
| 'OPPONENT_20'
| 'QUEUE'
| 'QUEUE_5'
| 'QUEUE_10'
| 'QUEUE_20';

// When using the submitMultipleOrders() endpoint, it seems to expect strings instead of numbers. All other endpoints use numbers.
export interface NewFuturesOrderParams<numberType = number> {
symbol: string;
Expand All @@ -124,6 +141,8 @@ export interface NewFuturesOrderParams<numberType = number> {
workingType?: WorkingType;
priceProtect?: BooleanStringCapitalised;
newOrderRespType?: OrderResponseType;
selfTradePreventionMode?: SelfTradePreventionMode;
priceMatch?: PriceMatchMode;
}

export interface ModifyFuturesOrderParams<numberType = number> {
Expand Down Expand Up @@ -425,6 +444,8 @@ export interface NewOrderResult {
updateTime: number;
workingType: WorkingType;
priceProtect: boolean;
selfTradePreventionMode: SelfTradePreventionMode;
priceMatch: PriceMatchMode;
}

export interface NewOrderError {
Expand Down Expand Up @@ -456,6 +477,8 @@ export interface OrderResult {
updateTime: number;
workingType: WorkingType;
priceProtect: boolean;
selfTradePreventionMode: SelfTradePreventionMode;
priceMatch: PriceMatchMode;
}

export interface ModifyFuturesOrderResult {
Expand All @@ -481,6 +504,8 @@ export interface ModifyFuturesOrderResult {
priceProtect: boolean;
origType: FuturesOrderType;
updateTime: number;
selfTradePreventionMode: SelfTradePreventionMode;
priceMatch: PriceMatchMode;
}

export interface CancelFuturesOrderResult {
Expand All @@ -506,6 +531,8 @@ export interface CancelFuturesOrderResult {
updateTime: number;
workingType: WorkingType;
priceProtect: boolean;
selfTradePreventionMode: SelfTradePreventionMode;
priceMatch: PriceMatchMode;
}

export interface CancelAllOpenOrdersResult {
Expand Down
106 changes: 105 additions & 1 deletion src/types/spot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5289,4 +5289,108 @@ export interface SpecialLowLatencyKeyInfo {
apiKey: string;
ip: string;
type: 'HMAC_SHA256' | 'RSA' | 'Ed25519';
}
}

export interface SolStakingAccount {
bnsolAmount: string; // Amount in bNSOL
holdingInSOL: string; // Holding in SOL
thirtyDaysProfitInSOL: string; // 30 days profit in SOL
}

export interface SolStakingQuota {
leftStakingPersonalQuota: string; // Remaining personal staking quota
leftRedemptionPersonalQuota: string; // Remaining personal redemption quota
minStakeAmount: string; // Minimum stake amount
minRedeemAmount: string; // Minimum redeem amount
redeemPeriod: number; // Redemption period in days
stakeable: boolean; // Whether staking is possible
redeemable: boolean; // Whether redemption is possible
soldOut: boolean; // Whether the staking is sold out
commissionFee: string; // Commission fee
nextEpochTime: number; // Time for the next epoch
calculating: boolean; // Whether calculations are ongoing
}

export interface SubscribeSolStakingResponse {
success: boolean; // Indicates if the subscription was successful
bnsolAmount: string; // Amount in bNSOL received
exchangeRate: string; // SOL amount per 1 BNSOL
}

export interface RedeemSolResponse {
success: boolean; // Indicates if the redemption was successful
solAmount: string; // Amount in SOL received
exchangeRate: string; // SOL amount per 1 BNSOL
arrivalTime: number; // Time of arrival for the redeemed SOL
}

export interface GetSolStakingHistoryReq {
startTime?: number; // Optional, start time in milliseconds
endTime?: number; // Optional, end time in milliseconds
current?: number; // Optional, current page, default is 1
size?: number; // Optional, number of records per page, default is 10, max is 100
recvWindow?: number; // Optional, cannot be greater than 60000
timestamp: number; // Mandatory
}

export interface SolStakingHistoryRecord {
time: number; // Time of the staking event
asset: string; // Asset involved, e.g., SOL
amount: string; // Amount staked
distributeAsset: string; // Asset distributed, e.g., BNSOL
distributeAmount: string; // Amount distributed
exchangeRate: string; // Exchange rate at the time
status: 'PENDING' | 'SUCCESS' | 'FAILED'; // Status of the staking event
}

export interface GetSolRedemptionHistoryReq {
startTime?: number; // Optional, start time in milliseconds
endTime?: number; // Optional, end time in milliseconds
current?: number; // Optional, current page, default is 1
size?: number; // Optional, number of records per page, default is 10, max is 100
recvWindow?: number; // Optional, cannot be greater than 60000
timestamp: number; // Mandatory
}

export interface SolRedemptionHistoryRecord {
time: number; // Time of the redemption event
arrivalTime: number; // Time of arrival for the redeemed SOL
asset: string; // Asset redeemed, e.g., BNSOL
amount: string; // Amount redeemed
distributeAsset: string; // Asset distributed, e.g., SOL
distributeAmount: string; // Amount distributed
exchangeRate: string; // Exchange rate at the time
status: 'PENDING' | 'SUCCESS' | 'FAILED'; // Status of the redemption event
}

export interface GetBnsolRewardsHistoryReq {
startTime?: number; // Optional, start time in milliseconds
endTime?: number; // Optional, end time in milliseconds
current?: number; // Optional, current page, default is 1
size?: number; // Optional, number of records per page, default is 10, max is 100
recvWindow?: number; // Optional, cannot be greater than 60000
timestamp: number; // Mandatory
}

export interface BnsolRewardHistoryRecord {
time: number; // Time of the reward event
amountInSOL: string; // Reward amount in SOL
holding: string; // BNSOL holding balance
holdingInSOL: string; // BNSOL holding balance in SOL
annualPercentageRate: string; // Annual Percentage Rate (e.g., "0.5" means 50%)
}

export interface GetBnsolRateHistoryReq {
startTime?: number; // Optional, start time in milliseconds
endTime?: number; // Optional, end time in milliseconds
current?: number; // Optional, current page, default is 1
size?: number; // Optional, number of records per page, default is 10, max is 100
recvWindow?: number; // Optional, cannot be greater than 60000
timestamp: number; // Mandatory
}

export interface BnsolRateHistoryRecord {
annualPercentageRate: string; // BNSOL APR
exchangeRate: string; // SOL amount per 1 BNSOL
time: number; // Time of the rate record
}

0 comments on commit 68245d1

Please sign in to comment.