@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,9 @@
|
|
|
1
|
+
import { DatepartType } from "../types";
|
|
2
|
+
export declare function getDatepartValue(value: string): {
|
|
3
|
+
datepart: DatepartType;
|
|
4
|
+
value: number;
|
|
5
|
+
timeframe: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function identityDatepart(interval: string): DatepartType | null;
|
|
8
|
+
export declare function inMinCandles(value: number): boolean;
|
|
9
|
+
export declare function inHourCandles(value: number): boolean;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory();
|
|
4
|
+
else if(typeof define === 'function' && define.amd)
|
|
5
|
+
define([], factory);
|
|
6
|
+
else {
|
|
7
|
+
var a = factory();
|
|
8
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
9
|
+
}
|
|
10
|
+
})(global, () => {
|
|
11
|
+
return /******/ (() => { // webpackBootstrap
|
|
12
|
+
/******/ "use strict";
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
// This entry needs to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
|
|
15
|
+
(() => {
|
|
16
|
+
var exports = __webpack_exports__;
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
19
|
+
exports.getDatepartValue = getDatepartValue;
|
|
20
|
+
exports.identityDatepart = identityDatepart;
|
|
21
|
+
exports.inMinCandles = inMinCandles;
|
|
22
|
+
exports.inHourCandles = inHourCandles;
|
|
23
|
+
const intervalRegex = {
|
|
24
|
+
hour: /(\d+)[H]/i,
|
|
25
|
+
day: /(\d+)[D]/i,
|
|
26
|
+
week: /(\d+)[W]/i,
|
|
27
|
+
month: /(\d+)[M]/i,
|
|
28
|
+
year: /(\d+)[Y]/i,
|
|
29
|
+
};
|
|
30
|
+
function getDatepartValue(value) {
|
|
31
|
+
const datepart = identityDatepart(value);
|
|
32
|
+
if (datepart === null) {
|
|
33
|
+
throw new Error(`Cannot fetch datepart from interval: ${value}`);
|
|
34
|
+
}
|
|
35
|
+
const units = datepart === 'minute' ? Number(value) : Number(value.slice(0, -1));
|
|
36
|
+
if (!units) {
|
|
37
|
+
return mapWithTimeframe(datepart, 1);
|
|
38
|
+
}
|
|
39
|
+
if (datepart === 'minute' && units % (7 * 24 * 60) === 0) { // week
|
|
40
|
+
return mapWithTimeframe('week', units / (7 * 24 * 60));
|
|
41
|
+
}
|
|
42
|
+
if (datepart === 'minute' && units % (24 * 60) === 0) { // day
|
|
43
|
+
return mapWithTimeframe('day', units / (24 * 60));
|
|
44
|
+
}
|
|
45
|
+
if (datepart === 'minute' && units % 60 === 0) { // hour
|
|
46
|
+
return mapWithTimeframe('hour', units / 60);
|
|
47
|
+
}
|
|
48
|
+
if (datepart === 'hour' && units % (7 * 24) === 0) { // week
|
|
49
|
+
return mapWithTimeframe('week', units / (7 * 24));
|
|
50
|
+
}
|
|
51
|
+
if (datepart === 'hour' && units % 24 === 0) { // day
|
|
52
|
+
return mapWithTimeframe(units === 24 ? 'hour' : 'day', units === 24 ? 24 : units / 24);
|
|
53
|
+
}
|
|
54
|
+
if (datepart === 'day' && units % 7 === 0) { // week
|
|
55
|
+
return mapWithTimeframe('week', units / 7);
|
|
56
|
+
}
|
|
57
|
+
if (datepart === 'month' && units % 12 === 0) { // year
|
|
58
|
+
return mapWithTimeframe('year', units / 12);
|
|
59
|
+
}
|
|
60
|
+
return mapWithTimeframe(datepart, units);
|
|
61
|
+
}
|
|
62
|
+
function identityDatepart(interval) {
|
|
63
|
+
if (!isNaN(Number(interval))) {
|
|
64
|
+
return 'minute';
|
|
65
|
+
}
|
|
66
|
+
const lastLetter = interval.slice(-1);
|
|
67
|
+
const value = `1${lastLetter}`;
|
|
68
|
+
switch (true) {
|
|
69
|
+
case intervalRegex.hour.test(value): return 'hour';
|
|
70
|
+
case intervalRegex.day.test(value): return 'day';
|
|
71
|
+
case intervalRegex.week.test(value): return 'week';
|
|
72
|
+
case intervalRegex.month.test(value): return 'month';
|
|
73
|
+
case intervalRegex.year.test(value): return 'year';
|
|
74
|
+
default: return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function mapWithTimeframe(datepart, value) {
|
|
78
|
+
return { datepart, value, timeframe: mapDatepartToTimeframe(datepart, value) };
|
|
79
|
+
}
|
|
80
|
+
function inMinCandles(value) {
|
|
81
|
+
return [1, 3, 5, 15, 30].includes(value);
|
|
82
|
+
}
|
|
83
|
+
function inHourCandles(value) {
|
|
84
|
+
return [1, 2, 3, 4, 12].includes(value);
|
|
85
|
+
}
|
|
86
|
+
function mapDatepartToTimeframe(datepart, value) {
|
|
87
|
+
switch (datepart) {
|
|
88
|
+
case 'minute':
|
|
89
|
+
return inMinCandles(value) ? `${value}m` : '1m';
|
|
90
|
+
case 'hour':
|
|
91
|
+
return inHourCandles(value) ? `${value}h` : '1h';
|
|
92
|
+
case 'day':
|
|
93
|
+
return `1d`;
|
|
94
|
+
case 'week':
|
|
95
|
+
return `1w`;
|
|
96
|
+
case 'month':
|
|
97
|
+
return `1M`;
|
|
98
|
+
case 'year':
|
|
99
|
+
return `1Y`;
|
|
100
|
+
default:
|
|
101
|
+
throw new Error(`Unsupported datepart: ${datepart}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
})();
|
|
106
|
+
|
|
107
|
+
/******/ return __webpack_exports__;
|
|
108
|
+
/******/ })()
|
|
109
|
+
;
|
|
110
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
/***/ 6168:
|
|
16
|
+
/***/ ((module) => {
|
|
17
|
+
|
|
18
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__6168__;
|
|
19
|
+
|
|
20
|
+
/***/ }),
|
|
21
|
+
|
|
22
|
+
/***/ 6810:
|
|
23
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
30
|
+
exports.computeLiquidityUsd = computeLiquidityUsd;
|
|
31
|
+
const bignumber_js_1 = __importDefault(__webpack_require__(6168));
|
|
32
|
+
function computeLiquidityUsd(opts) {
|
|
33
|
+
const { buy, sell, baseDec, baseUsd } = opts;
|
|
34
|
+
const sumQuoteRaw = buy.reduce((acc, [_, amount]) => acc.plus(new bignumber_js_1.default(amount)), new bignumber_js_1.default(0));
|
|
35
|
+
const asksBaseTokens = sell.reduce((acc, [, amount]) => acc.plus(new bignumber_js_1.default(amount)), new bignumber_js_1.default(0));
|
|
36
|
+
const liquidity = sumQuoteRaw.plus(asksBaseTokens).dividedBy(new bignumber_js_1.default(10).pow(baseDec));
|
|
37
|
+
const liquidityUsd = liquidity.multipliedBy(baseUsd);
|
|
38
|
+
const usdCeil = liquidityUsd.integerValue(bignumber_js_1.default.ROUND_CEIL);
|
|
39
|
+
return usdCeil.toNumber();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
/***/ })
|
|
44
|
+
|
|
45
|
+
/******/ });
|
|
46
|
+
/************************************************************************/
|
|
47
|
+
/******/ // The module cache
|
|
48
|
+
/******/ var __webpack_module_cache__ = {};
|
|
49
|
+
/******/
|
|
50
|
+
/******/ // The require function
|
|
51
|
+
/******/ function __webpack_require__(moduleId) {
|
|
52
|
+
/******/ // Check if module is in cache
|
|
53
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
54
|
+
/******/ if (cachedModule !== undefined) {
|
|
55
|
+
/******/ return cachedModule.exports;
|
|
56
|
+
/******/ }
|
|
57
|
+
/******/ // Create a new module (and put it into the cache)
|
|
58
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
59
|
+
/******/ // no module.id needed
|
|
60
|
+
/******/ // no module.loaded needed
|
|
61
|
+
/******/ exports: {}
|
|
62
|
+
/******/ };
|
|
63
|
+
/******/
|
|
64
|
+
/******/ // Execute the module function
|
|
65
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
66
|
+
/******/
|
|
67
|
+
/******/ // Return the exports of the module
|
|
68
|
+
/******/ return module.exports;
|
|
69
|
+
/******/ }
|
|
70
|
+
/******/
|
|
71
|
+
/************************************************************************/
|
|
72
|
+
/******/
|
|
73
|
+
/******/ // startup
|
|
74
|
+
/******/ // Load entry module and return exports
|
|
75
|
+
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
76
|
+
/******/ var __webpack_exports__ = __webpack_require__(6810);
|
|
77
|
+
/******/
|
|
78
|
+
/******/ return __webpack_exports__;
|
|
79
|
+
/******/ })()
|
|
80
|
+
;
|
|
81
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OrderSide, OrderType } from "@enums";
|
|
2
|
+
import { OrderSideShort, OrderTypeShort } from "../interfaces/order.interface";
|
|
3
|
+
export declare function mapOrderSideFromShort(value: OrderSideShort): OrderSide;
|
|
4
|
+
export declare function mapOrderSideToShort(value: OrderSide): OrderSideShort;
|
|
5
|
+
export declare function mapOrderTypeShort(value: OrderTypeShort): OrderType;
|
|
6
|
+
export declare function mapOrderSideFromShortToLong(value: OrderSideShort): string;
|
|
7
|
+
export declare function mapOrderTypeShortToLong(value: OrderTypeShort): string;
|