@ethereansos/interfaces-core 0.4.102 → 0.4.105

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.cjs.js CHANGED
@@ -63764,6 +63764,56 @@ const gBase64 = {
63764
63764
  extendBuiltins: extendBuiltins,
63765
63765
  };
63766
63766
 
63767
+ function memoryFetch(_x, _x2) {
63768
+ return _memoryFetch.apply(this, arguments);
63769
+ }
63770
+
63771
+ function _memoryFetch() {
63772
+ _memoryFetch = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee(url, type) {
63773
+ var element;
63774
+ return regeneratorRuntime.wrap(function _callee$(_context) {
63775
+ while (1) {
63776
+ switch (_context.prev = _context.next) {
63777
+ case 0:
63778
+ try {
63779
+ element = JSON.parse(window.localStorage.getItem(url));
63780
+ } catch (e) {}
63781
+
63782
+ if (!element) {
63783
+ _context.next = 3;
63784
+ break;
63785
+ }
63786
+
63787
+ return _context.abrupt("return", element);
63788
+
63789
+ case 3:
63790
+ _context.next = 5;
63791
+ return fetch(url);
63792
+
63793
+ case 5:
63794
+ element = _context.sent;
63795
+ _context.next = 8;
63796
+ return element[type || 'json']();
63797
+
63798
+ case 8:
63799
+ element = _context.sent;
63800
+
63801
+ try {
63802
+ window.localStorage.setItem(url, JSON.stringify(element));
63803
+ } catch (e) {}
63804
+
63805
+ return _context.abrupt("return", element);
63806
+
63807
+ case 11:
63808
+ case "end":
63809
+ return _context.stop();
63810
+ }
63811
+ }
63812
+ }, _callee);
63813
+ }));
63814
+ return _memoryFetch.apply(this, arguments);
63815
+ }
63816
+
63767
63817
  function cleanLink(linkToClean) {
63768
63818
  var cleanedLink = linkToClean;
63769
63819
 
@@ -63839,7 +63889,7 @@ function _tryRetrieveMetadata() {
63839
63889
  item.metadataLink = metadatas && metadatas[item.address] || item.metadataLink;
63840
63890
 
63841
63891
  if (!(item.metadataLink !== '')) {
63842
- _context.next = 44;
63892
+ _context.next = 42;
63843
63893
  break;
63844
63894
  }
63845
63895
 
@@ -63854,23 +63904,19 @@ function _tryRetrieveMetadata() {
63854
63904
  }
63855
63905
 
63856
63906
  _context.t1 = JSON.parse(gBase64.decode(item.metadataLink.substring('data:application/json;base64,'.length)));
63857
- _context.next = 33;
63907
+ _context.next = 31;
63858
63908
  break;
63859
63909
 
63860
63910
  case 28:
63861
63911
  _context.next = 30;
63862
- return fetch(cleanLink(formatLink({
63912
+ return memoryFetch(cleanLink(formatLink({
63863
63913
  context: context
63864
63914
  }, item.metadataLink)));
63865
63915
 
63866
63916
  case 30:
63867
- _context.next = 32;
63868
- return _context.sent.json();
63869
-
63870
- case 32:
63871
63917
  _context.t1 = _context.sent;
63872
63918
 
63873
- case 33:
63919
+ case 31:
63874
63920
  item.metadata = _context.t1;
63875
63921
 
63876
63922
  if (typeof item.metadata !== 'string') {
@@ -63886,11 +63932,11 @@ function _tryRetrieveMetadata() {
63886
63932
  item.description = item.description && item.description.split('\n\n').join(' ');
63887
63933
  }
63888
63934
 
63889
- _context.next = 43;
63935
+ _context.next = 41;
63890
63936
  break;
63891
63937
 
63892
- case 37:
63893
- _context.prev = 37;
63938
+ case 35:
63939
+ _context.prev = 35;
63894
63940
  _context.t2 = _context["catch"](23);
63895
63941
  delete item.image;
63896
63942
  item.image = getElementImage({
@@ -63899,18 +63945,18 @@ function _tryRetrieveMetadata() {
63899
63945
  item.metadataMessage = "Could not retrieve metadata, maybe due to CORS restriction policies for the link (<a href=\"".concat(item.metadataLink, "\" target=\"_blank\">").concat(item.metadataLink, "</a>), check it on <a href=\"").concat(item.collection ? context.openSeaItemLinkTemplate.format(item.collection.address, item.id) : context.openSeaCollectionLinkTemplate.format(item.address), "\" target=\"_blank\">Opensea</a>");
63900
63946
  console.error(item.metadataMessage);
63901
63947
 
63902
- case 43:
63948
+ case 41:
63903
63949
  clearMetadata = false;
63904
63950
 
63905
- case 44:
63906
- _context.next = 48;
63951
+ case 42:
63952
+ _context.next = 46;
63907
63953
  break;
63908
63954
 
63909
- case 46:
63910
- _context.prev = 46;
63955
+ case 44:
63956
+ _context.prev = 44;
63911
63957
  _context.t3 = _context["catch"](8);
63912
63958
 
63913
- case 48:
63959
+ case 46:
63914
63960
  clearMetadata && delete item.metadata;
63915
63961
  clearMetadata && (item.metadataLink = clearMetadata ? 'blank' : item.metadataLink);
63916
63962
 
@@ -63932,12 +63978,12 @@ function _tryRetrieveMetadata() {
63932
63978
 
63933
63979
  return _context.abrupt("return", item);
63934
63980
 
63935
- case 53:
63981
+ case 51:
63936
63982
  case "end":
63937
63983
  return _context.stop();
63938
63984
  }
63939
63985
  }
63940
- }, _callee, null, [[8, 46], [23, 37]]);
63986
+ }, _callee, null, [[8, 44], [23, 35]]);
63941
63987
  }));
63942
63988
  return _tryRetrieveMetadata.apply(this, arguments);
63943
63989
  }
@@ -64006,107 +64052,165 @@ function _getTokenPriceInDollarsOnUniswap() {
64006
64052
  return _getTokenPriceInDollarsOnUniswap.apply(this, arguments);
64007
64053
  }
64008
64054
 
64009
- function getTokenPriceInDollarsOnUniswapV3(_x5, _x6, _x7) {
64055
+ function getTokenPriceInDollarsOnSushiSwap(_x5, _x6, _x7, _x8) {
64056
+ return _getTokenPriceInDollarsOnSushiSwap.apply(this, arguments);
64057
+ }
64058
+
64059
+ function _getTokenPriceInDollarsOnSushiSwap() {
64060
+ _getTokenPriceInDollarsOnSushiSwap = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref2, tokenAddress, decimals, amountPlain) {
64061
+ var context, newContract, uniswapV2Router, wethAddress, ethereumPrice, path, amount, ethereumValue;
64062
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
64063
+ while (1) {
64064
+ switch (_context2.prev = _context2.next) {
64065
+ case 0:
64066
+ context = _ref2.context, newContract = _ref2.newContract;
64067
+ uniswapV2Router = newContract(context.uniswapV2RouterABI, context.sushiSwapRouterAddress);
64068
+ _context2.t0 = web3Utils__default["default"];
64069
+ _context2.next = 5;
64070
+ return blockchainCall(uniswapV2Router.methods.WETH);
64071
+
64072
+ case 5:
64073
+ _context2.t1 = _context2.sent;
64074
+ wethAddress = _context2.t0.toChecksumAddress.call(_context2.t0, _context2.t1);
64075
+ _context2.next = 9;
64076
+ return getEthereumPrice({
64077
+ context: context
64078
+ });
64079
+
64080
+ case 9:
64081
+ ethereumPrice = _context2.sent;
64082
+ path = [tokenAddress, wethAddress];
64083
+ amount = toDecimals(numberToString(!isNaN(amountPlain) ? amountPlain : 1), decimals);
64084
+ ethereumValue = '0';
64085
+ _context2.prev = 13;
64086
+ _context2.next = 16;
64087
+ return blockchainCall(uniswapV2Router.methods.getAmountsOut, amount, path);
64088
+
64089
+ case 16:
64090
+ ethereumValue = _context2.sent[1];
64091
+ _context2.next = 21;
64092
+ break;
64093
+
64094
+ case 19:
64095
+ _context2.prev = 19;
64096
+ _context2.t2 = _context2["catch"](13);
64097
+
64098
+ case 21:
64099
+ ethereumValue = parseFloat(fromDecimals(ethereumValue, 18, true));
64100
+ ethereumValue *= ethereumPrice;
64101
+ return _context2.abrupt("return", ethereumValue);
64102
+
64103
+ case 24:
64104
+ case "end":
64105
+ return _context2.stop();
64106
+ }
64107
+ }
64108
+ }, _callee2, null, [[13, 19]]);
64109
+ }));
64110
+ return _getTokenPriceInDollarsOnSushiSwap.apply(this, arguments);
64111
+ }
64112
+
64113
+ function getTokenPriceInDollarsOnUniswapV3(_x9, _x10, _x11) {
64010
64114
  return _getTokenPriceInDollarsOnUniswapV.apply(this, arguments);
64011
64115
  }
64012
64116
 
64013
64117
  function _getTokenPriceInDollarsOnUniswapV() {
64014
- _getTokenPriceInDollarsOnUniswapV = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref2, tokenAddress, decimals) {
64118
+ _getTokenPriceInDollarsOnUniswapV = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(_ref3, tokenAddress, decimals) {
64015
64119
  var context, newContract, chainId, uniswapV2Router, wethAddress, ethereumPrice, ethereumValue, univ3Factory, uniToken, uniTokenWeth, proms;
64016
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
64120
+ return regeneratorRuntime.wrap(function _callee4$(_context4) {
64017
64121
  while (1) {
64018
- switch (_context3.prev = _context3.next) {
64122
+ switch (_context4.prev = _context4.next) {
64019
64123
  case 0:
64020
- context = _ref2.context, newContract = _ref2.newContract, chainId = _ref2.chainId;
64124
+ context = _ref3.context, newContract = _ref3.newContract, chainId = _ref3.chainId;
64021
64125
  uniswapV2Router = newContract(context.uniswapV2RouterABI, context.uniswapV2RouterAddress);
64022
- _context3.t0 = web3Utils__default["default"];
64023
- _context3.next = 5;
64126
+ _context4.t0 = web3Utils__default["default"];
64127
+ _context4.next = 5;
64024
64128
  return blockchainCall(uniswapV2Router.methods.WETH);
64025
64129
 
64026
64130
  case 5:
64027
- _context3.t1 = _context3.sent;
64028
- wethAddress = _context3.t0.toChecksumAddress.call(_context3.t0, _context3.t1);
64029
- _context3.next = 9;
64131
+ _context4.t1 = _context4.sent;
64132
+ wethAddress = _context4.t0.toChecksumAddress.call(_context4.t0, _context4.t1);
64133
+ _context4.next = 9;
64030
64134
  return getEthereumPrice({
64031
64135
  context: context
64032
64136
  });
64033
64137
 
64034
64138
  case 9:
64035
- ethereumPrice = _context3.sent;
64139
+ ethereumPrice = _context4.sent;
64036
64140
  ethereumValue = '0';
64037
64141
  univ3Factory = newContract(context.UniswapV3FactoryABI, context.uniswapV3FactoryAddress);
64038
64142
  uniToken = new Token(chainId, tokenAddress, parseInt(decimals), 'TOK', 'Token');
64039
64143
  uniTokenWeth = new Token(chainId, wethAddress, 18, 'ETH', 'Ethereum');
64040
- _context3.prev = 14;
64041
- _context3.next = 17;
64144
+ _context4.prev = 14;
64145
+ _context4.next = 17;
64042
64146
  return Promise.all(Object.keys(conversionEncode).map( /*#__PURE__*/function () {
64043
- var _ref3 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(fee) {
64147
+ var _ref4 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(fee) {
64044
64148
  var pool, slot0, price;
64045
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
64149
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
64046
64150
  while (1) {
64047
- switch (_context2.prev = _context2.next) {
64151
+ switch (_context3.prev = _context3.next) {
64048
64152
  case 0:
64049
- _context2.prev = 0;
64050
- _context2.t0 = newContract;
64051
- _context2.t1 = context.UniswapV3PoolABI;
64052
- _context2.next = 5;
64153
+ _context3.prev = 0;
64154
+ _context3.t0 = newContract;
64155
+ _context3.t1 = context.UniswapV3PoolABI;
64156
+ _context3.next = 5;
64053
64157
  return blockchainCall(univ3Factory.methods.getPool, wethAddress, tokenAddress, fee);
64054
64158
 
64055
64159
  case 5:
64056
- _context2.t2 = _context2.sent;
64057
- pool = (0, _context2.t0)(_context2.t1, _context2.t2);
64058
- _context2.next = 9;
64160
+ _context3.t2 = _context3.sent;
64161
+ pool = (0, _context3.t0)(_context3.t1, _context3.t2);
64162
+ _context3.next = 9;
64059
64163
  return blockchainCall(pool.methods.slot0);
64060
64164
 
64061
64165
  case 9:
64062
- slot0 = _context2.sent;
64166
+ slot0 = _context3.sent;
64063
64167
  price = tickToPrice(uniToken, uniTokenWeth, parseInt(slot0.tick)).toSignificant(15);
64064
- return _context2.abrupt("return", toDecimals(price, 18));
64168
+ return _context3.abrupt("return", toDecimals(price, 18));
64065
64169
 
64066
64170
  case 14:
64067
- _context2.prev = 14;
64068
- _context2.t3 = _context2["catch"](0);
64069
- return _context2.abrupt("return", '0');
64171
+ _context3.prev = 14;
64172
+ _context3.t3 = _context3["catch"](0);
64173
+ return _context3.abrupt("return", '0');
64070
64174
 
64071
64175
  case 17:
64072
64176
  case "end":
64073
- return _context2.stop();
64177
+ return _context3.stop();
64074
64178
  }
64075
64179
  }
64076
- }, _callee2, null, [[0, 14]]);
64180
+ }, _callee3, null, [[0, 14]]);
64077
64181
  }));
64078
64182
 
64079
- return function (_x8) {
64080
- return _ref3.apply(this, arguments);
64183
+ return function (_x12) {
64184
+ return _ref4.apply(this, arguments);
64081
64185
  };
64082
64186
  }()));
64083
64187
 
64084
64188
  case 17:
64085
- proms = _context3.sent.filter(function (it) {
64189
+ proms = _context4.sent.filter(function (it) {
64086
64190
  return it && it !== '0';
64087
64191
  });
64088
64192
  ethereumValue = proms.reduce(function (a, b) {
64089
64193
  return a.ethereansosAdd(b);
64090
64194
  });
64091
64195
  ethereumValue = ethereumValue.ethereansosDiv(proms.length);
64092
- _context3.next = 24;
64196
+ _context4.next = 24;
64093
64197
  break;
64094
64198
 
64095
64199
  case 22:
64096
- _context3.prev = 22;
64097
- _context3.t2 = _context3["catch"](14);
64200
+ _context4.prev = 22;
64201
+ _context4.t2 = _context4["catch"](14);
64098
64202
 
64099
64203
  case 24:
64100
64204
  ethereumValue = parseFloat(fromDecimals(ethereumValue, 18, true));
64101
64205
  ethereumValue *= ethereumPrice;
64102
- return _context3.abrupt("return", ethereumValue);
64206
+ return _context4.abrupt("return", ethereumValue);
64103
64207
 
64104
64208
  case 27:
64105
64209
  case "end":
64106
- return _context3.stop();
64210
+ return _context4.stop();
64107
64211
  }
64108
64212
  }
64109
- }, _callee3, null, [[14, 22]]);
64213
+ }, _callee4, null, [[14, 22]]);
64110
64214
  }));
64111
64215
  return _getTokenPriceInDollarsOnUniswapV.apply(this, arguments);
64112
64216
  }
@@ -64145,7 +64249,7 @@ function _elaboratePrices() {
64145
64249
 
64146
64250
  case 7:
64147
64251
  if ((_step = _iterator.n()).done) {
64148
- _context.next = 36;
64252
+ _context.next = 57;
64149
64253
  break;
64150
64254
  }
64151
64255
 
@@ -64169,61 +64273,103 @@ function _elaboratePrices() {
64169
64273
  response.data[token] = {
64170
64274
  usd: _context.t4
64171
64275
  };
64172
- _context.next = 34;
64276
+ _context.next = 55;
64173
64277
  break;
64174
64278
 
64175
64279
  case 22:
64176
64280
  _context.prev = 22;
64177
64281
  _context.t5 = _context["catch"](9);
64282
+ _context.prev = 24;
64178
64283
  _context.t6 = getTokenPriceInDollarsOnUniswap;
64179
64284
  _context.t7 = _objectSpread2({
64180
64285
  context: context
64181
64286
  }, web3Data);
64182
64287
  _context.t8 = token;
64183
- _context.next = 29;
64288
+ _context.next = 30;
64184
64289
  return blockchainCall(web3Data.newContract(context.ERC20ABI, token).methods.decimals);
64185
64290
 
64186
- case 29:
64291
+ case 30:
64187
64292
  _context.t9 = _context.sent;
64188
- _context.next = 32;
64293
+ _context.next = 33;
64189
64294
  return (0, _context.t6)(_context.t7, _context.t8, _context.t9);
64190
64295
 
64191
- case 32:
64296
+ case 33:
64192
64297
  _context.t10 = _context.sent;
64193
64298
  response.data[token] = {
64194
64299
  usd: _context.t10
64195
64300
  };
64301
+ _context.next = 39;
64302
+ break;
64303
+
64304
+ case 37:
64305
+ _context.prev = 37;
64306
+ _context.t11 = _context["catch"](24);
64307
+
64308
+ case 39:
64309
+ _context.prev = 39;
64310
+
64311
+ if (!(!response.data[token].usd || parseFloat(response.data[token].usd) === 0)) {
64312
+ _context.next = 51;
64313
+ break;
64314
+ }
64315
+
64316
+ _context.t12 = getTokenPriceInDollarsOnSushiSwap;
64317
+ _context.t13 = _objectSpread2({
64318
+ context: context
64319
+ }, web3Data);
64320
+ _context.t14 = token;
64321
+ _context.next = 46;
64322
+ return blockchainCall(web3Data.newContract(context.ERC20ABI, token).methods.decimals);
64323
+
64324
+ case 46:
64325
+ _context.t15 = _context.sent;
64326
+ _context.next = 49;
64327
+ return (0, _context.t12)(_context.t13, _context.t14, _context.t15);
64328
+
64329
+ case 49:
64330
+ _context.t16 = _context.sent;
64331
+ response.data[token] = {
64332
+ usd: _context.t16
64333
+ };
64196
64334
 
64197
- case 34:
64335
+ case 51:
64336
+ _context.next = 55;
64337
+ break;
64338
+
64339
+ case 53:
64340
+ _context.prev = 53;
64341
+ _context.t17 = _context["catch"](39);
64342
+
64343
+ case 55:
64198
64344
  _context.next = 7;
64199
64345
  break;
64200
64346
 
64201
- case 36:
64202
- _context.next = 41;
64347
+ case 57:
64348
+ _context.next = 62;
64203
64349
  break;
64204
64350
 
64205
- case 38:
64206
- _context.prev = 38;
64207
- _context.t11 = _context["catch"](5);
64351
+ case 59:
64352
+ _context.prev = 59;
64353
+ _context.t18 = _context["catch"](5);
64208
64354
 
64209
- _iterator.e(_context.t11);
64355
+ _iterator.e(_context.t18);
64210
64356
 
64211
- case 41:
64212
- _context.prev = 41;
64357
+ case 62:
64358
+ _context.prev = 62;
64213
64359
 
64214
64360
  _iterator.f();
64215
64361
 
64216
- return _context.finish(41);
64362
+ return _context.finish(62);
64217
64363
 
64218
- case 44:
64364
+ case 65:
64219
64365
  return _context.abrupt("return", response);
64220
64366
 
64221
- case 45:
64367
+ case 66:
64222
64368
  case "end":
64223
64369
  return _context.stop();
64224
64370
  }
64225
64371
  }
64226
- }, _callee, null, [[5, 38, 41, 44], [9, 22]]);
64372
+ }, _callee, null, [[5, 59, 62, 65], [9, 22], [24, 37], [39, 53]]);
64227
64373
  }));
64228
64374
  return _elaboratePrices.apply(this, arguments);
64229
64375
  }
@@ -64982,6 +65128,7 @@ exports.getRandomArrayElement = getRandomArrayElement;
64982
65128
  exports.getRandomArrayIndex = getRandomArrayIndex;
64983
65129
  exports.getSolidityUtilities = SolidityUtilities;
64984
65130
  exports.getSupportedSolidityVersion = getSupportedSolidityVersion;
65131
+ exports.getTokenPriceInDollarsOnSushiSwap = getTokenPriceInDollarsOnSushiSwap;
64985
65132
  exports.getTokenPriceInDollarsOnUniswap = getTokenPriceInDollarsOnUniswap;
64986
65133
  exports.getTokenPriceInDollarsOnUniswapV3 = getTokenPriceInDollarsOnUniswapV3;
64987
65134
  exports.getTokenPricesInDollarsOnCoingecko = getTokenPricesInDollarsOnCoingecko;
@@ -64996,6 +65143,7 @@ exports.loadMetadatas = loadMetadatas;
64996
65143
  exports.loadOffchainWallets = loadOffChainWallets;
64997
65144
  exports.logger = logger;
64998
65145
  exports.maxLiquidityForAmounts = maxLiquidityForAmounts;
65146
+ exports.memoryFetch = memoryFetch;
64999
65147
  exports.methodSignatureMatch = methodSignatureMatch;
65000
65148
  exports.mint = mint;
65001
65149
  exports.mostSignificantBit = mostSignificantBit;