@ultrade/shared 1.0.0 → 1.0.2
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/dist/common/auth.helper.js +16 -37
- package/dist/common/awsKms.js +9 -19
- package/dist/common/big-number.helper.d.ts +0 -3
- package/dist/common/big-number.helper.js +7 -26
- package/dist/common/index.js +65 -107
- package/dist/common/indexer.helper.js +9 -19
- package/dist/common/logger.js +6 -16
- package/dist/common/mappers/codexAsset.mapper.js +3 -14
- package/dist/common/mappers/codexBalance.mapper.js +3 -14
- package/dist/common/mappers/index.js +15 -35
- package/dist/common/mappers/trade.mapper.js +15 -35
- package/dist/common/migration.helpers.js +3 -14
- package/dist/common/redis.helper.js +20 -40
- package/dist/common/secret.helper.js +11 -26
- package/dist/common/timestamp.helper.js +3 -14
- package/dist/common/utils/assert.js +3 -14
- package/dist/common/utils/decode.js +6 -17
- package/dist/common/utils/index.js +4 -15
- package/dist/common/utils/social.js +3 -14
- package/dist/common/utils/stat.js +7 -26
- package/dist/constants/index.js +3 -14
- package/dist/enums/index.js +3 -14
- package/dist/helpers/Encoding.js +10 -31
- package/dist/helpers/algo.helper.js +44 -82
- package/dist/helpers/assert.helper.js +13 -34
- package/dist/helpers/atomic.helper.d.ts +0 -17
- package/dist/helpers/atomic.helper.js +7 -43
- package/dist/helpers/balance.helper.js +71 -166
- package/dist/helpers/codex/common.helper.js +71 -149
- package/dist/helpers/codex/index.js +71 -149
- package/dist/helpers/codex/mbr.helper.js +71 -149
- package/dist/helpers/codex/mna.helper.js +71 -149
- package/dist/helpers/codex/order.helper.js +71 -149
- package/dist/helpers/codex/setGlobal.helper.js +73 -151
- package/dist/helpers/codex/transfer.helper.js +71 -149
- package/dist/helpers/codex/txn.helper.js +71 -149
- package/dist/helpers/codex.helper.js +71 -149
- package/dist/helpers/email.helper.js +6 -17
- package/dist/helpers/eth.helper.js +71 -149
- package/dist/helpers/hummingbots.helper.js +11 -22
- package/dist/helpers/index.js +31 -58
- package/dist/helpers/interval.helpers.js +10 -21
- package/dist/helpers/liquidity.helper.js +6 -17
- package/dist/helpers/order.helper.js +3 -14
- package/dist/helpers/pair.helper.js +3 -14
- package/dist/helpers/pointSystem.helper.js +15 -33
- package/dist/helpers/ticker.helpers.js +7 -27
- package/dist/helpers/vaa.helper.js +97 -175
- package/dist/helpers/withdraw.helper.js +97 -167
- package/dist/interfaces/db/market/index.d.ts +34 -6
- package/dist/interfaces/db/white_label/index.d.ts +3 -3
- package/dist/interfaces/index.js +11 -14
- package/dist/types/index.js +15 -33
- package/package.json +16 -8
- package/dist/baseModel/base.model.d.ts +0 -26
- package/dist/baseModel/index.d.ts +0 -2
- package/dist/helpers/api.helper.d.ts +0 -16
- package/dist/helpers/api.helper.js +0 -1652
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory(require("bignumber.js"));
|
|
4
|
-
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define(["bignumber.js"], factory);
|
|
6
|
-
else {
|
|
7
|
-
var a = typeof exports === 'object' ? factory(require("bignumber.js")) : factory(root["bignumber.js"]);
|
|
8
|
-
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
9
|
-
}
|
|
10
|
-
})(global, (__WEBPACK_EXTERNAL_MODULE__6168__) => {
|
|
11
|
-
return /******/ (() => { // webpackBootstrap
|
|
1
|
+
/******/ (() => { // webpackBootstrap
|
|
12
2
|
/******/ "use strict";
|
|
13
3
|
/******/ var __webpack_modules__ = ({
|
|
14
4
|
|
|
@@ -276,7 +266,7 @@ exports.bn_operation = bn_operation;
|
|
|
276
266
|
exports.roundNumber = roundNumber;
|
|
277
267
|
exports.convertFromBaseUnits = convertFromBaseUnits;
|
|
278
268
|
exports.convertToBaseUnits = convertToBaseUnits;
|
|
279
|
-
const bignumber_js_1 = __importDefault(__webpack_require__(
|
|
269
|
+
const bignumber_js_1 = __importDefault(__webpack_require__(4978));
|
|
280
270
|
bignumber_js_1.default.config({ DECIMAL_PLACES: 40, EXPONENTIAL_AT: 45 });
|
|
281
271
|
var Operations;
|
|
282
272
|
(function (Operations) {
|
|
@@ -294,7 +284,6 @@ var Operations;
|
|
|
294
284
|
function absolute(value) {
|
|
295
285
|
let x = new bignumber_js_1.default(value);
|
|
296
286
|
const res = x.abs().toString();
|
|
297
|
-
// console.log('Absolute value', { value, res })
|
|
298
287
|
return res;
|
|
299
288
|
}
|
|
300
289
|
function ceil(value) {
|
|
@@ -434,17 +423,10 @@ function roundNumber({ decimalPlaces = 0 }, x) {
|
|
|
434
423
|
}
|
|
435
424
|
function convertFromBaseUnits(assetDecimals, quantity) {
|
|
436
425
|
const decimals = Number(assetDecimals);
|
|
437
|
-
return roundNumber({ decimalPlaces: decimals },
|
|
438
|
-
// eslint-disable-next-line no-magic-numbers
|
|
439
|
-
Math.pow(10, -decimals) * Number(quantity));
|
|
426
|
+
return roundNumber({ decimalPlaces: decimals }, Math.pow(10, -decimals) * Number(quantity));
|
|
440
427
|
}
|
|
441
|
-
/**
|
|
442
|
-
* Computs quantity * 10^(assetDecimals) and rounds the result
|
|
443
|
-
*/
|
|
444
428
|
function convertToBaseUnits(assetDecimals, quantity) {
|
|
445
|
-
// eslint-disable-next-line no-magic-numbers
|
|
446
429
|
const baseAmount = Math.pow(10, Number(assetDecimals)) * Number(quantity);
|
|
447
|
-
// make sure the final value is an integer. This prevents this kind of computation errors: 0.0012 * 100000 = 119.99999999999999 and rounds this result into 120
|
|
448
430
|
return roundNumber({ decimalPlaces: 0 }, baseAmount);
|
|
449
431
|
}
|
|
450
432
|
|
|
@@ -1104,6 +1086,13 @@ const messageForSigning = (signingAddress) => `By signing this message, you conf
|
|
|
1104
1086
|
exports.messageForSigning = messageForSigning;
|
|
1105
1087
|
|
|
1106
1088
|
|
|
1089
|
+
/***/ }),
|
|
1090
|
+
|
|
1091
|
+
/***/ 4978:
|
|
1092
|
+
/***/ ((module) => {
|
|
1093
|
+
|
|
1094
|
+
module.exports = require("bignumber.js");
|
|
1095
|
+
|
|
1107
1096
|
/***/ }),
|
|
1108
1097
|
|
|
1109
1098
|
/***/ 5237:
|
|
@@ -1141,13 +1130,6 @@ var TwitterAccessScopeEnum;
|
|
|
1141
1130
|
})(TwitterAccessScopeEnum || (exports.TwitterAccessScopeEnum = TwitterAccessScopeEnum = {}));
|
|
1142
1131
|
|
|
1143
1132
|
|
|
1144
|
-
/***/ }),
|
|
1145
|
-
|
|
1146
|
-
/***/ 6168:
|
|
1147
|
-
/***/ ((module) => {
|
|
1148
|
-
|
|
1149
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__6168__;
|
|
1150
|
-
|
|
1151
1133
|
/***/ }),
|
|
1152
1134
|
|
|
1153
1135
|
/***/ 6450:
|
|
@@ -1235,7 +1217,6 @@ var MaintenanceMode;
|
|
|
1235
1217
|
|
|
1236
1218
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1237
1219
|
exports.assertOrder = exports.assertOrderExpirationAtCreationMoment = exports.assertOrderData = void 0;
|
|
1238
|
-
// import assert from "assert-ts";
|
|
1239
1220
|
const big_number_helper_1 = __webpack_require__(1174);
|
|
1240
1221
|
const utils_1 = __webpack_require__(8398);
|
|
1241
1222
|
const _constants_1 = __webpack_require__(6450);
|
|
@@ -1271,7 +1252,6 @@ const assertOrder = (order, pair) => {
|
|
|
1271
1252
|
}
|
|
1272
1253
|
else if (order.orderType === "M" && order.orderSide === "B" && (0, big_number_helper_1.equal)(order.amount, 0)) {
|
|
1273
1254
|
throw new Error("Buy murket order by total is not implemented yet");
|
|
1274
|
-
// assert( greaterThan(order.price, 0) && modZero(order.price, pair.min_price_increment), "Invalid buy market order by total");
|
|
1275
1255
|
}
|
|
1276
1256
|
else if (order.orderType === "M" && order.orderSide === "B" && (0, big_number_helper_1.greaterThan)(order.amount, 0)) {
|
|
1277
1257
|
assert((0, big_number_helper_1.greaterThan)(order.price, 0) && (0, big_number_helper_1.modZero)(order.amount, pair.min_size_increment) && (0, big_number_helper_1.greaterThanOrEqual)(order.amount, pair.min_order_size), "Invalid buy market order by amount");
|
|
@@ -1588,7 +1568,7 @@ function removeField(obj, fieldToRemove) {
|
|
|
1588
1568
|
.filter(([key]) => key !== fieldToRemove)
|
|
1589
1569
|
.map(([key, value]) => [key, removeField(value, fieldToRemove)]));
|
|
1590
1570
|
}
|
|
1591
|
-
return obj;
|
|
1571
|
+
return obj;
|
|
1592
1572
|
}
|
|
1593
1573
|
function removeUndefined(obj) {
|
|
1594
1574
|
return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined));
|
|
@@ -1670,8 +1650,7 @@ __exportStar(__webpack_require__(3004), exports);
|
|
|
1670
1650
|
/******/ // Load entry module and return exports
|
|
1671
1651
|
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
1672
1652
|
/******/ var __webpack_exports__ = __webpack_require__(7010);
|
|
1653
|
+
/******/ module.exports = __webpack_exports__;
|
|
1673
1654
|
/******/
|
|
1674
|
-
/******/ return __webpack_exports__;
|
|
1675
1655
|
/******/ })()
|
|
1676
|
-
;
|
|
1677
|
-
});
|
|
1656
|
+
;
|
|
@@ -1,21 +1,4 @@
|
|
|
1
1
|
export declare const factorPrice: (price: number) => string;
|
|
2
|
-
/**
|
|
3
|
-
* Convert a factored atomic value to a non-factored atomic value
|
|
4
|
-
* @param price - The price to convert
|
|
5
|
-
* @param decimal - The number of decimal places
|
|
6
|
-
* @returns The price converted to a non factored atomic value
|
|
7
|
-
*/
|
|
8
2
|
export declare const defactorPrice: (price: string, decimal: number) => string;
|
|
9
|
-
/**
|
|
10
|
-
* Convert an atomic value to a decimal value. ONLY for non-factored atomic values
|
|
11
|
-
* @param amount - The number to convert
|
|
12
|
-
* @param decimal - The number of decimal places
|
|
13
|
-
* @returns The number converted to a decimal
|
|
14
|
-
*/
|
|
15
3
|
export declare const toDecimal: (amount: string, decimal: number) => string;
|
|
16
|
-
/**
|
|
17
|
-
* Convert a factored atomic value to a decimal value
|
|
18
|
-
* @param price - The price to convert
|
|
19
|
-
* @returns The price converted to a decimal
|
|
20
|
-
*/
|
|
21
4
|
export declare const toDecimalPrice: (price: string) => string;
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory(require("bignumber.js"));
|
|
4
|
-
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define(["bignumber.js"], factory);
|
|
6
|
-
else {
|
|
7
|
-
var a = typeof exports === 'object' ? factory(require("bignumber.js")) : factory(root["bignumber.js"]);
|
|
8
|
-
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
9
|
-
}
|
|
10
|
-
})(global, (__WEBPACK_EXTERNAL_MODULE__6168__) => {
|
|
11
|
-
return /******/ (() => { // webpackBootstrap
|
|
1
|
+
/******/ (() => { // webpackBootstrap
|
|
12
2
|
/******/ "use strict";
|
|
13
3
|
/******/ var __webpack_modules__ = ({
|
|
14
4
|
|
|
@@ -155,7 +145,7 @@ exports.bn_operation = bn_operation;
|
|
|
155
145
|
exports.roundNumber = roundNumber;
|
|
156
146
|
exports.convertFromBaseUnits = convertFromBaseUnits;
|
|
157
147
|
exports.convertToBaseUnits = convertToBaseUnits;
|
|
158
|
-
const bignumber_js_1 = __importDefault(__webpack_require__(
|
|
148
|
+
const bignumber_js_1 = __importDefault(__webpack_require__(4978));
|
|
159
149
|
bignumber_js_1.default.config({ DECIMAL_PLACES: 40, EXPONENTIAL_AT: 45 });
|
|
160
150
|
var Operations;
|
|
161
151
|
(function (Operations) {
|
|
@@ -173,7 +163,6 @@ var Operations;
|
|
|
173
163
|
function absolute(value) {
|
|
174
164
|
let x = new bignumber_js_1.default(value);
|
|
175
165
|
const res = x.abs().toString();
|
|
176
|
-
// console.log('Absolute value', { value, res })
|
|
177
166
|
return res;
|
|
178
167
|
}
|
|
179
168
|
function ceil(value) {
|
|
@@ -313,17 +302,10 @@ function roundNumber({ decimalPlaces = 0 }, x) {
|
|
|
313
302
|
}
|
|
314
303
|
function convertFromBaseUnits(assetDecimals, quantity) {
|
|
315
304
|
const decimals = Number(assetDecimals);
|
|
316
|
-
return roundNumber({ decimalPlaces: decimals },
|
|
317
|
-
// eslint-disable-next-line no-magic-numbers
|
|
318
|
-
Math.pow(10, -decimals) * Number(quantity));
|
|
305
|
+
return roundNumber({ decimalPlaces: decimals }, Math.pow(10, -decimals) * Number(quantity));
|
|
319
306
|
}
|
|
320
|
-
/**
|
|
321
|
-
* Computs quantity * 10^(assetDecimals) and rounds the result
|
|
322
|
-
*/
|
|
323
307
|
function convertToBaseUnits(assetDecimals, quantity) {
|
|
324
|
-
// eslint-disable-next-line no-magic-numbers
|
|
325
308
|
const baseAmount = Math.pow(10, Number(assetDecimals)) * Number(quantity);
|
|
326
|
-
// make sure the final value is an integer. This prevents this kind of computation errors: 0.0012 * 100000 = 119.99999999999999 and rounds this result into 120
|
|
327
309
|
return roundNumber({ decimalPlaces: 0 }, baseAmount);
|
|
328
310
|
}
|
|
329
311
|
|
|
@@ -378,31 +360,14 @@ const factorPrice = (price) => {
|
|
|
378
360
|
return (0, big_number_helper_1.multiply)(price, 10 ** constants_1.FACTOR_PRICE_DECIMAL);
|
|
379
361
|
};
|
|
380
362
|
exports.factorPrice = factorPrice;
|
|
381
|
-
/**
|
|
382
|
-
* Convert a factored atomic value to a non-factored atomic value
|
|
383
|
-
* @param price - The price to convert
|
|
384
|
-
* @param decimal - The number of decimal places
|
|
385
|
-
* @returns The price converted to a non factored atomic value
|
|
386
|
-
*/
|
|
387
363
|
const defactorPrice = (price, decimal) => {
|
|
388
364
|
return (0, big_number_helper_1.divide)(price, 10 ** (constants_1.FACTOR_PRICE_DECIMAL - decimal));
|
|
389
365
|
};
|
|
390
366
|
exports.defactorPrice = defactorPrice;
|
|
391
|
-
/**
|
|
392
|
-
* Convert an atomic value to a decimal value. ONLY for non-factored atomic values
|
|
393
|
-
* @param amount - The number to convert
|
|
394
|
-
* @param decimal - The number of decimal places
|
|
395
|
-
* @returns The number converted to a decimal
|
|
396
|
-
*/
|
|
397
367
|
const toDecimal = (amount, decimal) => {
|
|
398
368
|
return (0, big_number_helper_1.divide)(amount, 10 ** decimal);
|
|
399
369
|
};
|
|
400
370
|
exports.toDecimal = toDecimal;
|
|
401
|
-
/**
|
|
402
|
-
* Convert a factored atomic value to a decimal value
|
|
403
|
-
* @param price - The price to convert
|
|
404
|
-
* @returns The price converted to a decimal
|
|
405
|
-
*/
|
|
406
371
|
const toDecimalPrice = (price) => {
|
|
407
372
|
return (0, exports.toDecimal)(price, constants_1.FACTOR_PRICE_DECIMAL);
|
|
408
373
|
};
|
|
@@ -423,10 +388,10 @@ exports.messageForSigning = messageForSigning;
|
|
|
423
388
|
|
|
424
389
|
/***/ }),
|
|
425
390
|
|
|
426
|
-
/***/
|
|
391
|
+
/***/ 4978:
|
|
427
392
|
/***/ ((module) => {
|
|
428
393
|
|
|
429
|
-
module.exports =
|
|
394
|
+
module.exports = require("bignumber.js");
|
|
430
395
|
|
|
431
396
|
/***/ }),
|
|
432
397
|
|
|
@@ -705,8 +670,7 @@ exports.CCTP_UNIFIED_ASSETS = {
|
|
|
705
670
|
/******/ // Load entry module and return exports
|
|
706
671
|
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
707
672
|
/******/ var __webpack_exports__ = __webpack_require__(3316);
|
|
673
|
+
/******/ module.exports = __webpack_exports__;
|
|
708
674
|
/******/
|
|
709
|
-
/******/ return __webpack_exports__;
|
|
710
675
|
/******/ })()
|
|
711
|
-
;
|
|
712
|
-
});
|
|
676
|
+
;
|