@aurigami/sdk 1.0.3 → 1.1.0

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/sdk.esm.js CHANGED
@@ -940,6 +940,14 @@ var networkAddresses = {
940
940
  name: "auWNEAR",
941
941
  address: /*#__PURE__*/'0xaE4fac24dCdAE0132C6d04f564dCf059616E9423'.toLowerCase(),
942
942
  underlying: /*#__PURE__*/'0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase()
943
+ }, {
944
+ name: "auSTNEAR",
945
+ address: /*#__PURE__*/"0x3195949f267702723bc614cAE037cdc8D1E94786".toLowerCase(),
946
+ underlying: /*#__PURE__*/'0x07f9f7f963c5cd2bbffd30ccfb964be114332e30'.toLowerCase()
947
+ }, {
948
+ name: "auAURORA",
949
+ address: /*#__PURE__*/"0x8888682E24dd4Df7B7Ff2B91fccB575737E433bf".toLowerCase(),
950
+ underlying: /*#__PURE__*/"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase()
943
951
  }],
944
952
  misc: {
945
953
  COMPTROLLER: /*#__PURE__*/"0x817af6cfAF35BdC1A634d6cC94eE9e4c68369Aeb".toLowerCase(),
@@ -952,6 +960,7 @@ var networkAddresses = {
952
960
  tokens: {
953
961
  AURORA: /*#__PURE__*/"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase(),
954
962
  PLY: /*#__PURE__*/"0x981bD5832EAB9C8F607940E0e9faCBf8C09ee20a".toLowerCase(),
963
+ stNEAR: /*#__PURE__*/"0x07f9f7f963c5cd2bbffd30ccfb964be114332e30".toLowerCase(),
955
964
  AURPLY: /*#__PURE__*/dummyAddress.toLowerCase()
956
965
  }
957
966
  };
@@ -2045,12 +2054,12 @@ function fetchPriceFromCoingecko(_x2) {
2045
2054
  }
2046
2055
 
2047
2056
  function _fetchPriceFromCoingecko() {
2048
- _fetchPriceFromCoingecko = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(address) {
2057
+ _fetchPriceFromCoingecko = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(id) {
2049
2058
  return runtime_1.wrap(function _callee2$(_context2) {
2050
2059
  while (1) {
2051
2060
  switch (_context2.prev = _context2.next) {
2052
2061
  case 0:
2053
- if (!isSameAddress(address, networkAddresses.tokens.AURORA)) {
2062
+ if (!isSameAddress(id, networkAddresses.tokens.AURORA)) {
2054
2063
  _context2.next = 4;
2055
2064
  break;
2056
2065
  }
@@ -2058,7 +2067,7 @@ function _fetchPriceFromCoingecko() {
2058
2067
  return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('aurora-near'));
2059
2068
 
2060
2069
  case 4:
2061
- throw Error("Unknown token " + address + " in fetchPriceFromCoingecko");
2070
+ throw Error("Unknown token " + id + " in fetchPriceFromCoingecko");
2062
2071
 
2063
2072
  case 5:
2064
2073
  case "end":
@@ -2236,53 +2245,105 @@ function _fetchUnderlyingTokensPrices() {
2236
2245
  return _fetchUnderlyingTokensPrices.apply(this, arguments);
2237
2246
  }
2238
2247
 
2248
+ function fetchStNEARPrice() {
2249
+ return _fetchStNEARPrice.apply(this, arguments);
2250
+ }
2251
+
2252
+ function _fetchStNEARPrice() {
2253
+ _fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
2254
+ var ratioPromise, nearPricePromise, _yield$Promise$all, ratioRes, nearPrice, ratio;
2255
+
2256
+ return runtime_1.wrap(function _callee7$(_context7) {
2257
+ while (1) {
2258
+ switch (_context7.prev = _context7.next) {
2259
+ case 0:
2260
+ ratioPromise = axios.get("https://validators.narwallets.com/metrics_json").then(function (res) {
2261
+ return res.data;
2262
+ });
2263
+ nearPricePromise = fetchPriceFromCoingeckoAPI('near');
2264
+ _context7.next = 4;
2265
+ return Promise.all([ratioPromise, nearPricePromise]);
2266
+
2267
+ case 4:
2268
+ _yield$Promise$all = _context7.sent;
2269
+ ratioRes = _yield$Promise$all[0];
2270
+ nearPrice = _yield$Promise$all[1];
2271
+ ratio = new BigNumber(ratioRes.st_near_price);
2272
+ return _context7.abrupt("return", ratio.multipliedBy(nearPrice));
2273
+
2274
+ case 9:
2275
+ case "end":
2276
+ return _context7.stop();
2277
+ }
2278
+ }
2279
+ }, _callee7);
2280
+ }));
2281
+ return _fetchStNEARPrice.apply(this, arguments);
2282
+ }
2283
+
2239
2284
  function fetchPrice(_x11, _x12) {
2240
2285
  return _fetchPrice.apply(this, arguments);
2241
2286
  }
2242
2287
 
2243
2288
  function _fetchPrice() {
2244
- _fetchPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(address, provider) {
2289
+ _fetchPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(address, provider) {
2245
2290
  var matchingAuToken;
2246
- return runtime_1.wrap(function _callee7$(_context7) {
2291
+ return runtime_1.wrap(function _callee8$(_context8) {
2247
2292
  while (1) {
2248
- switch (_context7.prev = _context7.next) {
2293
+ switch (_context8.prev = _context8.next) {
2249
2294
  case 0:
2250
2295
  if (!( isSameAddress(address, networkAddresses.tokens.PLY))) {
2251
- _context7.next = 2;
2296
+ _context8.next = 2;
2252
2297
  break;
2253
2298
  }
2254
2299
 
2255
- return _context7.abrupt("return", new BigNumber(0));
2300
+ return _context8.abrupt("return", new BigNumber(0));
2256
2301
 
2257
2302
  case 2:
2303
+ if (!isSameAddress(address, networkAddresses.tokens.stNEAR)) {
2304
+ _context8.next = 4;
2305
+ break;
2306
+ }
2307
+
2308
+ return _context8.abrupt("return", fetchStNEARPrice());
2309
+
2310
+ case 4:
2311
+ if (!isSameAddress(address, networkAddresses.tokens.AURORA)) {
2312
+ _context8.next = 6;
2313
+ break;
2314
+ }
2315
+
2316
+ return _context8.abrupt("return", fetchPriceFromCoingecko(address));
2317
+
2318
+ case 6:
2258
2319
  matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
2259
2320
  return isSameAddress(auToken.underlying, address);
2260
2321
  });
2261
2322
 
2262
2323
  if (!(matchingAuToken !== undefined)) {
2263
- _context7.next = 7;
2324
+ _context8.next = 11;
2264
2325
  break;
2265
2326
  }
2266
2327
 
2267
- return _context7.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
2328
+ return _context8.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
2268
2329
 
2269
- case 7:
2330
+ case 11:
2270
2331
  if (!isSameAddress(address, networkAddresses.tokens.AUPLYLP)) {
2271
- _context7.next = 11;
2332
+ _context8.next = 15;
2272
2333
  break;
2273
2334
  }
2274
2335
 
2275
- return _context7.abrupt("return", fetchLPPrice(address, provider));
2336
+ return _context8.abrupt("return", fetchLPPrice(address, provider));
2276
2337
 
2277
- case 11:
2278
- return _context7.abrupt("return", fetchPriceFromCoingecko(address));
2338
+ case 15:
2339
+ return _context8.abrupt("return", fetchPriceFromCoingecko(address));
2279
2340
 
2280
- case 12:
2341
+ case 16:
2281
2342
  case "end":
2282
- return _context7.stop();
2343
+ return _context8.stop();
2283
2344
  }
2284
2345
  }
2285
- }, _callee7);
2346
+ }, _callee8);
2286
2347
  }));
2287
2348
  return _fetchPrice.apply(this, arguments);
2288
2349
  }
@@ -2292,25 +2353,25 @@ function fetchValuation(_x13, _x14) {
2292
2353
  }
2293
2354
 
2294
2355
  function _fetchValuation() {
2295
- _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(tokenAmount, provider) {
2356
+ _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(tokenAmount, provider) {
2296
2357
  var price;
2297
- return runtime_1.wrap(function _callee8$(_context8) {
2358
+ return runtime_1.wrap(function _callee9$(_context9) {
2298
2359
  while (1) {
2299
- switch (_context8.prev = _context8.next) {
2360
+ switch (_context9.prev = _context9.next) {
2300
2361
  case 0:
2301
- _context8.next = 2;
2362
+ _context9.next = 2;
2302
2363
  return fetchPrice(tokenAmount.token.address, provider);
2303
2364
 
2304
2365
  case 2:
2305
- price = _context8.sent;
2306
- return _context8.abrupt("return", calcValuation(tokenAmount, price));
2366
+ price = _context9.sent;
2367
+ return _context9.abrupt("return", calcValuation(tokenAmount, price));
2307
2368
 
2308
2369
  case 4:
2309
2370
  case "end":
2310
- return _context8.stop();
2371
+ return _context9.stop();
2311
2372
  }
2312
2373
  }
2313
- }, _callee8);
2374
+ }, _callee9);
2314
2375
  }));
2315
2376
  return _fetchValuation.apply(this, arguments);
2316
2377
  }
@@ -2648,7 +2709,9 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
2648
2709
  depositPlyApy: depositPlyApy.toNumber(),
2649
2710
  borrowApy: borrowAPY,
2650
2711
  borrowPlyApy: borrowPlyApy.toNumber(),
2651
- collateralRatio: collateralRatio
2712
+ collateralRatio: collateralRatio,
2713
+ depositPlyPerWeek: new TokenAmount(PLYToken, rewardSpeeds.plyRewardSupplySpeed.mul(ONE_DAY).mul(7).toString()),
2714
+ BorrowPlyPerWeek: new TokenAmount(PLYToken, rewardSpeeds.plyRewardBorrowSpeed.mul(ONE_DAY).mul(7).toString())
2652
2715
  });
2653
2716
 
2654
2717
  case 14:
@@ -3444,5 +3507,5 @@ BigNumber.config({
3444
3507
  DECIMAL_PLACES: 50
3445
3508
  });
3446
3509
 
3447
- export { AURORA_CHAINID, AURPLYToken, AurPlyPid, BORROW_LIMIT_BUFFER, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, ETHAddress, INF, MarketAction, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, ONE_YEAR, PLYToken, REWARDCLAIMSTART, SDK, SdkRead, SdkReadWrite, Token, TokenAmount, calcLMRewardApr, calcValuation, decimalFactor, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchLPPositions, fetchLPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromOracle, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getCurrentTimestamp, getDecimal, isSameAddress, networkAddresses, validateAndParseAddress };
3510
+ export { AURORA_CHAINID, AURPLYToken, AurPlyPid, BORROW_LIMIT_BUFFER, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, ETHAddress, INF, MarketAction, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, ONE_YEAR, PLYToken, REWARDCLAIMSTART, SDK, SdkRead, SdkReadWrite, Token, TokenAmount, calcLMRewardApr, calcValuation, decimalFactor, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchLPPositions, fetchLPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromOracle, fetchStNEARPrice, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getCurrentTimestamp, getDecimal, isSameAddress, networkAddresses, validateAndParseAddress };
3448
3511
  //# sourceMappingURL=sdk.esm.js.map