UNPKG

@exchange-connect/coinex

Version:
1,119 lines 53.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.deleteSubAccountAPIKEY = exports.editSubAccountAPIKEY = exports.acquireSubAccountAPIKEYDetail = exports.acquireSubAccountAPIKEYList = exports.createSubAccountAPIKEY = exports.editAccountSettings = exports.freezeSubAccount = exports.unfreezeSubAccount = exports.createSubAccount = exports.acquireWithdrawalHistory = exports.transferRecordBetweenMarginSpotAccount = exports.transferRecordBetweenSpotPerpetualAccount = exports.acquireLoanRecordInMarginAccount = exports.acquireTransferRecordBetweenMainAndSubAccount = exports.transferRecordBetweenSpotFinancialAccount = exports.inquireDepositAddress = exports.updateDepositAddress = exports.marginRepayment = exports.marginLoan = exports.cancelWithdrawalRequest = exports.submitWithdrawalRequest = exports.assetTransferBetweenSpotPerpetualAccount = exports.assetTransferBetweenSpotMarginAccount = exports.spotAssetTransferBetweenMainAndSubAccount = exports.acquireTradingFeeRate = exports.inquireUserOperationHistory = exports.acquireDepositRecord = exports.acquireBalanceInCreditAccount = exports.inquireMarginAccountSettings = exports.acquireMarketInfoInMarginAccount = exports.acquireCreditInfoInAccount = exports.acquireBalanceInFinancialAccount = exports.acquireBalanceInAMMAccount = exports.acquireBalanceInSubAccount = exports.acquireAccountBalanceInfo = void 0; /** * @fileOverview Account API Endpoints * @module Account * @requires executeRequest */ var _a = require("../../constants"), BASE_URLS = _a.BASE_URLS, METHOD_TYPE = _a.METHOD_TYPE; var executeRequest = require("../../libs").executeRequest; var signParams = require("../../utils").signParams; /** * Acquire Account Balance Info * @async * @function acquireAccountBalanceInfo * @param {Object} options Optional Parameters * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<AccountBalanceInfoResults>} Promise object represents the result of the request */ function acquireAccountBalanceInfo(_a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/balance/info", params: params, }); } exports.acquireAccountBalanceInfo = acquireAccountBalanceInfo; /** * Acquire Balance In Sub Account * @async * @function acquireBalanceInSubAccount * @param {Object} options Optional Parameters * @param {String} [options.coin_type] Coin name * @param {String} [options.sub_user_name] Sub-account name * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<SubAccountBalanceInfoResults>} Promise object represents the result of the request */ function acquireBalanceInSubAccount(_a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, coin_type = _b.coin_type, sub_user_name = _b.sub_user_name, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { coin_type: coin_type, sub_user_name: sub_user_name, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/sub_account/balance", params: params, }); } exports.acquireBalanceInSubAccount = acquireBalanceInSubAccount; /** * Acquire Balance in AMM Account * @async * @function acquireBalanceInAMMAccount * @param {Object} options Optional Parameters * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<Array<AMMAccountBalanceInfoResult>>} Promise object represents the result of the request */ function acquireBalanceInAMMAccount(_a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/account/amm/balance", params: params, }); } exports.acquireBalanceInAMMAccount = acquireBalanceInAMMAccount; /** * Acquire Balance in Financial Account * @async * @function acquireBalanceInFinancialAccount * @param {Object} options Optional Parameters * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<Array<FinancialAccountBalanceInfoResult>>} Promise object represents the result of the request */ function acquireBalanceInFinancialAccount(_a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/account/investment/balance", params: params, }); } exports.acquireBalanceInFinancialAccount = acquireBalanceInFinancialAccount; /** * Acquire Credit Info in Account * @async * @function acquireCreditInfoInAccount * @param {Object} options Optional Parameters * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<CreditInfoResult>} Promise object represents the result of the request */ function acquireCreditInfoInAccount(_a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/credit/info", params: params, }); } exports.acquireCreditInfoInAccount = acquireCreditInfoInAccount; /** * Acquire Market Info in Margin Account * @async * @function acquireMarketInfoInMarginAccount * @param {String} market Market * @param {Object} options Optional Parameters * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<MarginAccountCreditInfoResult>} Promise object represents the result of the request */ function acquireMarketInfoInMarginAccount(market, _a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { market: market, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/margin/account", params: params, }); } exports.acquireMarketInfoInMarginAccount = acquireMarketInfoInMarginAccount; /** * Inquire Margin Account Settings * @async * @function inquireMarginAccountSettings * @param {String} market Market * @param {Object} options Optional Parameters * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<MarginAccountSettingsResult>} Promise object represents the result of the request */ function inquireMarginAccountSettings(market, _a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { market: market, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/margin/config", params: params, }); } exports.inquireMarginAccountSettings = inquireMarginAccountSettings; /** * Acquire Balance in Credit Account * @async * @function acquireBalanceInCreditAccount * @param {Object} options Optional Parameters * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<Array<BalanceInCreditAccountResult>>} Promise object represents the result of the request */ // @ts-ignore function acquireBalanceInCreditAccount(_a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/credit/balance", params: params, }); } exports.acquireBalanceInCreditAccount = acquireBalanceInCreditAccount; /** * [Acquire Deposit Record]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account009_deposit_list} * @async * @function acquireDepositRecord * @param {Object} options Optional Parameters * @param {String} [options.coin_type] Coin name * @param {"processing"|"confirming"|"cancel"|"finish"|"too_small"|"to_hot"} [options.status] State * @param {Number} [options.page=1] Page number, starting from 1 * @param {Number} [options.limit=10] Number of items per page, Max. 100 * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<Array<DepositRecordResult>>} Promise object represents the result of the request */ function acquireDepositRecord(_a) { var _b = _a === void 0 ? { page: 1, limit: 10, tonce: Date.now(), } : _a, coin_type = _b.coin_type, status = _b.status, page = _b.page, limit = _b.limit, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { coin_type: coin_type, status: status, page: page, limit: limit, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/balance/coin/deposit", params: params, }); } exports.acquireDepositRecord = acquireDepositRecord; /** * [Inquire User Operation History]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account010_balance_history} * @async * @function inquireUserOperationHistory * @param {Object} options Optional Parameters * @param {String} [options.asset] Asset * @param {Number} [options.account_id] Spot account ID: 0, Margin account ID: See [Acquire Market Info in Margin Account]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account006_margin_account} * @param {"trade"|"withdraw"|"deposit"|"maker_cash_back"} [options.business] Operation type ( trade: transaction, withdraw: withdrawal, deposit: deposit, maker_cash_back: spot maker rebate ) * @param {Number} [options.page=1] Page number, starting from 1 * @param {Number} [options.limit=10] Number of items per page, Max. 100 * @param {Number} [options.start_time] Query start time * @param {Number} [options.end_time] Query end time * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<Array<UserOperationHistoryResult>>} Promise object represents the result of the request */ function inquireUserOperationHistory(_a) { var _b = _a === void 0 ? { page: 1, limit: 10, tonce: Date.now(), } : _a, asset = _b.asset, account_id = _b.account_id, business = _b.business, page = _b.page, limit = _b.limit, start_time = _b.start_time, end_time = _b.end_time, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { asset: asset, account_id: account_id, business: business, page: page, limit: limit, start_time: start_time, end_time: end_time, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/account/balance/history", params: params, }); } exports.inquireUserOperationHistory = inquireUserOperationHistory; /** * [Acquire Trading Fee Rate]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account011_market_fee} * @async * @function acquireTradingFeeRate * @param {String} market Market * @param {Object} options Optional Parameters * @param {"SPOT"|"PERPETUAL"} [options.business_type="SPOT"] Transaction Type SPOT: Spot (default) PERPETUAL: Contract * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<TradingFeeRateResult>} Promise object represents the result of the request */ function acquireTradingFeeRate(market, _a) { var _b = _a === void 0 ? { business_type: "SPOT", tonce: Date.now(), } : _a, business_type = _b.business_type, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { market: market, business_type: business_type, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/account/market/fee", params: params, }); } exports.acquireTradingFeeRate = acquireTradingFeeRate; /** * [Spot Asset Transfer Between Main and Sub-Account]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account012_subaccount_transfer} * @async * @function spotAssetTransferBetweenMainAndSubAccount * @param {String} coin_type Coin name * @param {String} amount Transfer amount * @param {Object} options Optional Parameters * @param {"in"|"out"} [options.transfer_side="in"] Operation ("in": transfer in, "out": transfer out) * @param {String} [options.transfer_account] Sub-account name * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<{}>} Promise object represents the result of the request */ function spotAssetTransferBetweenMainAndSubAccount(coin_type, amount, _a) { var _b = _a === void 0 ? { transfer_side: "in", tonce: Date.now(), } : _a, transfer_side = _b.transfer_side, transfer_account = _b.transfer_account, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { coin_type: coin_type, amount: amount, transfer_side: transfer_side, transfer_account: transfer_account, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.POST, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/sub_account/transfer", params: params, }); } exports.spotAssetTransferBetweenMainAndSubAccount = spotAssetTransferBetweenMainAndSubAccount; /** * [Asset Transfer Between Spot - Margin Account]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account013_margin_transfer} * @async * @function assetTransferBetweenSpotMarginAccount * @param {String} amount Transfer amount * @param {String} coin_type Coin name * @param {Number} from_account Spot account ID: 0, Margin account ID: See [Acquire Market Info in Margin Account]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account006_margin_account} * @param {Number} to_account Spot account ID: 0, Margin account ID: See [Acquire Market Info in Margin Account]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account006_margin_account} * @param {Object} options Optional Parameters * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<null>} Promise object represents the result of the request */ function assetTransferBetweenSpotMarginAccount(amount, coin_type, from_account, to_account, _a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { amount: amount, coin_type: coin_type, from_account: from_account, to_account: to_account, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.POST, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/margin/transfer", params: params, }); } exports.assetTransferBetweenSpotMarginAccount = assetTransferBetweenSpotMarginAccount; /** * [Asset Transfer Between Spot - Perpetual Account]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account014_balance_contract_transfer} * @async * @function assetTransferBetweenSpotPerpetualAccount * @param {String} amount Number of transfers * @param {String} coin_type Coin name * @param {"directionin"|"Accountout"} transfer_side Operation (directionin: from Spot to Perpetual, Accountout: from Perpetual to Spot Account) * @param {Object} options Optional Parameters * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<null>} Promise object represents the result of the request */ function assetTransferBetweenSpotPerpetualAccount(amount, coin_type, transfer_side, _a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { amount: amount, coin_type: coin_type, transfer_side: transfer_side, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.POST, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/contract/balance/transfer", params: params, }); } exports.assetTransferBetweenSpotPerpetualAccount = assetTransferBetweenSpotPerpetualAccount; /** * [Submit Withdrawal Request]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account015_submit_withdraw} * @async * @function submitWithdrawalRequest * @param {String} actual_amount The actual amount of withdrawal refers to the amount one actually receives after deducting the service fee. see [Fee Rates]{@link https://www.coinex.com/fees} for more info * @param {String} coin_type Coin name * @param {String} coin_address Authorized withdrawal address. For instance, if you are withdrawing XMR or XMC, you need to use “:” to combine “address” and “payment_id” into the form of “xxx:yyy”; When withdrawing XRP, you need to use “:” to combine “address” and “tag” “Combine into the form of “xxx:yyy”. You can fill in the mobile phone number or email address for Inter-user Transfer * @param {Object} options Optional Parameters * @param {String} [options.smart_contract_name] Required by cryptocurrencies that support multiple withdrawal network, such as USDT is supported on ERC20, Omni, TRC20 * @param {"onchain"|"local"} [options.transfer_method] onchain: Onchain transfer, local: Inter-user transfer * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<WithdrawalRequestResult>} Promise object represents the result of the request */ function submitWithdrawalRequest(actual_amount, coin_type, coin_address, _a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, smart_contract_name = _b.smart_contract_name, transfer_method = _b.transfer_method, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { actual_amount: actual_amount, coin_type: coin_type, coin_address: coin_address, smart_contract_name: smart_contract_name, transfer_method: transfer_method, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.POST, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/balance/coin/withdraw", params: params, }); } exports.submitWithdrawalRequest = submitWithdrawalRequest; /** * Cancel Withdrawal Request * @async * @function cancelWithdrawalRequest * @param {String} coin_withdraw_id Withdrawal record ID * @param {Object} options Optional Parameters * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<{}>} Promise object represents the result of the request */ function cancelWithdrawalRequest(coin_withdraw_id, _a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { coin_withdraw_id: coin_withdraw_id, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.DELETE, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/balance/coin/withdraw", params: params, }); } exports.cancelWithdrawalRequest = cancelWithdrawalRequest; /** * [Margin Loan]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account017_margin_loan} * @async * @function marginLoan * @param {String} amount Loan amount * @param {String} coin_type Coin name * @param {String} market Market name * @param {Object} options Optional Parameters * @param {0|1} [options.renew] Whether to renew automatically (0:No, 1:Yes) * @param {String} [options.access_id] Access ID * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<MarginLoanResult>} Promise object represents the result of the request */ function marginLoan(amount, coin_type, market, _a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, renew = _b.renew, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { amount: amount, coin_type: coin_type, market: market, renew: renew, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.POST, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/margin/loan", params: params, }); } exports.marginLoan = marginLoan; /** * [Margin Repayment]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account018_margin_flat} * @async * @function marginRepayment * @param {String} amount Paid amount * @param {String} coin_type Coin name * @param {String} market Market name * @param {Object} options Optional Parameters * @param {Number} [options.loan_id] The ID of loan record, which is blank when the remaining amount of loan in the current market is paid off. * @param {String} [options.access_id] access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<null>} Promise object represents the result of the request */ function marginRepayment(amount, coin_type, market, _a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, loan_id = _b.loan_id, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { amount: amount, coin_type: coin_type, market: market, loan_id: loan_id, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.POST, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/margin/flat", params: params, }); } exports.marginRepayment = marginRepayment; /** * [Update Deposit Address]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account019_update_deposit_address} * @async * @function updateDepositAddress * @param {Object} options Optional Parameters * @param {Number} [options.smart_contract_name] If a certain coin support multiple networks, the protocol type must be specified. * @param {String} [options.access_id] access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<DepositAddressResult>} Promise object represents the result of the request */ function updateDepositAddress(_a) { var _b = _a === void 0 ? { tonce: Date.now(), } : _a, smart_contract_name = _b.smart_contract_name, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { smart_contract_name: smart_contract_name, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.PUT, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/balance/deposit/address/<string:coin_type>", params: params, }); } exports.updateDepositAddress = updateDepositAddress; /** * [Inquire Deposit Address]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account020_query_deposit_address} * @async * @function inquireDepositAddress * @param {Object} options Optional Parameters * @param {Number} [options.smart_contract_name] If a certain coin support multiple networks, the protocol type must be specified. * @param {String} [options.access_id] access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<DepositAddressResult>} Promise object represents the result of the request */ function inquireDepositAddress(_a) { var _b = _a === void 0 ? { tonce: Date.now(), } : _a, smart_contract_name = _b.smart_contract_name, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { smart_contract_name: smart_contract_name, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/balance/deposit/address/<string:coin_type>", params: params, }); } exports.inquireDepositAddress = inquireDepositAddress; /** * [Transfer Record Between Spot - Financial Account]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account021_spot_invest_transfer_histoty} * @async * @function transferRecordBetweenSpotFinancialAccount * @param {Object} options Optional Parameters * @param {String} [options.asset] Assets * @param {"IN"|"OUT"|"INTEREST"} [options.op_type] Operation ( IN: from Spot to Financial Account, OUT: from Financial to Spot Account, INTEREST: Interest ) * @param {Number} [options.start_time] Query start time * @param {Number} [options.end_time] Query end time * @param {Number} [options.page=1] Number of pages * @param {Number} [options.limit=10] Number of items per page * @param {String} [options.access_id] access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<TransferRecordBetweenSpotFinancialAccountResult>} Promise object represents the result of the request */ function transferRecordBetweenSpotFinancialAccount(_a) { var _b = _a === void 0 ? { page: 1, limit: 10, tonce: Date.now() } : _a, asset = _b.asset, op_type = _b.op_type, start_time = _b.start_time, end_time = _b.end_time, page = _b.page, limit = _b.limit, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { asset: asset, op_type: op_type, start_time: start_time, end_time: end_time, page: page, limit: limit, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/investment/transfer/history", params: params, }); } exports.transferRecordBetweenSpotFinancialAccount = transferRecordBetweenSpotFinancialAccount; /** * [Acquire Transfer Record Between Main and Sub-Account]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account022_sub_account_transfer_history} * @async * @function acquireTransferRecordBetweenMainAndSubAccount * @param {Object} options Optional Parameters * @param {String} [options.sub_user_name] Sub-account name * @param {String} [options.coin_type] Coin name * @param {Number} [options.page=1] Number of pages * @param {Number} [options.limit=10] Number of items per page (Max. 500) * @param {String} [options.access_id] access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<TransferRecordBetweenMainAndSubAccountResult>} Promise object represents the result of the request */ function acquireTransferRecordBetweenMainAndSubAccount(_a) { var _b = _a === void 0 ? { page: 1, limit: 10, tonce: Date.now() } : _a, sub_user_name = _b.sub_user_name, coin_type = _b.coin_type, page = _b.page, limit = _b.limit, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { sub_user_name: sub_user_name, coin_type: coin_type, page: page, limit: limit, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/sub_account/transfer/history", params: params, }); } exports.acquireTransferRecordBetweenMainAndSubAccount = acquireTransferRecordBetweenMainAndSubAccount; /** * [Acquire Loan Record in Margin Account]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account023_margin_loan_history} * @async * @function acquireLoanRecordInMarginAccount * @param {Object} options Optional Parameters * @param {String} [options.market] Market name * @param {String} [options.status] Status * @param {Number} [options.page=1] Page number, starting from 1 * @param {Number} [options.limit=10] Number of entries per page, Max. 100 * @param {String} [options.access_id] access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<Array<LoanRecordResult>>} Promise object represents the result of the request */ function acquireLoanRecordInMarginAccount(_a) { var _b = _a === void 0 ? { page: 1, limit: 10, tonce: Date.now() } : _a, market = _b.market, status = _b.status, page = _b.page, limit = _b.limit, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { market: market, status: status, page: page, limit: limit, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/margin/loan/history", params: params, }); } exports.acquireLoanRecordInMarginAccount = acquireLoanRecordInMarginAccount; /** * [Transfer Record Between Spot - Perpetual Account]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account024_contract_transfer_history} * @async * @function transferRecordBetweenSpotPerpetualAccount * @param {Object} options Optional Parameters * @param {String} [options.asset] Assets * @param {"transfer_in"|"transfer_out"} [options.transfer_type] Operation (transfer_in: from Spot to Perpetual Account, transfer_out: from Perpetual to Spot Account) * @param {Number} [options.start_time] Query start time * @param {Number} [options.end_time] Query end time * @param {Number} [options.page=1] Number of pages * @param {Number} [options.limit=10] Number of items per page * @param {String} [options.access_id] access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<TransferRecordBetweenSpotPerpetualAccountResult>} Promise object represents the result of the request */ function transferRecordBetweenSpotPerpetualAccount(_a) { var _b = _a === void 0 ? { page: 1, limit: 10, tonce: Date.now() } : _a, asset = _b.asset, transfer_type = _b.transfer_type, start_time = _b.start_time, end_time = _b.end_time, page = _b.page, limit = _b.limit, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { asset: asset, transfer_type: transfer_type, start_time: start_time, end_time: end_time, page: page, limit: limit, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/contract/transfer/history", params: params, }); } exports.transferRecordBetweenSpotPerpetualAccount = transferRecordBetweenSpotPerpetualAccount; /** * [Transfer Record Between Margin - Spot Account]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account025_margin_transfer_history} * @async * @function transferRecordBetweenMarginSpotAccount * @param {Object} options Optional Parameters * @param {String} [options.asset] Asset type * @param {String} [options.market] Market name * @param {String} [options.transfer_type] From/To * @param {Number} [options.start_time] Query start time * @param {Number} [options.end_time] Query end time * @param {Number} [options.page=1] Page number, starting from 1 * @param {Number} [options.limit=10] Number of entries per page, Max. 1000 * @param {String} [options.access_id] access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<TransferRecordBetweenMarginSpotAccountResult>} Promise object represents the result of the request */ function transferRecordBetweenMarginSpotAccount(_a) { var _b = _a === void 0 ? { page: 1, limit: 10, tonce: Date.now() } : _a, asset = _b.asset, market = _b.market, transfer_type = _b.transfer_type, start_time = _b.start_time, end_time = _b.end_time, page = _b.page, limit = _b.limit, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { asset: asset, market: market, transfer_type: transfer_type, start_time: start_time, end_time: end_time, page: page, limit: limit, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/margin/transfer/history", params: params, }); } exports.transferRecordBetweenMarginSpotAccount = transferRecordBetweenMarginSpotAccount; /** * [Acquire Withdrawal History]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account026_withdraw_list} * @async * @function acquireWithdrawalHistory * @param {Object} options Optional Parameters * @param {String} [options.coin_type] Coin name * @param {Number} [options.coin_withdraw_id] Withdrawal record ID * @param {Number} [options.page=1] Page number, starting from 1 * @param {Number} [options.limit=1] Number per page, Max. 100 * @param {String} [options.access_id] access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<Array<WithdrawalHistoryResult>>} Promise object represents the result of the request */ function acquireWithdrawalHistory(_a) { var _b = _a === void 0 ? { page: 1, limit: 10, tonce: Date.now() } : _a, coin_type = _b.coin_type, coin_withdraw_id = _b.coin_withdraw_id, page = _b.page, limit = _b.limit, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { coin_type: coin_type, coin_withdraw_id: coin_withdraw_id, page: page, limit: limit, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/balance/coin/withdraw", params: params, }); } exports.acquireWithdrawalHistory = acquireWithdrawalHistory; /** * [Create Sub-Account]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account027_create_sub_account} * @async * @function createSubAccount * @param {String} sub_user_name Username of sub-account * @param {String} password Containing at least 6 characters, including at least 1 upper case letter and 1 number * @param {Object} options Optional Parameters * @param {String} [options.access_id] access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<{}>} Promise object represents the result of the request */ function createSubAccount(sub_user_name, password, _a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { sub_user_name: sub_user_name, password: password, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.POST, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/sub_account/register", params: params, }); } exports.createSubAccount = createSubAccount; /** * [Unfreeze Sub-Account]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account028_unfronzen_sub_account} * @async * @function unfreezeSubAccount * @param {String} sub_user_name Username of sub-account * @param {Object} options Optional Parameters * @param {String} options.access_id access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<{}>} Promise object represents the result of the request */ // @ts-ignore function unfreezeSubAccount(sub_user_name, _a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { sub_user_name: sub_user_name, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.POST, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/sub_account/unfrozen", params: params, }); } exports.unfreezeSubAccount = unfreezeSubAccount; /** * [Freeze Sub-Account]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account029_fronzen_sub_account} * @async * @function freezeSubAccount * @param {String} sub_user_name Username of sub-account * @param {Object} options Optional Parameters * @param {String} [options.access_id] access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<{}>} Promise object represents the result of the request */ function freezeSubAccount(sub_user_name, _a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { sub_user_name: sub_user_name, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.POST, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/sub_account/frozen", params: params, }); } exports.freezeSubAccount = freezeSubAccount; /** * [Edit Account Settings]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account030_account_settings} * @async * @function editAccountSettings * @param {Object} options Optional Parameters * @param {Boolean} [options.cet_discount] Whether to activate CET deduction * @param {String} [options.access_id] access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<{}>} Promise object represents the result of the request */ function editAccountSettings(_a) { var _b = _a === void 0 ? { tonce: Date.now(), } : _a, cet_discount = _b.cet_discount, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { cet_discount: cet_discount, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.PUT, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/v1/account/settings", params: params, }); } exports.editAccountSettings = editAccountSettings; /** * [Create Sub-Account APIKEY]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account031_create_sub_account_api_key} * @async * @function createSubAccountAPIKEY * @param {String} sub_user_name Sub-account username * @param {String} allow_trade Whether there is transaction permission, true: yes; false: no * @param {String} allowed_ips Binding IP addresses (up to 50 can be bound) * @param {Object} options Optional Parameters * @param {String} [options.remark] API Remark * @param {String} [options.access_id] access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<SubAccountAPIKEYResult>} Promise object represents the result of the request */ function createSubAccountAPIKEY(sub_user_name, allow_trade, allowed_ips, _a) { var _b = _a === void 0 ? { tonce: Date.now() } : _a, remark = _b.remark, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { sub_user_name: sub_user_name, remark: remark, allow_trade: allow_trade, allowed_ips: allowed_ips, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.POST, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/sub_account/auth/api", params: params, }); } exports.createSubAccountAPIKEY = createSubAccountAPIKEY; /** * [Acquire Sub-Account APIKEY List]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account032_get_sub_account_api_key_list} * @async * @function acquireSubAccountAPIKEYList * @param {String} sub_user_name Sub-account username * @param {Object} options Optional Parameters * @param {Number} [options.page=1] Number of pages * @param {Number} [options.limit=10] Number of items per page * @param {String} [options.access_id] access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<SubAccountAPIKEYResults>} Promise object represents the result of the request */ function acquireSubAccountAPIKEYList(sub_user_name, _a) { var _b = _a === void 0 ? { page: 1, limit: 10, tonce: Date.now(), } : _a, page = _b.page, limit = _b.limit, access_id = _b.access_id, tonce = _b.tonce; // @ts-ignore var _c = this, apiKey = _c.apiKey, apiSecret = _c.apiSecret; var params = { sub_user_name: sub_user_name, page: page, limit: limit, access_id: access_id ? access_id : apiKey, tonce: tonce, }; return executeRequest({ method: METHOD_TYPE.GET, headers: { authorization: signParams(apiSecret, params), }, baseURL: BASE_URLS.GENERAL, url: "/sub_account/auth/api", params: params, }); } exports.acquireSubAccountAPIKEYList = acquireSubAccountAPIKEYList; /** * [Acquire Sub-Account APIKEY Detail]{@link https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account033_get_sub_account_api_key_detail} * @async * @function acquireSubAccountAPIKEYDetail * @param {Number} user_auth_id User Auth ID * @param {Object} options Optional Parameters * @param {String} [options.access_id] access_id * @param {Number} [options.tonce=Date.now()] Millisecond timestamp, the acceptable error range from server time is ±60s * @returns {Promise<SubAccountAPIKEYResult>} Promise object represents the result of the request */ function acquireSubAccountAPIKEYDetail(user_auth_id, _a) { var _b