gateio-api
Version:
Complete & Robust Node.js SDK for Gate.com's REST APIs, WebSockets & WebSocket APIs, with TypeScript declarations.
1,179 lines (1,178 loc) • 115 kB
TypeScript
import { AxiosRequestConfig } from 'axios';
import { BaseRestClient, RestClientType } from './lib/BaseRestClient.js';
import { RestClientOptions } from './lib/requestUtils.js';
import { CreateStpGroupReq } from './types/request/account.js';
import { GetLoanCollateralRecordsReq, GetLoanOrdersReq, GetLoanRepaymentHistoryReq, SubmitLoanOrderReq, UpdateLoanCollateralReq } from './types/request/collateralLoan.js';
import { GetDeliveryAutoOrdersReq, GetDeliveryBookReq, GetDeliveryCandlesReq, GetDeliveryClosedPositionsReq, GetDeliveryLiquidationHistoryReq, GetDeliveryOrderBookReq, GetDeliveryOrdersReq, GetDeliverySettlementHistoryReq, GetDeliveryTradesReq, GetDeliveryTradingHistoryReq, SubmitDeliveryFuturesOrderReq } from './types/request/delivery.js';
import { GetStructuredProductListReq, GetStructuredProductOrdersReq } from './types/request/earn.js';
import { GetLendingInterestRecordsReq, GetLendingOrdersReq, GetLendingRecordsReq, SubmitLendOrRedeemReq } from './types/request/earnuni.js';
import { GetFlashSwapOrdersReq, SubmitFlashSwapOrderPreviewReq, SubmitFlashSwapOrderReq } from './types/request/flashswap.js';
import { BatchAmendOrderReq, DeleteAllFuturesOrdersReq, GetFundingRatesReq, GetFuturesAccountBookReq, GetFuturesAutoOrdersReq, GetFuturesCandlesReq, GetFuturesInsuranceReq, GetFuturesLiquidationHistoryReq, GetFuturesOrderBookReq, GetFuturesOrdersByTimeRangeReq, GetFuturesOrdersReq, GetFuturesPositionCloseHistoryReq, GetFuturesPositionHistoryReq, GetFuturesPositionsReq, GetFuturesStatsReq, GetFuturesTradesReq, GetFuturesTradingHistoryByTimeRangeReq, GetFuturesTradingHistoryReq, GetLiquidationHistoryReq, GetRiskLimitTableReq, GetRiskLimitTiersReq, SubmitFuturesOrderReq, SubmitFuturesTriggeredOrderReq, UpdateDualModePositionLeverageReq, UpdateDualModePositionMarginReq, UpdateFuturesOrderReq } from './types/request/futures.js';
import { GetCrossMarginAccountHistoryReq, GetCrossMarginBorrowHistoryReq, GetCrossMarginInterestRecordsReq, GetCrossMarginRepaymentsReq, GetMarginBalanceHistoryReq, SubmitCrossMarginBorrowLoanReq } from './types/request/margin.js';
import { GetMarginUNIInterestRecordsReq, GetMarginUNILoanRecordsReq, GetMarginUNILoansReq, GetMarginUNIMaxBorrowReq } from './types/request/marginuni.js';
import { GetMultiLoanAdjustmentRecordsReq, GetMultiLoanOrdersReq, GetMultiLoanRepayRecordsReq, RepayMultiLoanReq, SubmitMultiLoanOrderReq, UpdateMultiLoanReq } from './types/request/multicollateralLoan.js';
import { GetOptionsAccountChangeReq, GetOptionsCandlesReq, GetOptionsMySettlementsReq, GetOptionsOrderBookReq, GetOptionsOrdersReq, GetOptionsPersonalHistoryReq, GetOptionsSettlementHistoryReq, GetOptionsTradesReq, GetOptionsUnderlyingCandlesReq, OptionsMMPSettingsReq, SubmitOptionsOrderReq } from './types/request/options.js';
import { GetAgencyCommissionHistoryReq, GetAgencyTransactionHistoryReq, GetBrokerCommissionHistoryReq, GetBrokerTransactionHistoryReq, GetPartnerSubordinateListReq, PartnerTransactionReq } from './types/request/rebate.js';
import { CancelSpotBatchOrdersReq, DeleteSpotOrderReq, GetSpotAccountBookReq, GetSpotAutoOrdersReq, GetSpotCandlesReq, GetSpotInsuranceHistoryReq, GetSpotOrderBookReq, GetSpotOrderReq, GetSpotOrdersReq, GetSpotTradesReq, GetSpotTradingHistoryReq, SubmitSpotClosePosCrossDisabledReq, SubmitSpotOrderReq, UpdateSpotBatchOrdersReq, UpdateSpotOrderReq } from './types/request/spot.js';
import { CreateSubAccountApiKeyReq, CreateSubAccountReq, UpdateSubAccountApiKeyReq } from './types/request/subaccount.js';
import { GetUnifiedHistoryLendingRateReq, GetUnifiedInterestRecordsReq, GetUnifiedLoanRecordsReq, GetUnifiedLoansReq, PortfolioMarginCalculatorReq, SetUnifiedAccountModeReq, SubmitUnifiedBorrowOrRepayReq, SubmitUnifiedLoanRepayReq } from './types/request/unified.js';
import { GetMainSubTransfersReq, GetSavedAddressReq, GetSmallBalanceHistoryReq, GetWithdrawalDepositRecordsReq, ListPushOrdersReq, SubmitMainSubTransferReq, SubmitSubToSubTransferReq, SubmitTransferReq } from './types/request/wallet.js';
import { SubmitWithdrawalReq } from './types/request/withdrawal.js';
import { AccountDetail, AccountRateLimit, StpGroup, StpGroupUser } from './types/response/account.js';
import { LoanCollateralRatio, LoanCollateralRecord, LoanOrder, LoanRepaymentHistoryRecord } from './types/response/collateralloan.js';
import { DeliveryAccount, DeliveryBook, DeliveryCandle, DeliveryClosedPosition, DeliveryLiquidationHistoryRecord, DeliveryOrderBook, DeliverySettlementHistoryRecord, DeliveryTicker, DeliveryTrade, DeliveryTradingHistoryRecord } from './types/response/delivery.js';
import { DualInvestmentOrder, DualInvestmentProduct, StructuredProduct, StructuredProductOrder } from './types/response/earn.js';
import { LendingCurrency, LendingInterestRecord, LendingOrder, LendingRecord } from './types/response/earnuni.js';
import { FlashSwapCurrencyPair, FlashSwapOrder, SubmitFlashSwapOrderPreviewResp } from './types/response/flashswap.js';
import { BatchAmendOrderResp, DeleteFuturesBatchOrdersResp, FuturesAccount, FuturesAccountBookRecord, FuturesAutoDeleveragingHistoryRecord, FuturesCandle, FuturesContract, FuturesDeliveryContract, FuturesInsuranceHistory, FuturesLiquidationHistoryRecord, FuturesOrder, FuturesOrderBook, FuturesPosition, FuturesPositionHistoryRecord, FuturesPriceTriggeredOrder, FuturesStats, FuturesTicker, FuturesTrade, FuturesTradingHistoryRecord, IndexConstituents, LiquidationHistoryRecord, PremiumIndexKLine, RiskLimitTableTier, RiskLimitTier } from './types/response/futures.js';
import { CrossMarginAccount, CrossMarginAccountHistoryRecord, CrossMarginCurrency, CrossMarginMorrowLoanRecord, MarginAccount, MarginBalanceHistoryRecord, MarginUserAccount } from './types/response/margin.js';
import { LendingMarket, MarginUNIInterestRecord, MarginUNILoan, MarginUNILoanRecord, MarginUNIMaxBorrowable } from './types/response/marginuni.js';
import { MultiLoanAdjustmentRecord, MultiLoanCurrencyQuota, MultiLoanFixedRate, MultiLoanOrder, MultiLoanRatio, MultiLoanRepayRecord, MultiLoanSupportedCurrencies, RepayMultiLoanResp, UpdateMultiLoanResp } from './types/response/multicollateralLoan.js';
import { GetOptionsLiquidationResp, OptionsAccount, OptionsAccountChangeRecord, OptionsCandle, OptionsContract, OptionsMMPSettings, OptionsOrderBook, OptionsPositionsUnderlying, OptionsSettlementHistoryRecord, OptionsTicker, OptionsTrade, OptionsUnderlyingCandle, OptionsUserHistoryRecord, OptionsUserSettlement, SubmitOptionsOrderResp } from './types/response/options.js';
import { AgencyCommissionHistoryRecord, AgencyTransactionHistoryRecord, BrokerCommissionHistoryRecord, BrokerTransactionHistoryRecord, PartnerCommission, PartnerSubordinate, PartnerTransaction } from './types/response/rebate.js';
import { DeleteSpotBatchOrdersResp, GetSpotOpenOrdersResp, SpotAccount, SpotAccountBook, SpotCandle, SpotCurrency, SpotFeeRates, SpotHistoricTradeRecord, SpotInsuranceHistory, SpotOrder, SpotOrderBook, SpotPriceTriggeredOrder, SpotTicker, SpotTrade, SubmitSpotBatchOrdersResp } from './types/response/spot.js';
import { CreatedSubAccountAPIKey, SubAccount, SubAccountAPIKey, SubAccountMode } from './types/response/subaccount.js';
import { MarginTier, PortfolioMarginCalculation, UnifiedAccountInfo, UnifiedCurrencyDiscountTiers, UnifiedHistoryLendingRate, UnifiedInterestRecord, UnifiedLoan, UnifiedLoanCurrency, UnifiedLoanRecord, UnifiedRiskUnitDetails, UserCurrencyLeverageConfig } from './types/response/unified.js';
import { CreateDepositAddressResp, CurrencyChain, GetBalancesResp, PushOrder, SavedAddress, SmallBalanceHistoryRecord, SmallBalanceRecord, SubAccountCrossMarginBalancesResp, SubAccountFuturesBalancesResp, SubAccountMarginBalance, SubAccountTransferRecord, TradingFees, WithdrawalStatus } from './types/response/wallet.js';
import { WithdrawalRecord } from './types/response/withdrawal.js';
import { CurrencyPair, FromToPageLimit } from './types/shared.js';
/**
* Unified REST API client for all of Gate's REST APIs
*/
export declare class RestClient extends BaseRestClient {
constructor(restClientOptions?: RestClientOptions, requestOptions?: AxiosRequestConfig);
/**
*
* Custom SDK functions
*
*/
/**
* This method is used to get the latency and time sync between the client and the server.
* This is not official API endpoint and is only used for internal testing purposes.
* Use this method to check the latency and time sync between the client and the server.
* Final values might vary slightly, but it should be within few ms difference.
* If you have any suggestions or improvements to this measurement, please create an issue or pull request on GitHub.
*/
fetchLatencySummary(): Promise<any>;
/**
*
* Gate.io misc endpoints
*
*/
getClientType(): RestClientType;
getSystemMaintenanceStatus(): Promise<any>;
/**================================================================================================================================
* WITHDRAW
* ==========================================================================================================================
*/
/**
* Withdraw
*
* Withdrawals to Gate addresses do not incur transaction fees.
*
* @param params Withdrawal parameters
* @returns Promise<Withdraw>
*/
submitWithdrawal(params: SubmitWithdrawalReq): Promise<WithdrawalRecord>;
/**
* Transfer between spot main accounts
*
* Both parties cannot be sub-accounts.
*
* @param params Transfer parameters
* @returns Promise<{
* id: number;
* }>
*/
submitSpotMainAccountTransfer(params: {
receive_uid: number;
currency: string;
amount: string;
}): Promise<{
id: number;
}>;
/**
* Cancel withdrawal with specified ID
*
* @param params Parameters containing the withdrawal ID
* @returns Promise<Withdraw>
*/
cancelWithdrawal(params: {
withdrawal_id: string;
}): Promise<WithdrawalRecord>;
/**==========================================================================================================================
* WALLET
* ==========================================================================================================================
*/
/**
* List chains supported for specified currency
*
* @param params Parameters containing the currency name
* @returns Promise< GetCurrencyChainsResp[][]>
*/
getCurrencyChains(params: {
currency: string;
}): Promise<CurrencyChain[]>;
/**
* Generate currency deposit address
*
* @param params Parameters containing the currency name
* @returns Promise<CreateDepositAddressResp>
*/
createDepositAddress(params: {
currency: string;
}): Promise<CreateDepositAddressResp>;
/**
* Retrieve withdrawal records
*
* Record time range cannot exceed 30 days
*
* @param params Parameters for filtering withdrawal records
* @returns Promise<Withdraw[]>
*/
getWithdrawalRecords(params?: GetWithdrawalDepositRecordsReq): Promise<WithdrawalRecord[]>;
/**
* Retrieve deposit records
*
* Record time range cannot exceed 30 days
*
* @param params Parameters for filtering deposit records
* @returns Promise<Withdraw[]>
*/
getDepositRecords(params?: GetWithdrawalDepositRecordsReq): Promise<WithdrawalRecord[]>;
/**
* Transfer between trading accounts
*
* Transfer between different accounts. Currently support transfers between the following:
* - spot - margin
* - spot - futures(perpetual)
* - spot - delivery
* - spot - cross margin
* - spot - options
*
* @param params Transfer parameters
* @returns Promise<TransferResponse>
*/
submitTransfer(params: SubmitTransferReq): Promise<{
tx_id: number;
}>;
/**
* Transfer between main and sub accounts
*
* Support transferring with sub user's spot or futures account. Note that only main user's spot account is used no matter which sub user's account is operated.
*
* @param params Transfer parameters
* @returns Promise<any>
*/
submitMainSubTransfer(params: SubmitMainSubTransferReq): Promise<any>;
/**
* Retrieve transfer records between main and sub accounts
*
* Record time range cannot exceed 30 days
*
* Note: only records after 2020-04-10 can be retrieved
*
* @param params Parameters for filtering transfer records
* @returns Promise<SubAccountTransferRecordResp[]>
*/
getMainSubTransfers(params?: GetMainSubTransfersReq): Promise<SubAccountTransferRecord[]>;
/**
* Sub-account transfers to sub-account
*
* It is possible to perform balance transfers between two sub-accounts under the same main account. You can use either the API Key of the main account or the API Key of the sub-account to initiate the transfer.
*
* @param params Transfer parameters
* @returns Promise<any>
*/
submitSubToSubTransfer(params: SubmitSubToSubTransferReq): Promise<any>;
/**
* Query transfer status based on client_order_id or tx_id
*
* @param params Parameters for querying transfer status
* @returns Promise<{
* tx_id: string;
* status: 'PENDING' | 'SUCCESS' | 'FAIL' | 'PARTIAL_SUCCESS';
* }>
*/
getTransferStatus(params: {
client_order_id?: string;
tx_id?: string;
}): Promise<{
tx_id: string;
status: 'PENDING' | 'SUCCESS' | 'FAIL' | 'PARTIAL_SUCCESS';
}>;
/**
* Retrieve withdrawal status
*
* @param params Parameters for retrieving withdrawal status
* @returns Promise<GetWithdrawalStatusResp[]>
*/
getWithdrawalStatus(params?: {
currency?: string;
}): Promise<WithdrawalStatus[]>;
/**
* Retrieve sub account balances
*
* @param params Parameters for retrieving sub account balances
* @returns Promise<{
uid: string;
available: { [key: string]: string };
}[]>
*/
getSubBalance(params?: {
sub_uid?: string;
}): Promise<{
uid: string;
available: {
[key: string]: string;
};
}[]>;
/**
* Query sub accounts' margin balances
*
* @param params Parameters for querying sub accounts' margin balances
* @returns Promise<SubAccountMarginBalancesResp[]>
*/
getSubMarginBalances(params?: {
sub_uid?: string;
}): Promise<{
uid: string;
available: SubAccountMarginBalance[];
}>;
/**
* Query sub accounts' futures account balances
*
* @param params Parameters for querying sub accounts' futures account balances
* @returns Promise<SubAccountFuturesBalancesResp[]>
*/
getSubFuturesBalances(params?: {
sub_uid?: string;
settle?: string;
}): Promise<SubAccountFuturesBalancesResp[]>;
/**
* Query subaccount's cross_margin account info
*
* @param params Parameters for querying subaccount's cross_margin account info
* @returns Promise<SubAccountCrossMarginBalancesResp[]>
*/
getSubCrossMarginBalances(params?: {
sub_uid?: string;
}): Promise<SubAccountCrossMarginBalancesResp[]>;
/**
* Query saved addresses
*
* @param params Parameters for querying saved address
* @returns Promise<GetSavedAddressResp[]>
*/
getSavedAddresses(params: GetSavedAddressReq): Promise<SavedAddress[]>;
/**
* Retrieve personal trading fee
*
* @param params Parameters for retrieving personal trading fee
* @returns Promise<GetTradingFeesResp>
*/
getTradingFees(params?: {
currency_pair?: string;
settle?: 'BTC' | 'USDT' | 'USD';
}): Promise<TradingFees>;
/**
* Retrieve user's total balances
*
* This endpoint returns an approximate sum of exchanged amount from all currencies to input currency for each account.
* The exchange rate and account balance could have been cached for at most 1 minute. It is not recommended to use its result for any trading calculation.
*
* For trading calculation, use the corresponding account query endpoint for each account type. For example:
* - GET /spot/accounts to query spot account balance
* - GET /margin/accounts to query margin account balance
* - GET /futures/{settle}/accounts to query futures account balance
*
* @param params Parameters for retrieving total balances
* @returns Promise<GetBalancesResp>
*/
getBalances(params?: {
currency?: string;
}): Promise<GetBalancesResp>;
/**
* List small balance
*
* @returns Promise<GetSmallBalancesResp>
*/
getSmallBalances(): Promise<SmallBalanceRecord>;
/**
* Convert small balance
*
* @param params Parameters for converting small balance
* @returns Promise<any>
*/
convertSmallBalance(params?: {
currency?: string[];
is_all?: boolean;
}): Promise<any>;
/**
* List small balance history
*
* @param params Parameters for listing small balance history
* @returns Promise<GetSmallBalanceHistoryResp[]>
*/
getSmallBalanceHistory(params?: GetSmallBalanceHistoryReq): Promise<SmallBalanceHistoryRecord[]>;
/**
* List push orders
*
* @param params Parameters for listing push orders
* @returns Promise<PushOrder[]>
*/
getPushOrders(params?: ListPushOrdersReq): Promise<PushOrder[]>;
/**==========================================================================================================================
* SUBACCOUNT
* ==========================================================================================================================
*/
/**
* Create a new sub-account
*
* @param params Parameters for creating a new sub-account
* @returns Promise<CreateSubAccountResp>
*/
createSubAccount(params: CreateSubAccountReq): Promise<SubAccount>;
/**
* List sub-accounts
*
* @param params Parameters for listing sub-accounts
* @returns Promise<GetSubAccountsResp[]>
*/
getSubAccounts(params?: {
type?: string;
}): Promise<SubAccount[]>;
/**
* Get the sub-account
*
* @param params Parameters containing the sub-account user ID
* @returns Promise<SubAccountResp>
*/
getSubAccount(params: {
user_id: number;
}): Promise<SubAccount>;
/**
* Create API Key of the sub-account
*
* @param params Parameters for creating API Key of the sub-account
* @returns Promise<CreateSubAccountApiKeyResp>
*/
createSubAccountApiKey(params: CreateSubAccountApiKeyReq): Promise<CreatedSubAccountAPIKey>;
/**
* List all API Key of the sub-account
*
* @param params Parameters containing the sub-account user ID
* @returns Promise<SubAccountKey[]>
*/
getSubAccountApiKeys(params: {
user_id: number;
}): Promise<SubAccountAPIKey[]>;
/**
* Update API key of the sub-account
*
* @param params Parameters for updating API key of the sub-account
* @returns Promise<any>
*/
updateSubAccountApiKey(params: UpdateSubAccountApiKeyReq): Promise<any>;
/**
* Delete API key of the sub-account
*
* @param params Parameters for deleting API key of the sub-account
* @returns Promise<any>
*/
deleteSubAccountApiKey(params: {
user_id: number;
key: string;
}): Promise<any>;
/**
* Get the API Key of the sub-account
*
* @param params Parameters containing the sub-account user ID and API key
* @returns Promise<SubAccountKey>
*/
getSubAccountApiKey(params: {
user_id: number;
key: string;
}): Promise<SubAccountAPIKey>;
/**
* Lock the sub-account
*
* @param params Parameters containing the sub-account user ID
* @returns Promise<any>
*/
lockSubAccount(params: {
user_id: number;
}): Promise<any>;
/**
* Unlock the sub-account
*
* @param params Parameters containing the sub-account user ID
* @returns Promise<any>
*/
unlockSubAccount(params: {
user_id: number;
}): Promise<any>;
/**
* Get sub-account mode
*
* Unified account mode:
* - classic: Classic account mode
* - multi_currency: Multi-currency margin mode
* - portfolio: Portfolio margin mode
*
* @returns Promise<SubAccountMode>
*/
getSubAccountMode(): Promise<SubAccountMode>;
/**==========================================================================================================================
* UNIFIED
* ==========================================================================================================================
*/
/**
* Get unified account information
*
* The assets of each currency in the account will be adjusted according to their liquidity, defined by corresponding adjustment coefficients, and then uniformly converted to USD to calculate the total asset value and position value of the account.
*
* @param params Parameters for retrieving unified account information
* @returns Promise<GetUnifiedAccountInfoResp>
*/
getUnifiedAccountInfo(params?: {
currency?: string;
sub_uid?: string;
}): Promise<UnifiedAccountInfo>;
/**
* Query about the maximum borrowing for the unified account
*
* @param params Parameters for querying the maximum borrowing for the unified account
* @returns Promise<{
* currency: string;
* amount: string;
* }>
*/
getUnifiedMaxBorrow(params: {
currency: string;
}): Promise<{
currency: string;
amount: string;
}>;
/**
* Query about the maximum transferable for the unified account
*
* @param params Parameters for querying the maximum transferable for the unified account
* @returns Promise<{
* currency: string;
* amount: string;
* }>
*/
getUnifiedMaxTransferable(params: {
currency: string;
}): Promise<{
currency: string;
amount: string;
}>;
/**
* Batch query maximum transferable amounts for unified accounts
*
* After withdrawing currency, the transferable amount will change.
*
* @param params Parameters containing currencies to query (up to 100 at once)
* @returns Promise with array of currency and maximum transferable amount
*/
getUnifiedMaxTransferables(params: {
currencies: string;
}): Promise<{
currency: string;
amount: string;
}[]>;
getUnifiedBatchMaxBorrowable(params: {
currencies: string[];
}): Promise<any>;
/**
* Borrow or repay
*
* When borrowing, it is essential to ensure that the borrowed amount is not below the minimum borrowing threshold for the specific cryptocurrency and does not exceed the maximum borrowing limit set by the platform and the user.
*
* The interest on the loan will be automatically deducted from the account at regular intervals. It is the user's responsibility to manage the repayment of the borrowed amount.
*
* For repayment, the option to repay the entire borrowed amount is available by setting the parameter repaid_all=true
*
* @param params Parameters for borrowing or repaying
* @returns Promise<any>
*/
submitUnifiedBorrowOrRepay(params: SubmitUnifiedBorrowOrRepayReq): Promise<any>;
/**
* List loans
*
* @param params Parameters for listing loans
* @returns Promise<GetUnifiedLoansResp[]>
*/
getUnifiedLoans(params?: GetUnifiedLoansReq): Promise<UnifiedLoan[]>;
/**
* Get loan records
*
* @param params Parameters for getting loan records
* @returns Promise<GetUnifiedLoanRecordsResp[]>
*/
getUnifiedLoanRecords(params?: GetUnifiedLoanRecordsReq): Promise<UnifiedLoanRecord[]>;
/**
* List interest records
*
* @param params Parameters for listing interest records
* @returns Promise<GetUnifiedInterestRecordsResp[]>
*/
getUnifiedInterestRecords(params?: GetUnifiedInterestRecordsReq): Promise<UnifiedInterestRecord[]>;
/**
* Retrieve user risk unit details, only valid in portfolio margin mode
*
* @returns Promise<GetUnifiedRiskUnitDetailsResp>
*/
getUnifiedRiskUnitDetails(): Promise<UnifiedRiskUnitDetails>;
/**
* Set mode of the unified account
*
* Switching between different account modes requires only passing the parameters corresponding to the target account mode. It also supports opening or closing configuration switches for the corresponding account mode when switching.
*
* @param params Parameters for setting the mode of the unified account
* @returns Promise<any>
*/
setUnifiedAccountMode(params: SetUnifiedAccountModeReq): Promise<any>;
/**
* Query mode of the unified account
*
* @returns Promise<SetUnifiedAccountModeReq>
*/
getUnifiedAccountMode(): Promise<SetUnifiedAccountModeReq>;
/**
* Get unified estimate rate
*
* Due to fluctuations in lending depth, hourly interest rates may vary, and thus, I cannot provide exact rates. When a currency is not supported, the interest rate returned will be an empty string.
*
* @param params Parameters for querying estimate rates
* @returns Promise<{ [key: string]: string }>
*/
getUnifiedEstimateRate(params: {
currencies: string[];
}): Promise<{
[key: string]: string;
}>;
/**
* List currency discount tiers
*
* @returns Promise<GetUnifiedCurrencyDiscountTiersResp[]>
*/
getUnifiedCurrencyDiscountTiers(): Promise<UnifiedCurrencyDiscountTiers[]>;
/**
* List loan margin tiers
*
* @returns Promise<{
* currency: string;
* margin_tiers: MarginTier[];
* }[]>
*/
getLoanMarginTiers(): Promise<{
currency: string;
margin_tiers: MarginTier[];
}[]>;
/**
* Portfolio margin calculator
*
* Portfolio Margin Calculator When inputting a simulated position portfolio, each position includes the position name and quantity held, supporting markets within the range of BTC and ETH perpetual contracts, options, and spot markets. When inputting simulated orders, each order includes the market identifier, order price, and order quantity, supporting markets within the range of BTC and ETH perpetual contracts, options, and spot markets. Market orders are not included.
*
* @param params Parameters for portfolio margin calculator
* @returns Promise<PortfolioMarginCalculatorResp>
*/
portfolioMarginCalculate(params: PortfolioMarginCalculatorReq): Promise<PortfolioMarginCalculation>;
/**
* Query user currency leverage configuration
*
* Get the maximum and minimum leverage multiples that users can set for a currency type
*
* @param params Parameters containing the currency
* @returns Promise<UserCurrencyLeverageConfig>
*/
getUserCurrencyLeverageConfig(params: {
currency: string;
}): Promise<UserCurrencyLeverageConfig>;
/**
* Get the user's currency leverage
*
* If currency is not passed, query all currencies.
*
* @param params Optional parameters containing the currency
* @returns Promise<UserCurrencyLeverageSetting[]>
*/
getUserCurrencyLeverageSettings(params?: {
currency?: string;
}): Promise<{
currency: string;
leverage: string;
}[]>;
/**
* Set the currency leverage ratio
*
* @param params Parameters for setting currency leverage ratio
* @returns Promise<any> Returns nothing on success (204 No Content)
*/
updateUserCurrencyLeverage(params: {
currency: string;
leverage: string;
}): Promise<any>;
/**
* List loan currencies supported by unified account
*
* @param params Optional parameters for filtering
* @returns Promise with array of loan currencies
*/
getUnifiedLoanCurrencies(params?: {
currency?: string;
}): Promise<UnifiedLoanCurrency[]>;
/**
* Get historical lending rates
*
* @param params Parameters for retrieving historical lending rates
* @returns Promise<UnifiedHistoryLendingRate>
*/
getHistoricalLendingRates(params: GetUnifiedHistoryLendingRateReq): Promise<UnifiedHistoryLendingRate>;
submitUnifiedLoanRepay(params: SubmitUnifiedLoanRepayReq): Promise<any>;
/**==========================================================================================================================
* SPOT
* ==========================================================================================================================
*/
/**
* List all currencies' details
*
* Currency has two forms:
* - Only currency name, e.g., BTC, USDT
* - <currency>_<chain>, e.g., HT_ETH
*
* The latter one occurs when one currency has multiple chains. Currency detail contains a chain field whatever the form is. To retrieve all chains of one currency, you can use all the details which have the name of the currency or name starting with <currency>_.
*
* @returns Promise<GetSpotCurrenciesResp[]>
*/
getSpotCurrencies(): Promise<SpotCurrency[]>;
/**
* Get details of a specific currency
*
* @param params Parameters for retrieving details of a specific currency
* @returns Promise<GetSpotCurrenciesResp>
*/
getSpotCurrency(params: {
currency: string;
}): Promise<SpotCurrency>;
/**
* List all currency pairs supported
*
* @returns Promise<CurrencyPair[]>
*/
getSpotCurrencyPairs(): Promise<CurrencyPair[]>;
/**
* Get details of a specific currency pair
*
* @param params Parameters for retrieving details of a specific currency pair
* @returns Promise<CurrencyPair>
*/
getSpotCurrencyPair(params: {
currency_pair: string;
}): Promise<CurrencyPair>;
/**
* Retrieve ticker information
*
* Return only related data if currency_pair is specified; otherwise return all of them.
*
* @param params Parameters for retrieving ticker information
* @returns Promise<GetSpotTickerResp[]>
*/
getSpotTicker(params?: {
currency_pair?: string;
timezone?: 'utc0' | 'utc8' | 'all';
}): Promise<SpotTicker[]>;
/**
* Retrieve order book
*
* Order book will be sorted by price from high to low on bids; low to high on asks.
*
* @param params Parameters for retrieving order book
* @returns Promise<GetSpotOrderBookResp>
*/
getSpotOrderBook(params: GetSpotOrderBookReq): Promise<SpotOrderBook>;
/**
* Retrieve market trades
*
* You can use from and to to query by time range, or use last_id by scrolling page. The default behavior is by time range.
* Scrolling query using last_id is not recommended any more. If last_id is specified, time range query parameters will be ignored.
*
* @param params Parameters for retrieving market trades
* @returns Promise<GetSpotTradesResp[]>
*/
getSpotTrades(params: GetSpotTradesReq): Promise<SpotTrade[]>;
/**
* Market Candles
*
* Maximum of 1000 points can be returned in a query. Be sure not to exceed the limit when specifying from, to and interval.
*
* @param params Parameters for retrieving market Candles
* @returns Promise<GetSpotCandlesResp>
*/
getSpotCandles(params: GetSpotCandlesReq): Promise<SpotCandle[]>;
/**
* Query user trading fee rates
*
* This API is deprecated in favour of new fee retrieving API /wallet/fee.
*
* @param params Parameters for querying user trading fee rates
* @returns Promise<GetSpotFeeRatesResp>
*/
getSpotFeeRates(params?: {
currency_pair?: string;
}): Promise<SpotFeeRates>;
/**
* Query a batch of user trading fee rates
*
* @param params Parameters for querying a batch of user trading fee rates
*/
getSpotBatchFeeRates(params: {
currency_pairs: string;
}): Promise<Record<string, SpotFeeRates>>;
/**
* List spot accounts
*
* @param params Parameters for listing spot accounts
* @returns Promise<GetSpotAccountsResp[]>
*/
getSpotAccounts(params?: {
currency?: string;
}): Promise<SpotAccount[]>;
/**
* Query account book
*
* Record time range cannot exceed 30 days.
*
* @param params Parameters for querying account book
* @returns Promise<GetSpotAccountBookResp[]>
*/
getSpotAccountBook(params?: GetSpotAccountBookReq): Promise<SpotAccountBook[]>;
/**
* Create a batch of orders
*
* Batch orders requirements:
* - custom order field text is required
* - At most 4 currency pairs, maximum 10 orders each, are allowed in one request
* - No mixture of spot orders and margin orders, i.e. account must be identical for all orders
*
* NOTE: The "xGateExptime" parameter will translate to the "x-gate-exptime" header.
*
* @param params Parameters for creating a batch of orders
* @returns Promise<SubmitSpotBatchOrdersResp[]>
*/
submitSpotBatchOrders(body: SpotOrder[], params?: {
xGateExptime?: number;
}): Promise<SubmitSpotBatchOrdersResp[]>;
/**
* List all open orders
*
* List open orders in all currency pairs.
* Note that pagination parameters affect record number in each currency pair's open order list. No pagination is applied to the number of currency pairs returned. All currency pairs with open orders will be returned.
* Spot, portfolio, and margin orders are returned by default. To list cross margin orders, account must be set to cross_margin.
*
* @param params Parameters for listing all open orders
* @returns Promise<GetSpotOpenOrdersResp[]>
*/
getSpotOpenOrders(params?: {
page?: number;
limit?: number;
account?: 'spot' | 'margin' | 'cross_margin' | 'unified';
}): Promise<GetSpotOpenOrdersResp[]>;
/**
* Close position when cross-currency is disabled
*
* Currently, only cross-margin accounts are supported to close position when cross currencies are disabled. Maximum buy quantity = (unpaid principal and interest - currency balance - the amount of the currency in the order book) / 0.998
*
* @param params Parameters for closing position when cross-currency is disabled
* @returns Promise<Order>
*/
submitSpotClosePosCrossDisabled(params: SubmitSpotClosePosCrossDisabledReq): Promise<SpotOrder>;
/**
* Create an order
*
* You can place orders with spot, portfolio, margin or cross margin account through setting the account field. It defaults to spot, which means spot account is used to place orders. If the user is using unified account, it defaults to the unified account.
*
* NOTE: The "xGateExptime" parameter will translate to the "x-gate-exptime" header.
*
* @param params Parameters for creating an order
* @returns Promise<Order>
*/
submitSpotOrder(params: SubmitSpotOrderReq): Promise<SpotOrder>;
/**
* List orders
*
* Spot, portfolio and margin orders are returned by default. If cross margin orders are needed, account must be set to cross_margin.
*
* @param params Parameters for listing orders
* @returns Promise<Order[]>
*/
getSpotOrders(params: GetSpotOrdersReq): Promise<SpotOrder[]>;
/**
* Cancel all open orders in specified currency pair
*
* If account is not set, all open orders, including spot, portfolio, margin and cross margin ones, will be cancelled.
* You can set account to cancel only orders within the specified account.
*
* NOTE: The "xGateExptime" parameter will translate to the "x-gate-exptime" header.
*
* @param params Parameters for cancelling all open orders in specified currency pair
* @returns Promise<Order[]>
*/
cancelSpotOpenOrders(params: {
currency_pair: string;
side?: 'buy' | 'sell';
account?: 'spot' | 'margin' | 'cross_margin' | 'unified';
action_mode?: 'ACK' | 'RESULT' | 'FULL';
xGateExptime?: number;
}): Promise<SpotOrder[]>;
/**
* Cancel a batch of orders with an ID list
*
* Multiple currency pairs can be specified, but maximum 20 orders are allowed per request.
*
* NOTE: The "xGateExptime" parameter will translate to the "x-gate-exptime" header.
*
* @param params Parameters for cancelling a batch of orders
* @returns Promise<DeleteSpotBatchOrdersResp[]>
*/
batchCancelSpotOrders(body: CancelSpotBatchOrdersReq[], params?: {
xGateExptime?: number;
}): Promise<DeleteSpotBatchOrdersResp[]>;
/**
* Get a single order
*
* Spot, portfolio and margin orders are queried by default. If cross margin orders are needed or portfolio margin account are used, account must be set to cross_margin.
*
* @param params Parameters for getting a single order
* @returns Promise<Order>
*/
getSpotOrder(params: GetSpotOrderReq): Promise<SpotOrder>;
/**
* Amend an order
*
* By default, the orders of spot, portfolio and margin account are updated. If you need to modify orders of the cross-margin account, you must specify account as cross_margin. For portfolio margin account, only cross_margin account is supported.
*
* Currently, only supports modification of price or amount fields.
*
* NOTE: The "xGateExptime" parameter will translate to the "x-gate-exptime" header.
*
* @param params Parameters for amending an order
* @returns Promise<Order>
*/
updateSpotOrder(params: UpdateSpotOrderReq): Promise<SpotOrder>;
/**
* Cancel a single order
*
* Spot, portfolio and margin orders are cancelled by default. If trying to cancel cross margin orders or portfolio margin account are used, account must be set to cross_margin.
*
* NOTE: The "xGateExptime" parameter will translate to the "x-gate-exptime" header.
*
* @param params Parameters for cancelling a single order
* @returns Promise<Order>
*/
cancelSpotOrder(params: DeleteSpotOrderReq): Promise<SpotOrder>;
/**
* List personal trading history
*
* Spot, portfolio and margin trades are queried by default. If cross margin trades are needed, account must be set to cross_margin.
*
* You can also set from and/or to to query by time range. If you don't specify from and/or to parameters, only the last 7 days of data will be returned. The range of from and to is not allowed to exceed 30 days. Time range parameters are handled as order finish time.
*
* @param params Parameters for listing personal trading history
* @returns Promise<GetSpotTradingHistoryResp[]>
*/
getSpotTradingHistory(params?: GetSpotTradingHistoryReq): Promise<SpotHistoricTradeRecord[]>;
/**
* Get server current time
*
* @returns Promise<{
* server_time: number;
* }>
*/
getServerTime(): Promise<{
server_time: number;
}>;
/**
* Countdown cancel orders
*
* When the timeout set by the user is reached, if there is no cancel or set a new countdown, the related pending orders will be automatically cancelled. This endpoint can be called repeatedly to set a new countdown or cancel the countdown.
*
* @param params Parameters for setting countdown cancel orders
* @returns Promise<{
* triggerTime: number;
* }>
*/
submitSpotCountdownOrders(params: {
timeout: number;
currency_pair?: string;
}): Promise<{
triggerTime: number;
}>;
/**
* Batch modification of orders
*
* Default modification of orders for spot, portfolio, and margin accounts. To modify orders for a cross margin account, the account parameter must be specified as cross_margin. For portfolio margin accounts, the account parameter can only be specified as cross_margin. Currently, only modifications to price or quantity (choose one) are supported.
*
* NOTE: The "xGateExptime" parameter will translate to the "x-gate-exptime" header.
*
* @param params Parameters for batch modification of orders
* @returns Promise<Order[]>
*/
batchUpdateSpotOrders(body: UpdateSpotBatchOrdersReq[], params?: {
xGateExptime?: number;
}): Promise<SpotOrder[]>;
/**
* Query spot insurance fund historical data
*
* @param params Parameters for querying spot insurance fund history
* @returns Promise<{
* currency: string;
* balance: string;
* time: number;
* }[]>
*/
getSpotInsuranceHistory(params: GetSpotInsuranceHistoryReq): Promise<SpotInsuranceHistory[]>;
/**
* Create a price-triggered order
*
* @param params Parameters for creating a price-triggered order
* @returns Promise<{
* id: number;
* }>
*/
submitSpotPriceTriggerOrder(params: SpotPriceTriggeredOrder): Promise<{
id: number;
}>;
/**
* Retrieve running auto order list
*
* @param params Parameters for retrieving running auto order list
* @returns Promise<SpotPriceTriggeredOrder[]>
*/
getSpotAutoOrders(params: GetSpotAutoOrdersReq): Promise<SpotPriceTriggeredOrder[]>;
/**
* Cancel all open orders
*
* @param params Parameters for cancelling all open orders
* @returns Promise<SpotPriceTriggeredOrder[]>
*/
cancelAllOpenSpotOrders(params?: {
market?: string;
account?: 'normal' | 'margin' | 'cross_margin';
}): Promise<SpotPriceTriggeredOrder[]>;
/**
* Get a price-triggered order
*
* @param params Parameters for getting a price-triggered order
* @returns Promise<SpotPriceTriggeredOrder>
*/
getPriceTriggeredOrder(params: {
order_id: string;
}): Promise<SpotPriceTriggeredOrder>;
/**
* Cancel a price-triggered order
*
* @param params Parameters for cancelling a price-triggered order
* @returns Promise<SpotPriceTriggeredOrder>
*/
cancelSpotTriggeredOrder(params: {
order_id: string;
}): Promise<SpotPriceTriggeredOrder>;
/**
* Set collateral currency
*
* @param params Parameters for setting collateral currency
* @returns Promise<{
* is_success: boolean;
* }>
*/
setCollateralCurrency(params: {
collateral_type: 0 | 1;
enable_list?: string[];
disable_list?: string[];
}): Promise<{
is_success: boolean;
}>;
/**==========================================================================================================================
* MARGIN
* ==========================================================================================================================
*/
/**
* Margin account list
*
* @param params Parameters for listing margin accounts
* @returns Promise<GetMarginAccountsResp[]>
*/
getMarginAccounts(params?: {
currency_pair?: string;
}): Promise<MarginAccount[]>;
/**
* List margin account balance change history
*
* Only transferals from and to margin account are provided for now. Time range allows 30 days at most.
*
* @param params Parameters for listing margin account balance change history
* @returns Promise<GetMarginBalanceHistoryResp[]>
*/
getMarginBalanceHistory(params?: GetMarginBalanceHistoryReq): Promise<MarginBalanceHistoryRecord[]>;
/**
* Funding account list
*
* @param params Parameters for listing funding accounts
* @returns Promise<{
* currency: string;
* available: string;
* locked: string;
* lent: string;
* total_lent: string;
* }[]>
*/
getFundingAccounts(params?: {
currency?: string;
}): Promise<{
currency: string;
available: string;
locked: string;
lent: string;
total_lent: string;
}[]>;
/**
* Update user's auto repayment setting
*
* @param params Parameters for updating auto repayment setting
* @returns Promise<{ status: 'on' | 'off' }>
*/
updateAutoRepaymentSetting(params: {
status: 'on' | 'off';
}): Promise<{
status: 'on' | 'off';
}>;
/**
* Retrieve user auto repayment setting
*
* @returns Promise<{ status: 'on' | 'off' }>
*/
getAutoRepaymentSetting(): Promise<{
status: 'on' | 'off';
}>;
/**
* Get the max transferable amount for a specific margin currency
*
* @param params Parameters for retrieving the max transferable amount
* @returns Promise<{
* currency: string;
* currency_pair?: string;
* amount: string;
* }>
*/
getMarginTransferableAmount(params: {
currency: string;
currency_pair?: string;
}): Promise<{
currency: string;
currency_pair?: string;
amount: string;
}>;
/**
* @deprecated as of 2025-02-10
* Currencies supported by cross margin
*
* @returns Promise<GetCrossMarginCurrenciesResp[]>
*/
getCrossMarginCurrencies(): Promise<CrossMarginCurrency[]>;
/**
* @deprecated as of 2025-02-10
* Retrieve detail of one single currency supported by cross margin
*
* @param params Parameters containing the currency name
* @returns Promise<GetCrossMarginCurrenciesResp>
*/
getCrossMarginCurrency(params: {
currency: string;
}): Promise<CrossMarginCurrency>;
/**
* @deprecated as of 2025-02-10
* Retrieve cross margin account
*
* @returns Promise<GetCrossMarginAccountResp>
*/
getCrossMarginAccount(): Promise<CrossMarginAccount>;
/**
* @deprecated as of 2025-02-10
* Retrieve cross margin account change history
*
* Record time range cannot exceed 30 days.
*
* @param params Parameters for retrieving cross margin account change history
* @returns Promise<GetCrossMarginAccountHistoryResp[]>
*/
getCrossMarginAccountHistory(params?: GetCrossMarginAccountHistoryReq): Promise<CrossMarginAccountHistoryRecord[]>;
/**
*
* @deprecated as of 2025-02-10
* Create a cross margin borrow loan
*
* Borrow amount cannot be less than currency minimum borrow amount.
*
* @param params Parameters for creating a cross margin borrow loan
* @returns Promise<SubmitCrossMarginBorrowLoanResp>
*
*/
submitCrossMarginBorrowLoan(params: SubmitCrossMarginBorrowLoanReq): Promise<CrossMarginMorrowLoanRecord>;
/**
*
* List cross margin borrow history
*
* Sort by creation time in descending order by default. Set reverse=false to return ascending results.
*
* @param params Parameters for listing cross margin borrow history
* @returns Promise<SubmitCrossMarginBorrowLoanResp[]>
*/
getCrossMarginBorrowHistory(params: GetCrossMarginBorrowHistoryReq): Promise<CrossMarginMorrowLoanRecord[]>;
/**
* @deprecated as of 2025-02-10
* Retrieve single borrow loan detail
*
* @param params Parameters containing the borrow loan ID
* @returns Promise<SubmitCrossMarginBorrowLoanResp>
*/
getCrossMarginBorrowLoan(params: {
loan_id: string;
}): Promise<CrossMarginMorrowLoanRecord>;
/**
* @deprecated as of 2025-02-10
* Cross margin repayments
*
* When the liquidity of the currency is insufficient and the transaction risk is high, the currency will be disabled, and funds cannot be transferred. When the available balance of cross-margin is insufficient, the balance of the spot account can be used for repayment. Please ensure that the balance of the spot account is sufficient, and system uses cross-margin account for repayment first.
*
* @param params Parameters for cross margin repayments
* @returns Promise<SubmitCrossMarginBorrowLoanResp[]>
*/
submitCrossMarginRepayment(params: {
currency: string;
amount: string;
}): Promise<CrossMarginMorrowLoanRecord[]>;
/**
* @deprecated as of 2025-02-10
* Retrieve cross margin repayments
*
* Sort by creation time in descending order by default. Set reverse=false to return ascending results.
*
* @param params Parameters for retrieving cross margin repayments
* @returns Promise<GetCrossMarginRepaymentsResp[]>
*/
getCrossMarginRepayments(params?: GetCrossMarginRepaymentsReq): Promise<CrossMarginAccount[]>;
/**
* @deprecated as of 2025-02-10
* Interest records for the cross margin account
*
* @param params Parameters for retrieving interest records
* @returns Promise<GetCrossMarginInterestRecordsResp[]>
*/
getCrossMarginInterestRecords(params?: GetCrossMarginInterestRecordsReq): Promise<GetCrossMarginInterestRecordsReq[]>;
/**
* @deprecated as of 2025-02-10
* Get the max transferable amount for a specific cross margin currency