hollaex-node-lib 2.12.0 → 2.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -69,13 +69,13 @@ client
69
69
  | `getBalance` | | User's wallet balance |
70
70
  | `getDeposits` | <ul><li>**opts**: Object with additional params</li><li>**opts.currency**: (_optional_) Filter data set by asset</li><li>**opts.status**: (_optional_) Filter data set `status`</li><li>**opts.dismissed**: (_optional_) Filter data set `dismissed`</li><li>**opts.rejected**: (_optional_) Filter data set `rejected`</li><li>**opts.processing**: (_optional_) Filter data set `processing`</li><li>**opts.waiting**: (_optional_) Filter data set `waiting`</li><li>**opts.limit**: (_optional_, _default_=`50`, _max_=`50`) Number of items to get</li><li>**opts.page**: (_optional_, _default_=`1`) Page number of data</li><li>**opts.orderBy**: (_optional_) Field to order data by</li><li>**opts.order**: (_optional_, _enum_=[`asc`, `desc`]) Specify ascending or descending order</li><li>**opts.startDate**: (_optional_, _format_=`ISO8601`) Start date of data set</li><li>**opts.endDate**: (_optional_, _format_=`ISO8601`) End date of data set</li><li>**opts.transactionId**: (_optional_) Filter data set by TXID</li><li>**opts.address**: (_optional_) Filter data set by address</li></ul> | User's list of all deposits |
71
71
  | `getWithdrawals` | <ul><li>**opts**: Object with additional params</li><li>**opts.currency**: (_optional_) Filter data set by asset</li><li>**opts.status**: (_optional_) Filter data set `status`</li><li>**opts.dismissed**: (_optional_) Filter data set `dismissed`</li><li>**opts.rejected**: (_optional_) Filter data set `rejected`</li><li>**opts.processing**: (_optional_) Filter data set `processing`</li><li>**opts.waiting**: (_optional_) Filter data set `waiting`</li><li>**opts.limit**: (_optional_, _default_=`50`, _max_=`50`) Number of items to get</li><li>**opts.page**: (_optional_, _default_=`1`) Page number of data</li><li>**opts.orderBy**: (_optional_) Field to order data by</li><li>**opts.order**: (_optional_, _enum_=[`asc`, `desc`]) Specify ascending or descending order</li><li>**opts.startDate**: (_optional_, _format_=`ISO8601`) Start date of data set</li><li>**opts.endDate**: (_optional_, _format_=`ISO8601`) End date of data set</li><li>**opts.transactionId**: (_optional_) Filter data set by TXID</li><li>**opts.address**: (_optional_) Filter data set by address</li></ul> | User's list of all withdrawals |
72
- | `requestWithdrawal` | <ul><li>**currency**: Currency code e.g. `xht`</li><li>**amount**: Withdrawal amount</li><li>**address**: Address to withdrawal to</li><li>**opts**: Object with additional params</li><li>**opts.network**: (_required if asset has multiple networks_) Blockchain network to create address for e.g. `trx`</li><li>**opts.otpCode**: (_required if user has otp enabled_) User otp code</li></ul> | Create a new withdrawal request |
72
+ | `makeWithdrawal` | <ul><li>**currency**: Currency code e.g. `xht`</li><li>**amount**: Withdrawal amount</li><li>**address**: Address to withdrawal to</li><li>**opts**: Object with additional params</li><li>**opts.network**: (_required if asset has multiple networks_) Blockchain network to create address for e.g. `trx`</li></ul> | Create a new withdrawal request |
73
73
  | `getUserTrades` | <ul><li>**opts**: Object with additional params</li><li>**opts.symbol**: (_optional_) HollaEx trading symbol e.g. `xht-usdt`</li><li>**opts.limit**: (_optional_, _default_=`50`, _max_=`50`) Number of items to get</li><li>**opts.page**: (_optional_, _default_=`1`) Page number of data</li><li>**opts.orderBy**: (_optional_) Field to order data by</li><li>**opts.order**: (_optional_, _enum_=[`asc`, `desc`]) Specify ascending or descending order</li><li>**opts.startDate**: (_optional_, _format_=`ISO8601`) Start date of data set</li><li>**opts.endDate**: (_optional_, _format_=`ISO8601`) End date of data set</li></ul> | User's list of all trades |
74
74
  | `getOrder` | <ul><li>**orderId**: HollaEx Network Order ID</li></ul> | Get specific information about a certain order |
75
75
  | `getOrders` | <ul><li>**opts**: Object with additional params</li><li>**opts.symbol**: (_optional_) HollaEx trading symbol e.g. `xht-usdt`</li><li>**opts.side**: (_optional_, _enum_=[`buy`, `sell`]) Order side</li><li>**opts.status**: (_optional_) Filter data set `status`</li><li>**opts.limit**: (_optional_, _default_=`50`, _max_=`50`) Number of items to get</li><li>**opts.page**: (_optional_, _default_=`1`) Page number of data</li><li>**opts.orderBy**: (_optional_) Field to order data by</li><li>**opts.order**: (_optional_, _enum_=[`asc`, `desc`])</li><li>**opts.startDate**: (_optional_, _format_=`ISO8601`) Start date of data set</li><li>**opts.endDate**: (_optional_, _format_=`ISO8601`) End date of data set</li></ul> | Get the list of all user orders. It can be filter by passing the symbol |
76
76
  | `createOrder` | <ul><li>**symbol**: HollaEx trading symbol e.g. `xht-usdt`</li><li>**side** (_enum_=[`buy`, `sell`]): Order side</li><li>**size**: Size of order to place</li><li>**type**: (_enum_=[`market`, `limit`] Order type</li><li>**price**: (_required if limit order type_) Order price</li><li>**opts**: Object with additional params</li><li>**opts.stop**: (_optional_) Stop price for order</li><li>**opts.meta**: (_optional_) Object with additional meta configurations</li><li>**opts.meta.post_only**: (_optional_, _default_=`false`) Make post only order </li><li>**opts.meta.note**: (_optional_) Custom note for order</li></ul> | Create a new order |
77
77
  | `cancelOrder` | <ul><li>**orderId**: HollaEx Network order ID</li></ul> | Cancel a specific order with its ID |
78
- | `cancelAllOrders` | <ul><li>**opts**: Object with additional params</li><li>**opts.symbol**: (_optional_) HollaEx trading symbol e.g. `xht-usdt`</li></ul> | Cancel all open order. It can be filter by passing the symbol |
78
+ | `cancelAllOrders` | <ul><li>**symbol**: HollaEx trading symbol e.g. `xht-usdt`</li></ul> | Cancel all the active orders of a user, filtered by currency pair symbol |
79
79
 
80
80
  ### Websocket
81
81
 
@@ -1,19 +1,27 @@
1
1
  const HollaEx = require('../index');
2
2
  require('dotenv').load();
3
3
 
4
- const API_KEY = process.env.API_KEY || '';
5
- const API_SECRET = process.env.API_SECRET || '';
6
- const client = new HollaEx({ apiKey: API_KEY, apiSecret: API_SECRET });
7
-
8
- client
9
- .getTicker('xht-usdt')
10
- .then((data) => {
11
- console.log(data);
12
- console.log('The volume is', data.volume);
13
- })
14
- .catch((err) => {
15
- console.log(err);
16
- });
4
+ const API_KEY = process.env.API_KEY || 'b28d81e806535350d83b48e952d0e2ed8ffcc6ef';
5
+ const API_SECRET = process.env.API_SECRET || '73879b785c50e235a0e2e972a899eba56968bc42c956f68e87';
6
+ const client = new HollaEx({ apiURL: 'https://api.sandbox.hollaex.com', apiKey: API_KEY, apiSecret: API_SECRET });
7
+
8
+ // client
9
+ // .createOrder(
10
+ // 'xht-usdt',
11
+ // 'buy',
12
+ // 0.1,
13
+ // 'market',
14
+ // // 0
15
+ // )
16
+ // .then(async (data) => {
17
+ // console.log(data);
18
+ // // console.log('The volume is', data.volume);
19
+ // // const withdrawal = await client.makeWithdrawal('xht', 1, '0x97e13fccfe2edab7e8077d0f2ac69fe984cfe7f7', { network: 'eth' });
20
+ // // console.log(withdrawal);
21
+ // })
22
+ // .catch((err) => {
23
+ // console.log(err);
24
+ // });
17
25
 
18
26
  // connect to websocket
19
27
  /*
@@ -22,7 +30,7 @@ client
22
30
  symbols : xht-usdt
23
31
  */
24
32
 
25
- client.connect(['orderbook']);
33
+ client.connect(['usertrade']);
26
34
 
27
35
  client.ws.on('message', (data) => {
28
36
  data = JSON.parse(data);
@@ -30,7 +38,11 @@ client.ws.on('message', (data) => {
30
38
  });
31
39
 
32
40
 
41
+ client.ws.on('error', (error) => {
42
+ console.log(error);
43
+ });
44
+
33
45
 
34
- setTimeout(() => {
35
- client.disconnect();
36
- }, 10000);
46
+ // setTimeout(() => {
47
+ // client.disconnect();
48
+ // }, 10000);
package/kit.js CHANGED
@@ -380,31 +380,25 @@ class HollaExKit {
380
380
  }
381
381
 
382
382
  /**
383
- * Make a withdrawal request
383
+ * Make a withdrawal
384
384
  * @param {string} currency - The currency to withdrawal
385
385
  * @param {number} amount - The amount of currency to withdrawal
386
386
  * @param {string} address - The recipient's wallet address
387
387
  * @param {object} opts - Optional parameters.
388
388
  * @param {string} opts.network - Crypto network of currency being withdrawn.
389
- * @param {string} opts.otpCode - Otp code for user if otp is enabled.
390
389
  * @return {object} A JSON object {message:"Success"}
391
390
  */
392
- requestWithdrawal(currency, amount, address, opts = {
391
+ makeWithdrawal(currency, amount, address, opts = {
393
392
  network: null,
394
- otpCode: null
395
393
  }) {
396
394
  const verb = 'POST';
397
- const path = `${this.baseUrl}/user/request-withdrawal`;
395
+ const path = `${this.baseUrl}/user/withdrawal`;
398
396
  const data = {
399
397
  currency,
400
398
  amount,
401
399
  address
402
400
  };
403
401
 
404
- if (opts.network) {
405
- data.otp_code = opts.otpCode;
406
- }
407
-
408
402
  if (opts.network) {
409
403
  data.network = opts.network;
410
404
  }
@@ -656,19 +650,17 @@ class HollaExKit {
656
650
  }
657
651
 
658
652
  /**
659
- * Cancel all the user's active orders, can filter by currency pair symbol
660
- * @param {object} opts - Optional parameters
661
- * @param {string} opts.symbol - The currency pair symbol to filter by e.g. 'hex-usdt', leave empty to cancel orders of all symbols
653
+ * Cancel all the active orders of a user, filtered by currency pair symbol
654
+ * @param {string} symbol - The currency pair symbol to filter by e.g. 'hex-usdt'
662
655
  * @return {array} A JSON array of objects containing the cancelled orders
663
656
  */
664
- cancelAllOrders(opts = { symbol: null }) {
665
- const verb = 'DELETE';
666
- let path = `${this.baseUrl}/order/all`;
667
-
668
- if (isString(opts.symbol)) {
669
- path += `?symbol=${opts.symbol}`;
657
+ cancelAllOrders(symbol) {
658
+ if (!isString(symbol)) {
659
+ throw new Error('You must provide a symbol to cancel all orders for');
670
660
  }
671
661
 
662
+ const verb = 'DELETE';
663
+ let path = `${this.baseUrl}/order/all?symbol=${symbol}`;
672
664
  const headers = generateHeaders(
673
665
  this.headers,
674
666
  this.apiSecret,
@@ -676,6 +668,7 @@ class HollaExKit {
676
668
  path,
677
669
  this.apiExpiresAfter
678
670
  );
671
+
679
672
  return createRequest(verb, `${this.apiUrl}${path}`, headers);
680
673
  }
681
674
 
@@ -820,6 +813,7 @@ class HollaExKit {
820
813
  }
821
814
  break;
822
815
  case 'order':
816
+ case 'usertrade':
823
817
  case 'wallet':
824
818
  case 'deposit':
825
819
  this.ws.send(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hollaex-node-lib",
3
- "version": "2.12.0",
3
+ "version": "2.14.1",
4
4
  "description": "hollaex api and websocket library for nodejs",
5
5
  "main": "index.js",
6
6
  "dependencies": {
@@ -36,8 +36,7 @@
36
36
  },
37
37
  "repository": {
38
38
  "type": "git",
39
- "url": "https://github.com/bitholla/hollaex-node-lib"
39
+ "url": "https://github.com/hollaex/hollaex-node-lib"
40
40
  },
41
- "author": "bitHolla Inc",
42
41
  "license": "MIT"
43
42
  }