@ultrade/shared 1.0.0
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/baseModel/base.model.d.ts +26 -0
- package/dist/baseModel/index.d.ts +2 -0
- package/dist/common/auth.helper.d.ts +4 -0
- package/dist/common/auth.helper.js +367 -0
- package/dist/common/awsKms.d.ts +2 -0
- package/dist/common/awsKms.js +265 -0
- package/dist/common/big-number.helper.d.ts +38 -0
- package/dist/common/big-number.helper.js +263 -0
- package/dist/common/index.d.ts +11 -0
- package/dist/common/index.js +2541 -0
- package/dist/common/indexer.helper.d.ts +2 -0
- package/dist/common/indexer.helper.js +387 -0
- package/dist/common/logger.d.ts +32 -0
- package/dist/common/logger.js +188 -0
- package/dist/common/mappers/codexAsset.mapper.d.ts +2 -0
- package/dist/common/mappers/codexAsset.mapper.js +40 -0
- package/dist/common/mappers/codexBalance.mapper.d.ts +2 -0
- package/dist/common/mappers/codexBalance.mapper.js +38 -0
- package/dist/common/mappers/index.d.ts +3 -0
- package/dist/common/mappers/index.js +1421 -0
- package/dist/common/mappers/trade.mapper.d.ts +6 -0
- package/dist/common/mappers/trade.mapper.js +1343 -0
- package/dist/common/migration.helpers.d.ts +4 -0
- package/dist/common/migration.helpers.js +44 -0
- package/dist/common/redis.helper.d.ts +27 -0
- package/dist/common/redis.helper.js +269 -0
- package/dist/common/secret.helper.d.ts +28 -0
- package/dist/common/secret.helper.js +144 -0
- package/dist/common/timestamp.helper.d.ts +1 -0
- package/dist/common/timestamp.helper.js +41 -0
- package/dist/common/utils/assert.d.ts +1 -0
- package/dist/common/utils/assert.js +32 -0
- package/dist/common/utils/decode.d.ts +5 -0
- package/dist/common/utils/decode.js +206 -0
- package/dist/common/utils/index.d.ts +9 -0
- package/dist/common/utils/index.js +122 -0
- package/dist/common/utils/social.d.ts +1 -0
- package/dist/common/utils/social.js +30 -0
- package/dist/common/utils/stat.d.ts +1 -0
- package/dist/common/utils/stat.js +274 -0
- package/dist/constants/allowedUrls.d.ts +1 -0
- package/dist/constants/auth.d.ts +2 -0
- package/dist/constants/cctp.d.ts +3 -0
- package/dist/constants/codex.d.ts +11 -0
- package/dist/constants/env.d.ts +6 -0
- package/dist/constants/index.d.ts +7 -0
- package/dist/constants/index.js +455 -0
- package/dist/constants/queue.d.ts +39 -0
- package/dist/constants/response.d.ts +82 -0
- package/dist/constants/settings.d.ts +2 -0
- package/dist/constants/social.d.ts +3 -0
- package/dist/constants/withdrawalWalletsMessage.d.ts +1 -0
- package/dist/enums/chains.enum.d.ts +50 -0
- package/dist/enums/db/account/index.d.ts +19 -0
- package/dist/enums/db/affiliate.enum.d.ts +7 -0
- package/dist/enums/db/available-pair-settings.enum.d.ts +12 -0
- package/dist/enums/db/chains.d.ts +30 -0
- package/dist/enums/db/common.enum.d.ts +4 -0
- package/dist/enums/db/component/index.d.ts +22 -0
- package/dist/enums/db/index.d.ts +21 -0
- package/dist/enums/db/market-maker.enum.d.ts +15 -0
- package/dist/enums/db/notification-center/userNotification.enum.d.ts +36 -0
- package/dist/enums/db/order-side.enum.d.ts +5 -0
- package/dist/enums/db/order-status.enum.d.ts +8 -0
- package/dist/enums/db/order-type.enum.d.ts +7 -0
- package/dist/enums/db/pending-actions.enum.d.ts +6 -0
- package/dist/enums/db/relayer.enum.d.ts +23 -0
- package/dist/enums/db/setting-type.enum.d.ts +8 -0
- package/dist/enums/db/social-action.enum.d.ts +24 -0
- package/dist/enums/db/social-prompt.enum.d.ts +8 -0
- package/dist/enums/db/social.enum.d.ts +10 -0
- package/dist/enums/db/state-type.enum.d.ts +9 -0
- package/dist/enums/db/trade.enums.d.ts +10 -0
- package/dist/enums/db/tradingKeyType.enum.d.ts +4 -0
- package/dist/enums/db/upgrade.enum.d.ts +5 -0
- package/dist/enums/db/withdrawal-wallet.enum.d.ts +5 -0
- package/dist/enums/index.d.ts +5 -0
- package/dist/enums/index.js +893 -0
- package/dist/enums/maintenanceMode.enum.d.ts +10 -0
- package/dist/enums/notification.enum.d.ts +7 -0
- package/dist/enums/social.enum.d.ts +10 -0
- package/dist/helpers/Encoding.d.ts +33 -0
- package/dist/helpers/Encoding.js +318 -0
- package/dist/helpers/algo.helper.d.ts +14 -0
- package/dist/helpers/algo.helper.js +1211 -0
- package/dist/helpers/api.helper.d.ts +16 -0
- package/dist/helpers/api.helper.js +1652 -0
- package/dist/helpers/assert.helper.d.ts +10 -0
- package/dist/helpers/assert.helper.js +1677 -0
- package/dist/helpers/atomic.helper.d.ts +21 -0
- package/dist/helpers/atomic.helper.js +712 -0
- package/dist/helpers/balance.helper.d.ts +13 -0
- package/dist/helpers/balance.helper.js +4330 -0
- package/dist/helpers/codex/common.helper.d.ts +24 -0
- package/dist/helpers/codex/common.helper.js +4246 -0
- package/dist/helpers/codex/index.d.ts +6 -0
- package/dist/helpers/codex/index.js +4246 -0
- package/dist/helpers/codex/mbr.helper.d.ts +6 -0
- package/dist/helpers/codex/mbr.helper.js +4246 -0
- package/dist/helpers/codex/mna.helper.d.ts +2 -0
- package/dist/helpers/codex/mna.helper.js +4246 -0
- package/dist/helpers/codex/order.helper.d.ts +6 -0
- package/dist/helpers/codex/order.helper.js +4246 -0
- package/dist/helpers/codex/setGlobal.helper.d.ts +27 -0
- package/dist/helpers/codex/setGlobal.helper.js +4312 -0
- package/dist/helpers/codex/transfer.helper.d.ts +21 -0
- package/dist/helpers/codex/transfer.helper.js +4246 -0
- package/dist/helpers/codex/txn.helper.d.ts +13 -0
- package/dist/helpers/codex/txn.helper.js +4246 -0
- package/dist/helpers/codex.helper.d.ts +106 -0
- package/dist/helpers/codex.helper.js +4246 -0
- package/dist/helpers/email.helper.d.ts +5 -0
- package/dist/helpers/email.helper.js +112 -0
- package/dist/helpers/eth.helper.d.ts +12 -0
- package/dist/helpers/eth.helper.js +4246 -0
- package/dist/helpers/hummingbots.helper.d.ts +2 -0
- package/dist/helpers/hummingbots.helper.js +163 -0
- package/dist/helpers/index.d.ts +5 -0
- package/dist/helpers/index.js +837 -0
- package/dist/helpers/interval.helpers.d.ts +9 -0
- package/dist/helpers/interval.helpers.js +110 -0
- package/dist/helpers/liquidity.helper.d.ts +6 -0
- package/dist/helpers/liquidity.helper.js +81 -0
- package/dist/helpers/order.helper.d.ts +7 -0
- package/dist/helpers/order.helper.js +946 -0
- package/dist/helpers/pair.helper.d.ts +9 -0
- package/dist/helpers/pair.helper.js +938 -0
- package/dist/helpers/pointSystem.helper.d.ts +14 -0
- package/dist/helpers/pointSystem.helper.js +392 -0
- package/dist/helpers/ticker.helpers.d.ts +8 -0
- package/dist/helpers/ticker.helpers.js +358 -0
- package/dist/helpers/vaa.helper.d.ts +2 -0
- package/dist/helpers/vaa.helper.js +4350 -0
- package/dist/helpers/withdraw.helper.d.ts +14 -0
- package/dist/helpers/withdraw.helper.js +4784 -0
- package/dist/interfaces/accountInfo.interface.d.ts +15 -0
- package/dist/interfaces/algostreamer/index.d.ts +49 -0
- package/dist/interfaces/api/affiliate.interface.d.ts +71 -0
- package/dist/interfaces/cache.interface.d.ts +25 -0
- package/dist/interfaces/confirmed-txn.interface.d.ts +46 -0
- package/dist/interfaces/controller.interface.d.ts +6 -0
- package/dist/interfaces/db/baseModel.interface.d.ts +5 -0
- package/dist/interfaces/db/hummingbot/index.d.ts +18 -0
- package/dist/interfaces/db/index.d.ts +10 -0
- package/dist/interfaces/db/market/index.d.ts +313 -0
- package/dist/interfaces/db/marketing/index.d.ts +48 -0
- package/dist/interfaces/db/notification_center/index.d.ts +33 -0
- package/dist/interfaces/db/relayer/index.d.ts +56 -0
- package/dist/interfaces/db/social/index.d.ts +188 -0
- package/dist/interfaces/db/softDeleteModel.interface.d.ts +4 -0
- package/dist/interfaces/db/white_label/index.d.ts +161 -0
- package/dist/interfaces/db/withdrawal_wallets/index.d.ts +12 -0
- package/dist/interfaces/dto/index.d.ts +62 -0
- package/dist/interfaces/emailService.interface.d.ts +4 -0
- package/dist/interfaces/index.d.ts +17 -0
- package/dist/interfaces/index.js +1319 -0
- package/dist/interfaces/kmsService.interface.d.ts +4 -0
- package/dist/interfaces/last-look-trade.interface.d.ts +10 -0
- package/dist/interfaces/market.interface.d.ts +17 -0
- package/dist/interfaces/order.interface.d.ts +162 -0
- package/dist/interfaces/pair.interface.d.ts +10 -0
- package/dist/interfaces/query.interface.d.ts +6 -0
- package/dist/interfaces/services/accountCache.interface.d.ts +15 -0
- package/dist/interfaces/services/algod.interface.d.ts +5 -0
- package/dist/interfaces/services/balances.interface.d.ts +11 -0
- package/dist/interfaces/services/coin-market-cap.interface.d.ts +124 -0
- package/dist/interfaces/services/index.d.ts +8 -0
- package/dist/interfaces/services/price-model.interface.d.ts +4 -0
- package/dist/interfaces/services/price-service.interface.d.ts +8 -0
- package/dist/interfaces/services/socialActivity.interface.d.ts +48 -0
- package/dist/interfaces/services/tmc.interface.d.ts +9 -0
- package/dist/interfaces/streaming.interface.d.ts +95 -0
- package/dist/interfaces/timestream.interface.d.ts +29 -0
- package/dist/interfaces/trading.interface.d.ts +235 -0
- package/dist/interfaces/tradingKey.interface.d.ts +26 -0
- package/dist/interfaces/transfer.interface.d.ts +12 -0
- package/dist/interfaces/wallet.interface.d.ts +89 -0
- package/dist/interfaces/withdrawalWallets.interface.d.ts +14 -0
- package/dist/types/algo-order.type.d.ts +10 -0
- package/dist/types/amm/amm.d.ts +163 -0
- package/dist/types/api/request.types.d.ts +99 -0
- package/dist/types/codex.types.d.ts +28 -0
- package/dist/types/hummingbots.types.d.ts +23 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.js +362 -0
- package/dist/types/notification.type.d.ts +10 -0
- package/dist/types/settings.type.d.ts +162 -0
- package/dist/types/state.type.d.ts +4 -0
- package/package.json +78 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare enum Operations {
|
|
2
|
+
MINUS = "-",
|
|
3
|
+
PLUS = "+",
|
|
4
|
+
MULTIPLY = "*",
|
|
5
|
+
DIVIDE = "/",
|
|
6
|
+
GREATER_THAN_OR_EQUAL = ">=",
|
|
7
|
+
GREATER_THAN = ">",
|
|
8
|
+
LESS_THAN_OR_EQUAL = "<=",
|
|
9
|
+
LESS_THAN = "<",
|
|
10
|
+
EQUAL = "==",
|
|
11
|
+
MOD = "mod"
|
|
12
|
+
}
|
|
13
|
+
export declare function absolute(value: number | string): string;
|
|
14
|
+
export declare function ceil(value: number | string): string;
|
|
15
|
+
export declare function toFixed(value: number | string, decimalPlaces: number, roundUpToFirstSignificant?: boolean): string;
|
|
16
|
+
export declare function floor(value: number | string): string;
|
|
17
|
+
export declare function round(value: number | string): string;
|
|
18
|
+
export declare function plus(value1: number | string | bigint, value2: number | string | bigint): string;
|
|
19
|
+
export declare function minus(value1: number | string | bigint, value2: number | string | bigint): string;
|
|
20
|
+
export declare function multiply(value1: number | string | bigint, value2: number | string | bigint): string;
|
|
21
|
+
export declare function toUsd(amount: string, price: number): string;
|
|
22
|
+
export declare function divide(value1: number | string | bigint, value2: number | string | bigint): string;
|
|
23
|
+
export declare function greaterThanOrEqual(value1: number | string | bigint, value2: number | string | bigint): boolean;
|
|
24
|
+
export declare function greaterThan(value1: number | string | bigint, value2: number | string | bigint): boolean;
|
|
25
|
+
export declare function lessThanOrEqual(value1: number | string | bigint, value2: number | string | bigint): boolean;
|
|
26
|
+
export declare function lessThan(value1: number | string | bigint, value2: number | string | bigint): boolean;
|
|
27
|
+
export declare function equal(value1: number | string | bigint, value2: number | string | bigint): boolean;
|
|
28
|
+
export declare function mod(value1: number | string | bigint, value2: number | string | bigint): string;
|
|
29
|
+
export declare function modZero(value1: number | string | bigint, value2: number | string | bigint): boolean;
|
|
30
|
+
export declare function bn_operation(a: any, b: any, operation: Operations): any;
|
|
31
|
+
export declare function roundNumber({ decimalPlaces }: {
|
|
32
|
+
decimalPlaces?: number;
|
|
33
|
+
}, x: number): number;
|
|
34
|
+
export declare function convertFromBaseUnits(assetDecimals: number | bigint, quantity: number | bigint): number;
|
|
35
|
+
/**
|
|
36
|
+
* Computs quantity * 10^(assetDecimals) and rounds the result
|
|
37
|
+
*/
|
|
38
|
+
export declare function convertToBaseUnits(assetDecimals: number | bigint, quantity: number | bigint): number;
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
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
|
|
12
|
+
/******/ "use strict";
|
|
13
|
+
/******/ var __webpack_modules__ = ({
|
|
14
|
+
|
|
15
|
+
/***/ 1174:
|
|
16
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
20
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
23
|
+
exports.Operations = void 0;
|
|
24
|
+
exports.absolute = absolute;
|
|
25
|
+
exports.ceil = ceil;
|
|
26
|
+
exports.toFixed = toFixed;
|
|
27
|
+
exports.floor = floor;
|
|
28
|
+
exports.round = round;
|
|
29
|
+
exports.plus = plus;
|
|
30
|
+
exports.minus = minus;
|
|
31
|
+
exports.multiply = multiply;
|
|
32
|
+
exports.toUsd = toUsd;
|
|
33
|
+
exports.divide = divide;
|
|
34
|
+
exports.greaterThanOrEqual = greaterThanOrEqual;
|
|
35
|
+
exports.greaterThan = greaterThan;
|
|
36
|
+
exports.lessThanOrEqual = lessThanOrEqual;
|
|
37
|
+
exports.lessThan = lessThan;
|
|
38
|
+
exports.equal = equal;
|
|
39
|
+
exports.mod = mod;
|
|
40
|
+
exports.modZero = modZero;
|
|
41
|
+
exports.bn_operation = bn_operation;
|
|
42
|
+
exports.roundNumber = roundNumber;
|
|
43
|
+
exports.convertFromBaseUnits = convertFromBaseUnits;
|
|
44
|
+
exports.convertToBaseUnits = convertToBaseUnits;
|
|
45
|
+
const bignumber_js_1 = __importDefault(__webpack_require__(6168));
|
|
46
|
+
bignumber_js_1.default.config({ DECIMAL_PLACES: 40, EXPONENTIAL_AT: 45 });
|
|
47
|
+
var Operations;
|
|
48
|
+
(function (Operations) {
|
|
49
|
+
Operations["MINUS"] = "-";
|
|
50
|
+
Operations["PLUS"] = "+";
|
|
51
|
+
Operations["MULTIPLY"] = "*";
|
|
52
|
+
Operations["DIVIDE"] = "/";
|
|
53
|
+
Operations["GREATER_THAN_OR_EQUAL"] = ">=";
|
|
54
|
+
Operations["GREATER_THAN"] = ">";
|
|
55
|
+
Operations["LESS_THAN_OR_EQUAL"] = "<=";
|
|
56
|
+
Operations["LESS_THAN"] = "<";
|
|
57
|
+
Operations["EQUAL"] = "==";
|
|
58
|
+
Operations["MOD"] = "mod";
|
|
59
|
+
})(Operations || (exports.Operations = Operations = {}));
|
|
60
|
+
function absolute(value) {
|
|
61
|
+
let x = new bignumber_js_1.default(value);
|
|
62
|
+
const res = x.abs().toString();
|
|
63
|
+
// console.log('Absolute value', { value, res })
|
|
64
|
+
return res;
|
|
65
|
+
}
|
|
66
|
+
function ceil(value) {
|
|
67
|
+
let x = new bignumber_js_1.default(String(value));
|
|
68
|
+
const res = x.integerValue(bignumber_js_1.default.ROUND_CEIL).toString();
|
|
69
|
+
if (!equal(value, res)) {
|
|
70
|
+
console.log('Ceil value', { value, res });
|
|
71
|
+
}
|
|
72
|
+
return res;
|
|
73
|
+
}
|
|
74
|
+
function toFixed(value, decimalPlaces, roundUpToFirstSignificant = false) {
|
|
75
|
+
const x = new bignumber_js_1.default(String(value));
|
|
76
|
+
let res;
|
|
77
|
+
if (roundUpToFirstSignificant) {
|
|
78
|
+
const valueStr = x.toFixed();
|
|
79
|
+
const decimalIndex = valueStr.indexOf('.');
|
|
80
|
+
if (decimalIndex >= 0) {
|
|
81
|
+
const fractionalPart = valueStr.slice(decimalIndex + 1);
|
|
82
|
+
let leadingZeros = 0;
|
|
83
|
+
for (let char of fractionalPart) {
|
|
84
|
+
if (char === '0') {
|
|
85
|
+
leadingZeros++;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const totalDecimalPlaces = leadingZeros + 1;
|
|
92
|
+
res = x.toFixed(totalDecimalPlaces, bignumber_js_1.default.ROUND_UP);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
res = x.toFixed(0);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
res = x.toFixed(decimalPlaces);
|
|
100
|
+
}
|
|
101
|
+
console.log('Fixed value', { value, res });
|
|
102
|
+
return res;
|
|
103
|
+
}
|
|
104
|
+
function floor(value) {
|
|
105
|
+
let x = new bignumber_js_1.default(String(value));
|
|
106
|
+
const res = x.integerValue(bignumber_js_1.default.ROUND_FLOOR).toString();
|
|
107
|
+
console.log('Floor value', { value, res });
|
|
108
|
+
return res;
|
|
109
|
+
}
|
|
110
|
+
function round(value) {
|
|
111
|
+
let x = new bignumber_js_1.default(String(value));
|
|
112
|
+
const res = x.integerValue(bignumber_js_1.default.ROUND_HALF_UP).toString();
|
|
113
|
+
console.log('Round value', { value, res });
|
|
114
|
+
return res;
|
|
115
|
+
}
|
|
116
|
+
function plus(value1, value2) {
|
|
117
|
+
return bn_operation(value1, value2, Operations.PLUS);
|
|
118
|
+
}
|
|
119
|
+
function minus(value1, value2) {
|
|
120
|
+
return bn_operation(value1, value2, Operations.MINUS);
|
|
121
|
+
}
|
|
122
|
+
function multiply(value1, value2) {
|
|
123
|
+
return bn_operation(value1, value2, Operations.MULTIPLY);
|
|
124
|
+
}
|
|
125
|
+
function toUsd(amount, price) {
|
|
126
|
+
return multiply(amount, price || 0);
|
|
127
|
+
}
|
|
128
|
+
;
|
|
129
|
+
function divide(value1, value2) {
|
|
130
|
+
return bn_operation(value1, value2, Operations.DIVIDE);
|
|
131
|
+
}
|
|
132
|
+
function greaterThanOrEqual(value1, value2) {
|
|
133
|
+
return Boolean(bn_operation(value1, value2, Operations.GREATER_THAN_OR_EQUAL));
|
|
134
|
+
}
|
|
135
|
+
function greaterThan(value1, value2) {
|
|
136
|
+
return Boolean(bn_operation(value1, value2, Operations.GREATER_THAN));
|
|
137
|
+
}
|
|
138
|
+
function lessThanOrEqual(value1, value2) {
|
|
139
|
+
return Boolean(bn_operation(value1, value2, Operations.LESS_THAN_OR_EQUAL));
|
|
140
|
+
}
|
|
141
|
+
function lessThan(value1, value2) {
|
|
142
|
+
return Boolean(bn_operation(value1, value2, Operations.LESS_THAN));
|
|
143
|
+
}
|
|
144
|
+
function equal(value1, value2) {
|
|
145
|
+
return Boolean(bn_operation(value1, value2, Operations.EQUAL));
|
|
146
|
+
}
|
|
147
|
+
function mod(value1, value2) {
|
|
148
|
+
return bn_operation(value1, value2, Operations.MOD);
|
|
149
|
+
}
|
|
150
|
+
function modZero(value1, value2) {
|
|
151
|
+
return equal(mod(value1, value2), 0);
|
|
152
|
+
}
|
|
153
|
+
function bn_operation(a, b, operation) {
|
|
154
|
+
a = new bignumber_js_1.default(String(a));
|
|
155
|
+
b = new bignumber_js_1.default(String(b));
|
|
156
|
+
switch (operation.toLowerCase()) {
|
|
157
|
+
case '-':
|
|
158
|
+
return a.minus(b).toString();
|
|
159
|
+
case '+':
|
|
160
|
+
return a.plus(b).toString();
|
|
161
|
+
case '*':
|
|
162
|
+
case 'x':
|
|
163
|
+
return a.multipliedBy(b).toString();
|
|
164
|
+
case '÷':
|
|
165
|
+
case '/':
|
|
166
|
+
return a.dividedBy(b).toString();
|
|
167
|
+
case '>=':
|
|
168
|
+
return a.isGreaterThanOrEqualTo(b);
|
|
169
|
+
case '>':
|
|
170
|
+
return a.isGreaterThan(b);
|
|
171
|
+
case '<=':
|
|
172
|
+
return a.isLessThanOrEqualTo(b);
|
|
173
|
+
case '<':
|
|
174
|
+
return a.isLessThan(b);
|
|
175
|
+
case '==':
|
|
176
|
+
return a.isEqualTo(b);
|
|
177
|
+
case 'mod':
|
|
178
|
+
return a.modulo(b);
|
|
179
|
+
default:
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function getExponentialNumberComponents(x) {
|
|
184
|
+
if (x.toString().includes('e')) {
|
|
185
|
+
const parts = x.toString().split('e');
|
|
186
|
+
return [parseFloat(parts[0]), parseFloat(parts[1])];
|
|
187
|
+
}
|
|
188
|
+
return [x, 0];
|
|
189
|
+
}
|
|
190
|
+
function generateExponentialNumberFromComponents(decimalPart, exponent) {
|
|
191
|
+
return decimalPart + (exponent < 0 ? `e${exponent}` : `e+${exponent}`);
|
|
192
|
+
}
|
|
193
|
+
function roundNumber({ decimalPlaces = 0 }, x) {
|
|
194
|
+
if (decimalPlaces > 0) {
|
|
195
|
+
const [decimal, decimalExponentialPart] = getExponentialNumberComponents(x);
|
|
196
|
+
const [rounded, roundedExponentialPart] = getExponentialNumberComponents(Math.round(Number(generateExponentialNumberFromComponents(decimal, decimalExponentialPart + decimalPlaces))));
|
|
197
|
+
return Number(generateExponentialNumberFromComponents(rounded, roundedExponentialPart - decimalPlaces));
|
|
198
|
+
}
|
|
199
|
+
return Math.round(x);
|
|
200
|
+
}
|
|
201
|
+
function convertFromBaseUnits(assetDecimals, quantity) {
|
|
202
|
+
const decimals = Number(assetDecimals);
|
|
203
|
+
return roundNumber({ decimalPlaces: decimals },
|
|
204
|
+
// eslint-disable-next-line no-magic-numbers
|
|
205
|
+
Math.pow(10, -decimals) * Number(quantity));
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Computs quantity * 10^(assetDecimals) and rounds the result
|
|
209
|
+
*/
|
|
210
|
+
function convertToBaseUnits(assetDecimals, quantity) {
|
|
211
|
+
// eslint-disable-next-line no-magic-numbers
|
|
212
|
+
const baseAmount = Math.pow(10, Number(assetDecimals)) * Number(quantity);
|
|
213
|
+
// 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
|
|
214
|
+
return roundNumber({ decimalPlaces: 0 }, baseAmount);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
/***/ }),
|
|
219
|
+
|
|
220
|
+
/***/ 6168:
|
|
221
|
+
/***/ ((module) => {
|
|
222
|
+
|
|
223
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__6168__;
|
|
224
|
+
|
|
225
|
+
/***/ })
|
|
226
|
+
|
|
227
|
+
/******/ });
|
|
228
|
+
/************************************************************************/
|
|
229
|
+
/******/ // The module cache
|
|
230
|
+
/******/ var __webpack_module_cache__ = {};
|
|
231
|
+
/******/
|
|
232
|
+
/******/ // The require function
|
|
233
|
+
/******/ function __webpack_require__(moduleId) {
|
|
234
|
+
/******/ // Check if module is in cache
|
|
235
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
236
|
+
/******/ if (cachedModule !== undefined) {
|
|
237
|
+
/******/ return cachedModule.exports;
|
|
238
|
+
/******/ }
|
|
239
|
+
/******/ // Create a new module (and put it into the cache)
|
|
240
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
241
|
+
/******/ // no module.id needed
|
|
242
|
+
/******/ // no module.loaded needed
|
|
243
|
+
/******/ exports: {}
|
|
244
|
+
/******/ };
|
|
245
|
+
/******/
|
|
246
|
+
/******/ // Execute the module function
|
|
247
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
248
|
+
/******/
|
|
249
|
+
/******/ // Return the exports of the module
|
|
250
|
+
/******/ return module.exports;
|
|
251
|
+
/******/ }
|
|
252
|
+
/******/
|
|
253
|
+
/************************************************************************/
|
|
254
|
+
/******/
|
|
255
|
+
/******/ // startup
|
|
256
|
+
/******/ // Load entry module and return exports
|
|
257
|
+
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
258
|
+
/******/ var __webpack_exports__ = __webpack_require__(1174);
|
|
259
|
+
/******/
|
|
260
|
+
/******/ return __webpack_exports__;
|
|
261
|
+
/******/ })()
|
|
262
|
+
;
|
|
263
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './mappers';
|
|
2
|
+
export * from './utils';
|
|
3
|
+
export * from './auth.helper';
|
|
4
|
+
export * from './awsKms';
|
|
5
|
+
export * from './big-number.helper';
|
|
6
|
+
export * from './indexer.helper';
|
|
7
|
+
export * from './logger';
|
|
8
|
+
export * from './migration.helpers';
|
|
9
|
+
export * from './redis.helper';
|
|
10
|
+
export * from './secret.helper';
|
|
11
|
+
export * from './timestamp.helper';
|