@aurigami/sdk 0.2.1 → 0.2.2

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.
@@ -12,6 +12,7 @@ export declare function fetchLPPositions(LPAddress: Address, provider: providers
12
12
  totalSupply: BN;
13
13
  }>;
14
14
  export declare function fetchLPPrice(address: Address, provider: providers.Provider): Promise<BigNumber>;
15
- export declare function fetchPriceFromOracle(auTokenAddress: Address, underlyingDecimals: number, provider: providers.Provider): Promise<BigNumber>;
15
+ export declare function fetchPriceFromOracle(auTokenAddress: Address, underlyingDecimal: number, provider: providers.Provider): Promise<BigNumber>;
16
+ export declare function fetchUnderlyingTokensPrices(provider: providers.Provider): Promise<any>;
16
17
  export declare function fetchPrice(address: Address, provider: providers.Provider): Promise<BigNumber>;
17
18
  export declare function fetchValuation(tokenAmount: TokenAmount, provider: providers.Provider, price?: BigNumber): Promise<BigNumber>;
@@ -935,7 +935,7 @@ var networkAddresses = {
935
935
  COMPTROLLER: "0xb51028d4f3fc69e3f9e3118ce067a4562c595aad",
936
936
  oracle: "0xf1ebfaa2af93f4d82215fd7817c1835853c62fb8",
937
937
  AURIFAIRLAUNCH: "0x7942874a9ef8059c5de259625a883dc61f03320d",
938
- AURILENS: dummyAddress
938
+ AURILENS: '0xa2635a23a7688cd3acdd07713c4943b2f0f9082c'
939
939
  },
940
940
  tokens: {
941
941
  AURORA: "0x7a80df8230c5aa711e2702a275ab31aeb32754bf",
@@ -2483,6 +2483,12 @@ var IUniswapV2PairABI = {
2483
2483
  deployedLinkReferences: deployedLinkReferences
2484
2484
  };
2485
2485
 
2486
+ var abi$2 = [
2487
+ ];
2488
+ var dummyABI = {
2489
+ abi: abi$2
2490
+ };
2491
+
2486
2492
  var axios = /*#__PURE__*/require('axios');
2487
2493
 
2488
2494
  function fetchPriceFromCoingecko(_x) {
@@ -2638,12 +2644,16 @@ function _fetchLPPrice() {
2638
2644
  return _fetchLPPrice.apply(this, arguments);
2639
2645
  }
2640
2646
 
2647
+ function processPriceFromOracle(rawPrice, underlyingDecimal) {
2648
+ return new BigNumber(rawPrice.toString()).div(decimalFactor(36 - underlyingDecimal));
2649
+ }
2650
+
2641
2651
  function fetchPriceFromOracle(_x7, _x8, _x9) {
2642
2652
  return _fetchPriceFromOracle.apply(this, arguments);
2643
2653
  }
2644
2654
 
2645
2655
  function _fetchPriceFromOracle() {
2646
- _fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(auTokenAddress, underlyingDecimals, provider) {
2656
+ _fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(auTokenAddress, underlyingDecimal, provider) {
2647
2657
  var oracleContract, rawPrice;
2648
2658
  return runtime_1.wrap(function _callee5$(_context5) {
2649
2659
  while (1) {
@@ -2655,7 +2665,7 @@ function _fetchPriceFromOracle() {
2655
2665
 
2656
2666
  case 3:
2657
2667
  rawPrice = _context5.sent;
2658
- return _context5.abrupt("return", new BigNumber(rawPrice.toString()).div(decimalFactor(36 - underlyingDecimals)));
2668
+ return _context5.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
2659
2669
 
2660
2670
  case 5:
2661
2671
  case "end":
@@ -2667,77 +2677,111 @@ function _fetchPriceFromOracle() {
2667
2677
  return _fetchPriceFromOracle.apply(this, arguments);
2668
2678
  }
2669
2679
 
2670
- function fetchPrice(_x10, _x11) {
2680
+ function fetchUnderlyingTokensPrices(_x10) {
2681
+ return _fetchUnderlyingTokensPrices.apply(this, arguments);
2682
+ }
2683
+
2684
+ function _fetchUnderlyingTokensPrices() {
2685
+ _fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(provider) {
2686
+ var auriLens, auTokenAddresses, underlyingDecimals, rawPrices;
2687
+ return runtime_1.wrap(function _callee6$(_context6) {
2688
+ while (1) {
2689
+ switch (_context6.prev = _context6.next) {
2690
+ case 0:
2691
+ auriLens = new ethers$1.Contract(networkAddresses.misc.AURILENS, dummyABI.abi, provider);
2692
+ auTokenAddresses = networkAddresses.auTokens.map(function (auToken) {
2693
+ return auToken.address;
2694
+ });
2695
+ underlyingDecimals = networkAddresses.auTokens.map(function (auToken) {
2696
+ return getDecimal(auToken.underlying);
2697
+ });
2698
+ _context6.next = 5;
2699
+ return auriLens.auTokenUnderlyingPriceAll(auTokenAddresses);
2700
+
2701
+ case 5:
2702
+ rawPrices = _context6.sent;
2703
+ return _context6.abrupt("return", rawPrices.map(function (res, ind) {
2704
+ return {
2705
+ auToken: res.auToken,
2706
+ underlyingPrice: processPriceFromOracle(res.underlyingPrice, underlyingDecimals[ind])
2707
+ };
2708
+ }));
2709
+
2710
+ case 7:
2711
+ case "end":
2712
+ return _context6.stop();
2713
+ }
2714
+ }
2715
+ }, _callee6);
2716
+ }));
2717
+ return _fetchUnderlyingTokensPrices.apply(this, arguments);
2718
+ }
2719
+
2720
+ function fetchPrice(_x11, _x12) {
2671
2721
  return _fetchPrice.apply(this, arguments);
2672
2722
  }
2673
2723
 
2674
2724
  function _fetchPrice() {
2675
- _fetchPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(address, provider) {
2725
+ _fetchPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(address, provider) {
2676
2726
  var matchingAuToken;
2677
- return runtime_1.wrap(function _callee6$(_context6) {
2727
+ return runtime_1.wrap(function _callee7$(_context7) {
2678
2728
  while (1) {
2679
- switch (_context6.prev = _context6.next) {
2729
+ switch (_context7.prev = _context7.next) {
2680
2730
  case 0:
2681
2731
  matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
2682
2732
  return isSameAddress(auToken.underlying, address);
2683
2733
  });
2684
2734
 
2685
2735
  if (!(matchingAuToken !== undefined)) {
2686
- _context6.next = 5;
2736
+ _context7.next = 5;
2687
2737
  break;
2688
2738
  }
2689
2739
 
2690
- return _context6.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
2740
+ return _context7.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
2691
2741
 
2692
2742
  case 5:
2693
2743
  if (!isSameAddress(address, networkAddresses.misc.AUPLYLP)) {
2694
- _context6.next = 9;
2744
+ _context7.next = 9;
2695
2745
  break;
2696
2746
  }
2697
2747
 
2698
- return _context6.abrupt("return", fetchLPPrice(address, provider));
2748
+ return _context7.abrupt("return", fetchLPPrice(address, provider));
2699
2749
 
2700
2750
  case 9:
2701
- return _context6.abrupt("return", fetchBasicTokenPrice(address));
2751
+ return _context7.abrupt("return", fetchBasicTokenPrice(address));
2702
2752
 
2703
2753
  case 10:
2704
2754
  case "end":
2705
- return _context6.stop();
2755
+ return _context7.stop();
2706
2756
  }
2707
2757
  }
2708
- }, _callee6);
2758
+ }, _callee7);
2709
2759
  }));
2710
2760
  return _fetchPrice.apply(this, arguments);
2711
2761
  }
2712
2762
 
2713
- function fetchValuation(_x12, _x13, _x14) {
2763
+ function fetchValuation(_x13, _x14, _x15) {
2714
2764
  return _fetchValuation.apply(this, arguments);
2715
2765
  }
2716
2766
 
2717
2767
  function _fetchValuation() {
2718
- _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(tokenAmount, provider, price) {
2719
- return runtime_1.wrap(function _callee7$(_context7) {
2768
+ _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(tokenAmount, provider, price) {
2769
+ return runtime_1.wrap(function _callee8$(_context8) {
2720
2770
  while (1) {
2721
- switch (_context7.prev = _context7.next) {
2771
+ switch (_context8.prev = _context8.next) {
2722
2772
  case 0:
2723
- return _context7.abrupt("return", new BigNumber(0));
2773
+ return _context8.abrupt("return", new BigNumber(0));
2724
2774
 
2725
2775
  case 1:
2726
2776
  case "end":
2727
- return _context7.stop();
2777
+ return _context8.stop();
2728
2778
  }
2729
2779
  }
2730
- }, _callee7);
2780
+ }, _callee8);
2731
2781
  }));
2732
2782
  return _fetchValuation.apply(this, arguments);
2733
2783
  }
2734
2784
 
2735
- var abi$2 = [
2736
- ];
2737
- var dummyABI = {
2738
- abi: abi$2
2739
- };
2740
-
2741
2785
  var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
2742
2786
  _inheritsLoose(SdkRead, _BlockchainEntityRead);
2743
2787
 
@@ -3208,6 +3252,7 @@ exports.fetchLPPrice = fetchLPPrice;
3208
3252
  exports.fetchPrice = fetchPrice;
3209
3253
  exports.fetchPriceFromCoingecko = fetchPriceFromCoingecko;
3210
3254
  exports.fetchPriceFromOracle = fetchPriceFromOracle;
3255
+ exports.fetchUnderlyingTokensPrices = fetchUnderlyingTokensPrices;
3211
3256
  exports.fetchValuation = fetchValuation;
3212
3257
  exports.formatObject = formatObject;
3213
3258
  exports.getCurrentTimestamp = getCurrentTimestamp;