@ethereansos/interfaces-core 0.4.104 → 0.4.107

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
@@ -50099,7 +50099,21 @@ function toDecimals(number, decimals) {
50099
50099
  var symbol = toEthereumSymbol(decimals);
50100
50100
 
50101
50101
  if (symbol) {
50102
- return web3Utils.toWei(numberToString(number), symbol);
50102
+ number = numberToString(number);
50103
+
50104
+ while (true) {
50105
+ try {
50106
+ return web3Utils.toWei(number, symbol);
50107
+ } catch (e) {
50108
+ var message = (e.message || e).toLowerCase();
50109
+
50110
+ if (message.indexOf('too many') !== -1) {
50111
+ number = number.substring(0, number.length - 1);
50112
+ } else {
50113
+ throw e;
50114
+ }
50115
+ }
50116
+ }
50103
50117
  }
50104
50118
 
50105
50119
  return numberToString(number * (decimals < 2 ? 1 : Math.pow(10, decimals)));
@@ -64040,107 +64054,165 @@ function _getTokenPriceInDollarsOnUniswap() {
64040
64054
  return _getTokenPriceInDollarsOnUniswap.apply(this, arguments);
64041
64055
  }
64042
64056
 
64043
- function getTokenPriceInDollarsOnUniswapV3(_x5, _x6, _x7) {
64057
+ function getTokenPriceInDollarsOnSushiSwap(_x5, _x6, _x7, _x8) {
64058
+ return _getTokenPriceInDollarsOnSushiSwap.apply(this, arguments);
64059
+ }
64060
+
64061
+ function _getTokenPriceInDollarsOnSushiSwap() {
64062
+ _getTokenPriceInDollarsOnSushiSwap = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref2, tokenAddress, decimals, amountPlain) {
64063
+ var context, newContract, uniswapV2Router, wethAddress, ethereumPrice, path, amount, ethereumValue;
64064
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
64065
+ while (1) {
64066
+ switch (_context2.prev = _context2.next) {
64067
+ case 0:
64068
+ context = _ref2.context, newContract = _ref2.newContract;
64069
+ uniswapV2Router = newContract(context.uniswapV2RouterABI, context.sushiSwapRouterAddress);
64070
+ _context2.t0 = web3Utils;
64071
+ _context2.next = 5;
64072
+ return blockchainCall(uniswapV2Router.methods.WETH);
64073
+
64074
+ case 5:
64075
+ _context2.t1 = _context2.sent;
64076
+ wethAddress = _context2.t0.toChecksumAddress.call(_context2.t0, _context2.t1);
64077
+ _context2.next = 9;
64078
+ return getEthereumPrice({
64079
+ context: context
64080
+ });
64081
+
64082
+ case 9:
64083
+ ethereumPrice = _context2.sent;
64084
+ path = [tokenAddress, wethAddress];
64085
+ amount = toDecimals(numberToString(!isNaN(amountPlain) ? amountPlain : 1), decimals);
64086
+ ethereumValue = '0';
64087
+ _context2.prev = 13;
64088
+ _context2.next = 16;
64089
+ return blockchainCall(uniswapV2Router.methods.getAmountsOut, amount, path);
64090
+
64091
+ case 16:
64092
+ ethereumValue = _context2.sent[1];
64093
+ _context2.next = 21;
64094
+ break;
64095
+
64096
+ case 19:
64097
+ _context2.prev = 19;
64098
+ _context2.t2 = _context2["catch"](13);
64099
+
64100
+ case 21:
64101
+ ethereumValue = parseFloat(fromDecimals(ethereumValue, 18, true));
64102
+ ethereumValue *= ethereumPrice;
64103
+ return _context2.abrupt("return", ethereumValue);
64104
+
64105
+ case 24:
64106
+ case "end":
64107
+ return _context2.stop();
64108
+ }
64109
+ }
64110
+ }, _callee2, null, [[13, 19]]);
64111
+ }));
64112
+ return _getTokenPriceInDollarsOnSushiSwap.apply(this, arguments);
64113
+ }
64114
+
64115
+ function getTokenPriceInDollarsOnUniswapV3(_x9, _x10, _x11) {
64044
64116
  return _getTokenPriceInDollarsOnUniswapV.apply(this, arguments);
64045
64117
  }
64046
64118
 
64047
64119
  function _getTokenPriceInDollarsOnUniswapV() {
64048
- _getTokenPriceInDollarsOnUniswapV = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref2, tokenAddress, decimals) {
64120
+ _getTokenPriceInDollarsOnUniswapV = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(_ref3, tokenAddress, decimals) {
64049
64121
  var context, newContract, chainId, uniswapV2Router, wethAddress, ethereumPrice, ethereumValue, univ3Factory, uniToken, uniTokenWeth, proms;
64050
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
64122
+ return regeneratorRuntime.wrap(function _callee4$(_context4) {
64051
64123
  while (1) {
64052
- switch (_context3.prev = _context3.next) {
64124
+ switch (_context4.prev = _context4.next) {
64053
64125
  case 0:
64054
- context = _ref2.context, newContract = _ref2.newContract, chainId = _ref2.chainId;
64126
+ context = _ref3.context, newContract = _ref3.newContract, chainId = _ref3.chainId;
64055
64127
  uniswapV2Router = newContract(context.uniswapV2RouterABI, context.uniswapV2RouterAddress);
64056
- _context3.t0 = web3Utils;
64057
- _context3.next = 5;
64128
+ _context4.t0 = web3Utils;
64129
+ _context4.next = 5;
64058
64130
  return blockchainCall(uniswapV2Router.methods.WETH);
64059
64131
 
64060
64132
  case 5:
64061
- _context3.t1 = _context3.sent;
64062
- wethAddress = _context3.t0.toChecksumAddress.call(_context3.t0, _context3.t1);
64063
- _context3.next = 9;
64133
+ _context4.t1 = _context4.sent;
64134
+ wethAddress = _context4.t0.toChecksumAddress.call(_context4.t0, _context4.t1);
64135
+ _context4.next = 9;
64064
64136
  return getEthereumPrice({
64065
64137
  context: context
64066
64138
  });
64067
64139
 
64068
64140
  case 9:
64069
- ethereumPrice = _context3.sent;
64141
+ ethereumPrice = _context4.sent;
64070
64142
  ethereumValue = '0';
64071
64143
  univ3Factory = newContract(context.UniswapV3FactoryABI, context.uniswapV3FactoryAddress);
64072
64144
  uniToken = new Token(chainId, tokenAddress, parseInt(decimals), 'TOK', 'Token');
64073
64145
  uniTokenWeth = new Token(chainId, wethAddress, 18, 'ETH', 'Ethereum');
64074
- _context3.prev = 14;
64075
- _context3.next = 17;
64146
+ _context4.prev = 14;
64147
+ _context4.next = 17;
64076
64148
  return Promise.all(Object.keys(conversionEncode).map( /*#__PURE__*/function () {
64077
- var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(fee) {
64149
+ var _ref4 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(fee) {
64078
64150
  var pool, slot0, price;
64079
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
64151
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
64080
64152
  while (1) {
64081
- switch (_context2.prev = _context2.next) {
64153
+ switch (_context3.prev = _context3.next) {
64082
64154
  case 0:
64083
- _context2.prev = 0;
64084
- _context2.t0 = newContract;
64085
- _context2.t1 = context.UniswapV3PoolABI;
64086
- _context2.next = 5;
64155
+ _context3.prev = 0;
64156
+ _context3.t0 = newContract;
64157
+ _context3.t1 = context.UniswapV3PoolABI;
64158
+ _context3.next = 5;
64087
64159
  return blockchainCall(univ3Factory.methods.getPool, wethAddress, tokenAddress, fee);
64088
64160
 
64089
64161
  case 5:
64090
- _context2.t2 = _context2.sent;
64091
- pool = (0, _context2.t0)(_context2.t1, _context2.t2);
64092
- _context2.next = 9;
64162
+ _context3.t2 = _context3.sent;
64163
+ pool = (0, _context3.t0)(_context3.t1, _context3.t2);
64164
+ _context3.next = 9;
64093
64165
  return blockchainCall(pool.methods.slot0);
64094
64166
 
64095
64167
  case 9:
64096
- slot0 = _context2.sent;
64168
+ slot0 = _context3.sent;
64097
64169
  price = tickToPrice(uniToken, uniTokenWeth, parseInt(slot0.tick)).toSignificant(15);
64098
- return _context2.abrupt("return", toDecimals(price, 18));
64170
+ return _context3.abrupt("return", toDecimals(price, 18));
64099
64171
 
64100
64172
  case 14:
64101
- _context2.prev = 14;
64102
- _context2.t3 = _context2["catch"](0);
64103
- return _context2.abrupt("return", '0');
64173
+ _context3.prev = 14;
64174
+ _context3.t3 = _context3["catch"](0);
64175
+ return _context3.abrupt("return", '0');
64104
64176
 
64105
64177
  case 17:
64106
64178
  case "end":
64107
- return _context2.stop();
64179
+ return _context3.stop();
64108
64180
  }
64109
64181
  }
64110
- }, _callee2, null, [[0, 14]]);
64182
+ }, _callee3, null, [[0, 14]]);
64111
64183
  }));
64112
64184
 
64113
- return function (_x8) {
64114
- return _ref3.apply(this, arguments);
64185
+ return function (_x12) {
64186
+ return _ref4.apply(this, arguments);
64115
64187
  };
64116
64188
  }()));
64117
64189
 
64118
64190
  case 17:
64119
- proms = _context3.sent.filter(function (it) {
64191
+ proms = _context4.sent.filter(function (it) {
64120
64192
  return it && it !== '0';
64121
64193
  });
64122
64194
  ethereumValue = proms.reduce(function (a, b) {
64123
64195
  return a.ethereansosAdd(b);
64124
64196
  });
64125
64197
  ethereumValue = ethereumValue.ethereansosDiv(proms.length);
64126
- _context3.next = 24;
64198
+ _context4.next = 24;
64127
64199
  break;
64128
64200
 
64129
64201
  case 22:
64130
- _context3.prev = 22;
64131
- _context3.t2 = _context3["catch"](14);
64202
+ _context4.prev = 22;
64203
+ _context4.t2 = _context4["catch"](14);
64132
64204
 
64133
64205
  case 24:
64134
64206
  ethereumValue = parseFloat(fromDecimals(ethereumValue, 18, true));
64135
64207
  ethereumValue *= ethereumPrice;
64136
- return _context3.abrupt("return", ethereumValue);
64208
+ return _context4.abrupt("return", ethereumValue);
64137
64209
 
64138
64210
  case 27:
64139
64211
  case "end":
64140
- return _context3.stop();
64212
+ return _context4.stop();
64141
64213
  }
64142
64214
  }
64143
- }, _callee3, null, [[14, 22]]);
64215
+ }, _callee4, null, [[14, 22]]);
64144
64216
  }));
64145
64217
  return _getTokenPriceInDollarsOnUniswapV.apply(this, arguments);
64146
64218
  }
@@ -64179,7 +64251,7 @@ function _elaboratePrices() {
64179
64251
 
64180
64252
  case 7:
64181
64253
  if ((_step = _iterator.n()).done) {
64182
- _context.next = 36;
64254
+ _context.next = 57;
64183
64255
  break;
64184
64256
  }
64185
64257
 
@@ -64203,61 +64275,103 @@ function _elaboratePrices() {
64203
64275
  response.data[token] = {
64204
64276
  usd: _context.t4
64205
64277
  };
64206
- _context.next = 34;
64278
+ _context.next = 55;
64207
64279
  break;
64208
64280
 
64209
64281
  case 22:
64210
64282
  _context.prev = 22;
64211
64283
  _context.t5 = _context["catch"](9);
64284
+ _context.prev = 24;
64212
64285
  _context.t6 = getTokenPriceInDollarsOnUniswap;
64213
64286
  _context.t7 = _objectSpread2({
64214
64287
  context: context
64215
64288
  }, web3Data);
64216
64289
  _context.t8 = token;
64217
- _context.next = 29;
64290
+ _context.next = 30;
64218
64291
  return blockchainCall(web3Data.newContract(context.ERC20ABI, token).methods.decimals);
64219
64292
 
64220
- case 29:
64293
+ case 30:
64221
64294
  _context.t9 = _context.sent;
64222
- _context.next = 32;
64295
+ _context.next = 33;
64223
64296
  return (0, _context.t6)(_context.t7, _context.t8, _context.t9);
64224
64297
 
64225
- case 32:
64298
+ case 33:
64226
64299
  _context.t10 = _context.sent;
64227
64300
  response.data[token] = {
64228
64301
  usd: _context.t10
64229
64302
  };
64303
+ _context.next = 39;
64304
+ break;
64230
64305
 
64231
- case 34:
64306
+ case 37:
64307
+ _context.prev = 37;
64308
+ _context.t11 = _context["catch"](24);
64309
+
64310
+ case 39:
64311
+ _context.prev = 39;
64312
+
64313
+ if (!(!response.data[token].usd || parseFloat(response.data[token].usd) === 0)) {
64314
+ _context.next = 51;
64315
+ break;
64316
+ }
64317
+
64318
+ _context.t12 = getTokenPriceInDollarsOnSushiSwap;
64319
+ _context.t13 = _objectSpread2({
64320
+ context: context
64321
+ }, web3Data);
64322
+ _context.t14 = token;
64323
+ _context.next = 46;
64324
+ return blockchainCall(web3Data.newContract(context.ERC20ABI, token).methods.decimals);
64325
+
64326
+ case 46:
64327
+ _context.t15 = _context.sent;
64328
+ _context.next = 49;
64329
+ return (0, _context.t12)(_context.t13, _context.t14, _context.t15);
64330
+
64331
+ case 49:
64332
+ _context.t16 = _context.sent;
64333
+ response.data[token] = {
64334
+ usd: _context.t16
64335
+ };
64336
+
64337
+ case 51:
64338
+ _context.next = 55;
64339
+ break;
64340
+
64341
+ case 53:
64342
+ _context.prev = 53;
64343
+ _context.t17 = _context["catch"](39);
64344
+
64345
+ case 55:
64232
64346
  _context.next = 7;
64233
64347
  break;
64234
64348
 
64235
- case 36:
64236
- _context.next = 41;
64349
+ case 57:
64350
+ _context.next = 62;
64237
64351
  break;
64238
64352
 
64239
- case 38:
64240
- _context.prev = 38;
64241
- _context.t11 = _context["catch"](5);
64353
+ case 59:
64354
+ _context.prev = 59;
64355
+ _context.t18 = _context["catch"](5);
64242
64356
 
64243
- _iterator.e(_context.t11);
64357
+ _iterator.e(_context.t18);
64244
64358
 
64245
- case 41:
64246
- _context.prev = 41;
64359
+ case 62:
64360
+ _context.prev = 62;
64247
64361
 
64248
64362
  _iterator.f();
64249
64363
 
64250
- return _context.finish(41);
64364
+ return _context.finish(62);
64251
64365
 
64252
- case 44:
64366
+ case 65:
64253
64367
  return _context.abrupt("return", response);
64254
64368
 
64255
- case 45:
64369
+ case 66:
64256
64370
  case "end":
64257
64371
  return _context.stop();
64258
64372
  }
64259
64373
  }
64260
- }, _callee, null, [[5, 38, 41, 44], [9, 22]]);
64374
+ }, _callee, null, [[5, 59, 62, 65], [9, 22], [24, 37], [39, 53]]);
64261
64375
  }));
64262
64376
  return _elaboratePrices.apply(this, arguments);
64263
64377
  }
@@ -64922,5 +65036,5 @@ var tokenPercentage = function tokenPercentage(amount, totalSupply) {
64922
65036
 
64923
65037
  var abi = new AbiCoder();
64924
65038
 
64925
- 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, memoryFetch, 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 };
65039
+ 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, getTokenPriceInDollarsOnSushiSwap, getTokenPriceInDollarsOnUniswap, getTokenPriceInDollarsOnUniswapV3, getTokenPricesInDollarsOnCoingecko, hasEthereumAddress, isEthereumAddress, isSorted, loadBlockSearchTranches, loadContent, loadFunctionality, loadFunctionalityNames, loadMetadatas, loadOffChainWallets as loadOffchainWallets, logger, maxLiquidityForAmounts, memoryFetch, 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 };
64926
65040
  //# sourceMappingURL=index.esm.js.map