From 8c8a7af2acc0ec1698d371a9d423d0d79b96803e Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Thu, 12 Dec 2024 11:07:24 +0100 Subject: [PATCH 01/13] chore(): rearranged v1 so I can start adding v2 responses --- src/types/index.ts | 2 +- src/types/response/{ => v1}/futures.ts | 2 +- src/types/response/{ => v1}/index.ts | 0 src/types/response/{ => v1}/shared.ts | 0 src/types/response/{ => v1}/spot.ts | 0 5 files changed, 2 insertions(+), 2 deletions(-) rename src/types/response/{ => v1}/futures.ts (98%) rename src/types/response/{ => v1}/index.ts (100%) rename src/types/response/{ => v1}/shared.ts (100%) rename src/types/response/{ => v1}/spot.ts (100%) diff --git a/src/types/index.ts b/src/types/index.ts index 86329ba..2b763b1 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,4 +1,4 @@ export * from './request'; -export * from './response'; +export * from './response/v1'; export * from './shared'; export * from './websockets'; 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/index.ts b/src/types/response/v1/index.ts similarity index 100% rename from src/types/response/index.ts rename to src/types/response/v1/index.ts 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 From d3a392dea70e1fd39b89008657e1466ada2eddb8 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Thu, 12 Dec 2024 12:00:58 +0100 Subject: [PATCH 02/13] feat(): added common response types --- src/rest-client-v2.ts | 206 ++++++++++----- src/types/index.ts | 2 +- src/types/response/index.ts | 4 + src/types/response/v1/index.ts | 3 - src/types/response/v2/common.ts | 443 ++++++++++++++++++++++++++++++++ 5 files changed, 583 insertions(+), 75 deletions(-) create mode 100644 src/types/response/index.ts delete mode 100644 src/types/response/v1/index.ts create mode 100644 src/types/response/v2/common.ts diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index 2e71d7f..be254a4 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -1,9 +1,30 @@ import { + AnnouncementV2, APIResponse, + BGBConvertCoinsV2, + BGBConvertHistoryV2, BorrowLoanRequestV2, + BotAssetsV2, CloseFuturesFollowerPositionsRequestV2, + ConvertBGBResponseV2, + ConvertCurrenciesV2, + ConvertHistoryV2, + ConvertQuotedPriceV2, + ConvertQuoteRequestV2, + ConvertRequestV2, + ConvertTradeResponseV2, CopyTradingProductTypeV2, + CreateSubAccountApiKeyRequestV2, + CreateVirtualSubAccountAndApiKeyV2, + CreateVirtualSubAccountApiKeyV2, + CreateVirtualSubAccountV2, + CreateVirtualSubApiKeyRequestV2, + CreateVirtualSubRequestV2, + FundingAssetsV2, FuturesAccountBillRequestV2, + FuturesActiveBuySellVolumeV2, + FuturesActiveLongShortAccountV2, + FuturesActiveLongShortPositionV2, FuturesBatchCancelOrderRequestV2, FuturesBatchOrderRequestV2, FuturesCancelAllOrdersRequestV2, @@ -21,6 +42,7 @@ import { FuturesHistoricalPositionsRequestV2, FuturesHistoricTradesRequestV2, FuturesInterestHistoryRequestV2, + FuturesLongShortRatioV2, FuturesMergeDepthRequestV2, FuturesModifyOrderRequestV2, FuturesModifyPlanOrderRequestV2, @@ -38,7 +60,11 @@ import { FuturesSingleAccountRequestV2, FuturesTPSLOrderRequestV2, FuturesTraderSymbolSettingRequestV2, + FuturesTransactionRecordV2, + GetAnnouncementsRequestV2, GetBorrowHistoryRequestV2, + GetConvertBGBHistoryRequestV2, + GetConvertHistoryRequestV2, GetEarnSavingsAssetsRequestV2, GetEarnSavingsRecordsRequestV2, GetFinancialHistoryRequestV2, @@ -49,6 +75,7 @@ import { GetFuturesTraderFollowersRequestV2, GetFuturesTraderHistoryOrdersRequestV2, GetFuturesTraderProfitShareDetailRequestV2, + GetFuturesTransactionsRequestV2, GetHistoryOrdersRequestV2, GetInterestHistoryRequestV2, GetLiquidationHistoryRequestV2, @@ -60,6 +87,11 @@ import { GetMarginCurrentOrdersRequestV2, GetMarginLiquidationOrdersRequestV2, GetMarginOrderFillsRequestV2, + GetMarginTransactionsRequestV2, + GetMerchantAdvertisementsRequestV2, + GetMerchantP2POrdersRequestV2, + GetP2PMerchantsRequestV2, + GetP2PTransactionsRequestV2, GetRepayHistoryRequestV2, GetSharkfinAssetsRequestV2, GetSharkfinRecordsRequestV2, @@ -78,13 +110,29 @@ import { GetSpotTraderFollowersRequestV2, GetSpotTraderHistoryOrdersRequestV2, GetSpotTraderHistoryProfitRequestV2, + GetSpotTransactionsRequestV2, GetSpotTransferRecordRequestV2, GetSpotWithdrawalRecordRequestV2, + GetSubAccountsRequestV2, + GetTradeRateRequestV2, + IsolatedMarginBorrowingRatioV2, + LeveragedLongShortRatioV2, MarginBatchOrdersRequestV2, + MarginLoanGrowthRateV2, MarginPlaceOrderRequestV2, + MarginTransactionRecordV2, MarginType, ModifyFuturesTraderOrderTPSLRequestV2, ModifyLoanPledgeRateRequestV2, + ModifySubAccountApiKeyRequestV2, + ModifySubRequestV2, + ModifyVirtualSubAccountApiKeyV2, + ModifyVirtualSubApiKeyRequestV2, + ModifyVirtualSubRequestV2, + P2PMerchantAdvertisementV2, + P2PMerchantInfoV2, + P2PMerchantListV2, + P2PMerchantOrderV2, RedeemSavingsRequestV2, RepayLoanRequestV2, SpotAccountBill, @@ -95,6 +143,7 @@ import { SpotCancelOrderRequestV2, SpotCandlesRequestV2, SpotFollowerCopyTradeSettingV2, + SpotFundFlowV2, SpotHistoricCandlesRequestV2, SpotHistoricTradesRequestV2, SpotMainSubTransferRecordRequestV2, @@ -102,39 +151,18 @@ import { SpotOrderRequestV2, SpotPlanOrderRequestV2, SpotSubAccountTransferRequestV2, + SpotTransactionRecordV2, SpotTransferRequestV2, + SpotWhaleNetFlowV2, SpotWithdrawalRequestV2, - UpdateFuturesFollowerSettingsRequestV2, - UpdateFuturesFollowerTPSLRequestV2, -} from './types'; -import { - CreateSubAccountApiKeyRequestV2, - GetSubAccountsRequestV2, - ModifySubAccountApiKeyRequestV2, - ModifySubRequestV2, + SubAccountApiKeyListV2, SubDepositRecordsRequestV2, 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, + VirtualSubAccountListV2, +} from './types'; import { assertMarginType, REST_CLIENT_TYPE_ENUM } from './util'; import BaseRestClient from './util/BaseRestClient'; @@ -236,7 +264,7 @@ export class RestClientV2 extends BaseRestClient { getAnnouncements( params?: GetAnnouncementsRequestV2, - ): Promise> { + ): Promise> { return this.get('/api/v2/public/annoucements', params); } @@ -246,11 +274,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 +299,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); } @@ -292,23 +329,23 @@ export class RestClientV2 extends BaseRestClient { getP2PMerchantList( params?: GetP2PMerchantsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/p2p/merchantList', params); } - getP2PMerchantInfo(): Promise> { + getP2PMerchantInfo(): Promise> { return this.getPrivate('/api/v2/p2p/merchantInfo'); } getP2PMerchantOrders( params: GetMerchantP2POrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/p2p/orderList', params); } getP2PMerchantAdvertisementList( params: GetMerchantAdvertisementsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/p2p/advList', params); } @@ -320,21 +357,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 +379,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 +387,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 +447,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 +472,13 @@ export class RestClientV2 extends BaseRestClient { limit?: string; idLessThan?: string; status?: 'normal' | 'freeze'; - }): Promise> { + }): Promise> { 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 +487,7 @@ export class RestClientV2 extends BaseRestClient { modifyVirtualSubaccountAPIKey( params: ModifyVirtualSubApiKeyRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate( '/api/v2/user/modify-virtual-subaccount-apikey', params, @@ -447,7 +496,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 +508,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 +538,25 @@ 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> { + ): Promise> { return this.getPrivate('/api/v2/convert/convert-record', params); } @@ -504,17 +566,19 @@ export class RestClientV2 extends BaseRestClient { * */ - getConvertBGBCoins(): Promise> { + getConvertBGBCoins(): Promise> { 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); } diff --git a/src/types/index.ts b/src/types/index.ts index 2b763b1..86329ba 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,4 +1,4 @@ export * from './request'; -export * from './response/v1'; +export * from './response'; export * from './shared'; export * from './websockets'; diff --git a/src/types/response/index.ts b/src/types/response/index.ts new file mode 100644 index 0000000..a98abe2 --- /dev/null +++ b/src/types/response/index.ts @@ -0,0 +1,4 @@ +export * from './v1/futures'; +export * from './v1/shared'; +export * from './v1/spot'; +export * from './v2/common'; diff --git a/src/types/response/v1/index.ts b/src/types/response/v1/index.ts deleted file mode 100644 index e42f90e..0000000 --- a/src/types/response/v1/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './futures'; -export * from './shared'; -export * from './spot'; diff --git a/src/types/response/v2/common.ts b/src/types/response/v2/common.ts new file mode 100644 index 0000000..091f82a --- /dev/null +++ b/src/types/response/v2/common.ts @@ -0,0 +1,443 @@ +/** + * + * * 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 P2PMerchantOrderV2 { + id: string; + coin: string; + p2pTaxType: string; + total: string; + ts: string; +} + +/** + * + * * Common | P2P + * + */ + +export interface P2PMerchantListV2 { + merchantList: { + 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; + }[]; + minMerchantId: 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 { + orderList: { + 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; + }[]; + }; + }[]; + minOrderId: string; +} + +export interface P2PMerchantAdvertisementV2 { + advList: { + 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; + }[]; + minAdvId: 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 VirtualSubAccountListV2 { + endId: string; + subAccountList: { + 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 SubAccountApiKeyListV2 { + subAccountUid: string; + label: string; + subAccountApiKey: string; + permList: string[]; + ipList: string[]; +} + +/** + * + * * Common | Assets + * + */ + +export interface FundingAssetsV2 { + coin: string; + available: string; + frozen: string; + usdtValue: string; +} + +export interface BotAssetsV2 { + coin: string; + available: string; + equity: string; + bonus: string; + frozen: string; + usdtValue: string; +} + +/** + * + * * Common | Convert + * + */ + +export interface ConvertCurrenciesV2 { + // array type + 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 ConvertHistoryV2 { + dataList: { + id: string; + ts: string; + cnvtPrice: string; + fee: string; + fromCoinSize: string; + fromCoin: string; + toCoinSize: string; + toCoin: string; + }[]; + endId: string; +} + +/** + * + * * Common | BGB Convert + * + */ + +export interface BGBConvertCoinsV2 { + coinList: { + 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; +} From 9add46e6fe771daf4dba7f5122fe28be6860c73a Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Fri, 13 Dec 2024 10:17:51 +0100 Subject: [PATCH 03/13] feat(): added all spot response types --- src/rest-client-v2.ts | 200 ++++++++++++----- src/types/response/index.ts | 1 + src/types/response/v2/spot.ts | 400 ++++++++++++++++++++++++++++++++++ 3 files changed, 542 insertions(+), 59 deletions(-) create mode 100644 src/types/response/v2/spot.ts diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index be254a4..f63693d 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -5,6 +5,7 @@ import { BGBConvertHistoryV2, BorrowLoanRequestV2, BotAssetsV2, + CancelAndSubmitSpotOrderResponseV2, CloseFuturesFollowerPositionsRequestV2, ConvertBGBResponseV2, ConvertCurrenciesV2, @@ -135,28 +136,52 @@ import { P2PMerchantOrderV2, RedeemSavingsRequestV2, RepayLoanRequestV2, - SpotAccountBill, + SpotAccountAssetV2, + SpotAccountBillV2, + SpotAccountInfoV2, SpotAccountTypeV2, SpotBatchCancelOrderRequestV2, SpotBatchOrderRequestV2, SpotCancelandSubmitOrderRequestV2, SpotCancelOrderRequestV2, + SpotCancelPlanOrdersV2, SpotCandlesRequestV2, + SpotCandlestickV2, + SpotCoinInfoV2, + SpotCurrentPlanOrderV2, + SpotDepositAddressV2, + SpotDepositRecordV2, + SpotFillV2, SpotFollowerCopyTradeSettingV2, SpotFundFlowV2, SpotHistoricCandlesRequestV2, SpotHistoricTradesRequestV2, SpotMainSubTransferRecordRequestV2, + SpotMainSubTransferRecordV2, + SpotMergeDepthV2, SpotModifyPlanOrderRequestV2, + SpotOpenOrderV2, + SpotOrderBookDepthV2, + SpotOrderInfoV2, SpotOrderRequestV2, SpotPlanOrderRequestV2, + SpotPlanSubOrderV2, + SpotSubAccountAssetsV2, + SpotSubAccountDepositRecordV2, SpotSubAccountTransferRequestV2, + SpotSymbolInfoV2, + SpotTickerV2, + SpotTradeV2, SpotTransactionRecordV2, + SpotTransferRecordV2, SpotTransferRequestV2, + SpotVipFeeRateV2, SpotWhaleNetFlowV2, + SpotWithdrawalRecordV2, SpotWithdrawalRequestV2, SubAccountApiKeyListV2, SubDepositRecordsRequestV2, + SubmitSpotBatchOrdersResponseV2, SubWithdrawalRecordsRequestV2, SubWithdrawalRequestV2, UpdateFuturesFollowerSettingsRequestV2, @@ -596,19 +621,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); } @@ -616,7 +647,7 @@ export class RestClientV2 extends BaseRestClient { symbol: string; precision?: string; limit?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/spot/market/merge-depth', params); } @@ -624,30 +655,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); } @@ -657,62 +690,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); } @@ -722,46 +773,56 @@ 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> { + ): Promise> { 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> { + ): Promise> { 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, @@ -774,25 +835,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, @@ -801,34 +862,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, @@ -837,11 +911,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); } @@ -849,7 +925,7 @@ export class RestClientV2 extends BaseRestClient { coin: string; chain?: string; size: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/spot/wallet/deposit-address', params); } @@ -858,42 +934,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); + } + /** * * diff --git a/src/types/response/index.ts b/src/types/response/index.ts index a98abe2..bc58c8c 100644 --- a/src/types/response/index.ts +++ b/src/types/response/index.ts @@ -2,3 +2,4 @@ export * from './v1/futures'; export * from './v1/shared'; export * from './v1/spot'; export * from './v2/common'; +export * from './v2/spot'; diff --git a/src/types/response/v2/spot.ts b/src/types/response/v2/spot.ts new file mode 100644 index 0000000..018f672 --- /dev/null +++ b/src/types/response/v2/spot.ts @@ -0,0 +1,400 @@ +/** + * + * * Spot | Market + * + */ + +export interface SpotCoinInfoV2 { + coinId: string; + coin: string; + transfer: boolean; + chains: { + 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 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 interface SpotCandlestickV2 { + [0]: string; // timestamp + [1]: string; // open + [2]: string; // high + [3]: string; // low + [4]: string; // close + [5]: string; // baseVolume + [6]: string; // usdtVolume + [7]: 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 { + nextFlag: boolean; + idLessThan: string; + orderList: { + 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 SpotSubAccountAssetsV2 { + userId: number; + assetsList: { + coin: string; + available: string; + limitAvailable: string; + frozen: string; + locked: string; + uTime: string; + }[]; +} + +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; +} From 68c5d7d89ddf1b4b560cbc128e01df4f7895523f Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Fri, 13 Dec 2024 11:54:14 +0100 Subject: [PATCH 04/13] feat(): added futures response types --- src/rest-client-v2.ts | 315 ++++++++++------ src/types/response/index.ts | 1 + src/types/response/v2/futures.ts | 614 +++++++++++++++++++++++++++++++ 3 files changed, 810 insertions(+), 120 deletions(-) create mode 100644 src/types/response/v2/futures.ts diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index f63693d..ebbbe10 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -23,16 +23,28 @@ import { CreateVirtualSubRequestV2, FundingAssetsV2, FuturesAccountBillRequestV2, + FuturesAccountBillV2, + FuturesAccountListV2, + FuturesAccountV2, FuturesActiveBuySellVolumeV2, FuturesActiveLongShortAccountV2, FuturesActiveLongShortPositionV2, FuturesBatchCancelOrderRequestV2, FuturesBatchOrderRequestV2, + FuturesBatchOrderResponseV2, FuturesCancelAllOrdersRequestV2, + FuturesCancelAllOrdersV2, FuturesCancelOrderRequestV2, FuturesCancelPlanOrderRequestV2, + FuturesCancelPlanOrderV2, FuturesCandlesRequestV2, + FuturesCandlestickV2, + FuturesClosePositionResponseV2, + FuturesContractConfigV2, + FuturesDiscountRateV2, + FuturesFillV2, FuturesFlashClosePositionsRequestV2, + FuturesFundingTimeV2, FuturesGetHistoricalFillsRequestV2, FuturesGetHistoryOrdersRequestV2, FuturesGetHistoryPlanOrdersRequestV2, @@ -40,17 +52,32 @@ import { FuturesGetOrderFillsRequestV2, FuturesGetOrderRequestV2, FuturesGetPlanOrdersRequestV2, + FuturesHistoricalFundingRateV2, FuturesHistoricalPositionsRequestV2, + FuturesHistoricalPositionV2, FuturesHistoricTradesRequestV2, + FuturesHistoryOrdersV2, + FuturesHistoryPlanOrderV2, + FuturesInterestExchangeRateV2, FuturesInterestHistoryRequestV2, + FuturesInterestHistoryV2, + FuturesInterestRateHistoryV2, FuturesLongShortRatioV2, FuturesMergeDepthRequestV2, + FuturesMergeDepthV2, FuturesModifyOrderRequestV2, FuturesModifyPlanOrderRequestV2, FuturesModifyTPSLOrderRequestV2, FuturesOpenCountRequestV2, + FuturesOpenInterestV2, + FuturesOpenOrdersV2, + FuturesOrderDetailV2, + FuturesOrderFillsV2, + FuturesPendingPlanOrderV2, FuturesPlaceOrderRequestV2, FuturesPlanOrderRequestV2, + FuturesPositionTierV2, + FuturesPositionV2, FuturesProductTypeV2, FuturesRecentTradesRequestV2, FuturesReversalOrderRequestV2, @@ -59,9 +86,14 @@ import { FuturesSetMarginModeRequestV2, FuturesSetPositionMarginRequestV2, FuturesSingleAccountRequestV2, + FuturesSubAccountAssetsV2, + FuturesSymbolPriceV2, + FuturesTickerV2, FuturesTPSLOrderRequestV2, FuturesTraderSymbolSettingRequestV2, FuturesTransactionRecordV2, + FuturesTriggerSubOrderV2, + FuturesVipFeeRateV2, GetAnnouncementsRequestV2, GetBorrowHistoryRequestV2, GetConvertBGBHistoryRequestV2, @@ -136,6 +168,8 @@ import { P2PMerchantOrderV2, RedeemSavingsRequestV2, RepayLoanRequestV2, + SetLeverageResponseV2, + SetMarginModeResponseV2, SpotAccountAssetV2, SpotAccountBillV2, SpotAccountInfoV2, @@ -990,97 +1024,99 @@ export class RestClientV2 extends BaseRestClient { * */ - getFuturesVIPFeeRate(): Promise> { + getFuturesVIPFeeRate(): Promise> { return this.get('/api/v2/mix/market/vip-fee-rate'); } getFuturesInterestRateHistory(params: { coin: string; - }): Promise> { + }): Promise> { return this.get('/api/v2/mix/market/union-interest-rate-history', params); } + getFuturesInterestExchangeRate(): Promise< + APIResponse + > { + 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> { 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); } @@ -1089,21 +1125,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); } @@ -1115,75 +1158,81 @@ 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> { 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> { + ): Promise> { return this.getPrivate('/api/v2/mix/account/bill', params); } @@ -1196,7 +1245,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); } @@ -1204,20 +1253,20 @@ 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> { return this.getPrivate('/api/v2/mix/position/history-position', params); } @@ -1227,79 +1276,93 @@ 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> { + ): Promise> { return this.getPrivate('/api/v2/mix/order/fills', params); } getFuturesHistoricOrderFills( params: FuturesGetHistoricalFillsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/mix/order/fill-history', params); } getFuturesOpenOrders( params: FuturesGetOpenOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/mix/order/orders-pending', params); } getFuturesHistoricOrders( params: FuturesGetHistoryOrdersRequestV2, - ): Promise> { + ): Promise> { 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); } @@ -1309,53 +1372,65 @@ 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); } - futuresCancelPlanOrder( - params: FuturesCancelPlanOrderRequestV2, - ): Promise> { - return this.postPrivate('/api/v2/mix/order/cancel-plan-order', params); - } - getFuturesPlanOrders( params: FuturesGetPlanOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/mix/order/orders-plan-pending', params); } + futuresCancelPlanOrder( + params: FuturesCancelPlanOrderRequestV2, + ): Promise> { + return this.postPrivate('/api/v2/mix/order/cancel-plan-order', params); + } + getFuturesHistoricPlanOrders( params: FuturesGetHistoryPlanOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/mix/order/orders-plan-history', params); } diff --git a/src/types/response/index.ts b/src/types/response/index.ts index bc58c8c..f9c806c 100644 --- a/src/types/response/index.ts +++ b/src/types/response/index.ts @@ -2,4 +2,5 @@ export * from './v1/futures'; export * from './v1/shared'; export * from './v1/spot'; export * from './v2/common'; +export * from './v2/futures'; export * from './v2/spot'; diff --git a/src/types/response/v2/futures.ts b/src/types/response/v2/futures.ts new file mode 100644 index 0000000..fbe4d84 --- /dev/null +++ b/src/types/response/v2/futures.ts @@ -0,0 +1,614 @@ +/** + * + * * Futures | Market + * + */ + +export interface FuturesVipFeeRateV2 { + level: string; + dealAmount: string; + assetAmount: string; + takerFeeRate: string; + makerFeeRate: string; + btcWithdrawAmount: string; + usdtWithdrawAmount: string; +} + +export interface FuturesInterestRateHistoryV2 { + coin: string; + historyInterestRateList: { + ts: string; + annualInterestRate: string; + dailyInterestRate: string; + }[]; +} + +export interface FuturesInterestExchangeRateV2 { + coin: string; + exchangeRateList: { + tier: string; + minAmount: string; + maxAmount: string; + exchangeRate: string; + }[]; +} + +export interface FuturesDiscountRateV2 { + coin: string; + userLimit: string; + totalLimit: string; + discountRateList: { + tier: string; + minAmount: string; + maxAmount: string; + discountRate: string; + }[]; +} + +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 interface FuturesCandlestickV2 { + [0]: string; // timestamp + [1]: string; // open + [2]: string; // high + [3]: string; // low + [4]: string; // close + [5]: string; // baseVolume + [6]: string; // quoteVolume +} + +export interface FuturesOpenInterestV2 { + openInterestList: { + symbol: string; + size: string; + }[]; + ts: 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 FuturesAccountListV2 { + 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 FuturesSubAccountAssetsV2 { + userId: number; + assetList: { + marginCoin: string; + locked: string; + available: string; + crossedMaxAvailable: string; + isolatedMaxAvailable: string; + maxTransferOut: string; + accountEquity: string; + usdtEquity: string; + btcEquity: string; + unrealizedPL: string; + coupon: string; + }[]; +} + +export interface FuturesInterestHistoryV2 { + nextSettleTime: string; + borrowAmount: string; + borrowLimit: string; + interestList: { + coin: string; + liability: string; + interestFreeLimit: string; + interestLimit: string; + hourInterestRate: string; + interest: string; + cTime: string; + }[]; + 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 { + bills: { + billId: string; + symbol: string; + amount: string; + fee: string; + feeByCoupon: string; + businessType: string; + coin: string; + balance: string; + cTime: string; + }[]; + endId: 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 FuturesHistoricalPositionV2 { + list: { + 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; + }[]; + endId: 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 FuturesOrderFillsV2 { + fillList: { + 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; + }[]; + endId: string; +} + +export interface FuturesOpenOrdersV2 { + entrustedList: { + 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; + }[]; + endId: string; +} + +export interface FuturesHistoryOrdersV2 { + entrustedList: { + 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; + }[]; + endId: 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 { + entrustedList: { + 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; + }[]; + endId: string; +} + +export interface FuturesCancelPlanOrderV2 { + successList: { + orderId: string; + clientOid: string; + }[]; + failureList: { + orderId: string; + clientOid: string; + errorMsg: string; + }[]; +} + +export interface FuturesHistoryPlanOrderV2 { + entrustedList: { + 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; + }[]; + endId: string; +} From 6cabbe5edb89f894461bb7aec4b25586270e7303 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Fri, 13 Dec 2024 12:12:16 +0100 Subject: [PATCH 05/13] feat(): added all broker response types --- src/rest-client-v2.ts | 67 ++++++++++---- src/types/response/index.ts | 1 + src/types/response/v2/broker.ts | 159 ++++++++++++++++++++++++++++++++ 3 files changed, 208 insertions(+), 19 deletions(-) create mode 100644 src/types/response/v2/broker.ts diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index ebbbe10..05f70c3 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -16,6 +16,9 @@ import { ConvertTradeResponseV2, CopyTradingProductTypeV2, CreateSubAccountApiKeyRequestV2, + CreateSubaccountApiKeyResponseV2, + CreateSubaccountDepositAddressV2, + CreateSubaccountResponseV2, CreateVirtualSubAccountAndApiKeyV2, CreateVirtualSubAccountApiKeyV2, CreateVirtualSubAccountV2, @@ -158,6 +161,8 @@ import { ModifyFuturesTraderOrderTPSLRequestV2, ModifyLoanPledgeRateRequestV2, ModifySubAccountApiKeyRequestV2, + ModifySubaccountApiKeyResponseV2, + ModifySubaccountResponseV2, ModifySubRequestV2, ModifyVirtualSubAccountApiKeyV2, ModifyVirtualSubApiKeyRequestV2, @@ -214,6 +219,13 @@ import { SpotWithdrawalRecordV2, SpotWithdrawalRequestV2, SubAccountApiKeyListV2, + SubaccountApiKeyV2, + SubaccountDepositV2, + SubaccountEmailV2, + SubaccountFutureAssetsV2, + SubaccountsListV2, + SubaccountSpotAssetsV2, + SubaccountWithdrawalV2, SubDepositRecordsRequestV2, SubmitSpotBatchOrdersResponseV2, SubWithdrawalRecordsRequestV2, @@ -1451,33 +1463,45 @@ 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> { 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); } @@ -1485,7 +1509,7 @@ export class RestClientV2 extends BaseRestClient { subUid: string; coin?: string; assetType?: 'hold_only' | 'all'; - }): Promise> { + }): Promise> { return this.getPrivate( '/api/v2/broker/account/subaccount-spot-assets', params, @@ -1495,7 +1519,7 @@ export class RestClientV2 extends BaseRestClient { getSubaccountFuturesAssets(params: { subUid: string; productType: FuturesProductTypeV2; - }): Promise> { + }): Promise> { return this.getPrivate( '/api/v2/broker/account/subaccount-future-assets', params, @@ -1506,16 +1530,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, @@ -1526,7 +1553,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, @@ -1535,32 +1562,34 @@ export class RestClientV2 extends BaseRestClient { subaccountDepositRecords( params: SubDepositRecordsRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate('/api/v2/broker/subaccount-deposit', params); } subaccountWithdrawalRecords( params: SubWithdrawalRecordsRequestV2, - ): Promise> { + ): Promise> { 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, @@ -1569,7 +1598,7 @@ export class RestClientV2 extends BaseRestClient { modifySubaccountApiKey( params: ModifySubAccountApiKeyRequestV2, - ): Promise> { + ): Promise> { return this.postPrivate( '/api/v2/broker/manage/modify-subaccount-apikey', params, diff --git a/src/types/response/index.ts b/src/types/response/index.ts index f9c806c..235f9c8 100644 --- a/src/types/response/index.ts +++ b/src/types/response/index.ts @@ -1,6 +1,7 @@ export * from './v1/futures'; export * from './v1/shared'; export * from './v1/spot'; +export * from './v2/broker'; export * from './v2/common'; export * from './v2/futures'; export * from './v2/spot'; diff --git a/src/types/response/v2/broker.ts b/src/types/response/v2/broker.ts new file mode 100644 index 0000000..dffc862 --- /dev/null +++ b/src/types/response/v2/broker.ts @@ -0,0 +1,159 @@ +/** + * + * * Broker | Subaccount + * + */ + +export interface CreateSubaccountResponseV2 { + subUid: string; + subaccountName: string; + status: string; + permList: string[]; + label: string; + cTime: string; +} + +export interface SubaccountsListV2 { + hasNextPage: boolean; + idLessThan: number; + subList: { + 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 SubaccountSpotAssetsV2 { + assetsList: { + coin: string; + available: string; + frozen: string; + locked: string; + uTime: string; + }[]; +} + +export interface SubaccountFutureAssetsV2 { + assetsList: { + 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 SubaccountWithdrawalV2 { + resultList: { + 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; + }[]; + endId: 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[]; +} From 8c736b0d3c089e65f808b896ffbe869f6c0e53fc Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Fri, 13 Dec 2024 13:14:30 +0100 Subject: [PATCH 06/13] feat(): added margin response types --- src/rest-client-v2.ts | 135 ++++++++++--- src/types/response/index.ts | 1 + src/types/response/v2/margin.ts | 335 ++++++++++++++++++++++++++++++++ 3 files changed, 446 insertions(+), 25 deletions(-) create mode 100644 src/types/response/v2/margin.ts diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index 05f70c3..f5a5861 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -24,6 +24,10 @@ import { CreateVirtualSubAccountV2, CreateVirtualSubApiKeyRequestV2, CreateVirtualSubRequestV2, + CrossInterestRateAndLimitResponseV2, + CrossMaxBorrowableResponseV2, + CrossMaxTransferableResponseV2, + CrossTierConfigurationResponseV2, FundingAssetsV2, FuturesAccountBillRequestV2, FuturesAccountBillV2, @@ -151,11 +155,27 @@ import { GetSpotWithdrawalRecordRequestV2, GetSubAccountsRequestV2, GetTradeRateRequestV2, + IsolatedInterestRateAndLimitResponseV2, IsolatedMarginBorrowingRatioV2, + IsolatedMaxBorrowableResponseV2, + IsolatedMaxTransferableResponseV2, + IsolatedTierConfigurationResponseV2, LeveragedLongShortRatioV2, + MarginAccountAssetV2, MarginBatchOrdersRequestV2, + MarginBatchOrdersResponseV2, + MarginBorrowHistoryV2, + MarginCurrencyV2, + MarginCurrentOrdersV2, + MarginFinancialHistoryV2, + MarginHistoryOrdersV2, + MarginInterestHistoryV2, + MarginLiquidationHistoryV2, + MarginLiquidationOrdersV2, MarginLoanGrowthRateV2, + MarginOrderFillsV2, MarginPlaceOrderRequestV2, + MarginRepaymentHistoryV2, MarginTransactionRecordV2, MarginType, ModifyFuturesTraderOrderTPSLRequestV2, @@ -1619,7 +1639,7 @@ export class RestClientV2 extends BaseRestClient { * */ - getMarginCurrencies(): Promise> { + getMarginCurrencies(): Promise> { return this.get('/api/v2/margin/currencies'); } @@ -1632,7 +1652,7 @@ export class RestClientV2 extends BaseRestClient { getMarginBorrowHistory( marginType: MarginType, params: GetBorrowHistoryRequestV2, - ): Promise> { + ): Promise> { assertMarginType(marginType); return this.getPrivate( `/api/v2/margin/${marginType}/borrow-history`, @@ -1643,7 +1663,7 @@ export class RestClientV2 extends BaseRestClient { getMarginRepayHistory( marginType: MarginType, params: GetRepayHistoryRequestV2, - ): Promise> { + ): Promise> { assertMarginType(marginType); return this.getPrivate( `/api/v2/margin/${marginType}/repay-history`, @@ -1654,7 +1674,7 @@ export class RestClientV2 extends BaseRestClient { getMarginInterestHistory( marginType: MarginType, params: GetInterestHistoryRequestV2, - ): Promise> { + ): Promise> { assertMarginType(marginType); return this.getPrivate( `/api/v2/margin/${marginType}/interest-history`, @@ -1665,7 +1685,7 @@ export class RestClientV2 extends BaseRestClient { getMarginLiquidationHistory( marginType: MarginType, params: GetLiquidationHistoryRequestV2, - ): Promise> { + ): Promise> { assertMarginType(marginType); return this.getPrivate( `/api/v2/margin/${marginType}/liquidation-history`, @@ -1676,7 +1696,7 @@ export class RestClientV2 extends BaseRestClient { getMarginFinancialHistory( marginType: MarginType, params: GetFinancialHistoryRequestV2, - ): Promise> { + ): Promise> { assertMarginType(marginType); return this.getPrivate( `/api/v2/margin/${marginType}/financial-records`, @@ -1693,7 +1713,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`, @@ -1704,11 +1724,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`, @@ -1719,10 +1747,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`, @@ -1730,7 +1769,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`); } @@ -1738,7 +1784,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', @@ -1749,7 +1797,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', @@ -1760,7 +1812,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', @@ -1771,7 +1828,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); } @@ -1779,7 +1840,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', @@ -1790,7 +1858,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', @@ -1807,7 +1882,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); } @@ -1815,7 +1895,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`, @@ -1830,7 +1910,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`, @@ -1844,7 +1929,7 @@ export class RestClientV2 extends BaseRestClient { symbol: string; orderIdList: string[]; }, - ): Promise> { + ): Promise> { assertMarginType(marginType); return this.postPrivate( '/api/v2/margin/${marginType}/batch-cancel-order', @@ -1855,7 +1940,7 @@ export class RestClientV2 extends BaseRestClient { getMarginOpenOrders( marginType: MarginType, params: GetMarginCurrentOrdersRequestV2, - ): Promise> { + ): Promise> { assertMarginType(marginType); return this.getPrivate(`/api/v2/margin/${marginType}/open-orders`, params); } @@ -1863,7 +1948,7 @@ export class RestClientV2 extends BaseRestClient { getMarginHistoricOrders( marginType: MarginType, params: GetHistoryOrdersRequestV2, - ): Promise> { + ): Promise> { assertMarginType(marginType); return this.getPrivate( `/api/v2/margin/${marginType}/history-orders`, @@ -1874,7 +1959,7 @@ export class RestClientV2 extends BaseRestClient { getMarginHistoricOrderFills( marginType: MarginType, params: GetMarginOrderFillsRequestV2, - ): Promise> { + ): Promise> { assertMarginType(marginType); return this.getPrivate(`/api/v2/margin/${marginType}/fills`, params); } @@ -1882,7 +1967,7 @@ export class RestClientV2 extends BaseRestClient { getMarginLiquidationOrders( marginType: MarginType, params: GetMarginLiquidationOrdersRequestV2, - ): Promise> { + ): Promise> { assertMarginType(marginType); return this.getPrivate( `/api/v2/margin/${marginType}/liquidation-order`, diff --git a/src/types/response/index.ts b/src/types/response/index.ts index 235f9c8..34af543 100644 --- a/src/types/response/index.ts +++ b/src/types/response/index.ts @@ -4,4 +4,5 @@ export * from './v1/spot'; export * from './v2/broker'; export * from './v2/common'; export * from './v2/futures'; +export * from './v2/margin'; export * from './v2/spot'; diff --git a/src/types/response/v2/margin.ts b/src/types/response/v2/margin.ts new file mode 100644 index 0000000..1073155 --- /dev/null +++ b/src/types/response/v2/margin.ts @@ -0,0 +1,335 @@ +/** + * + * * 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 MarginBorrowHistoryV2 { + resultList: { + loanId: string; + coin: string; + borrowAmount: string; + borrowType: string; + cTime: string; + uTime: string; + }[]; + maxId: string; + minId: string; +} + +export interface MarginRepaymentHistoryV2 { + resultList: { + repayId: string; + coin: string; + repayAmount: string; + repayType: string; + repayInterest: string; + repayPrincipal: string; + symbol: string; + cTime: string; + uTime: string; + }[]; + maxId: string; + minId: string; +} + +export interface MarginInterestHistoryV2 { + resultList: { + interestId: string; + interestCoin: string; + dailyInterestRate: string; + loanCoin: string; + interestAmount: string; + interstType: string; + symbol: string; + cTime: string; + uTime: string; + }[]; + maxId: string; + minId: string; +} + +export interface MarginLiquidationHistoryV2 { + resultList: { + liqId: string; + symbol: string; + liqStartTime: string; + liqEndTime: string; + liqRiskRatio: string; + totalAssets: string; + totalDebt: string; + liqFee: string; + cTime: string; + uTime: string; + }[]; + maxId: string; + minId: string; +} + +export interface MarginFinancialHistoryV2 { + resultList: { + coin: string; + symbol: string; + marginId: string; + amount: string; + balance: string; + fee: string; + marginType: string; + cTime: string; + uTime: string; + }[]; + maxId: string; + minId: 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 MarginCurrentOrdersV2 { + orderList: { + 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; + }[]; + maxId: string; + minId: string; +} + +export interface MarginHistoryOrdersV2 { + orderList: { + 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; + }[]; + maxId: string; + minId: string; +} + +export interface MarginOrderFillsV2 { + fills: { + 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; + }[]; + minId: string; + maxId: string; +} + +export interface MarginLiquidationOrdersV2 { + resultList: { + 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; + }[]; + idLessThan: string; +} From d2995530f1a592c26e541ffa5aa569443f7c0808 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Mon, 16 Dec 2024 12:08:02 +0100 Subject: [PATCH 07/13] feat(): added copytrading response types --- src/rest-client-v2.ts | 158 +++++++--- src/types/response/index.ts | 1 + src/types/response/v2/copy-trading.ts | 416 ++++++++++++++++++++++++++ 3 files changed, 529 insertions(+), 46 deletions(-) create mode 100644 src/types/response/v2/copy-trading.ts diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index f5a5861..0c6f5af 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -28,6 +28,28 @@ import { CrossMaxBorrowableResponseV2, CrossMaxTransferableResponseV2, CrossTierConfigurationResponseV2, + CTFuturesFollowerCurrentOrdersV2, + CTFuturesFollowerHistoryOrdersV2, + CTFuturesFollowerMyTradersV2, + CTFuturesFollowerSettingsV2, + CTFuturesTraderCurrentOrderV2, + CTFuturesTraderHistoryOrderV2, + CTFuturesTraderHistoryProfitSummaryV2, + CTFuturesTraderMyFollowersV2, + CTFuturesTraderProfitShareHistoryV2, + CTFuturesTraderSymbolSettingsV2, + CTFuturesTraderTotalOrderSummaryV2, + CTSpotFollowerCurrentOrdersV2, + CTSpotFollowerFollowConfigurationV2, + CTSpotFollowerHistoryOrdersV2, + CTSpotFollowerMyTradersV2, + CTSpotTraderCurrentTrackingOrdersV2, + CTSpotTraderFollowerListV2, + CTSpotTraderHistoryOrdersV2, + CTSpotTraderHistoryProfitSharingV2, + CTSpotTraderProfitSummaryV2, + CTSpotTraderTotalOrderDetailV2, + CTSpotTraderUnrealizedProfitV2, FundingAssetsV2, FuturesAccountBillRequestV2, FuturesAccountBillV2, @@ -1993,7 +2015,7 @@ export class RestClientV2 extends BaseRestClient { getFuturesTraderCurrentOrder( params: GetFuturesTraderCurrentOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/mix-trader/order-current-track', params, @@ -2002,7 +2024,7 @@ export class RestClientV2 extends BaseRestClient { getFuturesTraderHistoryOrders( params: GetFuturesTraderHistoryOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/mix-trader/order-history-track', params, @@ -2011,24 +2033,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, @@ -2039,7 +2065,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, @@ -2050,14 +2084,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, @@ -2066,7 +2116,7 @@ export class RestClientV2 extends BaseRestClient { getFuturesTraderSymbolSettings(params: { productType: CopyTradingProductTypeV2; - }): Promise> { + }): Promise> { return this.getPrivate( '/api/v2/copy/mix-trader/config-query-symbols', params, @@ -2075,7 +2125,7 @@ export class RestClientV2 extends BaseRestClient { updateFuturesTraderSymbolSettings(params: { settingList: FuturesTraderSymbolSettingRequestV2[]; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/copy/mix-trader/config-setting-symbols', params, @@ -2086,7 +2136,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, @@ -2095,7 +2145,7 @@ export class RestClientV2 extends BaseRestClient { getFuturesTraderFollowers( params?: GetFuturesTraderFollowersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/mix-trader/config-query-followers', params, @@ -2104,7 +2154,7 @@ export class RestClientV2 extends BaseRestClient { removeFuturesTraderFollower(params: { followerUid: string; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/copy/mix-trader/config-remove-follower', params, @@ -2121,7 +2171,7 @@ export class RestClientV2 extends BaseRestClient { getFuturesFollowerCurrentOrders( params: GetFollowerFuturesCurrentTrackingOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/mix-follower/query-current-orders', params, @@ -2130,7 +2180,7 @@ export class RestClientV2 extends BaseRestClient { getFuturesFollowerHistoryOrders( params: GetFollowerFuturesHistoryTrackingOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/mix-follower/query-history-orders', params, @@ -2139,25 +2189,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, @@ -2166,14 +2220,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, @@ -2182,7 +2244,7 @@ export class RestClientV2 extends BaseRestClient { unfollowFuturesTrader(params: { traderId: string; - }): Promise> { + }): Promise> { return this.postPrivate('/api/v2/copy/mix-follower/cancel-trader', params); } @@ -2220,13 +2282,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, @@ -2237,11 +2299,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'); } @@ -2249,7 +2311,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, @@ -2258,7 +2320,7 @@ export class RestClientV2 extends BaseRestClient { getSpotTraderHistoryOrders( params: GetSpotTraderHistoryOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/spot-trader/order-history-track', params, @@ -2267,7 +2329,7 @@ export class RestClientV2 extends BaseRestClient { getSpotTraderCurrentOrders( params: GetSpotTraderCurrentOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/spot-trader/order-current-track', params, @@ -2277,7 +2339,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, @@ -2287,7 +2349,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, @@ -2296,7 +2358,7 @@ export class RestClientV2 extends BaseRestClient { removeSpotTraderFollowers(params: { followerUid: string; - }): Promise> { + }): Promise> { return this.postPrivate( '/api/v2/copy/spot-trader/config-remove-follower', params, @@ -2309,7 +2371,7 @@ export class RestClientV2 extends BaseRestClient { getSpotTraderFollowers( params: GetSpotTraderFollowersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/spot-trader/config-query-followers', params, @@ -2326,7 +2388,7 @@ export class RestClientV2 extends BaseRestClient { cancelSpotFollowerOrder(params: { trackingNoList: string[]; - }): Promise> { + }): Promise> { return this.postPrivate('/api/v2/copy/spot-follower/stop-order', params); } @@ -2335,7 +2397,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); } @@ -2343,7 +2405,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); } @@ -2352,13 +2414,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, @@ -2367,13 +2431,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, @@ -2382,7 +2446,7 @@ export class RestClientV2 extends BaseRestClient { getSpotFollowerOpenOrders( params: GetSpotFollowerOpenOrdersRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate( '/api/v2/copy/spot-follower/query-current-orders', params, @@ -2392,14 +2456,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); } diff --git a/src/types/response/index.ts b/src/types/response/index.ts index 34af543..e1eef1e 100644 --- a/src/types/response/index.ts +++ b/src/types/response/index.ts @@ -3,6 +3,7 @@ export * from './v1/shared'; export * from './v1/spot'; export * from './v2/broker'; export * from './v2/common'; +export * from './v2/copy-trading'; export * from './v2/futures'; export * from './v2/margin'; export * from './v2/spot'; diff --git a/src/types/response/v2/copy-trading.ts b/src/types/response/v2/copy-trading.ts new file mode 100644 index 0000000..7c51776 --- /dev/null +++ b/src/types/response/v2/copy-trading.ts @@ -0,0 +1,416 @@ +/** + * + * + * Copy Trading | Future copy trading | Trader Api + * + * + */ + +export interface CTFuturesTraderCurrentOrderV2 { + trackingList: { + trackingNo: string; + openOrderId: string; + symbol: string; + posSide: string; + openLeverage: string; + openPriceAvg: string; + openTime: string; + openSize: string; + presetStopSurplusPrice: string; + presetStopLossPrice: string; + openFee: string; + followCount: string; + }[]; + endId: string; +} + +export interface CTFuturesTraderHistoryOrderV2 { + trackingList: { + 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; + }[]; + endId: string; +} + +export interface CTFuturesTraderTotalOrderSummaryV2 { + roi: string; + tradingOrderNum: string; + totalFollowerNum: string; + currentFollowerNum: string; + totalpl: string; + gainNum: string; + lossNum: string; + winRate: string; + tradingPairsAvailableList: string[]; + lastWeekRoiList: { + rate: string; + ctime: string; + }[]; + lastWeekProfitList: { + amount: string; + ctime: string; + }[]; + lastMonthRoiList: { + rate: string; + ctime: string; + }[]; + lastMonthProfitList: { + amount: string; + ctime: string; + }[]; + totalEquity: string; +} + +export interface CTFuturesTraderHistoryProfitSummaryV2 { + profitSummary: { + yesterdayProfit: string; + sumProfit: string; + waitProfit: string; + yesterdayTime: string; + }; + profitHistoryList: { + coin: string; + profitCount: string; + lastProfitTime: string; + }[]; +} + +export interface CTFuturesTraderProfitShareHistoryV2 { + profitList: { + profitId: string; + coin: string; + profit: string; + nickName: string; + profitTime: string; + }[]; + 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 CTFuturesFollowerHistoryOrdersV2 { + trackingList: { + 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; + }[]; + endId: string; +} + +export interface CTFuturesFollowerSettingsV2 { + followerEnable: string; + detailList: { + symbol: string; + productType: string; + marginType: string; + marginCoin: string; + leverType: string; + longLeverage: string; + shortLeverage: string; + traceType: string; + traceValue: string; + maxHoldSize: string; + stopSurplusRatio: string; + stopLossRatio: string; + }[]; +} + +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 CTSpotTraderHistoryProfitSharingV2 { + endId: string; + profitList: { + profitId: string; + coin: string; + distributeRatio: string; + profit: string; + followerName: string; + profitTime: string; + }[]; +} + +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: { + rate: string; + ctime: string; + }[]; + lastMonthRoiList: { + rate: string; + ctime: string; + }[]; + lastWeekProfitList: { + amount: string; + ctime: string; + }[]; + lastMonthProfitList: { + amount: string; + ctime: string; + }[]; +} + +export interface CTSpotTraderHistoryOrdersV2 { + endId: string; + trackingList: { + 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 CTSpotTraderCurrentTrackingOrdersV2 { + endId: string; + trackingList: { + 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 CTSpotTraderFollowerListV2 { + accountEquity: string; + isRemove: string; + followerHeadPic: string | null; + followerName: string; + followerUid: string; + followerTime: string; +} + +/** + * + * + * Copy Trading | Spot copy trading | Follower api + * + * + */ + +export interface CTSpotFollowerMyTradersV2 { + resultList: { + certificationType: string; + traceTotalAmount: string; + traceTotalNetProfit: string; + traceTotalProfit: string; + traderName: string; + traderId: string; + maxFollowLimit: string; + bgbMaxFollowLimit: string; + followCount: string; + bgbFollowCount: string; + followerTime: string; + }[]; +} + +export interface CTSpotFollowerFollowConfigurationV2 { + enable: string; + profitRate: string; + settledInDays: string; + tradeSettingList: { + maxTraceAmount: string; + stopLossRation: string; + stopSurplusRation: string; + symbol: string; + traceType: string; + }[]; + tradeSymbolSettingList: { + 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; + }[]; + traderHeadPic: string; + traderName: string; +} + +export interface CTSpotFollowerHistoryOrdersV2 { + endId: string; + trackingList: { + 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 CTSpotFollowerCurrentOrdersV2 { + endId: string; + trackingList: { + 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; + }[]; +} From c68899574a985c4040e7fa11e560d64f0365ba40 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Mon, 16 Dec 2024 12:26:57 +0100 Subject: [PATCH 08/13] feat(): added all Earn response types --- src/rest-client-v2.ts | 139 +++++++++++---- src/types/response/index.ts | 1 + src/types/response/v2/earn.ts | 306 ++++++++++++++++++++++++++++++++++ 3 files changed, 411 insertions(+), 35 deletions(-) create mode 100644 src/types/response/v2/earn.ts diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index 0c6f5af..8abc82f 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -50,6 +50,24 @@ import { CTSpotTraderProfitSummaryV2, CTSpotTraderTotalOrderDetailV2, CTSpotTraderUnrealizedProfitV2, + EarnLoanCurrenciesV2, + EarnLoanDebtsV2, + EarnLoanHistoryV2, + EarnLoanLiquidationRecordsV2, + EarnLoanOrdersV2, + EarnLoanPledgeRateHistoryV2, + EarnLoanRepayHistoryV2, + EarnLoanRepayResponseV2, + EarnSavingsAccountV2, + EarnSavingsAssetsV2, + EarnSavingsProductsV2, + EarnSavingsRecordsV2, + EarnSavingsSubscriptionDetailV2, + EarnSharkfinAccountV2, + EarnSharkfinAssetsV2, + EarnSharkfinProductsV2, + EarnSharkfinRecordsV2, + EarnSharkfinSubscriptionDetailV2, FundingAssetsV2, FuturesAccountBillRequestV2, FuturesAccountBillV2, @@ -2480,30 +2498,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); } @@ -2511,25 +2529,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); } @@ -2541,7 +2579,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); } @@ -2557,42 +2602,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); } @@ -2604,17 +2654,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); } @@ -2622,43 +2683,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 e1eef1e..c0a4a58 100644 --- a/src/types/response/index.ts +++ b/src/types/response/index.ts @@ -4,6 +4,7 @@ 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/v2/earn.ts b/src/types/response/v2/earn.ts new file mode 100644 index 0000000..1caed6e --- /dev/null +++ b/src/types/response/v2/earn.ts @@ -0,0 +1,306 @@ +/** + * + * + * 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 EarnSavingsAssetsV2 { + resultList: { + 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; + }[]; + }[]; + endId: string; +} + +export interface EarnSavingsRecordsV2 { + resultList: { + orderId: string; + coinName: string; + settleCoinName: string; + productType: string; + period: string; + productLevel: string; + amount: string; + ts: string; + orderType: string; + }[]; + 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 EarnSharkfinProductsV2 { + resultList: { + 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; + }[]; + endId: string; +} + +export interface EarnSharkfinAccountV2 { + btcSubscribeAmount: string; + usdtSubscribeAmount: string; + btcHistoricalAmount: string; + usdtHistoricalAmount: string; + btcTotalEarning: string; + usdtTotalEarning: string; +} + +export interface EarnSharkfinAssetsV2 { + resultList: { + productId: string; + interestStartTime: string; + interestEndTime: string; + productCoin: string; + subscribeCoin: string; + trend: string; + settleTime: string; + interestAmount: string; + productStatus: string; + }[]; + endId: string; +} + +export interface EarnSharkfinRecordsV2 { + resultList: { + orderId: string; + product: string; + period: string; + amount: string; + ts: string; + type: string; + }[]; + 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 EarnLoanCurrenciesV2 { + loanInfos: { + coin: string; + hourRate7D: string; + rate7D: string; + hourRate30D: string; + rate30D: string; + minUsdt: string; + maxUsdt: string; + min: string; + max: string; + }[]; + pledgeInfos: { + coin: string; + initRate: string; + supRate: string; + forceRate: string; + minUsdt: string; + maxUsdt: string; + }[]; +} + +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 EarnLoanDebtsV2 { + pledgeInfos: { + coin: string; + amount: string; + amountUsdt: string; + }[]; + loanInfos: { + coin: string; + amount: string; + amountUsdt: string; + }[]; +} + +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; +} From f35e32a83607646212a9bc45361ee791b76b9c0f Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Mon, 16 Dec 2024 12:28:46 +0100 Subject: [PATCH 09/13] chore(): version bump --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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", From ba6b83aa14542eda6a9437ab3221741384f86b54 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Tue, 17 Dec 2024 13:44:14 +0100 Subject: [PATCH 10/13] feat(): updated types to be more readable --- src/rest-client-v2.ts | 347 ++++++++++++++------ src/types/response/v2/broker.ts | 99 +++--- src/types/response/v2/common.ts | 252 +++++++-------- src/types/response/v2/copy-trading.ts | 438 +++++++++++++------------- src/types/response/v2/earn.ts | 214 +++++++------ src/types/response/v2/futures.ts | 434 ++++++++++++------------- src/types/response/v2/margin.ts | 269 +++++++--------- src/types/response/v2/spot.ts | 102 +++--- 8 files changed, 1127 insertions(+), 1028 deletions(-) diff --git a/src/rest-client-v2.ts b/src/rest-client-v2.ts index 8abc82f..ce3a7ea 100644 --- a/src/rest-client-v2.ts +++ b/src/rest-client-v2.ts @@ -1,17 +1,21 @@ import { AnnouncementV2, APIResponse, - BGBConvertCoinsV2, + BGBConvertCoinV2, BGBConvertHistoryV2, BorrowLoanRequestV2, - BotAssetsV2, + BotAssetV2, + BrokerSubaccountFutureAssetV2, + BrokerSubaccountSpotAssetV2, + BrokerSubaccountV2, + BrokerSubaccountWithdrawalV2, CancelAndSubmitSpotOrderResponseV2, CloseFuturesFollowerPositionsRequestV2, ConvertBGBResponseV2, - ConvertCurrenciesV2, - ConvertHistoryV2, + ConvertCurrencyV2, ConvertQuotedPriceV2, ConvertQuoteRequestV2, + ConvertRecordV2, ConvertRequestV2, ConvertTradeResponseV2, CopyTradingProductTypeV2, @@ -32,7 +36,7 @@ import { CTFuturesFollowerHistoryOrdersV2, CTFuturesFollowerMyTradersV2, CTFuturesFollowerSettingsV2, - CTFuturesTraderCurrentOrderV2, + CTFuturesTraderCurrentOrdersV2, CTFuturesTraderHistoryOrderV2, CTFuturesTraderHistoryProfitSummaryV2, CTFuturesTraderMyFollowersV2, @@ -68,10 +72,10 @@ import { EarnSharkfinProductsV2, EarnSharkfinRecordsV2, EarnSharkfinSubscriptionDetailV2, - FundingAssetsV2, + FundingAssetV2, FuturesAccountBillRequestV2, FuturesAccountBillV2, - FuturesAccountListV2, + FuturesAccountsV2, FuturesAccountV2, FuturesActiveBuySellVolumeV2, FuturesActiveLongShortAccountV2, @@ -88,7 +92,7 @@ import { FuturesCandlestickV2, FuturesClosePositionResponseV2, FuturesContractConfigV2, - FuturesDiscountRateV2, + FuturesDiscountRatesV2, FuturesFillV2, FuturesFlashClosePositionsRequestV2, FuturesFundingTimeV2, @@ -101,14 +105,14 @@ import { FuturesGetPlanOrdersRequestV2, FuturesHistoricalFundingRateV2, FuturesHistoricalPositionsRequestV2, - FuturesHistoricalPositionV2, FuturesHistoricTradesRequestV2, - FuturesHistoryOrdersV2, + FuturesHistoryInterestRateV2, + FuturesHistoryOrderV2, FuturesHistoryPlanOrderV2, + FuturesHistoryPositionV2, FuturesInterestExchangeRateV2, FuturesInterestHistoryRequestV2, FuturesInterestHistoryV2, - FuturesInterestRateHistoryV2, FuturesLongShortRatioV2, FuturesMergeDepthRequestV2, FuturesMergeDepthV2, @@ -117,9 +121,9 @@ import { FuturesModifyTPSLOrderRequestV2, FuturesOpenCountRequestV2, FuturesOpenInterestV2, - FuturesOpenOrdersV2, + FuturesOpenOrderV2, FuturesOrderDetailV2, - FuturesOrderFillsV2, + FuturesOrderFillV2, FuturesPendingPlanOrderV2, FuturesPlaceOrderRequestV2, FuturesPlanOrderRequestV2, @@ -133,7 +137,7 @@ import { FuturesSetMarginModeRequestV2, FuturesSetPositionMarginRequestV2, FuturesSingleAccountRequestV2, - FuturesSubAccountAssetsV2, + FuturesSubAccountAssetV2, FuturesSymbolPriceV2, FuturesTickerV2, FuturesTPSLOrderRequestV2, @@ -204,18 +208,18 @@ import { MarginAccountAssetV2, MarginBatchOrdersRequestV2, MarginBatchOrdersResponseV2, - MarginBorrowHistoryV2, + MarginBorrowHistoryItemV2, MarginCurrencyV2, - MarginCurrentOrdersV2, - MarginFinancialHistoryV2, - MarginHistoryOrdersV2, - MarginInterestHistoryV2, - MarginLiquidationHistoryV2, - MarginLiquidationOrdersV2, + MarginCurrentOrderV2, + MarginFinancialHistoryItemV2, + MarginHistoryOrderV2, + MarginInterestHistoryItemV2, + MarginLiquidationHistoryItemV2, + MarginLiquidationOrderV2, MarginLoanGrowthRateV2, - MarginOrderFillsV2, + MarginOrderFillV2, MarginPlaceOrderRequestV2, - MarginRepaymentHistoryV2, + MarginRepaymentHistoryItemV2, MarginTransactionRecordV2, MarginType, ModifyFuturesTraderOrderTPSLRequestV2, @@ -227,10 +231,11 @@ import { ModifyVirtualSubAccountApiKeyV2, ModifyVirtualSubApiKeyRequestV2, ModifyVirtualSubRequestV2, - P2PMerchantAdvertisementV2, + P2PMerchantAdvertismentV2, P2PMerchantInfoV2, - P2PMerchantListV2, + P2PMerchantOrdersV2, P2PMerchantOrderV2, + P2PMerchantV2, RedeemSavingsRequestV2, RepayLoanRequestV2, SetLeverageResponseV2, @@ -255,6 +260,7 @@ import { SpotFundFlowV2, SpotHistoricCandlesRequestV2, SpotHistoricTradesRequestV2, + SpotHistoryPlanOrderV2, SpotMainSubTransferRecordRequestV2, SpotMainSubTransferRecordV2, SpotMergeDepthV2, @@ -278,21 +284,17 @@ import { SpotWhaleNetFlowV2, SpotWithdrawalRecordV2, SpotWithdrawalRequestV2, - SubAccountApiKeyListV2, + SubAccountApiKeyItemV2, SubaccountApiKeyV2, SubaccountDepositV2, SubaccountEmailV2, - SubaccountFutureAssetsV2, - SubaccountsListV2, - SubaccountSpotAssetsV2, - SubaccountWithdrawalV2, SubDepositRecordsRequestV2, SubmitSpotBatchOrdersResponseV2, SubWithdrawalRecordsRequestV2, SubWithdrawalRequestV2, UpdateFuturesFollowerSettingsRequestV2, UpdateFuturesFollowerTPSLRequestV2, - VirtualSubAccountListV2, + VirtualSubAccountV2, } from './types'; import { assertMarginType, REST_CLIENT_TYPE_ENUM } from './util'; import BaseRestClient from './util/BaseRestClient'; @@ -448,7 +450,7 @@ export class RestClientV2 extends BaseRestClient { getP2PTransactionRecords( params: GetP2PTransactionsRequestV2, - ): Promise> { + ): Promise> { return this.getPrivate('/api/v2/tax/p2p-record', params); } @@ -458,9 +460,12 @@ 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); } @@ -468,15 +473,23 @@ export class RestClientV2 extends BaseRestClient { 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); } @@ -603,7 +616,12 @@ 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); } @@ -627,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, @@ -641,13 +659,13 @@ export class RestClientV2 extends BaseRestClient { */ getFundingAssets(params?: { coin?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/account/funding-assets', params); } getBotAccount(params?: { accountType?: string; - }): Promise> { + }): Promise> { return this.getPrivate('/api/v2/account/bot-assets', params); } @@ -669,7 +687,7 @@ export class RestClientV2 extends BaseRestClient { * */ - getConvertCoins(): Promise> { + getConvertCoins(): Promise> { return this.getPrivate('/api/v2/convert/currencies'); } @@ -685,9 +703,12 @@ export class RestClientV2 extends BaseRestClient { 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); } @@ -697,7 +718,11 @@ export class RestClientV2 extends BaseRestClient { * */ - getConvertBGBCoins(): Promise> { + getConvertBGBCoins(): Promise< + APIResponse<{ + coinList: BGBConvertCoinV2[]; + }> + > { return this.getPrivate('/api/v2/convert/bgb-convert-coin-list'); } @@ -908,9 +933,13 @@ export class RestClientV2 extends BaseRestClient { 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); } @@ -920,9 +949,13 @@ export class RestClientV2 extends BaseRestClient { 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); } @@ -1100,19 +1133,27 @@ export class RestClientV2 extends BaseRestClient { 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 + APIResponse< + { + coin: string; + exchangeRateList: FuturesInterestExchangeRateV2[]; + }[] + > > { return this.get('/api/v2/mix/market/exchange-rate'); } - getFuturesDiscountRate(): Promise> { + getFuturesDiscountRate(): Promise> { return this.get('/api/v2/mix/market/discount-rate'); } @@ -1174,7 +1215,12 @@ export class RestClientV2 extends BaseRestClient { getFuturesOpenInterest(params: { symbol: string; productType: FuturesProductTypeV2; - }): Promise> { + }): Promise< + APIResponse<{ + openInterestList: FuturesOpenInterestV2[]; + ts: string; + }> + > { return this.get('/api/v2/mix/market/open-interest', params); } @@ -1236,13 +1282,20 @@ export class RestClientV2 extends BaseRestClient { 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); } @@ -1302,9 +1355,12 @@ export class RestClientV2 extends BaseRestClient { 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); } @@ -1338,7 +1394,12 @@ export class RestClientV2 extends BaseRestClient { getFuturesHistoricPositions( params?: FuturesHistoricalPositionsRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + list: FuturesHistoryPositionV2[]; + endId: string; + }> + > { return this.getPrivate('/api/v2/mix/position/history-position', params); } @@ -1408,27 +1469,41 @@ export class RestClientV2 extends BaseRestClient { 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); } @@ -1488,9 +1563,12 @@ export class RestClientV2 extends BaseRestClient { return this.postPrivate('/api/v2/mix/order/modify-plan-order', params); } - getFuturesPlanOrders( - params: FuturesGetPlanOrdersRequestV2, - ): Promise> { + getFuturesPlanOrders(params: FuturesGetPlanOrdersRequestV2): Promise< + APIResponse<{ + entrustedList: FuturesPendingPlanOrderV2[]; + endId: string; + }> + > { return this.getPrivate('/api/v2/mix/order/orders-plan-pending', params); } @@ -1502,7 +1580,12 @@ export class RestClientV2 extends BaseRestClient { getFuturesHistoricPlanOrders( params: FuturesGetHistoryPlanOrdersRequestV2, - ): Promise> { + ): Promise< + APIResponse<{ + entrustedList: FuturesHistoryPlanOrderV2[]; + endId: string; + }> + > { return this.getPrivate('/api/v2/mix/order/orders-plan-history', params); } @@ -1547,9 +1630,13 @@ export class RestClientV2 extends BaseRestClient { 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); } @@ -1569,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, @@ -1579,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, @@ -1626,9 +1721,12 @@ export class RestClientV2 extends BaseRestClient { 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); } @@ -1692,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`, @@ -1703,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`, @@ -1714,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`, @@ -1725,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`, @@ -1736,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`, @@ -1980,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); } @@ -1988,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`, @@ -1999,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); } @@ -2007,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`, @@ -2033,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, diff --git a/src/types/response/v2/broker.ts b/src/types/response/v2/broker.ts index dffc862..ef9536e 100644 --- a/src/types/response/v2/broker.ts +++ b/src/types/response/v2/broker.ts @@ -13,19 +13,15 @@ export interface CreateSubaccountResponseV2 { cTime: string; } -export interface SubaccountsListV2 { - hasNextPage: boolean; - idLessThan: number; - subList: { - subUid: string; - subaccountName: string; - status: string; - permList: string[]; - label: string; - language: string; - cTime: string; - uTime: string; - }[]; +export interface BrokerSubaccountV2 { + subUid: string; + subaccountName: string; + status: string; + permList: string[]; + label: string; + language: string; + cTime: string; + uTime: string; } export interface ModifySubaccountResponseV2 { @@ -47,30 +43,26 @@ export interface SubaccountEmailV2 { uTime: string; } -export interface SubaccountSpotAssetsV2 { - assetsList: { - coin: string; - available: string; - frozen: string; - locked: string; - uTime: string; - }[]; +export interface BrokerSubaccountSpotAssetV2 { + coin: string; + available: string; + frozen: string; + locked: string; + uTime: string; } -export interface SubaccountFutureAssetsV2 { - assetsList: { - marginCoin: string; - available: string; - frozen: string; - locked: string; - crossedMaxAvailable: string; - isolatedMaxAvailable: string; - maxTransferOut: string; - accountEquity: string; - usdtEquity: string; - btcEquity: 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 { @@ -101,26 +93,23 @@ export interface SubaccountDepositV2 { uTime: string; } -export interface SubaccountWithdrawalV2 { - resultList: { - 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; - }[]; - endId: 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; } /** diff --git a/src/types/response/v2/common.ts b/src/types/response/v2/common.ts index 091f82a..5f771f7 100644 --- a/src/types/response/v2/common.ts +++ b/src/types/response/v2/common.ts @@ -56,7 +56,7 @@ export interface MarginTransactionRecordV2 { ts: string; } -export interface P2PMerchantOrderV2 { +export interface P2PMerchantOrdersV2 { id: string; coin: string; p2pTaxType: string; @@ -70,23 +70,20 @@ export interface P2PMerchantOrderV2 { * */ -export interface P2PMerchantListV2 { - merchantList: { - 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; - }[]; - minMerchantId: string; +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 { @@ -111,85 +108,79 @@ export interface P2PMerchantInfoV2 { } export interface P2PMerchantOrderV2 { - orderList: { - 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; - }[]; - }; - }[]; - minOrderId: string; + 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 P2PMerchantAdvertisementV2 { - advList: { - 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; - }[]; +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; }[]; - minAdvId: string; + merchantCertifiedList: { + imageUrl: string; + desc: string; + }[]; + utime: string; + ctime: string; } /** @@ -291,19 +282,16 @@ export interface CreateVirtualSubAccountAndApiKeyV2 { ipList: string[]; } -export interface VirtualSubAccountListV2 { - endId: string; - subAccountList: { - subAccountUid: string; - subAccountName: string; - status: string; - permList: string[]; - label: string; - accountType: string; - bindingTime: string; - cTime: string; - uTime: 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 { @@ -324,7 +312,7 @@ export interface ModifyVirtualSubAccountApiKeyV2 { ipList: string[]; } -export interface SubAccountApiKeyListV2 { +export interface SubAccountApiKeyItemV2 { subAccountUid: string; label: string; subAccountApiKey: string; @@ -338,14 +326,14 @@ export interface SubAccountApiKeyListV2 { * */ -export interface FundingAssetsV2 { +export interface FundingAssetV2 { coin: string; available: string; frozen: string; usdtValue: string; } -export interface BotAssetsV2 { +export interface BotAssetV2 { coin: string; available: string; equity: string; @@ -360,8 +348,7 @@ export interface BotAssetsV2 { * */ -export interface ConvertCurrenciesV2 { - // array type +export interface ConvertCurrencyV2 { coin: string; available: string; maxAmount: string; @@ -385,40 +372,37 @@ export interface ConvertTradeResponseV2 { toCoin: string; } -export interface ConvertHistoryV2 { - dataList: { - id: string; - ts: string; - cnvtPrice: string; - fee: string; - fromCoinSize: string; - fromCoin: string; - toCoinSize: string; - toCoin: string; - }[]; - endId: 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 BGBConvertCoinsV2 { - coinList: { - coin: string; - available: string; - bgbEstAmount: string; - precision: string; - feeDetail: { - feeRate: string; - fee: string; - }[]; - cTime: string; +export interface BGBConvertCoinV2 { + coin: string; + available: string; + bgbEstAmount: string; + precision: string; + feeDetail: { + feeRate: string; + fee: string; }[]; + cTime: string; } + export interface ConvertBGBResponseV2 { orderList: { coin: string; diff --git a/src/types/response/v2/copy-trading.ts b/src/types/response/v2/copy-trading.ts index 7c51776..98b71ac 100644 --- a/src/types/response/v2/copy-trading.ts +++ b/src/types/response/v2/copy-trading.ts @@ -7,47 +7,61 @@ */ export interface CTFuturesTraderCurrentOrderV2 { - trackingList: { - trackingNo: string; - openOrderId: string; - symbol: string; - posSide: string; - openLeverage: string; - openPriceAvg: string; - openTime: string; - openSize: string; - presetStopSurplusPrice: string; - presetStopLossPrice: string; - openFee: string; - followCount: string; - }[]; + 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 { - trackingList: { - 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; - }[]; + 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; @@ -58,25 +72,19 @@ export interface CTFuturesTraderTotalOrderSummaryV2 { lossNum: string; winRate: string; tradingPairsAvailableList: string[]; - lastWeekRoiList: { - rate: string; - ctime: string; - }[]; - lastWeekProfitList: { - amount: string; - ctime: string; - }[]; - lastMonthRoiList: { - rate: string; - ctime: string; - }[]; - lastMonthProfitList: { - amount: string; - ctime: 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; @@ -84,21 +92,19 @@ export interface CTFuturesTraderHistoryProfitSummaryV2 { waitProfit: string; yesterdayTime: string; }; - profitHistoryList: { - coin: string; - profitCount: string; - lastProfitTime: string; - }[]; + profitHistoryList: CTFuturesTraderProfitHistoryItemV2[]; +} + +export interface CTFuturesTraderProfitShare { + profitId: string; + coin: string; + profit: string; + nickName: string; + profitTime: string; } export interface CTFuturesTraderProfitShareHistoryV2 { - profitList: { - profitId: string; - coin: string; - profit: string; - nickName: string; - profitTime: string; - }[]; + profitList: CTFuturesTraderProfitShare[]; endId: string; } @@ -146,47 +152,47 @@ export interface CTFuturesFollowerCurrentOrdersV2 { 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: { - 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; - }[]; + 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: { - symbol: string; - productType: string; - marginType: string; - marginCoin: string; - leverType: string; - longLeverage: string; - shortLeverage: string; - traceType: string; - traceValue: string; - maxHoldSize: string; - stopSurplusRatio: string; - stopLossRatio: string; - }[]; + detailList: CTFuturesFollowerSettingV2[]; } export interface CTFuturesFollowerMyTradersV2 { @@ -230,16 +236,18 @@ export interface CTSpotTraderProfitSummaryV2 { }[]; } +export interface CTSpotTraderHistoryProfitShareItemV2 { + profitId: string; + coin: string; + distributeRatio: string; + profit: string; + followerName: string; + profitTime: string; +} + export interface CTSpotTraderHistoryProfitSharingV2 { endId: string; - profitList: { - profitId: string; - coin: string; - distributeRatio: string; - profit: string; - followerName: string; - profitTime: string; - }[]; + profitList: CTSpotTraderHistoryProfitShareItemV2[]; } export interface CTSpotTraderUnrealizedProfitV2 { @@ -259,60 +267,51 @@ export interface CTSpotTraderTotalOrderDetailV2 { lossNum: string; totalEquity: string; winRate: string; - lastWeekRoiList: { - rate: string; - ctime: string; - }[]; - lastMonthRoiList: { - rate: string; - ctime: string; - }[]; - lastWeekProfitList: { - amount: string; - ctime: string; - }[]; - lastMonthProfitList: { - amount: string; - ctime: 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: { - 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; - }[]; + 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: { - 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; - }[]; + trackingList: CTSpotTraderCurrentTrackingOrderV2[]; } export interface CTSpotTraderFollowerListV2 { @@ -332,85 +331,94 @@ export interface CTSpotTraderFollowerListV2 { * */ +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: { - certificationType: string; - traceTotalAmount: string; - traceTotalNetProfit: string; - traceTotalProfit: string; - traderName: string; - traderId: string; - maxFollowLimit: string; - bgbMaxFollowLimit: string; - followCount: string; - bgbFollowCount: string; - followerTime: string; - }[]; + 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: { - maxTraceAmount: string; - stopLossRation: string; - stopSurplusRation: string; - symbol: string; - traceType: string; - }[]; - tradeSymbolSettingList: { - 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; - }[]; + 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: { - trackingNo: string; - traderId: string; - fillSize: string; - buyPrice: string; - sellPrice: string; - buyFee: string; - sellFee: string; - achievedPL: string; - achievedPLR: string; - symbol: string; - buyTime: string; - sellTime: 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: { - 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; - }[]; + trackingList: CTSpotFollowerCurrentOrderV2[]; } diff --git a/src/types/response/v2/earn.ts b/src/types/response/v2/earn.ts index 1caed6e..a5dcdab 100644 --- a/src/types/response/v2/earn.ts +++ b/src/types/response/v2/earn.ts @@ -33,43 +33,47 @@ export interface EarnSavingsAccountV2 { usdtTotalEarning: string; } -export interface EarnSavingsAssetsV2 { - resultList: { - 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 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: { - orderId: string; - coinName: string; - settleCoinName: string; - productType: string; - period: string; - productLevel: string; - amount: string; - ts: string; - orderType: string; - }[]; + resultList: EarnSavingsRecordV2[]; endId: string; } @@ -110,26 +114,28 @@ export interface EarnSavingsSubscriptionDetailV2 { * */ +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: { - 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; - }[]; + resultList: EarnSharkfinProductV2[]; endId: string; } @@ -142,30 +148,33 @@ export interface EarnSharkfinAccountV2 { 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: { - productId: string; - interestStartTime: string; - interestEndTime: string; - productCoin: string; - subscribeCoin: string; - trend: string; - settleTime: string; - interestAmount: string; - productStatus: string; - }[]; + resultList: EarnSharkfinAssetV2[]; endId: string; } +export interface EarnSharkfinRecordV2 { + orderId: string; + product: string; + period: string; + amount: string; + ts: string; + type: string; +} export interface EarnSharkfinRecordsV2 { - resultList: { - orderId: string; - product: string; - period: string; - amount: string; - ts: string; - type: string; - }[]; + resultList: EarnSharkfinRecordV2[]; endId: string; } @@ -197,26 +206,29 @@ export interface EarnSharkfinSubscriptionDetailV2 { * */ +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: { - coin: string; - hourRate7D: string; - rate7D: string; - hourRate30D: string; - rate30D: string; - minUsdt: string; - maxUsdt: string; - min: string; - max: string; - }[]; - pledgeInfos: { - coin: string; - initRate: string; - supRate: string; - forceRate: string; - minUsdt: string; - maxUsdt: string; - }[]; + loanInfos: EarnLoanCurrencyLoanInfoV2[]; + pledgeInfos: EarnLoanCurrencyPledgeInfoV2[]; } export interface EarnLoanOrdersV2 { @@ -277,17 +289,21 @@ export interface EarnLoanHistoryV2 { status: string; } +export interface EarnLoanDebtPledgeInfoV2 { + coin: string; + amount: string; + amountUsdt: string; +} + +export interface EarnLoanDebtLoanInfoV2 { + coin: string; + amount: string; + amountUsdt: string; +} + export interface EarnLoanDebtsV2 { - pledgeInfos: { - coin: string; - amount: string; - amountUsdt: string; - }[]; - loanInfos: { - coin: string; - amount: string; - amountUsdt: string; - }[]; + pledgeInfos: EarnLoanDebtPledgeInfoV2[]; + loanInfos: EarnLoanDebtLoanInfoV2[]; } export interface EarnLoanLiquidationRecordsV2 { diff --git a/src/types/response/v2/futures.ts b/src/types/response/v2/futures.ts index fbe4d84..8bb7592 100644 --- a/src/types/response/v2/futures.ts +++ b/src/types/response/v2/futures.ts @@ -14,35 +14,31 @@ export interface FuturesVipFeeRateV2 { usdtWithdrawAmount: string; } -export interface FuturesInterestRateHistoryV2 { - coin: string; - historyInterestRateList: { - ts: string; - annualInterestRate: string; - dailyInterestRate: string; - }[]; +export interface FuturesHistoryInterestRateV2 { + ts: string; + annualInterestRate: string; + dailyInterestRate: string; } export interface FuturesInterestExchangeRateV2 { - coin: string; - exchangeRateList: { - tier: string; - minAmount: string; - maxAmount: string; - exchangeRate: string; - }[]; + 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: { - tier: string; - minAmount: string; - maxAmount: string; - discountRate: string; - }[]; + discountRateList: FuturesDiscountRateV2[]; } export interface FuturesMergeDepthV2 { @@ -100,11 +96,8 @@ export interface FuturesCandlestickV2 { } export interface FuturesOpenInterestV2 { - openInterestList: { - symbol: string; - size: string; - }[]; - ts: string; + symbol: string; + size: string; } export interface FuturesFundingTimeV2 { @@ -190,7 +183,7 @@ export interface FuturesAccountV2 { assetMode: string; } -export interface FuturesAccountListV2 { +export interface FuturesAccountsV2 { marginCoin: string; locked: string; available: string; @@ -217,36 +210,34 @@ export interface FuturesAccountListV2 { assetMode: string; } -export interface FuturesSubAccountAssetsV2 { - userId: number; - assetList: { - marginCoin: string; - locked: string; - available: string; - crossedMaxAvailable: string; - isolatedMaxAvailable: string; - maxTransferOut: string; - accountEquity: string; - usdtEquity: string; - btcEquity: string; - unrealizedPL: string; - coupon: 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: { - coin: string; - liability: string; - interestFreeLimit: string; - interestLimit: string; - hourInterestRate: string; - interest: string; - cTime: string; - }[]; + interestList: FuturesInterestV2[]; endId: string; } @@ -268,18 +259,15 @@ export interface SetMarginModeResponseV2 { } export interface FuturesAccountBillV2 { - bills: { - billId: string; - symbol: string; - amount: string; - fee: string; - feeByCoupon: string; - businessType: string; - coin: string; - balance: string; - cTime: string; - }[]; - endId: string; + billId: string; + symbol: string; + amount: string; + fee: string; + feeByCoupon: string; + businessType: string; + coin: string; + balance: string; + cTime: string; } /** @@ -325,26 +313,23 @@ export interface FuturesPositionV2 { cTime: string; } -export interface FuturesHistoricalPositionV2 { - list: { - 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; - }[]; - endId: 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; } /** @@ -412,97 +397,88 @@ export interface FuturesOrderDetailV2 { uTime: string; } -export interface FuturesOrderFillsV2 { - fillList: { - 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 FuturesOrderFillV2 { + tradeId: string; + symbol: string; + orderId: string; + price: string; + baseVolume: string; + feeDetail: { + deduction: string; + feeCoin: string; + totalDeductionFee: string; + totalFee: string; }[]; - endId: string; + side: string; + quoteVolume: string; + profit: string; + enterPointSource: string; + tradeSide: string; + posMode: string; + tradeScope: string; + cTime: string; } -export interface FuturesOpenOrdersV2 { - entrustedList: { - 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; - }[]; - endId: 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 FuturesHistoryOrdersV2 { - entrustedList: { - 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; - }[]; - endId: 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 { @@ -532,37 +508,34 @@ export interface FuturesTriggerSubOrderV2 { } export interface FuturesPendingPlanOrderV2 { - entrustedList: { - 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; - }[]; - endId: string; + 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 { @@ -578,37 +551,34 @@ export interface FuturesCancelPlanOrderV2 { } export interface FuturesHistoryPlanOrderV2 { - entrustedList: { - 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; - }[]; - endId: string; + 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 index 1073155..41f6674 100644 --- a/src/types/response/v2/margin.ts +++ b/src/types/response/v2/margin.ts @@ -33,82 +33,62 @@ export interface MarginCurrencyV2 { * */ -export interface MarginBorrowHistoryV2 { - resultList: { - loanId: string; - coin: string; - borrowAmount: string; - borrowType: string; - cTime: string; - uTime: string; - }[]; - maxId: string; - minId: string; +export interface MarginBorrowHistoryItemV2 { + loanId: string; + coin: string; + borrowAmount: string; + borrowType: string; + cTime: string; + uTime: string; } -export interface MarginRepaymentHistoryV2 { - resultList: { - repayId: string; - coin: string; - repayAmount: string; - repayType: string; - repayInterest: string; - repayPrincipal: string; - symbol: string; - cTime: string; - uTime: string; - }[]; - maxId: string; - minId: string; +export interface MarginRepaymentHistoryItemV2 { + repayId: string; + coin: string; + repayAmount: string; + repayType: string; + repayInterest: string; + repayPrincipal: string; + symbol: string; + cTime: string; + uTime: string; } -export interface MarginInterestHistoryV2 { - resultList: { - interestId: string; - interestCoin: string; - dailyInterestRate: string; - loanCoin: string; - interestAmount: string; - interstType: string; - symbol: string; - cTime: string; - uTime: string; - }[]; - maxId: string; - minId: string; +export interface MarginInterestHistoryItemV2 { + interestId: string; + interestCoin: string; + dailyInterestRate: string; + loanCoin: string; + interestAmount: string; + interstType: string; + symbol: string; + cTime: string; + uTime: string; } -export interface MarginLiquidationHistoryV2 { - resultList: { - liqId: string; - symbol: string; - liqStartTime: string; - liqEndTime: string; - liqRiskRatio: string; - totalAssets: string; - totalDebt: string; - liqFee: string; - cTime: string; - uTime: string; - }[]; - maxId: string; - minId: 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 MarginFinancialHistoryV2 { - resultList: { - coin: string; - symbol: string; - marginId: string; - amount: string; - balance: string; - fee: string; - marginType: string; - cTime: string; - uTime: string; - }[]; - maxId: string; - minId: string; +export interface MarginFinancialHistoryItemV2 { + coin: string; + symbol: string; + marginId: string; + amount: string; + balance: string; + fee: string; + marginType: string; + cTime: string; + uTime: string; } /** @@ -242,94 +222,79 @@ export interface MarginBatchOrdersResponseV2 { }[]; } -export interface MarginCurrentOrdersV2 { - orderList: { - 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; - }[]; - maxId: string; - minId: 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 MarginHistoryOrdersV2 { - orderList: { - 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; - }[]; - maxId: string; - minId: 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 MarginOrderFillsV2 { - fills: { - 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; - }[]; - minId: string; - maxId: 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 MarginLiquidationOrdersV2 { - resultList: { - 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; - }[]; - idLessThan: 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 index 018f672..df9c819 100644 --- a/src/types/response/v2/spot.ts +++ b/src/types/response/v2/spot.ts @@ -4,27 +4,29 @@ * */ +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: { - 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; - }[]; + chains: SpotCoinChainV2[]; } export interface SpotSymbolInfoV2 { @@ -225,24 +227,37 @@ export interface SpotFillV2 { */ export interface SpotCurrentPlanOrderV2 { - nextFlag: boolean; - idLessThan: string; - orderList: { - 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; - }[]; + 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 { @@ -291,16 +306,17 @@ export interface SpotAccountAssetV2 { uTime: string; } +export interface SpotSubAccountAssetV2 { + coin: string; + available: string; + limitAvailable: string; + frozen: string; + locked: string; + uTime: string; +} export interface SpotSubAccountAssetsV2 { userId: number; - assetsList: { - coin: string; - available: string; - limitAvailable: string; - frozen: string; - locked: string; - uTime: string; - }[]; + assetsList: SpotSubAccountAssetV2[]; } export interface SpotAccountBillV2 { From 7f79a57bf7f739d10350c3c6847ff3c0d0a950f1 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Tue, 17 Dec 2024 16:42:20 +0100 Subject: [PATCH 11/13] chore(): run linter --- src/types/response/v2/common.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/types/response/v2/common.ts b/src/types/response/v2/common.ts index 5f771f7..7e6be05 100644 --- a/src/types/response/v2/common.ts +++ b/src/types/response/v2/common.ts @@ -383,7 +383,6 @@ export interface ConvertRecordV2 { toCoin: string; } - /** * * * Common | BGB Convert @@ -402,7 +401,6 @@ export interface BGBConvertCoinV2 { cTime: string; } - export interface ConvertBGBResponseV2 { orderList: { coin: string; From a835c793c808079f0e6a0ea27d9eaed737968b09 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Tue, 17 Dec 2024 17:25:57 +0100 Subject: [PATCH 12/13] chore(): updated candle types --- src/types/response/v2/futures.ts | 19 ++++++++++--------- src/types/response/v2/spot.ts | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/types/response/v2/futures.ts b/src/types/response/v2/futures.ts index 8bb7592..49cba3c 100644 --- a/src/types/response/v2/futures.ts +++ b/src/types/response/v2/futures.ts @@ -85,15 +85,16 @@ export interface FuturesFillV2 { symbol: string; } -export interface FuturesCandlestickV2 { - [0]: string; // timestamp - [1]: string; // open - [2]: string; // high - [3]: string; // low - [4]: string; // close - [5]: string; // baseVolume - [6]: string; // quoteVolume -} +export type FuturesCandlestickV2 = [ + string, + string, + string, + string, + string, + string, + string, + string, +]; export interface FuturesOpenInterestV2 { symbol: string; diff --git a/src/types/response/v2/spot.ts b/src/types/response/v2/spot.ts index df9c819..87495be 100644 --- a/src/types/response/v2/spot.ts +++ b/src/types/response/v2/spot.ts @@ -92,16 +92,16 @@ export interface SpotOrderBookDepthV2 { ts: string; } -export interface SpotCandlestickV2 { - [0]: string; // timestamp - [1]: string; // open - [2]: string; // high - [3]: string; // low - [4]: string; // close - [5]: string; // baseVolume - [6]: string; // usdtVolume - [7]: string; // quoteVolume -} +export type SpotCandlestickV2 = [ + string, + string, + string, + string, + string, + string, + string, + string, +]; export interface SpotTradeV2 { symbol: string; From 0452aba3ec51453bdf17568396376c168603b823 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Tue, 17 Dec 2024 17:32:16 +0100 Subject: [PATCH 13/13] chore(): added comments to candle types --- src/types/response/v2/futures.ts | 16 ++++++++-------- src/types/response/v2/spot.ts | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/types/response/v2/futures.ts b/src/types/response/v2/futures.ts index 49cba3c..70c22f3 100644 --- a/src/types/response/v2/futures.ts +++ b/src/types/response/v2/futures.ts @@ -86,14 +86,14 @@ export interface FuturesFillV2 { } export type FuturesCandlestickV2 = [ - string, - string, - string, - string, - string, - string, - string, - string, + string, // timestamp + string, // open + string, // high + string, // low + string, // close + string, // baseVolume + string, // usdtVolume + string, // quoteVolume ]; export interface FuturesOpenInterestV2 { diff --git a/src/types/response/v2/spot.ts b/src/types/response/v2/spot.ts index 87495be..f99bff7 100644 --- a/src/types/response/v2/spot.ts +++ b/src/types/response/v2/spot.ts @@ -93,14 +93,14 @@ export interface SpotOrderBookDepthV2 { } export type SpotCandlestickV2 = [ - string, - string, - string, - string, - string, - string, - string, - string, + string, // timestamp + string, // open + string, // high + string, // low + string, // close + string, // baseVolume + string, // usdtVolume + string, // quoteVolume ]; export interface SpotTradeV2 {