UNPKG

neverrekt-apis

Version:

APIs for NeverRekt

1,047 lines 69.1 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Kucoin = void 0; var axios_1 = require("axios"); var crypto = require("crypto"); var api_1 = require("../api"); var utils_1 = require("../utils"); var Kucoin = /** @class */ (function () { function Kucoin(_a) { var SECRET = _a.SECRET, KEY = _a.KEY, PASSPHRASE = _a.PASSPHRASE, isTest = _a.isTest; this.SECRET = SECRET; this.KEY = KEY; this.PASSPHRASE = PASSPHRASE || ""; this.prefix = "/api/v1"; this.axios = axios_1.default.create({ baseURL: isTest ? "https://openapi-sandbox.kucoin.com" : "https://api.kucoin.com", headers: { "Content-Type": "application/json", "KC-API-PASSPHRASE": this.PASSPHRASE, "KC-API-KEY": this.KEY, }, }); } Kucoin.prototype.getSignature = function (path, queryString, timestamp, method) { var strForSign = "" + timestamp + method + path + queryString; var signatureResult = crypto .createHmac("sha256", this.SECRET) .update(strForSign) .digest("base64"); return signatureResult; }; Kucoin.prototype.makeRequest = function (_a, map) { var type = _a.type, method = _a.method, endpoint = _a.endpoint, params = _a.params; return __awaiter(this, void 0, void 0, function () { var paramError, config, path, timestamp, queryString, e_1; return __generator(this, function (_b) { switch (_b.label) { case 0: paramError = utils_1.checkParameters(params, map || []); if (!!paramError) { throw paramError; } _b.label = 1; case 1: _b.trys.push([1, 3, , 4]); config = {}; path = "" + this.prefix + endpoint; if (type === "private") { timestamp = "" + Date.now(); queryString = method === "GET" || method === "DELETE" ? utils_1.createQueryString(params) : JSON.stringify(params); config = { headers: { "KC-API-TIMESTAMP": timestamp, "KC-API-SIGN": this.getSignature(path, queryString, timestamp, method), }, }; } return [4 /*yield*/, api_1.api(this.axios, method, path, params, config)]; case 2: return [2 /*return*/, _b.sent()]; case 3: e_1 = _b.sent(); throw e_1; case 4: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-symbols-list * @description Request via this endpoint to get a list of available currency pairs for trading. If you want to get the market information of the trading symbol, please use Get All Tickers. */ Kucoin.prototype.getSymbolsList = function (params) { if (params === void 0) { params = {}; } return __awaiter(this, void 0, void 0, function () { var e_2; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ method: "GET", endpoint: "/symbols", params: params }, [{ key: "market" }])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_2 = _a.sent(); throw e_2; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-ticker * @description Request via this endpoint to get Level 1 Market Data. The returned value includes the best bid price and size, the best ask price and size as well as the last traded price and the last traded size. */ Kucoin.prototype.getTicker = function (params) { return __awaiter(this, void 0, void 0, function () { var e_3; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ method: "GET", endpoint: "/market/orderbook/level1", params: params }, [ { key: "symbol", required: true }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_3 = _a.sent(); throw e_3; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-all-tickers * @description Request market tickers for all the trading pairs in the market (including 24h volume). On the rare occasion that we will change the currency name, if you still want the changed symbol name, you can use the symbolName field instead of the symbol field via “Get all tickers” endpoint. */ Kucoin.prototype.getAllTickers = function () { return __awaiter(this, void 0, void 0, function () { var e_4; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ method: "GET", endpoint: "/market/allTickers", params: {} })]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_4 = _a.sent(); throw e_4; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-24hr-stats * @description Request via this endpoint to get the statistics of the specified ticker in the last 24 hours. */ Kucoin.prototype.get24HourStats = function (params) { return __awaiter(this, void 0, void 0, function () { var e_5; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ method: "GET", endpoint: "/market/stats", params: params }, [ { key: "symbol", required: true }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_5 = _a.sent(); throw e_5; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-market-list * @description Request via this endpoint to get the transaction currency for the entire trading market. */ Kucoin.prototype.getMarketList = function () { return __awaiter(this, void 0, void 0, function () { var e_6; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ method: "GET", endpoint: "/markets", params: {} })]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_6 = _a.sent(); throw e_6; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-currencies * @description Request via this endpoint to get the currency list. */ Kucoin.prototype.getCurrencies = function () { return __awaiter(this, void 0, void 0, function () { var e_7; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ method: "GET", endpoint: "/currencies", params: {} })]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_7 = _a.sent(); throw e_7; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-currency-detail * @description Request via this endpoint to get the currency details of a specified currency. */ Kucoin.prototype.getCurrencyDetail = function (currency, params) { if (params === void 0) { params = {}; } return __awaiter(this, void 0, void 0, function () { var e_8; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ method: "GET", endpoint: "/currencies/" + currency, params: params }, [ { key: "chain" }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_8 = _a.sent(); throw e_8; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-fiat-price * @description Request via this endpoint to get the fiat price of the currencies for the available trading pairs. */ Kucoin.prototype.getFiatPrice = function (params) { return __awaiter(this, void 0, void 0, function () { var e_9; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ method: "GET", endpoint: "/prices", params: params }, [ { key: "base" }, { key: "currencies" }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_9 = _a.sent(); throw e_9; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-part-order-book-aggregated * @description Request via this endpoint to get a list of open orders for a symbol. Level-2 order book includes all bids and asks (aggregated by price), this level returns only one size for each active price (as if there was only a single order for that price). Query via this endpoint and the system will return only part of the order book to you. If you request level2_20, the system will return you 20 pieces of data (ask and bid data) on the order book. If you request level_100, the system will return 100 pieces of data (ask and bid data) on the order book to you. You are recommended to request via this endpoint as the system reponse would be faster and cosume less traffic. To maintain up-to-date Order Book, please use Websocket incremental feed after retrieving the Level 2 snapshot. */ Kucoin.prototype.getPartOrderBook = function (level, params) { return __awaiter(this, void 0, void 0, function () { var e_10; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ method: "GET", endpoint: "/market/orderbook/level2_" + level, params: params, }, [{ key: "symbol", required: true }])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_10 = _a.sent(); throw e_10; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-full-order-book-aggregated * @description Request via this endpoint to get the order book of the specified symbol. Level 2 order book includes all bids and asks (aggregated by price). This level returns only one aggregated size for each price (as if there was only one single order for that price). This API will return data with full depth. It is generally used by professional traders because it uses more server resources and traffic, and we have strict access frequency control. To maintain up-to-date Order Book, please use Websocket incremental feed after retrieving the Level 2 snapshot. */ Kucoin.prototype.getFullOrderBookAggregated = function (params) { return __awaiter(this, void 0, void 0, function () { var e_11; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ method: "GET", endpoint: "/market/orderbook/level2", params: params }, [ { key: "symbol", required: true }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_11 = _a.sent(); throw e_11; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-full-order-book-atomic * @description Request via this endpoint to get the Level 3 order book of the specified trading pari. Level 3 order book includes all bids and asks (the data is non-aggregated, and each item means a single order). This API is generally used by professional traders because it uses more server resources and traffic, and we have strict access frequency control. To maintain up-to-date order book, please use Websocket incremental feed after retrieving the Level 3 snapshot. In the orderbook, the selling data is sorted low to high by price and orders with the same price are sorted in time sequence. The buying data is sorted high to low by price and orders with the same price are sorted in time sequence. The matching engine will match the orders according to the price and time sequence. */ Kucoin.prototype.getFullOrderBookAtomic = function (params) { return __awaiter(this, void 0, void 0, function () { var e_12; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ method: "GET", endpoint: "/market/orderbook/level3", params: params }, [ { key: "symbol", required: true }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_12 = _a.sent(); throw e_12; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-trade-histories * @description Request via this endpoint to get the trade history of the specified symbol. */ Kucoin.prototype.getTradeHistories = function (params) { return __awaiter(this, void 0, void 0, function () { var e_13; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ method: "GET", endpoint: "/market/histories", params: params }, [ { key: "symbol", required: true }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_13 = _a.sent(); throw e_13; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-klines * @description Request via this endpoint to get the kline of the specified symbol. Data are returned in grouped buckets based on requested type. */ Kucoin.prototype.getKlines = function (params) { return __awaiter(this, void 0, void 0, function () { var e_14; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ method: "GET", endpoint: "/market/candles", params: params }, [ { key: "symbol", required: true }, { key: "startAt" }, { key: "endAt" }, { key: "type", required: true }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_14 = _a.sent(); throw e_14; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-user-info-of-all-sub-accounts * @description You can get the user info of all sub-users via this interface. */ Kucoin.prototype.getUserSubInfo = function () { return __awaiter(this, void 0, void 0, function () { var e_15; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/sub/user", params: {} })]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_15 = _a.sent(); throw e_15; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#create-an-account * @description Create account. */ Kucoin.prototype.createAnAccount = function (params) { return __awaiter(this, void 0, void 0, function () { var e_16; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "POST", endpoint: "/accounts", params: params }, [ { key: "currency", required: true }, { key: "type", required: true }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_16 = _a.sent(); throw e_16; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#list-accounts * @description Get a list of accounts. Please deposit funds to the main account firstly, then transfer the funds to the trade account via Inner Transfer before transaction */ Kucoin.prototype.listAccounts = function (params) { if (params === void 0) { params = {}; } return __awaiter(this, void 0, void 0, function () { var e_17; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/accounts", params: params }, [ { key: "currency" }, { key: "type" }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_17 = _a.sent(); throw e_17; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-an-account * @description Information for a single account. Use this endpoint when you know the accountId. */ Kucoin.prototype.getAnAccount = function (params) { return __awaiter(this, void 0, void 0, function () { var e_18; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/accounts/" + params.accountId, params: params, }, [{ key: "accountId", required: true }])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_18 = _a.sent(); throw e_18; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-account-ledgers * @description Request via this endpoint to get the account ledgers. Items are paginated and sorted to show the latest first. See the Pagination section for retrieving additional entries after the first page. */ Kucoin.prototype.getAccountLedgers = function (params) { return __awaiter(this, void 0, void 0, function () { var e_19; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/accounts/" + params.accountId + "/ledgers", params: params, }, [ { key: "accountId", required: true }, { key: "startAt" }, { key: "endAt" }, { key: "direction" }, { key: "bizType" }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_19 = _a.sent(); throw e_19; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-holds * @description Holds are placed on an account for any active orders or pending withdraw requests. As an order is filled, the hold amount is updated. If an order is canceled, any remaining hold is removed. For a withdraw, once it is completed, the hold is removed. */ Kucoin.prototype.getHolds = function (params) { return __awaiter(this, void 0, void 0, function () { var e_20; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/accounts/" + params.accountId + "/holds", params: params, }, [{ key: "accountId", required: true }])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_20 = _a.sent(); throw e_20; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-account-balance-of-a-sub-account * @description This endpoint returns the account info of a sub-user specified by the subUserId. */ Kucoin.prototype.getSubAccountBalance = function (params) { return __awaiter(this, void 0, void 0, function () { var e_21; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/sub-accounts/" + params.subUserId, params: params, }, [{ key: "subUserId", required: true }])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_21 = _a.sent(); throw e_21; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-the-aggregated-balance-of-all-sub-accounts * @description This endpoint returns the account info of all sub-users. */ Kucoin.prototype.getAggregatedSubAccountBalance = function () { return __awaiter(this, void 0, void 0, function () { var e_22; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/sub-accounts", params: {}, })]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_22 = _a.sent(); throw e_22; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-the-transferable * @description This endpoint returns the transferable balance of a specified account. */ Kucoin.prototype.getTheTransferable = function (params) { return __awaiter(this, void 0, void 0, function () { var e_23; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/accounts/transferable", params: params, }, [ { key: "currency", required: true }, { key: "type", required: true }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_23 = _a.sent(); throw e_23; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#transfer-between-master-user-and-sub-user * @description This endpoint is used for transferring the assets between the master user and the sub-user. The main account of the master user supports the transfer to the main account or trade account of the sub-user. */ Kucoin.prototype.transferBetweenMasterAndSubUser = function (params) { return __awaiter(this, void 0, void 0, function () { var e_24; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/accounts/sub-transfer", params: params, }, [ { key: "clientOid", required: true }, { key: "currency", required: true }, { key: "amount", required: true }, { key: "direction", required: true }, { key: "accountType" }, { key: "subAccountType" }, { key: "subUserId", required: true }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_24 = _a.sent(); throw e_24; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#inner-transfer * @description The inner transfer interface is used for transferring assets between the accounts of a user and is free of charges. For example, a user could transfer assets from their main account to their trading account on the platform. Support transfer between main account and pool account. */ Kucoin.prototype.innerTransfer = function (params) { return __awaiter(this, void 0, void 0, function () { var e_25; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/accounts/inner-transfer", params: params, }, [ { key: "clientOid", required: true }, { key: "currency", required: true }, { key: "amount", required: true }, { key: "from", required: true }, { key: "to", required: true }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_25 = _a.sent(); throw e_25; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#create-deposit-address * @description Request via this endpoint to create a deposit address for a currency you intend to deposit. */ Kucoin.prototype.createDepositAddress = function (params) { return __awaiter(this, void 0, void 0, function () { var e_26; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "POST", endpoint: "/deposit-addresses", params: params, }, [{ key: "currency", required: true }, { key: "chain" }])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_26 = _a.sent(); throw e_26; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-deposit-address * @description Get a deposit address for the currency you intend to deposit. If the returned data is null, you may need to create a deposit address first. */ Kucoin.prototype.getDepositAddress = function (params) { return __awaiter(this, void 0, void 0, function () { var e_27; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/deposit-addresses", params: params, }, [{ key: "currency", required: true }, { key: "chain" }])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_27 = _a.sent(); throw e_27; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-deposit-list * @description Request via this endpoint to get deposit list Items are paginated and sorted to show the latest first. See the Pagination section for retrieving additional entries after the first page. */ Kucoin.prototype.getDepositList = function (params) { return __awaiter(this, void 0, void 0, function () { var e_28; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/deposits", params: params }, [ { key: "currency" }, { key: "startAt" }, { key: "endAt" }, { key: "status" }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_28 = _a.sent(); throw e_28; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-v1-historical-deposits-list * @description Request via this endpoint to get the V1 historical deposits list on KuCoin. */ Kucoin.prototype.getHistoricalDepositsList = function (params) { return __awaiter(this, void 0, void 0, function () { var e_29; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/hist-deposits", params: params }, [ { key: "currency" }, { key: "startAt" }, { key: "endAt" }, { key: "status" }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_29 = _a.sent(); throw e_29; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-withdrawals-list * @description Get withdrawals list */ Kucoin.prototype.getWithdrawalsList = function (params) { return __awaiter(this, void 0, void 0, function () { var e_30; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/withdrawals", params: params }, [ { key: "currency" }, { key: "startAt" }, { key: "endAt" }, { key: "status" }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_30 = _a.sent(); throw e_30; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-v1-historical-withdrawals-list * @description List of KuCoin V1 historical withdrawals. */ Kucoin.prototype.getHistoricalWithdrawalsList = function (params) { return __awaiter(this, void 0, void 0, function () { var e_31; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/hist-withdrawals", params: params, }, [ { key: "currency" }, { key: "startAt" }, { key: "endAt" }, { key: "status" }, { key: "currentPage" }, { key: "pageSize" }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_31 = _a.sent(); throw e_31; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#get-withdrawal-quotas * @description Get withdrawal quotas */ Kucoin.prototype.getWithdrawalQuotas = function (params) { return __awaiter(this, void 0, void 0, function () { var e_32; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "GET", endpoint: "/withdrawals/quotas", params: params, }, [{ key: "currency", required: true }, { key: "chain" }])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_32 = _a.sent(); throw e_32; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#apply-withdraw-2 * @description Apply withdraw */ Kucoin.prototype.applyWithdrawal = function (params) { return __awaiter(this, void 0, void 0, function () { var e_33; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "POST", endpoint: "/withdrawals", params: params }, [ { key: "currency", required: true }, { key: "address", required: true }, { key: "amount", required: true }, { key: "memo" }, { key: "isInner" }, { key: "remark" }, { key: "chain" }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_33 = _a.sent(); throw e_33; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#cancel-withdrawal * @description Only withdrawals requests of PROCESSING status could be canceled. */ Kucoin.prototype.cancelWithdrawal = function (params) { return __awaiter(this, void 0, void 0, function () { var e_34; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "DELETE", endpoint: "/withdrawals/" + params.withdrawalId, params: {}, })]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_34 = _a.sent(); throw e_34; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#place-a-new-order * @description You can place two types of orders: limit and market. Orders can only be placed if your account has sufficient funds. Once an order is placed, your account funds will be put on hold for the duration of the order. How much and which funds are put on hold depends on the order type and parameters specified. See the Holds details below. */ Kucoin.prototype.placeANewOrder = function (params) { return __awaiter(this, void 0, void 0, function () { var e_35; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "POST", endpoint: "/orders", params: params }, [ { key: "clientOid", required: true }, { key: "side", required: true }, { key: "symbol", required: true }, { key: "size", required: !!params.price || (!params.price && !params.funds), }, { key: "funds", required: !params.price && !params.size }, { key: "type" }, { key: "remark" }, { key: "stop" }, { key: "stopPrice" }, { key: "stp" }, { key: "tradeType" }, { key: "price" }, { key: "timeInForce" }, { key: "cancelAfter" }, { key: "postOnly" }, { key: "hidden" }, { key: "iceberg" }, { key: "visibleSize" }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_35 = _a.sent(); throw e_35; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#cancel-an-order * @description Request via this endpoint to cancel a single order previously placed. You will receive cancelledOrderIds field once the system has received the cancellation request. The cancellation request will be processed by the matching engine in sequence. To know if the request is processed (successfully or not), you may check the order status or the update message from the pushes. */ Kucoin.prototype.cancelAnOrder = function (params) { return __awaiter(this, void 0, void 0, function () { var e_36; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "DELETE", endpoint: "/orders/" + params.orderId, params: params, }, [{ key: "orderId", required: true }])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_36 = _a.sent(); throw e_36; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#cancel-all-orders * @description Request via this endpoint to cancel all open orders. The response is a list of ids of the canceled orders. */ Kucoin.prototype.cancelAllOrders = function (params) { return __awaiter(this, void 0, void 0, function () { var e_37; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); return [4 /*yield*/, this.makeRequest({ type: "private", method: "DELETE", endpoint: "/orders", params: params }, [ { key: "symbol" }, { key: "tradeType" }, ])]; case 1: return [2 /*return*/, _a.sent()]; case 2: e_37 = _a.sent(); throw e_37; case 3: return [2 /*return*/]; } }); }); }; /** * @docs https://docs.kucoin.com/#list-orders * @description Request via this endpoint to get your current order list. Items are paginated and sorted to show the latest first. See the Pagination section for retrieving additional entries afte