From 3a31d657d2bf90cc7196838a00eb55c02999bca3 Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Thu, 13 Jun 2024 11:16:15 +0100 Subject: [PATCH] chore(): minor refactoring on method names --- src/RestClient.ts | 72 +++++++++++++++++---------------- src/types/request/withdrawal.ts | 2 +- src/types/response/margin.ts | 2 +- 3 files changed, 40 insertions(+), 36 deletions(-) diff --git a/src/RestClient.ts b/src/RestClient.ts index d66a77a..03b8714 100644 --- a/src/RestClient.ts +++ b/src/RestClient.ts @@ -142,7 +142,7 @@ import { SubmitSubToSubTransferReq, SubmitTransferReq, } from './types/request/wallet.js'; -import { SubmitWithdrawReq } from './types/request/withdrawal.js'; +import { SubmitWithdrawalReq } from './types/request/withdrawal.js'; import { AccountDetail, StpGroup, @@ -210,9 +210,9 @@ import { CrossMarginAccount, CrossMarginAccountHistoryRecord, CrossMarginCurrency, + CrossMarginMorrowLoanRecord, MarginAccount, MarginBalanceHistoryRecord, - SubmitCrossMarginBorrowLoanResp, } from './types/response/margin.js'; import { LendingMarket, @@ -335,8 +335,8 @@ export class RestClient extends BaseRestClient { * @param params Withdrawal parameters * @returns Promise> */ - submitWithdraw( - params: SubmitWithdrawReq, + submitWithdrawal( + params: SubmitWithdrawalReq, ): Promise> { return this.postPrivate('/withdrawals', { query: params }); } @@ -1039,7 +1039,9 @@ export class RestClient extends BaseRestClient { * @param params Parameters for retrieving market Candles * @returns Promise> */ - getSpotCandle(params: GetSpotCandlesReq): Promise> { + getSpotCandles( + params: GetSpotCandlesReq, + ): Promise> { return this.get('/spot/Candles', params); } @@ -1176,7 +1178,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for cancelling all open orders in specified currency pair * @returns Promise> */ - deleteSpotPairOpenOrders(params: { + cancelSpotOpenOrders(params: { currency_pair: string; side?: 'buy' | 'sell'; account?: 'spot' | 'margin' | 'cross_margin' | 'unified'; @@ -1193,7 +1195,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for cancelling a batch of orders * @returns Promise> */ - deleteSpotBatchOrders( + batchCancelSpotOrders( params: CancelSpotBatchOrdersReq[], ): Promise> { return this.postPrivate('/spot/cancel_batch_orders', { body: params }); @@ -1244,7 +1246,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for cancelling a single order * @returns Promise> */ - deleteSpotOrder(params: DeleteSpotOrderReq): Promise> { + cancelSpotOrder(params: DeleteSpotOrderReq): Promise> { const { order_id, ...query } = params; return this.deletePrivate(`/spot/orders/${order_id}`, { query: query, @@ -1311,7 +1313,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for batch modification of orders * @returns Promise> */ - updateSpotBatchOrders( + batchUpdateSpotOrders( params: UpdateSpotBatchOrdersReq[], ): Promise> { return this.postPrivate('/spot/amend_batch_orders', { body: params }); @@ -1351,7 +1353,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for cancelling all open orders * @returns Promise> */ - deleteSpotAllOpenOrders(params?: { + cancelAllOpenSpotOrders(params?: { market?: string; account?: 'normal' | 'margin' | 'cross_margin'; }): Promise> { @@ -1376,7 +1378,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for cancelling a price-triggered order * @returns Promise> */ - deleteSpotPriceTriggeredOrder(params: { + cancelSpotTriggeredOrder(params: { order_id: string; }): Promise> { return this.deletePrivate(`/spot/price_orders/${params.order_id}`); @@ -1537,7 +1539,7 @@ export class RestClient extends BaseRestClient { */ submitCrossMarginBorrowLoan( params: SubmitCrossMarginBorrowLoanReq, - ): Promise> { + ): Promise> { return this.postPrivate('/margin/cross/loans', { body: params }); } @@ -1551,7 +1553,7 @@ export class RestClient extends BaseRestClient { */ getCrossMarginBorrowHistory( params: GetCrossMarginBorrowHistoryReq, - ): Promise> { + ): Promise> { return this.getPrivate('/margin/cross/loans', params); } @@ -1563,7 +1565,7 @@ export class RestClient extends BaseRestClient { */ getCrossMarginBorrowLoan(params: { loan_id: string; - }): Promise> { + }): Promise> { return this.getPrivate(`/margin/cross/loans/${params.loan_id}`); } /** @@ -1577,7 +1579,7 @@ export class RestClient extends BaseRestClient { submitCrossMarginRepayment(params: { currency: string; amount: string; - }): Promise> { + }): Promise> { return this.postPrivate('/margin/cross/repayments', { body: params }); } @@ -1917,7 +1919,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for retrieving premium index K-Line * @returns Promise> */ - getPremiumIndexKLine( + getPremiumIndexKLines( params: GetFuturesCandlesReq, ): Promise> { const { settle, ...query } = params; @@ -1972,7 +1974,7 @@ export class RestClient extends BaseRestClient { * b: string; * }[]>> */ - getFuturesInsuranceBalance(params: { + getFuturesInsuranceBalanceHistory(params: { settle: 'btc' | 'usdt' | 'usd'; limit?: number; }): Promise< @@ -2282,7 +2284,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for cancelling all open orders matched * @returns Promise> */ - deleteAllFuturesOrders( + cancelAllFuturesOrders( params: DeleteAllFuturesOrdersReq, ): Promise> { const { settle, ...query } = params; @@ -2352,7 +2354,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for cancelling a single order * @returns Promise> */ - deleteFuturesOrder(params: { + cancelFuturesOrder(params: { settle: 'btc' | 'usdt' | 'usd'; order_id: string; }): Promise> { @@ -2440,7 +2442,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for setting countdown cancel orders * @returns Promise> */ - deleteFuturesOrdersCountdown(params: { + setFuturesOrderCancelCountdown(params: { settle: 'btc' | 'usdt' | 'usd'; timeout: number; contract?: string; @@ -2473,13 +2475,13 @@ export class RestClient extends BaseRestClient { * @param params Parameters for cancelling a batch of orders with an ID list * @returns Promise> */ - deleteFuturesBatchOrders(params: { + batchCancelFuturesOrders(params: { settle: 'btc' | 'usdt' | 'usd'; - body: string[]; + orderIds: string[]; }): Promise> { - const { settle, ...body } = params; + const { settle, ...orderIds } = params; return this.postPrivate(`/futures/${settle}/batch_cancel_orders`, { - body: body, + body: orderIds, }); } @@ -2515,7 +2517,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for cancelling all open orders * @returns Promise> */ - deleteFuturesAllOpenOrders(params: { + cancelAllOpenFuturesOrders(params: { settle: 'btc' | 'usdt' | 'usd'; contract: string; }): Promise> { @@ -2546,7 +2548,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for cancelling a price-triggered order * @returns Promise> */ - deleteFuturesPriceTriggeredOrder(params: { + cancelFuturesPriceTriggeredOrder(params: { settle: 'btc' | 'usdt' | 'usd'; order_id: string; }): Promise> { @@ -2811,7 +2813,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for cancelling all open orders matched * @returns Promise> */ - deleteAllDeliveryOrders(params: { + cancelAllDeliveryOrders(params: { settle: 'usdt'; contract: string; side?: 'ask' | 'bid'; @@ -2845,7 +2847,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for cancelling a single order * @returns Promise> */ - deleteDeliveryOrder(params: { + cancelDeliveryOrder(params: { settle: 'usdt'; order_id: string; }): Promise> { @@ -2940,7 +2942,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for cancelling all open orders * @returns Promise> */ - deleteDeliveryOrders(params: { + cancelAllOpenDeliveryOrders(params: { settle: 'usdt'; contract: string; }): Promise> { @@ -2971,7 +2973,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for cancelling a price-triggered order * @returns Promise> */ - deleteDeliveryTriggeredOrder(params: { + cancelTriggeredDeliveryOrder(params: { settle: 'usdt'; order_id: string; }): Promise> { @@ -3242,7 +3244,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for canceling all open orders matched * @returns Promise> */ - deleteOptionsOrders(params: { + cancelAllOpenOptionsOrders(params: { contract?: string; underlying?: string; side?: 'ask' | 'bid'; @@ -3268,7 +3270,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for canceling a single order * @returns Promise> */ - deleteOptionsOrder(params: { + cancelOptionsOrder(params: { order_id: number; }): Promise> { return this.deletePrivate(`/options/orders/${params.order_id}`); @@ -3318,7 +3320,9 @@ export class RestClient extends BaseRestClient { * @param params Parameters for lending or redeeming * @returns Promise> */ - submitLendOrRedeem(params: SubmitLendOrRedeemReq): Promise> { + submitLendOrRedeemOrder( + params: SubmitLendOrRedeemReq, + ): Promise> { return this.postPrivate(`/earn/uni/lends`, { body: params }); } @@ -3753,7 +3757,7 @@ export class RestClient extends BaseRestClient { * @param params Parameters for listing structured products * @returns Promise> */ - getStructuredProductList( + getStructuredProducts( params: GetStructuredProductListReq, ): Promise> { return this.get(`/earn/structured/products`, params); diff --git a/src/types/request/withdrawal.ts b/src/types/request/withdrawal.ts index ffbc1ca..587801c 100644 --- a/src/types/request/withdrawal.ts +++ b/src/types/request/withdrawal.ts @@ -3,7 +3,7 @@ * ========================================================================================================================== */ -export interface SubmitWithdrawReq { +export interface SubmitWithdrawalReq { amount: string; currency: string; chain: string; diff --git a/src/types/response/margin.ts b/src/types/response/margin.ts index 60dae54..30d1419 100644 --- a/src/types/response/margin.ts +++ b/src/types/response/margin.ts @@ -88,7 +88,7 @@ export interface CrossMarginAccountHistoryRecord { type: string; } -export interface SubmitCrossMarginBorrowLoanResp { +export interface CrossMarginMorrowLoanRecord { id: string; create_time: number; update_time: number;