diff --git a/package-lock.json b/package-lock.json index 78f8fcd..d3ede02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bitget-api", - "version": "2.2.0", + "version": "2.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bitget-api", - "version": "2.2.0", + "version": "2.3.0", "license": "MIT", "dependencies": { "axios": "^1.6.1", diff --git a/package.json b/package.json index 6d51b4f..003ea4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bitget-api", - "version": "2.2.0", + "version": "2.3.0", "description": "Node.js & JavaScript SDK for Bitget REST APIs & WebSockets, with TypeScript & end-to-end tests.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index 2e71d7f..ce3a7ea 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -1,16 +1,101 @@ import { + AnnouncementV2, APIResponse, + BGBConvertCoinV2, + BGBConvertHistoryV2, BorrowLoanRequestV2, + BotAssetV2, + BrokerSubaccountFutureAssetV2, + BrokerSubaccountSpotAssetV2, + BrokerSubaccountV2, + BrokerSubaccountWithdrawalV2, + CancelAndSubmitSpotOrderResponseV2, CloseFuturesFollowerPositionsRequestV2, + ConvertBGBResponseV2, + ConvertCurrencyV2, + ConvertQuotedPriceV2, + ConvertQuoteRequestV2, + ConvertRecordV2, + ConvertRequestV2, + ConvertTradeResponseV2, CopyTradingProductTypeV2, + CreateSubAccountApiKeyRequestV2, + CreateSubaccountApiKeyResponseV2, + CreateSubaccountDepositAddressV2, + CreateSubaccountResponseV2, + CreateVirtualSubAccountAndApiKeyV2, + CreateVirtualSubAccountApiKeyV2, + CreateVirtualSubAccountV2, + CreateVirtualSubApiKeyRequestV2, + CreateVirtualSubRequestV2, + CrossInterestRateAndLimitResponseV2, + CrossMaxBorrowableResponseV2, + CrossMaxTransferableResponseV2, + CrossTierConfigurationResponseV2, + CTFuturesFollowerCurrentOrdersV2, + CTFuturesFollowerHistoryOrdersV2, + CTFuturesFollowerMyTradersV2, + CTFuturesFollowerSettingsV2, + CTFuturesTraderCurrentOrdersV2, + CTFuturesTraderHistoryOrderV2, + CTFuturesTraderHistoryProfitSummaryV2, + CTFuturesTraderMyFollowersV2, + CTFuturesTraderProfitShareHistoryV2, + CTFuturesTraderSymbolSettingsV2, + CTFuturesTraderTotalOrderSummaryV2, + CTSpotFollowerCurrentOrdersV2, + CTSpotFollowerFollowConfigurationV2, + CTSpotFollowerHistoryOrdersV2, + CTSpotFollowerMyTradersV2, + CTSpotTraderCurrentTrackingOrdersV2, + CTSpotTraderFollowerListV2, + CTSpotTraderHistoryOrdersV2, + CTSpotTraderHistoryProfitSharingV2, + CTSpotTraderProfitSummaryV2, + CTSpotTraderTotalOrderDetailV2, + CTSpotTraderUnrealizedProfitV2, + EarnLoanCurrenciesV2, + EarnLoanDebtsV2, + EarnLoanHistoryV2, + EarnLoanLiquidationRecordsV2, + EarnLoanOrdersV2, + EarnLoanPledgeRateHistoryV2, + EarnLoanRepayHistoryV2, + EarnLoanRepayResponseV2, + EarnSavingsAccountV2, + EarnSavingsAssetsV2, + EarnSavingsProductsV2, + EarnSavingsRecordsV2, + EarnSavingsSubscriptionDetailV2, + EarnSharkfinAccountV2, + EarnSharkfinAssetsV2, + EarnSharkfinProductsV2, + EarnSharkfinRecordsV2, + EarnSharkfinSubscriptionDetailV2, + FundingAssetV2, FuturesAccountBillRequestV2, + FuturesAccountBillV2, + FuturesAccountsV2, + FuturesAccountV2, + FuturesActiveBuySellVolumeV2, + FuturesActiveLongShortAccountV2, + FuturesActiveLongShortPositionV2, FuturesBatchCancelOrderRequestV2, FuturesBatchOrderRequestV2, + FuturesBatchOrderResponseV2, FuturesCancelAllOrdersRequestV2, + FuturesCancelAllOrdersV2, FuturesCancelOrderRequestV2, FuturesCancelPlanOrderRequestV2, + FuturesCancelPlanOrderV2, FuturesCandlesRequestV2, + FuturesCandlestickV2, + FuturesClosePositionResponseV2, + FuturesContractConfigV2, + FuturesDiscountRatesV2, + FuturesFillV2, FuturesFlashClosePositionsRequestV2, + FuturesFundingTimeV2, FuturesGetHistoricalFillsRequestV2, FuturesGetHistoryOrdersRequestV2, FuturesGetHistoryPlanOrdersRequestV2, @@ -18,16 +103,32 @@ import { FuturesGetOrderFillsRequestV2, FuturesGetOrderRequestV2, FuturesGetPlanOrdersRequestV2, + FuturesHistoricalFundingRateV2, FuturesHistoricalPositionsRequestV2, FuturesHistoricTradesRequestV2, + FuturesHistoryInterestRateV2, + FuturesHistoryOrderV2, + FuturesHistoryPlanOrderV2, + FuturesHistoryPositionV2, + FuturesInterestExchangeRateV2, FuturesInterestHistoryRequestV2, + FuturesInterestHistoryV2, + FuturesLongShortRatioV2, FuturesMergeDepthRequestV2, + FuturesMergeDepthV2, FuturesModifyOrderRequestV2, FuturesModifyPlanOrderRequestV2, FuturesModifyTPSLOrderRequestV2, FuturesOpenCountRequestV2, + FuturesOpenInterestV2, + FuturesOpenOrderV2, + FuturesOrderDetailV2, + FuturesOrderFillV2, + FuturesPendingPlanOrderV2, FuturesPlaceOrderRequestV2, FuturesPlanOrderRequestV2, + FuturesPositionTierV2, + FuturesPositionV2, FuturesProductTypeV2, FuturesRecentTradesRequestV2, FuturesReversalOrderRequestV2, @@ -36,9 +137,18 @@ import { FuturesSetMarginModeRequestV2, FuturesSetPositionMarginRequestV2, FuturesSingleAccountRequestV2, + FuturesSubAccountAssetV2, + FuturesSymbolPriceV2, + FuturesTickerV2, FuturesTPSLOrderRequestV2, FuturesTraderSymbolSettingRequestV2, + FuturesTransactionRecordV2, + FuturesTriggerSubOrderV2, + FuturesVipFeeRateV2, + GetAnnouncementsRequestV2, GetBorrowHistoryRequestV2, + GetConvertBGBHistoryRequestV2, + GetConvertHistoryRequestV2, GetEarnSavingsAssetsRequestV2, GetEarnSavingsRecordsRequestV2, GetFinancialHistoryRequestV2, @@ -49,6 +159,7 @@ import { GetFuturesTraderFollowersRequestV2, GetFuturesTraderHistoryOrdersRequestV2, GetFuturesTraderProfitShareDetailRequestV2, + GetFuturesTransactionsRequestV2, GetHistoryOrdersRequestV2, GetInterestHistoryRequestV2, GetLiquidationHistoryRequestV2, @@ -60,6 +171,11 @@ import { GetMarginCurrentOrdersRequestV2, GetMarginLiquidationOrdersRequestV2, GetMarginOrderFillsRequestV2, + GetMarginTransactionsRequestV2, + GetMerchantAdvertisementsRequestV2, + GetMerchantP2POrdersRequestV2, + GetP2PMerchantsRequestV2, + GetP2PTransactionsRequestV2, GetRepayHistoryRequestV2, GetSharkfinAssetsRequestV2, GetSharkfinRecordsRequestV2, @@ -78,63 +194,108 @@ import { GetSpotTraderFollowersRequestV2, GetSpotTraderHistoryOrdersRequestV2, GetSpotTraderHistoryProfitRequestV2, + GetSpotTransactionsRequestV2, GetSpotTransferRecordRequestV2, GetSpotWithdrawalRecordRequestV2, + GetSubAccountsRequestV2, + GetTradeRateRequestV2, + IsolatedInterestRateAndLimitResponseV2, + IsolatedMarginBorrowingRatioV2, + IsolatedMaxBorrowableResponseV2, + IsolatedMaxTransferableResponseV2, + IsolatedTierConfigurationResponseV2, + LeveragedLongShortRatioV2, + MarginAccountAssetV2, MarginBatchOrdersRequestV2, + MarginBatchOrdersResponseV2, + MarginBorrowHistoryItemV2, + MarginCurrencyV2, + MarginCurrentOrderV2, + MarginFinancialHistoryItemV2, + MarginHistoryOrderV2, + MarginInterestHistoryItemV2, + MarginLiquidationHistoryItemV2, + MarginLiquidationOrderV2, + MarginLoanGrowthRateV2, + MarginOrderFillV2, MarginPlaceOrderRequestV2, + MarginRepaymentHistoryItemV2, + MarginTransactionRecordV2, MarginType, ModifyFuturesTraderOrderTPSLRequestV2, ModifyLoanPledgeRateRequestV2, + ModifySubAccountApiKeyRequestV2, + ModifySubaccountApiKeyResponseV2, + ModifySubaccountResponseV2, + ModifySubRequestV2, + ModifyVirtualSubAccountApiKeyV2, + ModifyVirtualSubApiKeyRequestV2, + ModifyVirtualSubRequestV2, + P2PMerchantAdvertismentV2, + P2PMerchantInfoV2, + P2PMerchantOrdersV2, + P2PMerchantOrderV2, + P2PMerchantV2, RedeemSavingsRequestV2, RepayLoanRequestV2, - SpotAccountBill, + SetLeverageResponseV2, + SetMarginModeResponseV2, + SpotAccountAssetV2, + SpotAccountBillV2, + SpotAccountInfoV2, SpotAccountTypeV2, SpotBatchCancelOrderRequestV2, SpotBatchOrderRequestV2, SpotCancelandSubmitOrderRequestV2, SpotCancelOrderRequestV2, + SpotCancelPlanOrdersV2, SpotCandlesRequestV2, + SpotCandlestickV2, + SpotCoinInfoV2, + SpotCurrentPlanOrderV2, + SpotDepositAddressV2, + SpotDepositRecordV2, + SpotFillV2, SpotFollowerCopyTradeSettingV2, + SpotFundFlowV2, SpotHistoricCandlesRequestV2, SpotHistoricTradesRequestV2, + SpotHistoryPlanOrderV2, SpotMainSubTransferRecordRequestV2, + SpotMainSubTransferRecordV2, + SpotMergeDepthV2, SpotModifyPlanOrderRequestV2, + SpotOpenOrderV2, + SpotOrderBookDepthV2, + SpotOrderInfoV2, SpotOrderRequestV2, SpotPlanOrderRequestV2, + SpotPlanSubOrderV2, + SpotSubAccountAssetsV2, + SpotSubAccountDepositRecordV2, SpotSubAccountTransferRequestV2, + SpotSymbolInfoV2, + SpotTickerV2, + SpotTradeV2, + SpotTransactionRecordV2, + SpotTransferRecordV2, SpotTransferRequestV2, + SpotVipFeeRateV2, + SpotWhaleNetFlowV2, + SpotWithdrawalRecordV2, SpotWithdrawalRequestV2, - UpdateFuturesFollowerSettingsRequestV2, - UpdateFuturesFollowerTPSLRequestV2, -} from './types'; -import { - CreateSubAccountApiKeyRequestV2, - GetSubAccountsRequestV2, - ModifySubAccountApiKeyRequestV2, - ModifySubRequestV2, + SubAccountApiKeyItemV2, + SubaccountApiKeyV2, + SubaccountDepositV2, + SubaccountEmailV2, SubDepositRecordsRequestV2, + SubmitSpotBatchOrdersResponseV2, SubWithdrawalRecordsRequestV2, SubWithdrawalRequestV2, -} from './types/request/v2/broker'; -import { - ConvertQuoteRequestV2, - ConvertRequestV2, - CreateVirtualSubApiKeyRequestV2, - CreateVirtualSubRequestV2, - GetAnnouncementsRequestV2, - GetConvertBGBHistoryRequestV2, - GetConvertHistoryRequestV2, - GetFuturesTransactionsRequestV2, - GetMarginTransactionsRequestV2, - GetMerchantAdvertisementsRequestV2, - GetMerchantP2POrdersRequestV2, - GetP2PMerchantsRequestV2, - GetP2PTransactionsRequestV2, - GetSpotTransactionsRequestV2, - GetTradeRateRequestV2, - ModifyVirtualSubApiKeyRequestV2, - ModifyVirtualSubRequestV2, -} from './types/request/v2/common'; + UpdateFuturesFollowerSettingsRequestV2, + UpdateFuturesFollowerTPSLRequestV2, + VirtualSubAccountV2, +} from './types'; import { assertMarginType, REST_CLIENT_TYPE_ENUM } from './util'; import BaseRestClient from './util/BaseRestClient'; @@ -236,7 +397,7 @@ export class RestClientV2 extends BaseRestClient { getAnnouncements( params?: GetAnnouncementsRequestV2, - ): Promise> { + ): Promise> { return this.get('/api/v2/public/annoucements', params); } @@ -246,11 +407,20 @@ export class RestClientV2 extends BaseRestClient { * */ - getServerTime(): Promise> { + getServerTime(): Promise< + APIResponse<{ + serverTime: string; + }> + > { return this.get('/api/v2/public/time'); } - getTradeRate(params: GetTradeRateRequestV2): Promise> { + getTradeRate(params: GetTradeRateRequestV2): Promise< + APIResponse<{ + makerFeeRate: string; + takerFeeRate: string; + }> + > { return this.getPrivate('/api/v2/common/trade-rate', params); } @@ -262,25 +432,25 @@ export class RestClientV2 extends BaseRestClient { getSpotTransactionRecords( params: GetSpotTransactionsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/tax/spot-record', params); } getFuturesTransactionRecords( params: GetFuturesTransactionsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/tax/future-record', params); } getMarginTransactionRecords( params: GetMarginTransactionsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/tax/margin-record', params); } getP2PTransactionRecords( params: GetP2PTransactionsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/tax/p2p-record', params); } @@ -290,25 +460,36 @@ export class RestClientV2 extends BaseRestClient { * */ - getP2PMerchantList( - params?: GetP2PMerchantsRequestV2, - ): Promise> { + getP2PMerchantList(params?: GetP2PMerchantsRequestV2): Promise< + APIResponse<{ + merchantList: P2PMerchantV2[]; + minMerchantId: string; + }> + > { return this.getPrivate('/api/v2/p2p/merchantList', params); } - getP2PMerchantInfo(): Promise> { + getP2PMerchantInfo(): Promise> { return this.getPrivate('/api/v2/p2p/merchantInfo'); } - getP2PMerchantOrders( - params: GetMerchantP2POrdersRequestV2, - ): Promise> { + getP2PMerchantOrders(params: GetMerchantP2POrdersRequestV2): Promise< + APIResponse<{ + orderList: P2PMerchantOrderV2[]; + minOrderId: string; + }> + > { return this.getPrivate('/api/v2/p2p/orderList', params); } getP2PMerchantAdvertisementList( params: GetMerchantAdvertisementsRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + advList: P2PMerchantAdvertismentV2[]; + minAdvId: string; + }> + > { return this.getPrivate('/api/v2/p2p/advList', params); } @@ -320,21 +501,21 @@ export class RestClientV2 extends BaseRestClient { getSpotWhaleNetFlowData(params: { symbol: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/spot/market/whale-net-flow', params); } getFuturesActiveTakerBuySellVolumeData(params: { symbol: string; period?: string; - }): Promise> { + }): Promise> { return this.get('/api/v2/mix/market/taker-buy-sell', params); } getFuturesActiveLongShortPositionData(params: { symbol: string; period?: string; - }): Promise> { + }): Promise> { return this.get('/api/v2/mix/market/position-long-short', params); } @@ -342,7 +523,7 @@ export class RestClientV2 extends BaseRestClient { symbol: string; period?: string; coin?: string; - }): Promise> { + }): Promise> { return this.get('/api/v2/mix/market/long-short-ratio', params); } @@ -350,45 +531,55 @@ export class RestClientV2 extends BaseRestClient { symbol: string; period?: string; coin?: string; - }): Promise> { + }): Promise> { return this.get('/api/v2/mix/market/loan-growth', params); } getIsolatedMarginBorrowingRatio(params: { symbol: string; period?: string; - }): Promise> { + }): Promise> { return this.get('/api/v2/mix/market/isolated-borrow-rate', params); } getFuturesActiveBuySellVolumeData(params: { symbol: string; period?: string; - }): Promise> { + }): Promise> { return this.get('/api/v2/mix/market/long-short', params); } getSpotFundFlow(params: { symbol: string; period?: string; - }): Promise> { + }): Promise> { return this.get('/api/v2/spot/market/fund-flow', params); } - getTradeDataSupportSymbols(): Promise> { + getTradeDataSupportSymbols(): Promise< + APIResponse<{ + spotList: string[]; + futureList: string[]; + }> + > { return this.get('/api/v2/spot/market/support-symbols'); } - getSpotFundNetFlowData(params: { - symbol: string; - }): Promise> { + getSpotFundNetFlowData(params: { symbol: string }): Promise< + APIResponse< + { + netFlow: string; + ts: string; + }[] + > + > { return this.get('/api/v2/spot/market/fund-net-flow', params); } getFuturesActiveLongShortAccountData(params: { symbol: string; period?: string; - }): Promise> { + }): Promise> { return this.get('/api/v2/mix/market/account-long-short', params); } @@ -400,19 +591,21 @@ export class RestClientV2 extends BaseRestClient { createVirtualSubaccount(params: { subAccountList: string[]; - }): Promise> { + }): Promise> { return this.postPrivate('/api/v2/user/create-virtual-subaccount', params); } - modifyVirtualSubaccount( - params: ModifyVirtualSubRequestV2, - ): Promise> { + modifyVirtualSubaccount(params: ModifyVirtualSubRequestV2): Promise< + APIResponse<{ + result: string; + }> + > { return this.postPrivate('/api/v2/user/modify-virtual-subaccount', params); } batchCreateVirtualSubaccountAndAPIKey( params: CreateVirtualSubRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate( '/api/v2/user/batch-create-subaccount-and-apikey', params, @@ -423,13 +616,18 @@ export class RestClientV2 extends BaseRestClient { limit?: string; idLessThan?: string; status?: 'normal' | 'freeze'; - }): Promise> { + }): Promise< + APIResponse<{ + endId: string; + subAccountList: VirtualSubAccountV2[]; + }> + > { return this.getPrivate('/api/v2/user/virtual-subaccount-list', params); } createVirtualSubaccountAPIKey( params: CreateVirtualSubApiKeyRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate( '/api/v2/user/create-virtual-subaccount-apikey', params, @@ -438,7 +636,7 @@ export class RestClientV2 extends BaseRestClient { modifyVirtualSubaccountAPIKey( params: ModifyVirtualSubApiKeyRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate( '/api/v2/user/modify-virtual-subaccount-apikey', params, @@ -447,7 +645,7 @@ export class RestClientV2 extends BaseRestClient { getVirtualSubaccountAPIKeys(params: { subAccountUid: string; - }): Promise> { + }): Promise> { return this.getPrivate( '/api/v2/user/virtual-subaccount-apikey-list', params, @@ -459,16 +657,27 @@ export class RestClientV2 extends BaseRestClient { * * Common | Assets * */ - getFundingAssets(params?: { coin?: string }): Promise> { + getFundingAssets(params?: { + coin?: string; + }): Promise> { return this.getPrivate('/api/v2/account/funding-assets', params); } - getBotAccount(params?: { accountType?: string }): Promise> { + getBotAccount(params?: { + accountType?: string; + }): Promise> { return this.getPrivate('/api/v2/account/bot-assets', params); } /** Get assets overview */ - getBalances(): Promise> { + getBalances(): Promise< + APIResponse< + { + accountType: string; + usdtBalance: string; + }[] + > + > { return this.getPrivate('/api/v2/account/all-account-balance'); } @@ -478,23 +687,28 @@ export class RestClientV2 extends BaseRestClient { * */ - getConvertCoins(): Promise> { + getConvertCoins(): Promise> { return this.getPrivate('/api/v2/convert/currencies'); } getConvertQuotedPrice( params: ConvertQuoteRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/convert/quoted-price', params); } - convert(params: ConvertRequestV2): Promise> { + convert( + params: ConvertRequestV2, + ): Promise> { return this.postPrivate('/api/v2/convert/trade', params); } - getConvertHistory( - params: GetConvertHistoryRequestV2, - ): Promise> { + getConvertHistory(params: GetConvertHistoryRequestV2): Promise< + APIResponse<{ + dataList: ConvertRecordV2[]; + endId: string; + }> + > { return this.getPrivate('/api/v2/convert/convert-record', params); } @@ -504,17 +718,23 @@ export class RestClientV2 extends BaseRestClient { * */ - getConvertBGBCoins(): Promise> { + getConvertBGBCoins(): Promise< + APIResponse<{ + coinList: BGBConvertCoinV2[]; + }> + > { return this.getPrivate('/api/v2/convert/bgb-convert-coin-list'); } - convertBGB(params: { coinList: string }): Promise> { + convertBGB(params: { + coinList: string; + }): Promise> { return this.postPrivate('/api/v2/convert/bgb-convert', params); } getConvertBGBHistory( params: GetConvertBGBHistoryRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/convert/bgb-convert-records', params); } @@ -532,19 +752,25 @@ export class RestClientV2 extends BaseRestClient { * */ - getSpotCoinInfo(params?: { coin?: string }): Promise> { + getSpotCoinInfo(params?: { + coin?: string; + }): Promise> { return this.getPrivate('/api/v2/spot/public/coins', params); } - getSpotSymbolInfo(params?: { symbol?: string }): Promise> { + getSpotSymbolInfo(params?: { + symbol?: string; + }): Promise> { return this.getPrivate('/api/v2/spot/public/symbols', params); } - getSpotVIPFeeRate(): Promise> { + getSpotVIPFeeRate(): Promise> { return this.getPrivate('/api/v2/spot/market/vip-fee-rate'); } - getSpotTicker(params?: { symbol?: string }): Promise> { + getSpotTicker(params?: { + symbol?: string; + }): Promise> { return this.getPrivate('/api/v2/spot/market/tickers', params); } @@ -552,7 +778,7 @@ export class RestClientV2 extends BaseRestClient { symbol: string; precision?: string; limit?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/spot/market/merge-depth', params); } @@ -560,30 +786,32 @@ export class RestClientV2 extends BaseRestClient { symbol: string; type?: string; limit?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/spot/market/orderbook', params); } - getSpotCandles(params: SpotCandlesRequestV2): Promise> { + getSpotCandles( + params: SpotCandlesRequestV2, + ): Promise> { return this.getPrivate('/api/v2/spot/market/candles', params); } getSpotHistoricCandles( params: SpotHistoricCandlesRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/spot/market/history-candles', params); } getSpotRecentTrades(params: { symbol: string; limit?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/spot/market/fills', params); } getSpotHistoricTrades( params: SpotHistoricTradesRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/spot/market/fills-history', params); } @@ -593,62 +821,80 @@ export class RestClientV2 extends BaseRestClient { * */ - spotSubmitOrder(params: SpotOrderRequestV2): Promise> { + spotSubmitOrder(params: SpotOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { return this.postPrivate('/api/v2/spot/trade/place-order', params); } spotCancelandSubmitOrder( params: SpotCancelandSubmitOrderRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/spot/trade/cancel-replace-order', params); } spotBatchCancelandSubmitOrder(params: { orderList: SpotCancelandSubmitOrderRequestV2[]; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/spot/trade/batch-cancel-replace-order', params, ); } - spotCancelOrder(params: SpotCancelOrderRequestV2): Promise> { + spotCancelOrder(params: SpotCancelOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { return this.postPrivate('/api/v2/spot/trade/cancel-order', params); } spotBatchSubmitOrders( params: SpotBatchOrderRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/spot/trade/batch-orders', params); } spotBatchCancelOrders( params: SpotBatchCancelOrderRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/spot/trade/batch-cancel-order', params); } - spotCancelSymbolOrder(params: { symbol: string }): Promise> { + spotCancelSymbolOrder(params: { symbol: string }): Promise< + APIResponse<{ + symbol: string; + }> + > { return this.postPrivate('/api/v2/spot/trade/cancel-symbol-order', params); } - getSpotOrder(params?: GetSpotOrderInfoRequestV2): Promise> { + getSpotOrder( + params?: GetSpotOrderInfoRequestV2, + ): Promise> { return this.getPrivate('/api/v2/spot/trade/orderInfo', params); } getSpotOpenOrders( params?: GetSpotOpenOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/spot/trade/unfilled-orders', params); } getSpotHistoricOrders( params?: GetSpotHistoryOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/spot/trade/history-orders', params); } - getSpotFills(params: GetSpotFillsRequestV2): Promise> { + getSpotFills( + params: GetSpotFillsRequestV2, + ): Promise> { return this.getPrivate('/api/v2/spot/trade/fills', params); } @@ -658,46 +904,64 @@ export class RestClientV2 extends BaseRestClient { * */ - spotSubmitPlanOrder( - params: SpotPlanOrderRequestV2, - ): Promise> { + spotSubmitPlanOrder(params: SpotPlanOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { return this.postPrivate('/api/v2/spot/trade/place-plan-order', params); } - spotModifyPlanOrder( - params: SpotModifyPlanOrderRequestV2, - ): Promise> { + spotModifyPlanOrder(params: SpotModifyPlanOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { return this.postPrivate('/api/v2/spot/trade/modify-plan-order', params); } spotCancelPlanOrder(params: { clientOid?: string; orderId?: string; - }): Promise> { + }): Promise< + APIResponse<{ + result: string; + }> + > { return this.postPrivate('/api/v2/spot/trade/cancel-plan-order', params); } - getSpotCurrentPlanOrders( - params: GetSpotCurrentPlanOrdersRequestV2, - ): Promise> { + getSpotCurrentPlanOrders(params: GetSpotCurrentPlanOrdersRequestV2): Promise< + APIResponse<{ + nextFlag: boolean; + idLessThan: string; + orderList: SpotCurrentPlanOrderV2[]; + }> + > { return this.getPrivate('/api/v2/spot/trade/current-plan-order', params); } getSpotPlanSubOrder(params: { planOrderId: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/spot/trade/plan-sub-order', params); } - getSpotHistoricPlanOrders( - params: GetSpotHistoryPlanOrdersRequestV2, - ): Promise> { + getSpotHistoricPlanOrders(params: GetSpotHistoryPlanOrdersRequestV2): Promise< + APIResponse<{ + nextFlag: boolean; + idLessThan: string; + orderList: SpotHistoryPlanOrderV2[]; + }> + > { return this.getPrivate('/api/v2/spot/trade/history-plan-order', params); } spotCancelPlanOrders(params?: { symbolList?: string[]; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/spot/trade/batch-cancel-plan-order', params, @@ -710,25 +974,25 @@ export class RestClientV2 extends BaseRestClient { * */ - getSpotAccount(): Promise> { + getSpotAccount(): Promise> { return this.getPrivate('/api/v2/spot/account/info'); } getSpotAccountAssets(params?: { coin?: string; assetType?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/spot/account/assets', params); } - getSpotSubAccountAssets(): Promise> { + getSpotSubAccountAssets(): Promise> { return this.getPrivate('/api/v2/spot/account/subaccount-assets'); } spotModifyDepositAccount(params: { accountType: string; coin: string; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/spot/wallet/modify-deposit-account', params, @@ -737,34 +1001,47 @@ export class RestClientV2 extends BaseRestClient { getSpotAccountBills( params?: GetSpotAccountBillsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/spot/account/bills', params); } - spotTransfer(params: SpotTransferRequestV2): Promise> { + spotTransfer(params: SpotTransferRequestV2): Promise< + APIResponse<{ + transferId: string; + clientOid: string; + }> + > { return this.postPrivate('/api/v2/spot/wallet/transfer', params); } getSpotTransferableCoins(params: { fromType: SpotAccountTypeV2; toType: SpotAccountTypeV2; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/spot/wallet/transfer-coin-info', params); } - spotSubTransfer( - params: SpotSubAccountTransferRequestV2, - ): Promise> { + spotSubTransfer(params: SpotSubAccountTransferRequestV2): Promise< + APIResponse<{ + transferId: string; + clientOid: string; + }> + > { return this.postPrivate('/api/v2/spot/wallet/subaccount-transfer', params); } - spotWithdraw(params: SpotWithdrawalRequestV2): Promise> { + spotWithdraw(params: SpotWithdrawalRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { return this.postPrivate('/api/v2/spot/wallet/withdrawal', params); } getSpotMainSubTransferRecord( params: SpotMainSubTransferRecordRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/spot/account/sub-main-trans-record', params, @@ -773,11 +1050,13 @@ export class RestClientV2 extends BaseRestClient { getSpotTransferHistory( params: GetSpotTransferRecordRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/spot/account/transferRecords', params); } - spotSwitchBGBDeduct(params: { deduct: boolean }): Promise> { + spotSwitchBGBDeduct(params: { + deduct: boolean; + }): Promise> { return this.postPrivate('/api/v2/spot/account/switch-deduct', params); } @@ -785,7 +1064,7 @@ export class RestClientV2 extends BaseRestClient { coin: string; chain?: string; size: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/spot/wallet/deposit-address', params); } @@ -794,42 +1073,48 @@ export class RestClientV2 extends BaseRestClient { coin: string; chain?: string; size: string; - }): Promise> { + }): Promise> { return this.getPrivate( '/api/v2/spot/wallet/subaccount-deposit-address', params, ); } - getSpotBGBDeductInfo(): Promise> { + getSpotBGBDeductInfo(): Promise< + APIResponse<{ + deduct: string; + }> + > { return this.getPrivate('/api/v2/spot/account/deduct-info'); } - spotCancelWithdrawal(params: { orderId: string }): Promise> { + spotCancelWithdrawal(params: { + orderId: string; + }): Promise> { return this.postPrivate('/api/v2/spot/wallet/cancel-withdrawal', params); } getSubAccountDepositRecords( params: GetSpotSubAccountDepositRecordRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/spot/wallet/subaccount-deposit-records', params, ); } - getSpotDepositHistory( - params: GetSpotDepositRecordRequestV2, - ): Promise> { - return this.getPrivate('/api/v2/spot/wallet/deposit-records', params); - } - getSpotWithdrawalHistory( params: GetSpotWithdrawalRecordRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/spot/wallet/withdrawal-records', params); } + getSpotDepositHistory( + params: GetSpotDepositRecordRequestV2, + ): Promise> { + return this.getPrivate('/api/v2/spot/wallet/deposit-records', params); + } + /** * * @@ -844,97 +1129,112 @@ export class RestClientV2 extends BaseRestClient { * */ - getFuturesVIPFeeRate(): Promise> { + getFuturesVIPFeeRate(): Promise> { return this.get('/api/v2/mix/market/vip-fee-rate'); } - getFuturesInterestRateHistory(params: { - coin: string; - }): Promise> { + getFuturesInterestRateHistory(params: { coin: string }): Promise< + APIResponse<{ + coin: string; + historyInterestRateList: FuturesHistoryInterestRateV2[]; + }> + > { return this.get('/api/v2/mix/market/union-interest-rate-history', params); } + getFuturesInterestExchangeRate(): Promise< + APIResponse< + { + coin: string; + exchangeRateList: FuturesInterestExchangeRateV2[]; + }[] + > + > { + return this.get('/api/v2/mix/market/exchange-rate'); + } + + getFuturesDiscountRate(): Promise> { + return this.get('/api/v2/mix/market/discount-rate'); + } + + getFuturesMergeDepth( + params: FuturesMergeDepthRequestV2, + ): Promise> { + return this.get('/api/v2/mix/market/merge-depth', params); + } + getFuturesTicker(params: { symbol: string; productType: FuturesProductTypeV2; - }): Promise> { + }): Promise> { return this.get('/api/v2/mix/market/ticker', params); } - getFuturesInterestExchangeRate(): Promise> { - return this.get('/api/v2/mix/market/exchange-rate'); - } - - getFuturesDiscountRate(): Promise> { - return this.get('/api/v2/mix/market/discount-rate'); - } - getFuturesAllTickers(params: { productType: FuturesProductTypeV2; - }): Promise> { + }): Promise> { return this.get('/api/v2/mix/market/tickers', params); } - getFuturesMergeDepth( - params: FuturesMergeDepthRequestV2, - ): Promise> { - return this.get('/api/v2/mix/market/merge-depth', params); - } - - getFuturesCandles( - params: FuturesCandlesRequestV2, - ): Promise> { - return this.get('/api/v2/mix/market/candles', params); - } - - getFuturesHistoricCandles( - params: FuturesCandlesRequestV2, - ): Promise> { - return this.get('/api/v2/mix/market/history-candles', params); - } - - getFuturesHistoricIndexPriceCandles( - params: FuturesCandlesRequestV2, - ): Promise> { - return this.get('/api/v2/mix/market/history-index-candles', params); - } - - getFuturesHistoricMarkPriceCandles( - params: FuturesCandlesRequestV2, - ): Promise> { - return this.get('/api/v2/mix/market/history-mark-candles', params); - } - getFuturesRecentTrades( params: FuturesRecentTradesRequestV2, - ): Promise> { + ): Promise> { return this.get('/api/v2/mix/market/fills', params); } getFuturesHistoricTrades( params: FuturesHistoricTradesRequestV2, - ): Promise> { + ): Promise> { return this.get('/api/v2/mix/market/fills-history', params); } + getFuturesCandles( + params: FuturesCandlesRequestV2, + ): Promise> { + return this.get('/api/v2/mix/market/candles', params); + } + + getFuturesHistoricCandles( + params: FuturesCandlesRequestV2, + ): Promise> { + return this.get('/api/v2/mix/market/history-candles', params); + } + + getFuturesHistoricIndexPriceCandles( + params: FuturesCandlesRequestV2, + ): Promise> { + return this.get('/api/v2/mix/market/history-index-candles', params); + } + + getFuturesHistoricMarkPriceCandles( + params: FuturesCandlesRequestV2, + ): Promise> { + return this.get('/api/v2/mix/market/history-mark-candles', params); + } + getFuturesOpenInterest(params: { symbol: string; productType: FuturesProductTypeV2; - }): Promise> { + }): Promise< + APIResponse<{ + openInterestList: FuturesOpenInterestV2[]; + ts: string; + }> + > { return this.get('/api/v2/mix/market/open-interest', params); } getFuturesNextFundingTime(params: { symbol: string; productType: FuturesProductTypeV2; - }): Promise> { + }): Promise> { return this.get('/api/v2/mix/market/funding-time', params); } getFuturesSymbolPrice(params: { symbol: string; productType: FuturesProductTypeV2; - }): Promise> { + }): Promise> { return this.get('/api/v2/mix/market/symbol-price', params); } @@ -943,21 +1243,28 @@ export class RestClientV2 extends BaseRestClient { productType: FuturesProductTypeV2; pageSize?: string; pageNumber?: string; - }): Promise> { + }): Promise> { return this.get('/api/v2/mix/market/history-fund-rate', params); } getFuturesCurrentFundingRate(params: { symbol: string; productType: FuturesProductTypeV2; - }): Promise> { + }): Promise< + APIResponse< + { + symbol: string; + fundingRate: string; + }[] + > + > { return this.get('/api/v2/mix/market/current-fund-rate', params); } getFuturesContractConfig(params: { symbol: string; productType: FuturesProductTypeV2; - }): Promise> { + }): Promise> { return this.get('/api/v2/mix/market/contracts', params); } @@ -969,75 +1276,91 @@ export class RestClientV2 extends BaseRestClient { getFuturesAccountAsset( params: FuturesSingleAccountRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/mix/account/account', params); } getFuturesAccountAssets(params: { productType: FuturesProductTypeV2; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/mix/account/accounts', params); } getFuturesSubAccountAssets(params: { productType: FuturesProductTypeV2; - }): Promise> { + }): Promise< + APIResponse< + { + userId: number; + assetList: FuturesSubAccountAssetV2[]; + }[] + > + > { return this.getPrivate('/api/v2/mix/account/sub-account-assets', params); } getFuturesInterestHistory( params: FuturesInterestHistoryRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/mix/account/interest-history', params); } - getFuturesOpenCount( - params: FuturesOpenCountRequestV2, - ): Promise> { + getFuturesOpenCount(params: FuturesOpenCountRequestV2): Promise< + APIResponse<{ + size: string; + }> + > { return this.getPrivate('/api/v2/mix/account/open-count', params); } - setFuturesLeverage( - params: FuturesSetLeverageRequestV2, - ): Promise> { - return this.postPrivate('/api/v2/mix/account/set-leverage', params); - } - setFuturesPositionAutoMargin( params: FuturesSetAutoMarginRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/mix/account/set-auto-margin', params); } + setFuturesLeverage( + params: FuturesSetLeverageRequestV2, + ): Promise> { + return this.postPrivate('/api/v2/mix/account/set-leverage', params); + } + setFuturesPositionMargin( params: FuturesSetPositionMarginRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/mix/account/set-margin', params); } setFuturesAssetMode(params: { productType: 'USDT-FUTURES' | 'SUSDT-FUTURES'; assetMode: 'single' | 'union'; - }): Promise> { + }): Promise> { return this.postPrivate('/api/v2/mix/account/set-asset-mode', params); } setFuturesMarginMode( params: FuturesSetMarginModeRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/mix/account/set-margin-mode', params); } setFuturesPositionMode(params: { productType: FuturesProductTypeV2; posMode: 'one_way_mode' | 'hedge_mode'; - }): Promise> { + }): Promise< + APIResponse<{ + posMode: 'one_way_mode' | 'hedge_mode'; + }> + > { return this.postPrivate('/api/v2/mix/account/set-position-mode', params); } - getFuturesAccountBills( - params: FuturesAccountBillRequestV2, - ): Promise> { + getFuturesAccountBills(params: FuturesAccountBillRequestV2): Promise< + APIResponse<{ + bills: FuturesAccountBillV2[]; + endId: string; + }> + > { return this.getPrivate('/api/v2/mix/account/bill', params); } @@ -1050,7 +1373,7 @@ export class RestClientV2 extends BaseRestClient { getFuturesPositionTier(params: { productType: FuturesProductTypeV2; symbol: string; - }): Promise> { + }): Promise> { return this.get('/api/v2/mix/market/query-position-lever', params); } @@ -1058,20 +1381,25 @@ export class RestClientV2 extends BaseRestClient { productType: FuturesProductTypeV2; symbol: string; marginCoin: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/mix/position/single-position', params); } getFuturesPositions(params: { productType: FuturesProductTypeV2; marginCoin?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/mix/position/all-position', params); } getFuturesHistoricPositions( params?: FuturesHistoricalPositionsRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + list: FuturesHistoryPositionV2[]; + endId: string; + }> + > { return this.getPrivate('/api/v2/mix/position/history-position', params); } @@ -1081,79 +1409,107 @@ export class RestClientV2 extends BaseRestClient { * */ - futuresSubmitOrder( - params: FuturesPlaceOrderRequestV2, - ): Promise> { + futuresSubmitOrder(params: FuturesPlaceOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { return this.postPrivate('/api/v2/mix/order/place-order', params); } - futuresCancelOrder( - params: FuturesCancelOrderRequestV2, - ): Promise> { - return this.postPrivate('/api/v2/mix/order/cancel-order', params); - } - - futuresSubmitReversal( - params: FuturesReversalOrderRequestV2, - ): Promise> { + futuresSubmitReversal(params: FuturesReversalOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { return this.postPrivate('/api/v2/mix/order/click-backhand', params); } futuresBatchSubmitOrders( params: FuturesBatchOrderRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/mix/order/batch-place-order', params); } - futuresModifyOrder( - params: FuturesModifyOrderRequestV2, - ): Promise> { + futuresModifyOrder(params: FuturesModifyOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { return this.postPrivate('/api/v2/mix/order/modify-order', params); } + futuresCancelOrder(params: FuturesCancelOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { + return this.postPrivate('/api/v2/mix/order/cancel-order', params); + } + futuresBatchCancelOrders( params: FuturesBatchCancelOrderRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/mix/order/batch-cancel-orders', params); } futuresFlashClosePositions( params: FuturesFlashClosePositionsRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/mix/order/close-positions', params); } - getFuturesOrder(params: FuturesGetOrderRequestV2): Promise> { + getFuturesOrder( + params: FuturesGetOrderRequestV2, + ): Promise> { return this.getPrivate('/api/v2/mix/order/detail', params); } - getFuturesFills( - params: FuturesGetOrderFillsRequestV2, - ): Promise> { + getFuturesFills(params: FuturesGetOrderFillsRequestV2): Promise< + APIResponse<{ + fillList: FuturesOrderFillV2[]; + endId: string; + }> + > { return this.getPrivate('/api/v2/mix/order/fills', params); } getFuturesHistoricOrderFills( params: FuturesGetHistoricalFillsRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + fillList: FuturesOrderFillV2[]; + endId: string; + }> + > { return this.getPrivate('/api/v2/mix/order/fill-history', params); } - getFuturesOpenOrders( - params: FuturesGetOpenOrdersRequestV2, - ): Promise> { + getFuturesOpenOrders(params: FuturesGetOpenOrdersRequestV2): Promise< + APIResponse<{ + entrustedList: FuturesOpenOrderV2[]; + endId: string; + }> + > { return this.getPrivate('/api/v2/mix/order/orders-pending', params); } - getFuturesHistoricOrders( - params: FuturesGetHistoryOrdersRequestV2, - ): Promise> { + getFuturesHistoricOrders(params: FuturesGetHistoryOrdersRequestV2): Promise< + APIResponse<{ + entrustedList: FuturesHistoryOrderV2[]; + endId: string; + }> + > { return this.getPrivate('/api/v2/mix/order/orders-history', params); } futuresCancelAllOrders( params: FuturesCancelAllOrdersRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/mix/order/cancel-all-orders', params); } @@ -1163,53 +1519,73 @@ export class RestClientV2 extends BaseRestClient { * */ - futuresSubmitPlanSubOrder(params: { + getFuturesTriggerSubOrder(params: { planType: 'normal_plan' | 'track_plan'; planOrderId: string; productType: FuturesProductTypeV2; - }): Promise> { - return this.postPrivate('/api/v2/mix/order/plan-sub-order', params); + }): Promise> { + return this.getPrivate('/api/v2/mix/order/plan-sub-order', params); } - futuresSubmitTPSLOrder( - params: FuturesTPSLOrderRequestV2, - ): Promise> { + futuresSubmitTPSLOrder(params: FuturesTPSLOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { return this.postPrivate('/api/v2/mix/order/place-tpsl-order', params); } - futuresSubmitPlanOrder( - params: FuturesPlanOrderRequestV2, - ): Promise> { + futuresSubmitPlanOrder(params: FuturesPlanOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { return this.postPrivate('/api/v2/mix/order/place-plan-order', params); } - futuresModifyTPSLPOrder( - params: FuturesModifyTPSLOrderRequestV2, - ): Promise> { + futuresModifyTPSLPOrder(params: FuturesModifyTPSLOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { return this.postPrivate('/api/v2/mix/order/modify-tpsl-order', params); } - futuresModifyPlanOrder( - params: FuturesModifyPlanOrderRequestV2, - ): Promise> { + futuresModifyPlanOrder(params: FuturesModifyPlanOrderRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { return this.postPrivate('/api/v2/mix/order/modify-plan-order', params); } + getFuturesPlanOrders(params: FuturesGetPlanOrdersRequestV2): Promise< + APIResponse<{ + entrustedList: FuturesPendingPlanOrderV2[]; + endId: string; + }> + > { + return this.getPrivate('/api/v2/mix/order/orders-plan-pending', params); + } + futuresCancelPlanOrder( params: FuturesCancelPlanOrderRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/mix/order/cancel-plan-order', params); } - getFuturesPlanOrders( - params: FuturesGetPlanOrdersRequestV2, - ): Promise> { - return this.getPrivate('/api/v2/mix/order/orders-plan-pending', params); - } - getFuturesHistoricPlanOrders( params: FuturesGetHistoryPlanOrdersRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + entrustedList: FuturesHistoryPlanOrderV2[]; + endId: string; + }> + > { return this.getPrivate('/api/v2/mix/order/orders-plan-history', params); } @@ -1230,33 +1606,49 @@ export class RestClientV2 extends BaseRestClient { modifySubaccountEmail(params: { subUid: string; subaccountEmail: string; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/broker/account/modify-subaccount-email', params, ); } - getBrokerInfo(): Promise> { + getBrokerInfo(): Promise< + APIResponse<{ + subAccountSize: string; + maxSubAccountSize: string; + uTime: string; + }> + > { return this.getPrivate('/api/v2/broker/account/info'); } createSubaccount(params: { subaccountName: string; label: string; - }): Promise> { + }): Promise> { return this.postPrivate('/api/v2/broker/account/create-subaccount', params); } - getSubaccounts(params?: GetSubAccountsRequestV2): Promise> { + getSubaccounts(params?: GetSubAccountsRequestV2): Promise< + APIResponse<{ + hasNextPage: boolean; + idLessThan: number; + subList: BrokerSubaccountV2[]; + }> + > { return this.getPrivate('/api/v2/broker/account/subaccount-list', params); } - modifySubaccount(params: ModifySubRequestV2): Promise> { + modifySubaccount( + params: ModifySubRequestV2, + ): Promise> { return this.postPrivate('/api/v2/broker/account/modify-subaccount', params); } - getSubaccountEmail(params: { subUid: string }): Promise> { + getSubaccountEmail(params: { + subUid: string; + }): Promise> { return this.getPrivate('/api/v2/broker/account/subaccount-email', params); } @@ -1264,7 +1656,11 @@ export class RestClientV2 extends BaseRestClient { subUid: string; coin?: string; assetType?: 'hold_only' | 'all'; - }): Promise> { + }): Promise< + APIResponse<{ + assetsList: BrokerSubaccountSpotAssetV2[]; + }> + > { return this.getPrivate( '/api/v2/broker/account/subaccount-spot-assets', params, @@ -1274,7 +1670,11 @@ export class RestClientV2 extends BaseRestClient { getSubaccountFuturesAssets(params: { subUid: string; productType: FuturesProductTypeV2; - }): Promise> { + }): Promise< + APIResponse<{ + assetsList: BrokerSubaccountFutureAssetV2[]; + }> + > { return this.getPrivate( '/api/v2/broker/account/subaccount-future-assets', params, @@ -1285,16 +1685,19 @@ export class RestClientV2 extends BaseRestClient { subUid: string; coin: string; chain?: string; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/broker/account/subaccount-address', params, ); } - subaccountWithdrawal( - params: SubWithdrawalRequestV2, - ): Promise> { + subaccountWithdrawal(params: SubWithdrawalRequestV2): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { return this.postPrivate( '/api/v2/broker/account/subaccount-withdrawal', params, @@ -1305,7 +1708,7 @@ export class RestClientV2 extends BaseRestClient { subUid: string; coin: string; toAccountType: string; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/broker/account/set-subaccount-autotransfer', params, @@ -1314,32 +1717,37 @@ export class RestClientV2 extends BaseRestClient { subaccountDepositRecords( params: SubDepositRecordsRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/broker/subaccount-deposit', params); } - subaccountWithdrawalRecords( - params: SubWithdrawalRecordsRequestV2, - ): Promise> { + subaccountWithdrawalRecords(params: SubWithdrawalRecordsRequestV2): Promise< + APIResponse<{ + resultList: BrokerSubaccountWithdrawalV2[]; + endId: string; + }> + > { return this.postPrivate('/api/v2/broker/subaccount-withdrawal', params); } /** * - * * Broker | Subaccount + * Broker | Api Key * */ createSubaccountApiKey( params: CreateSubAccountApiKeyRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate( '/api/v2/broker/manage/create-subaccount-apikey', params, ); } - getSubaccountApiKey(params: { subUid: string }): Promise> { + getSubaccountApiKey(params: { + subUid: string; + }): Promise> { return this.getPrivate( '/api/v2/broker/manage/subaccount-apikey-list', params, @@ -1348,7 +1756,7 @@ export class RestClientV2 extends BaseRestClient { modifySubaccountApiKey( params: ModifySubAccountApiKeyRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate( '/api/v2/broker/manage/modify-subaccount-apikey', params, @@ -1369,7 +1777,7 @@ export class RestClientV2 extends BaseRestClient { * */ - getMarginCurrencies(): Promise> { + getMarginCurrencies(): Promise> { return this.get('/api/v2/margin/currencies'); } @@ -1382,7 +1790,13 @@ export class RestClientV2 extends BaseRestClient { getMarginBorrowHistory( marginType: MarginType, params: GetBorrowHistoryRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + resultList: MarginBorrowHistoryItemV2[]; + maxId: string; + minId: string; + }> + > { assertMarginType(marginType); return this.getPrivate( `/api/v2/margin/${marginType}/borrow-history`, @@ -1393,7 +1807,13 @@ export class RestClientV2 extends BaseRestClient { getMarginRepayHistory( marginType: MarginType, params: GetRepayHistoryRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + resultList: MarginRepaymentHistoryItemV2[]; + maxId: string; + minId: string; + }> + > { assertMarginType(marginType); return this.getPrivate( `/api/v2/margin/${marginType}/repay-history`, @@ -1404,7 +1824,13 @@ export class RestClientV2 extends BaseRestClient { getMarginInterestHistory( marginType: MarginType, params: GetInterestHistoryRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + resultList: MarginInterestHistoryItemV2[]; + maxId: string; + minId: string; + }> + > { assertMarginType(marginType); return this.getPrivate( `/api/v2/margin/${marginType}/interest-history`, @@ -1415,7 +1841,13 @@ export class RestClientV2 extends BaseRestClient { getMarginLiquidationHistory( marginType: MarginType, params: GetLiquidationHistoryRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + resultList: MarginLiquidationHistoryItemV2[]; + maxId: string; + minId: string; + }> + > { assertMarginType(marginType); return this.getPrivate( `/api/v2/margin/${marginType}/liquidation-history`, @@ -1426,7 +1858,13 @@ export class RestClientV2 extends BaseRestClient { getMarginFinancialHistory( marginType: MarginType, params: GetFinancialHistoryRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + resultList: MarginFinancialHistoryItemV2[]; + maxId: string; + minId: string; + }> + > { assertMarginType(marginType); return this.getPrivate( `/api/v2/margin/${marginType}/financial-records`, @@ -1443,7 +1881,7 @@ export class RestClientV2 extends BaseRestClient { getMarginAccountAssets( marginType: MarginType, params?: { coin?: string }, - ): Promise> { + ): Promise> { assertMarginType(marginType); return this.getPrivate( `/api/v2/margin/${marginType}/account/assets`, @@ -1454,11 +1892,19 @@ export class RestClientV2 extends BaseRestClient { marginBorrow( marginType: MarginType, params: { + loanId: string; + symbol: string; coin: string; borrowAmount: string; - clientOid?: string; }, - ): Promise> { + ): Promise< + APIResponse<{ + loanId: string; + symbol: string; + coin: string; + borrowAmount: string; + }> + > { assertMarginType(marginType); return this.postPrivate( `/api/v2/margin/${marginType}/account/borrow`, @@ -1469,10 +1915,21 @@ export class RestClientV2 extends BaseRestClient { marginRepay( marginType: MarginType, params: { + remainDebtAmount: string; + symbol: string; + repayId: string; coin: string; repayAmount: string; }, - ): Promise> { + ): Promise< + APIResponse<{ + symbol: string; + coin: string; + repayId: string; + remainDebtAmount: string; + repayAmount: string; + }> + > { assertMarginType(marginType); return this.postPrivate( `/api/v2/margin/${marginType}/account/repay`, @@ -1480,7 +1937,14 @@ export class RestClientV2 extends BaseRestClient { ); } - getMarginRiskRate(marginType: MarginType): Promise> { + getMarginRiskRate(marginType: MarginType): Promise< + APIResponse< + { + symbol: string; + riskRateRatio: string; + }[] + > + > { assertMarginType(marginType); return this.getPrivate(`/api/v2/margin/${marginType}/account/risk-rate`); } @@ -1488,7 +1952,9 @@ export class RestClientV2 extends BaseRestClient { getMarginMaxBorrowable( marginType: MarginType, params: { coin: string }, - ): Promise> { + ): Promise< + APIResponse + > { assertMarginType(marginType); return this.getPrivate( '/api/v2/margin/${marginType}/account/max-borrowable-amount', @@ -1499,7 +1965,11 @@ export class RestClientV2 extends BaseRestClient { getMarginMaxTransferable( marginType: MarginType, params: { coin: string }, - ): Promise> { + ): Promise< + APIResponse< + CrossMaxTransferableResponseV2 | IsolatedMaxTransferableResponseV2 + > + > { assertMarginType(marginType); return this.getPrivate( '/api/v2/margin/${marginType}/account/max-transfer-out-amount', @@ -1510,7 +1980,12 @@ export class RestClientV2 extends BaseRestClient { getMarginInterestRateAndMaxBorrowable( marginType: MarginType, params: { coin: string }, - ): Promise> { + ): Promise< + APIResponse< + | IsolatedInterestRateAndLimitResponseV2[] + | CrossInterestRateAndLimitResponseV2[] + > + > { assertMarginType(marginType); return this.getPrivate( '/api/v2/margin/${marginType}/interest-rate-and-limit', @@ -1521,7 +1996,11 @@ export class RestClientV2 extends BaseRestClient { getMarginTierConfiguration( marginType: MarginType, params: { coin: string }, - ): Promise> { + ): Promise< + APIResponse< + CrossTierConfigurationResponseV2[] | IsolatedTierConfigurationResponseV2[] + > + > { assertMarginType(marginType); return this.getPrivate(`/api/v2/margin/${marginType}/tier-data`, params); } @@ -1529,7 +2008,14 @@ export class RestClientV2 extends BaseRestClient { marginFlashRepay( marginType: MarginType, params: { coin: string }, - ): Promise> { + ): Promise< + APIResponse<{ + repayId: string; + coin?: string; + symbol?: string; + result?: string; + }> + > { assertMarginType(marginType); return this.postPrivate( '/api/v2/margin/${marginType}/account/flash-repay', @@ -1540,7 +2026,14 @@ export class RestClientV2 extends BaseRestClient { getMarginFlashRepayResult( marginType: MarginType, params: { idList: string }, - ): Promise> { + ): Promise< + APIResponse< + { + repayId: string; + status: string; + }[] + > + > { assertMarginType(marginType); return this.getPrivate( '/api/v2/margin/${marginType}/account/query-flash-repay-status', @@ -1557,7 +2050,12 @@ export class RestClientV2 extends BaseRestClient { marginSubmitOrder( marginType: MarginType, params: MarginPlaceOrderRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { assertMarginType(marginType); return this.postPrivate(`/api/v2/margin/${marginType}/place-order`, params); } @@ -1565,7 +2063,7 @@ export class RestClientV2 extends BaseRestClient { marginBatchSubmitOrders( marginType: MarginType, params: MarginBatchOrdersRequestV2, - ): Promise> { + ): Promise> { assertMarginType(marginType); return this.postPrivate( `/api/v2/margin/${marginType}/batch-place-order`, @@ -1580,7 +2078,12 @@ export class RestClientV2 extends BaseRestClient { orderId?: string; clientOid?: string; }, - ): Promise> { + ): Promise< + APIResponse<{ + orderId: string; + clientOid: string; + }> + > { assertMarginType(marginType); return this.postPrivate( `/api/v2/margin/${marginType}/cancel-order`, @@ -1594,7 +2097,7 @@ export class RestClientV2 extends BaseRestClient { symbol: string; orderIdList: string[]; }, - ): Promise> { + ): Promise> { assertMarginType(marginType); return this.postPrivate( '/api/v2/margin/${marginType}/batch-cancel-order', @@ -1605,7 +2108,13 @@ export class RestClientV2 extends BaseRestClient { getMarginOpenOrders( marginType: MarginType, params: GetMarginCurrentOrdersRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + orderList: MarginCurrentOrderV2[]; + maxId: string; + minId: string; + }> + > { assertMarginType(marginType); return this.getPrivate(`/api/v2/margin/${marginType}/open-orders`, params); } @@ -1613,7 +2122,13 @@ export class RestClientV2 extends BaseRestClient { getMarginHistoricOrders( marginType: MarginType, params: GetHistoryOrdersRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + orderList: MarginHistoryOrderV2[]; + maxId: string; + minId: string; + }> + > { assertMarginType(marginType); return this.getPrivate( `/api/v2/margin/${marginType}/history-orders`, @@ -1624,7 +2139,13 @@ export class RestClientV2 extends BaseRestClient { getMarginHistoricOrderFills( marginType: MarginType, params: GetMarginOrderFillsRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + fills: MarginOrderFillV2[]; + minId: string; + maxId: string; + }> + > { assertMarginType(marginType); return this.getPrivate(`/api/v2/margin/${marginType}/fills`, params); } @@ -1632,7 +2153,12 @@ export class RestClientV2 extends BaseRestClient { getMarginLiquidationOrders( marginType: MarginType, params: GetMarginLiquidationOrdersRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + resultList: MarginLiquidationOrderV2[]; + idLessThan: string; + }> + > { assertMarginType(marginType); return this.getPrivate( `/api/v2/margin/${marginType}/liquidation-order`, @@ -1658,7 +2184,7 @@ export class RestClientV2 extends BaseRestClient { getFuturesTraderCurrentOrder( params: GetFuturesTraderCurrentOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/mix-trader/order-current-track', params, @@ -1667,7 +2193,7 @@ export class RestClientV2 extends BaseRestClient { getFuturesTraderHistoryOrders( params: GetFuturesTraderHistoryOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/mix-trader/order-history-track', params, @@ -1676,24 +2202,28 @@ export class RestClientV2 extends BaseRestClient { modifyFuturesTraderOrderTPSL( params: ModifyFuturesTraderOrderTPSLRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate( '/api/v2/copy/mix-trader/order-modify-tpsl', params, ); } - getFuturesTraderOrder(): Promise> { + getFuturesTraderOrder(): Promise< + APIResponse + > { return this.getPrivate('/api/v2/copy/mix-trader/order-total-detail'); } - getFuturesTraderProfitHistory(): Promise> { + getFuturesTraderProfitHistory(): Promise< + APIResponse + > { return this.getPrivate('/api/v2/copy/mix-trader/profit-history-summarys'); } getFuturesTraderProfitShareHistory( params: GetFuturesTraderProfitShareDetailRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/mix-trader/profit-history-details', params, @@ -1704,7 +2234,15 @@ export class RestClientV2 extends BaseRestClient { trackingNo: string; symbol: string; productType: CopyTradingProductTypeV2; - }): Promise> { + }): Promise< + APIResponse< + { + trackingNo: string; + symbol: string; + productType: string; + }[] + > + > { return this.postPrivate( '/api/v2/copy/mix-trader/order-close-positions', params, @@ -1715,14 +2253,30 @@ export class RestClientV2 extends BaseRestClient { coin?: string; pageSize?: string; pageNo?: string; - }): Promise> { + }): Promise< + APIResponse< + { + coin: string; + profit: string; + nickName: string; + }[] + > + > { return this.getPrivate('/api/v2/copy/mix-trader/profit-details', params); } getFuturesTraderProfitShareGroup(params?: { pageSize?: string; pageNo?: string; - }): Promise> { + }): Promise< + APIResponse< + { + coin: string; + profit: string; + profitTime: string; + }[] + > + > { return this.getPrivate( '/api/v2/copy/mix-trader/profits-group-coin-date', params, @@ -1731,7 +2285,7 @@ export class RestClientV2 extends BaseRestClient { getFuturesTraderSymbolSettings(params: { productType: CopyTradingProductTypeV2; - }): Promise> { + }): Promise> { return this.getPrivate( '/api/v2/copy/mix-trader/config-query-symbols', params, @@ -1740,7 +2294,7 @@ export class RestClientV2 extends BaseRestClient { updateFuturesTraderSymbolSettings(params: { settingList: FuturesTraderSymbolSettingRequestV2[]; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/copy/mix-trader/config-setting-symbols', params, @@ -1751,7 +2305,7 @@ export class RestClientV2 extends BaseRestClient { enable?: 'YES' | 'NO'; showTotalEquity?: 'YES' | 'NO'; showTpsl?: 'YES' | 'NO'; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/copy/mix-trader/config-settings-base', params, @@ -1760,7 +2314,7 @@ export class RestClientV2 extends BaseRestClient { getFuturesTraderFollowers( params?: GetFuturesTraderFollowersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/mix-trader/config-query-followers', params, @@ -1769,7 +2323,7 @@ export class RestClientV2 extends BaseRestClient { removeFuturesTraderFollower(params: { followerUid: string; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/copy/mix-trader/config-remove-follower', params, @@ -1786,7 +2340,7 @@ export class RestClientV2 extends BaseRestClient { getFuturesFollowerCurrentOrders( params: GetFollowerFuturesCurrentTrackingOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/mix-follower/query-current-orders', params, @@ -1795,7 +2349,7 @@ export class RestClientV2 extends BaseRestClient { getFuturesFollowerHistoryOrders( params: GetFollowerFuturesHistoryTrackingOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/mix-follower/query-history-orders', params, @@ -1804,25 +2358,29 @@ export class RestClientV2 extends BaseRestClient { updateFuturesFollowerTPSL( params: UpdateFuturesFollowerTPSLRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/copy/mix-follower/setting-tpsl', params); } updateFuturesFollowerSettings( params: UpdateFuturesFollowerSettingsRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/copy/mix-follower/settings', params); } getFuturesFollowerSettings(params: { traderId: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/copy/mix-follower/query-settings', params); } closeFuturesFollowerPositions( params: CloseFuturesFollowerPositionsRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + orderIdList: string[]; + }> + > { return this.postPrivate( '/api/v2/copy/mix-follower/close-positions', params, @@ -1831,14 +2389,22 @@ export class RestClientV2 extends BaseRestClient { getFuturesFollowerTraders( params: GetFuturesFollowerTradersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/copy/mix-follower/query-traders', params); } getFuturesFollowerFollowLimit(params: { symbol: string; productType: CopyTradingProductTypeV2; - }): Promise> { + }): Promise< + APIResponse< + { + maxFollowSize: string; + minFollowSize: string; + symbol: string; + }[] + > + > { return this.getPrivate( '/api/v2/copy/mix-follower/query-quantity-limit', params, @@ -1847,7 +2413,7 @@ export class RestClientV2 extends BaseRestClient { unfollowFuturesTrader(params: { traderId: string; - }): Promise> { + }): Promise> { return this.postPrivate('/api/v2/copy/mix-follower/cancel-trader', params); } @@ -1885,13 +2451,13 @@ export class RestClientV2 extends BaseRestClient { * */ - getSpotTraderProfit(): Promise> { + getSpotTraderProfit(): Promise> { return this.getPrivate('/api/v2/copy/spot-trader/profit-summarys'); } getSpotTraderHistoryProfit( params: GetSpotTraderHistoryProfitRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/spot-trader/profit-history-details', params, @@ -1902,11 +2468,11 @@ export class RestClientV2 extends BaseRestClient { coin?: string; pageNo?: string; pageSize?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/copy/spot-trader/profit-details', params); } - getSpotTraderOrder(): Promise> { + getSpotTraderOrder(): Promise> { return this.getPrivate('/api/v2/copy/spot-trader/order-total-detail'); } @@ -1914,7 +2480,7 @@ export class RestClientV2 extends BaseRestClient { trackingNo: string; stopSurplusPrice?: string; stopLossPrice?: string; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/copy/spot-trader/order-modify-tpsl', params, @@ -1923,7 +2489,7 @@ export class RestClientV2 extends BaseRestClient { getSpotTraderHistoryOrders( params: GetSpotTraderHistoryOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/spot-trader/order-history-track', params, @@ -1932,7 +2498,7 @@ export class RestClientV2 extends BaseRestClient { getSpotTraderCurrentOrders( params: GetSpotTraderCurrentOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/spot-trader/order-current-track', params, @@ -1942,7 +2508,7 @@ export class RestClientV2 extends BaseRestClient { sellSpotTrader(params: { trackingNoList: string[]; symbol: string; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/copy/spot-trader/order-close-tracking', params, @@ -1952,7 +2518,7 @@ export class RestClientV2 extends BaseRestClient { getSpotTraderSymbolSettings(params: { symbolList: string[]; settingType: 'add' | 'delete'; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/copy/spot-trader/config-setting-symbols', params, @@ -1961,7 +2527,7 @@ export class RestClientV2 extends BaseRestClient { removeSpotTraderFollowers(params: { followerUid: string; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/copy/spot-trader/config-remove-follower', params, @@ -1974,7 +2540,7 @@ export class RestClientV2 extends BaseRestClient { getSpotTraderFollowers( params: GetSpotTraderFollowersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/spot-trader/config-query-followers', params, @@ -1991,7 +2557,7 @@ export class RestClientV2 extends BaseRestClient { cancelSpotFollowerOrder(params: { trackingNoList: string[]; - }): Promise> { + }): Promise> { return this.postPrivate('/api/v2/copy/spot-follower/stop-order', params); } @@ -2000,7 +2566,7 @@ export class RestClientV2 extends BaseRestClient { autoCopy?: 'on' | 'off'; mode?: 'basic' | 'advanced'; settings: SpotFollowerCopyTradeSettingV2[]; - }): Promise> { + }): Promise> { return this.postPrivate('/api/v2/copy/spot-follower/settings', params); } @@ -2008,7 +2574,7 @@ export class RestClientV2 extends BaseRestClient { trackingNo: string; stopSurplusPrice?: string; stopLossPrice?: string; - }): Promise> { + }): Promise> { return this.postPrivate('/api/v2/copy/spot-follower/setting-tpsl', params); } @@ -2017,13 +2583,15 @@ export class RestClientV2 extends BaseRestClient { pageSize?: string; startTime?: string; endTime?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/copy/spot-follower/query-traders', params); } - getSpotFollowerCurrentTraderSymbols(params: { - traderId: string; - }): Promise> { + getSpotFollowerCurrentTraderSymbols(params: { traderId: string }): Promise< + APIResponse<{ + currentTradingList: string[]; + }> + > { return this.getPrivate( '/api/v2/copy/spot-follower/query-trader-symbols', params, @@ -2032,13 +2600,13 @@ export class RestClientV2 extends BaseRestClient { getSpotFollowerSettings(params: { traderId: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/copy/spot-follower/query-settings', params); } getSpotFollowerHistoryOrders( params: GetSpotFollowerHistoryOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/spot-follower/query-history-orders', params, @@ -2047,7 +2615,7 @@ export class RestClientV2 extends BaseRestClient { getSpotFollowerOpenOrders( params: GetSpotFollowerOpenOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/spot-follower/query-current-orders', params, @@ -2057,14 +2625,16 @@ export class RestClientV2 extends BaseRestClient { sellSpotFollower(params: { trackingNoList: string[]; symbol: string; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/copy/spot-follower/order-close-tracking', params, ); } - unfollowSpotTrader(params: { traderId: string }): Promise> { + unfollowSpotTrader(params: { + traderId: string; + }): Promise> { return this.postPrivate('/api/v2/copy/spot-follower/cancel-trader', params); } @@ -2079,30 +2649,30 @@ export class RestClientV2 extends BaseRestClient { getEarnSavingsProducts(params?: { coin?: string; filter?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/earn/savings/product', params); } - getEarnSavingsAccount(): Promise> { + getEarnSavingsAccount(): Promise> { return this.getPrivate('/api/v2/earn/savings/account'); } getEarnSavingsAssets( params: GetEarnSavingsAssetsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/earn/savings/assets', params); } getEarnSavingsRecords( params: GetEarnSavingsRecordsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/earn/savings/records', params); } getEarnSavingsSubscription(params: { productId: string; periodType: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/earn/savings/subscribe-info', params); } @@ -2110,25 +2680,45 @@ export class RestClientV2 extends BaseRestClient { productId: string; periodType: string; amount: string; - }): Promise> { + }): Promise< + APIResponse<{ + orderId: string; + status: string; + }> + > { return this.postPrivate('/api/v2/earn/savings/subscribe', params); } getEarnSavingsSubscriptionResult(params: { productId: string; periodType: string; - }): Promise> { + }): Promise< + APIResponse<{ + result: 'success' | 'fail'; + msg: string; + }> + > { return this.getPrivate('/api/v2/earn/savings/subscribe-result', params); } - earnRedeemSavings(params: RedeemSavingsRequestV2): Promise> { + earnRedeemSavings(params: RedeemSavingsRequestV2): Promise< + APIResponse<{ + orderId: string; + status: string; + }> + > { return this.postPrivate('/api/v2/earn/savings/redeem', params); } getEarnSavingsRedemptionResult(params: { orderId: string; periodType: string; - }): Promise> { + }): Promise< + APIResponse<{ + result: 'success' | 'fail'; + msg: string; + }> + > { return this.getPrivate('/api/v2/earn/savings/redeem-result', params); } @@ -2140,7 +2730,14 @@ export class RestClientV2 extends BaseRestClient { * */ - getEarnAccount(params?: { coin?: string }): Promise> { + getEarnAccount(params?: { coin?: string }): Promise< + APIResponse< + { + coin: string; + amount: string; + }[] + > + > { return this.getPrivate('/api/v2/earn/account/assets', params); } @@ -2156,42 +2753,47 @@ export class RestClientV2 extends BaseRestClient { coin: string; limit?: string; idLessThan?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/earn/sharkfin/product', params); } - getSharkfinAccount(): Promise> { + getSharkfinAccount(): Promise> { return this.getPrivate('/api/v2/earn/sharkfin/account'); } getSharkfinAssets( params: GetSharkfinAssetsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/earn/sharkfin/assets', params); } getSharkfinRecords( params: GetSharkfinRecordsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/earn/sharkfin/records', params); } getSharkfinSubscription(params: { productId: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/earn/sharkfin/subscribe-info', params); } - subscribeSharkfin(params: { - productId: string; - amount: string; - }): Promise> { + subscribeSharkfin(params: { productId: string; amount: string }): Promise< + APIResponse<{ + orderId: string; + status: string; + }> + > { return this.postPrivate('/api/v2/earn/sharkfin/subscribe', params); } - getSharkfinSubscriptionResult(params: { - orderId: string; - }): Promise> { + getSharkfinSubscriptionResult(params: { orderId: string }): Promise< + APIResponse<{ + result: 'success' | 'fail'; + msg: string; + }> + > { return this.getPrivate('/api/v2/earn/sharkfin/subscribe-result', params); } @@ -2203,17 +2805,28 @@ export class RestClientV2 extends BaseRestClient { * */ - getLoanCurrencies(params?: { coin?: string }): Promise> { + getLoanCurrencies(params?: { + coin?: string; + }): Promise> { return this.get('/api/v2/earn/loan/public/coinInfos', params); } getLoanEstInterestAndBorrowable( params: GetLoanEstInterestAndBorrowableRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + hourInterest: string; + loanAmount: string; + }> + > { return this.get('/api/v2/earn/loan/public/hour-interest', params); } - borrowLoan(params: BorrowLoanRequestV2): Promise> { + borrowLoan(params: BorrowLoanRequestV2): Promise< + APIResponse<{ + orderId: string; + }> + > { return this.postPrivate('/api/v2/earn/loan/borrow', params); } @@ -2221,43 +2834,51 @@ export class RestClientV2 extends BaseRestClient { orderId?: string; loanCoin?: string; pledgeCoin?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/earn/loan/ongoing-orders', params); } - repayLoan(params: RepayLoanRequestV2): Promise> { + repayLoan( + params: RepayLoanRequestV2, + ): Promise> { return this.postPrivate('/api/v2/earn/loan/repay', params); } getRepayHistory( params: GetLoanRepayHistoryRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/earn/loan/repay-history', params); } - updateLoanPledgeRate( - params: ModifyLoanPledgeRateRequestV2, - ): Promise> { + updateLoanPledgeRate(params: ModifyLoanPledgeRateRequestV2): Promise< + APIResponse<{ + loanCoin: string; + pledgeCoin: string; + afterPledgeRate: string; + }> + > { return this.postPrivate('/api/v2/earn/loan/revise-pledge', params); } getLoanPledgeRateHistory( params: GetLoanPledgeRateHistoryRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/earn/loan/revise-history', params); } - getLoanHistory(params: GetLoanHistoryRequestV2): Promise> { + getLoanHistory( + params: GetLoanHistoryRequestV2, + ): Promise> { return this.getPrivate('/api/v2/earn/loan/borrow-history', params); } - getLoanDebts(): Promise> { + getLoanDebts(): Promise> { return this.getPrivate('/api/v2/earn/loan/debts'); } getLoanLiquidationRecords( params: GetLiquidationRecordsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/earn/loan/reduces', params); } } diff --git a/src/types/response/index.ts b/src/types/response/index.ts index e42f90e..c0a4a58 100644 --- a/src/types/response/index.ts +++ b/src/types/response/index.ts @@ -1,3 +1,10 @@ -export * from './futures'; -export * from './shared'; -export * from './spot'; +export * from './v1/futures'; +export * from './v1/shared'; +export * from './v1/spot'; +export * from './v2/broker'; +export * from './v2/common'; +export * from './v2/copy-trading'; +export * from './v2/earn'; +export * from './v2/futures'; +export * from './v2/margin'; +export * from './v2/spot'; diff --git a/src/types/response/futures.ts b/src/types/response/v1/futures.ts similarity index 98% rename from src/types/response/futures.ts rename to src/types/response/v1/futures.ts index fb3b4f3..6cbb251 100644 --- a/src/types/response/futures.ts +++ b/src/types/response/v1/futures.ts @@ -2,7 +2,7 @@ import { FuturesHoldMode, FuturesHoldSide, FuturesMarginMode, -} from '../request'; +} from '../../request'; export interface FuturesMarketTrade { tradeId: string; diff --git a/src/types/response/shared.ts b/src/types/response/v1/shared.ts similarity index 100% rename from src/types/response/shared.ts rename to src/types/response/v1/shared.ts diff --git a/src/types/response/spot.ts b/src/types/response/v1/spot.ts similarity index 100% rename from src/types/response/spot.ts rename to src/types/response/v1/spot.ts diff --git a/src/types/response/v2/broker.ts b/src/types/response/v2/broker.ts new file mode 100644 index 0000000..ef9536e --- /dev/null +++ b/src/types/response/v2/broker.ts @@ -0,0 +1,148 @@ +/** + * + * * Broker | Subaccount + * + */ + +export interface CreateSubaccountResponseV2 { + subUid: string; + subaccountName: string; + status: string; + permList: string[]; + label: string; + cTime: string; +} + +export interface BrokerSubaccountV2 { + subUid: string; + subaccountName: string; + status: string; + permList: string[]; + label: string; + language: string; + cTime: string; + uTime: string; +} + +export interface ModifySubaccountResponseV2 { + subUid: string; + subaccountName: string; + status: string; + permList: string[]; + label: string; + language: string; + cTime: string; + uTime: string; +} + +export interface SubaccountEmailV2 { + subUid: string; + subaccountName: string; + subaccountEmail: string; + cTime: string; + uTime: string; +} + +export interface BrokerSubaccountSpotAssetV2 { + coin: string; + available: string; + frozen: string; + locked: string; + uTime: string; +} + +export interface BrokerSubaccountFutureAssetV2 { + marginCoin: string; + available: string; + frozen: string; + locked: string; + crossedMaxAvailable: string; + isolatedMaxAvailable: string; + maxTransferOut: string; + accountEquity: string; + usdtEquity: string; + btcEquity: string; + uTime: string; +} + +export interface CreateSubaccountDepositAddressV2 { + subUid: string; + coin: string; + address: string; + chain: string; + tag: string; + url: string; + cTime: string; +} + +export interface SubaccountDepositV2 { + orderId: string; + txId: string; + coin: string; + type: string; + dest: string; + amount: string; + status: string; + fromAddress: string; + toAddress: string; + fee: string; + chain: string; + confirm: string; + tag: string; + cTime: string; + uTime: string; +} + +export interface BrokerSubaccountWithdrawalV2 { + orderId: string; + txId: string; + coin: string; + type: string; + dest: string; + amount: string; + status: string; + fromAddress: string; + toAddress: string; + fee: string; + chain: string; + confirm: string; + tag: string; + userId: string; + cTime: string; + uTime: string; +} + +/** + * + * Broker | Api Key + * + */ + +export interface CreateSubaccountApiKeyResponseV2 { + subUid: string; + apiKey: string; + secretKey: string; + label: string; + ipList: string[]; + permType: string; + permList: string[]; +} + +export interface SubaccountApiKeyV2 { + subUid: string; + label: string; + apiKey: string; + secretKey: string; + permType: string; + permList: string[]; + ipList: string[]; +} + +export interface ModifySubaccountApiKeyResponseV2 { + subUid: string; + apiKey: string; + label: string; + ipList: string[]; + permType: string; + permList: string[]; +} diff --git a/src/types/response/v2/common.ts b/src/types/response/v2/common.ts new file mode 100644 index 0000000..7e6be05 --- /dev/null +++ b/src/types/response/v2/common.ts @@ -0,0 +1,425 @@ +/** + * + * * Common | Notice + * + */ + +export interface AnnouncementV2 { + annId: string; + annTitle: string; + annDesc: string; + cTime: string; + language: string; + annUrl: string; +} + +/** + * + * * Common | Public + * + */ + +/** + * + * * Common | Tax + * + */ + +export interface SpotTransactionRecordV2 { + id: string; + coin: string; + spotTaxType: string; + amount: string; + fee: string; + balance: string; + ts: string; +} + +export interface FuturesTransactionRecordV2 { + id: string; + symbol: string; + marginCoin: string; + futureTaxType: string; + amount: string; + fee: string; + ts: string; +} + +export interface MarginTransactionRecordV2 { + id: string; + coin: string; + marginTaxType: string; + amount: string; + fee: string; + total: string; + symbol: string; + ts: string; +} + +export interface P2PMerchantOrdersV2 { + id: string; + coin: string; + p2pTaxType: string; + total: string; + ts: string; +} + +/** + * + * * Common | P2P + * + */ + +export interface P2PMerchantV2 { + registerTime: string; + nickName: string; + isOnline: string; + avgPaymentTime: string; + avgReleaseTime: string; + totalTrades: string; + totalBuy: string; + totalSell: string; + totalCompletionRate: string; + trades30d: string; + sell30d: string; + buy30d: string; + completionRate30d: string; +} + +export interface P2PMerchantInfoV2 { + registerTime: string; + nickName: string; + merchantId: string; + avgPaymentTime: string; + avgReleaseTime: string; + totalTrades: string; + totalBuy: string; + totalSell: string; + totalCompletionRate: string; + trades30d: string; + sell30d: string; + buy30d: string; + completionRate30d: string; + kycStatus: boolean; + emailBindStatus: boolean; + mobileBindStatus: boolean; + email: string; + mobile: string; +} + +export interface P2PMerchantOrderV2 { + orderId: string; + orderNo: string; + advNo: string; + side: string; + count: string; + coin: string; + price: string; + fiat: string; + withdrawTime: string; + representTime: string; + releaseTime: string; + paymentTime: string; + amount: string; + status: string; + buyerRealName: string; + sellerRealName: string; + ctime: string; + utime: string; + paymentInfo: { + paymethodName: string; + paymethodId: string; + paymethodInfo: { + name: string; + required: string; + type: string; + value: string; + }[]; + }; +} + +export interface P2PMerchantAdvertismentV2 { + advId: string; + advNo: string; + side: string; + advSize: string; + size: string; + coin: string; + price: string; + coinPrecision: string; + fiat: string; + fiatPrecision: string; + fiatSymbol: string; + status: string; + hide: string; + maxTradeAmount: string; + minTradeAmount: string; + payDuration: string; + turnoverNum: string; + turnoverRate: string; + label: string | null; + userLimitList: { + minCompleteNum: string; + maxCompleteNum: string; + placeOrderNum: string; + allowMerchantPlace: string; + completeRate30d: string; + country: string; + }; + paymentMethodList: { + paymentMethod: string; + paymentId: string; + paymentInfo: { + name: string; + required: boolean; + type: string; + }[]; + }[]; + merchantCertifiedList: { + imageUrl: string; + desc: string; + }[]; + utime: string; + ctime: string; +} + +/** + * + * * Common | Trading insights + * + */ + +export interface SpotWhaleNetFlowV2 { + volume: string; + date: string; +} + +export interface FuturesActiveBuySellVolumeV2 { + buyVolume: string; + sellVolume: string; + ts: string; +} + +export interface FuturesActiveLongShortPositionV2 { + longPositionRatio: string; + shortPositionRatio: string; + longShortPositionRatio: string; + ts: string; +} + +export interface LeveragedLongShortRatioV2 { + ts: string; + longShortRatio: string; +} + +export interface MarginLoanGrowthRateV2 { + ts: string; + growthRate: string; +} + +export interface IsolatedMarginBorrowingRatioV2 { + ts: string; + borrowRate: string; +} + +export interface FuturesLongShortRatioV2 { + longRatio: string; + shortRatio: string; + longShortRatio: string; + ts: string; +} + +export interface SpotFundFlowV2 { + whaleBuyVolume: string; + dolphinBuyVolume: string; + fishBuyVolume: string; + whaleSellVolume: string; + dolphinSellVolume: string; + fishSellVolume: string; + whaleBuyRatio: string; + dolphinBuyRatio: string; + fishBuyRatio: string; + whaleSellRatio: string; + dolphinSellRatio: string; + fishSellRatio: string; +} + +export interface FuturesActiveLongShortAccountV2 { + longAccountRatio: string; + shortAccountRatio: string; + longShortAccountRatio: string; + ts: string; +} + +/** + * + * * Common | Virtual Subaccount + * + */ + +export interface CreateVirtualSubAccountV2 { + failureList: { + subaAccountName: string; + }[]; + successList: { + subaAccountUid: string; + subaAccountName: string; + status: string; + label: string; + permList: string[]; + cTime: string; + uTime: string; + }[]; +} + +export interface CreateVirtualSubAccountAndApiKeyV2 { + subAccountUid: string; + subAccountName: string; + label: string; + subAccountApiKey: string; + secretKey: string; + permList: string[]; + ipList: string[]; +} + +export interface VirtualSubAccountV2 { + subAccountUid: string; + subAccountName: string; + status: string; + permList: string[]; + label: string; + accountType: string; + bindingTime: string; + cTime: string; + uTime: string; +} + +export interface CreateVirtualSubAccountApiKeyV2 { + subAccountUid: string; + label: string; + subAccountApiKey: string; + secretKey: string; + permList: string[]; + ipList: string[]; +} + +export interface ModifyVirtualSubAccountApiKeyV2 { + subAccountUid: string; + label: string; + subAccountApiKey: string; + secretKey: string; + permList: string[]; + ipList: string[]; +} + +export interface SubAccountApiKeyItemV2 { + subAccountUid: string; + label: string; + subAccountApiKey: string; + permList: string[]; + ipList: string[]; +} + +/** + * + * * Common | Assets + * + */ + +export interface FundingAssetV2 { + coin: string; + available: string; + frozen: string; + usdtValue: string; +} + +export interface BotAssetV2 { + coin: string; + available: string; + equity: string; + bonus: string; + frozen: string; + usdtValue: string; +} + +/** + * + * * Common | Convert + * + */ + +export interface ConvertCurrencyV2 { + coin: string; + available: string; + maxAmount: string; + minAmount: string; +} + +export interface ConvertQuotedPriceV2 { + fee: string; + fromCoinSize: string; + fromCoin: string; + cnvtPrice: string; + toCoinSize: string; + toCoin: string; + traceId: string; +} + +export interface ConvertTradeResponseV2 { + ts: string; + cnvtPrice: string; + toCoinSize: string; + toCoin: string; +} + +export interface ConvertRecordV2 { + id: string; + ts: string; + cnvtPrice: string; + fee: string; + fromCoinSize: string; + fromCoin: string; + toCoinSize: string; + toCoin: string; +} + +/** + * + * * Common | BGB Convert + * + */ + +export interface BGBConvertCoinV2 { + coin: string; + available: string; + bgbEstAmount: string; + precision: string; + feeDetail: { + feeRate: string; + fee: string; + }[]; + cTime: string; +} + +export interface ConvertBGBResponseV2 { + orderList: { + coin: string; + orderId: string; + }[]; +} + +export interface BGBConvertHistoryV2 { + orderId: string; + fromCoin: string; + fromAmount: string; + fromCoinPrice: string; + toCoin: string; + toAmount: string; + toCoinPrice: string; + feeDetail: { + feeCoin: string; + fee: string; + }[]; + status: string; + ctime: string; +} diff --git a/src/types/response/v2/copy-trading.ts b/src/types/response/v2/copy-trading.ts new file mode 100644 index 0000000..98b71ac --- /dev/null +++ b/src/types/response/v2/copy-trading.ts @@ -0,0 +1,424 @@ +/** + * + * + * Copy Trading | Future copy trading | Trader Api + * + * + */ + +export interface CTFuturesTraderCurrentOrderV2 { + trackingNo: string; + openOrderId: string; + symbol: string; + posSide: string; + openLeverage: string; + openPriceAvg: string; + openTime: string; + openSize: string; + presetStopSurplusPrice: string; + presetStopLossPrice: string; + openFee: string; + followCount: string; +} + +export interface CTFuturesTraderCurrentOrdersV2 { + trackingList: CTFuturesTraderCurrentOrderV2[]; + endId: string; +} + +export interface CTFuturesTraderHistoryOrderV2 { + trackingNo: string; + symbol: string; + openOrderId: string; + closeOrderId: string; + productType: string; + posSide: string; + openLeverage: string; + openPriceAvg: string; + openTime: string; + openSize: string; + closeSize: string; + closeTime: string; + closePriceAvg: string; + stopType: string; + achievedPL: string; + openFee: string; + closeFee: string; + cTime: string; +} + +export interface CTFuturesTraderHistoryOrderV2 { + trackingList: CTFuturesTraderHistoryOrderV2[]; + endId: string; +} + +export interface CTRateCTimeV2 { + rate: string; + ctime: string; +} + +export interface CTAmountCTimeV2 { + amount: string; + ctime: string; +} + +export interface CTFuturesTraderTotalOrderSummaryV2 { + roi: string; + tradingOrderNum: string; + totalFollowerNum: string; + currentFollowerNum: string; + totalpl: string; + gainNum: string; + lossNum: string; + winRate: string; + tradingPairsAvailableList: string[]; + lastWeekRoiList: CTRateCTimeV2[]; + lastWeekProfitList: CTAmountCTimeV2[]; + lastMonthRoiList: CTRateCTimeV2[]; + lastMonthProfitList: CTAmountCTimeV2[]; + totalEquity: string; +} + +export interface CTFuturesTraderProfitHistoryItemV2 { + coin: string; + profitCount: string; + lastProfitTime: string; +} + +export interface CTFuturesTraderHistoryProfitSummaryV2 { + profitSummary: { + yesterdayProfit: string; + sumProfit: string; + waitProfit: string; + yesterdayTime: string; + }; + profitHistoryList: CTFuturesTraderProfitHistoryItemV2[]; +} + +export interface CTFuturesTraderProfitShare { + profitId: string; + coin: string; + profit: string; + nickName: string; + profitTime: string; +} + +export interface CTFuturesTraderProfitShareHistoryV2 { + profitList: CTFuturesTraderProfitShare[]; + endId: string; +} + +export interface CTFuturesTraderSymbolSettingsV2 { + symbol: string; + openTrader: string; + minOpenCount: string; + maxLeverage: string; + stopSurplusRatio: string; + stopLossRatio: string; +} + +export interface CTFuturesTraderMyFollowersV2 { + accountEquity: string; + isRemove: string; + followerHeadPic: string; + followerName: string; + followerUid: string; + followerTime: string; +} + +/** + * + * + * Copy Trading | Future copy trading | Follower Api + * + * + */ + +export interface CTFuturesFollowerCurrentOrdersV2 { + trackingNo: string; + traderName: string; + openOrderId: string; + closeOrderId: string; + traderId: string; + symbol: string; + posSide: string; + openLeverage: string; + openAvgPrice: string; + openTime: string; + openSize: string; + closeAvgPrice: string; + closeSize: string; + openMarginSz: string; + closeTime: string; +} + +export interface CTFuturesFollowerHistoryOrderV2 { + trackingNo: string; + posSide: string; + openLeverage: string; + openSize: string; + closeSize: string; + openPriceAvg: string; + closePriceAvg: string; + achievedPL: string; + openFee: string; + closeFee: string; + symbol: string; + profitRate: string; + netProfit: string; + openOrderId: string; + closeOrderId: string; + openTime: string; + closeTime: string; + traderId: string; + productType: string; +} + +export interface CTFuturesFollowerHistoryOrdersV2 { + trackingList: CTFuturesFollowerHistoryOrderV2[]; + endId: string; +} + +export interface CTFuturesFollowerSettingV2 { + symbol: string; + productType: string; + marginType: string; + marginCoin: string; + leverType: string; + longLeverage: string; + shortLeverage: string; + traceType: string; +} + +export interface CTFuturesFollowerSettingsV2 { + followerEnable: string; + detailList: CTFuturesFollowerSettingV2[]; +} + +export interface CTFuturesFollowerMyTradersV2 { + certificationType: string; + traderId: string; + traderName: string; + maxFollowLimit: string; + followCount: string; + traceTotalMarginAmount: string; + traceTotalNetProfit: string; + traceTotalProfit: string; + currentTradingPairs: string[]; + followerTime: string; + bgbMaxFollowLimit: string; + bgbFollowCount: string; +} + +/** + * + * + * Copy Trading | Spot copy trading | Trader api + * + * + */ + +export interface CTSpotTraderProfitSummaryV2 { + profitSummarys: { + yesterdayProfit: string; + yesterdayTime: string; + sumProfit: string; + waitProfit: string; + }; + profitHistoryList: { + coin: string; + profitCount: string; + lastProfitTime: string; + historysByDateList: { + profit: string; + profitTime: string; + }[]; + }[]; +} + +export interface CTSpotTraderHistoryProfitShareItemV2 { + profitId: string; + coin: string; + distributeRatio: string; + profit: string; + followerName: string; + profitTime: string; +} + +export interface CTSpotTraderHistoryProfitSharingV2 { + endId: string; + profitList: CTSpotTraderHistoryProfitShareItemV2[]; +} + +export interface CTSpotTraderUnrealizedProfitV2 { + distributeRatio: string; + coin: string; + profit: string; + followerName: string; +} + +export interface CTSpotTraderTotalOrderDetailV2 { + totalFollowerNum: string; + currentFollowerNum: string; + maxFollowerNum: string; + tradingOrderNum: string; + totalpl: string; + gainNum: string; + lossNum: string; + totalEquity: string; + winRate: string; + lastWeekRoiList: CTAmountCTimeV2[]; + lastMonthRoiList: CTRateCTimeV2[]; + lastWeekProfitList: CTAmountCTimeV2[]; + lastMonthProfitList: CTAmountCTimeV2[]; +} + +export interface CTSpotTraderHistoryOrderV2 { + trackingNo: string; + fillSize: string; + buyPrice: string; + sellPrice: string; + achievedPL: string; + buyTime: string; + sellTime: string; + buyFee: string; + sellFee: string; + achievedPLR: string; + symbol: string; + netProfit: string; + followCount: string; +} +export interface CTSpotTraderHistoryOrdersV2 { + endId: string; + trackingList: CTSpotTraderHistoryOrderV2[]; +} + +export interface CTSpotTraderCurrentTrackingOrderV2 { + trackingNo: string; + orderId: string; + buyFillSize: string; + buyDelegateSize: string; + buyPrice: string; + unrealizedPL: string; + buyTime: string; + buyFee: string; + unrealizedPLR: string; + symbol: string; + stopLossPrice: string | null; + stopSurplusPrice: string | null; + followCount: string; +} + +export interface CTSpotTraderCurrentTrackingOrdersV2 { + endId: string; + trackingList: CTSpotTraderCurrentTrackingOrderV2[]; +} + +export interface CTSpotTraderFollowerListV2 { + accountEquity: string; + isRemove: string; + followerHeadPic: string | null; + followerName: string; + followerUid: string; + followerTime: string; +} + +/** + * + * + * Copy Trading | Spot copy trading | Follower api + * + * + */ + +export interface CTSpotFollowerMyTraderV2 { + certificationType: string; + traceTotalAmount: string; + traceTotalNetProfit: string; + traceTotalProfit: string; + traderName: string; + traderId: string; + maxFollowLimit: string; + bgbMaxFollowLimit: string; + followCount: string; + bgbFollowCount: string; + followerTime: string; +} + +export interface CTSpotFollowerMyTradersV2 { + resultList: CTSpotFollowerMyTraderV2[]; +} + +export interface CTSpotFollowerTradeSettingV2 { + maxTraceAmount: string; + stopLossRation: string; + stopSurplusRation: string; + symbol: string; + traceType: string; +} + +export interface CTSpotFollowerTradeSymbolSettingV2 { + maxStopLossRation: string; + maxStopSurplusRation: string; + maxTraceAmount: string; + maxTraceAmountSystem: string; + maxTraceSize: string; + maxTraceRation: string; + minStopLossRation: string; + minStopSurplusRation: string; + minTraceAmount: string; + minTraceSize: string; + minTraceRation: string; + sliderMaxStopLossRatio: string; + sliderMaxStopSurplusRatio: string; + symbol: string; +} + +export interface CTSpotFollowerFollowConfigurationV2 { + enable: string; + profitRate: string; + settledInDays: string; + tradeSettingList: CTSpotFollowerTradeSettingV2[]; + tradeSymbolSettingList: CTSpotFollowerTradeSymbolSettingV2[]; + traderHeadPic: string; + traderName: string; +} + +export interface CTSpotFollowerHistoryOrderV2 { + trackingNo: string; + traderId: string; + fillSize: string; + buyPrice: string; + sellPrice: string; + buyFee: string; + sellFee: string; + achievedPL: string; + achievedPLR: string; + symbol: string; + buyTime: string; + sellTime: string; +} +export interface CTSpotFollowerHistoryOrdersV2 { + endId: string; + trackingList: CTSpotFollowerHistoryOrderV2[]; +} + +export interface CTSpotFollowerCurrentOrderV2 { + trackingNo: string; + traderId: string; + buyFillSize: string; + buyDelegateSize: string; + buyPrice: string; + unrealizedPL: string; + buyTime: string; + buyFee: string; + unrealizedPLR: string; + symbol: string; + stopSurplusPrice: string | null; + stopLossPrice: string | null; +} + +export interface CTSpotFollowerCurrentOrdersV2 { + endId: string; + trackingList: CTSpotFollowerCurrentOrderV2[]; +} diff --git a/src/types/response/v2/earn.ts b/src/types/response/v2/earn.ts new file mode 100644 index 0000000..a5dcdab --- /dev/null +++ b/src/types/response/v2/earn.ts @@ -0,0 +1,322 @@ +/** + * + * + * Earn | Savings + * + * + */ + +export interface EarnSavingsProductsV2 { + productId: string; + coin: string; + periodType: string; + period: string; + apyType: string; + advanceRedeem: string; + settleMethod: string; + apyList: { + rateLevel: string; + minStepVal: string; + maxStepVal: string; + currentApy: string; + }[]; + status: string; + productLevel: string; +} + +export interface EarnSavingsAccountV2 { + btcAmount: string; + usdtAmount: string; + btc24hEarning: string; + usdt24hEarning: string; + btcTotalEarning: string; + usdtTotalEarning: string; +} + +export interface EarnSavingsAssetV2 { + productId: string; + orderId: string; + productCoin: string; + interestCoin: string; + periodType: string; + period: string; + holdAmount: string; + lastProfit: string; + totalProfit: string; + holdDays: string; + status: string; + allowRedemption: string; + productLevel: string; + apy: { + rateLevel: string; + minApy: string; + maxApy: string; + currentApy: string; + }[]; +} + +export interface EarnSavingsAssetsV2 { + resultList: EarnSavingsAssetV2[]; + endId: string; +} + +export interface EarnSavingsRecordV2 { + orderId: string; + coinName: string; + settleCoinName: string; + productType: string; + period: string; + productLevel: string; + amount: string; + ts: string; + orderType: string; +} + +export interface EarnSavingsRecordsV2 { + resultList: EarnSavingsRecordV2[]; + endId: string; +} + +export interface EarnSavingsSubscriptionDetailV2 { + singleMinAmount: string; + singleMaxAmount: string; + remainingAmount: string; + subscribePrecision: string; + profitPrecision: string; + subscribeTime: string; + interestTime: string; + settleTime: string; + expireTime: string; + redeemTime: string; + settleMethod: string; + apyList: { + rateLevel: string; + minStepVal: string; + maxStepVal: string; + currentApy: string; + }[]; + redeemDelay: string; +} + +/** + * + * + * Earn | Earn Account + * + * + */ + +/** + * + * + * Earn | Shark Fin + * + * + */ + +export interface EarnSharkfinProductV2 { + productId: string; + productName: string; + productCoin: string; + subscribeCoin: string; + farmingStartTime: string; + farmingEndTime: string; + lowerRate: string; + defaultRate: string; + upperRate: string; + period: string; + interestStartTime: string; + status: string; + minAmount: string; + limitAmount: string; + soldAmount: string; + endTime: string; + startTime: string; +} + +export interface EarnSharkfinProductsV2 { + resultList: EarnSharkfinProductV2[]; + endId: string; +} + +export interface EarnSharkfinAccountV2 { + btcSubscribeAmount: string; + usdtSubscribeAmount: string; + btcHistoricalAmount: string; + usdtHistoricalAmount: string; + btcTotalEarning: string; + usdtTotalEarning: string; +} + +export interface EarnSharkfinAssetV2 { + productId: string; + interestStartTime: string; + interestEndTime: string; + productCoin: string; + subscribeCoin: string; + trend: string; + settleTime: string; + interestAmount: string; + productStatus: string; +} + +export interface EarnSharkfinAssetsV2 { + resultList: EarnSharkfinAssetV2[]; + endId: string; +} + +export interface EarnSharkfinRecordV2 { + orderId: string; + product: string; + period: string; + amount: string; + ts: string; + type: string; +} +export interface EarnSharkfinRecordsV2 { + resultList: EarnSharkfinRecordV2[]; + endId: string; +} + +export interface EarnSharkfinSubscriptionDetailV2 { + productCoin: string; + subscribeCoin: string; + interestTime: string; + expirationTime: string; + minPrice: string; + currentPrice: string; + maxPrice: string; + minRate: string; + defaultRate: string; + maxRate: string; + period: string; + productMinAmount: string; + availableBalance: string; + userAmount: string; + remainingAmount: string; + profitPrecision: string; + subscribePrecision: string; +} + +/** + * + * + * Earn | Loan + * + * + */ + +export interface EarnLoanCurrencyLoanInfoV2 { + coin: string; + hourRate7D: string; + rate7D: string; + hourRate30D: string; + rate30D: string; + minUsdt: string; + maxUsdt: string; + min: string; + max: string; +} +export interface EarnLoanCurrencyPledgeInfoV2 { + coin: string; + initRate: string; + supRate: string; + forceRate: string; + minUsdt: string; + maxUsdt: string; +} + +export interface EarnLoanCurrenciesV2 { + loanInfos: EarnLoanCurrencyLoanInfoV2[]; + pledgeInfos: EarnLoanCurrencyPledgeInfoV2[]; +} + +export interface EarnLoanOrdersV2 { + orderId: string; + loanCoin: string; + loanAmount: string; + interestAmount: string; + hourInterestRate: string; + pledgeCoin: string; + pledgeAmount: string; + pledgeRate: string; + supRate: string; + forceRate: string; + borrowTime: string; + expireTime: string; +} + +export interface EarnLoanRepayResponseV2 { + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: string; +} + +export interface EarnLoanRepayHistoryV2 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + repayAmount: string; + payInterest: string; + repayLoanAmount: string; + repayUnlockAmount: string; + repayTime: string; +} + +export interface EarnLoanPledgeRateHistoryV2 { + loanCoin: string; + pledgeCoin: string; + orderId: string; + reviseTime: string; + reviseSide: string; + reviseAmount: string; + afterPledgeRate: string; + beforePledgeRate: string; +} + +export interface EarnLoanHistoryV2 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + initPledgeAmount: string; + initLoanAmount: string; + hourRate: string; + daily: string; + borrowTime: string; + status: string; +} + +export interface EarnLoanDebtPledgeInfoV2 { + coin: string; + amount: string; + amountUsdt: string; +} + +export interface EarnLoanDebtLoanInfoV2 { + coin: string; + amount: string; + amountUsdt: string; +} + +export interface EarnLoanDebtsV2 { + pledgeInfos: EarnLoanDebtPledgeInfoV2[]; + loanInfos: EarnLoanDebtLoanInfoV2[]; +} + +export interface EarnLoanLiquidationRecordsV2 { + orderId: string; + loanCoin: string; + pledgeCoin: string; + reduceTime: string; + pledgeRate: string; + pledgePrice: string; + status: string; + pledgeAmount: string; + reduceFee: string; + residueAmount: string; + runlockAmount: string; + repayLoanAmount: string; +} diff --git a/src/types/response/v2/futures.ts b/src/types/response/v2/futures.ts new file mode 100644 index 0000000..70c22f3 --- /dev/null +++ b/src/types/response/v2/futures.ts @@ -0,0 +1,585 @@ +/** + * + * * Futures | Market + * + */ + +export interface FuturesVipFeeRateV2 { + level: string; + dealAmount: string; + assetAmount: string; + takerFeeRate: string; + makerFeeRate: string; + btcWithdrawAmount: string; + usdtWithdrawAmount: string; +} + +export interface FuturesHistoryInterestRateV2 { + ts: string; + annualInterestRate: string; + dailyInterestRate: string; +} + +export interface FuturesInterestExchangeRateV2 { + tier: string; + minAmount: string; + maxAmount: string; + exchangeRate: string; +} + +export interface FuturesDiscountRateV2 { + tier: string; + minAmount: string; + maxAmount: string; + discountRate: string; +} + +export interface FuturesDiscountRatesV2 { + coin: string; + userLimit: string; + totalLimit: string; + discountRateList: FuturesDiscountRateV2[]; +} + +export interface FuturesMergeDepthV2 { + asks: [number, number][]; + bids: [number, number][]; + ts: string; + scale: string; + precision: string; + isMaxPrecision: string; +} + +export interface FuturesTickerV2 { + symbol: string; + lastPr: string; + askPr: string; + bidPr: string; + bidSz: string; + askSz: string; + high24h: string; + low24h: string; + ts: string; + change24h: string; + baseVolume: string; + quoteVolume: string; + usdtVolume: string; + openUtc: string; + changeUtc24h: string; + indexPrice: string; + fundingRate: string; + holdingAmount: string; + deliveryStartTime: string; + deliveryTime: string; + deliveryStatus: string; + open24h: string; + markPrice: string; +} + +export interface FuturesFillV2 { + tradeId: string; + price: string; + size: string; + side: string; + ts: string; + symbol: string; +} + +export type FuturesCandlestickV2 = [ + string, // timestamp + string, // open + string, // high + string, // low + string, // close + string, // baseVolume + string, // usdtVolume + string, // quoteVolume +]; + +export interface FuturesOpenInterestV2 { + symbol: string; + size: string; +} + +export interface FuturesFundingTimeV2 { + symbol: string; + nextFundingTime: string; + ratePeriod: string; +} + +export interface FuturesSymbolPriceV2 { + symbol: string; + price: string; + indexPrice: string; + markPrice: string; + ts: string; +} + +export interface FuturesHistoricalFundingRateV2 { + symbol: string; + fundingRate: string; + fundingTime: string; +} + +export interface FuturesContractConfigV2 { + symbol: string; + baseCoin: string; + quoteCoin: string; + buyLimitPriceRatio: string; + sellLimitPriceRatio: string; + feeRateUpRatio: string; + makerFeeRate: string; + takerFeeRate: string; + openCostUpRatio: string; + supportMarginCoins: string[]; + minTradeNum: string; + priceEndStep: string; + volumePlace: string; + pricePlace: string; + sizeMultiplier: string; + symbolType: string; + minTradeUSDT: string; + maxSymbolOrderNum: string; + maxProductOrderNum: string; + maxPositionNum: string; + symbolStatus: string; + offTime: string; + limitOpenTime: string; + deliveryTime: string; + deliveryStartTime: string; + launchTime: string; + fundInterval: string; + minLever: string; + maxLever: string; + posLimit: string; + maintainTime: string; +} + +/** + * + * * Futures | Account + * + */ + +export interface FuturesAccountV2 { + marginCoin: string; + locked: string; + available: string; + crossedMaxAvailable: string; + isolatedMaxAvailable: string; + maxTransferOut: string; + accountEquity: string; + usdtEquity: string; + btcEquity: string; + crossedRiskRate: string; + crossedMarginLeverage: string; + isolatedLongLever: string; + isolatedShortLever: string; + marginMode: string; + posMode: string; + unrealizedPL: string; + coupon: string; + crossedUnrealizedPL: string; + isolatedUnrealizedPL: string; + assetMode: string; +} + +export interface FuturesAccountsV2 { + marginCoin: string; + locked: string; + available: string; + crossedMaxAvailable: string; + isolatedMaxAvailable: string; + maxTransferOut: string; + accountEquity: string; + usdtEquity: string; + btcEquity: string; + crossedRiskRate: string; + unrealizedPL: string; + coupon: string; + unionTotalMagin: string; + unionAvailable: string; + unionMm: string; + assetList: { + coin: string; + balance: string; + }[]; + isolatedMargin: string; + crossedMargin: string; + crossedUnrealizedPL: string; + isolatedUnrealizedPL: string; + assetMode: string; +} + +export interface FuturesSubAccountAssetV2 { + marginCoin: string; + locked: string; + available: string; + crossedMaxAvailable: string; + isolatedMaxAvailable: string; + maxTransferOut: string; + accountEquity: string; + usdtEquity: string; + btcEquity: string; + unrealizedPL: string; + coupon: string; +} + +export interface FuturesInterestV2 { + coin: string; + liability: string; + interestFreeLimit: string; + interestLimit: string; + hourInterestRate: string; + interest: string; + cTime: string; +} +export interface FuturesInterestHistoryV2 { + nextSettleTime: string; + borrowAmount: string; + borrowLimit: string; + interestList: FuturesInterestV2[]; + endId: string; +} + +export interface SetLeverageResponseV2 { + symbol: string; + marginCoin: string; + longLeverage: string; + shortLeverage: string; + crossMarginLeverage: string; + marginMode: string; +} + +export interface SetMarginModeResponseV2 { + symbol: string; + marginCoin: string; + longLeverage: string; + shortLeverage: string; + marginMode: string; +} + +export interface FuturesAccountBillV2 { + billId: string; + symbol: string; + amount: string; + fee: string; + feeByCoupon: string; + businessType: string; + coin: string; + balance: string; + cTime: string; +} + +/** + * + * * Futures | Position + * + */ + +export interface FuturesPositionTierV2 { + symbol: string; + level: string; + startUnit: string; + endUnit: string; + leverage: string; + keepMarginRate: string; +} + +export interface FuturesPositionV2 { + marginCoin: string; + symbol: string; + holdSide: string; + openDelegateSize: string; + marginSize: string; + available: string; + locked: string; + total: string; + leverage: string; + achievedProfits: string; + openPriceAvg: string; + marginMode: string; + posMode: string; + unrealizedPL: string; + liquidationPrice: string; + keepMarginRate: string; + markPrice: string; + breakEvenPrice: string; + totalFee: string; + deductedFee: string; + marginRatio: string; + assetMode: string; + uTime: string; + autoMargin: string; + cTime: string; +} + +export interface FuturesHistoryPositionV2 { + positionId: string; + marginCoin: string; + symbol: string; + holdSide: string; + openAvgPrice: string; + closeAvgPrice: string; + marginMode: string; + openTotalPos: string; + closeTotalPos: string; + pnl: string; + netProfit: string; + totalFunding: string; + openFee: string; + closeFee: string; + cTime: string; + uTime: string; +} + +/** + * + * * Futures | Trade + * + */ + +export interface FuturesBatchOrderResponseV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + errorMsg: string; + errorCode: string; + }[]; +} + +export interface FuturesClosePositionResponseV2 { + successList: { + orderId: string; + clientOid: string; + symbol: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + symbol: string; + errorMsg: string; + errorCode: string; + }[]; +} + +export interface FuturesOrderDetailV2 { + symbol: string; + size: string; + orderId: string; + clientOid: string; + baseVolume: string; + priceAvg: string; + fee: string; + price: string; + state: string; + side: string; + force: string; + totalProfits: string; + posSide: string; + marginCoin: string; + presetStopSurplusPrice: string; + presetStopLossPrice: string; + quoteVolume: string; + orderType: string; + leverage: string; + marginMode: string; + reduceOnly: string; + enterPointSource: string; + tradeSide: string; + posMode: string; + orderSource: string; + cancelReason: string; + cTime: string; + uTime: string; +} + +export interface FuturesOrderFillV2 { + tradeId: string; + symbol: string; + orderId: string; + price: string; + baseVolume: string; + feeDetail: { + deduction: string; + feeCoin: string; + totalDeductionFee: string; + totalFee: string; + }[]; + side: string; + quoteVolume: string; + profit: string; + enterPointSource: string; + tradeSide: string; + posMode: string; + tradeScope: string; + cTime: string; +} + +export interface FuturesOpenOrderV2 { + symbol: string; + size: string; + orderId: string; + clientOid: string; + baseVolume: string; + fee: string; + price: string; + priceAvg: string; + status: string; + side: string; + force: string; + totalProfits: string; + posSide: string; + marginCoin: string; + quoteVolume: string; + leverage: string; + marginMode: string; + enterPointSource: string; + tradeSide: string; + posMode: string; + orderType: string; + orderSource: string; + cTime: string; + uTime: string; + presetStopSurplusPrice: string; + presetStopSurplusType: string; + presetStopSurplusExecutePrice: string; + presetStopLossPrice: string; + presetStopLossType: string; + presetStopLossExecutePrice: string; +} + +export interface FuturesHistoryOrderV2 { + symbol: string; + size: string; + orderId: string; + clientOid: string; + baseVolume: string; + fee: string; + price: string; + priceAvg: string; + status: string; + side: string; + force: string; + totalProfits: string; + posSide: string; + marginCoin: string; + quoteVolume: string; + leverage: string; + marginMode: string; + enterPointSource: string; + tradeSide: string; + posMode: string; + orderType: string; + orderSource: string; + cTime: string; + uTime: string; + presetStopSurplusPrice: string; + presetStopLossPrice: string; +} + +export interface FuturesCancelAllOrdersV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + errorMsg: string; + errorCode: string; + }[]; +} + +/** + * + * * Futures | Trigger Orders + * + */ + +export interface FuturesTriggerSubOrderV2 { + orderId: string; + price: string; + type: string; + status: string; +} + +export interface FuturesPendingPlanOrderV2 { + planType: string; + symbol: string; + size: string; + orderId: string; + clientOid: string; + price: string; + executePrice: string; + callbackRatio: string; + triggerPrice: string; + triggerType: string; + planStatus: string; + side: string; + posSide: string; + marginCoin: string; + marginMode: string; + enterPointSource: string; + tradeSide: string; + posMode: string; + orderType: string; + orderSource: string; + cTime: string; + uTime: string; + stopSurplusExecutePrice: string; + stopSurplusTriggerPrice: string; + stopSurplusTriggerType: string; + stopLossExecutePrice: string; + stopLossTriggerPrice: string; + stopLossTriggerType: string; +} + +export interface FuturesCancelPlanOrderV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + errorMsg: string; + }[]; +} + +export interface FuturesHistoryPlanOrderV2 { + planType: string; + symbol: string; + size: string; + orderId: string; + executeOrderId: string; + clientOid: string; + planStatus: string; + price: string; + executePrice: string; + priceAvg: string; + baseVolume: string; + callbackRatio: string; + triggerPrice: string; + triggerType: string; + side: string; + posSide: string; + marginCoin: string; + marginMode: string; + enterPointSource: string; + tradeSide: string; + posMode: string; + orderType: string; + cTime: string; + uTime: string; + stopSurplusExecutePrice: string; + stopSurplusTriggerPrice: string; + stopSurplusTriggerType: string; + stopLossExecutePrice: string; + stopLossTriggerPrice: string; + stopLossTriggerType: string; +} diff --git a/src/types/response/v2/margin.ts b/src/types/response/v2/margin.ts new file mode 100644 index 0000000..41f6674 --- /dev/null +++ b/src/types/response/v2/margin.ts @@ -0,0 +1,300 @@ +/** + * + * * Margin | Common + * + */ + +export interface MarginCurrencyV2 { + symbol: string; + baseCoin: string; + quoteCoin: string; + maxCrossedLeverage: string; + maxIsolatedLeverage: string; + warningRiskRatio: string; + liquidationRiskRatio: string; + minTradeAmount: string; + maxTradeAmount: string; + takerFeeRate: string; + makerFeeRate: string; + pricePrecision: string; + quantityPrecision: string; + minTradeUSDT: string; + isBorrowable: boolean; + userMinBorrow: string; + status: string; + isIsolatedBaseBorrowable: boolean; + isIsolatedQuoteBorrowable: boolean; + isCrossBorrowable: boolean; +} + +/** + * + * * Margin | Cross/Isolated | Order Record + * + */ + +export interface MarginBorrowHistoryItemV2 { + loanId: string; + coin: string; + borrowAmount: string; + borrowType: string; + cTime: string; + uTime: string; +} + +export interface MarginRepaymentHistoryItemV2 { + repayId: string; + coin: string; + repayAmount: string; + repayType: string; + repayInterest: string; + repayPrincipal: string; + symbol: string; + cTime: string; + uTime: string; +} + +export interface MarginInterestHistoryItemV2 { + interestId: string; + interestCoin: string; + dailyInterestRate: string; + loanCoin: string; + interestAmount: string; + interstType: string; + symbol: string; + cTime: string; + uTime: string; +} + +export interface MarginLiquidationHistoryItemV2 { + liqId: string; + symbol: string; + liqStartTime: string; + liqEndTime: string; + liqRiskRatio: string; + totalAssets: string; + totalDebt: string; + liqFee: string; + cTime: string; + uTime: string; +} + +export interface MarginFinancialHistoryItemV2 { + coin: string; + symbol: string; + marginId: string; + amount: string; + balance: string; + fee: string; + marginType: string; + cTime: string; + uTime: string; +} + +/** + * + * * Margin | Cross/Isolated | Account + * + */ + +export interface MarginAccountAssetV2 { + symbol: string; + coin: string; + totalAmount: string; + available: string; + frozen: string; + borrow: string; + interest: string; + net: string; + coupon: string; + cTime: string; + uTime: string; +} + +export interface CrossMaxBorrowableResponseV2 { + coin: string; + maxBorrowableAmount: string; +} + +export interface IsolatedMaxBorrowableResponseV2 { + symbol: string; + baseCoin: string; + baseCoinMaxBorrowAmount: string; + quoteCoin: string; + quoteCoinMaxBorrowAmount: string; +} + +export interface CrossMaxTransferableResponseV2 { + coin: string; + maxTransferOutAmount: string; +} + +export interface IsolatedMaxTransferableResponseV2 { + baseCoin: string; + symbol: string; + baseCoinMaxTransferOutAmount: string; + quoteCoin: string; + quoteCoinMaxTransferOutAmount: string; +} + +export interface CrossInterestRateAndLimitResponseV2 { + transferable: boolean; + leverage: string; + coin: string; + borrowable: boolean; + dailyInterestRate: string; + annualInterestRate: string; + maxBorrowableAmount: string; + vipList: { + level: string; + limit: string; + dailyInterestRate: string; + annualInterestRate: string; + discountRate: string; + }[]; +} + +export interface IsolatedInterestRateAndLimitResponseV2 { + symbol: string; + leverage: string; + baseCoin: string; + baseTransferable: boolean; + baseBorrowable: boolean; + baseDailyInterestRate: string; + baseAnnuallyInterestRate: string; + baseMaxBorrowableAmount: string; + baseVipList: { + level: string; + dailyInterestRate: string; + limit: string; + annuallyInterestRate: string; + discountRate: string; + }[]; + quoteCoin: string; + quoteTransferable: boolean; + quoteBorrowable: boolean; + quoteDailyInterestRate: string; + quoteAnnuallyInterestRate: string; + quoteMaxBorrowableAmount: string; + quoteList: { + level: string; + dailyInterestRate: string; + limit: string; + annuallyInterestRate: string; + discountRate: string; + }[]; +} + +export interface CrossTierConfigurationResponseV2 { + tier: string; + leverage: string; + coin: string; + maxBorrowableAmount: string; + maintainMarginRate: string; +} + +export interface IsolatedTierConfigurationResponseV2 { + tier: string; + symbol: string; + leverage: string; + baseCoin: string; + quoteCoin: string; + baseMaxBorrowableAmount: string; + quoteMaxBorrowableAmount: string; + maintainMarginRate: string; + initRate: string; +} + +/** + * + * * Margin | Cross/Isolated | Trade + * + */ + +export interface MarginBatchOrdersResponseV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + clientOid: string; + errorMsg: string; + }[]; +} + +export interface MarginCurrentOrderV2 { + orderId: string; + symbol: string; + orderType: string; + enterPointSource: string; + clientOid: string; + loanType: string; + price: string; + side: string; + status: string; + baseSize: string; + quoteSize: string; + priceAvg: string; + size: string; + amount: string; + force: string; + cTime: string; + uTime: string; +} + +export interface MarginHistoryOrderV2 { + orderId: string; + symbol: string; + orderType: string; + enterPointSource: string; + clientOid: string; + loanType: string; + price: string; + side: string; + status: string; + baseSize: string; + quoteSize: string; + priceAvg: string; + size: string; + amount: string; + force: string; + cTime: string; + uTime: string; +} + +export interface MarginOrderFillV2 { + orderId: string; + tradeId: string; + orderType: string; + side: string; + priceAvg: string; + size: string; + amount: string; + tradeScope: string; + feeDetail: { + deduction: string; + feeCoin: string; + totalDeductionFee: string; + totalFee: string; + }; + cTime: string; + uTime: string; +} + +export interface MarginLiquidationOrderV2 { + symbol: string; + orderType: string; + side: string; + priceAvg: string; + price: string; + fillSize: string; + size: string; + amount: string; + orderId: string; + fromCoin: string; + toCoin: string; + fromSize: string; + toSize: string; + cTime: string; + uTime: string; +} diff --git a/src/types/response/v2/spot.ts b/src/types/response/v2/spot.ts new file mode 100644 index 0000000..f99bff7 --- /dev/null +++ b/src/types/response/v2/spot.ts @@ -0,0 +1,416 @@ +/** + * + * * Spot | Market + * + */ + +export interface SpotCoinChainV2 { + chain: string; + needTag: boolean; + withdrawable: boolean; + rechargeable: boolean; + withdrawFee: string; + extraWithdrawFee: string; + depositConfirm: string; + withdrawConfirm: string; + minDepositAmount: string; + minWithdrawAmount: string; + browserUrl: string; + contractAddress: string; + withdrawStep: string; + withdrawMinScale: string; + congestion: string; +} + +export interface SpotCoinInfoV2 { + coinId: string; + coin: string; + transfer: boolean; + chains: SpotCoinChainV2[]; +} + +export interface SpotSymbolInfoV2 { + symbol: string; + baseCoin: string; + quoteCoin: string; + minTradeAmount: string; + maxTradeAmount: string; + takerFeeRate: string; + makerFeeRate: string; + pricePrecision: string; + quantityPrecision: string; + quotePrecision: string; + minTradeUSDT: string; + status: string; + buyLimitPriceRatio: string; + sellLimitPriceRatio: string; + orderQuantity: string; + areaSymbol: string; +} + +export interface SpotVipFeeRateV2 { + level: number; + dealAmount: string; + assetAmount: string; + takerFeeRate: string; + makerFeeRate: string; + btcWithdrawAmount: string; + usdtWithdrawAmount: string; +} + +export interface SpotTickerV2 { + symbol: string; + high24h: string; + open: string; + low24h: string; + lastPr: string; + quoteVolume: string; + baseVolume: string; + usdtVolume: string; + bidPr: string; + askPr: string; + bidSz: string; + askSz: string; + openUtc: string; + ts: string; + changeUtc24h: string; + change24h: string; +} + +export interface SpotMergeDepthV2 { + asks: [string, string][]; + bids: [string, string][]; + ts: string; + scale: string; + precision: string; + isMaxPrecision: string; +} + +export interface SpotOrderBookDepthV2 { + asks: [string, string][]; + bids: [string, string][]; + ts: string; +} + +export type SpotCandlestickV2 = [ + string, // timestamp + string, // open + string, // high + string, // low + string, // close + string, // baseVolume + string, // usdtVolume + string, // quoteVolume +]; + +export interface SpotTradeV2 { + symbol: string; + tradeId: string; + side: string; + price: string; + size: string; + ts: string; +} + +/** + * + * * Spot | Trade + * + */ + +export interface CancelAndSubmitSpotOrderResponseV2 { + orderId: string; + clientOid: string | null; + success: string; + msg: string | null; +} + +export interface SubmitSpotBatchOrdersResponseV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + errorMsg: string; + errorCode?: string; + }[]; +} + +export interface SpotOrderInfoV2 { + userId: string; + symbol: string; + orderId: string; + clientOid: string; + price: string; + size: string; + orderType: string; + side: string; + status: string; + priceAvg: string; + baseVolume: string; + quoteVolume: string; + enterPointSource: string; + feeDetail: { + BGB?: { + deduction: boolean; + feeCoinCode: string; + totalDeductionFee: string; + totalFee: string; + }; + newFees?: { + c: number; + d: number; + deduction: boolean; + r: string; + t: string; + totalDeductionFee: number; + }; + }; + orderSource: string; + cancelReason: string; + cTime: string; + uTime: string; +} + +export interface SpotOpenOrderV2 { + userId: string; + symbol: string; + orderId: string; + clientOid: string; + priceAvg: string; + size: string; + orderType: string; + side: string; + status: string; + basePrice: string; + baseVolume: string; + quoteVolume: string; + enterPointSource: string; + orderSource?: string; + presetTakeProfitPrice: string; + executeTakeProfitPrice: string; + presetStopLossPrice: string; + executeStopLossPrice: string; + cTime: string; + uTime?: string; + tpslType: string; + triggerPrice: string | null; +} + +export interface SpotFillV2 { + userId: string; + symbol: string; + orderId: string; + tradeId: string; + orderType: string; + side: string; + priceAvg: string; + size: string; + amount: string; + feeDetail: { + deduction: string; + feeCoin: string; + totalDeductionFee: string; + totalFee: string; + }; + tradeScope: string; + cTime: string; + uTime: string; +} + +/** + * + * * Spot | Trigger Orders + * + */ + +export interface SpotCurrentPlanOrderV2 { + orderId: string; + clientOid: string; + symbol: string; + size: string; + executePrice: string; + triggerPrice: string; + status: string; + orderType: string; + side: string; + planType: string; + triggerType: string; + enterPointSource: string; + uTime: string; + cTime: string; +} + +export interface SpotHistoryPlanOrderV2 { + orderId: string; + clientOid: string; + symbol: string; + size: string; + executePrice: string; + triggerPrice: string; + status: string; + orderType: string; + side: string; + planType: string; + triggerType: string; + enterPointSource: string; + uTime: string; + cTime: string; +} + +export interface SpotPlanSubOrderV2 { + orderId: string; + price: string; + type: string; + status: string; +} + +export interface SpotCancelPlanOrdersV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + errorMsg: string; + }[]; +} + +/** + * + * * Spot | Account + * + */ + +export interface SpotAccountInfoV2 { + userId: string; + inviterId: string; + ips: string; + authorities: string[]; + parentId: number; + traderType: string; + channelCode: string; + channel: string; + regisTime: string; +} + +export interface SpotAccountAssetV2 { + coin: string; + available: string; + frozen: string; + locked: string; + limitAvailable: string; + uTime: string; +} + +export interface SpotSubAccountAssetV2 { + coin: string; + available: string; + limitAvailable: string; + frozen: string; + locked: string; + uTime: string; +} +export interface SpotSubAccountAssetsV2 { + userId: number; + assetsList: SpotSubAccountAssetV2[]; +} + +export interface SpotAccountBillV2 { + cTime: string; + coin: string; + groupType: string; + businessType: string; + size: string; + balance: string; + fees: string; + billId: string; +} + +export interface SpotMainSubTransferRecordV2 { + coin: string; + status: string; + toType: string; + fromType: string; + size: string; + ts: string; + clientOid: string; + transferId: string; + fromUserId: string; + toUserId: string; +} + +export interface SpotTransferRecordV2 { + coin: string; + status: string; + toType: string; + toSymbol: string; + fromType: string; + fromSymbol: string; + size: string; + ts: string; + clientOid: string; + transferId: string; +} + +export interface SpotDepositAddressV2 { + address: string; + chain: string; + coin: string; + tag: string; + url: string; +} + +export interface SpotSubAccountDepositRecordV2 { + orderId: string; + tradeId: string; + coin: string; + size: string; + status: string; + toAddress: string; + dest: string; + chain: string; + fromAddress: string; + clientOid?: string; + confirm?: string; + tag?: string; + cTime: string; + uTime: string; +} + +export interface SpotWithdrawalRecordV2 { + orderId: string; + tradeId: string; + coin: string; + dest: string; + clientOid: string; + type: string; + tag: string; + size: string; + fee: string; + status: string; + toAddress: string; + fromAddress: string; + confirm: string; + chain: string; + cTime: string; + uTime: string; +} + +export interface SpotDepositRecordV2 { + orderId: string; + tradeId: string; + coin: string; + type: string; + size: string; + status: string; + toAddress: string; + dest: string; + chain: string; + fromAddress: string; + cTime: string; + uTime: string; +}