@ethereansos/interfaces-core 0.4.103 → 0.4.106
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.cjs.js +173 -76
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +173 -77
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -63889,7 +63889,7 @@ function _tryRetrieveMetadata() {
|
|
|
63889
63889
|
item.metadataLink = metadatas && metadatas[item.address] || item.metadataLink;
|
|
63890
63890
|
|
|
63891
63891
|
if (!(item.metadataLink !== '')) {
|
|
63892
|
-
_context.next =
|
|
63892
|
+
_context.next = 42;
|
|
63893
63893
|
break;
|
|
63894
63894
|
}
|
|
63895
63895
|
|
|
@@ -63904,7 +63904,7 @@ function _tryRetrieveMetadata() {
|
|
|
63904
63904
|
}
|
|
63905
63905
|
|
|
63906
63906
|
_context.t1 = JSON.parse(gBase64.decode(item.metadataLink.substring('data:application/json;base64,'.length)));
|
|
63907
|
-
_context.next =
|
|
63907
|
+
_context.next = 31;
|
|
63908
63908
|
break;
|
|
63909
63909
|
|
|
63910
63910
|
case 28:
|
|
@@ -63914,13 +63914,9 @@ function _tryRetrieveMetadata() {
|
|
|
63914
63914
|
}, item.metadataLink)));
|
|
63915
63915
|
|
|
63916
63916
|
case 30:
|
|
63917
|
-
_context.next = 32;
|
|
63918
|
-
return _context.sent.json();
|
|
63919
|
-
|
|
63920
|
-
case 32:
|
|
63921
63917
|
_context.t1 = _context.sent;
|
|
63922
63918
|
|
|
63923
|
-
case
|
|
63919
|
+
case 31:
|
|
63924
63920
|
item.metadata = _context.t1;
|
|
63925
63921
|
|
|
63926
63922
|
if (typeof item.metadata !== 'string') {
|
|
@@ -63936,11 +63932,11 @@ function _tryRetrieveMetadata() {
|
|
|
63936
63932
|
item.description = item.description && item.description.split('\n\n').join(' ');
|
|
63937
63933
|
}
|
|
63938
63934
|
|
|
63939
|
-
_context.next =
|
|
63935
|
+
_context.next = 41;
|
|
63940
63936
|
break;
|
|
63941
63937
|
|
|
63942
|
-
case
|
|
63943
|
-
_context.prev =
|
|
63938
|
+
case 35:
|
|
63939
|
+
_context.prev = 35;
|
|
63944
63940
|
_context.t2 = _context["catch"](23);
|
|
63945
63941
|
delete item.image;
|
|
63946
63942
|
item.image = getElementImage({
|
|
@@ -63949,18 +63945,18 @@ function _tryRetrieveMetadata() {
|
|
|
63949
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>");
|
|
63950
63946
|
console.error(item.metadataMessage);
|
|
63951
63947
|
|
|
63952
|
-
case
|
|
63948
|
+
case 41:
|
|
63953
63949
|
clearMetadata = false;
|
|
63954
63950
|
|
|
63955
|
-
case
|
|
63956
|
-
_context.next =
|
|
63951
|
+
case 42:
|
|
63952
|
+
_context.next = 46;
|
|
63957
63953
|
break;
|
|
63958
63954
|
|
|
63959
|
-
case
|
|
63960
|
-
_context.prev =
|
|
63955
|
+
case 44:
|
|
63956
|
+
_context.prev = 44;
|
|
63961
63957
|
_context.t3 = _context["catch"](8);
|
|
63962
63958
|
|
|
63963
|
-
case
|
|
63959
|
+
case 46:
|
|
63964
63960
|
clearMetadata && delete item.metadata;
|
|
63965
63961
|
clearMetadata && (item.metadataLink = clearMetadata ? 'blank' : item.metadataLink);
|
|
63966
63962
|
|
|
@@ -63982,12 +63978,12 @@ function _tryRetrieveMetadata() {
|
|
|
63982
63978
|
|
|
63983
63979
|
return _context.abrupt("return", item);
|
|
63984
63980
|
|
|
63985
|
-
case
|
|
63981
|
+
case 51:
|
|
63986
63982
|
case "end":
|
|
63987
63983
|
return _context.stop();
|
|
63988
63984
|
}
|
|
63989
63985
|
}
|
|
63990
|
-
}, _callee, null, [[8,
|
|
63986
|
+
}, _callee, null, [[8, 44], [23, 35]]);
|
|
63991
63987
|
}));
|
|
63992
63988
|
return _tryRetrieveMetadata.apply(this, arguments);
|
|
63993
63989
|
}
|
|
@@ -64056,107 +64052,165 @@ function _getTokenPriceInDollarsOnUniswap() {
|
|
|
64056
64052
|
return _getTokenPriceInDollarsOnUniswap.apply(this, arguments);
|
|
64057
64053
|
}
|
|
64058
64054
|
|
|
64059
|
-
function
|
|
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) {
|
|
64060
64114
|
return _getTokenPriceInDollarsOnUniswapV.apply(this, arguments);
|
|
64061
64115
|
}
|
|
64062
64116
|
|
|
64063
64117
|
function _getTokenPriceInDollarsOnUniswapV() {
|
|
64064
|
-
_getTokenPriceInDollarsOnUniswapV = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function
|
|
64118
|
+
_getTokenPriceInDollarsOnUniswapV = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(_ref3, tokenAddress, decimals) {
|
|
64065
64119
|
var context, newContract, chainId, uniswapV2Router, wethAddress, ethereumPrice, ethereumValue, univ3Factory, uniToken, uniTokenWeth, proms;
|
|
64066
|
-
return regeneratorRuntime.wrap(function
|
|
64120
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
64067
64121
|
while (1) {
|
|
64068
|
-
switch (
|
|
64122
|
+
switch (_context4.prev = _context4.next) {
|
|
64069
64123
|
case 0:
|
|
64070
|
-
context =
|
|
64124
|
+
context = _ref3.context, newContract = _ref3.newContract, chainId = _ref3.chainId;
|
|
64071
64125
|
uniswapV2Router = newContract(context.uniswapV2RouterABI, context.uniswapV2RouterAddress);
|
|
64072
|
-
|
|
64073
|
-
|
|
64126
|
+
_context4.t0 = web3Utils__default["default"];
|
|
64127
|
+
_context4.next = 5;
|
|
64074
64128
|
return blockchainCall(uniswapV2Router.methods.WETH);
|
|
64075
64129
|
|
|
64076
64130
|
case 5:
|
|
64077
|
-
|
|
64078
|
-
wethAddress =
|
|
64079
|
-
|
|
64131
|
+
_context4.t1 = _context4.sent;
|
|
64132
|
+
wethAddress = _context4.t0.toChecksumAddress.call(_context4.t0, _context4.t1);
|
|
64133
|
+
_context4.next = 9;
|
|
64080
64134
|
return getEthereumPrice({
|
|
64081
64135
|
context: context
|
|
64082
64136
|
});
|
|
64083
64137
|
|
|
64084
64138
|
case 9:
|
|
64085
|
-
ethereumPrice =
|
|
64139
|
+
ethereumPrice = _context4.sent;
|
|
64086
64140
|
ethereumValue = '0';
|
|
64087
64141
|
univ3Factory = newContract(context.UniswapV3FactoryABI, context.uniswapV3FactoryAddress);
|
|
64088
64142
|
uniToken = new Token(chainId, tokenAddress, parseInt(decimals), 'TOK', 'Token');
|
|
64089
64143
|
uniTokenWeth = new Token(chainId, wethAddress, 18, 'ETH', 'Ethereum');
|
|
64090
|
-
|
|
64091
|
-
|
|
64144
|
+
_context4.prev = 14;
|
|
64145
|
+
_context4.next = 17;
|
|
64092
64146
|
return Promise.all(Object.keys(conversionEncode).map( /*#__PURE__*/function () {
|
|
64093
|
-
var
|
|
64147
|
+
var _ref4 = _asyncToGenerator$1( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(fee) {
|
|
64094
64148
|
var pool, slot0, price;
|
|
64095
|
-
return regeneratorRuntime.wrap(function
|
|
64149
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
64096
64150
|
while (1) {
|
|
64097
|
-
switch (
|
|
64151
|
+
switch (_context3.prev = _context3.next) {
|
|
64098
64152
|
case 0:
|
|
64099
|
-
|
|
64100
|
-
|
|
64101
|
-
|
|
64102
|
-
|
|
64153
|
+
_context3.prev = 0;
|
|
64154
|
+
_context3.t0 = newContract;
|
|
64155
|
+
_context3.t1 = context.UniswapV3PoolABI;
|
|
64156
|
+
_context3.next = 5;
|
|
64103
64157
|
return blockchainCall(univ3Factory.methods.getPool, wethAddress, tokenAddress, fee);
|
|
64104
64158
|
|
|
64105
64159
|
case 5:
|
|
64106
|
-
|
|
64107
|
-
pool = (0,
|
|
64108
|
-
|
|
64160
|
+
_context3.t2 = _context3.sent;
|
|
64161
|
+
pool = (0, _context3.t0)(_context3.t1, _context3.t2);
|
|
64162
|
+
_context3.next = 9;
|
|
64109
64163
|
return blockchainCall(pool.methods.slot0);
|
|
64110
64164
|
|
|
64111
64165
|
case 9:
|
|
64112
|
-
slot0 =
|
|
64166
|
+
slot0 = _context3.sent;
|
|
64113
64167
|
price = tickToPrice(uniToken, uniTokenWeth, parseInt(slot0.tick)).toSignificant(15);
|
|
64114
|
-
return
|
|
64168
|
+
return _context3.abrupt("return", toDecimals(price, 18));
|
|
64115
64169
|
|
|
64116
64170
|
case 14:
|
|
64117
|
-
|
|
64118
|
-
|
|
64119
|
-
return
|
|
64171
|
+
_context3.prev = 14;
|
|
64172
|
+
_context3.t3 = _context3["catch"](0);
|
|
64173
|
+
return _context3.abrupt("return", '0');
|
|
64120
64174
|
|
|
64121
64175
|
case 17:
|
|
64122
64176
|
case "end":
|
|
64123
|
-
return
|
|
64177
|
+
return _context3.stop();
|
|
64124
64178
|
}
|
|
64125
64179
|
}
|
|
64126
|
-
},
|
|
64180
|
+
}, _callee3, null, [[0, 14]]);
|
|
64127
64181
|
}));
|
|
64128
64182
|
|
|
64129
|
-
return function (
|
|
64130
|
-
return
|
|
64183
|
+
return function (_x12) {
|
|
64184
|
+
return _ref4.apply(this, arguments);
|
|
64131
64185
|
};
|
|
64132
64186
|
}()));
|
|
64133
64187
|
|
|
64134
64188
|
case 17:
|
|
64135
|
-
proms =
|
|
64189
|
+
proms = _context4.sent.filter(function (it) {
|
|
64136
64190
|
return it && it !== '0';
|
|
64137
64191
|
});
|
|
64138
64192
|
ethereumValue = proms.reduce(function (a, b) {
|
|
64139
64193
|
return a.ethereansosAdd(b);
|
|
64140
64194
|
});
|
|
64141
64195
|
ethereumValue = ethereumValue.ethereansosDiv(proms.length);
|
|
64142
|
-
|
|
64196
|
+
_context4.next = 24;
|
|
64143
64197
|
break;
|
|
64144
64198
|
|
|
64145
64199
|
case 22:
|
|
64146
|
-
|
|
64147
|
-
|
|
64200
|
+
_context4.prev = 22;
|
|
64201
|
+
_context4.t2 = _context4["catch"](14);
|
|
64148
64202
|
|
|
64149
64203
|
case 24:
|
|
64150
64204
|
ethereumValue = parseFloat(fromDecimals(ethereumValue, 18, true));
|
|
64151
64205
|
ethereumValue *= ethereumPrice;
|
|
64152
|
-
return
|
|
64206
|
+
return _context4.abrupt("return", ethereumValue);
|
|
64153
64207
|
|
|
64154
64208
|
case 27:
|
|
64155
64209
|
case "end":
|
|
64156
|
-
return
|
|
64210
|
+
return _context4.stop();
|
|
64157
64211
|
}
|
|
64158
64212
|
}
|
|
64159
|
-
},
|
|
64213
|
+
}, _callee4, null, [[14, 22]]);
|
|
64160
64214
|
}));
|
|
64161
64215
|
return _getTokenPriceInDollarsOnUniswapV.apply(this, arguments);
|
|
64162
64216
|
}
|
|
@@ -64195,7 +64249,7 @@ function _elaboratePrices() {
|
|
|
64195
64249
|
|
|
64196
64250
|
case 7:
|
|
64197
64251
|
if ((_step = _iterator.n()).done) {
|
|
64198
|
-
_context.next =
|
|
64252
|
+
_context.next = 57;
|
|
64199
64253
|
break;
|
|
64200
64254
|
}
|
|
64201
64255
|
|
|
@@ -64219,61 +64273,103 @@ function _elaboratePrices() {
|
|
|
64219
64273
|
response.data[token] = {
|
|
64220
64274
|
usd: _context.t4
|
|
64221
64275
|
};
|
|
64222
|
-
_context.next =
|
|
64276
|
+
_context.next = 55;
|
|
64223
64277
|
break;
|
|
64224
64278
|
|
|
64225
64279
|
case 22:
|
|
64226
64280
|
_context.prev = 22;
|
|
64227
64281
|
_context.t5 = _context["catch"](9);
|
|
64282
|
+
_context.prev = 24;
|
|
64228
64283
|
_context.t6 = getTokenPriceInDollarsOnUniswap;
|
|
64229
64284
|
_context.t7 = _objectSpread2({
|
|
64230
64285
|
context: context
|
|
64231
64286
|
}, web3Data);
|
|
64232
64287
|
_context.t8 = token;
|
|
64233
|
-
_context.next =
|
|
64288
|
+
_context.next = 30;
|
|
64234
64289
|
return blockchainCall(web3Data.newContract(context.ERC20ABI, token).methods.decimals);
|
|
64235
64290
|
|
|
64236
|
-
case
|
|
64291
|
+
case 30:
|
|
64237
64292
|
_context.t9 = _context.sent;
|
|
64238
|
-
_context.next =
|
|
64293
|
+
_context.next = 33;
|
|
64239
64294
|
return (0, _context.t6)(_context.t7, _context.t8, _context.t9);
|
|
64240
64295
|
|
|
64241
|
-
case
|
|
64296
|
+
case 33:
|
|
64242
64297
|
_context.t10 = _context.sent;
|
|
64243
64298
|
response.data[token] = {
|
|
64244
64299
|
usd: _context.t10
|
|
64245
64300
|
};
|
|
64301
|
+
_context.next = 39;
|
|
64302
|
+
break;
|
|
64246
64303
|
|
|
64247
|
-
case
|
|
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
|
+
};
|
|
64334
|
+
|
|
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:
|
|
64248
64344
|
_context.next = 7;
|
|
64249
64345
|
break;
|
|
64250
64346
|
|
|
64251
|
-
case
|
|
64252
|
-
_context.next =
|
|
64347
|
+
case 57:
|
|
64348
|
+
_context.next = 62;
|
|
64253
64349
|
break;
|
|
64254
64350
|
|
|
64255
|
-
case
|
|
64256
|
-
_context.prev =
|
|
64257
|
-
_context.
|
|
64351
|
+
case 59:
|
|
64352
|
+
_context.prev = 59;
|
|
64353
|
+
_context.t18 = _context["catch"](5);
|
|
64258
64354
|
|
|
64259
|
-
_iterator.e(_context.
|
|
64355
|
+
_iterator.e(_context.t18);
|
|
64260
64356
|
|
|
64261
|
-
case
|
|
64262
|
-
_context.prev =
|
|
64357
|
+
case 62:
|
|
64358
|
+
_context.prev = 62;
|
|
64263
64359
|
|
|
64264
64360
|
_iterator.f();
|
|
64265
64361
|
|
|
64266
|
-
return _context.finish(
|
|
64362
|
+
return _context.finish(62);
|
|
64267
64363
|
|
|
64268
|
-
case
|
|
64364
|
+
case 65:
|
|
64269
64365
|
return _context.abrupt("return", response);
|
|
64270
64366
|
|
|
64271
|
-
case
|
|
64367
|
+
case 66:
|
|
64272
64368
|
case "end":
|
|
64273
64369
|
return _context.stop();
|
|
64274
64370
|
}
|
|
64275
64371
|
}
|
|
64276
|
-
}, _callee, null, [[5,
|
|
64372
|
+
}, _callee, null, [[5, 59, 62, 65], [9, 22], [24, 37], [39, 53]]);
|
|
64277
64373
|
}));
|
|
64278
64374
|
return _elaboratePrices.apply(this, arguments);
|
|
64279
64375
|
}
|
|
@@ -65032,6 +65128,7 @@ exports.getRandomArrayElement = getRandomArrayElement;
|
|
|
65032
65128
|
exports.getRandomArrayIndex = getRandomArrayIndex;
|
|
65033
65129
|
exports.getSolidityUtilities = SolidityUtilities;
|
|
65034
65130
|
exports.getSupportedSolidityVersion = getSupportedSolidityVersion;
|
|
65131
|
+
exports.getTokenPriceInDollarsOnSushiSwap = getTokenPriceInDollarsOnSushiSwap;
|
|
65035
65132
|
exports.getTokenPriceInDollarsOnUniswap = getTokenPriceInDollarsOnUniswap;
|
|
65036
65133
|
exports.getTokenPriceInDollarsOnUniswapV3 = getTokenPriceInDollarsOnUniswapV3;
|
|
65037
65134
|
exports.getTokenPricesInDollarsOnCoingecko = getTokenPricesInDollarsOnCoingecko;
|