@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.
Files changed (58) hide show
  1. package/dist/common/auth.helper.js +16 -37
  2. package/dist/common/awsKms.js +9 -19
  3. package/dist/common/big-number.helper.d.ts +0 -3
  4. package/dist/common/big-number.helper.js +7 -26
  5. package/dist/common/index.js +65 -107
  6. package/dist/common/indexer.helper.js +9 -19
  7. package/dist/common/logger.js +6 -16
  8. package/dist/common/mappers/codexAsset.mapper.js +3 -14
  9. package/dist/common/mappers/codexBalance.mapper.js +3 -14
  10. package/dist/common/mappers/index.js +15 -35
  11. package/dist/common/mappers/trade.mapper.js +15 -35
  12. package/dist/common/migration.helpers.js +3 -14
  13. package/dist/common/redis.helper.js +20 -40
  14. package/dist/common/secret.helper.js +11 -26
  15. package/dist/common/timestamp.helper.js +3 -14
  16. package/dist/common/utils/assert.js +3 -14
  17. package/dist/common/utils/decode.js +6 -17
  18. package/dist/common/utils/index.js +4 -15
  19. package/dist/common/utils/social.js +3 -14
  20. package/dist/common/utils/stat.js +7 -26
  21. package/dist/constants/index.js +3 -14
  22. package/dist/enums/index.js +3 -14
  23. package/dist/helpers/Encoding.js +10 -31
  24. package/dist/helpers/algo.helper.js +44 -82
  25. package/dist/helpers/assert.helper.js +13 -34
  26. package/dist/helpers/atomic.helper.d.ts +0 -17
  27. package/dist/helpers/atomic.helper.js +7 -43
  28. package/dist/helpers/balance.helper.js +71 -166
  29. package/dist/helpers/codex/common.helper.js +71 -149
  30. package/dist/helpers/codex/index.js +71 -149
  31. package/dist/helpers/codex/mbr.helper.js +71 -149
  32. package/dist/helpers/codex/mna.helper.js +71 -149
  33. package/dist/helpers/codex/order.helper.js +71 -149
  34. package/dist/helpers/codex/setGlobal.helper.js +73 -151
  35. package/dist/helpers/codex/transfer.helper.js +71 -149
  36. package/dist/helpers/codex/txn.helper.js +71 -149
  37. package/dist/helpers/codex.helper.js +71 -149
  38. package/dist/helpers/email.helper.js +6 -17
  39. package/dist/helpers/eth.helper.js +71 -149
  40. package/dist/helpers/hummingbots.helper.js +11 -22
  41. package/dist/helpers/index.js +31 -58
  42. package/dist/helpers/interval.helpers.js +10 -21
  43. package/dist/helpers/liquidity.helper.js +6 -17
  44. package/dist/helpers/order.helper.js +3 -14
  45. package/dist/helpers/pair.helper.js +3 -14
  46. package/dist/helpers/pointSystem.helper.js +15 -33
  47. package/dist/helpers/ticker.helpers.js +7 -27
  48. package/dist/helpers/vaa.helper.js +97 -175
  49. package/dist/helpers/withdraw.helper.js +97 -167
  50. package/dist/interfaces/db/market/index.d.ts +34 -6
  51. package/dist/interfaces/db/white_label/index.d.ts +3 -3
  52. package/dist/interfaces/index.js +11 -14
  53. package/dist/types/index.js +15 -33
  54. package/package.json +16 -8
  55. package/dist/baseModel/base.model.d.ts +0 -26
  56. package/dist/baseModel/index.d.ts +0 -2
  57. package/dist/helpers/api.helper.d.ts +0 -16
  58. package/dist/helpers/api.helper.js +0 -1652
@@ -1,24 +1,7 @@
1
- (function webpackUniversalModuleDefinition(root, factory) {
2
- if(typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory(require("buffer"), require("ethereumjs-util"), require("bs58"), require("bignumber.js"), require("algosdk"));
4
- else if(typeof define === 'function' && define.amd)
5
- define(["buffer", "ethereumjs-util", "bs58", "bignumber.js", "algosdk"], factory);
6
- else {
7
- var a = typeof exports === 'object' ? factory(require("buffer"), require("ethereumjs-util"), require("bs58"), require("bignumber.js"), require("algosdk")) : factory(root["buffer"], root["ethereumjs-util"], root["bs58"], root["bignumber.js"], root["algosdk"]);
8
- for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
9
- }
10
- })(global, (__WEBPACK_EXTERNAL_MODULE__18__, __WEBPACK_EXTERNAL_MODULE__1297__, __WEBPACK_EXTERNAL_MODULE__4578__, __WEBPACK_EXTERNAL_MODULE__6168__, __WEBPACK_EXTERNAL_MODULE__9709__) => {
11
- return /******/ (() => { // webpackBootstrap
1
+ /******/ (() => { // webpackBootstrap
12
2
  /******/ "use strict";
13
3
  /******/ var __webpack_modules__ = ({
14
4
 
15
- /***/ 18:
16
- /***/ ((module) => {
17
-
18
- module.exports = __WEBPACK_EXTERNAL_MODULE__18__;
19
-
20
- /***/ }),
21
-
22
5
  /***/ 223:
23
6
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
24
7
 
@@ -63,8 +46,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
63
46
  exports.unified_CCTP_ChainID = exports.unified_CCTP_token = exports.encodeAddress = exports.getProviderChainId = exports.getPrefixedMessage = exports.getPublicKey = exports.decodeSignature = exports.getMsgArgs = exports.getDataBytesFromMsg = exports.getAppArgs = exports.getBoxKeyFromHash = exports.getBoxKey = exports.generateHash = void 0;
64
47
  exports.getUnifiedUSDC = getUnifiedUSDC;
65
48
  exports.getUnifiedUSDCToken = getUnifiedUSDCToken;
66
- const algosdk_1 = __importDefault(__webpack_require__(9709));
67
- const bs58 = __importStar(__webpack_require__(4578));
49
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
50
+ const bs58 = __importStar(__webpack_require__(5316));
68
51
  const algoHelper = __importStar(__webpack_require__(6897));
69
52
  const ethHelper = __importStar(__webpack_require__(9019));
70
53
  const codex_helper_1 = __webpack_require__(3955);
@@ -100,8 +83,6 @@ const getAppArgs = (methodSignature, args) => {
100
83
  txnArgsLog[`txnArgs${index}`] = Array.apply([], Array.from(v)).join(", ");
101
84
  return v;
102
85
  });
103
- // console.log('getAppArgs', methodSignature, JSON.stringify(txnArgsLog));
104
- // console.log('TOTAL TXN ARGS BYTES', txnArgs.reduce((prev, curr: Uint8Array | Buffer) => curr.length + prev, 0));
105
86
  return [selector, ...txnArgs];
106
87
  };
107
88
  exports.getAppArgs = getAppArgs;
@@ -119,7 +100,6 @@ const getMsgArgs = (message, signature, signerAddress, signerChainId, encoding =
119
100
  (0, exports.decodeSignature)(signature, signerChainId),
120
101
  (0, exports.getPublicKey)(signerAddress, signerChainId, message, signature, encoding),
121
102
  ];
122
- // console.log('MSG ARGS', msgArgs)
123
103
  return msgArgs;
124
104
  };
125
105
  exports.getMsgArgs = getMsgArgs;
@@ -317,7 +297,6 @@ function groupTickersByInterval(tickers, newIntervalInSec, endTimeInSec) {
317
297
  const newGroupedTickers = [];
318
298
  let timestamp = endTimeInSec - newIntervalInSec;
319
299
  let slot = null;
320
- // desc direction by timestamp
321
300
  const sortedTickers = tickers.sort((a, b) => b.t - a.t);
322
301
  for (let i = 0; i < sortedTickers.length; i++) {
323
302
  const element = sortedTickers[i];
@@ -629,7 +608,7 @@ exports.bn_operation = bn_operation;
629
608
  exports.roundNumber = roundNumber;
630
609
  exports.convertFromBaseUnits = convertFromBaseUnits;
631
610
  exports.convertToBaseUnits = convertToBaseUnits;
632
- const bignumber_js_1 = __importDefault(__webpack_require__(6168));
611
+ const bignumber_js_1 = __importDefault(__webpack_require__(4978));
633
612
  bignumber_js_1.default.config({ DECIMAL_PLACES: 40, EXPONENTIAL_AT: 45 });
634
613
  var Operations;
635
614
  (function (Operations) {
@@ -647,7 +626,6 @@ var Operations;
647
626
  function absolute(value) {
648
627
  let x = new bignumber_js_1.default(value);
649
628
  const res = x.abs().toString();
650
- // console.log('Absolute value', { value, res })
651
629
  return res;
652
630
  }
653
631
  function ceil(value) {
@@ -787,17 +765,10 @@ function roundNumber({ decimalPlaces = 0 }, x) {
787
765
  }
788
766
  function convertFromBaseUnits(assetDecimals, quantity) {
789
767
  const decimals = Number(assetDecimals);
790
- return roundNumber({ decimalPlaces: decimals },
791
- // eslint-disable-next-line no-magic-numbers
792
- Math.pow(10, -decimals) * Number(quantity));
768
+ return roundNumber({ decimalPlaces: decimals }, Math.pow(10, -decimals) * Number(quantity));
793
769
  }
794
- /**
795
- * Computs quantity * 10^(assetDecimals) and rounds the result
796
- */
797
770
  function convertToBaseUnits(assetDecimals, quantity) {
798
- // eslint-disable-next-line no-magic-numbers
799
771
  const baseAmount = Math.pow(10, Number(assetDecimals)) * Number(quantity);
800
- // 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
801
772
  return roundNumber({ decimalPlaces: 0 }, baseAmount);
802
773
  }
803
774
 
@@ -822,13 +793,6 @@ var StateType;
822
793
  })(StateType || (exports.StateType = StateType = {}));
823
794
 
824
795
 
825
- /***/ }),
826
-
827
- /***/ 1297:
828
- /***/ ((module) => {
829
-
830
- module.exports = __WEBPACK_EXTERNAL_MODULE__1297__;
831
-
832
796
  /***/ }),
833
797
 
834
798
  /***/ 1492:
@@ -877,7 +841,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
877
841
  };
878
842
  Object.defineProperty(exports, "__esModule", ({ value: true }));
879
843
  exports.makeSetGlobalTxn = exports.AppGlobalParamType = exports.AppGlobalParamName = exports.SuperAppGlobalParamName = void 0;
880
- const algosdk_1 = __importDefault(__webpack_require__(9709));
844
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
881
845
  const algo_helper_1 = __webpack_require__(6897);
882
846
  const codex_helper_1 = __webpack_require__(3955);
883
847
  const common_helper_1 = __webpack_require__(223);
@@ -916,7 +880,7 @@ const makeSetGlobalTxn = async (algoClient, superAppId, sender, name, value, typ
916
880
  params.fee = 1000;
917
881
  const encodedValue = type === AppGlobalParamType.NUMBER ? (0, codex_helper_1.encode)(value, '8B')
918
882
  : type === AppGlobalParamType.ADDRESS ? algosdk_1.default.decodeAddress(value).publicKey
919
- : /*type === AppGlobalParamType.STRING*/ (0, codex_helper_1.encode)(value, 'str');
883
+ : (0, codex_helper_1.encode)(value, 'str');
920
884
  const txn = algosdk_1.default.makeApplicationNoOpTxnFromObject({
921
885
  appIndex: superAppId,
922
886
  from: sender,
@@ -1384,7 +1348,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1384
1348
  };
1385
1349
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1386
1350
  exports.makeTransferTxn = exports.makeTransferMsg = exports.decodeTransferMsg = exports.makeDtwMsg = exports.decodeDtwMsg = exports.getTransferBytesFromMsg = exports.calcTransferHash = exports.getTransferBoxKeyFromHash = exports.getTransferBoxKey = exports.TRANSFER_DATA_BYTES_LENGTH = exports.DTW_DATA_BYTES_LENGTH = void 0;
1387
- const algosdk_1 = __importDefault(__webpack_require__(9709));
1351
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
1388
1352
  const enums_1 = __webpack_require__(9965);
1389
1353
  const codex_helper_1 = __webpack_require__(3955);
1390
1354
  const Encoding_1 = __webpack_require__(8593);
@@ -1436,7 +1400,6 @@ const makeDtwMsg = (data) => {
1436
1400
  const bs64OrderBytes = (0, codex_helper_1.getBase64EncodedData)(dataBytes);
1437
1401
  console.log(`Dtw data should be ${exports.DTW_DATA_BYTES_LENGTH} bytes`, bs64OrderBytes.length, bs64OrderBytes);
1438
1402
  return bs64OrderBytes;
1439
- // return makeSigningMessage(JSON.stringify(data), dataBytes);
1440
1403
  };
1441
1404
  exports.makeDtwMsg = makeDtwMsg;
1442
1405
  const decodeTransferMsg = (message, encoding = 'hex') => {
@@ -1473,7 +1436,6 @@ const makeTransferMsg = (data) => {
1473
1436
  const bs64OrderBytes = (0, codex_helper_1.getBase64EncodedData)(dataBytes);
1474
1437
  console.log(`Transfer data should be ${exports.TRANSFER_DATA_BYTES_LENGTH} bytes`, bs64OrderBytes.length, bs64OrderBytes);
1475
1438
  return bs64OrderBytes;
1476
- // return makeSigningMessage(JSON.stringify(data), dataBytes);
1477
1439
  };
1478
1440
  exports.makeTransferMsg = makeTransferMsg;
1479
1441
  const makeTransferTxn = async ({ data, message, signature }, dtw, options) => {
@@ -1523,7 +1485,6 @@ const makeTransferTxn = async ({ data, message, signature }, dtw, options) => {
1523
1485
  foreignApps,
1524
1486
  boxes: allBoxes,
1525
1487
  });
1526
- // console.log('directTransfer txn', appCallTxn);
1527
1488
  return appCallTxn;
1528
1489
  };
1529
1490
  exports.makeTransferTxn = makeTransferTxn;
@@ -1697,8 +1658,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
1697
1658
  exports.createBoxes = exports.getTokenBoxKey = exports.getPairBoxKey = exports.decodeCreateOrderMsg = exports.getCancelOrderDataJsonBytes = exports.makeCreateOrderMsg = exports.makeDepositMsg = exports.makeDepositTxns = exports.makeAssetOptInTxn = exports.getTokenBoxValue = exports.getOrderBoxValue = exports.getPairBoxValue = exports.getCompanyBoxValue = exports.getCompanyBoxName = exports.getAccountBoxByHash = exports.getAccountBoxValue = exports.getAccountBalanceBoxValue = exports.getBoxes = exports.getAssetBalancesByAppAddress = exports.getAssetBalancesByAppIndex = exports.getTradingKeyBoxValue = exports.getTradingKeyBoxName = exports.getTmcBoxValue = exports.getTmcBoxName = exports.getRebalanceBoxName = exports.getCCTPBalancesBoxValue = exports.getCCTPBalanceBoxValue = exports.getCCTPBalanceBoxName = exports.getAccountBalanceBoxName = exports.getAccountBalanceBoxNameHash = exports.getCodexAccountInfo = exports.getCodexStateValue = exports.encodeToken = exports.checkIfAddressIsNormalized = exports.normalizeAddress = exports.decodeToken = exports.decodeAddress = exports.extractUint256 = exports.extractUint64 = exports.extractUint32 = exports.extractUint16 = exports.extractStr = exports.extractDouble = exports.extractToken = exports.extractAddress = exports.decode = exports.encode = exports.getAddressFromNormalized = exports.getAddressChainFromNormalized = exports.encodeAddress = void 0;
1698
1659
  exports.getUpgradeImpMsg = exports.makeUpdatePairInfoTxn = exports.makeUpdateTokenInfoTxns = exports.makeSetCompanyFeeTxn = exports.makeSetSuperAppTxns = exports.makeSetSuperCollectionWalletTxns = exports.makeSetCollectionWalletTxn = exports.makeWithdrawTxns = exports.getBase64EncodedData = exports.getUtf8EncodedData = exports.makeSigningMessage = exports.makeSetCollectionWalletMsg = exports.makeRevokeTradingKeyTxn = exports.makeAddTradingKeyTxn = exports.decodeTradingKeyMsg = exports.makeTradingKeyMsg = exports.makeLoginMsg = exports.makeMatchTxns = void 0;
1699
1660
  exports.getTokenFromNormalized = getTokenFromNormalized;
1700
- const algosdk_1 = __importDefault(__webpack_require__(9709));
1701
- const bs58 = __importStar(__webpack_require__(4578));
1661
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
1662
+ const bs58 = __importStar(__webpack_require__(5316));
1702
1663
  const big_number_helper_1 = __webpack_require__(1174);
1703
1664
  const utils_1 = __webpack_require__(8398);
1704
1665
  const codex_1 = __webpack_require__(430);
@@ -1742,7 +1703,6 @@ function getTokenFromNormalized(token, chainId) {
1742
1703
  return (0, exports.getAddressFromNormalized)(token, Number(chainId));
1743
1704
  }
1744
1705
  const encode = (value, type, chain) => {
1745
- // console.log('encode', JSON.stringify({ value: typeof value === "bigint" ? `${value}n` : value, type, chain }));
1746
1706
  switch (type) {
1747
1707
  case '8B': return algosdk_1.default.encodeUint64(Number(value));
1748
1708
  case '32B': return (0, eth_helper_1.encode32Bytes)(value);
@@ -1845,13 +1805,6 @@ const encodeToken = (token, chain) => {
1845
1805
  exports.encodeToken = encodeToken;
1846
1806
  const getCodexStateValue = async (algoClient, appId) => {
1847
1807
  const globalState = await (0, algo_helper_1.getAppGlobalState)(algoClient, appId);
1848
- // console.log('codexState', appId, globalState);
1849
- // if (globalState["MNA"]) {
1850
- // console.log('MNA', decodeAddress(Buffer.from(globalState["MNA"]), 8));
1851
- // }
1852
- // if (globalState["BKA"]) {
1853
- // console.log('BKA', decodeAddress(Buffer.from(globalState["BKA"]), 8));
1854
- // }
1855
1808
  const msgProcId = globalState["MSG_PROCESSOR"];
1856
1809
  const superAppId = globalState["UL_SUPERADMIN_APP"];
1857
1810
  let superWallet = globalState["UL_SUPERADMIN_WALLET"];
@@ -1981,7 +1934,6 @@ const getAccountBalanceBoxValue = async (algoClient, appId, login, token) => {
1981
1934
  };
1982
1935
  exports.getAccountBalanceBoxValue = getAccountBalanceBoxValue;
1983
1936
  const getAccountBoxValue = async (algoClient, appId, loginAddress, loginChainId, tokenAddress, tokenChainId) => {
1984
- // console.log('getAccountBoxValue', { loginAddress, loginChainId, tokenAddress, tokenChainId });
1985
1937
  const boxName = (0, eth_helper_1.keccak256)((0, exports.getAccountBalanceBoxName)(loginAddress, loginChainId, tokenAddress, tokenChainId));
1986
1938
  const boxValue = await getAccountBox(algoClient, appId, boxName);
1987
1939
  console.log('Box account value', loginAddress.substring(0, 8), tokenAddress, boxValue, Buffer.from(boxName).toString('hex'));
@@ -2177,7 +2129,7 @@ const makeCreateOrderMsg = (data) => {
2177
2129
  (0, exports.encode)(data.companyId, '2B'),
2178
2130
  (0, exports.encode)(data.random, '8B'),
2179
2131
  (0, exports.encode)(data.decimalPrice, 'float'),
2180
- Buffer.alloc(50), // extra 50 zero bytes
2132
+ Buffer.alloc(50),
2181
2133
  ]);
2182
2134
  const bs64OrderBytes = new Uint8Array(Buffer.from((0, Encoding_1.encodeBase64)(orderBytes)));
2183
2135
  const messageBytes = new Uint8Array([
@@ -2258,14 +2210,13 @@ const decodeCreateOrderMsg = (message, encoding = 'hex') => {
2258
2210
  return {
2259
2211
  ...orderData,
2260
2212
  expiredDate: String(orderData.expiredTime).length > 10
2261
- ? new Date(orderData.expiredTime) // TODO: fix pysdk to send time in sec
2213
+ ? new Date(orderData.expiredTime)
2262
2214
  : new Date(orderData.expiredTime * 1000)
2263
2215
  };
2264
2216
  };
2265
2217
  exports.decodeCreateOrderMsg = decodeCreateOrderMsg;
2266
2218
  const getMatchOrderArgs = (order) => {
2267
2219
  const { id, address, chain, message, encoding, signature, tradingKey } = order;
2268
- // console.log('getMatchOrderArgs', JSON.stringify(order));
2269
2220
  const signAddress = tradingKey || address;
2270
2221
  const signChain = tradingKey ? enums_1.Chains.Algorand : chain;
2271
2222
  return [
@@ -2294,8 +2245,6 @@ const createBoxes = (appIndex, boxNames, encode = eth_helper_1.keccak256) => {
2294
2245
  appIndex,
2295
2246
  name: encode(boxName)
2296
2247
  }));
2297
- // console.log('createBoxes', boxes.map(b => Buffer.from(b.name).toString('hex')))
2298
- // console.log(`createBoxesBytes`, boxes.map(b => Array.apply([], Array.from(b.name)).join(", ")));
2299
2248
  return boxes;
2300
2249
  };
2301
2250
  exports.createBoxes = createBoxes;
@@ -2389,7 +2338,7 @@ const makeMatchTxns = (appId, args, params, sender, encoding = 'hex') => {
2389
2338
  getShareWalletBoxKey(afTaker, baseAsset),
2390
2339
  getShareWalletBoxKey(afTaker, priceAsset),
2391
2340
  ]
2392
- .filter(Boolean) // filter possible undefined args
2341
+ .filter(Boolean)
2393
2342
  .map(o => Buffer.from(o).toString('hex')))
2394
2343
  ].map(o => Buffer.from(o, 'hex'));
2395
2344
  const allBoxes = [
@@ -2403,7 +2352,6 @@ const makeMatchTxns = (appId, args, params, sender, encoding = 'hex') => {
2403
2352
  ];
2404
2353
  const allBoxesUnique = [...new Set(allBoxes.map(o => Buffer.from(o.name).toString('hex')))];
2405
2354
  console.log(`[TradeID: ${id}] All boxes`, JSON.stringify(allBoxesUnique));
2406
- // allBoxes = allBoxesUnique.map(o => Buffer.from(o.name))
2407
2355
  const foreignApps = [superAppId];
2408
2356
  const MAX_REFS = 8;
2409
2357
  const mainTxnBoxes = allBoxes.slice(0, MAX_REFS - foreignApps.length);
@@ -2428,12 +2376,6 @@ const makeMatchTxns = (appId, args, params, sender, encoding = 'hex') => {
2428
2376
  };
2429
2377
  exports.makeMatchTxns = makeMatchTxns;
2430
2378
  const makeLoginMsg = (data, signingMessage) => {
2431
- // const dataBytes = concatArrays([
2432
- // encode(data.address, 'address', data.chainId),
2433
- // encode(data.chainId, '8B'),
2434
- // encode(data.provider, 'str'),
2435
- // ]);
2436
- // return makeSigningMessage(data.signingMessage, dataBytes);
2437
2379
  const { address, technology } = data;
2438
2380
  return (0, exports.getUtf8EncodedData)(signingMessage || JSON.stringify({ address, technology }));
2439
2381
  };
@@ -2467,9 +2409,7 @@ const decodeTradingKeyMsg = (message, encoding = 'hex') => {
2467
2409
  };
2468
2410
  };
2469
2411
  exports.decodeTradingKeyMsg = decodeTradingKeyMsg;
2470
- const makeAddTradingKeyTxn = async (algoClient, appId, superId, sender, { loginAddress, loginChainId, }, message,
2471
- // encoding: BufferEncoding | undefined,
2472
- signature) => {
2412
+ const makeAddTradingKeyTxn = async (algoClient, appId, superId, sender, { loginAddress, loginChainId, }, message, signature) => {
2473
2413
  const msgArgs = (0, codex_1.getMsgArgs)(message, signature, loginAddress, loginChainId);
2474
2414
  const appArgs = (0, codex_1.getAppArgs)("manageTradingKey(byte[],byte[],byte[],byte[])uint64", [
2475
2415
  (0, exports.encode)('add', 'str'),
@@ -2490,9 +2430,7 @@ signature) => {
2490
2430
  return txn;
2491
2431
  };
2492
2432
  exports.makeAddTradingKeyTxn = makeAddTradingKeyTxn;
2493
- const makeRevokeTradingKeyTxn = async (algoClient, appId, superId, sender, { loginAddress, loginChainId, }, message,
2494
- // encoding: BufferEncoding | undefined,
2495
- signature) => {
2433
+ const makeRevokeTradingKeyTxn = async (algoClient, appId, superId, sender, { loginAddress, loginChainId, }, message, signature) => {
2496
2434
  const msgArgs = (0, codex_1.getMsgArgs)(message, signature, loginAddress, loginChainId);
2497
2435
  const appArgs = (0, codex_1.getAppArgs)("manageTradingKey(byte[],byte[],byte[],byte[])uint64", [
2498
2436
  (0, exports.encode)('delete', 'str'),
@@ -2517,7 +2455,6 @@ const makeSetCollectionWalletMsg = (data) => {
2517
2455
  const chainIdBytes = algosdk_1.default.encodeUint64(loginChainId);
2518
2456
  const dataBytes = (0, Encoding_1.concatArrays)([senderBytes, chainIdBytes, companyIdBytes]);
2519
2457
  const messageBytes = new Uint8Array([
2520
- // ...getUtf8EncodedData(JSON.stringify(data)),
2521
2458
  ...(0, exports.getBase64EncodedData)(dataBytes),
2522
2459
  ]);
2523
2460
  console.log('MESSAGE LENGTH: ', messageBytes);
@@ -2532,14 +2469,10 @@ const getUtf8EncodedData = (jsonData) => new Uint8Array(Buffer.from((jsonData +
2532
2469
  exports.getUtf8EncodedData = getUtf8EncodedData;
2533
2470
  const getBase64EncodedData = (data) => new Uint8Array(Buffer.from((0, Encoding_1.encodeBase64)(data)));
2534
2471
  exports.getBase64EncodedData = getBase64EncodedData;
2535
- const makeWithdrawTxns = async (algoClient, { loginAddress, loginChainId, tokenIndex, recipient, recipientChainId }, message, signature,
2536
- // encoding: BufferEncoding | undefined,
2537
- sender, options) => {
2472
+ const makeWithdrawTxns = async (algoClient, { loginAddress, loginChainId, tokenIndex, recipient, recipientChainId }, message, signature, sender, options) => {
2538
2473
  const msgArgs = (0, codex_1.getMsgArgs)(message, signature, loginAddress, loginChainId);
2539
2474
  const appArgs = (0, codex_1.getAppArgs)("withdraw(byte[],byte[],byte[])uint64", msgArgs);
2540
2475
  const isAlgoChain = recipientChainId === enums_1.Chains.Algorand;
2541
- // TODO: calc actual txn fee
2542
- // const params = await getTxnParams(algoClient, 7);
2543
2476
  const params = await (0, algo_helper_1.getTxnParams)(algoClient, isAlgoChain ? 6 : 2);
2544
2477
  params.fee = params.fee + (algosdk_1.default.ALGORAND_MIN_TX_FEE * 5);
2545
2478
  const { appId, coreId, lsaAddress, msgProcessorId, unifiedChainId, cctpSupportedChains, superWallet } = options;
@@ -2790,10 +2723,10 @@ exports.messageForSigning = messageForSigning;
2790
2723
 
2791
2724
  /***/ }),
2792
2725
 
2793
- /***/ 4578:
2726
+ /***/ 4978:
2794
2727
  /***/ ((module) => {
2795
2728
 
2796
- module.exports = __WEBPACK_EXTERNAL_MODULE__4578__;
2729
+ module.exports = require("bignumber.js");
2797
2730
 
2798
2731
  /***/ }),
2799
2732
 
@@ -2811,6 +2744,13 @@ var UpgradeStatus;
2811
2744
  })(UpgradeStatus || (exports.UpgradeStatus = UpgradeStatus = {}));
2812
2745
 
2813
2746
 
2747
+ /***/ }),
2748
+
2749
+ /***/ 5316:
2750
+ /***/ ((module) => {
2751
+
2752
+ module.exports = require("bs58");
2753
+
2814
2754
  /***/ }),
2815
2755
 
2816
2756
  /***/ 5386:
@@ -2831,7 +2771,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
2831
2771
  };
2832
2772
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2833
2773
  exports.makeRemoveExpiredOrderTxn = exports.calcOrderHash = exports.getOrderBoxKeyFromHash = exports.getOrderBoxKey = exports.getOrderBytesFromMsg = void 0;
2834
- const algosdk_1 = __importDefault(__webpack_require__(9709));
2774
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
2835
2775
  const common_helper_1 = __webpack_require__(223);
2836
2776
  const Encoding_1 = __webpack_require__(8593);
2837
2777
  const constants_1 = __webpack_require__(6450);
@@ -2895,25 +2835,25 @@ function getDatepartValue(value) {
2895
2835
  if (!units) {
2896
2836
  return mapWithTimeframe(datepart, 1);
2897
2837
  }
2898
- if (datepart === 'minute' && units % (7 * 24 * 60) === 0) { // week
2838
+ if (datepart === 'minute' && units % (7 * 24 * 60) === 0) {
2899
2839
  return mapWithTimeframe('week', units / (7 * 24 * 60));
2900
2840
  }
2901
- if (datepart === 'minute' && units % (24 * 60) === 0) { // day
2841
+ if (datepart === 'minute' && units % (24 * 60) === 0) {
2902
2842
  return mapWithTimeframe('day', units / (24 * 60));
2903
2843
  }
2904
- if (datepart === 'minute' && units % 60 === 0) { // hour
2844
+ if (datepart === 'minute' && units % 60 === 0) {
2905
2845
  return mapWithTimeframe('hour', units / 60);
2906
2846
  }
2907
- if (datepart === 'hour' && units % (7 * 24) === 0) { // week
2847
+ if (datepart === 'hour' && units % (7 * 24) === 0) {
2908
2848
  return mapWithTimeframe('week', units / (7 * 24));
2909
2849
  }
2910
- if (datepart === 'hour' && units % 24 === 0) { // day
2850
+ if (datepart === 'hour' && units % 24 === 0) {
2911
2851
  return mapWithTimeframe(units === 24 ? 'hour' : 'day', units === 24 ? 24 : units / 24);
2912
2852
  }
2913
- if (datepart === 'day' && units % 7 === 0) { // week
2853
+ if (datepart === 'day' && units % 7 === 0) {
2914
2854
  return mapWithTimeframe('week', units / 7);
2915
2855
  }
2916
- if (datepart === 'month' && units % 12 === 0) { // year
2856
+ if (datepart === 'month' && units % 12 === 0) {
2917
2857
  return mapWithTimeframe('year', units / 12);
2918
2858
  }
2919
2859
  return mapWithTimeframe(datepart, units);
@@ -2983,13 +2923,6 @@ var TwitterAccessScopeEnum;
2983
2923
  })(TwitterAccessScopeEnum || (exports.TwitterAccessScopeEnum = TwitterAccessScopeEnum = {}));
2984
2924
 
2985
2925
 
2986
- /***/ }),
2987
-
2988
- /***/ 6168:
2989
- /***/ ((module) => {
2990
-
2991
- module.exports = __WEBPACK_EXTERNAL_MODULE__6168__;
2992
-
2993
2926
  /***/ }),
2994
2927
 
2995
2928
  /***/ 6450:
@@ -3064,7 +2997,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3064
2997
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3065
2998
  exports.verifySignature = exports.decodeAndNormalizeAddress = exports.isAssetOptedIn = exports.getTxnParams = exports.getBoxByName = exports.getAppBoxes = exports.getAppGlobalState = exports.getAccountAssetBalances = exports.createBoxes = void 0;
3066
2999
  exports.decodeStateArray = decodeStateArray;
3067
- const algosdk_1 = __importDefault(__webpack_require__(9709));
3000
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
3068
3001
  const Encoding_1 = __webpack_require__(8593);
3069
3002
  const helpers_1 = __webpack_require__(9730);
3070
3003
  const createBoxes = (appIndex, foreignApps) => {
@@ -3124,7 +3057,6 @@ const getAppBoxes = async (algodClient, appId) => {
3124
3057
  exports.getAppBoxes = getAppBoxes;
3125
3058
  const getBoxByName = async (algoClient, appId, boxName) => {
3126
3059
  try {
3127
- // console.log('Get box by name', boxName);
3128
3060
  const { value } = await algoClient.getApplicationBoxByName(appId, boxName).do();
3129
3061
  const box = value;
3130
3062
  return box;
@@ -3324,23 +3256,19 @@ var SmallTimeframeEnum;
3324
3256
  SmallTimeframeEnum["last_year"] = "last_year";
3325
3257
  })(SmallTimeframeEnum || (exports.SmallTimeframeEnum = SmallTimeframeEnum = {}));
3326
3258
  class PairsQueryDto {
3327
- constructor() {
3328
- this.timeRange = SmallTimeframeEnum.last_30_days;
3329
- this.sortBy = 'volume_usd';
3330
- this.order = 'desc';
3331
- this.limit = 20;
3332
- this.page = 1;
3333
- }
3259
+ timeRange = SmallTimeframeEnum.last_30_days;
3260
+ sortBy = 'volume_usd';
3261
+ order = 'desc';
3262
+ limit = 20;
3263
+ page = 1;
3334
3264
  }
3335
3265
  exports.PairsQueryDto = PairsQueryDto;
3336
3266
  class UsersQueryDto {
3337
- constructor() {
3338
- this.timeRange = SmallTimeframeEnum.last_30_days;
3339
- this.sortBy = 'volume_usd';
3340
- this.order = 'desc';
3341
- this.limit = 20;
3342
- this.page = 1;
3343
- }
3267
+ timeRange = SmallTimeframeEnum.last_30_days;
3268
+ sortBy = 'volume_usd';
3269
+ order = 'desc';
3270
+ limit = 20;
3271
+ page = 1;
3344
3272
  }
3345
3273
  exports.UsersQueryDto = UsersQueryDto;
3346
3274
  var StatisticTypeQuery;
@@ -3351,10 +3279,8 @@ var StatisticTypeQuery;
3351
3279
  StatisticTypeQuery["dau"] = "dau";
3352
3280
  })(StatisticTypeQuery || (exports.StatisticTypeQuery = StatisticTypeQuery = {}));
3353
3281
  class ChartQueryDto {
3354
- constructor() {
3355
- this.type = StatisticTypeQuery.volume;
3356
- this.timeRange = SmallTimeframeEnum.last_7_days;
3357
- }
3282
+ type = StatisticTypeQuery.volume;
3283
+ timeRange = SmallTimeframeEnum.last_7_days;
3358
3284
  }
3359
3285
  exports.ChartQueryDto = ChartQueryDto;
3360
3286
 
@@ -3495,6 +3421,13 @@ exports.QueueOptions = {
3495
3421
  };
3496
3422
 
3497
3423
 
3424
+ /***/ }),
3425
+
3426
+ /***/ 7835:
3427
+ /***/ ((module) => {
3428
+
3429
+ module.exports = require("ethereumjs-util");
3430
+
3498
3431
  /***/ }),
3499
3432
 
3500
3433
  /***/ 8060:
@@ -3506,7 +3439,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3506
3439
  };
3507
3440
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3508
3441
  exports.makeGroupTxnsWithDummy = exports.makeDummyTxn = void 0;
3509
- const algosdk_1 = __importDefault(__webpack_require__(9709));
3442
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
3510
3443
  const common_helper_1 = __webpack_require__(223);
3511
3444
  const makeDummyTxn = (appIndex, sender, params, boxes, note, foreignApps) => {
3512
3445
  const appArgs = (0, common_helper_1.getAppArgs)("dummy(uint64)void", [1]);
@@ -3546,8 +3479,6 @@ const makeGroupTxnsWithDummy = (id, mainTxnBody) => {
3546
3479
  dummyTxnIndex++;
3547
3480
  }
3548
3481
  }
3549
- // TODO: check this dummy txn
3550
- // additional dummy txn for withdrawal
3551
3482
  dummyTxns2.push((0, exports.makeDummyTxn)(appIndex, from, suggestedParams, [], `${id}_${++dummyTxnIndex}`, foreignApps));
3552
3483
  console.log("dummy count", dummyTxns2.length);
3553
3484
  return [mainTxn, ...dummyTxns2];
@@ -3555,6 +3486,13 @@ const makeGroupTxnsWithDummy = (id, mainTxnBody) => {
3555
3486
  exports.makeGroupTxnsWithDummy = makeGroupTxnsWithDummy;
3556
3487
 
3557
3488
 
3489
+ /***/ }),
3490
+
3491
+ /***/ 8115:
3492
+ /***/ ((module) => {
3493
+
3494
+ module.exports = require("algosdk");
3495
+
3558
3496
  /***/ }),
3559
3497
 
3560
3498
  /***/ 8398:
@@ -3654,7 +3592,7 @@ function removeField(obj, fieldToRemove) {
3654
3592
  .filter(([key]) => key !== fieldToRemove)
3655
3593
  .map(([key, value]) => [key, removeField(value, fieldToRemove)]));
3656
3594
  }
3657
- return obj; // Return primitives as-is
3595
+ return obj;
3658
3596
  }
3659
3597
  function removeUndefined(obj) {
3660
3598
  return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined));
@@ -3718,9 +3656,8 @@ exports.getDeltaUint = getDeltaUint;
3718
3656
  exports.getDeltaBytes = getDeltaBytes;
3719
3657
  exports.toUnix = toUnix;
3720
3658
  exports.fromUnix = fromUnix;
3721
- const algosdk_1 = __importStar(__webpack_require__(9709));
3722
- // import sha512 from "js-sha512"
3723
- const buffer_1 = __webpack_require__(18);
3659
+ const algosdk_1 = __importStar(__webpack_require__(8115));
3660
+ const buffer_1 = __webpack_require__(9428);
3724
3661
  function concatArrays(arrays) {
3725
3662
  return arrays.reduce((a, b) => Uint8Array.from([...a, ...b]));
3726
3663
  }
@@ -3873,15 +3810,6 @@ function encodeBase64(value) {
3873
3810
  function decodeBase64(value) {
3874
3811
  return buffer_1.Buffer.from(value, 'base64');
3875
3812
  }
3876
- // export const sha256HashLength = 32
3877
- // export function sha256Hash(arr: sha512.Message): Uint8Array {
3878
- // return new Uint8Array(sha512.sha512_256.arrayBuffer(arr))
3879
- // }
3880
- // export function encodeApplicationAddress(id: number): Address {
3881
- // const APP_ID_PREFIX = Buffer.from('appID');
3882
- // const toBeSigned = concatArrays([APP_ID_PREFIX, encodeUint64(BigInt(id))]);
3883
- // return encodeAddress(sha256Hash(toBeSigned));
3884
- // }
3885
3813
  function compareArrays(a, b) {
3886
3814
  return a.length === b.length && a.reduce((equal, item, index) => equal && item === b[index], true);
3887
3815
  }
@@ -3909,7 +3837,7 @@ function toUnix(date) {
3909
3837
  function fromUnix(timestamp) {
3910
3838
  return new Date(timestamp * 1000);
3911
3839
  }
3912
- var algosdk_2 = __webpack_require__(9709);
3840
+ var algosdk_2 = __webpack_require__(8115);
3913
3841
  Object.defineProperty(exports, "encodeAddress", ({ enumerable: true, get: function () { return algosdk_2.encodeAddress; } }));
3914
3842
  Object.defineProperty(exports, "decodeAddress", ({ enumerable: true, get: function () { return algosdk_2.decodeAddress; } }));
3915
3843
 
@@ -3958,11 +3886,10 @@ exports.keccak256 = exports.verifyMessage = exports.verifySignature = exports.re
3958
3886
  exports.decode32Bytes = decode32Bytes;
3959
3887
  exports.encodeBigNumber = encodeBigNumber;
3960
3888
  exports.encode32Bytes = encode32Bytes;
3961
- const ethUtil = __importStar(__webpack_require__(1297));
3889
+ const ethUtil = __importStar(__webpack_require__(7835));
3962
3890
  const common_helper_1 = __webpack_require__(223);
3963
3891
  function decode32Bytes(value) {
3964
3892
  const bnValue = ethUtil.fromSigned(Buffer.from(value));
3965
- // console.log('bnValue', value, bnValue, bnValue.toString())
3966
3893
  return BigInt(bnValue.toString());
3967
3894
  }
3968
3895
  function encodeBigNumber(value) {
@@ -4006,9 +3933,8 @@ exports.unpadHexPrefix = unpadHexPrefix;
4006
3933
  const isAddress = (address) => ethUtil.isValidAddress(address);
4007
3934
  exports.isAddress = isAddress;
4008
3935
  const recoverPublicKey = (message, signature) => {
4009
- const messageHash = ethUtil.keccak256(message); // Ensure message is correctly formatted
3936
+ const messageHash = ethUtil.keccak256(message);
4010
3937
  const { r, s, v } = ethUtil.fromRpcSig(signature);
4011
- // Recover the public key
4012
3938
  return ethUtil.ecrecover(messageHash, v, r, s);
4013
3939
  };
4014
3940
  exports.recoverPublicKey = recoverPublicKey;
@@ -4039,7 +3965,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4039
3965
  };
4040
3966
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4041
3967
  exports.makeSetManagerKeyTxn = void 0;
4042
- const algosdk_1 = __importDefault(__webpack_require__(9709));
3968
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
4043
3969
  const algo_helper_1 = __webpack_require__(6897);
4044
3970
  const codex_helper_1 = __webpack_require__(3955);
4045
3971
  const common_helper_1 = __webpack_require__(223);
@@ -4051,14 +3977,12 @@ const makeSetManagerKeyTxn = async (algoClient, superAppId, sender, mnaKey) => {
4051
3977
  console.log("new MNA key:", mnaKey);
4052
3978
  console.log("sender:", sender);
4053
3979
  console.log("superAppId:", superAppId);
4054
- // return makeSetGlobalTxn(algoClient, superAppId, sender, AppGlobalParamName.MNA, mnaKey, AppGlobalParamType.STRING);
4055
3980
  const txn = algosdk_1.default.makeApplicationNoOpTxnFromObject({
4056
3981
  appIndex: superAppId,
4057
3982
  from: sender,
4058
3983
  suggestedParams: params,
4059
3984
  appArgs: (0, common_helper_1.getAppArgs)("set_global(byte[],byte[],byte[])void", [
4060
3985
  (0, codex_helper_1.encode)("MNA", 'str'),
4061
- // encode(mnaKey, 'str'),
4062
3986
  algosdk_1.default.decodeAddress(mnaKey).publicKey,
4063
3987
  (0, codex_helper_1.encode)('S', 'str')
4064
3988
  ]),
@@ -4074,7 +3998,6 @@ exports.makeSetManagerKeyTxn = makeSetManagerKeyTxn;
4074
3998
  /***/ ((__unused_webpack_module, exports) => {
4075
3999
 
4076
4000
 
4077
- //--import { Asset } from "@ultrade/shared/db/entities/market/asset.entity";
4078
4001
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4079
4002
  exports.AmmBucketKeys = exports.VALIDATOR_APP_ID = exports.CONTRACT_VERSION = exports.AmmForeignResources = exports.AmmChars = exports.AmmIds = exports.PoolType = void 0;
4080
4003
  var PoolType;
@@ -4141,7 +4064,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4141
4064
  };
4142
4065
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4143
4066
  exports.makeUpdateMbrTxn = exports.getMbrBoxValue = void 0;
4144
- const algosdk_1 = __importDefault(__webpack_require__(9709));
4067
+ const algosdk_1 = __importDefault(__webpack_require__(8115));
4145
4068
  const algo_helper_1 = __webpack_require__(6897);
4146
4069
  const common_helper_1 = __webpack_require__(223);
4147
4070
  const Encoding_1 = __webpack_require__(8593);
@@ -4193,10 +4116,10 @@ exports.makeUpdateMbrTxn = makeUpdateMbrTxn;
4193
4116
 
4194
4117
  /***/ }),
4195
4118
 
4196
- /***/ 9709:
4119
+ /***/ 9428:
4197
4120
  /***/ ((module) => {
4198
4121
 
4199
- module.exports = __WEBPACK_EXTERNAL_MODULE__9709__;
4122
+ module.exports = require("buffer");
4200
4123
 
4201
4124
  /***/ }),
4202
4125
 
@@ -4305,8 +4228,7 @@ __exportStar(__webpack_require__(3004), exports);
4305
4228
  /******/ // Load entry module and return exports
4306
4229
  /******/ // This entry module is referenced by other modules so it can't be inlined
4307
4230
  /******/ var __webpack_exports__ = __webpack_require__(1931);
4231
+ /******/ module.exports = __webpack_exports__;
4308
4232
  /******/
4309
- /******/ return __webpack_exports__;
4310
4233
  /******/ })()
4311
- ;
4312
- });
4234
+ ;