diff --git a/src/spot-client-v3.ts b/src/spot-client-v3.ts index 514bb0e..bf75429 100644 --- a/src/spot-client-v3.ts +++ b/src/spot-client-v3.ts @@ -5,6 +5,12 @@ import { OrderSide, OrderTypeSpot, SpotBalances, + KlineInterval, + NewSpotOrderV3, + SpotMyTradesRequest, + SpotLeveragedTokenPRHistoryRequest, + SpotCrossMarginBorrowingInfoRequest, + SpotCrossMarginRepaymentHistoryRequest, } from './types'; import { REST_CLIENT_TYPE_ENUM } from './util'; import BaseRestClient from './util/BaseRestClient'; @@ -40,8 +46,16 @@ export class SpotV3Client extends BaseRestClient { } /** Get merged orderbook for symbol */ - getOrderBookMerged(params: unknown): Promise> { - return this.get('/spot/v3/public/quote/depth/merged', params); + getOrderBookMerged( + symbol: string, + scale?: number, + limit?: number + ): Promise> { + return this.get('/spot/v3/public/quote/depth/merged', { + symbol, + scale, + limit, + }); } /** Get public trading records (raw trades) */ @@ -50,8 +64,20 @@ export class SpotV3Client extends BaseRestClient { } /** Get candles/klines */ - getCandles(params: unknown): Promise> { - return this.get('/spot/v3/public/quote/kline', params); + getCandles( + symbol: string, + interval: KlineInterval, + limit?: number, + startTime?: number, + endTime?: number + ): Promise> { + return this.get('/spot/v3/public/quote/kline', { + symbol, + interval, + limit, + startTime, + endTime, + }); } /** Get latest information for symbol (24hr ticker) */ @@ -78,7 +104,7 @@ export class SpotV3Client extends BaseRestClient { /** -> Order API */ /** Create order */ - submitOrder(params: unknown): Promise> { + submitOrder(params: NewSpotOrderV3): Promise> { return this.postPrivate('/spot/v3/private/order', params); } @@ -147,7 +173,7 @@ export class SpotV3Client extends BaseRestClient { * If startTime is not specified, you can only query for records in the last 7 days. * If you want to query for records older than 7 days, startTime is required. */ - getMyTrades(params?: unknown): Promise> { + getMyTrades(params?: SpotMyTradesRequest): Promise> { return this.getPrivate('/spot/v3/private/my-trades', params); } @@ -215,7 +241,9 @@ export class SpotV3Client extends BaseRestClient { } /** Get leveraged token purchase/redemption history */ - getLeveragedTokenPRHistory(params: unknown): Promise> { + getLeveragedTokenPRHistory( + params?: SpotLeveragedTokenPRHistoryRequest + ): Promise> { return this.getPrivate('/spot/v3/private/record', params); } @@ -245,7 +273,9 @@ export class SpotV3Client extends BaseRestClient { } /** Query borrowing info */ - getCrossMarginBorrowingInfo(params?: unknown): Promise> { + getCrossMarginBorrowingInfo( + params?: SpotCrossMarginBorrowingInfoRequest + ): Promise> { return this.getPrivate('/spot/v3/private/cross-margin-orders', params); } @@ -261,7 +291,7 @@ export class SpotV3Client extends BaseRestClient { /** Query repayment history */ getCrossMarginRepaymentHistory( - params?: unknown + params?: SpotCrossMarginRepaymentHistoryRequest ): Promise> { return this.getPrivate( '/spot/v3/private/cross-margin-repay-history', diff --git a/src/types/index.ts b/src/types/index.ts index 78f54db..145ac98 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,4 +1,3 @@ export * from './response'; export * from './request'; export * from './shared'; -export * from './spot'; diff --git a/src/types/request/index.ts b/src/types/request/index.ts index e80dc2f..77aaef5 100644 --- a/src/types/request/index.ts +++ b/src/types/request/index.ts @@ -1,5 +1,6 @@ export * from './account-asset'; export * from './copy-trading'; +export * from './spot'; export * from './usdt-perp'; export * from './usdc-perp'; export * from './usdc-options'; diff --git a/src/types/request/spot.ts b/src/types/request/spot.ts new file mode 100644 index 0000000..fc589ea --- /dev/null +++ b/src/types/request/spot.ts @@ -0,0 +1,81 @@ +import { numberInString, OrderSide } from '../shared'; + +export type OrderTypeSpot = 'LIMIT' | 'MARKET' | 'LIMIT_MAKER'; +export type OrderTimeInForce = 'GTC' | 'FOK' | 'IOC'; + +export interface NewSpotOrder { + symbol: string; + qty: number; + side: OrderSide; + type: OrderTypeSpot; + timeInForce?: OrderTimeInForce; + price?: number; + orderLinkId?: string; +} + +export interface NewSpotOrderV3 { + symbol: string; + orderQty: string; + side: OrderSide; + orderType: OrderTypeSpot; + timeInForce?: OrderTimeInForce; + orderPrice?: string; + orderLinkId?: string; + orderCategory?: 0 | 1; + triggerPrice?: string; +} + +export interface SpotOrderQueryById { + orderId?: string; + orderLinkId?: string; +} + +export interface SpotSymbolInfo { + name: string; + alias: string; + baseCurrency: string; + quoteCurrency: string; + basePrecision: numberInString; + quotePrecision: numberInString; + minTradeQuantity: numberInString; + minTradeAmount: numberInString; + minPricePrecision: numberInString; + maxTradeQuantity: numberInString; + maxTradeAmount: numberInString; + category: numberInString; +} + +export interface SpotMyTradesRequest { + symbol?: string; + orderId?: string; + limit?: string; + startTime?: number; + endTime?: number; + fromTradeId?: string; + toTradeId?: string; +} + +export interface SpotLeveragedTokenPRHistoryRequest { + ltCode?: string; + orderId?: string; + startTime?: number; + endTime?: number; + limit?: number; + orderType?: 1 | 2; + serialNo?: string; +} + +export interface SpotCrossMarginBorrowingInfoRequest { + startTime?: number; + endTime?: number; + coin?: string; + status?: 0 | 1 | 2; + limit?: number; +} + +export interface SpotCrossMarginRepaymentHistoryRequest { + startTime?: number; + endTime?: number; + coin?: string; + limit?: number; +} diff --git a/src/types/spot.ts b/src/types/spot.ts deleted file mode 100644 index 24a581d..0000000 --- a/src/types/spot.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { numberInString, OrderSide } from './shared'; - -export type OrderTypeSpot = 'LIMIT' | 'MARKET' | 'LIMIT_MAKER'; -export type OrderTimeInForce = 'GTC' | 'FOK' | 'IOC'; - -export interface NewSpotOrder { - symbol: string; - qty: number; - side: OrderSide; - type: OrderTypeSpot; - timeInForce?: OrderTimeInForce; - price?: number; - orderLinkId?: string; -} - -export interface SpotOrderQueryById { - orderId?: string; - orderLinkId?: string; -} - -export interface SpotSymbolInfo { - name: string; - alias: string; - baseCurrency: string; - quoteCurrency: string; - basePrecision: numberInString; - quotePrecision: numberInString; - minTradeQuantity: numberInString; - minTradeAmount: numberInString; - minPricePrecision: numberInString; - maxTradeQuantity: numberInString; - maxTradeAmount: numberInString; - category: numberInString; -}