@ethereansos/interfaces-core 0.4.99 → 0.4.102

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/index.esm.js CHANGED
@@ -50355,14 +50355,15 @@ function fromDecimals(number, decimals, skipFormat) {
50355
50355
  return '0';
50356
50356
  }
50357
50357
 
50358
+ number = numberToString(number).split('.')[0];
50358
50359
  var symbol = toEthereumSymbol(decimals);
50359
50360
 
50360
50361
  if (symbol) {
50361
- var result = web3Utils.fromWei(numberToString(number), symbol);
50362
+ var result = web3Utils.fromWei(number, symbol);
50362
50363
  return skipFormat === true ? result : formatMoney(result);
50363
50364
  }
50364
50365
 
50365
- var nts = parseFloat(numberToString(number / (decimals < 2 ? 1 : Math.pow(10, decimals)))); // TODO verify if is expected that is rounded to 2 decimals
50366
+ var nts = parseFloat(numberToString(parseFloat(number) / (decimals < 2 ? 1 : Math.pow(10, decimals)))); // TODO verify if is expected that is rounded to 2 decimals
50366
50367
 
50367
50368
  return skipFormat === true ? numberToString(nts) : formatMoney(nts);
50368
50369
  }
@@ -64098,6 +64099,333 @@ function _getTokenPriceInDollarsOnUniswapV() {
64098
64099
  return _getTokenPriceInDollarsOnUniswapV.apply(this, arguments);
64099
64100
  }
64100
64101
 
64102
+ var tokenPrices = {};
64103
+ var tokenPricesPromises = {};
64104
+
64105
+ function elaboratePrices(_x, _x2, _x3) {
64106
+ return _elaboratePrices.apply(this, arguments);
64107
+ }
64108
+
64109
+ function _elaboratePrices() {
64110
+ _elaboratePrices = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref, res, tokens) {
64111
+ var context, web3Data, response, _iterator, _step, token;
64112
+
64113
+ return regeneratorRuntime.wrap(function _callee$(_context) {
64114
+ while (1) {
64115
+ switch (_context.prev = _context.next) {
64116
+ case 0:
64117
+ context = _ref.context, web3Data = _ref.web3Data;
64118
+ response = {
64119
+ data: {}
64120
+ };
64121
+ Object.entries(res.data).forEach(function (entry) {
64122
+ return response.data[entry[0]] = entry[1];
64123
+ });
64124
+ tokens = (!(tokens instanceof Array) ? tokens = tokens.split(',') : tokens).map(function (it) {
64125
+ return it.toLowerCase();
64126
+ }).filter(function (it) {
64127
+ return it && it !== VOID_ETHEREUM_ADDRESS && !response.data[it];
64128
+ });
64129
+ _iterator = _createForOfIteratorHelper(tokens);
64130
+ _context.prev = 5;
64131
+
64132
+ _iterator.s();
64133
+
64134
+ case 7:
64135
+ if ((_step = _iterator.n()).done) {
64136
+ _context.next = 36;
64137
+ break;
64138
+ }
64139
+
64140
+ token = _step.value;
64141
+ _context.prev = 9;
64142
+ _context.t0 = getTokenPriceInDollarsOnUniswapV3;
64143
+ _context.t1 = _objectSpread2({
64144
+ context: context
64145
+ }, web3Data);
64146
+ _context.t2 = token;
64147
+ _context.next = 15;
64148
+ return blockchainCall(web3Data.newContract(context.ERC20ABI, token).methods.decimals);
64149
+
64150
+ case 15:
64151
+ _context.t3 = _context.sent;
64152
+ _context.next = 18;
64153
+ return (0, _context.t0)(_context.t1, _context.t2, _context.t3);
64154
+
64155
+ case 18:
64156
+ _context.t4 = _context.sent;
64157
+ response.data[token] = {
64158
+ usd: _context.t4
64159
+ };
64160
+ _context.next = 34;
64161
+ break;
64162
+
64163
+ case 22:
64164
+ _context.prev = 22;
64165
+ _context.t5 = _context["catch"](9);
64166
+ _context.t6 = getTokenPriceInDollarsOnUniswap;
64167
+ _context.t7 = _objectSpread2({
64168
+ context: context
64169
+ }, web3Data);
64170
+ _context.t8 = token;
64171
+ _context.next = 29;
64172
+ return blockchainCall(web3Data.newContract(context.ERC20ABI, token).methods.decimals);
64173
+
64174
+ case 29:
64175
+ _context.t9 = _context.sent;
64176
+ _context.next = 32;
64177
+ return (0, _context.t6)(_context.t7, _context.t8, _context.t9);
64178
+
64179
+ case 32:
64180
+ _context.t10 = _context.sent;
64181
+ response.data[token] = {
64182
+ usd: _context.t10
64183
+ };
64184
+
64185
+ case 34:
64186
+ _context.next = 7;
64187
+ break;
64188
+
64189
+ case 36:
64190
+ _context.next = 41;
64191
+ break;
64192
+
64193
+ case 38:
64194
+ _context.prev = 38;
64195
+ _context.t11 = _context["catch"](5);
64196
+
64197
+ _iterator.e(_context.t11);
64198
+
64199
+ case 41:
64200
+ _context.prev = 41;
64201
+
64202
+ _iterator.f();
64203
+
64204
+ return _context.finish(41);
64205
+
64206
+ case 44:
64207
+ return _context.abrupt("return", response);
64208
+
64209
+ case 45:
64210
+ case "end":
64211
+ return _context.stop();
64212
+ }
64213
+ }
64214
+ }, _callee, null, [[5, 38, 41, 44], [9, 22]]);
64215
+ }));
64216
+ return _elaboratePrices.apply(this, arguments);
64217
+ }
64218
+
64219
+ function getTokenPricesInDollarsOnCoingecko(_x4, _x5) {
64220
+ return _getTokenPricesInDollarsOnCoingecko.apply(this, arguments);
64221
+ }
64222
+
64223
+ function _getTokenPricesInDollarsOnCoingecko() {
64224
+ _getTokenPricesInDollarsOnCoingecko = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref2, t) {
64225
+ var context, web3Data, tokens, response, tkns, _iterator2, _step2, token, prom, _i, _tkns, _i2, _tkns2, _iterator3, _step3;
64226
+
64227
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
64228
+ while (1) {
64229
+ switch (_context3.prev = _context3.next) {
64230
+ case 0:
64231
+ context = _ref2.context, web3Data = _ref2.web3Data;
64232
+ tokens = (!(t instanceof Array) ? t = t.split(',') : t).map(function (it) {
64233
+ return it.toLowerCase();
64234
+ });
64235
+ response = {
64236
+ data: {}
64237
+ };
64238
+ tkns = [];
64239
+ _iterator2 = _createForOfIteratorHelper(tokens);
64240
+ _context3.prev = 5;
64241
+
64242
+ _iterator2.s();
64243
+
64244
+ case 7:
64245
+ if ((_step2 = _iterator2.n()).done) {
64246
+ _context3.next = 29;
64247
+ break;
64248
+ }
64249
+
64250
+ token = _step2.value;
64251
+
64252
+ if (!(!token || token === VOID_ETHEREUM_ADDRESS)) {
64253
+ _context3.next = 14;
64254
+ break;
64255
+ }
64256
+
64257
+ _context3.next = 12;
64258
+ return getEthereumPrice({
64259
+ context: context
64260
+ });
64261
+
64262
+ case 12:
64263
+ response.data[token] = _context3.sent;
64264
+ return _context3.abrupt("continue", 27);
64265
+
64266
+ case 14:
64267
+ if (!(tokenPrices[token] && tokenPrices[token].requestExpires > new Date().getTime() && tokenPrices[token].price !== 0)) {
64268
+ _context3.next = 18;
64269
+ break;
64270
+ }
64271
+
64272
+ response.data[token] = {
64273
+ usd: tokenPrices[token].price
64274
+ };
64275
+ _context3.next = 27;
64276
+ break;
64277
+
64278
+ case 18:
64279
+ if (!tokenPricesPromises[token]) {
64280
+ _context3.next = 26;
64281
+ break;
64282
+ }
64283
+
64284
+ _context3.next = 21;
64285
+ return tokenPricesPromises[token];
64286
+
64287
+ case 21:
64288
+ _context3.t0 = token;
64289
+ _context3.t1 = _context3.sent.data[_context3.t0].usd;
64290
+ response.data[token] = {
64291
+ usd: _context3.t1
64292
+ };
64293
+ _context3.next = 27;
64294
+ break;
64295
+
64296
+ case 26:
64297
+ tkns.push(token);
64298
+
64299
+ case 27:
64300
+ _context3.next = 7;
64301
+ break;
64302
+
64303
+ case 29:
64304
+ _context3.next = 34;
64305
+ break;
64306
+
64307
+ case 31:
64308
+ _context3.prev = 31;
64309
+ _context3.t2 = _context3["catch"](5);
64310
+
64311
+ _iterator2.e(_context3.t2);
64312
+
64313
+ case 34:
64314
+ _context3.prev = 34;
64315
+
64316
+ _iterator2.f();
64317
+
64318
+ return _context3.finish(34);
64319
+
64320
+ case 37:
64321
+ prom = /*#__PURE__*/function () {
64322
+ var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(t1, t2) {
64323
+ var res;
64324
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
64325
+ while (1) {
64326
+ switch (_context2.prev = _context2.next) {
64327
+ case 0:
64328
+ res = {
64329
+ data: {}
64330
+ };
64331
+ _context2.prev = 1;
64332
+ _context2.t0 = t1.length > 0;
64333
+
64334
+ if (!_context2.t0) {
64335
+ _context2.next = 9;
64336
+ break;
64337
+ }
64338
+
64339
+ _context2.next = 6;
64340
+ return fetch(context.coingeckoCoinPriceURL + t1.join(','));
64341
+
64342
+ case 6:
64343
+ _context2.next = 8;
64344
+ return _context2.sent.json();
64345
+
64346
+ case 8:
64347
+ res.data = _context2.sent;
64348
+
64349
+ case 9:
64350
+ _context2.next = 13;
64351
+ break;
64352
+
64353
+ case 11:
64354
+ _context2.prev = 11;
64355
+ _context2.t1 = _context2["catch"](1);
64356
+
64357
+ case 13:
64358
+ _context2.next = 15;
64359
+ return elaboratePrices({
64360
+ context: context,
64361
+ web3Data: web3Data
64362
+ }, res, t2);
64363
+
64364
+ case 15:
64365
+ return _context2.abrupt("return", _context2.sent);
64366
+
64367
+ case 16:
64368
+ case "end":
64369
+ return _context2.stop();
64370
+ }
64371
+ }
64372
+ }, _callee2, null, [[1, 11]]);
64373
+ }));
64374
+
64375
+ return function prom(_x6, _x7) {
64376
+ return _ref3.apply(this, arguments);
64377
+ };
64378
+ }();
64379
+
64380
+ prom = prom(tkns, t);
64381
+
64382
+ for (_i = 0, _tkns = tkns; _i < _tkns.length; _i++) {
64383
+ token = _tkns[_i];
64384
+ tokenPricesPromises[token] = prom;
64385
+ }
64386
+
64387
+ _context3.next = 42;
64388
+ return prom;
64389
+
64390
+ case 42:
64391
+ prom = _context3.sent;
64392
+ Object.entries(prom.data).forEach(function (it) {
64393
+ return response.data[it[0]] = it[1];
64394
+ });
64395
+
64396
+ for (_i2 = 0, _tkns2 = tkns; _i2 < _tkns2.length; _i2++) {
64397
+ token = _tkns2[_i2];
64398
+ tokenPrices[token] = {
64399
+ requestExpires: new Date().getTime() + context.coingeckoEthereumPriceRequestInterval,
64400
+ price: response.data[token].usd
64401
+ };
64402
+ }
64403
+
64404
+ _iterator3 = _createForOfIteratorHelper(tokens);
64405
+
64406
+ try {
64407
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
64408
+ token = _step3.value;
64409
+ delete tokenPricesPromises[token];
64410
+ }
64411
+ } catch (err) {
64412
+ _iterator3.e(err);
64413
+ } finally {
64414
+ _iterator3.f();
64415
+ }
64416
+
64417
+ return _context3.abrupt("return", response);
64418
+
64419
+ case 48:
64420
+ case "end":
64421
+ return _context3.stop();
64422
+ }
64423
+ }
64424
+ }, _callee3, null, [[5, 31, 34, 37]]);
64425
+ }));
64426
+ return _getTokenPricesInDollarsOnCoingecko.apply(this, arguments);
64427
+ }
64428
+
64101
64429
  function op(a, operator, b) {
64102
64430
  var operations = {
64103
64431
  '+': 'add',
@@ -64548,5 +64876,5 @@ var tokenPercentage = function tokenPercentage(amount, totalSupply) {
64548
64876
 
64549
64877
  var abi = new AbiCoder();
64550
64878
 
64551
- export { ADDRESS_ZERO, BASE64_REGEXP, BLOCK_SEARCH_SIZE, gBase64 as Base64, BaseContract, BigNumber, Contract, ContractFactory, CurrencyAmount, DFO_DEPLOYED_EVENT, Ether, FACTORY_ADDRESS, FeeAmount, FixedNumber, Fraction, FullMath, GlobalContextsProvider, InitContextProvider, LiquidityMath, MaxUint256, Multicall, NEW_DFO_DEPLOYED_EVENT, NativeCurrency, NoTickDataProvider, NonfungiblePositionManager, POOL_INIT_CODE_HASH, Payments, Percent, PluginsContextProvider, Pool, Position, PositionLibrary, Price, Rounding, Route, SelfPermit, Signer, SqrtPriceMath, Staker, SwapMath, SwapQuoter, SwapRouter, TICK_SPACINGS, Tick, TickLibrary, TickList, TickListDataProvider, TickMath, Token, Trade, TradeType, URL_REGEXP, VOID_BYTES32, VOID_ETHEREUM_ADDRESS, VoidSigner, WETH9, Wallet, Web3ContextProvider, Wordlist, abi, add, blockchainCall, checkCoverSize, computePoolAddress, computePriceImpact, index$2 as constants, createContract, deployMetadataLink, div, eliminateFloatingFinalZeroes, encodeRouteToPath, encodeSqrtRatioX96, ErrorCode as errors, ethers, PubSub as ethosEvents, extractComment, extractHTMLDescription, formatLink, formatMoney, formatMoneyUniV3, formatNumber, formatString, fromDecimals, generateAndCompileContract, generateFunctionalityMetadataLink, getAllContracts, getDefaultProvider, getEthereumPrice, getLogs, getNetworkElement, getRandomArrayElement, getRandomArrayIndex, SolidityUtilities as getSolidityUtilities, getSupportedSolidityVersion, getTokenPriceInDollarsOnUniswap, getTokenPriceInDollarsOnUniswapV3, hasEthereumAddress, isEthereumAddress, isSorted, loadBlockSearchTranches, loadContent, loadFunctionality, loadFunctionalityNames, loadMetadatas, loadOffChainWallets as loadOffchainWallets, logger, maxLiquidityForAmounts, methodSignatureMatch, mint, mostSignificantBit, mul, nearestUsableTick, newContract, normalizeValue, numberToString, packCollection, pragmaSolidityRule, priceToClosestTick, index as providers, refreshBalances, resetContracts, searchForCodeErrors, sendAsync, sendGeneratedProposal, shortenWord, sleep, solidityImportRule, sortedInsert, split, sqrt, toLines as stringToLines, sub, subIn256, swap, tickToPrice, toDecimals, toEthereumSymbol, toHex, toSubArrays, tokenPercentage, tradeComparator, transfer, truncatedWord, tryRetrieveMetadata, uploadMetadata, uploadToIPFS, useEthosContext, useInit, useIsUnmounted, useLoadUniswapPairs, useLocalStorage, usePlaceholder, usePlugins, usePrevious, useSinglePlaceholder, useWeb3, utils, validateAndParseAddress, validateDFOMetadata, version$1 as version, web3States, wordlists };
64879
+ export { ADDRESS_ZERO, BASE64_REGEXP, BLOCK_SEARCH_SIZE, gBase64 as Base64, BaseContract, BigNumber, Contract, ContractFactory, CurrencyAmount, DFO_DEPLOYED_EVENT, Ether, FACTORY_ADDRESS, FeeAmount, FixedNumber, Fraction, FullMath, GlobalContextsProvider, InitContextProvider, LiquidityMath, MaxUint256, Multicall, NEW_DFO_DEPLOYED_EVENT, NativeCurrency, NoTickDataProvider, NonfungiblePositionManager, POOL_INIT_CODE_HASH, Payments, Percent, PluginsContextProvider, Pool, Position, PositionLibrary, Price, Rounding, Route, SelfPermit, Signer, SqrtPriceMath, Staker, SwapMath, SwapQuoter, SwapRouter, TICK_SPACINGS, Tick, TickLibrary, TickList, TickListDataProvider, TickMath, Token, Trade, TradeType, URL_REGEXP, VOID_BYTES32, VOID_ETHEREUM_ADDRESS, VoidSigner, WETH9, Wallet, Web3ContextProvider, Wordlist, abi, add, blockchainCall, checkCoverSize, computePoolAddress, computePriceImpact, index$2 as constants, createContract, deployMetadataLink, div, eliminateFloatingFinalZeroes, encodeRouteToPath, encodeSqrtRatioX96, ErrorCode as errors, ethers, PubSub as ethosEvents, extractComment, extractHTMLDescription, formatLink, formatMoney, formatMoneyUniV3, formatNumber, formatString, fromDecimals, generateAndCompileContract, generateFunctionalityMetadataLink, getAllContracts, getDefaultProvider, getEthereumPrice, getLogs, getNetworkElement, getRandomArrayElement, getRandomArrayIndex, SolidityUtilities as getSolidityUtilities, getSupportedSolidityVersion, getTokenPriceInDollarsOnUniswap, getTokenPriceInDollarsOnUniswapV3, getTokenPricesInDollarsOnCoingecko, hasEthereumAddress, isEthereumAddress, isSorted, loadBlockSearchTranches, loadContent, loadFunctionality, loadFunctionalityNames, loadMetadatas, loadOffChainWallets as loadOffchainWallets, logger, maxLiquidityForAmounts, methodSignatureMatch, mint, mostSignificantBit, mul, nearestUsableTick, newContract, normalizeValue, numberToString, packCollection, pragmaSolidityRule, priceToClosestTick, index as providers, refreshBalances, resetContracts, searchForCodeErrors, sendAsync, sendGeneratedProposal, shortenWord, sleep, solidityImportRule, sortedInsert, split, sqrt, toLines as stringToLines, sub, subIn256, swap, tickToPrice, toDecimals, toEthereumSymbol, toHex, toSubArrays, tokenPercentage, tradeComparator, transfer, truncatedWord, tryRetrieveMetadata, uploadMetadata, uploadToIPFS, useEthosContext, useInit, useIsUnmounted, useLoadUniswapPairs, useLocalStorage, usePlaceholder, usePlugins, usePrevious, useSinglePlaceholder, useWeb3, utils, validateAndParseAddress, validateDFOMetadata, version$1 as version, web3States, wordlists };
64552
64880
  //# sourceMappingURL=index.esm.js.map