@ethereansos/interfaces-core 0.4.104 → 0.4.105

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