Skip to content

Commit

Permalink
Merge pull request #449 from JJ-Cro/RelNotes9_9_2024
Browse files Browse the repository at this point in the history
v2.13.3: feat(): Added new convert  and PMPro endpoints
  • Loading branch information
tiagosiebler authored Sep 9, 2024
2 parents 4493db5 + f1fca6b commit 55e6b0b
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 11 deletions.
5 changes: 5 additions & 0 deletions docs/endpointFunctionList.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ This table includes all endpoints from the official Exchange API docs and corres
| `getPortfolioMarginIndexPrice()` | | GET | `sapi/v1/portfolio/asset-index-price` |
| `getPortfolioMarginAssetLeverage()` | :closed_lock_with_key: | GET | `sapi/v1/portfolio/margin-asset-leverage` |
| `getPortfolioMarginProCollateralRate()` | | GET | `sapi/v1/portfolio/collateralRate` |
| `getPortfolioMarginProTieredCollateralRate()` | | GET | `sapi/v2/portfolio/collateralRate` |
| `getPortfolioMarginProAccountInfo()` | :closed_lock_with_key: | GET | `sapi/v1/portfolio/account` |
| `bnbTransfer()` | :closed_lock_with_key: | POST | `sapi/v1/portfolio/bnb-transfer` |
| `submitPortfolioMarginProFullTransfer()` | :closed_lock_with_key: | POST | `sapi/v1/portfolio/auto-collection` |
Expand Down Expand Up @@ -534,6 +535,10 @@ This table includes all endpoints from the official Exchange API docs and corres
| `setBNBBurnEnabled()` | :closed_lock_with_key: | POST | `fapi/v1/feeBurn` |
| `getBNBBurnStatus()` | :closed_lock_with_key: | GET | `fapi/v1/feeBurn` |
| `testOrder()` | :closed_lock_with_key: | POST | `fapi/v1/order/test` |
| `getAllConvertPairs()` | | GET | `fapi/v1/convert/exchangeInfo` |
| `submitConvertQuoteRequest()` | :closed_lock_with_key: | POST | `fapi/v1/convert/getQuote` |
| `acceptConvertQuote()` | :closed_lock_with_key: | POST | `fapi/v1/convert/acceptQuote` |
| `getConvertOrderStatus()` | :closed_lock_with_key: | GET | `fapi/v1/convert/orderStatus` |
| `getPortfolioMarginProAccountInfo()` | :closed_lock_with_key: | GET | `fapi/v1/pmAccountInfo` |
| `getBrokerIfNewFuturesUser()` | :closed_lock_with_key: | GET | `fapi/v1/apiReferral/ifNewUser` |
| `setBrokerCustomIdForClient()` | :closed_lock_with_key: | POST | `fapi/v1/apiReferral/customization` |
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.2",
"version": "2.13.3",
"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
16 changes: 10 additions & 6 deletions src/main-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3080,19 +3080,23 @@ export class MainClient extends BaseRestClient {
return this.getPrivate('sapi/v1/portfolio/margin-asset-leverage');
}

getPortfolioMarginProCollateralRate(): Promise<
GetPortfolioMarginProCollateralRateResponse[]
> {
return this.get('sapi/v1/portfolio/collateralRate');
}

getPortfolioMarginProTieredCollateralRate(): Promise<any[]> {
return this.get('sapi/v2/portfolio/collateralRate');
}

/**
*
* DERIVATIVES - Portfolio Margin Pro - Account
* This is in mainclient because it shares the same base url
*
**/

getPortfolioMarginProCollateralRate(): Promise<
GetPortfolioMarginProCollateralRateResponse[]
> {
return this.get('sapi/v1/portfolio/collateralRate');
}

getPortfolioMarginProAccountInfo(): Promise<GetPortfolioMarginProAccountInfoResponse> {
return this.getPrivate('sapi/v1/portfolio/account');
}
Expand Down
38 changes: 38 additions & 0 deletions src/types/futures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,3 +870,41 @@ export interface PortfolioMarginProAccountInfo {
asset: string;
maxWithdrawAmount: string; // This field will be ignored in the response
}

export interface FuturesConvertPair {
fromAsset: string;
toAsset: string;
fromAssetMinAmount: string;
fromAssetMaxAmount: string;
toAssetMinAmount: string;
toAssetMaxAmount: string;
}

export interface FuturesConvertQuoteRequest {
fromAsset: string;
toAsset: string;
fromAmount?: number;
toAmount?: number;
validTime?: '10s' | '30s' | '1m' | '2m';
}

export interface FuturesConvertQuote {
quoteId: string;
ratio: string;
inverseRatio: string;
validTimestamp: number;
toAmount: string;
fromAmount: string;
}

export interface FuturesConvertOrderStatus {
orderId: string;
orderStatus: 'PROCESS' | 'ACCEPT_SUCCESS' | 'SUCCESS' | 'FAIL';
fromAsset: string;
fromAmount: string;
toAsset: string;
toAmount: string;
ratio: string;
inverseRatio: string;
createTime: number;
}
39 changes: 37 additions & 2 deletions src/types/websockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export type WsMessageFuturesUserDataEventRaw =
| WsMessageFuturesUserDataMarginCallRaw
| WsMessageFuturesUserDataOrderTradeUpdateEventRaw
| WsMessageFuturesUserDataAccountConfigUpdateEventRaw
| WsMessageFuturesUserDataCondOrderTriggerRejectEventRaw;
| WsMessageFuturesUserDataCondOrderTriggerRejectEventRaw
| WsMessageFuturesUserDataTradeLiteEventRaw;

// TODO: consistent across USDM vs COINM?
export type WsMessageFuturesUserDataEventFormatted =
Expand All @@ -59,7 +60,8 @@ export type WsMessageFuturesUserDataEventFormatted =
| WsMessageFuturesUserDataMarginCallFormatted
| WsMessageFuturesUserDataTradeUpdateEventFormatted
| WsMessageFuturesUserDataAccountConfigUpdateEventFormatted
| WsMessageFuturesUserDataCondOrderTriggerRejectEventFormatted;
| WsMessageFuturesUserDataCondOrderTriggerRejectEventFormatted
| WsMessageFuturesUserDataTradeLiteEventFormatted;

export type WsRawMessage =
| WsMessageKlineRaw
Expand Down Expand Up @@ -755,6 +757,39 @@ export interface WsMessageFuturesUserDataOrderTradeUpdateEventRaw
ss: numberInString; // ignore
};
}
export interface WsMessageFuturesUserDataTradeLiteEventRaw
extends WsSharedBase {
e: 'TRADE_LITE'; // Event Type
E: number; // Event Time
T: number; // Transaction Time
s: string; // Symbol
q: string; // Original Quantity
p: string; // Original Price
m: boolean; // Is this trade the maker side?
c: string; // Client Order Id
S: 'BUY' | 'SELL'; // Side
L: string; // Last Filled Price
l: string; // Order Last Filled Quantity
t: number; // Trade Id
i: number; // Order Id
}

export interface WsMessageFuturesUserDataTradeLiteEventFormatted
extends WsSharedBase {
eventType: 'TRADE_LITE';
eventTime: number;
transactionTime: number;
symbol: string;
originalQuantity: number;
originalPrice: number;
isMakerSide: boolean;
clientOrderId: string;
side: 'BUY' | 'SELL';
lastFilledPrice: number;
lastFilledQuantity: number;
tradeId: number;
orderId: number;
}

export interface WsMessageFuturesUserDataTradeUpdateEventFormatted
extends WsSharedBase {
Expand Down
38 changes: 38 additions & 0 deletions src/usdm-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ import {
FuturesAccountConfig,
SymbolConfig,
UserForceOrder,
FuturesConvertPair,
FuturesConvertQuote,
FuturesConvertOrderStatus,
FuturesConvertQuoteRequest,
} from './types/futures';

import {
Expand Down Expand Up @@ -594,6 +598,40 @@ export class USDMClient extends BaseRestClient {
return this.postPrivate('fapi/v1/order/test', params);
}

/**
*
* Convert Endpoints
*
**/

getAllConvertPairs(params?: {
fromAsset?: string;
toAsset?: string;
}): Promise<FuturesConvertPair[]> {
return this.get('fapi/v1/convert/exchangeInfo', params);
}

submitConvertQuoteRequest(
params: FuturesConvertQuoteRequest,
): Promise<FuturesConvertQuote> {
return this.postPrivate('fapi/v1/convert/getQuote', params);
}

acceptConvertQuote(params: { quoteId: string }): Promise<{
orderId: string;
createTime: number;
orderStatus: 'PROCESS' | 'ACCEPT_SUCCESS' | 'SUCCESS' | 'FAIL';
}> {
return this.postPrivate('fapi/v1/convert/acceptQuote', params);
}

getConvertOrderStatus(params: {
orderId?: string;
quoteId?: string;
}): Promise<FuturesConvertOrderStatus> {
return this.getPrivate('fapi/v1/convert/orderStatus', params);
}

/**
*
* Portfolio Margin Pro Endpoints
Expand Down

0 comments on commit 55e6b0b

Please sign in to comment.