diff --git a/NETWORK_README.md b/NETWORK_README.md index c43f1d6..63b52ce 100644 --- a/NETWORK_README.md +++ b/NETWORK_README.md @@ -49,42 +49,51 @@ client - **Optional parameters are all contained within an object parameter called `opts`** -| Command | Parameters | Description | -| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | -| `init` | | Initialize your Kit for HollaEx Network. Must have passed activation_code in constructor | -| `getTicker` | **symbol** | Last, high, low, open and close price and volume within the last 24 hours | -| `getTickers` | | Last, high, low, open and close price and volume within the last 24 hours for all symbols | -| `getOrderbook` | **symbol** | Orderbook containing list of bids and asks | -| `getOrderbooks` | | Orderbook containing list of bids and asks for all symbols | -| `getPublicTrades` | **symbol** (_optional_) | List of last trades | -| `getTradesHistory` |**symbol** (_optional_), **side** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | List of trades in paginated form | -| `getGeneratedFees` |**limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | List of generated fees for the exchange | -| `getUser` | **userId** (_optional_) | User's personal information | -| `getUsers` | | Get all user's for your exchange | -| `createUser` | **email** (_optional_) | Create a user on the Network | -| `getBalance` | | User's wallet balance | -| `createUserCryptoAddress` | **userId**, **crypto** (_optional_) | Create a crypto address for a user | -| `mintAsset` | **userId**, **currency**, **amount**, **description** (_optional_) | Mint an asset that is created by the operator for a user | -| `burnAsset` | **userId**, **currency**, **amount**, **description** (_optional_) | Burn an asset that is created by the operator from a user | -| `getDeposits` | **userId** (_optional_), **currency** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | User's list of all deposits | -| `getWithdrawals` | **userId** (_optional_), **currency** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | User's list of all withdrawals | -| `performWithdrawal` | **userId**, **address**, **currency**, **amount**, **fee** (_receipient's_) | Create a withdrawal for an exchange's user on the network | -| `cancelWithdrawal` | **userId**, **withdrawalId** | Cancel a pending withdrawal | -| `checkTransaction` | **userId**, **transactionId**, **address**, **isTestnet** (_optional_) | Check transaction in network. Will update transaction status on Kit accordingly | -| `transferAsset` | **senderId**, **receiverId**, **currency**, **amount**, **description** (_optional_) | Transfer funds between two users | -| `getUserTrades` | **userId** (_optional_), **symbol** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`desc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | User's list of all trades | -| `getUserStats` | **userId** (_optional_) | Get sum of user trades and its stats | -| `getOrder` | **userId**, **orderId** | Get specific information about a certain order | -| `getOrders` | **userId** (_optional_), **symbol** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`desc`, _enum_=`asc`, `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | Get the list of all user orders. It can be filter by passing the symbol | -| `createOrder` | **userId**, **symbol**, **side** (`buy` or `sell`), **size**, **type** (`market` or `limit`), **price**, **feeData** (object with `fee_structure` and `fee_coin`, `fee_structure` is an object with `maker` and `taker` fee percentages and is required), **stop** (_optional_), **meta** (_optional_, object with optional properties e.g. `post_only`) | Create a new order | -| `cancelOrder` | **userId**, **orderId** | Cancel a specific order with its ID | -| `cancelAllOrders` | **userId**, **symbol** (_optional_) | Cancel all open order. It can be filter by passing the symbol | -| `getChart` | **from**, **to**, **symbol**, **resolution** | Get TradingView trade history HOLCV | -| `getCharts` | **from**, **to**, **resolution** | Get TradingView trade history HOLCV for all pairs | -| `getUdfConfig` | | Get TradingView udf config | -| `getUdfHistory` | **from**, **to**, **symbol**, **resolution** | Get TradingView udf history HOLCV | -| `getUdfSymbols` | **symbol** | Get TradingView udf symbols | -| `getOraclePrices` | **assets** (an array of assets to get converted prices), **quote** (_optional_, _default_=`usdt`), **amount** (_optional_, _default_=`1`) | Get converted quote amount for an asset | +| Command | Parameters | Description | +| - | - | - | +| `init`| | Initialize your Kit for HollaEx Network. Must have passed activation_code in constructor | +| `getTicker` | **symbol** | Last, high, low, open and close price and volume within the last 24 hours | +| `getTickers` | | Last, high, low, open and close price and volume within the last 24 hours for all symbols | +| `getOrderbook` | **symbol** | Orderbook containing list of bids and asks | +| `getOrderbooks` | | Orderbook containing list of bids and asks for all symbols | +| `getPublicTrades` | **symbol** (_optional_) | List of last trades | +| `getTradesHistory` | **symbol** (_optional_), **side** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | List of trades in paginated form | +| `getGeneratedFees` | **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | List of generated fees for the exchange | +| `settleFees` | | Settle exchange's fees | +| `getUser` | **userId** (_optional_) | User's personal information | +| `getUsers` | | Get all user's for your exchange | +| `createUser` | **email** (_optional_) | Create a user on the Network | +| `getBalance` | | Exchange's wallet balance | +| `getUserBalance` | **userId** | User's wallet balance | +| `createUserCryptoAddress` | **userId**, **crypto**, **network** (_optional_) | Create a crypto address for a user | +| `mintAsset` | **userId**, **currency**, **amount**, **description** (_optional_), **transactionId** (_optional_), **status** (_optional_, _default_=`true`) | Mint an asset that is created by the operator for a user | +| `updatePendingMint` | **transactionId**, **status** (_optional_), **dismissed** (_optional_), **rejected** (_optional_), **updatedTransactionId** (_optional_) | Update a pending mint | +| `burnAsset` | **userId**, **currency**, **amount**, **description** (_optional_), **transactionId** (_optional_), **status** (_optional_, _default_=`true`) | Burn an asset that is created by the operator from a user | +| `updatePendingBurn` | **transactionId**, **status** (_optional_), **dismissed** (_optional_), **rejected** (_optional_), **updatedTransactionId** (_optional_) | Update a pending burn | +| `getDeposits` | **currency** (_optional_), **status** (_optional_), **dismissed** (_optional_), **rejected** (_optional_), **processing** (_optional_), **waiting** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`), **transactionId** (_optional_), **address** (_optional_) | Exchanges's list of all deposits | +| `getUserDeposits` | **userId**, **currency** (_optional_), **status** (_optional_), **dismissed** (_optional_), **rejected** (_optional_), **processing** (_optional_), **waiting** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`), **transactionId** (_optional_), **address** (_optional_) | User's list of all deposits | +| `getWithdrawals` | **currency** (_optional_), **status** (_optional_), **dismissed** (_optional_), **rejected** (_optional_), **processing** (_optional_), **waiting** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`), **transactionId** (_optional_), **address** (_optional_) | Exchange's list of all withdrawals | +| `getUserWithdrawals` | **userId**, **currency** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`), **transactionId** (_optional_), **address** (_optional_) | User's list of all withdrawals | +| `performWithdrawal` | **userId**, **address**, **currency**, **amount**, **network** (_optional_) | Create a withdrawal for an exchange's user on the network | +| `cancelWithdrawal` | **userId**, **withdrawalId** | Cancel a pending withdrawal | +| `checkTransaction` | **userId**, **transactionId**, **address**, **isTestnet** (_optional_) | Check transaction in network. Will update transaction status on Kit accordingly | +| `transferAsset` | **senderId**, **receiverId**, **currency**, **amount**, **description** (_optional_), **email** (_optional_, _default_=`true`) | Transfer funds between two users | +| `getTrades` | **symbol** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`desc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | Exchange's list of all trades | +| `getUserTrades` | **userId**, **symbol** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`desc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | User's list of all trades | +| `getUserStats` | **userId** | Get sum of user trades and its stats | +| `getOrder` | **userId**, **orderId** | Get specific information about a certain order | +| `getOrders` | **symbol** (_optional_), **side** (_optional_), **status** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`desc`, _enum_=`asc`, `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | Get the list of all orders for the exchange | +| `getUserOrders` | **userId**, **symbol** (_optional_), **side** (_optional_), **status** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`desc`, _enum_=`asc`, `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | Get the list of all orders for a user | +| `createOrder` | **userId**, **symbol**, **side** (`buy` or `sell`), **size**, **type** (`market` or `limit`), **price**, **feeData** (object with `fee_structure` and `fee_coin`, `fee_structure` is an object with `maker` and `taker` fee percentages and is required), **stop** (_optional_), **meta** (_optional_, object with optional properties e.g. `post_only`) | Create a new order | +| `cancelOrder` | **userId**, **orderId** | Cancel a specific order with its ID | +| `cancelAllOrders` | **userId**, **symbol** (_optional_) | Cancel all open order. It can be filtered by passing the symbol | +| `getPublicTrades` | **symbol** (_optional_) | Get public trades on Network | +| `getChart` | **from**, **to**, **symbol**, **resolution** | Get TradingView trade history HOLCV | +| `getCharts` | **from**, **to**, **resolution** | Get TradingView trade history HOLCV for all pairs | +| `getUdfConfig` | | Get TradingView udf config | +| `getUdfHistory` | **from**, **to**, **symbol**, **resolution** | Get TradingView udf history HOLCV | +| `getUdfSymbols` | **symbol** | Get TradingView udf symbols | +| `getOraclePrices` | **assets** (an array of assets to get converted prices), **quote** (_optional_, _default_=`usdt`), **amount** (_optional_, _default_=`1`) | Get converted quote amount for an asset | ### Websocket diff --git a/README.md b/README.md index 6d0011d..7f55893 100644 --- a/README.md +++ b/README.md @@ -58,26 +58,26 @@ client - **Optional parameters are all contained within an object parameter called `opts`** -| Command | Parameters | Description | -| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `getKit` | | Get exchange information e.g. name, valid languages, description, etc. | -| `getConstants` | | Tick size, min price, max price, min size and max size of each symbol pair and coin | -| `getTicker` | **symbol** | Last, high, low, open and close price and volume within the last 24 hours | -| `getTickers` | | Last, high, low, open and close price and volume within the last 24 hours for all symbols | -| `getOrderbook` | **symbol** | Orderbook containing list of bids and asks | -| `getOrderbooks` | | Orderbook containing list of bids and asks for all symbols | -| `getTrades` | **symbol** (_optional_) | List of last trades | -| `getUser` | | User's personal information | -| `getBalance` | | User's wallet balance | -| `getDeposits` | **currency** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | User's list of all deposits | -| `getWithdrawals` | **currency** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | User's list of all withdrawals | -| `requestWithdrawal` | **currency**, **amount**, **address** (_receipient's_) | Create a new withdrawal request. **Disable Two-Factor Authentication to be able to use this function. Must confirm within 5 minutes via email to complete withdrawal** | -| `getUserTrades` | **symbol** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`desc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | User's list of all trades | -| `getOrder` | **orderId** | Get specific information about a certain order | -| `getOrders` | **symbol** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`desc`, _enum_=`asc`, `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | Get the list of all user orders. It can be filter by passing the symbol | -| `createOrder` | **symbol**, **side** (`buy` or `sell`), **size**, **type** (`market` or `limit`), **price**, **stop** (_optional_), **meta** (_optional_, object with optional properties e.g. `post_only`) | Create a new order | -| `cancelOrder` | **orderId** | Cancel a specific order with its ID | -| `cancelAllOrders` | **symbol** (_optional_) | Cancel all open order. It can be filter by passing the symbol | +| Command | Parameters | Description | +| - | - | - | +| `getKit` | | Get exchange information e.g. name, valid languages, description, etc. | +| `getConstants` | | Tick size, min price, max price, min size and max size of each symbol pair and coin | +| `getTicker` | **symbol** | Last, high, low, open and close price and volume within the last 24 hours | +| `getTickers` | | Last, high, low, open and close price and volume within the last 24 hours for all symbols | +| `getOrderbook` | **symbol** | Orderbook containing list of bids and asks | +| `getOrderbooks` | | Orderbook containing list of bids and asks for all symbols | +| `getTrades` | **symbol** (_optional_) | List of last trades | +| `getUser` | | User's personal information | +| `getBalance` | | User's wallet balance | +| `getDeposits` | **currency** (_optional_), **status** (_optional_), **dismissed** (_optional_), **rejected** (_optional_), **processing** (_optional_), **waiting** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`), **transactionId** (_optional_), **address** (_optional_) | User's list of all deposits | +| `getWithdrawals` | **currency** (_optional_), **status** (_optional_), **dismissed** (_optional_), **rejected** (_optional_), **processing** (_optional_), **waiting** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`asc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`), **transactionId** (_optional_), **address** (_optional_) | User's list of all withdrawals | +| `requestWithdrawal` | **currency**, **amount**, **address**, **network** (_optional_), **otpCode** (_optional_) | Create a new withdrawal request | +| `getUserTrades` | **symbol** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`desc`, `asc` or `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | User's list of all trades | +| `getOrder` | **orderId** | Get specific information about a certain order | +| `getOrders` | **symbol** (_optional_), **side** (_optional_), **status** (_optional_), **limit** (_optional_, _default_=`50`, _max_=`100`), **page** (_optional_, _default_=`1`), **orderBy** (_optional_, _default_=`id`), **order** (_optional_, _default_=`desc`, _enum_=`asc`, `desc`), **startDate** (_optional_, _default_=`0`, _format_=`ISO8601`), **endDate** (_optional_, _default_=`NOW`, _format_=`ISO8601`) | Get the list of all user orders. It can be filter by passing the symbol | +| `createOrder` | **symbol**, **side** (`buy` or `sell`), **size**, **type** (`market` or `limit`), **price**, **stop** (_optional_), **meta** (_optional_, object with optional properties e.g. `post_only`) | Create a new order | +| `cancelOrder` | **orderId** | Cancel a specific order with its ID | +| `cancelAllOrders` | **symbol** (_optional_) | Cancel all open order. It can be filter by passing the symbol | ### Websocket diff --git a/kit.js b/kit.js index 930b3c5..eae1a7f 100644 --- a/kit.js +++ b/kit.js @@ -169,25 +169,39 @@ class HollaExKit { /** * Retrieve list of the user's deposits - * @param {object} opts Optional parameters - * @param {string} opts.currency The currency to filter by, pass undefined to receive data on all currencies + * @param {object} opts - Optional parameters + * @param {string} opts.currency - The currency to filter by, pass undefined to receive data on all currencies + * @param {boolean} opts.status - Confirmed status of the deposits to get. Leave blank to get all confirmed and unconfirmed deposits + * @param {boolean} opts.dismissed - Dismissed status of the deposits to get. Leave blank to get all dismissed and undismissed deposits + * @param {boolean} opts.rejected - Rejected status of the deposits to get. Leave blank to get all rejected and unrejected deposits + * @param {boolean} opts.processing - Processing status of the deposits to get. Leave blank to get all processing and unprocessing deposits + * @param {boolean} opts.waiting - Waiting status of the deposits to get. Leave blank to get all waiting and unwaiting deposits * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50 * @param {number} opts.page - Page of trades data. Default: 1 - * @param {string} opts.orderBy The field to order data by e.g. amount, id. Default: id - * @param {string} opts.order Ascending (asc) or descending (desc). Default: asc - * @param {string} opts.startDate Start date of query in ISO8601 format. Default: 0 - * @param {string} opts.endDate End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id + * @param {string} opts.order - Ascending (asc) or descending (desc). Default: asc + * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0 + * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {string} opts.transactionId - Deposits with specific transaction ID. + * @param {string} opts.address - Deposits with specific address. * @return {object} A JSON object with the keys count(total number of user's deposits) and data(array of deposits as objects with keys id(number), type(string), amount(number), transaction_id(string), currency(string), created_at(string), status(boolean), fee(number), dismissed(boolean), rejected(boolean), description(string)) */ getDeposits( opts = { currency: null, + status: null, + dismissed: null, + rejected: null, + processing: null, + waiting: null, limit: 50, page: 1, orderBy: 'id', order: 'asc', startDate: 0, - endDate: moment().toISOString() + endDate: moment().toISOString(), + transactionId: null, + address: null } ) { const verb = 'GET'; @@ -221,6 +235,34 @@ class HollaExKit { path += `&end_date=${opts.endDate}`; } + if (isString(opts.address)) { + path += `&address=${opts.address}`; + } + + if (isString(opts.transactionId)) { + path += `&transaction_id=${opts.transactionId}`; + } + + if (isBoolean(opts.status)) { + path += `&status=${opts.status}`; + } + + if (isBoolean(opts.dismissed)) { + path += `&dismissed=${opts.dismissed}`; + } + + if (isBoolean(opts.rejected)) { + path += `&rejected=${opts.rejected}`; + } + + if (isBoolean(opts.processing)) { + path += `&processing=${opts.processing}`; + } + + if (isBoolean(opts.waiting)) { + path += `&waiting=${opts.waiting}`; + } + const headers = generateHeaders( this.headers, this.apiSecret, @@ -234,25 +276,39 @@ class HollaExKit { /****** Withdrawals ******/ /** * Retrieve list of the user's withdrawals - * @param {object} opts Optional parameters - * @param {string} opts.currency The currency to filter by, pass undefined to receive data on all currencies + * @param {object} opts - Optional parameters + * @param {string} opts.currency - The currency to filter by, pass undefined to receive data on all currencies + * @param {boolean} opts.status - Confirmed status of the withdrawals to get. Leave blank to get all confirmed and unconfirmed withdrawals + * @param {boolean} opts.dismissed - Dismissed status of the withdrawals to get. Leave blank to get all dismissed and undismissed withdrawals + * @param {boolean} opts.rejected - Rejected status of the withdrawals to get. Leave blank to get all rejected and unrejected withdrawals + * @param {boolean} opts.processing - Processing status of the withdrawals to get. Leave blank to get all processing and unprocessing withdrawals + * @param {boolean} opts.waiting - Waiting status of the withdrawals to get. Leave blank to get all waiting and unwaiting withdrawals * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50 * @param {number} opts.page - Page of trades data. Default: 1 - * @param {string} opts.orderBy The field to order data by e.g. amount, id. Default: id - * @param {string} opts.order Ascending (asc) or descending (desc). Default: asc - * @param {string} opts.startDate Start date of query in ISO8601 format. Default: 0 - * @param {string} opts.endDate End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id + * @param {string} opts.order - Ascending (asc) or descending (desc). Default: asc + * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0 + * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {string} opts.transactionId - Withdrawals with specific transaction ID. + * @param {string} opts.address - Withdrawals with specific address. * @return {object} A JSON object with the keys count(total number of user's withdrawals) and data(array of withdrawals as objects with keys id(number), type(string), amount(number), transaction_id(string), currency(string), created_at(string), status(boolean), fee(number), dismissed(boolean), rejected(boolean), description(string)) */ getWithdrawals( opts = { currency: null, + status: null, + dismissed: null, + rejected: null, + processing: null, + waiting: null, limit: 50, page: 1, orderBy: 'id', order: 'asc', startDate: 0, - endDate: moment().toISOString() + endDate: moment().toISOString(), + transactionId: null, + address: null } ) { const verb = 'GET'; @@ -286,6 +342,34 @@ class HollaExKit { path += `&end_date=${opts.endDate}`; } + if (isString(opts.address)) { + path += `&address=${opts.address}`; + } + + if (isString(opts.transactionId)) { + path += `&transaction_id=${opts.transactionId}`; + } + + if (isBoolean(opts.status)) { + path += `&status=${opts.status}`; + } + + if (isBoolean(opts.dismissed)) { + path += `&dismissed=${opts.dismissed}`; + } + + if (isBoolean(opts.rejected)) { + path += `&rejected=${opts.rejected}`; + } + + if (isBoolean(opts.processing)) { + path += `&processing=${opts.processing}`; + } + + if (isBoolean(opts.waiting)) { + path += `&waiting=${opts.waiting}`; + } + const headers = generateHeaders( this.headers, this.apiSecret, @@ -301,12 +385,31 @@ class HollaExKit { * @param {string} currency - The currency to withdrawal * @param {number} amount - The amount of currency to withdrawal * @param {string} address - The recipient's wallet address + * @param {object} opts - Optional parameters. + * @param {string} opts.network - Crypto network of currency being withdrawn. + * @param {string} opts.otpCode - Otp code for user if otp is enabled. * @return {object} A JSON object {message:"Success"} */ - requestWithdrawal(currency, amount, address) { + requestWithdrawal(currency, amount, address, opts = { + network: null, + otpCode: null + }) { const verb = 'POST'; const path = `${this.baseUrl}/user/request-withdrawal`; - const data = { currency, amount, address }; + const data = { + currency, + amount, + address + }; + + if (opts.network) { + data.otp_code = opts.otpCode; + } + + if (opts.network) { + data.network = opts.network; + } + const headers = generateHeaders( this.headers, this.apiSecret, @@ -320,14 +423,14 @@ class HollaExKit { /** * Retrieve list of the user's completed trades - * @param {object} opts Optional parameters - * @param {string} opts.symbol The symbol-pair to filter by, pass undefined to receive data on all currencies + * @param {object} opts - Optional parameters + * @param {string} opts.symbol - The symbol-pair to filter by, pass undefined to receive data on all currencies * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50 * @param {number} opts.page - Page of trades data. Default: 1 - * @param {string} opts.orderBy The field to order data by e.g. amount, id. Default: id - * @param {string} opts.order Ascending (asc) or descending (desc). Default: desc - * @param {string} opts.startDate Start date of query in ISO8601 format. Default: 0 - * @param {string} opts.endDate End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id + * @param {string} opts.order - Ascending (asc) or descending (desc). Default: desc + * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0 + * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format * @return {object} A JSON object with the keys count(total number of user's completed trades) and data(array of up to the user's last 50 completed trades as objects with keys side(string), symbol(string), size(number), price(number), timestamp(string), and fee(number)) */ getUserTrades( @@ -403,14 +506,14 @@ class HollaExKit { /** * Retrieve information of all the user's active orders - * @param {object} opts Optional parameters + * @param {object} opts - Optional parameters * @param {string} opts.symbol - The currency pair symbol to filter by e.g. 'hex-usdt', leave empty to retrieve information of orders of all symbols * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50 * @param {number} opts.page - Page of trades data. Default: 1 - * @param {string} opts.orderBy The field to order data by e.g. amount, id. Default: id - * @param {string} opts.order Ascending (asc) or descending (desc). Default: desc - * @param {string} opts.startDate Start date of query in ISO8601 format. Default: 0 - * @param {string} opts.endDate End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id + * @param {string} opts.order - Ascending (asc) or descending (desc). Default: desc + * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0 + * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format * @return {object} A JSON array of objects containing the user's active orders */ getOrders( @@ -546,7 +649,7 @@ class HollaExKit { /** * Cancel all the user's active orders, can filter by currency pair symbol - * @param {object} opts Optional parameters + * @param {object} opts - Optional parameters * @param {string} opts.symbol - The currency pair symbol to filter by e.g. 'hex-usdt', leave empty to cancel orders of all symbols * @return {array} A JSON array of objects containing the cancelled orders */ @@ -570,7 +673,7 @@ class HollaExKit { /** * Connect to hollaEx websocket and listen to an event - * @param {array} event - The events to listen to + * @param {array} events - The events to listen to */ connect(events = []) { this.wsReconnect = true; @@ -671,7 +774,7 @@ class HollaExKit { /** * Subscribe to hollaEx websocket events - * @param {array} event - The events to listen to + * @param {array} events - The events to listen to */ subscribe(events = []) { if (this.wsConnected()) { @@ -733,7 +836,7 @@ class HollaExKit { /** * Unsubscribe to hollaEx websocket events - * @param {array} event - The events to unsub from + * @param {array} events - The events to unsub from */ unsubscribe(events = []) { if (this.wsConnected()) { diff --git a/network.js b/network.js index d56a10e..547010b 100644 --- a/network.js +++ b/network.js @@ -116,13 +116,14 @@ class HollaExNetwork { /** * Get all trades for the exchange on the network - * @param {string} symbol - Symbol of trades. Leave blank to get trades for all symbols - * @param {number} limit - Amount of trades per page. Maximum: 50. Default: 50 - * @param {number} page - Page of trades data. Default: 1 - * @param {string} orderBy The field to order data by e.g. amount, id. Default: id - * @param {string} order Ascending (asc) or descending (desc). Default: desc - * @param {string} startDate Start date of query in ISO8601 format. Default: 0 - * @param {string} endDate End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {object} opts - Optional parameters. + * @param {string} opts.symbol - Symbol of trades. Leave blank to get trades for all symbols + * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50 + * @param {number} opts.page - Page of trades data. Default: 1 + * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id + * @param {string} opts.order - Ascending (asc) or descending (desc). Default: desc + * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0 + * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format * @return {object} Fields: Count, Data. Count is the number of trades on the page. Data is an array of trades */ getTrades( @@ -185,13 +186,14 @@ class HollaExNetwork { /** * Get all trades for a user on the network * @param {number} userId - User id on network. Leave blank to get all trades for the exchange - * @param {string} symbol - Symbol of trades. Leave blank to get trades for all symbols - * @param {number} limit - Amount of trades per page. Maximum: 50. Default: 50 - * @param {number} page - Page of trades data. Default: 1 - * @param {string} orderBy The field to order data by e.g. amount, id. Default: id - * @param {string} order Ascending (asc) or descending (desc). Default: desc - * @param {string} startDate Start date of query in ISO8601 format. Default: 0 - * @param {string} endDate End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {object} opts - Optional parameters. + * @param {string} opts.symbol - Symbol of trades. Leave blank to get trades for all symbols + * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50 + * @param {number} opts.page - Page of trades data. Default: 1 + * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id + * @param {string} opts.order - Ascending (asc) or descending (desc). Default: desc + * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0 + * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format * @return {object} Fields: Count, Data. Count is the number of trades on the page. Data is an array of trades */ getUserTrades( @@ -259,6 +261,11 @@ class HollaExNetwork { return createRequest(verb, `${this.apiUrl}${path}`, headers); } + /** + * Get user network data + * @param {number} userId - User's network id + * @return {object} User network data + */ getUser(userId) { checkKit(this.exchange_id); @@ -300,7 +307,17 @@ class HollaExNetwork { return createRequest(verb, `${this.apiUrl}${path}`, headers); } - createUserCryptoAddress(userId, crypto) { + /** + * Create a crypto address for user + * @param {number} userId - User id on network. + * @param {string} crypto - Crypto to create address for. + * @param {object} opts - Optional parameters. + * @param {string} opts.network - Crypto's blockchain network + * @return {object} Object with new address + */ + createUserCryptoAddress(userId, crypto, opts = { + network: null + }) { checkKit(this.exchange_id); if (!userId) { @@ -310,9 +327,12 @@ class HollaExNetwork { } const verb = 'GET'; - const path = `${this.baseUrl}/network/${ - this.exchange_id - }/create-address?user_id=${userId}&crypto=${crypto}`; + let path = `${this.baseUrl}/network/${this.exchange_id}/create-address?user_id=${userId}&crypto=${crypto}`; + + if (opts.network) { + path += `&network=${opts.network}`; + } + const headers = generateHeaders( this.headers, this.apiSecret, @@ -330,9 +350,13 @@ class HollaExNetwork { * @param {string} address - Address to send withdrawal to * @param {string} currency - Curreny to withdraw * @param {number} amount - Amount to withdraw + * @param {object} opts - Optional parameters. + * @param {string} opts.network - Specify crypto currency network * @return {object} Withdrawal made on the network */ - performWithdrawal(userId, address, currency, amount) { + performWithdrawal(userId, address, currency, amount, opts = { + network: null + }) { checkKit(this.exchange_id); if (!userId) { @@ -348,6 +372,9 @@ class HollaExNetwork { this.exchange_id }/withdraw?user_id=${userId}`; const data = { address, currency, amount }; + if (opts.network) { + data.network = opts.network; + } const headers = generateHeaders( this.headers, this.apiSecret, @@ -360,6 +387,12 @@ class HollaExNetwork { return createRequest(verb, `${this.apiUrl}${path}`, headers, data); } + /** + * Cancel a withdrawal for an exchange's user on the network + * @param {number} userId - User id on network + * @param {string} withdrawalId - Withdrawal's id on network (not transaction id). + * @return {object} Withdrawal canceled on the network + */ cancelWithdrawal(userId, withdrawalId) { checkKit(this.exchange_id); @@ -386,18 +419,21 @@ class HollaExNetwork { /** * Get all deposits for the exchange on the network - * @param {string} currency - Currency of deposits. Leave blank to get deposits for all currencies - * @param {boolean} status - Confirmed status of the deposits to get. Leave blank to get all confirmed and unconfirmed deposits - * @param {boolean} dismissed - Dismissed status of the deposits to get. Leave blank to get all dismissed and undismissed deposits - * @param {boolean} rejected - Rejected status of the deposits to get. Leave blank to get all rejected and unrejected deposits - * @param {boolean} processing - Processing status of the deposits to get. Leave blank to get all processing and unprocessing deposits - * @param {boolean} waiting - Waiting status of the deposits to get. Leave blank to get all waiting and unwaiting deposits - * @param {number} limit - Amount of trades per page. Maximum: 50. Default: 50 - * @param {number} page - Page of trades data. Default: 1 - * @param {string} orderBy The field to order data by e.g. amount, id. Default: id - * @param {string} order Ascending (asc) or descending (desc). Default: asc - * @param {string} startDate Start date of query in ISO8601 format. Default: 0 - * @param {string} endDate End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {object} opts - Optional parameters. + * @param {string} opts.currency - Currency of deposits. Leave blank to get deposits for all currencies + * @param {boolean} opts.status - Confirmed status of the deposits to get. Leave blank to get all confirmed and unconfirmed deposits + * @param {boolean} opts.dismissed - Dismissed status of the deposits to get. Leave blank to get all dismissed and undismissed deposits + * @param {boolean} opts.rejected - Rejected status of the deposits to get. Leave blank to get all rejected and unrejected deposits + * @param {boolean} opts.processing - Processing status of the deposits to get. Leave blank to get all processing and unprocessing deposits + * @param {boolean} opts.waiting - Waiting status of the deposits to get. Leave blank to get all waiting and unwaiting deposits + * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50 + * @param {number} opts.page - Page of trades data. Default: 1 + * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id + * @param {string} opts.order - Ascending (asc) or descending (desc). Default: asc + * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0 + * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {string} opts.transactionId - Deposit with specific transaction ID. + * @param {string} opts.address - Deposits with specific address. * @return {object} Fields: Count, Data. Count is the number of deposits on the page. Data is an array of deposits */ getDeposits( @@ -413,7 +449,9 @@ class HollaExNetwork { orderBy: 'id', order: 'asc', startDate: null, - endDate: null + endDate: null, + transactionId: null, + address: null } ) { checkKit(this.exchange_id); @@ -439,6 +477,14 @@ class HollaExNetwork { path += `&order=${opts.order}`; } + if (isString(opts.address)) { + path += `&address=${opts.address}`; + } + + if (isString(opts.transactionId)) { + path += `&transaction_id=${opts.transactionId}`; + } + if (isString(opts.startDate)) { path += `&start_date=${opts.startDate}`; } else if (isDate(opts.startDate)) { @@ -489,18 +535,21 @@ class HollaExNetwork { /** * Get all deposits for a user on the network * @param {number} userId - User id on network. Leave blank to get all deposits for the exchange - * @param {string} currency - Currency of deposits. Leave blank to get deposits for all currencies - * @param {boolean} status - Confirmed status of the deposits to get. Leave blank to get all confirmed and unconfirmed deposits - * @param {boolean} dismissed - Dismissed status of the deposits to get. Leave blank to get all dismissed and undismissed deposits - * @param {boolean} rejected - Rejected status of the deposits to get. Leave blank to get all rejected and unrejected deposits - * @param {boolean} processing - Processing status of the deposits to get. Leave blank to get all processing and unprocessing deposits - * @param {boolean} waiting - Waiting status of the deposits to get. Leave blank to get all waiting and unwaiting deposits - * @param {number} limit - Amount of trades per page. Maximum: 50. Default: 50 - * @param {number} page - Page of trades data. Default: 1 - * @param {string} orderBy The field to order data by e.g. amount, id. Default: id - * @param {string} order Ascending (asc) or descending (desc). Default: asc - * @param {string} startDate Start date of query in ISO8601 format. Default: 0 - * @param {string} endDate End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {object} opts - Optional parameters. + * @param {string} opts.currency - Currency of deposits. Leave blank to get deposits for all currencies + * @param {boolean} opts.status - Confirmed status of the deposits to get. Leave blank to get all confirmed and unconfirmed deposits + * @param {boolean} opts.dismissed - Dismissed status of the deposits to get. Leave blank to get all dismissed and undismissed deposits + * @param {boolean} opts.rejected - Rejected status of the deposits to get. Leave blank to get all rejected and unrejected deposits + * @param {boolean} opts.processing - Processing status of the deposits to get. Leave blank to get all processing and unprocessing deposits + * @param {boolean} opts.waiting - Waiting status of the deposits to get. Leave blank to get all waiting and unwaiting deposits + * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50 + * @param {number} opts.page - Page of trades data. Default: 1 + * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id + * @param {string} opts.order - Ascending (asc) or descending (desc). Default: asc + * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0 + * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {string} opts.transactionId - Deposit with specific transaction ID. + * @param {string} opts.address - Deposits with specific address. * @return {object} Fields: Count, Data. Count is the number of deposits on the page. Data is an array of deposits */ getUserDeposits( @@ -517,7 +566,9 @@ class HollaExNetwork { orderBy: 'id', order: 'asc', startDate: null, - endDate: null + endDate: null, + transactionId: null, + address: null } ) { checkKit(this.exchange_id); @@ -548,6 +599,14 @@ class HollaExNetwork { path += `&order=${opts.order}`; } + if (isString(opts.address)) { + path += `&address=${opts.address}`; + } + + if (isString(opts.transactionId)) { + path += `&transaction_id=${opts.transactionId}`; + } + if (isString(opts.startDate)) { path += `&start_date=${opts.startDate}`; } else if (isDate(opts.startDate)) { @@ -597,19 +656,21 @@ class HollaExNetwork { /** * Get all withdrawals for the exchange on the network - * @param {number} userId - User id on network. Leave blank to get all withdrawals for the exchange - * @param {string} currency - Currency of withdrawals. Leave blank to get withdrawals for all currencies - * @param {boolean} status - Confirmed status of the depowithdrawalssits to get. Leave blank to get all confirmed and unconfirmed withdrawals - * @param {boolean} dismissed - Dismissed status of the withdrawals to get. Leave blank to get all dismissed and undismissed withdrawals - * @param {boolean} rejected - Rejected status of the withdrawals to get. Leave blank to get all rejected and unrejected withdrawals - * @param {boolean} processing - Processing status of the withdrawals to get. Leave blank to get all processing and unprocessing withdrawals - * @param {boolean} waiting - Waiting status of the withdrawals to get. Leave blank to get all waiting and unwaiting withdrawals - * @param {number} limit - Amount of trades per page. Maximum: 50. Default: 50 - * @param {number} page - Page of trades data. Default: 1 - * @param {string} orderBy The field to order data by e.g. amount, id. Default: id - * @param {string} order Ascending (asc) or descending (desc). Default: asc - * @param {string} startDate Start date of query in ISO8601 format. Default: 0 - * @param {string} endDate End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {object} opts - Optional parameters. + * @param {string} opts.currency - Currency of withdrawals. Leave blank to get withdrawals for all currencies + * @param {boolean} opts.status - Confirmed status of the withdrawals to get. Leave blank to get all confirmed and unconfirmed withdrawals + * @param {boolean} opts.dismissed - Dismissed status of the withdrawals to get. Leave blank to get all dismissed and undismissed withdrawals + * @param {boolean} opts.rejected - Rejected status of the withdrawals to get. Leave blank to get all rejected and unrejected withdrawals + * @param {boolean} opts.processing - Processing status of the withdrawals to get. Leave blank to get all processing and unprocessing withdrawals + * @param {boolean} opts.waiting - Waiting status of the withdrawals to get. Leave blank to get all waiting and unwaiting withdrawals + * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50 + * @param {number} opts.page - Page of trades data. Default: 1 + * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id + * @param {string} opts.order - Ascending (asc) or descending (desc). Default: asc + * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0 + * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {string} opts.transactionId - Withdrawals with specific transaction ID. + * @param {string} opts.address - Withdrawals with specific address. * @return {object} Fields: Count, Data. Count is the number of withdrawals on the page. Data is an array of withdrawals */ getWithdrawals( @@ -625,7 +686,9 @@ class HollaExNetwork { orderBy: 'id', order: 'asc', startDate: null, - endDate: null + endDate: null, + transactionId: null, + address: null } ) { checkKit(this.exchange_id); @@ -651,6 +714,14 @@ class HollaExNetwork { path += `&order=${opts.order}`; } + if (isString(opts.address)) { + path += `&address=${opts.address}`; + } + + if (isString(opts.transactionId)) { + path += `&transaction_id=${opts.transactionId}`; + } + if (isString(opts.startDate)) { path += `&start_date=${opts.startDate}`; } else if (isDate(opts.startDate)) { @@ -701,18 +772,21 @@ class HollaExNetwork { /** * Get all withdrawals for a user on the network * @param {number} userId - User id on network. Leave blank to get all withdrawals for the exchange - * @param {string} currency - Currency of withdrawals. Leave blank to get withdrawals for all currencies - * @param {boolean} status - Confirmed status of the depowithdrawalssits to get. Leave blank to get all confirmed and unconfirmed withdrawals - * @param {boolean} dismissed - Dismissed status of the withdrawals to get. Leave blank to get all dismissed and undismissed withdrawals - * @param {boolean} rejected - Rejected status of the withdrawals to get. Leave blank to get all rejected and unrejected withdrawals - * @param {boolean} processing - Processing status of the withdrawals to get. Leave blank to get all processing and unprocessing withdrawals - * @param {boolean} waiting - Waiting status of the withdrawals to get. Leave blank to get all waiting and unwaiting withdrawals - * @param {number} limit - Amount of trades per page. Maximum: 50. Default: 50 - * @param {number} page - Page of trades data. Default: 1 - * @param {string} orderBy The field to order data by e.g. amount, id. Default: id - * @param {string} order Ascending (asc) or descending (desc). Default: asc - * @param {string} startDate Start date of query in ISO8601 format. Default: 0 - * @param {string} endDate End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {object} opts - Optional parameters. + * @param {string} opts.currency - Currency of withdrawals. Leave blank to get withdrawals for all currencies + * @param {boolean} opts.status - Confirmed status of the depowithdrawalssits to get. Leave blank to get all confirmed and unconfirmed withdrawals + * @param {boolean} opts.dismissed - Dismissed status of the withdrawals to get. Leave blank to get all dismissed and undismissed withdrawals + * @param {boolean} opts.rejected - Rejected status of the withdrawals to get. Leave blank to get all rejected and unrejected withdrawals + * @param {boolean} opts.processing - Processing status of the withdrawals to get. Leave blank to get all processing and unprocessing withdrawals + * @param {boolean} opts.waiting - Waiting status of the withdrawals to get. Leave blank to get all waiting and unwaiting withdrawals + * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50 + * @param {number} opts.page - Page of trades data. Default: 1 + * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id + * @param {string} opts.order - Ascending (asc) or descending (desc). Default: asc + * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0 + * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {string} opts.transactionId - Withdrawals with specific transaction ID. + * @param {string} opts.address - Withdrawals with specific address. * @return {object} Fields: Count, Data. Count is the number of withdrawals on the page. Data is an array of withdrawals */ getUserWithdrawals( @@ -729,7 +803,9 @@ class HollaExNetwork { orderBy: 'id', order: 'asc', startDate: null, - endDate: null + endDate: null, + transactionId: null, + address: null } ) { checkKit(this.exchange_id); @@ -760,6 +836,14 @@ class HollaExNetwork { path += `&order=${opts.order}`; } + if (isString(opts.address)) { + path += `&address=${opts.address}`; + } + + if (isString(opts.transactionId)) { + path += `&transaction_id=${opts.transactionId}`; + } + if (isString(opts.startDate)) { path += `&start_date=${opts.startDate}`; } else if (isDate(opts.startDate)) { @@ -809,7 +893,6 @@ class HollaExNetwork { /** * Get the balance for the exchange on the network - * @param {number} userId - User id on network. Leave blank to get balance for exchange * @return {object} Available, pending, and total balance for all currencies for your exchange on the network */ getBalance() { @@ -894,6 +977,13 @@ class HollaExNetwork { * @param {number} size - The amount of currency to order * @param {string} type - The type of order to create e.g. 'market', 'limit' * @param {number} price - The price at which to order (only required if type is 'limit') + * @param {object} feeData - Object with fee data + * @param {object} feeData.fee_structure - Object with maker and taker fees + * @param {number} feeData.fee_structure.maker - Maker fee. + * @param {number} feeData.fee_structure.taker - Taker fee + * @param {object} opts - Optional parameters. + * @param {number} opts.stop - Stop price of order. This makes the order a stop loss order. + * @param {object} opts.meta - Meta values for order. * @return {object} Newly created order values e.g. symbol, id, side, status, etc. */ createOrder( @@ -996,21 +1086,20 @@ class HollaExNetwork { /** * Get all orders for the exchange on the network - * @param {number} userId - User id on network. Leave blank to get all orders for the exchange - * @param {string} symbol - Symbol of orders. Leave blank to get orders for all symbols - * @param {string} side - Side of orders to query e.g. buy, sell - * @param {string} type - Type of orders to query e.g. active, stop - * @param {number} limit - Amount of trades per page. Maximum: 50. Default: 50 - * @param {number} page - Page of trades data. Default: 1 - * @param {string} orderBy The field to order data by e.g. amount, id. Default: id - * @param {string} order Ascending (asc) or descending (desc). Default: desc - * @param {string} startDate Start date of query in ISO8601 format. Default: 0 - * @param {string} endDate End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {object} opts - Optional parameters. + * @param {string} opts.symbol - Symbol of orders. Leave blank to get orders for all symbols + * @param {string} opts.side - Side of orders to query e.g. buy, sell + * @param {string} opts.type - Type of orders to query e.g. active, stop + * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50 + * @param {number} opts.page - Page of trades data. Default: 1 + * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id + * @param {string} opts.order - Ascending (asc) or descending (desc). Default: desc + * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0 + * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format * @return {array} Array of queried orders */ getOrders( opts = { - userId: null, symbol: null, side: null, status: null, @@ -1086,15 +1175,16 @@ class HollaExNetwork { /** * Get all orders for a user on the network * @param {number} userId - User id on network. Leave blank to get all orders for the exchange - * @param {string} symbol - Symbol of orders. Leave blank to get orders for all symbols - * @param {string} side - Side of orders to query e.g. buy, sell - * @param {string} type - Type of orders to query e.g. active, stop - * @param {number} limit - Amount of trades per page. Maximum: 50. Default: 50 - * @param {number} page - Page of trades data. Default: 1 - * @param {string} orderBy The field to order data by e.g. amount, id. Default: id - * @param {string} order Ascending (asc) or descending (desc). Default: desc - * @param {string} startDate Start date of query in ISO8601 format. Default: 0 - * @param {string} endDate End date of query in ISO8601 format: Default: current time in ISO8601 format + * @param {object} opts - Optional parameters. + * @param {string} opts.symbol - Symbol of orders. Leave blank to get orders for all symbols + * @param {string} opts.side - Side of orders to query e.g. buy, sell + * @param {string} opts.type - Type of orders to query e.g. active, stop + * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50 + * @param {number} opts.page - Page of trades data. Default: 1 + * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id + * @param {string} opts.order - Ascending (asc) or descending (desc). Default: desc + * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0 + * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format * @return {array} Array of queried orders */ getUserOrders( @@ -1180,7 +1270,8 @@ class HollaExNetwork { /** * Cancel all orders for an exchange's user on the network * @param {number} userId - User id on network - * @param {string} symbol - Symbol of orders to cancel. Leave blank to cancel user's orders for all symbols + * @param {object} opts - Optional parameters. + * @param {string} opts.symbol - Symbol of orders to cancel. Leave blank to cancel user's orders for all symbols * @return {array} Array of canceled orders */ cancelAllOrders(userId, opts = { symbol: null }) { @@ -1242,7 +1333,8 @@ class HollaExNetwork { * @param {string} currency; - Currency of transaction * @param {string} transactionId - Transaction id * @param {string} address - Transaction receiving address - * @param {boolean} isTestnet - Network transaction was made on. Default: false + * @param {object} opts - Optional parameters. + * @param {boolean} opts.isTestnet - Network transaction was made on. Default: false * @return {object} Success or failed message */ checkTransaction( @@ -1285,7 +1377,9 @@ class HollaExNetwork { * @param {number} receiverId - Network id of user that is receiving funds * @param {string} currency - Currency to transfer * @param {number} amount - Amount to transfer - * @param {string} description - Description of transfer. Default: Empty string + * @param {object} opts - Optional parameters. + * @param {string} opts.description - Description of transfer. Default: Empty string + * @param {boolean} opts.email - Send email to users after transfer. Default: true. * @return {object} Object with field transaction_id */ transferAsset( @@ -1340,6 +1434,19 @@ class HollaExNetwork { return createRequest(verb, `${this.apiUrl}${path}`, headers, data); } + /** + * Get trade history for exchange on network + * @param {object} opts - Optional parameters. + * @param {string} opts.symbol - Symbol of trades. + * @param {string} opts.side - Side of trades. + * @param {number} opts.limit - Amount of trades per page. Maximum: 50. Default: 50 + * @param {number} opts.page - Page of trades data. Default: 1 + * @param {string} opts.orderBy - The field to order data by e.g. amount, id. Default: id + * @param {string} opts.order - Ascending (asc) or descending (desc). Default: asc + * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0 + * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format + * @return {object} Count and data format. + */ getTradesHistory( opts = { symbol: null, @@ -1409,8 +1516,9 @@ class HollaExNetwork { /* Network Engine Endpoints*/ /** - * Get time and sales on Nework engine - * @param {string} symbol - Symbol to get trades for. Leave blank to get trades of all symbols + * Get Public trades on network + * @param {object} opts - Optional parameters. + * @param {string} opts.symbol - Symbol to get trades for. Leave blank to get trades of all symbols * @return {object} Object with trades */ getPublicTrades(opts = { symbol: null }) { @@ -1434,7 +1542,7 @@ class HollaExNetwork { } /** - * Get top orderbooks + * Get top orderbook for specific symbol * @param {string} symbol - Symbol to get orderbook for. Leave blank to get orderbook of all symbols * @return {object} Object with orderbook */ @@ -1692,7 +1800,18 @@ class HollaExNetwork { return createRequest(verb, `${this.apiUrl}${path}`, headers); } - mintAsset(userId, currency, amount, opts = { description: null, transaction_id: null }) { + /** + * Mint an asset you own to a user + * @param {number} userId; - Network id of user. + * @param {string} currency - Currency to mint. + * @param {number} amount - Amount to mint. + * @param {object} opts - Optional parameters. + * @param {string} opts.description - Description of transfer. Default: Empty string + * @param {string} opts.transactionId - Custom transaction ID for mint. + * @param {boolean} opts.status - Status of mint created. Default: true. + * @return {object} Object with created mint's data. + */ + mintAsset(userId, currency, amount, opts = { description: null, transactionId: null, status: null }) { if (!userId) { return reject(parameterError('userId', 'cannot be null')); } else if (!currency) { @@ -1713,8 +1832,66 @@ class HollaExNetwork { data.description = opts.description; } - if (opts.transaction_id) { - data.transaction_id = opts.transaction_id; + if (opts.transactionId) { + data.transaction_id = opts.transactionId; + } + + if (isBoolean(opts.status)) { + data.status = opts.status; + } + + const headers = generateHeaders( + this.headers, + this.apiSecret, + verb, + path, + this.apiExpiresAfter, + data + ); + + return createRequest(verb, `${this.apiUrl}${path}`, headers, data); + } + + /** + * Update a pending mint + * @param {string} transactionId; - Transaction ID of pending mint. + * @param {object} opts - Optional parameters. + * @param {boolean} opts.status - Set to true to confirm pending mint. + * @param {boolean} opts.dismissed - Set to true to dismiss pending mint. + * @param {boolean} opts.rejected - Set to true to reject pending mint. + * @param {string} opts.updatedTransactionId - Value to update transaction ID of pending mint to. + * @return {object} Object with updated mint's data. + */ + updatePendingMint(transactionId, opts = { status: null, dismissed: null, rejected: null, updatedTransactionId: null }) { + if (!transactionId) { + return reject(parameterError('transactionId', 'cannot be null')); + } + + const status = isBoolean(opts.status) ? opts.status : false; + const rejected = isBoolean(opts.rejected) ? opts.rejected : false; + const dismissed = isBoolean(opts.dismissed) ? opts.dismissed : false; + + if (!status && !rejected && !dismissed) { + return reject(new Error('Must give one parameter to update')); + } else if ( + status && (rejected || dismissed) + || rejected && (status || dismissed) + || dismissed && (status || rejected) + ) { + return reject(new Error('Can only update one parmaeter')); + } + + const verb = 'PUT'; + const path = `${this.baseUrl}/network/mint`; + const data = { + transaction_id: transactionId, + status, + rejected, + dismissed + }; + + if (opts.updatedTransactionId) { + data.updated_transaction_id = opts.updatedTransactionId; } const headers = generateHeaders( @@ -1729,7 +1906,18 @@ class HollaExNetwork { return createRequest(verb, `${this.apiUrl}${path}`, headers, data); } - burnAsset(userId, currency, amount, opts = { description: null, transaction_id: null }) { + /** + * Burn an asset you own to a user + * @param {number} userId; - Network id of user. + * @param {string} currency - Currency to burn. + * @param {number} amount - Amount to burn. + * @param {object} opts - Optional parameters. + * @param {string} opts.description - Description of transfer. Default: Empty string + * @param {string} opts.transactionId - Custom transaction ID for burn. + * @param {boolean} opts.status - Status of burn created. Default: true. + * @return {object} Object with created burn's data. + */ + burnAsset(userId, currency, amount, opts = { description: null, transactionId: null, status: null }) { if (!userId) { return reject(parameterError('userId', 'cannot be null')); } else if (!currency) { @@ -1750,8 +1938,12 @@ class HollaExNetwork { data.description = opts.description; } - if (opts.transaction_id) { - data.transaction_id = opts.transaction_id; + if (opts.transactionId) { + data.transaction_id = opts.transactionId; + } + + if (isBoolean(opts.status)) { + data.status = opts.status; } const headers = generateHeaders( @@ -1766,6 +1958,67 @@ class HollaExNetwork { return createRequest(verb, `${this.apiUrl}${path}`, headers, data); } + /** + * Update a pending burn + * @param {string} transactionId; - Transaction ID of pending burn. + * @param {object} opts - Optional parameters. + * @param {boolean} opts.status - Set to true to confirm pending burn. + * @param {boolean} opts.dismissed - Set to true to dismiss pending burn. + * @param {boolean} opts.rejected - Set to true to reject pending burn. + * @param {string} opts.updatedTransactionId - Value to update transaction ID of pending burn to. + * @return {object} Object with updated burn's data. + */ + updatePendingBurn(transactionId, opts = { status: null, dismissed: null, rejected: null, updatedTransactionId: null }) { + if (!transactionId) { + return reject(parameterError('transactionId', 'cannot be null')); + } + + const status = isBoolean(opts.status) ? opts.status : false; + const rejected = isBoolean(opts.rejected) ? opts.rejected : false; + const dismissed = isBoolean(opts.dismissed) ? opts.dismissed : false; + + if (!status && !rejected && !dismissed) { + return reject(new Error('Must give one parameter to update')); + } else if ( + status && (rejected || dismissed) + || rejected && (status || dismissed) + || dismissed && (status || rejected) + ) { + return reject(new Error('Can only update one parmaeter')); + } + + const verb = 'PUT'; + const path = `${this.baseUrl}/network/burn`; + const data = { + transaction_id: transactionId, + status, + rejected, + dismissed + }; + + if (opts.updatedTransactionId) { + data.updated_transaction_id = opts.updatedTransactionId; + } + + const headers = generateHeaders( + this.headers, + this.apiSecret, + verb, + path, + this.apiExpiresAfter, + data + ); + + return createRequest(verb, `${this.apiUrl}${path}`, headers, data); + } + + /** + * Get generated fees for exchange + * @param {object} opts - Optional parameters. + * @param {string} opts.startDate - Start date of query in ISO8601 format. Default: 0 + * @param {string} opts.endDate - End date of query in ISO8601 format: Default: current time in ISO8601 format + * @return {object} Object with generated fees + */ getGeneratedFees( opts = { startDate: null, @@ -1800,6 +2053,10 @@ class HollaExNetwork { return createRequest(verb, `${this.apiUrl}${path}`, headers); } + /** + * Settle exchange fees + * @return {object} Object with settled fees. + */ settleFees() { checkKit(this.exchange_id); const verb = 'GET'; @@ -1817,6 +2074,14 @@ class HollaExNetwork { return createRequest(verb, `${this.apiUrl}${path}`, headers); } + /** + * Convert assets to a quote asset + * @param {array} assets - Array of assets to convert as strings + * @param {object} opts - Optional parameters. + * @param {string} opts.quote - Quote asset to convert to. Default: USDT. + * @param {number} opts.amount - Amount of quote asset to convert to. Default: 1. + * @return {object} Object with converted assets. + */ getOraclePrices(assets = [], opts = { quote: null, amount: null }) { checkKit(this.exchange_id); @@ -1850,6 +2115,10 @@ class HollaExNetwork { return createRequest(verb, `${this.apiUrl}${path}`, headers); } + /** + * Connect to websocket + * @param {array} events - Array of events to connect to + */ connect(events = []) { checkKit(this.exchange_id); this.wsReconnect = true; @@ -1933,6 +2202,9 @@ class HollaExNetwork { } } + /** + * Disconnect from Network websocket + */ disconnect() { checkKit(this.exchange_id); if (this.wsConnected()) { @@ -1943,6 +2215,10 @@ class HollaExNetwork { } } + /** + * Subscribe to Network websocket events + * @param {array} events - The events to listen to + */ subscribe(events = []) { checkKit(this.exchange_id); if (this.wsConnected()) { @@ -1957,6 +2233,10 @@ class HollaExNetwork { } } + /** + * Unsubscribe to Network websocket events + * @param {array} events - The events to unsub from + */ unsubscribe(events = []) { checkKit(this.exchange_id); if (this.wsConnected()) { diff --git a/package.json b/package.json index eb35ac7..5d8eb5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hollaex-node-lib", - "version": "2.0.0", + "version": "2.1.0", "description": "hollaex api and websocket library for nodejs", "main": "index.js", "dependencies": {