hollaex-node-lib 2.19.0 → 2.19.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.
Files changed (3) hide show
  1. package/README.md +7 -2
  2. package/kit.js +666 -236
  3. package/package.json +1 -1
package/kit.js CHANGED
@@ -693,7 +693,7 @@ class HollaExKit {
693
693
  * @return {object} A JSON object with conversion info
694
694
  */
695
695
  getOraclePrice(
696
- assets,
696
+ assets,
697
697
  opts = {
698
698
  quote: null,
699
699
  amount: null
@@ -710,7 +710,7 @@ class HollaExKit {
710
710
  if (isString(opts.quote)) {
711
711
  params += `&quote=${opts.quote}`;
712
712
  }
713
-
713
+
714
714
  if (isNumber(opts.amount)) {
715
715
  params += `&amount=${opts.amount}`;
716
716
  }
@@ -726,7 +726,7 @@ class HollaExKit {
726
726
  return createRequest(verb, `${this.apiUrl}${path}`, headers);
727
727
  }
728
728
 
729
-
729
+
730
730
  /**
731
731
  * Get trade history HOLCV for all pairs
732
732
  * @param {array} assets - The list of assets to get the mini charts for
@@ -750,21 +750,21 @@ class HollaExKit {
750
750
  if (isArray(assets)) {
751
751
  params += `&assets=${opts.assets}`;
752
752
  }
753
-
753
+
754
754
  if (isString(opts.from)) {
755
755
  params += `&from=${opts.from}`;
756
756
  }
757
-
757
+
758
758
  if (isString(opts.to)) {
759
759
  params += `&to=${opts.to}`;
760
760
  }
761
-
761
+
762
762
  if (isString(opts.quote)) {
763
763
  params += `&quote=${opts.quote}`;
764
764
  }
765
-
765
+
766
766
  if (params.length > 1) path += params;
767
-
767
+
768
768
  const headers = generateHeaders(
769
769
  this.headers,
770
770
  this.apiSecret,
@@ -774,7 +774,7 @@ class HollaExKit {
774
774
  );
775
775
  return createRequest(verb, `${this.apiUrl}${path}`, headers);
776
776
  }
777
-
777
+
778
778
  /**
779
779
  * Get Quick Trade Quote
780
780
  * @param {string} spending_currency - Currency symbol of the spending currency
@@ -793,11 +793,11 @@ class HollaExKit {
793
793
  const verb = 'GET';
794
794
  let path = `${this.baseUrl}/quick-trade`;
795
795
  let params = '?';
796
-
796
+
797
797
  if (isString(spending_currency)) {
798
798
  params += `&spending_currency=${spending_currency}`;
799
799
  }
800
-
800
+
801
801
  if (isString(receiving_currency)) {
802
802
  params += `&receiving_currency=${receiving_currency}`;
803
803
  }
@@ -805,13 +805,13 @@ class HollaExKit {
805
805
  if (isString(opts.spending_amount)) {
806
806
  params += `&spending_amount=${opts.spending_amount}`;
807
807
  }
808
-
808
+
809
809
  if (isString(opts.receiving_amount)) {
810
810
  params += `&receiving_amount=${opts.receiving_amount}`;
811
811
  }
812
-
812
+
813
813
  if (params.length > 1) path += params;
814
-
814
+
815
815
  const headers = generateHeaders(
816
816
  this.headers,
817
817
  this.apiSecret,
@@ -834,7 +834,7 @@ class HollaExKit {
834
834
  const data = {
835
835
  token
836
836
  };
837
-
837
+
838
838
  const headers = generateHeaders(
839
839
  this.headers,
840
840
  this.apiSecret,
@@ -907,7 +907,7 @@ class HollaExKit {
907
907
  const verb = 'GET';
908
908
  let path = `${this.baseUrl}/admin/deposits`;
909
909
  let params = '?';
910
-
910
+
911
911
  if (isNumber(opts.userId)) {
912
912
  params += `&user_id=${opts.userId}`;
913
913
  }
@@ -983,7 +983,7 @@ class HollaExKit {
983
983
  );
984
984
  return createRequest(verb, `${this.apiUrl}${path}`, headers);
985
985
  }
986
-
986
+
987
987
  /**
988
988
  * Retrieve list of the user's withdrawals by admin
989
989
  * @param {object} opts - Optional parameters
@@ -1150,7 +1150,7 @@ class HollaExKit {
1150
1150
  amount
1151
1151
  };
1152
1152
 
1153
-
1153
+
1154
1154
  if (isString(opts.description)) {
1155
1155
  data.description = opts.description;
1156
1156
  }
@@ -1200,7 +1200,7 @@ class HollaExKit {
1200
1200
  amount
1201
1201
  };
1202
1202
 
1203
-
1203
+
1204
1204
  if (isString(opts.transactionId)) {
1205
1205
  data.transaction_id = opts.transactionId;
1206
1206
  }
@@ -1264,7 +1264,7 @@ class HollaExKit {
1264
1264
  if (isString(opts.updatedTransactionId)) {
1265
1265
  data.updated_transaction_id = opts.updatedTransactionId;
1266
1266
  }
1267
-
1267
+
1268
1268
  if (isString(opts.updatedAddress)) {
1269
1269
  data.updated_address = opts.updatedAddress;
1270
1270
  }
@@ -1338,24 +1338,24 @@ class HollaExKit {
1338
1338
  currency,
1339
1339
  amount
1340
1340
  };
1341
-
1342
-
1341
+
1342
+
1343
1343
  if (isString(opts.transactionId)) {
1344
1344
  data.transaction_id = opts.transactionId;
1345
1345
  }
1346
-
1346
+
1347
1347
  if (isBoolean(opts.status)) {
1348
1348
  data.status = opts.status;
1349
1349
  }
1350
-
1350
+
1351
1351
  if (isBoolean(opts.email)) {
1352
1352
  data.email = opts.email;
1353
1353
  }
1354
-
1354
+
1355
1355
  if (isNumber(opts.fee)) {
1356
1356
  data.fee = opts.fee;
1357
1357
  }
1358
-
1358
+
1359
1359
  const headers = generateHeaders(
1360
1360
  this.headers,
1361
1361
  this.apiSecret,
@@ -1366,7 +1366,7 @@ class HollaExKit {
1366
1366
  );
1367
1367
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1368
1368
  }
1369
-
1369
+
1370
1370
  /**
1371
1371
  * Update Exchange Withdrawal
1372
1372
  * @param {string} transactionId - Withdrawals with specific transaction ID.
@@ -1399,43 +1399,43 @@ class HollaExKit {
1399
1399
  const data = {
1400
1400
  transaction_id: transactionId
1401
1401
  };
1402
-
1402
+
1403
1403
  if (isString(opts.updatedTransactionId)) {
1404
1404
  data.updated_transaction_id = opts.updatedTransactionId;
1405
1405
  }
1406
-
1406
+
1407
1407
  if (isString(opts.updatedAddress)) {
1408
1408
  data.updated_address = opts.updatedAddress;
1409
1409
  }
1410
-
1410
+
1411
1411
  if (isBoolean(opts.status)) {
1412
1412
  data.status = opts.status;
1413
1413
  }
1414
-
1414
+
1415
1415
  if (isBoolean(opts.rejected)) {
1416
1416
  data.rejected = opts.rejected;
1417
1417
  }
1418
-
1418
+
1419
1419
  if (isBoolean(opts.dismissed)) {
1420
1420
  data.dismissed = opts.dismissed;
1421
1421
  }
1422
-
1422
+
1423
1423
  if (isBoolean(opts.processing)) {
1424
1424
  data.processing = opts.processing;
1425
1425
  }
1426
-
1426
+
1427
1427
  if (isBoolean(opts.waiting)) {
1428
1428
  data.waiting = opts.waiting;
1429
1429
  }
1430
-
1430
+
1431
1431
  if (isBoolean(opts.email)) {
1432
1432
  data.email = opts.email;
1433
1433
  }
1434
-
1434
+
1435
1435
  if (isString(opts.description)) {
1436
1436
  data.description = opts.description;
1437
1437
  }
1438
-
1438
+
1439
1439
  const headers = generateHeaders(
1440
1440
  this.headers,
1441
1441
  this.apiSecret,
@@ -1446,7 +1446,7 @@ class HollaExKit {
1446
1446
  );
1447
1447
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1448
1448
  }
1449
-
1449
+
1450
1450
  /**
1451
1451
  * Check exchange deposit status
1452
1452
  * @param {number} userId - The identifier of the user
@@ -1473,19 +1473,19 @@ class HollaExKit {
1473
1473
  if (isString(currency)) {
1474
1474
  params += `&currency=${currency}`;
1475
1475
  }
1476
-
1476
+
1477
1477
  if (isString(transactionId)) {
1478
1478
  params += `&transaction_id=${transactionId}`;
1479
1479
  }
1480
-
1480
+
1481
1481
  if (isString(address)) {
1482
1482
  params += `&address=${address}`;
1483
1483
  }
1484
-
1484
+
1485
1485
  if (isString(network)) {
1486
1486
  params += `&network=${network}`;
1487
1487
  }
1488
-
1488
+
1489
1489
  if (isBoolean(opts.isTestnet)) {
1490
1490
  params += `&is_testnet=${opts.isTestnet}`;
1491
1491
  }
@@ -1501,7 +1501,7 @@ class HollaExKit {
1501
1501
  );
1502
1502
  return createRequest(verb, `${this.apiUrl}${path}`, headers);
1503
1503
  }
1504
-
1504
+
1505
1505
  /**
1506
1506
  * Set exchange fees by admin
1507
1507
  * @param {number} opts.userId - The identifier of the user
@@ -1514,11 +1514,11 @@ class HollaExKit {
1514
1514
  ) {
1515
1515
  const verb = 'GET';
1516
1516
  let path = `${this.baseUrl}/admin/fees/settle`;
1517
-
1517
+
1518
1518
  if (isNumber(opts.userId)) {
1519
1519
  path += `?user_id=${opts.userId}`;
1520
1520
  }
1521
-
1521
+
1522
1522
  const headers = generateHeaders(
1523
1523
  this.headers,
1524
1524
  this.apiSecret,
@@ -1528,7 +1528,7 @@ class HollaExKit {
1528
1528
  );
1529
1529
  return createRequest(verb, `${this.apiUrl}${path}`, headers);
1530
1530
  }
1531
-
1531
+
1532
1532
  /**
1533
1533
  * Retrieve user's trades by admin
1534
1534
  * @param {number} opts.userId - The identifier of the user
@@ -1559,45 +1559,45 @@ class HollaExKit {
1559
1559
  const verb = 'GET';
1560
1560
  let path = `${this.baseUrl}/admin/trades`;
1561
1561
  let params = '?';
1562
-
1562
+
1563
1563
  if (isNumber(opts.userId)) {
1564
1564
  params += `&user_id=${opts.userId}`;
1565
1565
  }
1566
-
1566
+
1567
1567
  if (isNumber(opts.limit)) {
1568
1568
  params += `&limit=${opts.limit}`;
1569
1569
  }
1570
-
1570
+
1571
1571
  if (isNumber(opts.page)) {
1572
1572
  params += `&page=${opts.page}`;
1573
1573
  }
1574
-
1574
+
1575
1575
  if (isString(opts.symbol)) {
1576
1576
  params += `&symbol=${opts.symbol}`;
1577
1577
  }
1578
-
1578
+
1579
1579
  if (isString(opts.orderBy)) {
1580
1580
  params += `&order_by=${opts.orderBy}`;
1581
1581
  }
1582
-
1582
+
1583
1583
  if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
1584
1584
  params += `&order=${opts.order}`;
1585
1585
  }
1586
-
1586
+
1587
1587
  if (isDatetime(opts.startDate)) {
1588
1588
  params += `&start_date=${sanitizeDate(opts.startDate)}`;
1589
1589
  }
1590
-
1590
+
1591
1591
  if (isDatetime(opts.endDate)) {
1592
1592
  params += `&end_date=${sanitizeDate(opts.endDate)}`;
1593
1593
  }
1594
-
1594
+
1595
1595
  if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
1596
1596
  params += `&format=${opts.format}`;
1597
1597
  }
1598
1598
 
1599
1599
  if (params.length > 1) path += params;
1600
-
1600
+
1601
1601
  const headers = generateHeaders(
1602
1602
  this.headers,
1603
1603
  this.apiSecret,
@@ -1642,47 +1642,47 @@ class HollaExKit {
1642
1642
  const verb = 'GET';
1643
1643
  let path = `${this.baseUrl}/admin/orders`;
1644
1644
  let params = '?';
1645
-
1645
+
1646
1646
  if (isNumber(opts.userId)) {
1647
1647
  params += `&user_id=${opts.userId}`;
1648
1648
  }
1649
-
1649
+
1650
1650
  if (isString(opts.side) && (opts.side === 'buy' || opts.side === 'sell')) {
1651
1651
  params += `&side=${opts.side}`;
1652
1652
  }
1653
-
1653
+
1654
1654
  if (isString(opts.status)) {
1655
1655
  params += `&status=${opts.status}`;
1656
1656
  }
1657
-
1657
+
1658
1658
  if (isBoolean(opts.open)) {
1659
1659
  params += `&open=${opts.open}`;
1660
1660
  }
1661
-
1661
+
1662
1662
  if (isNumber(opts.limit)) {
1663
1663
  params += `&limit=${opts.limit}`;
1664
1664
  }
1665
-
1665
+
1666
1666
  if (isNumber(opts.page)) {
1667
1667
  params += `&page=${opts.page}`;
1668
1668
  }
1669
-
1669
+
1670
1670
  if (isString(opts.symbol)) {
1671
1671
  params += `&symbol=${opts.symbol}`;
1672
1672
  }
1673
-
1673
+
1674
1674
  if (isString(opts.orderBy)) {
1675
1675
  params += `&order_by=${opts.orderBy}`;
1676
1676
  }
1677
-
1677
+
1678
1678
  if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
1679
1679
  params += `&order=${opts.order}`;
1680
1680
  }
1681
-
1681
+
1682
1682
  if (isDatetime(opts.startDate)) {
1683
1683
  params += `&start_date=${sanitizeDate(opts.startDate)}`;
1684
1684
  }
1685
-
1685
+
1686
1686
  if (isDatetime(opts.endDate)) {
1687
1687
  params += `&end_date=${sanitizeDate(opts.endDate)}`;
1688
1688
  }
@@ -1698,7 +1698,7 @@ class HollaExKit {
1698
1698
  );
1699
1699
  return createRequest(verb, `${this.apiUrl}${path}`, headers);
1700
1700
  }
1701
-
1701
+
1702
1702
  /**
1703
1703
  * Cancel user's order by order id
1704
1704
  * @param {number} userId - The identifier of the user
@@ -1709,11 +1709,11 @@ class HollaExKit {
1709
1709
  const verb = 'DELETE';
1710
1710
  let path = `${this.baseUrl}/admin/order`;
1711
1711
  let params = '?';
1712
-
1712
+
1713
1713
  if (isString(orderId)) {
1714
1714
  params += `&order_id=${orderId}`;
1715
1715
  }
1716
-
1716
+
1717
1717
  if (isNumber(userId)) {
1718
1718
  params += `&user_id=${userId}`;
1719
1719
  }
@@ -1732,6 +1732,7 @@ class HollaExKit {
1732
1732
  /**
1733
1733
  * Retrieve list of the user info by admin
1734
1734
  * @param {object} opts - Optional parameters
1735
+ * @param {number} opts.id - The identifier of the user to filter by
1735
1736
  * @param {number} opts.userId - The identifier of the user to filter by
1736
1737
  * @param {string} opts.search - The search text to filter by, pass undefined to receive data on all fields
1737
1738
  * @param {boolean} opts.pending - The pending field to filter by, pass undefined to receive all data
@@ -1747,6 +1748,7 @@ class HollaExKit {
1747
1748
  */
1748
1749
  getExchangeUsers(
1749
1750
  opts = {
1751
+ id: null,
1750
1752
  userId: null,
1751
1753
  search: null,
1752
1754
  type: null,
@@ -1764,56 +1766,60 @@ class HollaExKit {
1764
1766
  const verb = 'GET';
1765
1767
  let path = `${this.baseUrl}/admin/users`;
1766
1768
  let params = '?';
1767
-
1769
+
1770
+ if (isNumber(opts.id)) {
1771
+ params += `&id=${opts.id}`;
1772
+ }
1773
+
1768
1774
  if (isNumber(opts.userId)) {
1769
1775
  params += `&id=${opts.userId}`;
1770
1776
  }
1771
-
1777
+
1772
1778
  if (isString(opts.search)) {
1773
1779
  params += `&search=${opts.search}`;
1774
1780
  }
1775
-
1781
+
1776
1782
  if (isString(opts.type)) {
1777
1783
  params += `&type=${opts.type}`;
1778
1784
  }
1779
-
1785
+
1780
1786
  if (isBoolean(opts.pending)) {
1781
1787
  params += `&pending=${opts.pending}`;
1782
1788
  }
1783
-
1784
- if (isString(opts.pendingType) && (opts.pendingType === 'id' ||opts.pendingType === 'bank')) {
1789
+
1790
+ if (isString(opts.pendingType) && (opts.pendingType === 'id' || opts.pendingType === 'bank')) {
1785
1791
  params += `&pending_type=${opts.pendingType}`;
1786
1792
  }
1787
-
1793
+
1788
1794
  if (isNumber(opts.limit)) {
1789
1795
  params += `&limit=${opts.limit}`;
1790
1796
  }
1791
-
1797
+
1792
1798
  if (isNumber(opts.page)) {
1793
1799
  params += `&page=${opts.page}`;
1794
1800
  }
1795
-
1801
+
1796
1802
  if (isString(opts.orderBy)) {
1797
1803
  params += `&order_by=${opts.orderBy}`;
1798
1804
  }
1799
-
1805
+
1800
1806
  if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
1801
1807
  params += `&order=${opts.order}`;
1802
1808
  }
1803
-
1809
+
1804
1810
  if (isDatetime(opts.startDate)) {
1805
1811
  params += `&start_date=${sanitizeDate(opts.startDate)}`;
1806
1812
  }
1807
-
1813
+
1808
1814
  if (isDatetime(opts.endDate)) {
1809
1815
  params += `&end_date=${sanitizeDate(opts.endDate)}`;
1810
1816
  }
1811
-
1817
+
1812
1818
  if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
1813
1819
  params += `&format=${opts.format}`;
1814
1820
  }
1815
1821
  if (params.length > 1) path += params;
1816
-
1822
+
1817
1823
  const headers = generateHeaders(
1818
1824
  this.headers,
1819
1825
  this.apiSecret,
@@ -1823,7 +1829,7 @@ class HollaExKit {
1823
1829
  );
1824
1830
  return createRequest(verb, `${this.apiUrl}${path}`, headers);
1825
1831
  }
1826
-
1832
+
1827
1833
  /**
1828
1834
  * Create exchange user
1829
1835
  * @param {string} email - The mail address for the user
@@ -1840,12 +1846,12 @@ class HollaExKit {
1840
1846
  email,
1841
1847
  password
1842
1848
  };
1843
-
1844
-
1849
+
1850
+
1845
1851
  if (isString(opts.referral)) {
1846
1852
  data.referral = opts.referral;
1847
1853
  };
1848
-
1854
+
1849
1855
  const headers = generateHeaders(
1850
1856
  this.headers,
1851
1857
  this.apiSecret,
@@ -1856,7 +1862,7 @@ class HollaExKit {
1856
1862
  );
1857
1863
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1858
1864
  }
1859
-
1865
+
1860
1866
  /**
1861
1867
  * Update exchange user
1862
1868
  * @param {number} userId - The identifier of the user to filter by
@@ -1877,11 +1883,11 @@ class HollaExKit {
1877
1883
  note: null,
1878
1884
  verification_level: null
1879
1885
  },
1880
-
1886
+
1881
1887
  ) {
1882
- if (isString(opts.role)
1888
+ if (isString(opts.role)
1883
1889
  && ['admin', 'supervisor', 'support', 'kyc', 'communicator', 'user'].includes(opts.role)) {
1884
-
1890
+
1885
1891
  const verb = 'PUT';
1886
1892
  let path = `${this.baseUrl}/admin/user/role`;
1887
1893
 
@@ -1891,7 +1897,7 @@ class HollaExKit {
1891
1897
  const data = {
1892
1898
  role: opts.role
1893
1899
  };
1894
-
1900
+
1895
1901
  const headers = generateHeaders(
1896
1902
  this.headers,
1897
1903
  this.apiSecret,
@@ -1902,20 +1908,20 @@ class HollaExKit {
1902
1908
  );
1903
1909
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1904
1910
  }
1905
-
1906
- if(isObject(opts.meta)){
1911
+
1912
+ if (isObject(opts.meta)) {
1907
1913
  const verb = 'PUT';
1908
1914
  let path = `${this.baseUrl}/admin/user/meta`;
1909
-
1915
+
1910
1916
  if (isNumber(userId)) {
1911
1917
  path += `?user_id=${userId}`;
1912
1918
  }
1913
-
1919
+
1914
1920
  const data = {
1915
1921
  meta: opts.meta,
1916
1922
  ...(isBoolean(opts.overwrite) && { overwrite: opts.overwrite }),
1917
1923
  };
1918
-
1924
+
1919
1925
  const headers = generateHeaders(
1920
1926
  this.headers,
1921
1927
  this.apiSecret,
@@ -1926,19 +1932,19 @@ class HollaExKit {
1926
1932
  );
1927
1933
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1928
1934
  }
1929
-
1930
- if(isNumber(opts.discount) && opts.discount <= 100 && opts.discount >= 0){
1935
+
1936
+ if (isNumber(opts.discount) && opts.discount <= 100 && opts.discount >= 0) {
1931
1937
  const verb = 'PUT';
1932
1938
  let path = `${this.baseUrl}/admin/user/discount`;
1933
-
1939
+
1934
1940
  if (isNumber(userId)) {
1935
1941
  path += `?user_id=${userId}`;
1936
1942
  }
1937
-
1943
+
1938
1944
  const data = {
1939
1945
  discount: opts.discount
1940
1946
  };
1941
-
1947
+
1942
1948
  const headers = generateHeaders(
1943
1949
  this.headers,
1944
1950
  this.apiSecret,
@@ -1949,19 +1955,19 @@ class HollaExKit {
1949
1955
  );
1950
1956
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1951
1957
  }
1952
-
1953
- if(isString(opts.note)){
1958
+
1959
+ if (isString(opts.note)) {
1954
1960
  const verb = 'PUT';
1955
1961
  let path = `${this.baseUrl}/admin/user/note`;
1956
-
1962
+
1957
1963
  if (isNumber(userId)) {
1958
1964
  path += `?user_id=${userId}`;
1959
1965
  }
1960
-
1966
+
1961
1967
  const data = {
1962
1968
  note: opts.note
1963
1969
  };
1964
-
1970
+
1965
1971
  const headers = generateHeaders(
1966
1972
  this.headers,
1967
1973
  this.apiSecret,
@@ -1972,16 +1978,16 @@ class HollaExKit {
1972
1978
  );
1973
1979
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1974
1980
  }
1975
-
1976
- if(isNumber(opts.verification_level)){
1981
+
1982
+ if (isNumber(opts.verification_level)) {
1977
1983
  const verb = 'POST';
1978
1984
  let path = `${this.baseUrl}/admin/upgrade-user`;
1979
-
1985
+
1980
1986
  const data = {
1981
1987
  user_id: userId,
1982
1988
  verification_level: opts.verification_level
1983
1989
  };
1984
-
1990
+
1985
1991
  const headers = generateHeaders(
1986
1992
  this.headers,
1987
1993
  this.apiSecret,
@@ -1992,7 +1998,7 @@ class HollaExKit {
1992
1998
  );
1993
1999
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
1994
2000
  }
1995
-
2001
+
1996
2002
  }
1997
2003
 
1998
2004
  /**
@@ -2006,7 +2012,7 @@ class HollaExKit {
2006
2012
  const data = {
2007
2013
  user_id
2008
2014
  };
2009
-
2015
+
2010
2016
  const headers = generateHeaders(
2011
2017
  this.headers,
2012
2018
  this.apiSecret,
@@ -2017,8 +2023,8 @@ class HollaExKit {
2017
2023
  );
2018
2024
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
2019
2025
  }
2020
-
2021
-
2026
+
2027
+
2022
2028
  /**
2023
2029
  * Create wallet for exchange user
2024
2030
  * @param {number} userId - The identifier of the user
@@ -2029,7 +2035,7 @@ class HollaExKit {
2029
2035
  createExchangeUserWallet(
2030
2036
  userId,
2031
2037
  crypto,
2032
- opts= {
2038
+ opts = {
2033
2039
  network: null
2034
2040
  }
2035
2041
  ) {
@@ -2039,11 +2045,11 @@ class HollaExKit {
2039
2045
  user_id: userId,
2040
2046
  crypto
2041
2047
  };
2042
-
2048
+
2043
2049
  if (isString(opts.network)) {
2044
2050
  data.network = opts.network;
2045
2051
  }
2046
-
2052
+
2047
2053
  const headers = generateHeaders(
2048
2054
  this.headers,
2049
2055
  this.apiSecret,
@@ -2096,11 +2102,11 @@ class HollaExKit {
2096
2102
  if (isNumber(opts.userId)) {
2097
2103
  params += `&user_id=${opts.userId}`;
2098
2104
  }
2099
-
2105
+
2100
2106
  if (isString(opts.currency)) {
2101
2107
  params += `&currency=${opts.currency}`;
2102
2108
  }
2103
-
2109
+
2104
2110
  if (isString(opts.address)) {
2105
2111
  params += `&address=${opts.address}`;
2106
2112
  }
@@ -2112,23 +2118,23 @@ class HollaExKit {
2112
2118
  if (isBoolean(opts.isValid)) {
2113
2119
  params += `&is_valid=${opts.isValid}`;
2114
2120
  }
2115
-
2121
+
2116
2122
  if (isNumber(opts.limit)) {
2117
2123
  params += `&limit=${opts.limit}`;
2118
2124
  }
2119
-
2125
+
2120
2126
  if (isNumber(opts.page)) {
2121
2127
  params += `&page=${opts.page}`;
2122
2128
  }
2123
-
2129
+
2124
2130
  if (isString(opts.orderBy)) {
2125
2131
  params += `&order_by=${opts.orderBy}`;
2126
2132
  }
2127
-
2133
+
2128
2134
  if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
2129
2135
  params += `&order=${opts.order}`;
2130
2136
  }
2131
-
2137
+
2132
2138
  if (isDatetime(opts.startDate)) {
2133
2139
  params += `&start_date=${sanitizeDate(opts.startDate)}`;
2134
2140
  }
@@ -2136,13 +2142,13 @@ class HollaExKit {
2136
2142
  if (isDatetime(opts.endDate)) {
2137
2143
  params += `&end_date=${sanitizeDate(opts.endDate)}`;
2138
2144
  }
2139
-
2145
+
2140
2146
  if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
2141
2147
  params += `&format=${opts.format}`;
2142
2148
  }
2143
2149
 
2144
2150
  if (params.length > 1) path += params;
2145
-
2151
+
2146
2152
  const headers = generateHeaders(
2147
2153
  this.headers,
2148
2154
  this.apiSecret,
@@ -2152,7 +2158,7 @@ class HollaExKit {
2152
2158
  );
2153
2159
  return createRequest(verb, `${this.apiUrl}${path}`, headers);
2154
2160
  }
2155
-
2161
+
2156
2162
  /**
2157
2163
  * Retrieve user's login info by admin
2158
2164
  * @param {number} userId - The identifier of the user
@@ -2161,7 +2167,7 @@ class HollaExKit {
2161
2167
  getExchangeUserBalance(userId) {
2162
2168
  const verb = 'GET';
2163
2169
  let path = `${this.baseUrl}/admin/user/balance?user_id=${userId}`;
2164
-
2170
+
2165
2171
  const headers = generateHeaders(
2166
2172
  this.headers,
2167
2173
  this.apiSecret,
@@ -2171,7 +2177,7 @@ class HollaExKit {
2171
2177
  );
2172
2178
  return createRequest(verb, `${this.apiUrl}${path}`, headers);
2173
2179
  }
2174
-
2180
+
2175
2181
  /**
2176
2182
  * Create bank account for user by admin
2177
2183
  * @param {number} userId - The identifier of the user
@@ -2181,15 +2187,15 @@ class HollaExKit {
2181
2187
  createExchangeUserBank(userId, bankAccount) {
2182
2188
  const verb = 'POST';
2183
2189
  let path = `${this.baseUrl}/admin/user/bank`;
2184
-
2190
+
2185
2191
  if (isNumber(userId)) {
2186
2192
  path += `?id=${userId}`;
2187
2193
  }
2188
-
2194
+
2189
2195
  const data = {
2190
2196
  bank_account: bankAccount
2191
2197
  };
2192
-
2198
+
2193
2199
  const headers = generateHeaders(
2194
2200
  this.headers,
2195
2201
  this.apiSecret,
@@ -2199,9 +2205,9 @@ class HollaExKit {
2199
2205
  data
2200
2206
  );
2201
2207
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
2202
-
2208
+
2203
2209
  }
2204
-
2210
+
2205
2211
  /**
2206
2212
  * Retrieve user's login info by admin
2207
2213
  * @param {number} opts.userId - The identifier of the user
@@ -2228,39 +2234,39 @@ class HollaExKit {
2228
2234
  const verb = 'GET';
2229
2235
  let path = `${this.baseUrl}/admin/logins`;
2230
2236
  let params = '?';
2231
-
2237
+
2232
2238
  if (isNumber(opts.userId)) {
2233
2239
  params += `&user_id=${opts.userId}`;
2234
2240
  }
2235
-
2241
+
2236
2242
  if (isNumber(opts.limit)) {
2237
2243
  params += `&limit=${opts.limit}`;
2238
2244
  }
2239
-
2245
+
2240
2246
  if (isNumber(opts.page)) {
2241
2247
  params += `&page=${opts.page}`;
2242
2248
  }
2243
-
2249
+
2244
2250
  if (isString(opts.orderBy)) {
2245
2251
  params += `&order_by=${opts.orderBy}`;
2246
2252
  }
2247
-
2253
+
2248
2254
  if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
2249
2255
  params += `&order=${opts.order}`;
2250
2256
  }
2251
-
2257
+
2252
2258
  if (isDatetime(opts.startDate)) {
2253
2259
  params += `&start_date=${sanitizeDate(opts.startDate)}`;
2254
2260
  }
2255
-
2261
+
2256
2262
  if (isDatetime(opts.endDate)) {
2257
2263
  params += `&end_date=${sanitizeDate(opts.endDate)}`;
2258
2264
  }
2259
-
2265
+
2260
2266
  if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
2261
2267
  params += `&format=${opts.format}`;
2262
2268
  }
2263
-
2269
+
2264
2270
  if (params.length > 1) path += params;
2265
2271
 
2266
2272
  const headers = generateHeaders(
@@ -2272,7 +2278,7 @@ class HollaExKit {
2272
2278
  );
2273
2279
  return createRequest(verb, `${this.apiUrl}${path}`, headers);
2274
2280
  }
2275
-
2281
+
2276
2282
  /**
2277
2283
  * Deactivate exchange user account by admin
2278
2284
  * @param {number} userId - The identifier of the user to deactivate their exchange account
@@ -2285,7 +2291,7 @@ class HollaExKit {
2285
2291
  user_id: userId,
2286
2292
  activated: false
2287
2293
  };
2288
-
2294
+
2289
2295
  const headers = generateHeaders(
2290
2296
  this.headers,
2291
2297
  this.apiSecret,
@@ -2296,7 +2302,7 @@ class HollaExKit {
2296
2302
  );
2297
2303
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
2298
2304
  }
2299
-
2305
+
2300
2306
  /**
2301
2307
  * Deactivate user otp by admin
2302
2308
  * @param {number} userId - The identifier of the user to deactivate their otp
@@ -2308,7 +2314,7 @@ class HollaExKit {
2308
2314
  const data = {
2309
2315
  user_id: userId
2310
2316
  };
2311
-
2317
+
2312
2318
  const headers = generateHeaders(
2313
2319
  this.headers,
2314
2320
  this.apiSecret,
@@ -2319,7 +2325,7 @@ class HollaExKit {
2319
2325
  );
2320
2326
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
2321
2327
  }
2322
-
2328
+
2323
2329
  /**
2324
2330
  * Retrieve user's referrals info by admin
2325
2331
  * @param {number} userId - The identifier of the user to filter by
@@ -2345,38 +2351,38 @@ class HollaExKit {
2345
2351
  const verb = 'GET';
2346
2352
  let path = `${this.baseUrl}/admin/user/affiliation`;
2347
2353
  let params = '?';
2348
-
2354
+
2349
2355
  if (isNumber(userId)) {
2350
2356
  params += `&user_id=${userId}`;
2351
2357
  }
2352
-
2358
+
2353
2359
  if (isNumber(opts.limit)) {
2354
2360
  params += `&limit=${opts.limit}`;
2355
2361
  }
2356
-
2362
+
2357
2363
  if (isNumber(opts.page)) {
2358
2364
  params += `&page=${opts.page}`;
2359
2365
  }
2360
-
2366
+
2361
2367
  if (isString(opts.orderBy)) {
2362
2368
  params += `&order_by=${opts.orderBy}`;
2363
2369
  }
2364
-
2370
+
2365
2371
  if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
2366
2372
  params += `&order=${opts.order}`;
2367
2373
  }
2368
-
2374
+
2369
2375
  if (isDatetime(opts.startDate)) {
2370
2376
  params += `&start_date=${sanitizeDate(opts.startDate)}`;
2371
2377
  }
2372
-
2378
+
2373
2379
  if (isDatetime(opts.endDate)) {
2374
2380
  params += `&end_date=${sanitizeDate(opts.endDate)}`;
2375
2381
  }
2376
2382
 
2377
2383
  if (params.length > 1) path += params;
2378
-
2379
-
2384
+
2385
+
2380
2386
  const headers = generateHeaders(
2381
2387
  this.headers,
2382
2388
  this.apiSecret,
@@ -2420,7 +2426,7 @@ class HollaExKit {
2420
2426
  mail_type: mailType,
2421
2427
  data: content
2422
2428
  };
2423
-
2429
+
2424
2430
  const headers = generateHeaders(
2425
2431
  this.headers,
2426
2432
  this.apiSecret,
@@ -2451,14 +2457,14 @@ class HollaExKit {
2451
2457
  html,
2452
2458
  };
2453
2459
 
2454
- if(isString(opts.title)) {
2460
+ if (isString(opts.title)) {
2455
2461
  data.title = opts.title;
2456
2462
  }
2457
-
2458
- if(isString(opts.text)) {
2463
+
2464
+ if (isString(opts.text)) {
2459
2465
  data.text = opts.text;
2460
2466
  }
2461
-
2467
+
2462
2468
  const headers = generateHeaders(
2463
2469
  this.headers,
2464
2470
  this.apiSecret,
@@ -2469,7 +2475,7 @@ class HollaExKit {
2469
2475
  );
2470
2476
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
2471
2477
  }
2472
-
2478
+
2473
2479
  /**
2474
2480
  * Retrieve user's balances by admin
2475
2481
  * @param {number} opts.userId - The identifier of the user to filter by
@@ -2486,20 +2492,20 @@ class HollaExKit {
2486
2492
  ) {
2487
2493
  const verb = 'GET';
2488
2494
  let path = `${this.baseUrl}/admin/balances?`;
2489
-
2490
-
2495
+
2496
+
2491
2497
  if (isNumber(opts.userId)) {
2492
2498
  path += `&user_id=${opts.userId}`;
2493
2499
  }
2494
-
2500
+
2495
2501
  if (isString(opts.currency)) {
2496
2502
  path += `&currency=${opts.currency}`;
2497
2503
  }
2498
-
2504
+
2499
2505
  if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
2500
2506
  path += `&format=${opts.format}`;
2501
2507
  }
2502
-
2508
+
2503
2509
  const headers = generateHeaders(
2504
2510
  this.headers,
2505
2511
  this.apiSecret,
@@ -2538,7 +2544,7 @@ class HollaExKit {
2538
2544
  price,
2539
2545
  symbol
2540
2546
  };
2541
-
2547
+
2542
2548
  const headers = generateHeaders(
2543
2549
  this.headers,
2544
2550
  this.apiSecret,
@@ -2549,7 +2555,7 @@ class HollaExKit {
2549
2555
  );
2550
2556
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
2551
2557
  }
2552
-
2558
+
2553
2559
  /**
2554
2560
  * Create trade on behalf of users
2555
2561
  * @param {number} maker_id - User id for the maker
@@ -2584,7 +2590,7 @@ class HollaExKit {
2584
2590
  price,
2585
2591
  side,
2586
2592
  };
2587
-
2593
+
2588
2594
  const headers = generateHeaders(
2589
2595
  this.headers,
2590
2596
  this.apiSecret,
@@ -2621,8 +2627,8 @@ class HollaExKit {
2621
2627
  amount,
2622
2628
  currency
2623
2629
  };
2624
-
2625
- if(isString(opts.network)) {
2630
+
2631
+ if (isString(opts.network)) {
2626
2632
  data.network = opts.network;
2627
2633
  }
2628
2634
 
@@ -2637,6 +2643,431 @@ class HollaExKit {
2637
2643
  return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
2638
2644
  }
2639
2645
 
2646
+
2647
+ /**
2648
+ * Get exchange stakes for admin
2649
+ * @param {object} opts - Optional parameters
2650
+ * @param {number} opts.limit - Number of elements to return. Default: 50. Maximum: 100
2651
+ * @param {number} opts.page - Page of data to retrieve
2652
+ * @param {string} opts.order_by - Field to order data
2653
+ * @param {string} opts.order - Direction to order (asc/desc)
2654
+ * @param {string} opts.start_date - Starting date of queried data in ISO8601 format
2655
+ * @param {string} opts.end_date - Ending date of queried data in ISO8601 format
2656
+ * @param {string} opts.format - Specify data format (csv/all)
2657
+ * @return {object} A JSON object with stakes data
2658
+ */
2659
+ getExchangeStakesByAdmin(
2660
+ opts = {
2661
+ limit: null,
2662
+ page: null,
2663
+ order_by: null,
2664
+ order: null,
2665
+ start_date: null,
2666
+ end_date: null,
2667
+ format: null
2668
+ }
2669
+ ) {
2670
+ const verb = 'GET';
2671
+ let path = `${this.baseUrl}/admin/stakes`;
2672
+ let params = '?';
2673
+
2674
+ if (isNumber(opts.limit)) {
2675
+ params += `&limit=${opts.limit}`;
2676
+ }
2677
+
2678
+ if (isNumber(opts.page)) {
2679
+ params += `&page=${opts.page}`;
2680
+ }
2681
+
2682
+ if (isString(opts.order_by)) {
2683
+ params += `&order_by=${opts.order_by}`;
2684
+ }
2685
+
2686
+ if (isString(opts.order)) {
2687
+ params += `&order=${opts.order}`;
2688
+ }
2689
+
2690
+ if (isDatetime(opts.start_date)) {
2691
+ params += `&start_date=${sanitizeDate(opts.start_date)}`;
2692
+ }
2693
+
2694
+ if (isDatetime(opts.end_date)) {
2695
+ params += `&end_date=${sanitizeDate(opts.end_date)}`;
2696
+ }
2697
+
2698
+ if (isString(opts.format)) {
2699
+ params += `&format=${opts.format}`;
2700
+ }
2701
+
2702
+ if (params.length > 1) path += params;
2703
+ const headers = generateHeaders(
2704
+ this.headers,
2705
+ this.apiSecret,
2706
+ verb,
2707
+ path,
2708
+ this.apiExpiresAfter
2709
+ );
2710
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
2711
+ }
2712
+
2713
+ /**
2714
+ * Create exchange stakes for admin
2715
+ * @param {string} name - Name of the stake pool
2716
+ * @param {number} user_id - User ID associated with the stake pool
2717
+ * @param {string} currency - Currency of the stake pool
2718
+ * @param {number} account_id - Account ID
2719
+ * @param {number} apy - Annual Percentage Yield
2720
+ * @param {number} min_amount - Minimum stake amount
2721
+ * @param {number} max_amount - Maximum stake amount
2722
+ * @param {boolean} early_unstake - Whether early unstake is allowed
2723
+ * @param {string} status - Pool status (uninitialized/active/paused/terminated)
2724
+ * @param {object} opts - Optional parameters
2725
+ * @param {number} opts.id - ID for existing stake pool (update only)
2726
+ * @param {string} opts.reward_currency - Currency for rewards
2727
+ * @param {number} opts.duration - Duration in days
2728
+ * @param {boolean} opts.slashing - Whether slashing is enabled
2729
+ * @param {number} opts.slashing_earning_percentage - Slashing percentage for earnings
2730
+ * @param {number} opts.slashing_principle_percentage - Slashing percentage for principle
2731
+ * @param {boolean} opts.onboarding - Whether pool is for onboarding
2732
+ * @param {string} opts.disclaimer - Disclaimer text
2733
+ * @return {object} A JSON object with the created stake
2734
+ */
2735
+ createExchangeStakesByAdmin(
2736
+ name,
2737
+ user_id,
2738
+ currency,
2739
+ account_id,
2740
+ apy,
2741
+ min_amount,
2742
+ max_amount,
2743
+ early_unstake,
2744
+ status,
2745
+ opts = {
2746
+ reward_currency: null,
2747
+ duration: null,
2748
+ slashing: null,
2749
+ slashing_earning_percentage: null,
2750
+ slashing_principle_percentage: null,
2751
+ onboarding: null,
2752
+ disclaimer: null
2753
+ }
2754
+ ) {
2755
+ const verb = 'POST';
2756
+ const path = `${this.baseUrl}/admin/stake`;
2757
+ const data = {
2758
+ name,
2759
+ user_id,
2760
+ currency,
2761
+ account_id,
2762
+ apy,
2763
+ min_amount,
2764
+ max_amount,
2765
+ early_unstake,
2766
+ status
2767
+ };
2768
+
2769
+ if (isString(opts.reward_currency)) {
2770
+ data.reward_currency = opts.reward_currency;
2771
+ }
2772
+
2773
+ if (isNumber(opts.duration)) {
2774
+ data.duration = opts.duration;
2775
+ }
2776
+
2777
+ if (isBoolean(opts.slashing)) {
2778
+ data.slashing = opts.slashing;
2779
+ }
2780
+
2781
+ if (isNumber(opts.slashing_earning_percentage)) {
2782
+ data.slashing_earning_percentage = opts.slashing_earning_percentage;
2783
+ }
2784
+
2785
+ if (isNumber(opts.slashing_principle_percentage)) {
2786
+ data.slashing_principle_percentage = opts.slashing_principle_percentage;
2787
+ }
2788
+
2789
+ if (isBoolean(opts.onboarding)) {
2790
+ data.onboarding = opts.onboarding;
2791
+ }
2792
+
2793
+ if (isString(opts.disclaimer)) {
2794
+ data.disclaimer = opts.disclaimer;
2795
+ }
2796
+
2797
+ const headers = generateHeaders(
2798
+ this.headers,
2799
+ this.apiSecret,
2800
+ verb,
2801
+ path,
2802
+ this.apiExpiresAfter,
2803
+ data
2804
+ );
2805
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
2806
+ }
2807
+
2808
+ /**
2809
+ * Update exchange stakes for admin
2810
+ * @param {number} id - ID of the stake pool to update
2811
+ * @param {object} opts - Optional parameters
2812
+ * @param {string} opts.name - Name of the stake pool
2813
+ * @param {number} opts.user_id - User ID associated with the stake pool
2814
+ * @param {string} opts.currency - Currency of the stake pool
2815
+ * @param {string} opts.reward_currency - Currency for rewards
2816
+ * @param {number} opts.account_id - Account ID
2817
+ * @param {number} opts.apy - Annual Percentage Yield
2818
+ * @param {number} opts.duration - Duration in days
2819
+ * @param {boolean} opts.slashing - Whether slashing is enabled
2820
+ * @param {number} opts.slashing_earning_percentage - Slashing percentage for earnings
2821
+ * @param {number} opts.slashing_principle_percentage - Slashing percentage for principle
2822
+ * @param {boolean} opts.early_unstake - Whether early unstake is allowed
2823
+ * @param {number} opts.min_amount - Minimum stake amount
2824
+ * @param {number} opts.max_amount - Maximum stake amount
2825
+ * @param {string} opts.status - Pool status (uninitialized/active/paused/terminated)
2826
+ * @param {boolean} opts.onboarding - Whether pool is for onboarding
2827
+ * @param {string} opts.disclaimer - Disclaimer text
2828
+ * @return {object} A JSON object with the updated stake
2829
+ */
2830
+ updateExchangeStakesByAdmin(
2831
+ id,
2832
+ opts = {
2833
+ name: null,
2834
+ user_id: null,
2835
+ currency: null,
2836
+ reward_currency: null,
2837
+ account_id: null,
2838
+ apy: null,
2839
+ duration: null,
2840
+ slashing: null,
2841
+ slashing_earning_percentage: null,
2842
+ slashing_principle_percentage: null,
2843
+ early_unstake: null,
2844
+ min_amount: null,
2845
+ max_amount: null,
2846
+ status: null,
2847
+ onboarding: null,
2848
+ disclaimer: null
2849
+ }
2850
+ ) {
2851
+ const verb = 'PUT';
2852
+ const path = `${this.baseUrl}/admin/stake`;
2853
+ const data = { id };
2854
+
2855
+ // Optional parameters
2856
+ if (isString(opts.name)) {
2857
+ data.name = opts.name;
2858
+ }
2859
+
2860
+ if (isNumber(opts.user_id)) {
2861
+ data.user_id = opts.user_id;
2862
+ }
2863
+
2864
+ if (isString(opts.currency)) {
2865
+ data.currency = opts.currency;
2866
+ }
2867
+
2868
+ if (isString(opts.reward_currency)) {
2869
+ data.reward_currency = opts.reward_currency;
2870
+ }
2871
+
2872
+ if (isNumber(opts.account_id)) {
2873
+ data.account_id = opts.account_id;
2874
+ }
2875
+
2876
+ if (isNumber(opts.apy)) {
2877
+ data.apy = opts.apy;
2878
+ }
2879
+
2880
+ if (isNumber(opts.duration)) {
2881
+ data.duration = opts.duration;
2882
+ }
2883
+
2884
+ if (isBoolean(opts.slashing)) {
2885
+ data.slashing = opts.slashing;
2886
+ }
2887
+
2888
+ if (isNumber(opts.slashing_earning_percentage)) {
2889
+ data.slashing_earning_percentage = opts.slashing_earning_percentage;
2890
+ }
2891
+
2892
+ if (isNumber(opts.slashing_principle_percentage)) {
2893
+ data.slashing_principle_percentage = opts.slashing_principle_percentage;
2894
+ }
2895
+
2896
+ if (isBoolean(opts.early_unstake)) {
2897
+ data.early_unstake = opts.early_unstake;
2898
+ }
2899
+
2900
+ if (isNumber(opts.min_amount)) {
2901
+ data.min_amount = opts.min_amount;
2902
+ }
2903
+
2904
+ if (isNumber(opts.max_amount)) {
2905
+ data.max_amount = opts.max_amount;
2906
+ }
2907
+
2908
+ if (isString(opts.status) && ['uninitialized', 'active', 'paused', 'terminated'].includes(opts.status)) {
2909
+ data.status = opts.status;
2910
+ }
2911
+
2912
+ if (isBoolean(opts.onboarding)) {
2913
+ data.onboarding = opts.onboarding;
2914
+ }
2915
+
2916
+ if (isString(opts.disclaimer)) {
2917
+ data.disclaimer = opts.disclaimer;
2918
+ }
2919
+
2920
+ const headers = generateHeaders(
2921
+ this.headers,
2922
+ this.apiSecret,
2923
+ verb,
2924
+ path,
2925
+ this.apiExpiresAfter,
2926
+ data
2927
+ );
2928
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
2929
+ }
2930
+
2931
+ /**
2932
+ * Delete exchange stakes for admin
2933
+ * @param {object} data - ID object containing stake ID to delete
2934
+ * @return {object} A JSON object with deletion result
2935
+ */
2936
+ deleteExchangeStakesByAdmin(id) {
2937
+ const verb = 'DELETE';
2938
+ const path = `${this.baseUrl}/admin/stake`;
2939
+ const data = { id };
2940
+
2941
+ const headers = generateHeaders(
2942
+ this.headers,
2943
+ this.apiSecret,
2944
+ verb,
2945
+ path,
2946
+ this.apiExpiresAfter,
2947
+ data
2948
+ );
2949
+ return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
2950
+ }
2951
+
2952
+ /**
2953
+ * Get exchange stakers of users for admin
2954
+ * @param {object} opts - Optional parameters
2955
+ * @param {number} opts.id - Unique identifier for the staker entry
2956
+ * @param {number} opts.user_id - The ID of the user who has locked funds and staked
2957
+ * @param {number} opts.stake_id - The ID of the stake pool
2958
+ * @param {string} opts.currency - The currency in which the user staked
2959
+ * @param {number} opts.reward - The amount the user has received as rewards
2960
+ * @param {number} opts.slashed - The amount slashed
2961
+ * @param {number} opts.limit - Number of elements to return. Default: 50. Maximum: 100
2962
+ * @param {number} opts.page - Page of data to retrieve
2963
+ * @param {string} opts.order_by - Field to order data
2964
+ * @param {string} opts.order - Direction to order (asc/desc)
2965
+ * @param {string} opts.start_date - Starting date of queried data in ISO8601 format
2966
+ * @param {string} opts.end_date - Ending date of queried data in ISO8601 format
2967
+ * @param {string} opts.format - Specify data format (csv/all)
2968
+ * @return {object} A JSON object with stakers data
2969
+ */
2970
+ getExchangeStakersByAdmin(
2971
+ opts = {
2972
+ id: null,
2973
+ user_id: null,
2974
+ stake_id: null,
2975
+ currency: null,
2976
+ reward: null,
2977
+ slashed: null,
2978
+ limit: null,
2979
+ page: null,
2980
+ order_by: null,
2981
+ order: null,
2982
+ start_date: null,
2983
+ end_date: null,
2984
+ format: null
2985
+ }
2986
+ ) {
2987
+ const verb = 'GET';
2988
+ let path = `${this.baseUrl}/admin/stakers`;
2989
+ let params = '?';
2990
+
2991
+ if (isNumber(opts.id)) {
2992
+ params += `&id=${opts.id}`;
2993
+ }
2994
+
2995
+ if (isNumber(opts.user_id)) {
2996
+ params += `&user_id=${opts.user_id}`;
2997
+ }
2998
+
2999
+ if (isNumber(opts.stake_id)) {
3000
+ params += `&stake_id=${opts.stake_id}`;
3001
+ }
3002
+
3003
+ if (isString(opts.currency)) {
3004
+ params += `&currency=${opts.currency}`;
3005
+ }
3006
+
3007
+ if (isNumber(opts.reward)) {
3008
+ params += `&reward=${opts.reward}`;
3009
+ }
3010
+
3011
+ if (isNumber(opts.slashed)) {
3012
+ params += `&slashed=${opts.slashed}`;
3013
+ }
3014
+
3015
+ if (isNumber(opts.limit)) {
3016
+ params += `&limit=${opts.limit}`;
3017
+ }
3018
+
3019
+ if (isNumber(opts.page)) {
3020
+ params += `&page=${opts.page}`;
3021
+ }
3022
+
3023
+ if (isString(opts.order_by)) {
3024
+ params += `&order_by=${opts.order_by}`;
3025
+ }
3026
+
3027
+ if (isString(opts.order)) {
3028
+ params += `&order=${opts.order}`;
3029
+ }
3030
+
3031
+ if (isDatetime(opts.start_date)) {
3032
+ params += `&start_date=${sanitizeDate(opts.start_date)}`;
3033
+ }
3034
+
3035
+ if (isDatetime(opts.end_date)) {
3036
+ params += `&end_date=${sanitizeDate(opts.end_date)}`;
3037
+ }
3038
+
3039
+ if (isString(opts.format)) {
3040
+ params += `&format=${opts.format}`;
3041
+ }
3042
+
3043
+ if (params.length > 1) path += params;
3044
+ const headers = generateHeaders(
3045
+ this.headers,
3046
+ this.apiSecret,
3047
+ verb,
3048
+ path,
3049
+ this.apiExpiresAfter
3050
+ );
3051
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
3052
+ }
3053
+
3054
+ /**
3055
+ * Get staking and unstaking amounts
3056
+ * @return {object} A JSON object with stake analytics data
3057
+ */
3058
+ getStakeAnalyticsByAdmin() {
3059
+ const verb = 'GET';
3060
+ const path = `${this.baseUrl}/admin/stake/analytics`;
3061
+
3062
+ const headers = generateHeaders(
3063
+ this.headers,
3064
+ this.apiSecret,
3065
+ verb,
3066
+ path,
3067
+ this.apiExpiresAfter
3068
+ );
3069
+ return createRequest(verb, `${this.apiUrl}${path}`, headers);
3070
+ }
2640
3071
  /**
2641
3072
  * Connect to hollaEx websocket and listen to an event
2642
3073
  * @param {array} events - The events to listen to
@@ -2654,9 +3085,8 @@ class HollaExKit {
2654
3085
  '/stream',
2655
3086
  apiExpires
2656
3087
  );
2657
- url = `${url}?api-key=${
2658
- this.apiKey
2659
- }&api-signature=${signature}&api-expires=${apiExpires}`;
3088
+ url = `${url}?api-key=${this.apiKey
3089
+ }&api-signature=${signature}&api-expires=${apiExpires}`;
2660
3090
  }
2661
3091
 
2662
3092
  this.ws = new WebSocket(url);
@@ -2748,21 +3178,41 @@ class HollaExKit {
2748
3178
  if (!this.wsEvents.includes(event) || this.initialConnection) {
2749
3179
  const [topic, symbol] = event.split(':');
2750
3180
  switch (topic) {
2751
- case 'orderbook':
2752
- case 'trade':
2753
- if (symbol) {
2754
- if (!this.wsEvents.includes(topic)) {
3181
+ case 'orderbook':
3182
+ case 'trade':
3183
+ if (symbol) {
3184
+ if (!this.wsEvents.includes(topic)) {
3185
+ this.ws.send(
3186
+ JSON.stringify({
3187
+ op: 'subscribe',
3188
+ args: [`${topic}:${symbol}`]
3189
+ })
3190
+ );
3191
+ if (!this.initialConnection) {
3192
+ this.wsEvents = union(this.wsEvents, [event]);
3193
+ }
3194
+ }
3195
+ } else {
2755
3196
  this.ws.send(
2756
3197
  JSON.stringify({
2757
3198
  op: 'subscribe',
2758
- args: [`${topic}:${symbol}`]
3199
+ args: [topic]
2759
3200
  })
2760
3201
  );
2761
3202
  if (!this.initialConnection) {
3203
+ this.wsEvents = this.wsEvents.filter(
3204
+ (e) => !e.includes(`${topic}:`)
3205
+ );
2762
3206
  this.wsEvents = union(this.wsEvents, [event]);
2763
3207
  }
2764
3208
  }
2765
- } else {
3209
+ break;
3210
+ case 'order':
3211
+ case 'usertrade':
3212
+ case 'wallet':
3213
+ case 'deposit':
3214
+ case 'withdrawal':
3215
+ case 'admin':
2766
3216
  this.ws.send(
2767
3217
  JSON.stringify({
2768
3218
  op: 'subscribe',
@@ -2770,31 +3220,11 @@ class HollaExKit {
2770
3220
  })
2771
3221
  );
2772
3222
  if (!this.initialConnection) {
2773
- this.wsEvents = this.wsEvents.filter(
2774
- (e) => !e.includes(`${topic}:`)
2775
- );
2776
3223
  this.wsEvents = union(this.wsEvents, [event]);
2777
3224
  }
2778
- }
2779
- break;
2780
- case 'order':
2781
- case 'usertrade':
2782
- case 'wallet':
2783
- case 'deposit':
2784
- case 'withdrawal':
2785
- case 'admin':
2786
- this.ws.send(
2787
- JSON.stringify({
2788
- op: 'subscribe',
2789
- args: [topic]
2790
- })
2791
- );
2792
- if (!this.initialConnection) {
2793
- this.wsEvents = union(this.wsEvents, [event]);
2794
- }
2795
- break;
2796
- default:
2797
- break;
3225
+ break;
3226
+ default:
3227
+ break;
2798
3228
  }
2799
3229
  }
2800
3230
  });
@@ -2813,40 +3243,40 @@ class HollaExKit {
2813
3243
  if (this.wsEvents.includes(event)) {
2814
3244
  const [topic, symbol] = event.split(':');
2815
3245
  switch (topic) {
2816
- case 'orderbook':
2817
- case 'trade':
2818
- if (symbol) {
2819
- this.ws.send(
2820
- JSON.stringify({
2821
- op: 'unsubscribe',
2822
- args: [`${topic}:${symbol}`]
2823
- })
2824
- );
2825
- } else {
3246
+ case 'orderbook':
3247
+ case 'trade':
3248
+ if (symbol) {
3249
+ this.ws.send(
3250
+ JSON.stringify({
3251
+ op: 'unsubscribe',
3252
+ args: [`${topic}:${symbol}`]
3253
+ })
3254
+ );
3255
+ } else {
3256
+ this.ws.send(
3257
+ JSON.stringify({
3258
+ op: 'unsubscribe',
3259
+ args: [topic]
3260
+ })
3261
+ );
3262
+ }
3263
+ this.wsEvents = this.wsEvents.filter((e) => e !== event);
3264
+ break;
3265
+ case 'order':
3266
+ case 'wallet':
3267
+ case 'deposit':
3268
+ case 'withdrawal':
3269
+ case 'admin':
2826
3270
  this.ws.send(
2827
3271
  JSON.stringify({
2828
3272
  op: 'unsubscribe',
2829
3273
  args: [topic]
2830
3274
  })
2831
3275
  );
2832
- }
2833
- this.wsEvents = this.wsEvents.filter((e) => e !== event);
2834
- break;
2835
- case 'order':
2836
- case 'wallet':
2837
- case 'deposit':
2838
- case 'withdrawal':
2839
- case 'admin':
2840
- this.ws.send(
2841
- JSON.stringify({
2842
- op: 'unsubscribe',
2843
- args: [topic]
2844
- })
2845
- );
2846
- this.wsEvents = this.wsEvents.filter((e) => e !== event);
2847
- break;
2848
- default:
2849
- break;
3276
+ this.wsEvents = this.wsEvents.filter((e) => e !== event);
3277
+ break;
3278
+ default:
3279
+ break;
2850
3280
  }
2851
3281
  }
2852
3282
  });
@@ -2856,4 +3286,4 @@ class HollaExKit {
2856
3286
  }
2857
3287
  }
2858
3288
 
2859
- module.exports = HollaExKit;
3289
+ module.exports = HollaExKit;