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; +}