From 7460cf4b5cefb078f80a9efee3a55ebe33fcc1d5 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Mon, 30 Oct 2023 12:22:04 +0000 Subject: [PATCH] feat(): add deprecation warnings for v1/v2 REST clients --- src/account-asset-client.ts | 30 +++++++------ src/inverse-client.ts | 68 +++++++++++++++------------- src/inverse-futures-client.ts | 36 ++++++++------- src/linear-client.ts | 84 ++++++++++++++++++----------------- src/spot-client.ts | 17 ++++--- src/usdc-option-client.ts | 84 ++++++++++++++++++----------------- src/usdc-perpetual-client.ts | 70 +++++++++++++++-------------- 7 files changed, 208 insertions(+), 181 deletions(-) diff --git a/src/account-asset-client.ts b/src/account-asset-client.ts index ccdf57c..cd30af0 100644 --- a/src/account-asset-client.ts +++ b/src/account-asset-client.ts @@ -17,6 +17,10 @@ import BaseRestClient from './util/BaseRestClient'; /** * REST API client for Account Asset APIs + * + * @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet + * will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability. + * Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP. */ export class AccountAssetClient extends BaseRestClient { getClientType() { @@ -35,29 +39,29 @@ export class AccountAssetClient extends BaseRestClient { */ createInternalTransfer( - params: InternalTransferRequest + params: InternalTransferRequest, ): Promise> { return this.postPrivate('/asset/v1/private/transfer', params); } createSubAccountTransfer( - params: SubAccountTransferRequest + params: SubAccountTransferRequest, ): Promise> { return this.postPrivate('/asset/v1/private/sub-member/transfer', params); } getInternalTransfers( - params?: TransferQueryRequest + params?: TransferQueryRequest, ): Promise> { return this.getPrivate('/asset/v1/private/transfer/list', params); } getSubAccountTransfers( - params?: TransferQueryRequest + params?: TransferQueryRequest, ): Promise> { return this.getPrivate( '/asset/v1/private/sub-member/transfer/list', - params + params, ); } @@ -66,19 +70,19 @@ export class AccountAssetClient extends BaseRestClient { } enableUniversalTransfer( - params?: EnableUniversalTransferRequest + params?: EnableUniversalTransferRequest, ): Promise> { return this.postPrivate('/asset/v1/private/transferable-subs/save', params); } createUniversalTransfer( - params: UniversalTransferRequest + params: UniversalTransferRequest, ): Promise> { return this.postPrivate('/asset/v1/private/universal/transfer', params); } getUniversalTransfers( - params?: TransferQueryRequest + params?: TransferQueryRequest, ): Promise> { return this.getPrivate('/asset/v1/private/universal/transfer/list', params); } @@ -90,19 +94,19 @@ export class AccountAssetClient extends BaseRestClient { */ getSupportedDepositList( - params?: SupportedDepositListRequest + params?: SupportedDepositListRequest, ): Promise> { return this.get('/asset/v1/public/deposit/allowed-deposit-list', params); } getDepositRecords( - params?: DepositRecordsRequest + params?: DepositRecordsRequest, ): Promise> { return this.getPrivate('/asset/v1/private/deposit/record/query', params); } getWithdrawRecords( - params?: WithdrawalRecordsRequest + params?: WithdrawalRecordsRequest, ): Promise> { return this.getPrivate('/asset/v1/private/withdraw/record/query', params); } @@ -112,13 +116,13 @@ export class AccountAssetClient extends BaseRestClient { } getAssetInformation( - params?: AccountAssetInformationRequest + params?: AccountAssetInformationRequest, ): Promise> { return this.getPrivate('/asset/v1/private/asset-info/query', params); } submitWithdrawal( - params: WithdrawalRequest + params: WithdrawalRequest, ): Promise> { return this.postPrivate('/asset/v1/private/withdraw', params); } diff --git a/src/inverse-client.ts b/src/inverse-client.ts index abe8d47..b860e17 100644 --- a/src/inverse-client.ts +++ b/src/inverse-client.ts @@ -32,6 +32,10 @@ import BaseRestClient from './util/BaseRestClient'; /** * REST API client for Inverse Perpetual Futures APIs (v2) + * + * @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet + * will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability. + * Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP. */ export class InverseClient extends BaseRestClient { getClientType() { @@ -54,7 +58,7 @@ export class InverseClient extends BaseRestClient { } getKline( - params: SymbolIntervalFromLimitParam + params: SymbolIntervalFromLimitParam, ): Promise> { return this.get('v2/public/kline/list', params); } @@ -63,7 +67,7 @@ export class InverseClient extends BaseRestClient { * Get latest information for symbol */ getTickers( - params?: Partial + params?: Partial, ): Promise> { return this.get('v2/public/tickers', params); } @@ -77,19 +81,19 @@ export class InverseClient extends BaseRestClient { } getMarkPriceKline( - params: SymbolIntervalFromLimitParam + params: SymbolIntervalFromLimitParam, ): Promise> { return this.get('v2/public/mark-price-kline', params); } getIndexPriceKline( - params: SymbolIntervalFromLimitParam + params: SymbolIntervalFromLimitParam, ): Promise> { return this.get('v2/public/index-price-kline', params); } getPremiumIndexKline( - params: SymbolIntervalFromLimitParam + params: SymbolIntervalFromLimitParam, ): Promise> { return this.get('v2/public/premium-index-kline', params); } @@ -101,19 +105,19 @@ export class InverseClient extends BaseRestClient { */ getOpenInterest( - params: SymbolPeriodLimitParam + params: SymbolPeriodLimitParam, ): Promise> { return this.get('v2/public/open-interest', params); } getLatestBigDeal( - params: SymbolLimitParam + params: SymbolLimitParam, ): Promise> { return this.get('v2/public/big-deal', params); } getLongShortRatio( - params: SymbolPeriodLimitParam + params: SymbolPeriodLimitParam, ): Promise> { return this.get('v2/public/account-ratio', params); } @@ -135,25 +139,25 @@ export class InverseClient extends BaseRestClient { */ getWalletBalance( - params?: Partial + params?: Partial, ): Promise> { return this.getPrivate('v2/private/wallet/balance', params); } getWalletFundRecords( - params?: WalletFundRecordsReq + params?: WalletFundRecordsReq, ): Promise> { return this.getPrivate('v2/private/wallet/fund/records', params); } getWithdrawRecords( - params?: WithdrawRecordsReq + params?: WithdrawRecordsReq, ): Promise> { return this.getPrivate('v2/private/wallet/withdraw/list', params); } getAssetExchangeRecords( - params?: AssetExchangeRecordsReq + params?: AssetExchangeRecordsReq, ): Promise> { return this.getPrivate('v2/private/exchange-order/list', params); } @@ -183,37 +187,37 @@ export class InverseClient extends BaseRestClient { */ placeActiveOrder( - orderRequest: InverseOrderRequest + orderRequest: InverseOrderRequest, ): Promise> { return this.postPrivate('v2/private/order/create', orderRequest); } getActiveOrderList( - params: InverseActiveOrdersRequest + params: InverseActiveOrdersRequest, ): Promise> { return this.getPrivate('v2/private/order/list', params); } cancelActiveOrder( - params: InverseCancelOrderRequest + params: InverseCancelOrderRequest, ): Promise> { return this.postPrivate('v2/private/order/cancel', params); } cancelAllActiveOrders( - params: SymbolParam + params: SymbolParam, ): Promise> { return this.postPrivate('v2/private/order/cancelAll', params); } replaceActiveOrder( - params: InverseReplaceOrderRequest + params: InverseReplaceOrderRequest, ): Promise> { return this.postPrivate('v2/private/order/replace', params); } queryActiveOrder( - params: InverseGetOrderRequest + params: InverseGetOrderRequest, ): Promise> { return this.getPrivate('v2/private/order', params); } @@ -223,38 +227,38 @@ export class InverseClient extends BaseRestClient { */ placeConditionalOrder( - params: InverseConditionalOrderRequest + params: InverseConditionalOrderRequest, ): Promise> { return this.postPrivate('v2/private/stop-order/create', params); } /** get conditional order list. This may see delays, use queryConditionalOrder() for real-time queries */ getConditionalOrder( - params: InverseActiveConditionalOrderRequest + params: InverseActiveConditionalOrderRequest, ): Promise> { return this.getPrivate('v2/private/stop-order/list', params); } cancelConditionalOrder( - params: InverseCancelConditionalOrderRequest + params: InverseCancelConditionalOrderRequest, ): Promise> { return this.postPrivate('v2/private/stop-order/cancel', params); } cancelAllConditionalOrders( - params: SymbolParam + params: SymbolParam, ): Promise> { return this.postPrivate('v2/private/stop-order/cancelAll', params); } replaceConditionalOrder( - params: InverseReplaceConditionalOrderRequest + params: InverseReplaceConditionalOrderRequest, ): Promise> { return this.postPrivate('v2/private/stop-order/replace', params); } queryConditionalOrder( - params: InverseGetOrderRequest + params: InverseGetOrderRequest, ): Promise> { return this.getPrivate('v2/private/stop-order', params); } @@ -264,49 +268,49 @@ export class InverseClient extends BaseRestClient { */ getPosition( - params?: Partial + params?: Partial, ): Promise> { return this.getPrivate('v2/private/position/list', params); } changePositionMargin( - params: InverseChangePositionMarginRequest + params: InverseChangePositionMarginRequest, ): Promise> { return this.postPrivate('position/change-position-margin', params); } setTradingStop( - params: InverseSetTradingStopRequest + params: InverseSetTradingStopRequest, ): Promise> { return this.postPrivate('v2/private/position/trading-stop', params); } setUserLeverage( - params: InverseSetLeverageRequest + params: InverseSetLeverageRequest, ): Promise> { return this.postPrivate('v2/private/position/leverage/save', params); } getTradeRecords( - params: InverseGetTradeRecordsRequest + params: InverseGetTradeRecordsRequest, ): Promise> { return this.getPrivate('v2/private/execution/list', params); } getClosedPnl( - params: InverseGetClosedPnlRequest + params: InverseGetClosedPnlRequest, ): Promise> { return this.getPrivate('v2/private/trade/closed-pnl/list', params); } setSlTpPositionMode( - params: InverseSetSlTpPositionModeRequest + params: InverseSetSlTpPositionModeRequest, ): Promise> { return this.postPrivate('v2/private/tpsl/switch-mode', params); } setMarginType( - params: InverseSetMarginTypeRequest + params: InverseSetMarginTypeRequest, ): Promise> { return this.postPrivate('v2/private/position/switch-isolated', params); } diff --git a/src/inverse-futures-client.ts b/src/inverse-futures-client.ts index 8fecd14..eb8646b 100644 --- a/src/inverse-futures-client.ts +++ b/src/inverse-futures-client.ts @@ -16,6 +16,10 @@ import BaseRestClient from './util/BaseRestClient'; /** * REST API client for Inverse Futures APIs (e.g. quarterly futures) (v2) + * + * @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet + * will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability. + * Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP. */ export class InverseFuturesClient extends BaseRestClient { getClientType() { @@ -38,7 +42,7 @@ export class InverseFuturesClient extends BaseRestClient { } getKline( - params: SymbolIntervalFromLimitParam + params: SymbolIntervalFromLimitParam, ): Promise> { return this.get('v2/public/kline/list', params); } @@ -47,7 +51,7 @@ export class InverseFuturesClient extends BaseRestClient { * Get latest information for symbol */ getTickers( - params?: Partial + params?: Partial, ): Promise> { return this.get('v2/public/tickers', params); } @@ -64,19 +68,19 @@ export class InverseFuturesClient extends BaseRestClient { } getMarkPriceKline( - params: SymbolIntervalFromLimitParam + params: SymbolIntervalFromLimitParam, ): Promise> { return this.get('v2/public/mark-price-kline', params); } getIndexPriceKline( - params: SymbolIntervalFromLimitParam + params: SymbolIntervalFromLimitParam, ): Promise> { return this.get('v2/public/index-price-kline', params); } getPremiumIndexKline( - params: SymbolIntervalFromLimitParam + params: SymbolIntervalFromLimitParam, ): Promise> { return this.get('v2/public/premium-index-kline', params); } @@ -88,19 +92,19 @@ export class InverseFuturesClient extends BaseRestClient { */ getOpenInterest( - params: SymbolPeriodLimitParam + params: SymbolPeriodLimitParam, ): Promise> { return this.get('v2/public/open-interest', params); } getLatestBigDeal( - params: SymbolLimitParam + params: SymbolLimitParam, ): Promise> { return this.get('v2/public/big-deal', params); } getLongShortRatio( - params: SymbolPeriodLimitParam + params: SymbolPeriodLimitParam, ): Promise> { return this.get('v2/public/account-ratio', params); } @@ -122,25 +126,25 @@ export class InverseFuturesClient extends BaseRestClient { */ getWalletBalance( - params?: Partial + params?: Partial, ): Promise> { return this.getPrivate('v2/private/wallet/balance', params); } getWalletFundRecords( - params?: WalletFundRecordsReq + params?: WalletFundRecordsReq, ): Promise> { return this.getPrivate('v2/private/wallet/fund/records', params); } getWithdrawRecords( - params?: WithdrawRecordsReq + params?: WithdrawRecordsReq, ): Promise> { return this.getPrivate('v2/private/wallet/withdraw/list', params); } getAssetExchangeRecords( - params?: AssetExchangeRecordsReq + params?: AssetExchangeRecordsReq, ): Promise> { return this.getPrivate('v2/private/exchange-order/list', params); } @@ -204,7 +208,7 @@ export class InverseFuturesClient extends BaseRestClient { } cancelAllActiveOrders( - params: SymbolParam + params: SymbolParam, ): Promise> { return this.postPrivate('futures/private/order/cancelAll', params); } @@ -266,7 +270,7 @@ export class InverseFuturesClient extends BaseRestClient { } cancelAllConditionalOrders( - params: SymbolParam + params: SymbolParam, ): Promise> { return this.postPrivate('futures/private/stop-order/cancelAll', params); } @@ -298,7 +302,7 @@ export class InverseFuturesClient extends BaseRestClient { * Get position list */ getPosition( - params?: Partial + params?: Partial, ): Promise> { return this.getPrivate('futures/private/position/list', params); } @@ -309,7 +313,7 @@ export class InverseFuturesClient extends BaseRestClient { }): Promise> { return this.postPrivate( 'futures/private/position/change-position-margin', - params + params, ); } diff --git a/src/linear-client.ts b/src/linear-client.ts index 4ab0086..2e6a637 100644 --- a/src/linear-client.ts +++ b/src/linear-client.ts @@ -42,6 +42,10 @@ import BaseRestClient from './util/BaseRestClient'; /** * REST API client for linear/USD perpetual futures APIs (v2) + * + * @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet + * will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability. + * Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP. */ export class LinearClient extends BaseRestClient { getClientType() { @@ -64,7 +68,7 @@ export class LinearClient extends BaseRestClient { } getKline( - params: SymbolIntervalFromLimitParam + params: SymbolIntervalFromLimitParam, ): Promise> { return this.get('public/linear/kline', params); } @@ -73,7 +77,7 @@ export class LinearClient extends BaseRestClient { * Get latest information for symbol */ getTickers( - params?: Partial + params?: Partial, ): Promise> { return this.get('v2/public/tickers', params); } @@ -91,19 +95,19 @@ export class LinearClient extends BaseRestClient { } getMarkPriceKline( - params: SymbolIntervalFromLimitParam + params: SymbolIntervalFromLimitParam, ): Promise> { return this.get('public/linear/mark-price-kline', params); } getIndexPriceKline( - params: SymbolIntervalFromLimitParam + params: SymbolIntervalFromLimitParam, ): Promise> { return this.get('public/linear/index-price-kline', params); } getPremiumIndexKline( - params: SymbolIntervalFromLimitParam + params: SymbolIntervalFromLimitParam, ): Promise> { return this.get('public/linear/premium-index-kline', params); } @@ -115,19 +119,19 @@ export class LinearClient extends BaseRestClient { */ getOpenInterest( - params: SymbolPeriodLimitParam + params: SymbolPeriodLimitParam, ): Promise> { return this.get('v2/public/open-interest', params); } getLatestBigDeal( - params: SymbolLimitParam + params: SymbolLimitParam, ): Promise> { return this.get('v2/public/big-deal', params); } getLongShortRatio( - params: SymbolPeriodLimitParam + params: SymbolPeriodLimitParam, ): Promise> { return this.get('v2/public/account-ratio', params); } @@ -149,25 +153,25 @@ export class LinearClient extends BaseRestClient { */ getWalletBalance( - params?: Partial + params?: Partial, ): Promise> { return this.getPrivate('v2/private/wallet/balance', params); } getWalletFundRecords( - params?: WalletFundRecordsReq + params?: WalletFundRecordsReq, ): Promise> { return this.getPrivate('v2/private/wallet/fund/records', params); } getWithdrawRecords( - params?: WithdrawRecordsReq + params?: WithdrawRecordsReq, ): Promise> { return this.getPrivate('v2/private/wallet/withdraw/list', params); } getAssetExchangeRecords( - params?: AssetExchangeRecordsReq + params?: AssetExchangeRecordsReq, ): Promise> { return this.getPrivate('v2/private/exchange-order/list', params); } @@ -193,37 +197,37 @@ export class LinearClient extends BaseRestClient { */ placeActiveOrder( - params: NewLinearOrder + params: NewLinearOrder, ): Promise> { return this.postPrivate('private/linear/order/create', params); } getActiveOrderList( - params: LinearGetOrdersRequest + params: LinearGetOrdersRequest, ): Promise> { return this.getPrivate('private/linear/order/list', params); } cancelActiveOrder( - params: LinearCancelOrderRequest + params: LinearCancelOrderRequest, ): Promise> { return this.postPrivate('private/linear/order/cancel', params); } cancelAllActiveOrders( - params: SymbolParam + params: SymbolParam, ): Promise> { return this.postPrivate('private/linear/order/cancel-all', params); } replaceActiveOrder( - params: LinearReplaceOrderRequest + params: LinearReplaceOrderRequest, ): Promise> { return this.postPrivate('private/linear/order/replace', params); } queryActiveOrder( - params: LinearGetOrderRequest + params: LinearGetOrderRequest, ): Promise> { return this.getPrivate('private/linear/order/search', params); } @@ -233,37 +237,37 @@ export class LinearClient extends BaseRestClient { */ placeConditionalOrder( - params: LinearConditionalOrderRequest + params: LinearConditionalOrderRequest, ): Promise> { return this.postPrivate('private/linear/stop-order/create', params); } getConditionalOrder( - params: LinearGetConditionalOrderRequest + params: LinearGetConditionalOrderRequest, ): Promise> { return this.getPrivate('private/linear/stop-order/list', params); } cancelConditionalOrder( - params: LinearCancelConditionalOrderRequest + params: LinearCancelConditionalOrderRequest, ): Promise> { return this.postPrivate('private/linear/stop-order/cancel', params); } cancelAllConditionalOrders( - params: SymbolParam + params: SymbolParam, ): Promise> { return this.postPrivate('private/linear/stop-order/cancel-all', params); } replaceConditionalOrder( - params: LinearReplaceConditionalOrderRequest + params: LinearReplaceConditionalOrderRequest, ): Promise> { return this.postPrivate('private/linear/stop-order/replace', params); } queryConditionalOrder( - params: LinearQueryConditionalOrderRequest + params: LinearQueryConditionalOrderRequest, ): Promise> { return this.getPrivate('private/linear/stop-order/search', params); } @@ -275,26 +279,26 @@ export class LinearClient extends BaseRestClient { getPosition(): Promise>; getPosition( - params: Partial + params: Partial, ): Promise>; getPosition( - params?: Partial + params?: Partial, ): Promise> { return this.getPrivate('private/linear/position/list', params); } setAutoAddMargin( - params?: LinearSetAutoAddMarginRequest + params?: LinearSetAutoAddMarginRequest, ): Promise> { return this.postPrivate( 'private/linear/position/set-auto-add-margin', - params + params, ); } setMarginSwitch( - params?: LinearSetMarginSwitchRequest + params?: LinearSetMarginSwitchRequest, ): Promise> { return this.postPrivate('private/linear/position/switch-isolated', params); } @@ -303,7 +307,7 @@ export class LinearClient extends BaseRestClient { * Switch between one-way vs hedge mode. Use `linearPositionModeEnum` for the mode parameter. */ setPositionMode( - params: LinearSetPositionModeRequest + params: LinearSetPositionModeRequest, ): Promise> { return this.postPrivate('private/linear/position/switch-mode', params); } @@ -313,46 +317,46 @@ export class LinearClient extends BaseRestClient { * This is set with the setTradingStop() method. Use `positionTpSlModeEnum` for the tp_sl_mode parameter. */ setPositionTpSlMode( - params: LinearSetPositionTpSlModeRequest + params: LinearSetPositionTpSlModeRequest, ): Promise> { return this.postPrivate('private/linear/tpsl/switch-mode', params); } setAddReduceMargin( - params?: LinearSetAddReduceMarginRequest + params?: LinearSetAddReduceMarginRequest, ): Promise> { return this.postPrivate('private/linear/position/add-margin', params); } setUserLeverage( - params: LinearSetUserLeverageRequest + params: LinearSetUserLeverageRequest, ): Promise> { return this.postPrivate('private/linear/position/set-leverage', params); } setTradingStop( - params: LinearSetTradingStopRequest + params: LinearSetTradingStopRequest, ): Promise> { return this.postPrivate('private/linear/position/trading-stop', params); } getTradeRecords( - params: LinearGetTradeRecordsRequest + params: LinearGetTradeRecordsRequest, ): Promise> { return this.getPrivate('private/linear/trade/execution/list', params); } getHistoryTradeRecords( - params: LinearGetHistoryTradeRecordsRequest + params: LinearGetHistoryTradeRecordsRequest, ): Promise> { return this.getPrivate( '/private/linear/trade/execution/history-list', - params + params, ); } getClosedPnl( - params: LinearGetClosedPnlRequest + params: LinearGetClosedPnlRequest, ): Promise> { return this.getPrivate('private/linear/trade/closed-pnl/list', params); } @@ -366,7 +370,7 @@ export class LinearClient extends BaseRestClient { } setRiskLimit( - params: LinearSetRiskLimitRequest + params: LinearSetRiskLimitRequest, ): Promise> { return this.postPrivate('private/linear/position/set-risk', params); } @@ -376,7 +380,7 @@ export class LinearClient extends BaseRestClient { */ getPredictedFundingFee( - params: SymbolParam + params: SymbolParam, ): Promise> { return this.getPrivate('private/linear/funding/predicted-funding', params); } diff --git a/src/spot-client.ts b/src/spot-client.ts index 5860433..c18ae0c 100644 --- a/src/spot-client.ts +++ b/src/spot-client.ts @@ -14,8 +14,11 @@ import BaseRestClient from './util/BaseRestClient'; import { REST_CLIENT_TYPE_ENUM } from './util/requestUtils'; /** - * @deprecated Use SpotV3Client instead, which leverages the newer v3 APIs * REST API client for Spot APIs (v1) + * + * @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet + * will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability. + * Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP. */ export class SpotClient extends BaseRestClient { getClientType() { @@ -51,7 +54,7 @@ export class SpotClient extends BaseRestClient { getMergedOrderBook( symbol: string, scale?: number, - limit?: number + limit?: number, ): Promise> { return this.get('/spot/quote/v1/depth/merged', { symbol, @@ -72,7 +75,7 @@ export class SpotClient extends BaseRestClient { interval: KlineInterval, limit?: number, startTime?: number, - endTime?: number + endTime?: number, ): Promise> { return this.get('/spot/quote/v1/kline', { symbol, @@ -92,7 +95,7 @@ export class SpotClient extends BaseRestClient { getLastTradedPrice(symbol: string): Promise>; getLastTradedPrice( - symbol?: string + symbol?: string, ): Promise> { return this.get('/spot/quote/v1/ticker/price', { symbol }); } @@ -135,7 +138,7 @@ export class SpotClient extends BaseRestClient { getOpenOrders( symbol?: string, orderId?: string, - limit?: number + limit?: number, ): Promise> { return this.getPrivate('/spot/v1/open-orders', { symbol, @@ -147,7 +150,7 @@ export class SpotClient extends BaseRestClient { getPastOrders( symbol?: string, orderId?: string, - limit?: number + limit?: number, ): Promise> { return this.getPrivate('/spot/v1/history-orders', { symbol, @@ -160,7 +163,7 @@ export class SpotClient extends BaseRestClient { symbol?: string, limit?: number, fromId?: number, - toId?: number + toId?: number, ): Promise> { return this.getPrivate('/spot/v1/myTrades', { symbol, diff --git a/src/usdc-option-client.ts b/src/usdc-option-client.ts index ea6d3cf..8db52e7 100644 --- a/src/usdc-option-client.ts +++ b/src/usdc-option-client.ts @@ -25,6 +25,10 @@ import BaseRestClient from './util/BaseRestClient'; /** * REST API client for USDC Option APIs + * + * @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet + * will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability. + * Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP. */ export class USDCOptionClient extends BaseRestClient { getClientType() { @@ -49,7 +53,7 @@ export class USDCOptionClient extends BaseRestClient { /** Fetch trading rules (such as min/max qty). Query for all if blank. */ getContractInfo( - params?: USDCOptionsContractInfoRequest + params?: USDCOptionsContractInfoRequest, ): Promise> { return this.get('/option/usdc/openapi/public/v1/symbols', params); } @@ -61,18 +65,18 @@ export class USDCOptionClient extends BaseRestClient { /** Get delivery information */ getDeliveryPrice( - params?: USDCOptionsDeliveryPriceRequest + params?: USDCOptionsDeliveryPriceRequest, ): Promise> { return this.get('/option/usdc/openapi/public/v1/delivery-price', params); } /** Returned records are Taker Buy in default. */ getLast500Trades( - params: USDCOptionsRecentTradesRequest + params: USDCOptionsRecentTradesRequest, ): Promise> { return this.get( '/option/usdc/openapi/public/v1/query-trade-latest', - params + params, ); } @@ -84,11 +88,11 @@ export class USDCOptionClient extends BaseRestClient { * Both startTime & endTime entered together or both are left blank */ getHistoricalVolatility( - params?: USDCOptionsHistoricalVolatilityRequest + params?: USDCOptionsHistoricalVolatilityRequest, ): Promise> { return this.get( '/option/usdc/openapi/public/v1/query-historical-volatility', - params + params, ); } @@ -108,7 +112,7 @@ export class USDCOptionClient extends BaseRestClient { submitOrder(params: USDCOptionsOrderRequest): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/place-order', - params + params, ); } @@ -116,91 +120,91 @@ export class USDCOptionClient extends BaseRestClient { * Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request. */ batchSubmitOrders( - orderRequest: USDCOptionsOrderRequest[] + orderRequest: USDCOptionsOrderRequest[], ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/batch-place-orders', - { orderRequest } + { orderRequest }, ); } /** For Options, at least one of the three parameters — price, quantity or implied volatility — must be input. */ modifyOrder( - params: USDCOptionsModifyOrderRequest + params: USDCOptionsModifyOrderRequest, ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/replace-order', - params + params, ); } /** Each request supports a max. of four orders. The reduceOnly parameter should be separate and unique for each order in the request. */ batchModifyOrders( - replaceOrderRequest: USDCOptionsModifyOrderRequest[] + replaceOrderRequest: USDCOptionsModifyOrderRequest[], ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/batch-replace-orders', - { replaceOrderRequest } + { replaceOrderRequest }, ); } /** Cancel order */ cancelOrder( - params: USDCOptionsCancelOrderRequest + params: USDCOptionsCancelOrderRequest, ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/cancel-order', - params + params, ); } /** Batch cancel orders */ batchCancelOrders( - cancelRequest: USDCOptionsCancelOrderRequest[] + cancelRequest: USDCOptionsCancelOrderRequest[], ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/batch-cancel-orders', - { cancelRequest } + { cancelRequest }, ); } /** This is used to cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */ cancelActiveOrders( - params?: USDCOptionsCancelAllOrdersRequest + params?: USDCOptionsCancelAllOrdersRequest, ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/cancel-all', - params + params, ); } /** Query Unfilled/Partially Filled Orders(real-time), up to last 7 days of partially filled/unfilled orders */ getActiveRealtimeOrders( - params?: USDCOptionsActiveOrdersRealtimeRequest + params?: USDCOptionsActiveOrdersRealtimeRequest, ): Promise> { return this.getPrivate( '/option/usdc/openapi/private/v1/trade/query-active-orders', - params + params, ); } /** Query Unfilled/Partially Filled Orders */ getActiveOrders( - params: USDCOptionsActiveOrdersRequest + params: USDCOptionsActiveOrdersRequest, ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/query-active-orders', - params + params, ); } /** Query order history. The endpoint only supports up to 30 days of queried records */ getHistoricOrders( - params: USDCOptionsHistoricOrdersRequest + params: USDCOptionsHistoricOrdersRequest, ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/query-order-history', - params + params, ); } @@ -210,11 +214,11 @@ export class USDCOptionClient extends BaseRestClient { * An error will be returned if startTime is more than 30 days. */ getOrderExecutionHistory( - params: USDCOptionsOrderExecutionRequest + params: USDCOptionsOrderExecutionRequest, ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/execution-list', - params + params, ); } @@ -222,18 +226,18 @@ export class USDCOptionClient extends BaseRestClient { /** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */ getTransactionLog( - params: USDCTransactionLogRequest + params: USDCTransactionLogRequest, ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/query-transaction-log', - params + params, ); } /** Wallet info for USDC account. */ getBalances(): Promise> { return this.postPrivate( - '/option/usdc/openapi/private/v1/query-wallet-balance' + '/option/usdc/openapi/private/v1/query-wallet-balance', ); } @@ -241,7 +245,7 @@ export class USDCOptionClient extends BaseRestClient { getAssetInfo(baseCoin?: string): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/query-asset-info', - { baseCoin } + { baseCoin }, ); } @@ -252,18 +256,18 @@ export class USDCOptionClient extends BaseRestClient { * Rest API returns the result of checking prerequisites. You could get the real status of margin mode change by subscribing margin mode. */ setMarginMode( - newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN' + newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN', ): Promise> { return this.postPrivate( '/option/usdc/private/asset/account/setMarginMode', - { setMarginMode: newMarginMode } + { setMarginMode: newMarginMode }, ); } /** Query margin mode for USDC account. */ getMarginMode(): Promise> { return this.postPrivate( - '/option/usdc/openapi/private/v1/query-margin-info' + '/option/usdc/openapi/private/v1/query-margin-info', ); } @@ -273,27 +277,27 @@ export class USDCOptionClient extends BaseRestClient { getPositions(params: USDCPositionsRequest): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/query-position', - params + params, ); } /** Query Delivery History */ getDeliveryHistory( - params: USDCOptionsDeliveryHistoryRequest + params: USDCOptionsDeliveryHistoryRequest, ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/query-delivery-list', - params + params, ); } /** Query Positions Info Upon Expiry */ getPositionsInfoUponExpiry( - params?: USDCOptionsPositionsInfoExpiryRequest + params?: USDCOptionsPositionsInfoExpiryRequest, ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/query-position-exp-date', - params + params, ); } @@ -303,7 +307,7 @@ export class USDCOptionClient extends BaseRestClient { modifyMMP(params: USDCOptionsModifyMMPRequest): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/mmp-modify', - params + params, ); } diff --git a/src/usdc-perpetual-client.ts b/src/usdc-perpetual-client.ts index a6886b9..58ab690 100644 --- a/src/usdc-perpetual-client.ts +++ b/src/usdc-perpetual-client.ts @@ -23,6 +23,10 @@ import BaseRestClient from './util/BaseRestClient'; /** * REST API client for USDC Perpetual APIs + * + * @deprecated WARNING: V1/V2 private endpoints (Rest API & Websocket Stream) for mainnet + * will be switched off gradually from 30 Oct 2023 UTC, so they are not promised a stability. + * Please note that you are at your own risk of using old endpoints going forward, and please move to V5 ASAP. */ export class USDCPerpetualClient extends BaseRestClient { getClientType() { @@ -47,7 +51,7 @@ export class USDCPerpetualClient extends BaseRestClient { /** Fetch trading rules (such as min/max qty). Query for all if blank. */ getContractInfo( - params?: USDCSymbolDirectionLimit + params?: USDCSymbolDirectionLimit, ): Promise> { return this.get('/perpetual/usdc/openapi/public/v1/symbols', params); } @@ -64,48 +68,48 @@ export class USDCPerpetualClient extends BaseRestClient { getMarkPrice(params: USDCKlineRequest): Promise> { return this.get( '/perpetual/usdc/openapi/public/v1/mark-price-kline', - params + params, ); } getIndexPrice(params: USDCKlineRequest): Promise> { return this.get( '/perpetual/usdc/openapi/public/v1/index-price-kline', - params + params, ); } getIndexPremium(params: USDCKlineRequest): Promise> { return this.get( '/perpetual/usdc/openapi/public/v1/premium-index-kline', - params + params, ); } getOpenInterest( - params: USDCOpenInterestRequest + params: USDCOpenInterestRequest, ): Promise> { return this.get('/perpetual/usdc/openapi/public/v1/open-interest', params); } getLargeOrders( - params: SymbolLimitParam + params: SymbolLimitParam, ): Promise> { return this.get('/perpetual/usdc/openapi/public/v1/big-deal', params); } getLongShortRatio( - params: SymbolPeriodLimitParam + params: SymbolPeriodLimitParam, ): Promise> { return this.get('/perpetual/usdc/openapi/public/v1/account-ratio', params); } getLast500Trades( - params: USDCLast500TradesRequest + params: USDCLast500TradesRequest, ): Promise> { return this.get( '/option/usdc/openapi/public/v1/query-trade-latest', - params + params, ); } @@ -125,7 +129,7 @@ export class USDCPerpetualClient extends BaseRestClient { submitOrder(params: USDCPerpOrderRequest): Promise> { return this.postPrivate( '/perpetual/usdc/openapi/private/v1/place-order', - params + params, ); } @@ -133,7 +137,7 @@ export class USDCPerpetualClient extends BaseRestClient { modifyOrder(params: USDCPerpModifyOrderRequest): Promise> { return this.postPrivate( '/perpetual/usdc/openapi/private/v1/replace-order', - params + params, ); } @@ -141,14 +145,14 @@ export class USDCPerpetualClient extends BaseRestClient { cancelOrder(params: USDCPerpCancelOrderRequest): Promise> { return this.postPrivate( '/perpetual/usdc/openapi/private/v1/cancel-order', - params + params, ); } /** Cancel all active orders. The real-time response indicates whether the request is successful, depending on retCode. */ cancelActiveOrders( symbol: string, - orderFilter: USDCOrderFilter + orderFilter: USDCOrderFilter, ): Promise> { return this.postPrivate('/perpetual/usdc/openapi/private/v1/cancel-all', { symbol, @@ -158,31 +162,31 @@ export class USDCPerpetualClient extends BaseRestClient { /** Query Unfilled/Partially Filled Orders */ getActiveOrders( - params: USDCPerpActiveOrdersRequest + params: USDCPerpActiveOrdersRequest, ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/query-active-orders', - params + params, ); } /** Query order history. The endpoint only supports up to 30 days of queried records */ getHistoricOrders( - params: USDCPerpHistoricOrdersRequest + params: USDCPerpHistoricOrdersRequest, ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/query-order-history', - params + params, ); } /** Query trade history. The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */ getOrderExecutionHistory( - params: USDCPerpActiveOrdersRequest + params: USDCPerpActiveOrdersRequest, ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/execution-list', - params + params, ); } @@ -190,18 +194,18 @@ export class USDCPerpetualClient extends BaseRestClient { /** The endpoint only supports up to 30 days of queried records. An error will be returned if startTime is more than 30 days. */ getTransactionLog( - params: USDCTransactionLogRequest + params: USDCTransactionLogRequest, ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/query-transaction-log', - params + params, ); } /** Wallet info for USDC account. */ getBalances(): Promise> { return this.postPrivate( - '/option/usdc/openapi/private/v1/query-wallet-balance' + '/option/usdc/openapi/private/v1/query-wallet-balance', ); } @@ -209,7 +213,7 @@ export class USDCPerpetualClient extends BaseRestClient { getAssetInfo(baseCoin?: string): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/query-asset-info', - { baseCoin } + { baseCoin }, ); } @@ -220,18 +224,18 @@ export class USDCPerpetualClient extends BaseRestClient { * Rest API returns the result of checking prerequisites. You could get the real status of margin mode change by subscribing margin mode. */ setMarginMode( - newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN' + newMarginMode: 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN', ): Promise> { return this.postPrivate( '/option/usdc/private/asset/account/setMarginMode', - { setMarginMode: newMarginMode } + { setMarginMode: newMarginMode }, ); } /** Query margin mode for USDC account. */ getMarginMode(): Promise> { return this.postPrivate( - '/option/usdc/openapi/private/v1/query-margin-info' + '/option/usdc/openapi/private/v1/query-margin-info', ); } @@ -241,7 +245,7 @@ export class USDCPerpetualClient extends BaseRestClient { getPositions(params: USDCPositionsRequest): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/query-position', - params + params, ); } @@ -249,17 +253,17 @@ export class USDCPerpetualClient extends BaseRestClient { setLeverage(symbol: string, leverage: string): Promise> { return this.postPrivate( '/perpetual/usdc/openapi/private/v1/position/leverage/save', - { symbol, leverage } + { symbol, leverage }, ); } /** Query Settlement History */ getSettlementHistory( - params?: USDCSymbolDirectionLimitCursor + params?: USDCSymbolDirectionLimitCursor, ): Promise> { return this.postPrivate( '/option/usdc/openapi/private/v1/session-settlement', - params + params, ); } @@ -271,7 +275,7 @@ export class USDCPerpetualClient extends BaseRestClient { '/perpetual/usdc/openapi/public/v1/risk-limit/list', { symbol, - } + }, ); } @@ -279,7 +283,7 @@ export class USDCPerpetualClient extends BaseRestClient { setRiskLimit(symbol: string, riskId: number): Promise> { return this.postPrivate( '/perpetual/usdc/openapi/private/v1/position/set-risk-limit', - { symbol, riskId } + { symbol, riskId }, ); } @@ -296,7 +300,7 @@ export class USDCPerpetualClient extends BaseRestClient { getPredictedFundingRate(symbol: string): Promise> { return this.postPrivate( '/perpetual/usdc/openapi/private/v1/predicted-funding', - { symbol } + { symbol }, ); }