diff --git a/src/rest-client-v5.ts b/src/rest-client-v5.ts index b76b3fc..fc48402 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -170,7 +170,6 @@ import { SpotBorrowCheckResultV5, SpotLeveragedTokenOrderHistoryV5, SpotMarginStateV5, - SubAccountAllApiKeysResultV5, SubMemberV5, SwitchIsolatedMarginParamsV5, SwitchPositionModeParamsV5, @@ -191,6 +190,7 @@ import { VipCollateralCoinsV5, WalletBalanceV5, WithdrawParamsV5, + WithdrawableAmountV5, WithdrawalRecordV5, } from './types'; @@ -551,7 +551,9 @@ export class RestClientV5 extends BaseRestClient { cancelAllOrders( params: CancelAllOrdersParamsV5, - ): Promise> { + ): Promise< + APIResponseV3WithTime<{ list: OrderResultV5[]; success: string }> + > { return this.postPrivate('/v5/order/cancel-all', params); } @@ -566,6 +568,18 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/order/history', params); } + /** + * Query users' execution records, sorted by execTime in descending order + * + * Unified account covers: Spot / Linear contract / Options + * Normal account covers: USDT perpetual / Inverse perpetual / Inverse futures + */ + getExecutionList( + params: GetExecutionListParamsV5, + ): Promise>> { + return this.getPrivate('/v5/execution/list', params); + } + /** * This endpoint allows you to place more than one order in a single request. * Covers: Option (UTA, UTA Pro) / USDT Perpetual, UDSC Perpetual, USDC Futures (UTA Pro) @@ -675,7 +689,7 @@ export class RestClientV5 extends BaseRestClient { * Only for institutional clients! */ setDisconnectCancelAllWindowV2(params: { - product: 'OPTION' | 'SPOT' | 'DERIVATIVES'; + product?: 'OPTION' | 'SPOT' | 'DERIVATIVES'; timeWindow: number; }): Promise> { return this.postPrivate('/v5/order/disconnected-cancel-all', params); @@ -733,6 +747,7 @@ export class RestClientV5 extends BaseRestClient { } /** + * @deprecated * This endpoint sets the take profit/stop loss (TP/SL) mode to full or partial. * * Unified account covers: Linear contract; normal account covers: USDT perpetual, inverse perpetual, inverse futures. @@ -761,6 +776,7 @@ export class RestClientV5 extends BaseRestClient { } /** + * @deprecated * The risk limit will limit the maximum position value you can hold under different margin requirements. * If you want to hold a bigger position size, you need more margin. * @@ -811,18 +827,6 @@ export class RestClientV5 extends BaseRestClient { return this.postPrivate('/v5/position/add-margin', params); } - /** - * Query users' execution records, sorted by execTime in descending order - * - * Unified account covers: Spot / Linear contract / Options - * Normal account covers: USDT perpetual / Inverse perpetual / Inverse futures - */ - getExecutionList( - params: GetExecutionListParamsV5, - ): Promise>> { - return this.getPrivate('/v5/execution/list', params); - } - /** * Query user's closed profit and loss records. The results are sorted by createdTime in descending order. * @@ -1099,6 +1103,19 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/account/info'); } + /** + * Query the DCP configuration of the account's contracts (USDT perpetual, USDC perpetual and USDC Futures) / spot / options. + * + * Only the configured main / sub account can query information from this API. Calling this API by an account always returns empty. + * + * INFO + * support linear contract (USDT, USDC Perp & USDC Futures) / Spot / Options only + * Unified account only + */ + getDCPInfo(): Promise> { + return this.getPrivate('/v5/account/query-dcp-info'); + } + /** * Query transaction logs in Unified account. */ @@ -1183,39 +1200,12 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/account/mmp-state', { baseCoin }); } - /** - * Query the DCP configuration of the account's contracts (USDT perpetual, USDC perpetual and USDC Futures) / spot / options. - * - * Only the configured main / sub account can query information from this API. Calling this API by an account always returns empty. - * - * INFO - * support linear contract (USDT, USDC Perp & USDC Futures) / Spot / Options only - * Unified account only - */ - getDCPInfo(): Promise> { - return this.getPrivate('/v5/account/query-dcp-info'); - } - /** * ****** Asset APIs * */ - /** - * Query the coin exchange records. - * - * CAUTION: You may experience long delays with this endpoint. - */ - getCoinExchangeRecords(params?: GetCoinExchangeRecordParamsV5): Promise< - APIResponseV3WithTime<{ - orderBody: CoinExchangeRecordV5[]; - nextPageCursor?: string; - }> - > { - return this.getPrivate('/v5/asset/exchange/order-record', params); - } - /** * Query option delivery records, sorted by deliveryTime in descending order. * @@ -1240,6 +1230,46 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/asset/settlement-record', params); } + /** + * Query the coin exchange records. + * + * CAUTION: You may experience long delays with this endpoint. + */ + getCoinExchangeRecords(params?: GetCoinExchangeRecordParamsV5): Promise< + APIResponseV3WithTime<{ + orderBody: CoinExchangeRecordV5[]; + nextPageCursor?: string; + }> + > { + return this.getPrivate('/v5/asset/exchange/order-record', params); + } + + /** + * Query coin information, including chain information, withdraw and deposit status. + */ + getCoinInfo( + coin?: string, + ): Promise> { + return this.getPrivate( + '/v5/asset/coin/query-info', + coin ? { coin } : undefined, + ); + } + + /** + * Query the sub UIDs under a main UID + * + * CAUTION: Can query by the master UID's api key only + */ + getSubUID(): Promise< + APIResponseV3WithTime<{ + subMemberIds: string[]; + transferableSubMemberIds: string[]; + }> + > { + return this.getPrivate('/v5/asset/transfer/query-sub-member-list'); + } + /** * Query asset information. * @@ -1280,6 +1310,15 @@ export class RestClientV5 extends BaseRestClient { ); } + /** + * Query withdrawable amount. + */ + getWithdrawableAmount(params: { + coin: string; + }): Promise> { + return this.getPrivate('/v5/asset/withdraw/withdrawable-amount', params); + } + /** * Query the transferable coin list between each account type. */ @@ -1327,20 +1366,6 @@ export class RestClientV5 extends BaseRestClient { ); } - /** - * Query the sub UIDs under a main UID - * - * CAUTION: Can query by the master UID's api key only - */ - getSubUID(): Promise< - APIResponseV3WithTime<{ - subMemberIds: string[]; - transferableSubMemberIds: string[]; - }> - > { - return this.getPrivate('/v5/asset/transfer/query-sub-member-list'); - } - /** * Enable Universal Transfer for Sub UID * @@ -1396,7 +1421,7 @@ export class RestClientV5 extends BaseRestClient { nextPageCursor: string; }> > { - return this.get('/v5/asset/deposit/query-allowed-list', params); + return this.getPrivate('/v5/asset/deposit/query-allowed-list', params); } /** @@ -1497,6 +1522,7 @@ export class RestClientV5 extends BaseRestClient { } /** + * @deprecated - duplicate function, use getSubDepositAddress() instead * Query the deposit address information of SUB account. * @deprecated Duplicate endpoint - Use getSubDepositAddress() instead * @@ -1520,18 +1546,6 @@ export class RestClientV5 extends BaseRestClient { }); } - /** - * Query coin information, including chain information, withdraw and deposit status. - */ - getCoinInfo( - coin?: string, - ): Promise> { - return this.getPrivate( - '/v5/asset/coin/query-info', - coin ? { coin } : undefined, - ); - } - /** * Query withdrawal records. */ @@ -1541,15 +1555,6 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/asset/withdraw/query-record', params); } - /** - * Query withdrawable amount. - */ - getWithdrawableAmount(params: { - coin: string; - }): Promise> { - return this.getPrivate('/v5/asset/withdraw/withdrawable-amount', params); - } - /** * Get Exchange Entity List. * @@ -1621,7 +1626,7 @@ export class RestClientV5 extends BaseRestClient { * Query the exchange result by sending quoteTxId. */ getConvertStatus(params: { - quoteTxId?: string; + quoteTxId: string; accountType: | 'eb_convert_funding' | 'eb_convert_uta' @@ -1701,15 +1706,6 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/user/submembers', params); } - /** - * Query all api keys information of a sub UID. - */ - getSubAccountAllApiKeys( - params: GetSubAccountAllApiKeysParamsV5, - ): Promise> { - return this.getPrivate('/v5/user/sub-apikeys', params); - } - /** * Froze sub uid. Use master user's api key only. * @@ -1733,6 +1729,18 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/user/query-api'); } + /** + * Query all api keys information of a sub UID. + */ + getSubAccountAllApiKeys(params: GetSubAccountAllApiKeysParamsV5): Promise< + APIResponseV3WithTime<{ + result: ApiKeyInfoV5[]; + nextPageCursor: string; + }> + > { + return this.getPrivate('/v5/user/sub-apikeys', params); + } + getUIDWalletType(params: { memberIds: string }): Promise< APIResponseV3WithTime<{ accounts: { @@ -1741,7 +1749,7 @@ export class RestClientV5 extends BaseRestClient { }[]; }> > { - return this.getPrivate('/v5/user/query-api', params); + return this.getPrivate('/v5/user/get-member-type', params); } /** @@ -1770,6 +1778,19 @@ export class RestClientV5 extends BaseRestClient { return this.postPrivate('/v5/user/update-sub-api', params); } + /** + * Delete a sub UID. Before deleting the UID, please make sure there are no assets. + * + * TIP: + * The API key must have one of the permissions to be allowed to call the following API endpoint. + * - master API key: "Account Transfer", "Subaccount Transfer", "Withdrawal" + */ + deleteSubMember( + params: DeleteSubMemberParamsV5, + ): Promise> { + return this.postPrivate('/v5/user/del-submember', params); + } + /** * Delete the api key of master account. Use the api key pending to be delete to call the endpoint. Use master user's api key only. * @@ -1799,19 +1820,6 @@ export class RestClientV5 extends BaseRestClient { return this.postPrivate('/v5/user/delete-sub-api', params); } - /** - * Delete a sub UID. Before deleting the UID, please make sure there are no assets. - * - * TIP: - * The API key must have one of the permissions to be allowed to call the following API endpoint. - * - master API key: "Account Transfer", "Subaccount Transfer", "Withdrawal" - */ - deleteSubMember( - params: DeleteSubMemberParamsV5, - ): Promise> { - return this.postPrivate('/v5/user/del-submember', params); - } - /** * ****** Affiliate APIs diff --git a/src/types/request/v5-asset.ts b/src/types/request/v5-asset.ts index c981206..2258887 100644 --- a/src/types/request/v5-asset.ts +++ b/src/types/request/v5-asset.ts @@ -20,6 +20,8 @@ export interface GetDeliveryRecordParamsV5 { export interface GetSettlementRecordParamsV5 { category: CategoryV5; symbol?: string; + startTime?: number; + endTime?: number; limit?: number; cursor?: string; } @@ -102,6 +104,7 @@ export interface GetSubAccountDepositRecordParamsV5 { } export interface GetInternalDepositRecordParamsV5 { + txID?: string; startTime?: number; endTime?: number; coin?: string; @@ -111,6 +114,7 @@ export interface GetInternalDepositRecordParamsV5 { export interface GetWithdrawalRecordsParamsV5 { withdrawID?: string; + txID?: string; coin?: string; withdrawType?: number; startTime?: number; @@ -131,7 +135,7 @@ export interface WithdrawParamsV5 { feeType?: 0 | 1; requestId?: string; beneficiary?: { - vaspEntityId: string; + vaspEntityId?: string; beneficiaryName?: string; }; } diff --git a/src/types/request/v5-market.ts b/src/types/request/v5-market.ts index f5a3c4b..3d37b16 100644 --- a/src/types/request/v5-market.ts +++ b/src/types/request/v5-market.ts @@ -108,6 +108,7 @@ export interface GetInsuranceParamsV5 { export interface GetRiskLimitParamsV5 { category?: 'linear' | 'inverse'; symbol?: string; + cursor?: string; } export interface GetOptionDeliveryPriceParamsV5 { diff --git a/src/types/request/v5-trade.ts b/src/types/request/v5-trade.ts index 437c70c..76aad5a 100644 --- a/src/types/request/v5-trade.ts +++ b/src/types/request/v5-trade.ts @@ -8,6 +8,7 @@ import { OrderTriggerByV5, OrderTypeV5, PositionIdx, + StopOrderTypeV5, } from '../shared-v5'; export interface OrderParamsV5 { @@ -51,6 +52,7 @@ export interface AmendOrderParamsV5 { triggerPrice?: string; qty?: string; price?: string; + tpslMode?: 'Full' | 'Partial'; takeProfit?: string; stopLoss?: string; tpTriggerBy?: OrderTriggerByV5; @@ -86,6 +88,7 @@ export interface GetAccountHistoricOrdersParamsV5 { category: CategoryV5; symbol?: string; baseCoin?: string; + settleCoin?: string; orderId?: string; orderLinkId?: string; orderFilter?: OrderFilterV5; @@ -102,11 +105,13 @@ export interface CancelAllOrdersParamsV5 { baseCoin?: string; settleCoin?: string; orderFilter?: OrderFilterV5; + stopOrderType?: StopOrderTypeV5; } export interface BatchOrderParamsV5 { symbol: string; side: OrderSideV5; + isLeverage?: 0 | 1; orderType: OrderTypeV5; qty: string; price?: string; diff --git a/src/types/response/v5-account.ts b/src/types/response/v5-account.ts index b23884d..3bf10a3 100644 --- a/src/types/response/v5-account.ts +++ b/src/types/response/v5-account.ts @@ -14,7 +14,7 @@ export interface WalletBalanceV5Coin { free: string; // spot only locked: string; // spot only borrowAmount: string; - availableToBorrow: string; + availableToBorrow: string; // deprecated field availableToWithdraw: string; accruedInterest: string; totalOrderIM: string; @@ -23,6 +23,8 @@ export interface WalletBalanceV5Coin { unrealisedPnl: string; cumRealisedPnl: string; bonus: string; + marginCollateral: boolean; + collateralSwitch: boolean; } export interface WalletBalanceV5 { @@ -54,6 +56,9 @@ export interface BorrowHistoryRecordV5 { hourlyBorrowRate: string; InterestBearingBorrowSize: string; costExemption: string; + borrowAmount: string; + unrealisedLoss: string; + freeBorrowedAmount: string; } export interface CollateralInfoV5 { @@ -110,6 +115,7 @@ export interface TransactionLogV5 { change: string; cashBalance: string; feeRate: string; + bonusChange: string; tradeId: string; orderId: string; orderLinkId: string; diff --git a/src/types/response/v5-asset.ts b/src/types/response/v5-asset.ts index fe43abf..92372b3 100644 --- a/src/types/response/v5-asset.ts +++ b/src/types/response/v5-asset.ts @@ -66,6 +66,8 @@ export interface AccountCoinBalanceV5 { walletBalance: string; transferBalance: string; bonus: string; + transferSafeAmount: string; + ltvTransferSafeAmount: string; }; } @@ -113,6 +115,9 @@ export interface DepositRecordV5 { confirmations: string; txIndex: string; blockHash: string; + batchReleaseLimit: string; + depositType: string; + fromAddress: string; } export interface InternalDepositRecordV5 { @@ -123,6 +128,7 @@ export interface InternalDepositRecordV5 { status: 1 | 2 | 3; address: string; createdTime: string; + txID: string; } export interface DepositAddressChainV5 { @@ -130,6 +136,8 @@ export interface DepositAddressChainV5 { addressDeposit: string; tagDeposit: string; chain: string; + batchReleaseLimit: string; + contractAddress: string; } export interface DepositAddressResultV5 { @@ -151,6 +159,8 @@ export interface CoinInfoV5 { minAccuracy: string; chainDeposit: string; chainWithdraw: string; + withdrawPercentageFee: string; + contractAddress: string; }[]; } @@ -169,6 +179,22 @@ export interface WithdrawalRecordV5 { updateTime: string; } +export interface WithdrawableAmountV5 { + limitAmountUsd: string; + withdrawableAmount: { + SPOT: { + coin: string; + withdrawableAmount: string; + availableBalance: string; + }; + FUND: { + coin: string; + withdrawableAmount: string; + availableBalance: string; + }; + }; +} + export interface VaspEntityV5 { vaspEntityId: string; vaspName: string; @@ -220,7 +246,7 @@ export interface ConvertStatusV5 { fromAmount: string; toAmount: string; exchangeStatus: 'init' | 'processing' | 'success' | 'failure'; - extInfo: object; + extInfo: { paramType: string; paramValue: string }; convertRate: string; createdAt: string; } @@ -236,7 +262,7 @@ export interface ConvertHistoryRecordV5 { fromAmount: string; toAmount: string; exchangeStatus: 'init' | 'processing' | 'success' | 'failure'; - extInfo: object; + extInfo: { paramType: string; paramValue: string }; convertRate: string; createdAt: string; } diff --git a/src/types/response/v5-crypto-loan.ts b/src/types/response/v5-crypto-loan.ts index e379de7..4074fe4 100644 --- a/src/types/response/v5-crypto-loan.ts +++ b/src/types/response/v5-crypto-loan.ts @@ -1,6 +1,5 @@ export interface CollateralCoinV5 { collateralAccuracy: number; - currency: string; initialLTV: string; liquidationLTV: string; marginCallLTV: string; diff --git a/src/types/response/v5-market.ts b/src/types/response/v5-market.ts index 8041b6b..1a9cdee 100644 --- a/src/types/response/v5-market.ts +++ b/src/types/response/v5-market.ts @@ -163,6 +163,8 @@ export interface OrderbookResponseV5 { a: OrderbookLevelV5[]; ts: number; u: number; + seq: number; + cts: number; } export interface TickerLinearInverseV5 { @@ -192,6 +194,7 @@ export interface TickerLinearInverseV5 { preOpenPrice: string; preQty: string; curPreListingPhase: string; + basis: string; } export interface TickerOptionV5 { @@ -252,6 +255,10 @@ export interface PublicTradeV5 { side: OrderSideV5; time: string; isBlockTrade: boolean; + mP?: string; + iP?: string; + mIv?: string; + iv?: string; } /** @@ -279,6 +286,7 @@ export interface HistoricalVolatilityV5 { export interface InsuranceDataV5 { coin: string; + symbols: string; balance: string; value: string; } @@ -299,6 +307,7 @@ export interface RiskLimitV5 { isLowestRisk: 0 | 1; maxLeverage: string; mmDeduction: string; + nextPageCursor?: string; } /** @deprecated use DeliveryPriceV5 instead */ diff --git a/src/types/response/v5-position.ts b/src/types/response/v5-position.ts index 3500c50..fa03842 100644 --- a/src/types/response/v5-position.ts +++ b/src/types/response/v5-position.ts @@ -29,6 +29,7 @@ export interface PositionV5 { bustPrice?: string; positionIM?: string; positionMM?: string; + positionBalance?: string; tpslMode?: TPSLModeV5; takeProfit?: string; stopLoss?: string; @@ -108,6 +109,7 @@ export interface ExecutionV5 { underlyingPrice?: string; blockTradeId?: string; closedSize?: string; + seq: number; } export interface ClosedPnLV5 { diff --git a/src/types/response/v5-trade.ts b/src/types/response/v5-trade.ts index 8e61cfd..454823d 100644 --- a/src/types/response/v5-trade.ts +++ b/src/types/response/v5-trade.ts @@ -107,5 +107,7 @@ export interface SpotBorrowCheckResultV5 { side: OrderSideV5; maxTradeQty: string; maxTradeAmount: string; + spotMaxTradeQty: string; + spotMaxTradeAmount: string; borrowCoin: string; } diff --git a/src/types/response/v5-user.ts b/src/types/response/v5-user.ts index b74c579..eb884aa 100644 --- a/src/types/response/v5-user.ts +++ b/src/types/response/v5-user.ts @@ -27,26 +27,44 @@ export interface SubMemberV5 { } export type ApiKeyType = 1 | 2; +export interface ApiKeyPermissionsV5 { + ContractTrade: string[]; + Spot: string[]; + Wallet: string[]; + Options: string[]; + Derivatives: string[]; + CopyTrading: string[]; + BlockTrade: string[]; + Exchange: string[]; + NFT: string[]; + Affiliate: string[]; +} + export interface ApiKeyInfoV5 { id: string; note: string; apiKey: string; readOnly: 0 | 1; secret: string; - permissions: PermissionsV5; - ips?: string[]; - type: ApiKeyType; - deadlineDay?: number; - expiredAt?: string; + permissions: ApiKeyPermissionsV5; + ips: string[]; + type: 1 | 2; // 1: personal, 2: connected to third-party app + deadlineDay: number; + expiredAt: string; createdAt: string; - unified: 0 | 1; - uta: 0 | 1; + /** @deprecated */ + unified: number; + uta: 0 | 1; // 0: regular account, 1: unified trade account userID: number; inviterID: number; - vipLevel?: string; - mktMakerLevel?: string; - affiliateID?: number; + vipLevel: string; + mktMakerLevel: string; + affiliateID: number; + rsaPublicKey: string; isMaster: boolean; + parentUid: string; + kycLevel: 'LEVEL_DEFAULT' | 'LEVEL_1' | 'LEVEL_2'; + kycRegion: string; } export interface UpdateApiKeyResultV5 { diff --git a/src/types/shared-v5.ts b/src/types/shared-v5.ts index 514111f..b594b6d 100644 --- a/src/types/shared-v5.ts +++ b/src/types/shared-v5.ts @@ -142,7 +142,10 @@ export type StopOrderTypeV5 = | 'Stop' | 'PartialTakeProfit' | 'PartialStopLoss' - | 'tpslOrder'; + | 'tpslOrder' + | 'OcoOrder' + | 'MmRateClose' + | 'BidirectionalTpslOrder'; /** * Position index. Used to identify positions in different position modes.