From 50a01d123e282276844c19d491572ee8bfc1a011 Mon Sep 17 00:00:00 2001 From: JJ-Cro Date: Mon, 17 Feb 2025 13:51:38 +0100 Subject: [PATCH] feat(): finished asset category types --- src/rest-client-v5.ts | 108 +++++++++++++++++---------------- src/types/request/v5-asset.ts | 6 +- src/types/response/v5-asset.ts | 30 ++++++++- 3 files changed, 88 insertions(+), 56 deletions(-) diff --git a/src/rest-client-v5.ts b/src/rest-client-v5.ts index 833e7cc..9cfb13b 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -191,6 +191,7 @@ import { VipCollateralCoinsV5, WalletBalanceV5, WithdrawParamsV5, + WithdrawableAmountV5, WithdrawalRecordV5, } from './types'; @@ -1206,20 +1207,6 @@ export class RestClientV5 extends BaseRestClient { * */ - /** - * 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. * @@ -1244,6 +1231,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. * @@ -1284,6 +1311,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. */ @@ -1309,7 +1345,7 @@ export class RestClientV5 extends BaseRestClient { amount: string, fromAccountType: AccountTypeV5, toAccountType: AccountTypeV5, - ): Promise> { + ): Promise> { return this.postPrivate('/v5/asset/transfer/inter-transfer', { transferId, coin, @@ -1331,20 +1367,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 * @@ -1369,7 +1391,7 @@ export class RestClientV5 extends BaseRestClient { */ createUniversalTransfer( params: UniversalTransferParamsV5, - ): Promise> { + ): Promise> { return this.postPrivate('/v5/asset/transfer/universal-transfer', params); } @@ -1400,7 +1422,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); } /** @@ -1491,6 +1513,7 @@ export class RestClientV5 extends BaseRestClient { } /** + * @deprecated - duplicate function, use getSubDepositAddress() instead * Query the deposit address information of SUB account. * * CAUTION @@ -1508,18 +1531,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. */ @@ -1529,15 +1540,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. * @@ -1609,7 +1611,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' diff --git a/src/types/request/v5-asset.ts b/src/types/request/v5-asset.ts index c7483d7..f9c671e 100644 --- a/src/types/request/v5-asset.ts +++ b/src/types/request/v5-asset.ts @@ -18,6 +18,8 @@ export interface GetDeliveryRecordParamsV5 { export interface GetSettlementRecordParamsV5 { category: CategoryV5; symbol?: string; + startTime?: number; + endTime?: number; limit?: number; cursor?: string; } @@ -100,6 +102,7 @@ export interface GetSubAccountDepositRecordParamsV5 { } export interface GetInternalDepositRecordParamsV5 { + txID?: string; startTime?: number; endTime?: number; coin?: string; @@ -109,6 +112,7 @@ export interface GetInternalDepositRecordParamsV5 { export interface GetWithdrawalRecordsParamsV5 { withdrawID?: string; + txID?: string; coin?: string; withdrawType?: number; startTime?: number; @@ -129,7 +133,7 @@ export interface WithdrawParamsV5 { feeType?: 0 | 1; requestId?: string; beneficiary?: { - vaspEntityId: string; + vaspEntityId?: string; beneficiaryName?: 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; }