@aurigami/sdk 1.18.4 → 1.18.6
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/consts/constants.d.ts +2 -0
- package/dist/helpers/kyber-aggregator-api.d.ts +5 -0
- package/dist/helpers/one-inch-aggregator-api.d.ts +21 -0
- package/dist/helpers/priceFetcher.d.ts +7 -0
- package/dist/sdk.cjs.development.js +399 -216
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +405 -227
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/interactors/MoneyMarket.ts +1 -1
|
@@ -16,14 +16,14 @@ var AuriOracleABI = _interopDefault(require('@aurigami/contracts/artifacts/contr
|
|
|
16
16
|
var abis$5 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuToken.sol/AuToken.json'));
|
|
17
17
|
var abis$6 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json'));
|
|
18
18
|
var abis$7 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/EthRepayHelper.sol/EthRepayHelper.json'));
|
|
19
|
-
var
|
|
20
|
-
var abis$
|
|
19
|
+
var EIP20InterfaceABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json'));
|
|
20
|
+
var abis$8 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/mock/AuriInternalLens.sol/AuriInternalLens.json'));
|
|
21
21
|
var IUniswapV2PairABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/mock/IUniswapV2Pair.sol/IUniswapV2Pair.json'));
|
|
22
|
-
var abis$
|
|
23
|
-
var abis$
|
|
24
|
-
var abis$
|
|
25
|
-
var abis$
|
|
26
|
-
var abis$
|
|
22
|
+
var abis$9 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json'));
|
|
23
|
+
var abis$a = _interopDefault(require('@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json'));
|
|
24
|
+
var abis$b = _interopDefault(require('@aurigami/contracts/artifacts/contracts/ReferralDirectoryV2.sol/ReferralDirectoryV2.json'));
|
|
25
|
+
var abis$c = _interopDefault(require('@aurigami/contracts/artifacts/contracts/plygame/PlyGame.sol/PlyGame.json'));
|
|
26
|
+
var abis$d = _interopDefault(require('@aurigami/contracts/artifacts/contracts/PlyTokenLock.sol/PlyTokenLock.json'));
|
|
27
27
|
var MAINNET_ADDRESSES = _interopDefault(require('@aurigami/contracts/deployments/aurora_mainnet.json'));
|
|
28
28
|
var aurora_testnet_json = _interopDefault(require('@aurigami/contracts/deployments/aurora_testnet.json'));
|
|
29
29
|
var axios = _interopDefault(require('axios'));
|
|
@@ -42,16 +42,16 @@ var index = {
|
|
|
42
42
|
AuriFairLaunchABI: abis$3,
|
|
43
43
|
AuriLensABI: abis$4,
|
|
44
44
|
ComptrollerABI: abis$6,
|
|
45
|
-
EIP20InterfaceABI:
|
|
46
|
-
ReferralDirectoryV2ABI: abis$
|
|
45
|
+
EIP20InterfaceABI: EIP20InterfaceABI,
|
|
46
|
+
ReferralDirectoryV2ABI: abis$b,
|
|
47
47
|
AuErc20ABI: abis,
|
|
48
48
|
AuETHABI: abis$1,
|
|
49
49
|
EthRepayHelperABI: abis$7,
|
|
50
|
-
Multicall2ABI: abis$
|
|
51
|
-
PulpABI: abis$
|
|
52
|
-
AuriInternalLensABI: abis$
|
|
53
|
-
PlyGameABI: abis$
|
|
54
|
-
PlyTokenLockABI: abis$
|
|
50
|
+
Multicall2ABI: abis$9,
|
|
51
|
+
PulpABI: abis$a,
|
|
52
|
+
AuriInternalLensABI: abis$8,
|
|
53
|
+
PlyGameABI: abis$c,
|
|
54
|
+
PlyTokenLockABI: abis$d
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
var dummyAddress = '0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE';
|
|
@@ -208,6 +208,8 @@ var REFERRAL_CAMPAIGNS = /*#__PURE__*/Object.fromEntries([['referral-2505', {
|
|
|
208
208
|
}]]);
|
|
209
209
|
var CACHE_TIMEOUT = 10 * 1000; // 10 seconds
|
|
210
210
|
var SD_INCENTIVE_IN_SD = 83.35;
|
|
211
|
+
var STADER_ETH = /*#__PURE__*/'0x30D20208d987713f46DFD34EF128Bb16C404D10f'.toLowerCase();
|
|
212
|
+
var USDT_ETH = /*#__PURE__*/'0xdAC17F958D2ee523a2206206994597C13D831ec7'.toLowerCase();
|
|
211
213
|
|
|
212
214
|
var decimalRecords = {
|
|
213
215
|
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
|
|
@@ -1138,7 +1140,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1138
1140
|
key: "ply",
|
|
1139
1141
|
get: function get() {
|
|
1140
1142
|
if (!this._ply) {
|
|
1141
|
-
this._ply = this.getContract(networkAddresses.tokens.PLY,
|
|
1143
|
+
this._ply = this.getContract(networkAddresses.tokens.PLY, EIP20InterfaceABI.abi);
|
|
1142
1144
|
}
|
|
1143
1145
|
return this._ply;
|
|
1144
1146
|
}
|
|
@@ -1146,7 +1148,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1146
1148
|
key: "pulp",
|
|
1147
1149
|
get: function get() {
|
|
1148
1150
|
if (!this._pulp) {
|
|
1149
|
-
this._pulp = this.getContract(networkAddresses.tokens.PULP, abis$
|
|
1151
|
+
this._pulp = this.getContract(networkAddresses.tokens.PULP, abis$a.abi);
|
|
1150
1152
|
}
|
|
1151
1153
|
return this._pulp;
|
|
1152
1154
|
}
|
|
@@ -1154,7 +1156,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1154
1156
|
key: "auriInternalLens",
|
|
1155
1157
|
get: function get() {
|
|
1156
1158
|
if (!this._auriInternalLens) {
|
|
1157
|
-
this._auriInternalLens = this.getContract(networkAddresses.misc.AURI_INTERNAL_LENS, abis$
|
|
1159
|
+
this._auriInternalLens = this.getContract(networkAddresses.misc.AURI_INTERNAL_LENS, abis$8.abi);
|
|
1158
1160
|
}
|
|
1159
1161
|
return this._auriInternalLens;
|
|
1160
1162
|
}
|
|
@@ -1170,7 +1172,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1170
1172
|
key: "referralDirectoryV2",
|
|
1171
1173
|
get: function get() {
|
|
1172
1174
|
if (!this._referralDirectoryV2) {
|
|
1173
|
-
this._referralDirectoryV2 = this.getContract(networkAddresses.misc.REFERRAL_V2, abis$
|
|
1175
|
+
this._referralDirectoryV2 = this.getContract(networkAddresses.misc.REFERRAL_V2, abis$b.abi);
|
|
1174
1176
|
}
|
|
1175
1177
|
return this._referralDirectoryV2;
|
|
1176
1178
|
}
|
|
@@ -1186,7 +1188,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1186
1188
|
key: "plygame",
|
|
1187
1189
|
get: function get() {
|
|
1188
1190
|
if (!this._plygame) {
|
|
1189
|
-
this._plygame = this.getContract(networkAddresses.misc.PLYGAME, abis$
|
|
1191
|
+
this._plygame = this.getContract(networkAddresses.misc.PLYGAME, abis$c.abi);
|
|
1190
1192
|
}
|
|
1191
1193
|
return this._plygame;
|
|
1192
1194
|
}
|
|
@@ -1194,7 +1196,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1194
1196
|
key: "plyTokenLock",
|
|
1195
1197
|
get: function get() {
|
|
1196
1198
|
if (!this._plyTokenLock) {
|
|
1197
|
-
this._plyTokenLock = this.getContract(networkAddresses.misc.PLY_TOKEN_LOCK, abis$
|
|
1199
|
+
this._plyTokenLock = this.getContract(networkAddresses.misc.PLY_TOKEN_LOCK, abis$d.abi);
|
|
1198
1200
|
}
|
|
1199
1201
|
return this._plyTokenLock;
|
|
1200
1202
|
}
|
|
@@ -1354,16 +1356,190 @@ function _getPaginatedApi() {
|
|
|
1354
1356
|
return _getPaginatedApi.apply(this, arguments);
|
|
1355
1357
|
}
|
|
1356
1358
|
|
|
1357
|
-
|
|
1359
|
+
var KYBER_AGGREGATOR_AURORA_API_END_POINT = 'https://aggregator-api.kyberswap.com/aurora/route/encode';
|
|
1360
|
+
var KYBER_AGGREGATOR_ETH_API_END_POINT = 'https://aggregator-api.kyberswap.com/ethereum/route/encode';
|
|
1361
|
+
function getSwapInfo(_x, _x2, _x3, _x4) {
|
|
1362
|
+
return _getSwapInfo.apply(this, arguments);
|
|
1363
|
+
}
|
|
1364
|
+
function _getSwapInfo() {
|
|
1365
|
+
_getSwapInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(tokenIn, tokenOut, amountIn, onAurora) {
|
|
1366
|
+
var params, endpoint, resp;
|
|
1367
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1368
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1369
|
+
case 0:
|
|
1370
|
+
if (onAurora === void 0) {
|
|
1371
|
+
onAurora = true;
|
|
1372
|
+
}
|
|
1373
|
+
params = {
|
|
1374
|
+
tokenIn: tokenIn,
|
|
1375
|
+
tokenOut: tokenOut,
|
|
1376
|
+
amountIn: amountIn,
|
|
1377
|
+
to: '0x0000000000000000000000000000000000000000',
|
|
1378
|
+
useMeta: '1',
|
|
1379
|
+
saveGas: '1',
|
|
1380
|
+
gasInclude: '1'
|
|
1381
|
+
};
|
|
1382
|
+
endpoint = onAurora ? KYBER_AGGREGATOR_AURORA_API_END_POINT : KYBER_AGGREGATOR_ETH_API_END_POINT;
|
|
1383
|
+
_context.next = 5;
|
|
1384
|
+
return axios.get(endpoint + '?' + new URLSearchParams(params), {
|
|
1385
|
+
headers: {
|
|
1386
|
+
'Content-Type': 'application/json'
|
|
1387
|
+
}
|
|
1388
|
+
});
|
|
1389
|
+
case 5:
|
|
1390
|
+
resp = _context.sent;
|
|
1391
|
+
return _context.abrupt("return", resp.data);
|
|
1392
|
+
case 7:
|
|
1393
|
+
case "end":
|
|
1394
|
+
return _context.stop();
|
|
1395
|
+
}
|
|
1396
|
+
}, _callee);
|
|
1397
|
+
}));
|
|
1398
|
+
return _getSwapInfo.apply(this, arguments);
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
var ONEINCH_AGGREGATOR_API_END_POINT = 'https://api.1inch.io/v5.0/1313161554/quote';
|
|
1402
|
+
function getQuoteOneInch(_x, _x2, _x3) {
|
|
1403
|
+
return _getQuoteOneInch.apply(this, arguments);
|
|
1404
|
+
}
|
|
1405
|
+
function _getQuoteOneInch() {
|
|
1406
|
+
_getQuoteOneInch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fromTokenAddress, toTokenAddress, amount) {
|
|
1407
|
+
var params, resp;
|
|
1408
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1409
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1410
|
+
case 0:
|
|
1411
|
+
params = {
|
|
1412
|
+
fromTokenAddress: fromTokenAddress,
|
|
1413
|
+
toTokenAddress: toTokenAddress,
|
|
1414
|
+
amount: amount
|
|
1415
|
+
};
|
|
1416
|
+
_context.next = 3;
|
|
1417
|
+
return axios.get(ONEINCH_AGGREGATOR_API_END_POINT + '?' + new URLSearchParams(params), {
|
|
1418
|
+
headers: {
|
|
1419
|
+
'Content-Type': 'application/json'
|
|
1420
|
+
}
|
|
1421
|
+
});
|
|
1422
|
+
case 3:
|
|
1423
|
+
resp = _context.sent;
|
|
1424
|
+
return _context.abrupt("return", resp.data);
|
|
1425
|
+
case 5:
|
|
1426
|
+
case "end":
|
|
1427
|
+
return _context.stop();
|
|
1428
|
+
}
|
|
1429
|
+
}, _callee);
|
|
1430
|
+
}));
|
|
1431
|
+
return _getQuoteOneInch.apply(this, arguments);
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
function prepareParamsAggregator(_x, _x2) {
|
|
1435
|
+
return _prepareParamsAggregator.apply(this, arguments);
|
|
1436
|
+
}
|
|
1437
|
+
function _prepareParamsAggregator() {
|
|
1438
|
+
_prepareParamsAggregator = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(address, provider) {
|
|
1439
|
+
var _networkAddresses$auT, _networkAddresses$auT2;
|
|
1440
|
+
var tokenInErc20, tokenInDecimal, tokenInQuantity, usdtAddress, usdtDecimal;
|
|
1441
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1442
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1443
|
+
case 0:
|
|
1444
|
+
tokenInErc20 = new ethers.Contract(address, EIP20InterfaceABI.abi, provider);
|
|
1445
|
+
_context.next = 3;
|
|
1446
|
+
return tokenInErc20.decimals();
|
|
1447
|
+
case 3:
|
|
1448
|
+
tokenInDecimal = _context.sent;
|
|
1449
|
+
tokenInQuantity = ethers.BigNumber.from(10).pow(tokenInDecimal).toString();
|
|
1450
|
+
usdtAddress = (_networkAddresses$auT = (_networkAddresses$auT2 = networkAddresses.auTokens.find(function (autoken) {
|
|
1451
|
+
return autoken.name == 'auUSDT';
|
|
1452
|
+
})) == null ? void 0 : _networkAddresses$auT2.underlying) != null ? _networkAddresses$auT : '';
|
|
1453
|
+
usdtDecimal = getDecimal(usdtAddress);
|
|
1454
|
+
return _context.abrupt("return", {
|
|
1455
|
+
tokenInQuantity: tokenInQuantity,
|
|
1456
|
+
usdtAddress: usdtAddress,
|
|
1457
|
+
usdtDecimal: usdtDecimal
|
|
1458
|
+
});
|
|
1459
|
+
case 8:
|
|
1460
|
+
case "end":
|
|
1461
|
+
return _context.stop();
|
|
1462
|
+
}
|
|
1463
|
+
}, _callee);
|
|
1464
|
+
}));
|
|
1465
|
+
return _prepareParamsAggregator.apply(this, arguments);
|
|
1466
|
+
}
|
|
1467
|
+
function fetchPriceFromOneInch(_x3, _x4) {
|
|
1468
|
+
return _fetchPriceFromOneInch.apply(this, arguments);
|
|
1469
|
+
}
|
|
1470
|
+
function _fetchPriceFromOneInch() {
|
|
1471
|
+
_fetchPriceFromOneInch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(address, provider) {
|
|
1472
|
+
var _yield$prepareParamsA, tokenInQuantity, usdtAddress, usdtDecimal, info, outputAmount;
|
|
1473
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1474
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1475
|
+
case 0:
|
|
1476
|
+
_context2.next = 2;
|
|
1477
|
+
return prepareParamsAggregator(address, provider);
|
|
1478
|
+
case 2:
|
|
1479
|
+
_yield$prepareParamsA = _context2.sent;
|
|
1480
|
+
tokenInQuantity = _yield$prepareParamsA.tokenInQuantity;
|
|
1481
|
+
usdtAddress = _yield$prepareParamsA.usdtAddress;
|
|
1482
|
+
usdtDecimal = _yield$prepareParamsA.usdtDecimal;
|
|
1483
|
+
_context2.next = 8;
|
|
1484
|
+
return getQuoteOneInch(address, usdtAddress, tokenInQuantity);
|
|
1485
|
+
case 8:
|
|
1486
|
+
info = _context2.sent;
|
|
1487
|
+
outputAmount = info.toTokenAmount;
|
|
1488
|
+
return _context2.abrupt("return", new BigNumber(outputAmount).dividedBy(Math.pow(10, usdtDecimal)));
|
|
1489
|
+
case 11:
|
|
1490
|
+
case "end":
|
|
1491
|
+
return _context2.stop();
|
|
1492
|
+
}
|
|
1493
|
+
}, _callee2);
|
|
1494
|
+
}));
|
|
1495
|
+
return _fetchPriceFromOneInch.apply(this, arguments);
|
|
1496
|
+
}
|
|
1497
|
+
function fetchPriceFromKyberSwap(_x5, _x6, _x7) {
|
|
1498
|
+
return _fetchPriceFromKyberSwap.apply(this, arguments);
|
|
1499
|
+
}
|
|
1500
|
+
function _fetchPriceFromKyberSwap() {
|
|
1501
|
+
_fetchPriceFromKyberSwap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(address, provider, onAurora) {
|
|
1502
|
+
var _yield$prepareParamsA2, tokenInQuantity, usdtAddress, usdtDecimal, info, outputAmount;
|
|
1503
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1504
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1505
|
+
case 0:
|
|
1506
|
+
if (onAurora === void 0) {
|
|
1507
|
+
onAurora = true;
|
|
1508
|
+
}
|
|
1509
|
+
_context3.next = 3;
|
|
1510
|
+
return prepareParamsAggregator(address, provider);
|
|
1511
|
+
case 3:
|
|
1512
|
+
_yield$prepareParamsA2 = _context3.sent;
|
|
1513
|
+
tokenInQuantity = _yield$prepareParamsA2.tokenInQuantity;
|
|
1514
|
+
usdtAddress = _yield$prepareParamsA2.usdtAddress;
|
|
1515
|
+
usdtDecimal = _yield$prepareParamsA2.usdtDecimal;
|
|
1516
|
+
if (!onAurora) {
|
|
1517
|
+
usdtAddress = USDT_ETH;
|
|
1518
|
+
}
|
|
1519
|
+
_context3.next = 10;
|
|
1520
|
+
return getSwapInfo(address, usdtAddress, tokenInQuantity, onAurora);
|
|
1521
|
+
case 10:
|
|
1522
|
+
info = _context3.sent;
|
|
1523
|
+
outputAmount = info.outputAmount;
|
|
1524
|
+
return _context3.abrupt("return", new BigNumber(outputAmount).dividedBy(Math.pow(10, usdtDecimal)));
|
|
1525
|
+
case 13:
|
|
1526
|
+
case "end":
|
|
1527
|
+
return _context3.stop();
|
|
1528
|
+
}
|
|
1529
|
+
}, _callee3);
|
|
1530
|
+
}));
|
|
1531
|
+
return _fetchPriceFromKyberSwap.apply(this, arguments);
|
|
1532
|
+
}
|
|
1533
|
+
function fetchPriceFromDefiLlamaAPI(_x8) {
|
|
1358
1534
|
return _fetchPriceFromDefiLlamaAPI.apply(this, arguments);
|
|
1359
1535
|
}
|
|
1360
1536
|
function _fetchPriceFromDefiLlamaAPI() {
|
|
1361
|
-
_fetchPriceFromDefiLlamaAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1537
|
+
_fetchPriceFromDefiLlamaAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(id) {
|
|
1362
1538
|
var price;
|
|
1363
|
-
return _regeneratorRuntime().wrap(function
|
|
1364
|
-
while (1) switch (
|
|
1539
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1540
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
1365
1541
|
case 0:
|
|
1366
|
-
|
|
1542
|
+
_context4.next = 2;
|
|
1367
1543
|
return axios.post("https://coins.llama.fi/prices", {
|
|
1368
1544
|
coins: [id]
|
|
1369
1545
|
}).then(function (res) {
|
|
@@ -1374,26 +1550,26 @@ function _fetchPriceFromDefiLlamaAPI() {
|
|
|
1374
1550
|
return 0;
|
|
1375
1551
|
});
|
|
1376
1552
|
case 2:
|
|
1377
|
-
price =
|
|
1378
|
-
return
|
|
1553
|
+
price = _context4.sent;
|
|
1554
|
+
return _context4.abrupt("return", new BigNumber(price));
|
|
1379
1555
|
case 4:
|
|
1380
1556
|
case "end":
|
|
1381
|
-
return
|
|
1557
|
+
return _context4.stop();
|
|
1382
1558
|
}
|
|
1383
|
-
},
|
|
1559
|
+
}, _callee4);
|
|
1384
1560
|
}));
|
|
1385
1561
|
return _fetchPriceFromDefiLlamaAPI.apply(this, arguments);
|
|
1386
1562
|
}
|
|
1387
|
-
function fetchPriceFromCoingeckoAPI(
|
|
1563
|
+
function fetchPriceFromCoingeckoAPI(_x9) {
|
|
1388
1564
|
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
1389
1565
|
}
|
|
1390
1566
|
function _fetchPriceFromCoingeckoAPI() {
|
|
1391
|
-
_fetchPriceFromCoingeckoAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1567
|
+
_fetchPriceFromCoingeckoAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id) {
|
|
1392
1568
|
var price;
|
|
1393
|
-
return _regeneratorRuntime().wrap(function
|
|
1394
|
-
while (1) switch (
|
|
1569
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1570
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
1395
1571
|
case 0:
|
|
1396
|
-
|
|
1572
|
+
_context5.next = 2;
|
|
1397
1573
|
return axios.get("https://api.coingecko.com/api/v3/simple/price?ids=" + id + "&vs_currencies=usd").then(function (res) {
|
|
1398
1574
|
return res.data[id];
|
|
1399
1575
|
})["catch"](function (err) {
|
|
@@ -1404,87 +1580,87 @@ function _fetchPriceFromCoingeckoAPI() {
|
|
|
1404
1580
|
};
|
|
1405
1581
|
});
|
|
1406
1582
|
case 2:
|
|
1407
|
-
price =
|
|
1408
|
-
return
|
|
1583
|
+
price = _context5.sent;
|
|
1584
|
+
return _context5.abrupt("return", new BigNumber(price.usd));
|
|
1409
1585
|
case 4:
|
|
1410
1586
|
case "end":
|
|
1411
|
-
return
|
|
1587
|
+
return _context5.stop();
|
|
1412
1588
|
}
|
|
1413
|
-
},
|
|
1589
|
+
}, _callee5);
|
|
1414
1590
|
}));
|
|
1415
1591
|
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
1416
1592
|
}
|
|
1417
|
-
function fetchPriceFromDefiLlama(
|
|
1593
|
+
function fetchPriceFromDefiLlama(_x10) {
|
|
1418
1594
|
return _fetchPriceFromDefiLlama.apply(this, arguments);
|
|
1419
1595
|
}
|
|
1420
1596
|
function _fetchPriceFromDefiLlama() {
|
|
1421
|
-
_fetchPriceFromDefiLlama = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1422
|
-
return _regeneratorRuntime().wrap(function
|
|
1423
|
-
while (1) switch (
|
|
1597
|
+
_fetchPriceFromDefiLlama = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(id) {
|
|
1598
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1599
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
1424
1600
|
case 0:
|
|
1425
1601
|
if (!(id.toLowerCase() == networkAddresses.tokens.AURORA || id.toLowerCase() == networkAddresses.tokens.TRI || id.toLowerCase() == networkAddresses.tokens.META)) {
|
|
1426
|
-
|
|
1602
|
+
_context6.next = 2;
|
|
1427
1603
|
break;
|
|
1428
1604
|
}
|
|
1429
|
-
return
|
|
1605
|
+
return _context6.abrupt("return", fetchPriceFromDefiLlamaAPI("aurora:" + id.toLowerCase()));
|
|
1430
1606
|
case 2:
|
|
1431
1607
|
throw Error("Unknown token " + id + " in fetchPriceFromDefiLlama");
|
|
1432
1608
|
case 3:
|
|
1433
1609
|
case "end":
|
|
1434
|
-
return
|
|
1610
|
+
return _context6.stop();
|
|
1435
1611
|
}
|
|
1436
|
-
},
|
|
1612
|
+
}, _callee6);
|
|
1437
1613
|
}));
|
|
1438
1614
|
return _fetchPriceFromDefiLlama.apply(this, arguments);
|
|
1439
1615
|
}
|
|
1440
|
-
function fetchPriceFromCoingecko(
|
|
1616
|
+
function fetchPriceFromCoingecko(_x11) {
|
|
1441
1617
|
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
1442
1618
|
}
|
|
1443
1619
|
function _fetchPriceFromCoingecko() {
|
|
1444
|
-
_fetchPriceFromCoingecko = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1445
|
-
return _regeneratorRuntime().wrap(function
|
|
1446
|
-
while (1) switch (
|
|
1620
|
+
_fetchPriceFromCoingecko = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(id) {
|
|
1621
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
1622
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1447
1623
|
case 0:
|
|
1448
|
-
|
|
1449
|
-
|
|
1624
|
+
_context7.t0 = id.toLowerCase();
|
|
1625
|
+
_context7.next = _context7.t0 === networkAddresses.tokens.AURORA ? 3 : _context7.t0 === networkAddresses.tokens.TRI ? 4 : _context7.t0 === networkAddresses.tokens.META ? 5 : _context7.t0 === networkAddresses.tokens.STADER ? 6 : 7;
|
|
1450
1626
|
break;
|
|
1451
1627
|
case 3:
|
|
1452
|
-
return
|
|
1628
|
+
return _context7.abrupt("return", fetchPriceFromCoingeckoAPI('aurora-near'));
|
|
1453
1629
|
case 4:
|
|
1454
|
-
return
|
|
1630
|
+
return _context7.abrupt("return", fetchPriceFromCoingeckoAPI('trisolaris'));
|
|
1455
1631
|
case 5:
|
|
1456
|
-
return
|
|
1632
|
+
return _context7.abrupt("return", fetchPriceFromCoingeckoAPI('meta-pool'));
|
|
1457
1633
|
case 6:
|
|
1458
|
-
return
|
|
1634
|
+
return _context7.abrupt("return", fetchPriceFromCoingeckoAPI('stader'));
|
|
1459
1635
|
case 7:
|
|
1460
1636
|
throw Error("Unknown token " + id + " in fetchPriceFromCoingecko");
|
|
1461
1637
|
case 8:
|
|
1462
1638
|
case "end":
|
|
1463
|
-
return
|
|
1639
|
+
return _context7.stop();
|
|
1464
1640
|
}
|
|
1465
|
-
},
|
|
1641
|
+
}, _callee7);
|
|
1466
1642
|
}));
|
|
1467
1643
|
return _fetchPriceFromCoingecko.apply(this, arguments);
|
|
1468
1644
|
}
|
|
1469
|
-
function fetchLPPositions(
|
|
1645
|
+
function fetchLPPositions(_x12, _x13) {
|
|
1470
1646
|
return _fetchLPPositions.apply(this, arguments);
|
|
1471
1647
|
}
|
|
1472
1648
|
function _fetchLPPositions() {
|
|
1473
|
-
_fetchLPPositions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1649
|
+
_fetchLPPositions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(LPAddress, provider) {
|
|
1474
1650
|
var LPContract, _yield$Promise$all, token0, token1, reserves, totalSupply;
|
|
1475
|
-
return _regeneratorRuntime().wrap(function
|
|
1476
|
-
while (1) switch (
|
|
1651
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1652
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1477
1653
|
case 0:
|
|
1478
1654
|
LPContract = new ethers.Contract(LPAddress, IUniswapV2PairABI.abi, provider);
|
|
1479
|
-
|
|
1655
|
+
_context8.next = 3;
|
|
1480
1656
|
return Promise.all([LPContract.token0(), LPContract.token1(), LPContract.getReserves(), LPContract.totalSupply()]);
|
|
1481
1657
|
case 3:
|
|
1482
|
-
_yield$Promise$all =
|
|
1658
|
+
_yield$Promise$all = _context8.sent;
|
|
1483
1659
|
token0 = _yield$Promise$all[0];
|
|
1484
1660
|
token1 = _yield$Promise$all[1];
|
|
1485
1661
|
reserves = _yield$Promise$all[2];
|
|
1486
1662
|
totalSupply = _yield$Promise$all[3];
|
|
1487
|
-
return
|
|
1663
|
+
return _context8.abrupt("return", {
|
|
1488
1664
|
token0: token0,
|
|
1489
1665
|
token1: token1,
|
|
1490
1666
|
reserve0: reserves.reserve0,
|
|
@@ -1493,93 +1669,93 @@ function _fetchLPPositions() {
|
|
|
1493
1669
|
});
|
|
1494
1670
|
case 9:
|
|
1495
1671
|
case "end":
|
|
1496
|
-
return
|
|
1672
|
+
return _context8.stop();
|
|
1497
1673
|
}
|
|
1498
|
-
},
|
|
1674
|
+
}, _callee8);
|
|
1499
1675
|
}));
|
|
1500
1676
|
return _fetchLPPositions.apply(this, arguments);
|
|
1501
1677
|
}
|
|
1502
|
-
function fetchLPPrice(
|
|
1678
|
+
function fetchLPPrice(_x14, _x15) {
|
|
1503
1679
|
return _fetchLPPrice.apply(this, arguments);
|
|
1504
1680
|
}
|
|
1505
1681
|
function _fetchLPPrice() {
|
|
1506
|
-
_fetchLPPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1682
|
+
_fetchLPPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(address, provider) {
|
|
1507
1683
|
var LPInfo, LPDecimal, fetchLPPriceBy, _fetchLPPriceBy, lpPrice;
|
|
1508
|
-
return _regeneratorRuntime().wrap(function
|
|
1509
|
-
while (1) switch (
|
|
1684
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1685
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1510
1686
|
case 0:
|
|
1511
1687
|
_fetchLPPriceBy = function _fetchLPPriceBy3() {
|
|
1512
|
-
_fetchLPPriceBy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1688
|
+
_fetchLPPriceBy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(tokenReverse) {
|
|
1513
1689
|
var tokenPrice, tokenDecimal, reserveUSD;
|
|
1514
|
-
return _regeneratorRuntime().wrap(function
|
|
1515
|
-
while (1) switch (
|
|
1690
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1691
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1516
1692
|
case 0:
|
|
1517
1693
|
if (!tokenReverse.reserve.isZero()) {
|
|
1518
|
-
|
|
1694
|
+
_context9.next = 2;
|
|
1519
1695
|
break;
|
|
1520
1696
|
}
|
|
1521
|
-
return
|
|
1697
|
+
return _context9.abrupt("return", new BigNumber(0));
|
|
1522
1698
|
case 2:
|
|
1523
|
-
|
|
1699
|
+
_context9.next = 4;
|
|
1524
1700
|
return _fetchPrice(tokenReverse.address, provider);
|
|
1525
1701
|
case 4:
|
|
1526
|
-
tokenPrice =
|
|
1702
|
+
tokenPrice = _context9.sent;
|
|
1527
1703
|
tokenDecimal = getDecimal(tokenReverse.address); // reserveUSD will be divided by 10^tokenDecimal later for more precision
|
|
1528
1704
|
reserveUSD = tokenPrice.multipliedBy(tokenReverse.reserve.toString()).multipliedBy(2);
|
|
1529
|
-
return
|
|
1705
|
+
return _context9.abrupt("return", reserveUSD.multipliedBy(decimalFactor(LPDecimal)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())).dividedBy(decimalFactor(tokenDecimal)));
|
|
1530
1706
|
case 8:
|
|
1531
1707
|
case "end":
|
|
1532
|
-
return
|
|
1708
|
+
return _context9.stop();
|
|
1533
1709
|
}
|
|
1534
|
-
},
|
|
1710
|
+
}, _callee9);
|
|
1535
1711
|
}));
|
|
1536
1712
|
return _fetchLPPriceBy.apply(this, arguments);
|
|
1537
1713
|
};
|
|
1538
|
-
fetchLPPriceBy = function _fetchLPPriceBy2(
|
|
1714
|
+
fetchLPPriceBy = function _fetchLPPriceBy2(_x32) {
|
|
1539
1715
|
return _fetchLPPriceBy.apply(this, arguments);
|
|
1540
1716
|
};
|
|
1541
|
-
|
|
1717
|
+
_context10.next = 4;
|
|
1542
1718
|
return fetchLPPositions(address, provider);
|
|
1543
1719
|
case 4:
|
|
1544
|
-
LPInfo =
|
|
1720
|
+
LPInfo = _context10.sent;
|
|
1545
1721
|
LPDecimal = getDecimal(address);
|
|
1546
|
-
|
|
1547
|
-
|
|
1722
|
+
_context10.prev = 6;
|
|
1723
|
+
_context10.next = 9;
|
|
1548
1724
|
return fetchLPPriceBy({
|
|
1549
1725
|
address: LPInfo.token0,
|
|
1550
1726
|
reserve: LPInfo.reserve0
|
|
1551
1727
|
});
|
|
1552
1728
|
case 9:
|
|
1553
|
-
lpPrice =
|
|
1729
|
+
lpPrice = _context10.sent;
|
|
1554
1730
|
if (!lpPrice.isZero()) {
|
|
1555
|
-
|
|
1731
|
+
_context10.next = 12;
|
|
1556
1732
|
break;
|
|
1557
1733
|
}
|
|
1558
1734
|
throw Error("Price is zero");
|
|
1559
1735
|
case 12:
|
|
1560
|
-
return
|
|
1736
|
+
return _context10.abrupt("return", lpPrice);
|
|
1561
1737
|
case 15:
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
devLog("fetchLPPriceBy " + LPInfo.token0 + " failed",
|
|
1565
|
-
|
|
1566
|
-
|
|
1738
|
+
_context10.prev = 15;
|
|
1739
|
+
_context10.t0 = _context10["catch"](6);
|
|
1740
|
+
devLog("fetchLPPriceBy " + LPInfo.token0 + " failed", _context10.t0);
|
|
1741
|
+
_context10.prev = 18;
|
|
1742
|
+
_context10.next = 21;
|
|
1567
1743
|
return fetchLPPriceBy({
|
|
1568
1744
|
address: LPInfo.token1,
|
|
1569
1745
|
reserve: LPInfo.reserve1
|
|
1570
1746
|
});
|
|
1571
1747
|
case 21:
|
|
1572
|
-
return
|
|
1748
|
+
return _context10.abrupt("return", _context10.sent);
|
|
1573
1749
|
case 24:
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
devLog("fetchLPPriceBy " + LPInfo.token1 + " failed",
|
|
1750
|
+
_context10.prev = 24;
|
|
1751
|
+
_context10.t1 = _context10["catch"](18);
|
|
1752
|
+
devLog("fetchLPPriceBy " + LPInfo.token1 + " failed", _context10.t1);
|
|
1577
1753
|
throw Error("Unable to fetch price for both tokens of LP " + address);
|
|
1578
1754
|
case 28:
|
|
1579
1755
|
case "end":
|
|
1580
|
-
return
|
|
1756
|
+
return _context10.stop();
|
|
1581
1757
|
}
|
|
1582
|
-
},
|
|
1758
|
+
}, _callee10, null, [[6, 15], [18, 24]]);
|
|
1583
1759
|
}));
|
|
1584
1760
|
return _fetchLPPrice.apply(this, arguments);
|
|
1585
1761
|
}
|
|
@@ -1587,81 +1763,81 @@ function fetchStNEARPrice() {
|
|
|
1587
1763
|
return _fetchStNEARPrice.apply(this, arguments);
|
|
1588
1764
|
}
|
|
1589
1765
|
function _fetchStNEARPrice() {
|
|
1590
|
-
_fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1766
|
+
_fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
1591
1767
|
var ratioPromise, nearPricePromise, _yield$Promise$all2, ratioRes, nearPrice, ratio;
|
|
1592
|
-
return _regeneratorRuntime().wrap(function
|
|
1593
|
-
while (1) switch (
|
|
1768
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1769
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1594
1770
|
case 0:
|
|
1595
1771
|
ratioPromise = axios.get('https://validators.narwallets.com/metrics_json').then(function (res) {
|
|
1596
1772
|
return res.data;
|
|
1597
1773
|
});
|
|
1598
1774
|
nearPricePromise = fetchPriceFromCoingeckoAPI('near');
|
|
1599
|
-
|
|
1775
|
+
_context11.next = 4;
|
|
1600
1776
|
return Promise.all([ratioPromise, nearPricePromise]);
|
|
1601
1777
|
case 4:
|
|
1602
|
-
_yield$Promise$all2 =
|
|
1778
|
+
_yield$Promise$all2 = _context11.sent;
|
|
1603
1779
|
ratioRes = _yield$Promise$all2[0];
|
|
1604
1780
|
nearPrice = _yield$Promise$all2[1];
|
|
1605
1781
|
ratio = new BigNumber(ratioRes.st_near_price);
|
|
1606
|
-
return
|
|
1782
|
+
return _context11.abrupt("return", ratio.multipliedBy(nearPrice));
|
|
1607
1783
|
case 9:
|
|
1608
1784
|
case "end":
|
|
1609
|
-
return
|
|
1785
|
+
return _context11.stop();
|
|
1610
1786
|
}
|
|
1611
|
-
},
|
|
1787
|
+
}, _callee11);
|
|
1612
1788
|
}));
|
|
1613
1789
|
return _fetchStNEARPrice.apply(this, arguments);
|
|
1614
1790
|
}
|
|
1615
1791
|
function processPriceFromOracle(rawPrice, underlyingDecimal) {
|
|
1616
1792
|
return new BigNumber(rawPrice.toString()).div(decimalFactor(36 - underlyingDecimal));
|
|
1617
1793
|
}
|
|
1618
|
-
function fetchPriceFromOracle(
|
|
1794
|
+
function fetchPriceFromOracle(_x16, _x17, _x18) {
|
|
1619
1795
|
return _fetchPriceFromOracle.apply(this, arguments);
|
|
1620
1796
|
}
|
|
1621
1797
|
function _fetchPriceFromOracle() {
|
|
1622
|
-
_fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1798
|
+
_fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(auTokenAddress, underlyingDecimal, provider) {
|
|
1623
1799
|
var oracleContract, rawPrice, matchingAuToken;
|
|
1624
|
-
return _regeneratorRuntime().wrap(function
|
|
1625
|
-
while (1) switch (
|
|
1800
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1801
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1626
1802
|
case 0:
|
|
1627
1803
|
oracleContract = new ethers.Contract(networkAddresses.misc.oracle, AuriOracleABI.abi, provider);
|
|
1628
|
-
|
|
1804
|
+
_context12.next = 3;
|
|
1629
1805
|
return oracleContract.getUnderlyingPrice(auTokenAddress)["catch"](function (e) {
|
|
1630
1806
|
console.log("Unable to fetch price from oracle for " + auTokenAddress);
|
|
1631
1807
|
return ethers.BigNumber.from(0);
|
|
1632
1808
|
});
|
|
1633
1809
|
case 3:
|
|
1634
|
-
rawPrice =
|
|
1810
|
+
rawPrice = _context12.sent;
|
|
1635
1811
|
if (!rawPrice.isZero()) {
|
|
1636
|
-
|
|
1812
|
+
_context12.next = 8;
|
|
1637
1813
|
break;
|
|
1638
1814
|
}
|
|
1639
1815
|
matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
|
|
1640
1816
|
return isSameAddress(auToken.address, auTokenAddress);
|
|
1641
1817
|
});
|
|
1642
1818
|
if (!((matchingAuToken == null ? void 0 : matchingAuToken.name) == 'auSTNEAR')) {
|
|
1643
|
-
|
|
1819
|
+
_context12.next = 8;
|
|
1644
1820
|
break;
|
|
1645
1821
|
}
|
|
1646
|
-
return
|
|
1822
|
+
return _context12.abrupt("return", fetchStNEARPrice());
|
|
1647
1823
|
case 8:
|
|
1648
|
-
return
|
|
1824
|
+
return _context12.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
|
|
1649
1825
|
case 9:
|
|
1650
1826
|
case "end":
|
|
1651
|
-
return
|
|
1827
|
+
return _context12.stop();
|
|
1652
1828
|
}
|
|
1653
|
-
},
|
|
1829
|
+
}, _callee12);
|
|
1654
1830
|
}));
|
|
1655
1831
|
return _fetchPriceFromOracle.apply(this, arguments);
|
|
1656
1832
|
}
|
|
1657
|
-
function fetchUnderlyingTokensPrices(
|
|
1833
|
+
function fetchUnderlyingTokensPrices(_x19) {
|
|
1658
1834
|
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
1659
1835
|
}
|
|
1660
1836
|
function _fetchUnderlyingTokensPrices() {
|
|
1661
|
-
_fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1837
|
+
_fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(provider) {
|
|
1662
1838
|
var auriLens, auTokenAddresses, underlyingDecimals, rawPrices;
|
|
1663
|
-
return _regeneratorRuntime().wrap(function
|
|
1664
|
-
while (1) switch (
|
|
1839
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1840
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1665
1841
|
case 0:
|
|
1666
1842
|
auriLens = new ethers.Contract(networkAddresses.misc.AURILENS, abis$4.abi, provider);
|
|
1667
1843
|
auTokenAddresses = networkAddresses.auTokens.map(function (auToken) {
|
|
@@ -1670,11 +1846,11 @@ function _fetchUnderlyingTokensPrices() {
|
|
|
1670
1846
|
underlyingDecimals = networkAddresses.auTokens.map(function (auToken) {
|
|
1671
1847
|
return getDecimal(auToken.underlying);
|
|
1672
1848
|
});
|
|
1673
|
-
|
|
1849
|
+
_context13.next = 5;
|
|
1674
1850
|
return auriLens.auTokenUnderlyingPriceAll(auTokenAddresses);
|
|
1675
1851
|
case 5:
|
|
1676
|
-
rawPrices =
|
|
1677
|
-
return
|
|
1852
|
+
rawPrices = _context13.sent;
|
|
1853
|
+
return _context13.abrupt("return", rawPrices.map(function (res, ind) {
|
|
1678
1854
|
return {
|
|
1679
1855
|
auToken: res.auToken,
|
|
1680
1856
|
underlyingPrice: processPriceFromOracle(res.underlyingPrice, underlyingDecimals[ind])
|
|
@@ -1682,215 +1858,214 @@ function _fetchUnderlyingTokensPrices() {
|
|
|
1682
1858
|
}));
|
|
1683
1859
|
case 7:
|
|
1684
1860
|
case "end":
|
|
1685
|
-
return
|
|
1861
|
+
return _context13.stop();
|
|
1686
1862
|
}
|
|
1687
|
-
},
|
|
1863
|
+
}, _callee13);
|
|
1688
1864
|
}));
|
|
1689
1865
|
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
1690
1866
|
}
|
|
1691
|
-
function
|
|
1867
|
+
function shouldFetchFromKyberSwap(address) {
|
|
1692
1868
|
address = address.toLowerCase();
|
|
1693
1869
|
return address == networkAddresses.tokens.AURORA || address == networkAddresses.tokens.TRI || address == networkAddresses.tokens.META || address == networkAddresses.tokens.STADER;
|
|
1694
1870
|
}
|
|
1695
1871
|
/**
|
|
1696
1872
|
* Fetch price from Oracle or Coingecko
|
|
1697
1873
|
*/
|
|
1698
|
-
function _fetchPrice(
|
|
1874
|
+
function _fetchPrice(_x20, _x21) {
|
|
1699
1875
|
return _fetchPrice2.apply(this, arguments);
|
|
1700
1876
|
}
|
|
1701
1877
|
function _fetchPrice2() {
|
|
1702
|
-
_fetchPrice2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1703
|
-
var matchingAuToken;
|
|
1704
|
-
return _regeneratorRuntime().wrap(function
|
|
1705
|
-
while (1) switch (
|
|
1878
|
+
_fetchPrice2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(address, provider) {
|
|
1879
|
+
var ETH_PROVIDER, matchingAuToken;
|
|
1880
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1881
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1706
1882
|
case 0:
|
|
1707
1883
|
assert(PRICE_WHITELISTED.has(address.toLocaleLowerCase()), "Address " + address + " is not whitelisted for price fetching");
|
|
1708
|
-
if (!
|
|
1709
|
-
|
|
1884
|
+
if (!shouldFetchFromKyberSwap(address)) {
|
|
1885
|
+
_context14.next = 6;
|
|
1710
1886
|
break;
|
|
1711
1887
|
}
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1888
|
+
if (!(address == networkAddresses.tokens.STADER)) {
|
|
1889
|
+
_context14.next = 5;
|
|
1890
|
+
break;
|
|
1891
|
+
}
|
|
1892
|
+
ETH_PROVIDER = new ethers.ethers.providers.JsonRpcProvider('https://rpc.ankr.com/eth');
|
|
1893
|
+
return _context14.abrupt("return", fetchPriceFromKyberSwap(STADER_ETH, ETH_PROVIDER, false));
|
|
1715
1894
|
case 5:
|
|
1716
|
-
return
|
|
1717
|
-
case
|
|
1718
|
-
_context11.prev = 8;
|
|
1719
|
-
_context11.t0 = _context11["catch"](2);
|
|
1720
|
-
return _context11.abrupt("return", fetchPriceFromDefiLlama(address));
|
|
1721
|
-
case 11:
|
|
1895
|
+
return _context14.abrupt("return", fetchPriceFromKyberSwap(address, provider));
|
|
1896
|
+
case 6:
|
|
1722
1897
|
matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
|
|
1723
1898
|
return isSameAddress(auToken.underlying, address);
|
|
1724
1899
|
});
|
|
1725
1900
|
if (!(matchingAuToken !== undefined)) {
|
|
1726
|
-
|
|
1901
|
+
_context14.next = 11;
|
|
1727
1902
|
break;
|
|
1728
1903
|
}
|
|
1729
|
-
return
|
|
1730
|
-
case
|
|
1904
|
+
return _context14.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
|
|
1905
|
+
case 11:
|
|
1731
1906
|
throw Error("Unable to fetch price for " + address);
|
|
1732
|
-
case
|
|
1907
|
+
case 12:
|
|
1733
1908
|
case "end":
|
|
1734
|
-
return
|
|
1909
|
+
return _context14.stop();
|
|
1735
1910
|
}
|
|
1736
|
-
},
|
|
1911
|
+
}, _callee14);
|
|
1737
1912
|
}));
|
|
1738
1913
|
return _fetchPrice2.apply(this, arguments);
|
|
1739
1914
|
}
|
|
1740
|
-
function fetchPrice(
|
|
1915
|
+
function fetchPrice(_x22, _x23) {
|
|
1741
1916
|
return _fetchPrice3.apply(this, arguments);
|
|
1742
1917
|
}
|
|
1743
1918
|
function _fetchPrice3() {
|
|
1744
|
-
_fetchPrice3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1745
|
-
return _regeneratorRuntime().wrap(function
|
|
1746
|
-
while (1) switch (
|
|
1919
|
+
_fetchPrice3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(address, provider) {
|
|
1920
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1921
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1747
1922
|
case 0:
|
|
1748
1923
|
if (!(address.toLowerCase() in HARDCODE_PRICE_TOKENS)) {
|
|
1749
|
-
|
|
1924
|
+
_context15.next = 4;
|
|
1750
1925
|
break;
|
|
1751
1926
|
}
|
|
1752
|
-
return
|
|
1927
|
+
return _context15.abrupt("return", new BigNumber(HARDCODE_PRICE_TOKENS[address.toLowerCase()]));
|
|
1753
1928
|
case 4:
|
|
1754
1929
|
if (!isSameAddress(address, networkAddresses.tokens.PLYWNEAR)) {
|
|
1755
|
-
|
|
1930
|
+
_context15.next = 8;
|
|
1756
1931
|
break;
|
|
1757
1932
|
}
|
|
1758
|
-
return
|
|
1933
|
+
return _context15.abrupt("return", fetchLPPrice(address, provider));
|
|
1759
1934
|
case 8:
|
|
1760
1935
|
if (!isSameAddress(address, networkAddresses.tokens.PLY)) {
|
|
1761
|
-
|
|
1936
|
+
_context15.next = 12;
|
|
1762
1937
|
break;
|
|
1763
1938
|
}
|
|
1764
|
-
return
|
|
1939
|
+
return _context15.abrupt("return", fetchPLYPrice(provider));
|
|
1765
1940
|
case 12:
|
|
1766
1941
|
if (!isSameAddress(address, networkAddresses.tokens.PULP)) {
|
|
1767
|
-
|
|
1942
|
+
_context15.next = 14;
|
|
1768
1943
|
break;
|
|
1769
1944
|
}
|
|
1770
|
-
return
|
|
1945
|
+
return _context15.abrupt("return", fetchPULPPrice(provider));
|
|
1771
1946
|
case 14:
|
|
1772
|
-
return
|
|
1947
|
+
return _context15.abrupt("return", _fetchPrice(address, provider));
|
|
1773
1948
|
case 15:
|
|
1774
1949
|
case "end":
|
|
1775
|
-
return
|
|
1950
|
+
return _context15.stop();
|
|
1776
1951
|
}
|
|
1777
|
-
},
|
|
1952
|
+
}, _callee15);
|
|
1778
1953
|
}));
|
|
1779
1954
|
return _fetchPrice3.apply(this, arguments);
|
|
1780
1955
|
}
|
|
1781
|
-
function fetchPLYPrice(
|
|
1956
|
+
function fetchPLYPrice(_x24) {
|
|
1782
1957
|
return _fetchPLYPrice.apply(this, arguments);
|
|
1783
1958
|
}
|
|
1784
1959
|
function _fetchPLYPrice() {
|
|
1785
|
-
_fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1786
|
-
return _regeneratorRuntime().wrap(function
|
|
1787
|
-
while (1) switch (
|
|
1960
|
+
_fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(provider) {
|
|
1961
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1962
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1788
1963
|
case 0:
|
|
1789
|
-
return
|
|
1964
|
+
return _context16.abrupt("return", fetchToken0PriceByLP(networkAddresses.tokens.PLYWNEAR, provider));
|
|
1790
1965
|
case 1:
|
|
1791
1966
|
case "end":
|
|
1792
|
-
return
|
|
1967
|
+
return _context16.stop();
|
|
1793
1968
|
}
|
|
1794
|
-
},
|
|
1969
|
+
}, _callee16);
|
|
1795
1970
|
}));
|
|
1796
1971
|
return _fetchPLYPrice.apply(this, arguments);
|
|
1797
1972
|
}
|
|
1798
|
-
function fetchPULPPrice(
|
|
1973
|
+
function fetchPULPPrice(_x25) {
|
|
1799
1974
|
return _fetchPULPPrice.apply(this, arguments);
|
|
1800
1975
|
}
|
|
1801
1976
|
function _fetchPULPPrice() {
|
|
1802
|
-
_fetchPULPPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1803
|
-
return _regeneratorRuntime().wrap(function
|
|
1804
|
-
while (1) switch (
|
|
1977
|
+
_fetchPULPPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(provider) {
|
|
1978
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1979
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1805
1980
|
case 0:
|
|
1806
|
-
return
|
|
1981
|
+
return _context17.abrupt("return", new BigNumber(0));
|
|
1807
1982
|
case 1:
|
|
1808
1983
|
case "end":
|
|
1809
|
-
return
|
|
1984
|
+
return _context17.stop();
|
|
1810
1985
|
}
|
|
1811
|
-
},
|
|
1986
|
+
}, _callee17);
|
|
1812
1987
|
}));
|
|
1813
1988
|
return _fetchPULPPrice.apply(this, arguments);
|
|
1814
1989
|
}
|
|
1815
|
-
function fetchToken0PriceByLP(
|
|
1990
|
+
function fetchToken0PriceByLP(_x26, _x27) {
|
|
1816
1991
|
return _fetchToken0PriceByLP.apply(this, arguments);
|
|
1817
1992
|
}
|
|
1818
1993
|
function _fetchToken0PriceByLP() {
|
|
1819
|
-
_fetchToken0PriceByLP = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1994
|
+
_fetchToken0PriceByLP = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(LP, provider) {
|
|
1820
1995
|
var LPInfo, token0Decimal, token1Decimal;
|
|
1821
|
-
return _regeneratorRuntime().wrap(function
|
|
1822
|
-
while (1) switch (
|
|
1996
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1997
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1823
1998
|
case 0:
|
|
1824
|
-
|
|
1999
|
+
_context18.next = 2;
|
|
1825
2000
|
return fetchLPPositions(LP, provider);
|
|
1826
2001
|
case 2:
|
|
1827
|
-
LPInfo =
|
|
2002
|
+
LPInfo = _context18.sent;
|
|
1828
2003
|
if (!LPInfo.reserve1.isZero()) {
|
|
1829
|
-
|
|
2004
|
+
_context18.next = 5;
|
|
1830
2005
|
break;
|
|
1831
2006
|
}
|
|
1832
|
-
return
|
|
2007
|
+
return _context18.abrupt("return", new BigNumber(0));
|
|
1833
2008
|
case 5:
|
|
1834
2009
|
token0Decimal = getDecimal(LPInfo.token0);
|
|
1835
2010
|
token1Decimal = getDecimal(LPInfo.token1); // (token0Price * reserve0) / 10^decimal0 = (token1Price * reserve1) / 10^decimal1
|
|
1836
2011
|
// token0Price = (token1Price * reserve1) * 10^decimal0 / 10^decimal1 / reserve0
|
|
1837
|
-
|
|
2012
|
+
_context18.next = 9;
|
|
1838
2013
|
return fetchPrice(LPInfo.token1, provider);
|
|
1839
2014
|
case 9:
|
|
1840
|
-
return
|
|
2015
|
+
return _context18.abrupt("return", _context18.sent.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(decimalFactor(token0Decimal)).dividedBy(decimalFactor(token1Decimal)).dividedBy(LPInfo.reserve0.toString()));
|
|
1841
2016
|
case 10:
|
|
1842
2017
|
case "end":
|
|
1843
|
-
return
|
|
2018
|
+
return _context18.stop();
|
|
1844
2019
|
}
|
|
1845
|
-
},
|
|
2020
|
+
}, _callee18);
|
|
1846
2021
|
}));
|
|
1847
2022
|
return _fetchToken0PriceByLP.apply(this, arguments);
|
|
1848
2023
|
}
|
|
1849
|
-
function fetchValuation(
|
|
2024
|
+
function fetchValuation(_x28, _x29) {
|
|
1850
2025
|
return _fetchValuation.apply(this, arguments);
|
|
1851
2026
|
}
|
|
1852
2027
|
function _fetchValuation() {
|
|
1853
|
-
_fetchValuation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2028
|
+
_fetchValuation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(tokenAmount, provider) {
|
|
1854
2029
|
var price;
|
|
1855
|
-
return _regeneratorRuntime().wrap(function
|
|
1856
|
-
while (1) switch (
|
|
2030
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
2031
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1857
2032
|
case 0:
|
|
1858
2033
|
if (!(tokenAmount.rawAmount() == '0')) {
|
|
1859
|
-
|
|
2034
|
+
_context19.next = 2;
|
|
1860
2035
|
break;
|
|
1861
2036
|
}
|
|
1862
|
-
return
|
|
2037
|
+
return _context19.abrupt("return", new BigNumber(0));
|
|
1863
2038
|
case 2:
|
|
1864
|
-
|
|
2039
|
+
_context19.next = 4;
|
|
1865
2040
|
return fetchPrice(tokenAmount.token.address, provider);
|
|
1866
2041
|
case 4:
|
|
1867
|
-
price =
|
|
1868
|
-
return
|
|
2042
|
+
price = _context19.sent;
|
|
2043
|
+
return _context19.abrupt("return", calcValuation(tokenAmount, price));
|
|
1869
2044
|
case 6:
|
|
1870
2045
|
case "end":
|
|
1871
|
-
return
|
|
2046
|
+
return _context19.stop();
|
|
1872
2047
|
}
|
|
1873
|
-
},
|
|
2048
|
+
}, _callee19);
|
|
1874
2049
|
}));
|
|
1875
2050
|
return _fetchValuation.apply(this, arguments);
|
|
1876
2051
|
}
|
|
1877
2052
|
function calcValuation(tokenAmount, price) {
|
|
1878
2053
|
return new BigNumber(tokenAmount.formattedAmount()).multipliedBy(price);
|
|
1879
2054
|
}
|
|
1880
|
-
function valuateToken(
|
|
2055
|
+
function valuateToken(_x30, _x31) {
|
|
1881
2056
|
return _valuateToken.apply(this, arguments);
|
|
1882
2057
|
}
|
|
1883
2058
|
function _valuateToken() {
|
|
1884
|
-
_valuateToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2059
|
+
_valuateToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(tokenAmount, provider) {
|
|
1885
2060
|
var tokenValuation;
|
|
1886
|
-
return _regeneratorRuntime().wrap(function
|
|
1887
|
-
while (1) switch (
|
|
2061
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2062
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1888
2063
|
case 0:
|
|
1889
|
-
|
|
2064
|
+
_context20.next = 2;
|
|
1890
2065
|
return fetchValuation(tokenAmount, provider);
|
|
1891
2066
|
case 2:
|
|
1892
|
-
tokenValuation =
|
|
1893
|
-
return
|
|
2067
|
+
tokenValuation = _context20.sent;
|
|
2068
|
+
return _context20.abrupt("return", {
|
|
1894
2069
|
tokenAmount: tokenAmount,
|
|
1895
2070
|
currencyAmount: {
|
|
1896
2071
|
currency: 'USD',
|
|
@@ -1899,9 +2074,9 @@ function _valuateToken() {
|
|
|
1899
2074
|
});
|
|
1900
2075
|
case 4:
|
|
1901
2076
|
case "end":
|
|
1902
|
-
return
|
|
2077
|
+
return _context20.stop();
|
|
1903
2078
|
}
|
|
1904
|
-
},
|
|
2079
|
+
}, _callee20);
|
|
1905
2080
|
}));
|
|
1906
2081
|
return _valuateToken.apply(this, arguments);
|
|
1907
2082
|
}
|
|
@@ -2288,6 +2463,9 @@ var helpers = {
|
|
|
2288
2463
|
getBlockBeforeTimestamp: getBlockBeforeTimestamp,
|
|
2289
2464
|
devLog: devLog,
|
|
2290
2465
|
sortEvents: sortEvents,
|
|
2466
|
+
prepareParamsAggregator: prepareParamsAggregator,
|
|
2467
|
+
fetchPriceFromOneInch: fetchPriceFromOneInch,
|
|
2468
|
+
fetchPriceFromKyberSwap: fetchPriceFromKyberSwap,
|
|
2291
2469
|
fetchPriceFromDefiLlamaAPI: fetchPriceFromDefiLlamaAPI,
|
|
2292
2470
|
fetchPriceFromCoingeckoAPI: fetchPriceFromCoingeckoAPI,
|
|
2293
2471
|
fetchPriceFromDefiLlama: fetchPriceFromDefiLlama,
|
|
@@ -2793,7 +2971,7 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2793
2971
|
}
|
|
2794
2972
|
_context14.t0 = helpers;
|
|
2795
2973
|
_context14.next = 13;
|
|
2796
|
-
return fetchValuation(TokenAmount.fromAddressAndAmount(networkAddresses.tokens.STADER, '
|
|
2974
|
+
return fetchValuation(TokenAmount.fromAddressAndAmount(networkAddresses.tokens.STADER, '0', false), this._networkConnection.provider);
|
|
2797
2975
|
case 13:
|
|
2798
2976
|
_context14.t1 = _context14.sent;
|
|
2799
2977
|
_context14.t2 = underlyingPrice.multipliedBy(totalDeposited.formattedAmount());
|
|
@@ -4652,7 +4830,7 @@ var StakingRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4652
4830
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
4653
4831
|
while (1) switch (_context3.prev = _context3.next) {
|
|
4654
4832
|
case 0:
|
|
4655
|
-
lpContract = new ethers.Contract(networkAddresses.tokens.PLYWNEAR,
|
|
4833
|
+
lpContract = new ethers.Contract(networkAddresses.tokens.PLYWNEAR, EIP20InterfaceABI.abi, this._networkConnection.provider);
|
|
4656
4834
|
_context3.next = 3;
|
|
4657
4835
|
return lpContract.balanceOf(user);
|
|
4658
4836
|
case 3:
|
|
@@ -4787,7 +4965,7 @@ var MulticallRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4787
4965
|
function MulticallRead(networkConnection) {
|
|
4788
4966
|
var _this;
|
|
4789
4967
|
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
4790
|
-
_this.multicall = new ethers.Contract(networkAddresses.misc.MULTICALL, abis$
|
|
4968
|
+
_this.multicall = new ethers.Contract(networkAddresses.misc.MULTICALL, abis$9.abi, networkConnection.provider);
|
|
4791
4969
|
return _this;
|
|
4792
4970
|
}
|
|
4793
4971
|
/**
|
|
@@ -5861,6 +6039,7 @@ exports.ReferralRead = ReferralRead;
|
|
|
5861
6039
|
exports.ReferralReadWrite = ReferralReadWrite;
|
|
5862
6040
|
exports.SDK = SDK;
|
|
5863
6041
|
exports.SD_INCENTIVE_IN_SD = SD_INCENTIVE_IN_SD;
|
|
6042
|
+
exports.STADER_ETH = STADER_ETH;
|
|
5864
6043
|
exports.SdkRead = SdkRead;
|
|
5865
6044
|
exports.SdkReadWrite = SdkReadWrite;
|
|
5866
6045
|
exports.Staking = Staking;
|
|
@@ -5869,6 +6048,7 @@ exports.StakingReadWrite = StakingReadWrite;
|
|
|
5869
6048
|
exports.Token = Token;
|
|
5870
6049
|
exports.TokenAmount = TokenAmount;
|
|
5871
6050
|
exports.TransferEventQuery = TransferEventQuery;
|
|
6051
|
+
exports.USDT_ETH = USDT_ETH;
|
|
5872
6052
|
exports.abis = index;
|
|
5873
6053
|
exports.assert = assert;
|
|
5874
6054
|
exports.calcLMRewardApr = calcLMRewardApr;
|
|
@@ -5902,6 +6082,8 @@ exports.fetchPriceFromCoingecko = fetchPriceFromCoingecko;
|
|
|
5902
6082
|
exports.fetchPriceFromCoingeckoAPI = fetchPriceFromCoingeckoAPI;
|
|
5903
6083
|
exports.fetchPriceFromDefiLlama = fetchPriceFromDefiLlama;
|
|
5904
6084
|
exports.fetchPriceFromDefiLlamaAPI = fetchPriceFromDefiLlamaAPI;
|
|
6085
|
+
exports.fetchPriceFromKyberSwap = fetchPriceFromKyberSwap;
|
|
6086
|
+
exports.fetchPriceFromOneInch = fetchPriceFromOneInch;
|
|
5905
6087
|
exports.fetchPriceFromOracle = fetchPriceFromOracle;
|
|
5906
6088
|
exports.fetchStNEARPrice = fetchStNEARPrice;
|
|
5907
6089
|
exports.fetchToken0PriceByLP = fetchToken0PriceByLP;
|
|
@@ -5921,6 +6103,7 @@ exports.getSymbol = getSymbol;
|
|
|
5921
6103
|
exports.getUnderlying = getUnderlying;
|
|
5922
6104
|
exports.isSameAddress = isSameAddress;
|
|
5923
6105
|
exports.networkAddresses = networkAddresses;
|
|
6106
|
+
exports.prepareParamsAggregator = prepareParamsAggregator;
|
|
5924
6107
|
exports.queryGraphQL = queryGraphQL;
|
|
5925
6108
|
exports.referralRewardDummy1 = referralRewardDummy1;
|
|
5926
6109
|
exports.referralRewardDummy2 = referralRewardDummy2;
|