hollaex-node-lib 2.18.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.
- package/README.md +12 -3
- package/kit.js +900 -311
- package/package.json +1 -1
package/kit.js
CHANGED
|
@@ -208,7 +208,7 @@ class HollaExKit {
|
|
|
208
208
|
) {
|
|
209
209
|
const verb = 'GET';
|
|
210
210
|
let path = `${this.baseUrl}/user/deposits`;
|
|
211
|
-
let params = '?'
|
|
211
|
+
let params = '?';
|
|
212
212
|
|
|
213
213
|
if (isString(opts.currency)) {
|
|
214
214
|
params += `¤cy=${opts.currency}`;
|
|
@@ -318,7 +318,7 @@ class HollaExKit {
|
|
|
318
318
|
) {
|
|
319
319
|
const verb = 'GET';
|
|
320
320
|
let path = `${this.baseUrl}/user/withdrawals`;
|
|
321
|
-
let params = '?'
|
|
321
|
+
let params = '?';
|
|
322
322
|
|
|
323
323
|
if (isString(opts.currency)) {
|
|
324
324
|
params += `¤cy=${opts.currency}`;
|
|
@@ -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 += `"e=${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 += `"e=${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 += `¤cy=${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,21 +1829,29 @@ 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
|
|
1830
1836
|
* @param {string} password - The password for the user
|
|
1837
|
+
* @param {string} opts.referral - The referral code for the user
|
|
1831
1838
|
* @return {object} A JSON object with message
|
|
1832
1839
|
*/
|
|
1833
|
-
createExchangeUser(email, password
|
|
1840
|
+
createExchangeUser(email, password, opts = {
|
|
1841
|
+
referral: null
|
|
1842
|
+
}) {
|
|
1834
1843
|
const verb = 'POST';
|
|
1835
1844
|
let path = `${this.baseUrl}/admin/user`;
|
|
1836
1845
|
const data = {
|
|
1837
1846
|
email,
|
|
1838
1847
|
password
|
|
1839
1848
|
};
|
|
1840
|
-
|
|
1849
|
+
|
|
1850
|
+
|
|
1851
|
+
if (isString(opts.referral)) {
|
|
1852
|
+
data.referral = opts.referral;
|
|
1853
|
+
};
|
|
1854
|
+
|
|
1841
1855
|
const headers = generateHeaders(
|
|
1842
1856
|
this.headers,
|
|
1843
1857
|
this.apiSecret,
|
|
@@ -1848,7 +1862,7 @@ class HollaExKit {
|
|
|
1848
1862
|
);
|
|
1849
1863
|
return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
|
|
1850
1864
|
}
|
|
1851
|
-
|
|
1865
|
+
|
|
1852
1866
|
/**
|
|
1853
1867
|
* Update exchange user
|
|
1854
1868
|
* @param {number} userId - The identifier of the user to filter by
|
|
@@ -1869,11 +1883,11 @@ class HollaExKit {
|
|
|
1869
1883
|
note: null,
|
|
1870
1884
|
verification_level: null
|
|
1871
1885
|
},
|
|
1872
|
-
|
|
1886
|
+
|
|
1873
1887
|
) {
|
|
1874
|
-
if (isString(opts.role)
|
|
1888
|
+
if (isString(opts.role)
|
|
1875
1889
|
&& ['admin', 'supervisor', 'support', 'kyc', 'communicator', 'user'].includes(opts.role)) {
|
|
1876
|
-
|
|
1890
|
+
|
|
1877
1891
|
const verb = 'PUT';
|
|
1878
1892
|
let path = `${this.baseUrl}/admin/user/role`;
|
|
1879
1893
|
|
|
@@ -1883,7 +1897,7 @@ class HollaExKit {
|
|
|
1883
1897
|
const data = {
|
|
1884
1898
|
role: opts.role
|
|
1885
1899
|
};
|
|
1886
|
-
|
|
1900
|
+
|
|
1887
1901
|
const headers = generateHeaders(
|
|
1888
1902
|
this.headers,
|
|
1889
1903
|
this.apiSecret,
|
|
@@ -1894,20 +1908,20 @@ class HollaExKit {
|
|
|
1894
1908
|
);
|
|
1895
1909
|
return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
|
|
1896
1910
|
}
|
|
1897
|
-
|
|
1898
|
-
if(isObject(opts.meta)){
|
|
1911
|
+
|
|
1912
|
+
if (isObject(opts.meta)) {
|
|
1899
1913
|
const verb = 'PUT';
|
|
1900
1914
|
let path = `${this.baseUrl}/admin/user/meta`;
|
|
1901
|
-
|
|
1915
|
+
|
|
1902
1916
|
if (isNumber(userId)) {
|
|
1903
1917
|
path += `?user_id=${userId}`;
|
|
1904
1918
|
}
|
|
1905
|
-
|
|
1919
|
+
|
|
1906
1920
|
const data = {
|
|
1907
1921
|
meta: opts.meta,
|
|
1908
1922
|
...(isBoolean(opts.overwrite) && { overwrite: opts.overwrite }),
|
|
1909
1923
|
};
|
|
1910
|
-
|
|
1924
|
+
|
|
1911
1925
|
const headers = generateHeaders(
|
|
1912
1926
|
this.headers,
|
|
1913
1927
|
this.apiSecret,
|
|
@@ -1918,19 +1932,19 @@ class HollaExKit {
|
|
|
1918
1932
|
);
|
|
1919
1933
|
return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
|
|
1920
1934
|
}
|
|
1921
|
-
|
|
1922
|
-
if(isNumber(opts.discount) && opts.discount <= 100 && opts.discount >= 0){
|
|
1935
|
+
|
|
1936
|
+
if (isNumber(opts.discount) && opts.discount <= 100 && opts.discount >= 0) {
|
|
1923
1937
|
const verb = 'PUT';
|
|
1924
1938
|
let path = `${this.baseUrl}/admin/user/discount`;
|
|
1925
|
-
|
|
1939
|
+
|
|
1926
1940
|
if (isNumber(userId)) {
|
|
1927
1941
|
path += `?user_id=${userId}`;
|
|
1928
1942
|
}
|
|
1929
|
-
|
|
1943
|
+
|
|
1930
1944
|
const data = {
|
|
1931
1945
|
discount: opts.discount
|
|
1932
1946
|
};
|
|
1933
|
-
|
|
1947
|
+
|
|
1934
1948
|
const headers = generateHeaders(
|
|
1935
1949
|
this.headers,
|
|
1936
1950
|
this.apiSecret,
|
|
@@ -1941,19 +1955,19 @@ class HollaExKit {
|
|
|
1941
1955
|
);
|
|
1942
1956
|
return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
|
|
1943
1957
|
}
|
|
1944
|
-
|
|
1945
|
-
if(isString(opts.note)){
|
|
1958
|
+
|
|
1959
|
+
if (isString(opts.note)) {
|
|
1946
1960
|
const verb = 'PUT';
|
|
1947
1961
|
let path = `${this.baseUrl}/admin/user/note`;
|
|
1948
|
-
|
|
1962
|
+
|
|
1949
1963
|
if (isNumber(userId)) {
|
|
1950
1964
|
path += `?user_id=${userId}`;
|
|
1951
1965
|
}
|
|
1952
|
-
|
|
1966
|
+
|
|
1953
1967
|
const data = {
|
|
1954
1968
|
note: opts.note
|
|
1955
1969
|
};
|
|
1956
|
-
|
|
1970
|
+
|
|
1957
1971
|
const headers = generateHeaders(
|
|
1958
1972
|
this.headers,
|
|
1959
1973
|
this.apiSecret,
|
|
@@ -1964,16 +1978,16 @@ class HollaExKit {
|
|
|
1964
1978
|
);
|
|
1965
1979
|
return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
|
|
1966
1980
|
}
|
|
1967
|
-
|
|
1968
|
-
if(isNumber(opts.verification_level)){
|
|
1981
|
+
|
|
1982
|
+
if (isNumber(opts.verification_level)) {
|
|
1969
1983
|
const verb = 'POST';
|
|
1970
1984
|
let path = `${this.baseUrl}/admin/upgrade-user`;
|
|
1971
|
-
|
|
1985
|
+
|
|
1972
1986
|
const data = {
|
|
1973
1987
|
user_id: userId,
|
|
1974
1988
|
verification_level: opts.verification_level
|
|
1975
1989
|
};
|
|
1976
|
-
|
|
1990
|
+
|
|
1977
1991
|
const headers = generateHeaders(
|
|
1978
1992
|
this.headers,
|
|
1979
1993
|
this.apiSecret,
|
|
@@ -1984,9 +1998,33 @@ class HollaExKit {
|
|
|
1984
1998
|
);
|
|
1985
1999
|
return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
|
|
1986
2000
|
}
|
|
1987
|
-
|
|
2001
|
+
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
/**
|
|
2005
|
+
* Delete exchange user
|
|
2006
|
+
* @param {number} user_id - The id for the user
|
|
2007
|
+
* @return {object} A JSON object with message
|
|
2008
|
+
*/
|
|
2009
|
+
deleteExchangeUser(user_id) {
|
|
2010
|
+
const verb = 'DELETE';
|
|
2011
|
+
let path = `${this.baseUrl}/admin/user`;
|
|
2012
|
+
const data = {
|
|
2013
|
+
user_id
|
|
2014
|
+
};
|
|
2015
|
+
|
|
2016
|
+
const headers = generateHeaders(
|
|
2017
|
+
this.headers,
|
|
2018
|
+
this.apiSecret,
|
|
2019
|
+
verb,
|
|
2020
|
+
path,
|
|
2021
|
+
this.apiExpiresAfter,
|
|
2022
|
+
data
|
|
2023
|
+
);
|
|
2024
|
+
return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
|
|
1988
2025
|
}
|
|
1989
|
-
|
|
2026
|
+
|
|
2027
|
+
|
|
1990
2028
|
/**
|
|
1991
2029
|
* Create wallet for exchange user
|
|
1992
2030
|
* @param {number} userId - The identifier of the user
|
|
@@ -1997,7 +2035,7 @@ class HollaExKit {
|
|
|
1997
2035
|
createExchangeUserWallet(
|
|
1998
2036
|
userId,
|
|
1999
2037
|
crypto,
|
|
2000
|
-
opts= {
|
|
2038
|
+
opts = {
|
|
2001
2039
|
network: null
|
|
2002
2040
|
}
|
|
2003
2041
|
) {
|
|
@@ -2007,11 +2045,11 @@ class HollaExKit {
|
|
|
2007
2045
|
user_id: userId,
|
|
2008
2046
|
crypto
|
|
2009
2047
|
};
|
|
2010
|
-
|
|
2048
|
+
|
|
2011
2049
|
if (isString(opts.network)) {
|
|
2012
2050
|
data.network = opts.network;
|
|
2013
2051
|
}
|
|
2014
|
-
|
|
2052
|
+
|
|
2015
2053
|
const headers = generateHeaders(
|
|
2016
2054
|
this.headers,
|
|
2017
2055
|
this.apiSecret,
|
|
@@ -2064,11 +2102,11 @@ class HollaExKit {
|
|
|
2064
2102
|
if (isNumber(opts.userId)) {
|
|
2065
2103
|
params += `&user_id=${opts.userId}`;
|
|
2066
2104
|
}
|
|
2067
|
-
|
|
2105
|
+
|
|
2068
2106
|
if (isString(opts.currency)) {
|
|
2069
2107
|
params += `¤cy=${opts.currency}`;
|
|
2070
2108
|
}
|
|
2071
|
-
|
|
2109
|
+
|
|
2072
2110
|
if (isString(opts.address)) {
|
|
2073
2111
|
params += `&address=${opts.address}`;
|
|
2074
2112
|
}
|
|
@@ -2080,23 +2118,23 @@ class HollaExKit {
|
|
|
2080
2118
|
if (isBoolean(opts.isValid)) {
|
|
2081
2119
|
params += `&is_valid=${opts.isValid}`;
|
|
2082
2120
|
}
|
|
2083
|
-
|
|
2121
|
+
|
|
2084
2122
|
if (isNumber(opts.limit)) {
|
|
2085
2123
|
params += `&limit=${opts.limit}`;
|
|
2086
2124
|
}
|
|
2087
|
-
|
|
2125
|
+
|
|
2088
2126
|
if (isNumber(opts.page)) {
|
|
2089
2127
|
params += `&page=${opts.page}`;
|
|
2090
2128
|
}
|
|
2091
|
-
|
|
2129
|
+
|
|
2092
2130
|
if (isString(opts.orderBy)) {
|
|
2093
2131
|
params += `&order_by=${opts.orderBy}`;
|
|
2094
2132
|
}
|
|
2095
|
-
|
|
2133
|
+
|
|
2096
2134
|
if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
|
|
2097
2135
|
params += `&order=${opts.order}`;
|
|
2098
2136
|
}
|
|
2099
|
-
|
|
2137
|
+
|
|
2100
2138
|
if (isDatetime(opts.startDate)) {
|
|
2101
2139
|
params += `&start_date=${sanitizeDate(opts.startDate)}`;
|
|
2102
2140
|
}
|
|
@@ -2104,13 +2142,13 @@ class HollaExKit {
|
|
|
2104
2142
|
if (isDatetime(opts.endDate)) {
|
|
2105
2143
|
params += `&end_date=${sanitizeDate(opts.endDate)}`;
|
|
2106
2144
|
}
|
|
2107
|
-
|
|
2145
|
+
|
|
2108
2146
|
if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
|
|
2109
2147
|
params += `&format=${opts.format}`;
|
|
2110
2148
|
}
|
|
2111
2149
|
|
|
2112
2150
|
if (params.length > 1) path += params;
|
|
2113
|
-
|
|
2151
|
+
|
|
2114
2152
|
const headers = generateHeaders(
|
|
2115
2153
|
this.headers,
|
|
2116
2154
|
this.apiSecret,
|
|
@@ -2120,7 +2158,7 @@ class HollaExKit {
|
|
|
2120
2158
|
);
|
|
2121
2159
|
return createRequest(verb, `${this.apiUrl}${path}`, headers);
|
|
2122
2160
|
}
|
|
2123
|
-
|
|
2161
|
+
|
|
2124
2162
|
/**
|
|
2125
2163
|
* Retrieve user's login info by admin
|
|
2126
2164
|
* @param {number} userId - The identifier of the user
|
|
@@ -2129,7 +2167,7 @@ class HollaExKit {
|
|
|
2129
2167
|
getExchangeUserBalance(userId) {
|
|
2130
2168
|
const verb = 'GET';
|
|
2131
2169
|
let path = `${this.baseUrl}/admin/user/balance?user_id=${userId}`;
|
|
2132
|
-
|
|
2170
|
+
|
|
2133
2171
|
const headers = generateHeaders(
|
|
2134
2172
|
this.headers,
|
|
2135
2173
|
this.apiSecret,
|
|
@@ -2139,7 +2177,7 @@ class HollaExKit {
|
|
|
2139
2177
|
);
|
|
2140
2178
|
return createRequest(verb, `${this.apiUrl}${path}`, headers);
|
|
2141
2179
|
}
|
|
2142
|
-
|
|
2180
|
+
|
|
2143
2181
|
/**
|
|
2144
2182
|
* Create bank account for user by admin
|
|
2145
2183
|
* @param {number} userId - The identifier of the user
|
|
@@ -2149,15 +2187,15 @@ class HollaExKit {
|
|
|
2149
2187
|
createExchangeUserBank(userId, bankAccount) {
|
|
2150
2188
|
const verb = 'POST';
|
|
2151
2189
|
let path = `${this.baseUrl}/admin/user/bank`;
|
|
2152
|
-
|
|
2190
|
+
|
|
2153
2191
|
if (isNumber(userId)) {
|
|
2154
2192
|
path += `?id=${userId}`;
|
|
2155
2193
|
}
|
|
2156
|
-
|
|
2194
|
+
|
|
2157
2195
|
const data = {
|
|
2158
2196
|
bank_account: bankAccount
|
|
2159
2197
|
};
|
|
2160
|
-
|
|
2198
|
+
|
|
2161
2199
|
const headers = generateHeaders(
|
|
2162
2200
|
this.headers,
|
|
2163
2201
|
this.apiSecret,
|
|
@@ -2167,9 +2205,9 @@ class HollaExKit {
|
|
|
2167
2205
|
data
|
|
2168
2206
|
);
|
|
2169
2207
|
return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
|
|
2170
|
-
|
|
2208
|
+
|
|
2171
2209
|
}
|
|
2172
|
-
|
|
2210
|
+
|
|
2173
2211
|
/**
|
|
2174
2212
|
* Retrieve user's login info by admin
|
|
2175
2213
|
* @param {number} opts.userId - The identifier of the user
|
|
@@ -2196,39 +2234,39 @@ class HollaExKit {
|
|
|
2196
2234
|
const verb = 'GET';
|
|
2197
2235
|
let path = `${this.baseUrl}/admin/logins`;
|
|
2198
2236
|
let params = '?';
|
|
2199
|
-
|
|
2237
|
+
|
|
2200
2238
|
if (isNumber(opts.userId)) {
|
|
2201
2239
|
params += `&user_id=${opts.userId}`;
|
|
2202
2240
|
}
|
|
2203
|
-
|
|
2241
|
+
|
|
2204
2242
|
if (isNumber(opts.limit)) {
|
|
2205
2243
|
params += `&limit=${opts.limit}`;
|
|
2206
2244
|
}
|
|
2207
|
-
|
|
2245
|
+
|
|
2208
2246
|
if (isNumber(opts.page)) {
|
|
2209
2247
|
params += `&page=${opts.page}`;
|
|
2210
2248
|
}
|
|
2211
|
-
|
|
2249
|
+
|
|
2212
2250
|
if (isString(opts.orderBy)) {
|
|
2213
2251
|
params += `&order_by=${opts.orderBy}`;
|
|
2214
2252
|
}
|
|
2215
|
-
|
|
2253
|
+
|
|
2216
2254
|
if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
|
|
2217
2255
|
params += `&order=${opts.order}`;
|
|
2218
2256
|
}
|
|
2219
|
-
|
|
2257
|
+
|
|
2220
2258
|
if (isDatetime(opts.startDate)) {
|
|
2221
2259
|
params += `&start_date=${sanitizeDate(opts.startDate)}`;
|
|
2222
2260
|
}
|
|
2223
|
-
|
|
2261
|
+
|
|
2224
2262
|
if (isDatetime(opts.endDate)) {
|
|
2225
2263
|
params += `&end_date=${sanitizeDate(opts.endDate)}`;
|
|
2226
2264
|
}
|
|
2227
|
-
|
|
2265
|
+
|
|
2228
2266
|
if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
|
|
2229
2267
|
params += `&format=${opts.format}`;
|
|
2230
2268
|
}
|
|
2231
|
-
|
|
2269
|
+
|
|
2232
2270
|
if (params.length > 1) path += params;
|
|
2233
2271
|
|
|
2234
2272
|
const headers = generateHeaders(
|
|
@@ -2240,7 +2278,7 @@ class HollaExKit {
|
|
|
2240
2278
|
);
|
|
2241
2279
|
return createRequest(verb, `${this.apiUrl}${path}`, headers);
|
|
2242
2280
|
}
|
|
2243
|
-
|
|
2281
|
+
|
|
2244
2282
|
/**
|
|
2245
2283
|
* Deactivate exchange user account by admin
|
|
2246
2284
|
* @param {number} userId - The identifier of the user to deactivate their exchange account
|
|
@@ -2253,7 +2291,7 @@ class HollaExKit {
|
|
|
2253
2291
|
user_id: userId,
|
|
2254
2292
|
activated: false
|
|
2255
2293
|
};
|
|
2256
|
-
|
|
2294
|
+
|
|
2257
2295
|
const headers = generateHeaders(
|
|
2258
2296
|
this.headers,
|
|
2259
2297
|
this.apiSecret,
|
|
@@ -2264,7 +2302,7 @@ class HollaExKit {
|
|
|
2264
2302
|
);
|
|
2265
2303
|
return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
|
|
2266
2304
|
}
|
|
2267
|
-
|
|
2305
|
+
|
|
2268
2306
|
/**
|
|
2269
2307
|
* Deactivate user otp by admin
|
|
2270
2308
|
* @param {number} userId - The identifier of the user to deactivate their otp
|
|
@@ -2276,7 +2314,7 @@ class HollaExKit {
|
|
|
2276
2314
|
const data = {
|
|
2277
2315
|
user_id: userId
|
|
2278
2316
|
};
|
|
2279
|
-
|
|
2317
|
+
|
|
2280
2318
|
const headers = generateHeaders(
|
|
2281
2319
|
this.headers,
|
|
2282
2320
|
this.apiSecret,
|
|
@@ -2287,7 +2325,7 @@ class HollaExKit {
|
|
|
2287
2325
|
);
|
|
2288
2326
|
return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
|
|
2289
2327
|
}
|
|
2290
|
-
|
|
2328
|
+
|
|
2291
2329
|
/**
|
|
2292
2330
|
* Retrieve user's referrals info by admin
|
|
2293
2331
|
* @param {number} userId - The identifier of the user to filter by
|
|
@@ -2313,38 +2351,38 @@ class HollaExKit {
|
|
|
2313
2351
|
const verb = 'GET';
|
|
2314
2352
|
let path = `${this.baseUrl}/admin/user/affiliation`;
|
|
2315
2353
|
let params = '?';
|
|
2316
|
-
|
|
2354
|
+
|
|
2317
2355
|
if (isNumber(userId)) {
|
|
2318
2356
|
params += `&user_id=${userId}`;
|
|
2319
2357
|
}
|
|
2320
|
-
|
|
2358
|
+
|
|
2321
2359
|
if (isNumber(opts.limit)) {
|
|
2322
2360
|
params += `&limit=${opts.limit}`;
|
|
2323
2361
|
}
|
|
2324
|
-
|
|
2362
|
+
|
|
2325
2363
|
if (isNumber(opts.page)) {
|
|
2326
2364
|
params += `&page=${opts.page}`;
|
|
2327
2365
|
}
|
|
2328
|
-
|
|
2366
|
+
|
|
2329
2367
|
if (isString(opts.orderBy)) {
|
|
2330
2368
|
params += `&order_by=${opts.orderBy}`;
|
|
2331
2369
|
}
|
|
2332
|
-
|
|
2370
|
+
|
|
2333
2371
|
if (isString(opts.order) && (opts.order === 'asc' || opts.order === 'desc')) {
|
|
2334
2372
|
params += `&order=${opts.order}`;
|
|
2335
2373
|
}
|
|
2336
|
-
|
|
2374
|
+
|
|
2337
2375
|
if (isDatetime(opts.startDate)) {
|
|
2338
2376
|
params += `&start_date=${sanitizeDate(opts.startDate)}`;
|
|
2339
2377
|
}
|
|
2340
|
-
|
|
2378
|
+
|
|
2341
2379
|
if (isDatetime(opts.endDate)) {
|
|
2342
2380
|
params += `&end_date=${sanitizeDate(opts.endDate)}`;
|
|
2343
2381
|
}
|
|
2344
2382
|
|
|
2345
2383
|
if (params.length > 1) path += params;
|
|
2346
|
-
|
|
2347
|
-
|
|
2384
|
+
|
|
2385
|
+
|
|
2348
2386
|
const headers = generateHeaders(
|
|
2349
2387
|
this.headers,
|
|
2350
2388
|
this.apiSecret,
|
|
@@ -2388,7 +2426,7 @@ class HollaExKit {
|
|
|
2388
2426
|
mail_type: mailType,
|
|
2389
2427
|
data: content
|
|
2390
2428
|
};
|
|
2391
|
-
|
|
2429
|
+
|
|
2392
2430
|
const headers = generateHeaders(
|
|
2393
2431
|
this.headers,
|
|
2394
2432
|
this.apiSecret,
|
|
@@ -2419,14 +2457,14 @@ class HollaExKit {
|
|
|
2419
2457
|
html,
|
|
2420
2458
|
};
|
|
2421
2459
|
|
|
2422
|
-
if(isString(opts.title)) {
|
|
2423
|
-
data.title = opts.title
|
|
2460
|
+
if (isString(opts.title)) {
|
|
2461
|
+
data.title = opts.title;
|
|
2424
2462
|
}
|
|
2425
|
-
|
|
2426
|
-
if(isString(opts.text)) {
|
|
2427
|
-
data.text = opts.text
|
|
2463
|
+
|
|
2464
|
+
if (isString(opts.text)) {
|
|
2465
|
+
data.text = opts.text;
|
|
2428
2466
|
}
|
|
2429
|
-
|
|
2467
|
+
|
|
2430
2468
|
const headers = generateHeaders(
|
|
2431
2469
|
this.headers,
|
|
2432
2470
|
this.apiSecret,
|
|
@@ -2437,7 +2475,7 @@ class HollaExKit {
|
|
|
2437
2475
|
);
|
|
2438
2476
|
return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
|
|
2439
2477
|
}
|
|
2440
|
-
|
|
2478
|
+
|
|
2441
2479
|
/**
|
|
2442
2480
|
* Retrieve user's balances by admin
|
|
2443
2481
|
* @param {number} opts.userId - The identifier of the user to filter by
|
|
@@ -2445,99 +2483,650 @@ class HollaExKit {
|
|
|
2445
2483
|
* @param {string} opts.format - Custom format of data set. Enum: ['all', 'csv']
|
|
2446
2484
|
* @return {object} A JSON object with referral info
|
|
2447
2485
|
*/
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
}
|
|
2454
|
-
) {
|
|
2455
|
-
const verb = 'GET';
|
|
2456
|
-
let path = `${this.baseUrl}/admin/balances?`;
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
if (isNumber(opts.userId)) {
|
|
2460
|
-
path += `&user_id=${opts.userId}`;
|
|
2461
|
-
}
|
|
2462
|
-
|
|
2463
|
-
if (isString(opts.currency)) {
|
|
2464
|
-
path += `¤cy=${opts.currency}`;
|
|
2465
|
-
}
|
|
2466
|
-
|
|
2467
|
-
if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
|
|
2468
|
-
path += `&format=${opts.format}`;
|
|
2469
|
-
}
|
|
2470
|
-
|
|
2471
|
-
const headers = generateHeaders(
|
|
2472
|
-
this.headers,
|
|
2473
|
-
this.apiSecret,
|
|
2474
|
-
verb,
|
|
2475
|
-
path,
|
|
2476
|
-
this.apiExpiresAfter
|
|
2477
|
-
);
|
|
2478
|
-
return createRequest(verb, `${this.apiUrl}${path}`, headers);
|
|
2486
|
+
getExchangeUserBalances(
|
|
2487
|
+
opts = {
|
|
2488
|
+
userId: null,
|
|
2489
|
+
currency: null,
|
|
2490
|
+
format: null
|
|
2479
2491
|
}
|
|
2492
|
+
) {
|
|
2493
|
+
const verb = 'GET';
|
|
2494
|
+
let path = `${this.baseUrl}/admin/balances?`;
|
|
2480
2495
|
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
*/
|
|
2485
|
-
connect(events = []) {
|
|
2486
|
-
this.wsReconnect = true;
|
|
2487
|
-
this.wsEvents = events;
|
|
2488
|
-
this.initialConnection = true;
|
|
2489
|
-
let url = this.wsUrl;
|
|
2490
|
-
if (this.apiKey && this.apiSecret) {
|
|
2491
|
-
const apiExpires = moment().unix() + this.apiExpiresAfter;
|
|
2492
|
-
const signature = createSignature(
|
|
2493
|
-
this.apiSecret,
|
|
2494
|
-
'CONNECT',
|
|
2495
|
-
'/stream',
|
|
2496
|
-
apiExpires
|
|
2497
|
-
);
|
|
2498
|
-
url = `${url}?api-key=${
|
|
2499
|
-
this.apiKey
|
|
2500
|
-
}&api-signature=${signature}&api-expires=${apiExpires}`;
|
|
2496
|
+
|
|
2497
|
+
if (isNumber(opts.userId)) {
|
|
2498
|
+
path += `&user_id=${opts.userId}`;
|
|
2501
2499
|
}
|
|
2502
2500
|
|
|
2503
|
-
|
|
2501
|
+
if (isString(opts.currency)) {
|
|
2502
|
+
path += `¤cy=${opts.currency}`;
|
|
2503
|
+
}
|
|
2504
2504
|
|
|
2505
|
-
if (
|
|
2506
|
-
|
|
2507
|
-
}
|
|
2508
|
-
this.ws.on('unexpected-response', () => {
|
|
2509
|
-
if (this.ws.readyState !== WebSocket.CLOSING) {
|
|
2510
|
-
if (this.ws.readyState === WebSocket.OPEN) {
|
|
2511
|
-
this.ws.close();
|
|
2512
|
-
} else if (this.wsReconnect) {
|
|
2513
|
-
this.wsEventListeners = this.ws._events;
|
|
2514
|
-
this.ws = null;
|
|
2515
|
-
setTimeout(() => {
|
|
2516
|
-
this.connect(this.wsEvents);
|
|
2517
|
-
}, this.wsReconnectInterval);
|
|
2518
|
-
} else {
|
|
2519
|
-
this.wsEventListeners = null;
|
|
2520
|
-
this.ws = null;
|
|
2521
|
-
}
|
|
2522
|
-
}
|
|
2523
|
-
});
|
|
2505
|
+
if (isString(opts.format) && ['csv', 'all'].includes(opts.format)) {
|
|
2506
|
+
path += `&format=${opts.format}`;
|
|
2507
|
+
}
|
|
2524
2508
|
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2509
|
+
const headers = generateHeaders(
|
|
2510
|
+
this.headers,
|
|
2511
|
+
this.apiSecret,
|
|
2512
|
+
verb,
|
|
2513
|
+
path,
|
|
2514
|
+
this.apiExpiresAfter
|
|
2515
|
+
);
|
|
2516
|
+
return createRequest(verb, `${this.apiUrl}${path}`, headers);
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
/**
|
|
2520
|
+
* Create order on behalf of user
|
|
2521
|
+
* @param {number} user_id - User id for the order
|
|
2522
|
+
* @param {string} symbol - Currency symbol of the order e.g. xht-usdt
|
|
2523
|
+
* @param {number} size - Size of the order
|
|
2524
|
+
* @param {number} price - Order Price
|
|
2525
|
+
* @param {string} side - Order Side, buy or sell
|
|
2526
|
+
* @param {string} type - Order Type, limit or market
|
|
2527
|
+
*/
|
|
2528
|
+
createOrderByAdmin(
|
|
2529
|
+
user_id,
|
|
2530
|
+
symbol,
|
|
2531
|
+
size,
|
|
2532
|
+
price,
|
|
2533
|
+
side,
|
|
2534
|
+
type
|
|
2535
|
+
) {
|
|
2536
|
+
const verb = 'POST';
|
|
2537
|
+
let path = `${this.baseUrl}/admin/order`;
|
|
2538
|
+
|
|
2539
|
+
const data = {
|
|
2540
|
+
user_id,
|
|
2541
|
+
size,
|
|
2542
|
+
side,
|
|
2543
|
+
type,
|
|
2544
|
+
price,
|
|
2545
|
+
symbol
|
|
2546
|
+
};
|
|
2547
|
+
|
|
2548
|
+
const headers = generateHeaders(
|
|
2549
|
+
this.headers,
|
|
2550
|
+
this.apiSecret,
|
|
2551
|
+
verb,
|
|
2552
|
+
path,
|
|
2553
|
+
this.apiExpiresAfter,
|
|
2554
|
+
data
|
|
2555
|
+
);
|
|
2556
|
+
return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
/**
|
|
2560
|
+
* Create trade on behalf of users
|
|
2561
|
+
* @param {number} maker_id - User id for the maker
|
|
2562
|
+
* @param {number} taker_id - User id for the taker
|
|
2563
|
+
* @param {number} maker_fee - fee in percentage for the maker
|
|
2564
|
+
* @param {number} taker_fee - fee in percentage for the taker
|
|
2565
|
+
* @param {string} symbol - Currency symbol of the order e.g. xht-usdt
|
|
2566
|
+
* @param {number} size - Size of the order
|
|
2567
|
+
* @param {number} price - Order Price
|
|
2568
|
+
* @param {string} side - Order Side, buy or sell
|
|
2569
|
+
*/
|
|
2570
|
+
createTradeByAdmin(
|
|
2571
|
+
maker_id,
|
|
2572
|
+
taker_id,
|
|
2573
|
+
maker_fee,
|
|
2574
|
+
taker_fee,
|
|
2575
|
+
symbol,
|
|
2576
|
+
size,
|
|
2577
|
+
price,
|
|
2578
|
+
side,
|
|
2579
|
+
) {
|
|
2580
|
+
const verb = 'POST';
|
|
2581
|
+
let path = `${this.baseUrl}/admin/trade`;
|
|
2582
|
+
|
|
2583
|
+
const data = {
|
|
2584
|
+
maker_id,
|
|
2585
|
+
taker_id,
|
|
2586
|
+
maker_fee,
|
|
2587
|
+
taker_fee,
|
|
2588
|
+
symbol,
|
|
2589
|
+
size,
|
|
2590
|
+
price,
|
|
2591
|
+
side,
|
|
2592
|
+
};
|
|
2593
|
+
|
|
2594
|
+
const headers = generateHeaders(
|
|
2595
|
+
this.headers,
|
|
2596
|
+
this.apiSecret,
|
|
2597
|
+
verb,
|
|
2598
|
+
path,
|
|
2599
|
+
this.apiExpiresAfter,
|
|
2600
|
+
data
|
|
2601
|
+
);
|
|
2602
|
+
return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
|
|
2603
|
+
}
|
|
2604
|
+
/**
|
|
2605
|
+
* Create withdrawal on behalf of users
|
|
2606
|
+
* @param {number} user_id - User id for the withdrawal process
|
|
2607
|
+
* @param {string} address - Specific address for the withdrawal
|
|
2608
|
+
* @param {number} amount - Size of the withdrawal
|
|
2609
|
+
* @param {string} currency - Currency symbol of the withdrawal
|
|
2610
|
+
* @param {string} opts.network - Blockchain network
|
|
2611
|
+
*/
|
|
2612
|
+
createWithdrawalByAdmin(
|
|
2613
|
+
user_id,
|
|
2614
|
+
address,
|
|
2615
|
+
amount,
|
|
2616
|
+
currency,
|
|
2617
|
+
opts = {
|
|
2618
|
+
network: null
|
|
2619
|
+
}
|
|
2620
|
+
) {
|
|
2621
|
+
const verb = 'POST';
|
|
2622
|
+
let path = `${this.baseUrl}/admin/withdrawal`;
|
|
2623
|
+
|
|
2624
|
+
const data = {
|
|
2625
|
+
user_id,
|
|
2626
|
+
address,
|
|
2627
|
+
amount,
|
|
2628
|
+
currency
|
|
2629
|
+
};
|
|
2630
|
+
|
|
2631
|
+
if (isString(opts.network)) {
|
|
2632
|
+
data.network = opts.network;
|
|
2633
|
+
}
|
|
2634
|
+
|
|
2635
|
+
const headers = generateHeaders(
|
|
2636
|
+
this.headers,
|
|
2637
|
+
this.apiSecret,
|
|
2638
|
+
verb,
|
|
2639
|
+
path,
|
|
2640
|
+
this.apiExpiresAfter,
|
|
2641
|
+
data
|
|
2642
|
+
);
|
|
2643
|
+
return createRequest(verb, `${this.apiUrl}${path}`, headers, { data });
|
|
2644
|
+
}
|
|
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 += `¤cy=${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
|
+
}
|
|
3071
|
+
/**
|
|
3072
|
+
* Connect to hollaEx websocket and listen to an event
|
|
3073
|
+
* @param {array} events - The events to listen to
|
|
3074
|
+
*/
|
|
3075
|
+
connect(events = []) {
|
|
3076
|
+
this.wsReconnect = true;
|
|
3077
|
+
this.wsEvents = events;
|
|
3078
|
+
this.initialConnection = true;
|
|
3079
|
+
let url = this.wsUrl;
|
|
3080
|
+
if (this.apiKey && this.apiSecret) {
|
|
3081
|
+
const apiExpires = moment().unix() + this.apiExpiresAfter;
|
|
3082
|
+
const signature = createSignature(
|
|
3083
|
+
this.apiSecret,
|
|
3084
|
+
'CONNECT',
|
|
3085
|
+
'/stream',
|
|
3086
|
+
apiExpires
|
|
3087
|
+
);
|
|
3088
|
+
url = `${url}?api-key=${this.apiKey
|
|
3089
|
+
}&api-signature=${signature}&api-expires=${apiExpires}`;
|
|
3090
|
+
}
|
|
3091
|
+
|
|
3092
|
+
this.ws = new WebSocket(url);
|
|
3093
|
+
|
|
3094
|
+
if (this.wsEventListeners) {
|
|
3095
|
+
this.ws._events = this.wsEventListeners;
|
|
3096
|
+
} else {
|
|
3097
|
+
this.ws.on('unexpected-response', () => {
|
|
3098
|
+
if (this.ws.readyState !== WebSocket.CLOSING) {
|
|
3099
|
+
if (this.ws.readyState === WebSocket.OPEN) {
|
|
3100
|
+
this.ws.close();
|
|
3101
|
+
} else if (this.wsReconnect) {
|
|
3102
|
+
this.wsEventListeners = this.ws._events;
|
|
3103
|
+
this.ws = null;
|
|
3104
|
+
setTimeout(() => {
|
|
3105
|
+
this.connect(this.wsEvents);
|
|
3106
|
+
}, this.wsReconnectInterval);
|
|
3107
|
+
} else {
|
|
3108
|
+
this.wsEventListeners = null;
|
|
3109
|
+
this.ws = null;
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
});
|
|
3113
|
+
|
|
3114
|
+
this.ws.on('error', () => {
|
|
3115
|
+
if (this.ws.readyState !== WebSocket.CLOSING) {
|
|
3116
|
+
if (this.ws.readyState === WebSocket.OPEN) {
|
|
3117
|
+
this.ws.close();
|
|
3118
|
+
} else if (this.wsReconnect) {
|
|
3119
|
+
this.wsEventListeners = this.ws._events;
|
|
3120
|
+
this.ws = null;
|
|
3121
|
+
setTimeout(() => {
|
|
3122
|
+
this.connect(this.wsEvents);
|
|
3123
|
+
}, this.wsReconnectInterval);
|
|
3124
|
+
} else {
|
|
3125
|
+
this.wsEventListeners = null;
|
|
3126
|
+
this.ws = null;
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
});
|
|
2541
3130
|
|
|
2542
3131
|
this.ws.on('close', () => {
|
|
2543
3132
|
if (this.wsReconnect) {
|
|
@@ -2589,21 +3178,41 @@ class HollaExKit {
|
|
|
2589
3178
|
if (!this.wsEvents.includes(event) || this.initialConnection) {
|
|
2590
3179
|
const [topic, symbol] = event.split(':');
|
|
2591
3180
|
switch (topic) {
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
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 {
|
|
2596
3196
|
this.ws.send(
|
|
2597
3197
|
JSON.stringify({
|
|
2598
3198
|
op: 'subscribe',
|
|
2599
|
-
args: [
|
|
3199
|
+
args: [topic]
|
|
2600
3200
|
})
|
|
2601
3201
|
);
|
|
2602
3202
|
if (!this.initialConnection) {
|
|
3203
|
+
this.wsEvents = this.wsEvents.filter(
|
|
3204
|
+
(e) => !e.includes(`${topic}:`)
|
|
3205
|
+
);
|
|
2603
3206
|
this.wsEvents = union(this.wsEvents, [event]);
|
|
2604
3207
|
}
|
|
2605
3208
|
}
|
|
2606
|
-
|
|
3209
|
+
break;
|
|
3210
|
+
case 'order':
|
|
3211
|
+
case 'usertrade':
|
|
3212
|
+
case 'wallet':
|
|
3213
|
+
case 'deposit':
|
|
3214
|
+
case 'withdrawal':
|
|
3215
|
+
case 'admin':
|
|
2607
3216
|
this.ws.send(
|
|
2608
3217
|
JSON.stringify({
|
|
2609
3218
|
op: 'subscribe',
|
|
@@ -2611,31 +3220,11 @@ class HollaExKit {
|
|
|
2611
3220
|
})
|
|
2612
3221
|
);
|
|
2613
3222
|
if (!this.initialConnection) {
|
|
2614
|
-
this.wsEvents = this.wsEvents.filter(
|
|
2615
|
-
(e) => !e.includes(`${topic}:`)
|
|
2616
|
-
);
|
|
2617
3223
|
this.wsEvents = union(this.wsEvents, [event]);
|
|
2618
3224
|
}
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
case 'usertrade':
|
|
2623
|
-
case 'wallet':
|
|
2624
|
-
case 'deposit':
|
|
2625
|
-
case 'withdrawal':
|
|
2626
|
-
case 'admin':
|
|
2627
|
-
this.ws.send(
|
|
2628
|
-
JSON.stringify({
|
|
2629
|
-
op: 'subscribe',
|
|
2630
|
-
args: [topic]
|
|
2631
|
-
})
|
|
2632
|
-
);
|
|
2633
|
-
if (!this.initialConnection) {
|
|
2634
|
-
this.wsEvents = union(this.wsEvents, [event]);
|
|
2635
|
-
}
|
|
2636
|
-
break;
|
|
2637
|
-
default:
|
|
2638
|
-
break;
|
|
3225
|
+
break;
|
|
3226
|
+
default:
|
|
3227
|
+
break;
|
|
2639
3228
|
}
|
|
2640
3229
|
}
|
|
2641
3230
|
});
|
|
@@ -2654,40 +3243,40 @@ class HollaExKit {
|
|
|
2654
3243
|
if (this.wsEvents.includes(event)) {
|
|
2655
3244
|
const [topic, symbol] = event.split(':');
|
|
2656
3245
|
switch (topic) {
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
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':
|
|
2667
3270
|
this.ws.send(
|
|
2668
3271
|
JSON.stringify({
|
|
2669
3272
|
op: 'unsubscribe',
|
|
2670
3273
|
args: [topic]
|
|
2671
3274
|
})
|
|
2672
3275
|
);
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
case 'wallet':
|
|
2678
|
-
case 'deposit':
|
|
2679
|
-
case 'withdrawal':
|
|
2680
|
-
case 'admin':
|
|
2681
|
-
this.ws.send(
|
|
2682
|
-
JSON.stringify({
|
|
2683
|
-
op: 'unsubscribe',
|
|
2684
|
-
args: [topic]
|
|
2685
|
-
})
|
|
2686
|
-
);
|
|
2687
|
-
this.wsEvents = this.wsEvents.filter((e) => e !== event);
|
|
2688
|
-
break;
|
|
2689
|
-
default:
|
|
2690
|
-
break;
|
|
3276
|
+
this.wsEvents = this.wsEvents.filter((e) => e !== event);
|
|
3277
|
+
break;
|
|
3278
|
+
default:
|
|
3279
|
+
break;
|
|
2691
3280
|
}
|
|
2692
3281
|
}
|
|
2693
3282
|
});
|
|
@@ -2697,4 +3286,4 @@ class HollaExKit {
|
|
|
2697
3286
|
}
|
|
2698
3287
|
}
|
|
2699
3288
|
|
|
2700
|
-
module.exports = HollaExKit;
|
|
3289
|
+
module.exports = HollaExKit;
|