@aurigami/sdk 1.12.6 → 1.12.8

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,17 +12,17 @@ var abis$1 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/Au
12
12
  var abis$2 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuriAirdrop.sol/AuriAirdrop.json'));
13
13
  var abis$3 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json'));
14
14
  var abis$4 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json'));
15
- var abis$5 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuriOracle.sol/AuriOracle.json'));
16
- var abis$6 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuToken.sol/AuToken.json'));
17
- var abis$7 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json'));
18
- var abis$8 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/EthRepayHelper.sol/EthRepayHelper.json'));
19
- var abis$9 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json'));
20
- var abis$a = _interopDefault(require('@aurigami/contracts/artifacts/contracts/mock/AuriInternalLens.sol/AuriInternalLens.json'));
15
+ var AuriOracleABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuriOracle.sol/AuriOracle.json'));
16
+ var abis$5 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuToken.sol/AuToken.json'));
17
+ var abis$6 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json'));
18
+ var abis$7 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/EthRepayHelper.sol/EthRepayHelper.json'));
19
+ var abis$8 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json'));
20
+ var abis$9 = _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$b = _interopDefault(require('@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json'));
23
- var abis$c = _interopDefault(require('@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json'));
24
- var abis$d = _interopDefault(require('@aurigami/contracts/artifacts/contracts/ReferralDirectoryV2.sol/ReferralDirectoryV2.json'));
25
- var abis$e = _interopDefault(require('@aurigami/contracts/artifacts/contracts/plygame/PlyGame.sol/PlyGame.json'));
22
+ var abis$a = _interopDefault(require('@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json'));
23
+ var abis$b = _interopDefault(require('@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json'));
24
+ var abis$c = _interopDefault(require('@aurigami/contracts/artifacts/contracts/ReferralDirectoryV2.sol/ReferralDirectoryV2.json'));
25
+ var abis$d = _interopDefault(require('@aurigami/contracts/artifacts/contracts/plygame/PlyGame.sol/PlyGame.json'));
26
26
  var MAINNET_ADDRESSES = _interopDefault(require('@aurigami/contracts/deployments/aurora_mainnet.json'));
27
27
  var aurora_testnet_json = _interopDefault(require('@aurigami/contracts/deployments/aurora_testnet.json'));
28
28
  var axios = _interopDefault(require('axios'));
@@ -32,22 +32,22 @@ var abstractSigner = require('@ethersproject/abstract-signer');
32
32
 
33
33
  var index = {
34
34
  __proto__: null,
35
- AuriOracleABI: abis$5,
36
- AuTokenABI: abis$6,
35
+ AuriOracleABI: AuriOracleABI,
36
+ AuTokenABI: abis$5,
37
37
  IUniswapV2PairABI: IUniswapV2PairABI,
38
38
  AuriAirdropABI: abis$2,
39
39
  AuriFairLaunchABI: abis$3,
40
40
  AuriLensABI: abis$4,
41
- ComptrollerABI: abis$7,
42
- EIP20InterfaceABI: abis$9,
43
- ReferralDirectoryV2ABI: abis$d,
41
+ ComptrollerABI: abis$6,
42
+ EIP20InterfaceABI: abis$8,
43
+ ReferralDirectoryV2ABI: abis$c,
44
44
  AuErc20ABI: abis,
45
45
  AuETHABI: abis$1,
46
- EthRepayHelperABI: abis$8,
47
- Multicall2ABI: abis$b,
48
- PulpABI: abis$c,
49
- AuriInternalLensABI: abis$a,
50
- PlyGameABI: abis$e
46
+ EthRepayHelperABI: abis$7,
47
+ Multicall2ABI: abis$a,
48
+ PulpABI: abis$b,
49
+ AuriInternalLensABI: abis$9,
50
+ PlyGameABI: abis$d
51
51
  };
52
52
 
53
53
  var dummyAddress = '0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE';
@@ -129,7 +129,10 @@ var networkAddresses = {
129
129
  META: /*#__PURE__*/'0xc21ff01229e982d7c8b8691163b0a3cb8f357453'.toLowerCase(),
130
130
  PULP: /*#__PURE__*/MAINNET_ADDRESSES.PULP.toLowerCase(),
131
131
  PLYWNEAR: /*#__PURE__*/MAINNET_ADDRESSES.ply_wnear_lp.toLowerCase(),
132
- USN: /*#__PURE__*/'0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase()
132
+ USN: /*#__PURE__*/'0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase(),
133
+ PLY_WNEAR: /*#__PURE__*/'0x044b6b0cd3bb13d2b9057781df4459c66781dce7'.toLowerCase(),
134
+ WNEAR_TRI: /*#__PURE__*/'0x84b123875f0f36b966d0b6ca14b31121bd9676ad'.toLowerCase(),
135
+ AURORA_WNEAR: /*#__PURE__*/'0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008'.toLowerCase()
133
136
  }
134
137
  };
135
138
  var DEPOSIT_ONLY_TOKENS = [/*#__PURE__*/MAINNET_ADDRESSES.auTokens.STNEAR.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.AURORA.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.TRI.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.PLY.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.USN.toLowerCase()]; // All token that we can calculate the price via oracle + coingecko
@@ -217,7 +220,9 @@ var decimalRecords = {
217
220
  '0xc21ff01229e982d7c8b8691163b0a3cb8f357453': 24,
218
221
  '0x04ac48711bcdc45b4d223fb021e09da73c71095e': 18,
219
222
  '0x044b6b0cd3bb13d2b9057781df4459c66781dce7': 18,
220
- '0x5183e1b1091804bc2602586919e6880ac1cf2896': 18
223
+ '0x5183e1b1091804bc2602586919e6880ac1cf2896': 18,
224
+ '0x84b123875f0f36b966d0b6ca14b31121bd9676ad': 18,
225
+ '0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008': 18
221
226
  };
222
227
 
223
228
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -1593,7 +1598,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
1593
1598
  var _this2 = this;
1594
1599
 
1595
1600
  return networkAddresses.auTokens.map(function (auToken) {
1596
- var contract = _this2.getContract(auToken.address, abis$6.abi);
1601
+ var contract = _this2.getContract(auToken.address, abis$5.abi);
1597
1602
 
1598
1603
  contract.underlying = auToken.underlying;
1599
1604
  return contract;
@@ -1628,7 +1633,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
1628
1633
  key: "comptroller",
1629
1634
  get: function get() {
1630
1635
  if (!this._comptroller) {
1631
- this._comptroller = this.getContract(networkAddresses.misc.COMPTROLLER, abis$7.abi);
1636
+ this._comptroller = this.getContract(networkAddresses.misc.COMPTROLLER, abis$6.abi);
1632
1637
  }
1633
1638
 
1634
1639
  return this._comptroller;
@@ -1655,7 +1660,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
1655
1660
  key: "ply",
1656
1661
  get: function get() {
1657
1662
  if (!this._ply) {
1658
- this._ply = this.getContract(networkAddresses.tokens.PLY, abis$9.abi);
1663
+ this._ply = this.getContract(networkAddresses.tokens.PLY, abis$8.abi);
1659
1664
  }
1660
1665
 
1661
1666
  return this._ply;
@@ -1664,7 +1669,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
1664
1669
  key: "pulp",
1665
1670
  get: function get() {
1666
1671
  if (!this._pulp) {
1667
- this._pulp = this.getContract(networkAddresses.tokens.PULP, abis$c.abi);
1672
+ this._pulp = this.getContract(networkAddresses.tokens.PULP, abis$b.abi);
1668
1673
  }
1669
1674
 
1670
1675
  return this._pulp;
@@ -1673,7 +1678,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
1673
1678
  key: "auriInternalLens",
1674
1679
  get: function get() {
1675
1680
  if (!this._auriInternalLens) {
1676
- this._auriInternalLens = this.getContract(networkAddresses.misc.AURI_INTERNAL_LENS, abis$a.abi);
1681
+ this._auriInternalLens = this.getContract(networkAddresses.misc.AURI_INTERNAL_LENS, abis$9.abi);
1677
1682
  }
1678
1683
 
1679
1684
  return this._auriInternalLens;
@@ -1691,7 +1696,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
1691
1696
  key: "referralDirectoryV2",
1692
1697
  get: function get() {
1693
1698
  if (!this._referralDirectoryV2) {
1694
- this._referralDirectoryV2 = this.getContract(networkAddresses.misc.REFERRAL_V2, abis$d.abi);
1699
+ this._referralDirectoryV2 = this.getContract(networkAddresses.misc.REFERRAL_V2, abis$c.abi);
1695
1700
  }
1696
1701
 
1697
1702
  return this._referralDirectoryV2;
@@ -1700,7 +1705,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
1700
1705
  key: "oracle",
1701
1706
  get: function get() {
1702
1707
  if (!this._oracle) {
1703
- this._oracle = this.getContract(networkAddresses.misc.oracle, abis$5.abi);
1708
+ this._oracle = this.getContract(networkAddresses.misc.oracle, AuriOracleABI.abi);
1704
1709
  }
1705
1710
 
1706
1711
  return this._oracle;
@@ -1709,7 +1714,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
1709
1714
  key: "plygame",
1710
1715
  get: function get() {
1711
1716
  if (!this._plygame) {
1712
- this._plygame = this.getContract(networkAddresses.misc.PLYGAME, abis$e.abi);
1717
+ this._plygame = this.getContract(networkAddresses.misc.PLYGAME, abis$d.abi);
1713
1718
  }
1714
1719
 
1715
1720
  return this._plygame;
@@ -2232,7 +2237,7 @@ function _fetchPriceFromOracle() {
2232
2237
  while (1) {
2233
2238
  switch (_context9.prev = _context9.next) {
2234
2239
  case 0:
2235
- oracleContract = new ethers.Contract(networkAddresses.misc.oracle, abis$5.abi, provider);
2240
+ oracleContract = new ethers.Contract(networkAddresses.misc.oracle, AuriOracleABI.abi, provider);
2236
2241
  _context9.next = 3;
2237
2242
  return oracleContract.getUnderlyingPrice(auTokenAddress)["catch"](function (e) {
2238
2243
  console.log("Unable to fetch price from oracle for " + auTokenAddress);
@@ -2598,7 +2603,7 @@ var TransferEventQuery = /*#__PURE__*/function (_BlockchainEntityRead) {
2598
2603
  var _this;
2599
2604
 
2600
2605
  _this = _BlockchainEntityRead.call(this, networkConnection) || this;
2601
- _this.auToken = new ethers.Contract(tokenAddr, abis$6.abi, _this._networkConnection.provider);
2606
+ _this.auToken = new ethers.Contract(tokenAddr, abis$5.abi, _this._networkConnection.provider);
2602
2607
  return _this;
2603
2608
  }
2604
2609
  /**
@@ -2692,6 +2697,351 @@ var TransferEventQuery = /*#__PURE__*/function (_BlockchainEntityRead) {
2692
2697
  return TransferEventQuery;
2693
2698
  }(BlockchainEntityRead);
2694
2699
 
2700
+ function fetchHistoricalLPPositions(_x, _x2, _x3) {
2701
+ return _fetchHistoricalLPPositions.apply(this, arguments);
2702
+ }
2703
+
2704
+ function _fetchHistoricalLPPositions() {
2705
+ _fetchHistoricalLPPositions = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(LPAddress, provider, block) {
2706
+ var LPContract, promises, values;
2707
+ return runtime_1.wrap(function _callee$(_context) {
2708
+ while (1) {
2709
+ switch (_context.prev = _context.next) {
2710
+ case 0:
2711
+ LPContract = new ethers.Contract(LPAddress, IUniswapV2PairABI.abi, provider);
2712
+ promises = [];
2713
+ promises.push(LPContract.token0());
2714
+ promises.push(LPContract.token1());
2715
+ promises.push(LPContract.getReserves({
2716
+ blockTag: block
2717
+ }));
2718
+ promises.push(LPContract.totalSupply({
2719
+ blockTag: block
2720
+ }));
2721
+ _context.next = 8;
2722
+ return Promise.all(promises);
2723
+
2724
+ case 8:
2725
+ values = _context.sent;
2726
+ return _context.abrupt("return", {
2727
+ token0: values[0],
2728
+ token1: values[1],
2729
+ reserve0: values[2].reserve0,
2730
+ reserve1: values[2].reserve1,
2731
+ totalSupply: values[3]
2732
+ });
2733
+
2734
+ case 10:
2735
+ case "end":
2736
+ return _context.stop();
2737
+ }
2738
+ }
2739
+ }, _callee);
2740
+ }));
2741
+ return _fetchHistoricalLPPositions.apply(this, arguments);
2742
+ }
2743
+
2744
+ function fetchHistoricalLPPrice(_x4, _x5, _x6) {
2745
+ return _fetchHistoricalLPPrice.apply(this, arguments);
2746
+ }
2747
+
2748
+ function _fetchHistoricalLPPrice() {
2749
+ _fetchHistoricalLPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(address, provider, block) {
2750
+ var LPInfo, LPDecimal, fetchLPPriceBy, _fetchLPPriceBy, lpPrice;
2751
+
2752
+ return runtime_1.wrap(function _callee3$(_context3) {
2753
+ while (1) {
2754
+ switch (_context3.prev = _context3.next) {
2755
+ case 0:
2756
+ _fetchLPPriceBy = function _fetchLPPriceBy3() {
2757
+ _fetchLPPriceBy = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(tokenReverse, block) {
2758
+ var tokenPrice, tokenDecimal, reserveUSD;
2759
+ return runtime_1.wrap(function _callee2$(_context2) {
2760
+ while (1) {
2761
+ switch (_context2.prev = _context2.next) {
2762
+ case 0:
2763
+ if (!tokenReverse.reserve.isZero()) {
2764
+ _context2.next = 2;
2765
+ break;
2766
+ }
2767
+
2768
+ return _context2.abrupt("return", new BigNumber(0));
2769
+
2770
+ case 2:
2771
+ _context2.next = 4;
2772
+ return fetchHistoricalPrice(tokenReverse.address, provider, block);
2773
+
2774
+ case 4:
2775
+ tokenPrice = _context2.sent;
2776
+ tokenDecimal = getDecimal(tokenReverse.address); // reserveUSD will be divided by 10^tokenDecimal later for more precision
2777
+
2778
+ reserveUSD = tokenPrice.multipliedBy(tokenReverse.reserve.toString()).multipliedBy(2);
2779
+ return _context2.abrupt("return", reserveUSD.multipliedBy(decimalFactor(LPDecimal)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())).dividedBy(decimalFactor(tokenDecimal)));
2780
+
2781
+ case 8:
2782
+ case "end":
2783
+ return _context2.stop();
2784
+ }
2785
+ }
2786
+ }, _callee2);
2787
+ }));
2788
+ return _fetchLPPriceBy.apply(this, arguments);
2789
+ };
2790
+
2791
+ fetchLPPriceBy = function _fetchLPPriceBy2(_x19, _x20) {
2792
+ return _fetchLPPriceBy.apply(this, arguments);
2793
+ };
2794
+
2795
+ _context3.next = 4;
2796
+ return fetchHistoricalLPPositions(address, provider, block);
2797
+
2798
+ case 4:
2799
+ LPInfo = _context3.sent;
2800
+ LPDecimal = getDecimal(address);
2801
+ _context3.prev = 6;
2802
+ _context3.next = 9;
2803
+ return fetchLPPriceBy({
2804
+ address: LPInfo.token0,
2805
+ reserve: LPInfo.reserve0
2806
+ }, block);
2807
+
2808
+ case 9:
2809
+ lpPrice = _context3.sent;
2810
+
2811
+ if (!lpPrice.isZero()) {
2812
+ _context3.next = 12;
2813
+ break;
2814
+ }
2815
+
2816
+ throw Error("Price is zero");
2817
+
2818
+ case 12:
2819
+ return _context3.abrupt("return", lpPrice);
2820
+
2821
+ case 15:
2822
+ _context3.prev = 15;
2823
+ _context3.t0 = _context3["catch"](6);
2824
+ devLog("fetchLPPriceBy " + LPInfo.token0 + " failed", _context3.t0);
2825
+ _context3.prev = 18;
2826
+ _context3.next = 21;
2827
+ return fetchLPPriceBy({
2828
+ address: LPInfo.token1,
2829
+ reserve: LPInfo.reserve1
2830
+ }, block);
2831
+
2832
+ case 21:
2833
+ return _context3.abrupt("return", _context3.sent);
2834
+
2835
+ case 24:
2836
+ _context3.prev = 24;
2837
+ _context3.t1 = _context3["catch"](18);
2838
+ devLog("fetchLPPriceBy " + LPInfo.token1 + " failed", _context3.t1);
2839
+ throw Error("Unable to fetch price for both tokens of LP " + address);
2840
+
2841
+ case 28:
2842
+ case "end":
2843
+ return _context3.stop();
2844
+ }
2845
+ }
2846
+ }, _callee3, null, [[6, 15], [18, 24]]);
2847
+ }));
2848
+ return _fetchHistoricalLPPrice.apply(this, arguments);
2849
+ }
2850
+
2851
+ function processPriceFromOracle$1(rawPrice, underlyingDecimal) {
2852
+ return new BigNumber(rawPrice.toString()).div(decimalFactor(36 - underlyingDecimal));
2853
+ }
2854
+
2855
+ function fetchHistoricalPriceFromOracle(_x7, _x8, _x9, _x10) {
2856
+ return _fetchHistoricalPriceFromOracle.apply(this, arguments);
2857
+ }
2858
+
2859
+ function _fetchHistoricalPriceFromOracle() {
2860
+ _fetchHistoricalPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(auTokenAddress, underlyingDecimal, provider, block) {
2861
+ var oracleContract, rawPrice;
2862
+ return runtime_1.wrap(function _callee4$(_context4) {
2863
+ while (1) {
2864
+ switch (_context4.prev = _context4.next) {
2865
+ case 0:
2866
+ oracleContract = new ethers.Contract(networkAddresses.misc.oracle, AuriOracleABI.abi, provider);
2867
+ _context4.next = 3;
2868
+ return oracleContract.getUnderlyingPrice(auTokenAddress, {
2869
+ blockTag: block
2870
+ })["catch"](function (e) {
2871
+ console.log("Unable to fetch price from oracle for " + auTokenAddress);
2872
+ return ethers.BigNumber.from(0);
2873
+ });
2874
+
2875
+ case 3:
2876
+ rawPrice = _context4.sent;
2877
+ return _context4.abrupt("return", processPriceFromOracle$1(rawPrice, underlyingDecimal));
2878
+
2879
+ case 5:
2880
+ case "end":
2881
+ return _context4.stop();
2882
+ }
2883
+ }
2884
+ }, _callee4);
2885
+ }));
2886
+ return _fetchHistoricalPriceFromOracle.apply(this, arguments);
2887
+ }
2888
+
2889
+ function fetchHistoricalPrice(_x11, _x12, _x13) {
2890
+ return _fetchHistoricalPrice.apply(this, arguments);
2891
+ }
2892
+
2893
+ function _fetchHistoricalPrice() {
2894
+ _fetchHistoricalPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(address, provider, block) {
2895
+ var matchingAuToken;
2896
+ return runtime_1.wrap(function _callee5$(_context5) {
2897
+ while (1) {
2898
+ switch (_context5.prev = _context5.next) {
2899
+ case 0:
2900
+ if (!(address.toLowerCase() in HARDCODE_PRICE_TOKENS)) {
2901
+ _context5.next = 4;
2902
+ break;
2903
+ }
2904
+
2905
+ return _context5.abrupt("return", new BigNumber(HARDCODE_PRICE_TOKENS[address.toLowerCase()]));
2906
+
2907
+ case 4:
2908
+ if (!(isSameAddress(address, networkAddresses.tokens.PLY_WNEAR) || isSameAddress(address, networkAddresses.tokens.WNEAR_TRI) || isSameAddress(address, networkAddresses.tokens.AURORA_WNEAR))) {
2909
+ _context5.next = 8;
2910
+ break;
2911
+ }
2912
+
2913
+ return _context5.abrupt("return", fetchHistoricalLPPrice(address, provider, block));
2914
+
2915
+ case 8:
2916
+ if (!isSameAddress(address, networkAddresses.tokens.PLY)) {
2917
+ _context5.next = 12;
2918
+ break;
2919
+ }
2920
+
2921
+ return _context5.abrupt("return", fetchHistoricalPriceByLP(networkAddresses.tokens.PLY_WNEAR, provider, block));
2922
+
2923
+ case 12:
2924
+ if (!isSameAddress(address, networkAddresses.tokens.TRI)) {
2925
+ _context5.next = 16;
2926
+ break;
2927
+ }
2928
+
2929
+ return _context5.abrupt("return", fetchHistoricalPriceByLP(networkAddresses.tokens.WNEAR_TRI, provider, block, 1));
2930
+
2931
+ case 16:
2932
+ if (!isSameAddress(address, networkAddresses.tokens.AURORA)) {
2933
+ _context5.next = 18;
2934
+ break;
2935
+ }
2936
+
2937
+ return _context5.abrupt("return", fetchHistoricalPriceByLP(networkAddresses.tokens.AURORA_WNEAR, provider, block));
2938
+
2939
+ case 18:
2940
+ matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
2941
+ return isSameAddress(auToken.underlying, address);
2942
+ });
2943
+
2944
+ if (!(matchingAuToken !== undefined)) {
2945
+ _context5.next = 23;
2946
+ break;
2947
+ }
2948
+
2949
+ return _context5.abrupt("return", fetchHistoricalPriceFromOracle(matchingAuToken.address, getDecimal(address), provider, block));
2950
+
2951
+ case 23:
2952
+ throw Error("Unable to fetch price for " + address);
2953
+
2954
+ case 24:
2955
+ case "end":
2956
+ return _context5.stop();
2957
+ }
2958
+ }
2959
+ }, _callee5);
2960
+ }));
2961
+ return _fetchHistoricalPrice.apply(this, arguments);
2962
+ }
2963
+
2964
+ function fetchHistoricalPULPPrice(_x14) {
2965
+ return _fetchHistoricalPULPPrice.apply(this, arguments);
2966
+ }
2967
+
2968
+ function _fetchHistoricalPULPPrice() {
2969
+ _fetchHistoricalPULPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(provider) {
2970
+ return runtime_1.wrap(function _callee6$(_context6) {
2971
+ while (1) {
2972
+ switch (_context6.prev = _context6.next) {
2973
+ case 0:
2974
+ return _context6.abrupt("return", new BigNumber(0));
2975
+
2976
+ case 1:
2977
+ case "end":
2978
+ return _context6.stop();
2979
+ }
2980
+ }
2981
+ }, _callee6);
2982
+ }));
2983
+ return _fetchHistoricalPULPPrice.apply(this, arguments);
2984
+ }
2985
+
2986
+ function fetchHistoricalPriceByLP(_x15, _x16, _x17, _x18) {
2987
+ return _fetchHistoricalPriceByLP.apply(this, arguments);
2988
+ }
2989
+
2990
+ function _fetchHistoricalPriceByLP() {
2991
+ _fetchHistoricalPriceByLP = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(LP, provider, block, tokenNumber) {
2992
+ var LPInfo, token0Decimal, token1Decimal;
2993
+ return runtime_1.wrap(function _callee7$(_context7) {
2994
+ while (1) {
2995
+ switch (_context7.prev = _context7.next) {
2996
+ case 0:
2997
+ if (tokenNumber === void 0) {
2998
+ tokenNumber = 0;
2999
+ }
3000
+
3001
+ _context7.next = 3;
3002
+ return fetchHistoricalLPPositions(LP, provider, block);
3003
+
3004
+ case 3:
3005
+ LPInfo = _context7.sent;
3006
+
3007
+ if (tokenNumber === 1) {
3008
+ LPInfo = {
3009
+ token0: LPInfo.token1,
3010
+ token1: LPInfo.token0,
3011
+ reserve0: LPInfo.reserve1,
3012
+ reserve1: LPInfo.reserve0,
3013
+ totalSupply: LPInfo.totalSupply
3014
+ };
3015
+ }
3016
+
3017
+ if (!LPInfo.reserve1.isZero()) {
3018
+ _context7.next = 7;
3019
+ break;
3020
+ }
3021
+
3022
+ return _context7.abrupt("return", new BigNumber(0));
3023
+
3024
+ case 7:
3025
+ token0Decimal = getDecimal(LPInfo.token0);
3026
+ token1Decimal = getDecimal(LPInfo.token1); // (token0Price * reserve0) / 10^decimal0 = (token1Price * reserve1) / 10^decimal1
3027
+ // token0Price = (token1Price * reserve1) * 10^decimal0 / 10^decimal1 / reserve0
3028
+
3029
+ _context7.next = 11;
3030
+ return fetchHistoricalPrice(LPInfo.token1, provider, block);
3031
+
3032
+ case 11:
3033
+ return _context7.abrupt("return", _context7.sent.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(decimalFactor(token0Decimal)).dividedBy(decimalFactor(token1Decimal)).dividedBy(LPInfo.reserve0.toString()));
3034
+
3035
+ case 12:
3036
+ case "end":
3037
+ return _context7.stop();
3038
+ }
3039
+ }
3040
+ }, _callee7);
3041
+ }));
3042
+ return _fetchHistoricalPriceByLP.apply(this, arguments);
3043
+ }
3044
+
2695
3045
 
2696
3046
 
2697
3047
  var helpers = {
@@ -2733,7 +3083,13 @@ var helpers = {
2733
3083
  fetchValuation: fetchValuation,
2734
3084
  calcValuation: calcValuation,
2735
3085
  valuateToken: valuateToken,
2736
- TransferEventQuery: TransferEventQuery
3086
+ TransferEventQuery: TransferEventQuery,
3087
+ fetchHistoricalLPPositions: fetchHistoricalLPPositions,
3088
+ fetchHistoricalLPPrice: fetchHistoricalLPPrice,
3089
+ fetchHistoricalPriceFromOracle: fetchHistoricalPriceFromOracle,
3090
+ fetchHistoricalPrice: fetchHistoricalPrice,
3091
+ fetchHistoricalPULPPrice: fetchHistoricalPULPPrice,
3092
+ fetchHistoricalPriceByLP: fetchHistoricalPriceByLP
2737
3093
  };
2738
3094
 
2739
3095
  var AirdropRead = /*#__PURE__*/function (_BlockchainEntityRead) {
@@ -3382,6 +3738,66 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3382
3738
  }
3383
3739
  };
3384
3740
 
3741
+ _proto.mintCap = /*#__PURE__*/function () {
3742
+ var _mintCap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12() {
3743
+ return runtime_1.wrap(function _callee12$(_context12) {
3744
+ while (1) {
3745
+ switch (_context12.prev = _context12.next) {
3746
+ case 0:
3747
+ _context12.t0 = TokenAmount;
3748
+ _context12.t1 = this.underlying;
3749
+ _context12.next = 4;
3750
+ return this.env.comptroller.mintCaps(this.auToken.address);
3751
+
3752
+ case 4:
3753
+ _context12.t2 = _context12.sent.toString();
3754
+ return _context12.abrupt("return", new _context12.t0(_context12.t1, _context12.t2));
3755
+
3756
+ case 6:
3757
+ case "end":
3758
+ return _context12.stop();
3759
+ }
3760
+ }
3761
+ }, _callee12, this);
3762
+ }));
3763
+
3764
+ function mintCap() {
3765
+ return _mintCap.apply(this, arguments);
3766
+ }
3767
+
3768
+ return mintCap;
3769
+ }();
3770
+
3771
+ _proto.borrowCap = /*#__PURE__*/function () {
3772
+ var _borrowCap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13() {
3773
+ return runtime_1.wrap(function _callee13$(_context13) {
3774
+ while (1) {
3775
+ switch (_context13.prev = _context13.next) {
3776
+ case 0:
3777
+ _context13.t0 = TokenAmount;
3778
+ _context13.t1 = this.underlying;
3779
+ _context13.next = 4;
3780
+ return this.env.comptroller.borrowCaps(this.auToken.address);
3781
+
3782
+ case 4:
3783
+ _context13.t2 = _context13.sent.toString();
3784
+ return _context13.abrupt("return", new _context13.t0(_context13.t1, _context13.t2));
3785
+
3786
+ case 6:
3787
+ case "end":
3788
+ return _context13.stop();
3789
+ }
3790
+ }
3791
+ }, _callee13, this);
3792
+ }));
3793
+
3794
+ function borrowCap() {
3795
+ return _borrowCap.apply(this, arguments);
3796
+ }
3797
+
3798
+ return borrowCap;
3799
+ }();
3800
+
3385
3801
  return MoneyMarketRead;
3386
3802
  }(BlockchainEntityRead);
3387
3803
  var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
@@ -3391,36 +3807,36 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
3391
3807
  var _this3;
3392
3808
 
3393
3809
  _this3 = _MoneyMarketRead.call(this, networkConnection, auToken, underlyingAsset) || this;
3394
- _this3._EthRepayHelper = new ethers.Contract(networkAddresses.misc.ETHREPAYHELPER, abis$8.abi, networkConnection.provider);
3810
+ _this3._EthRepayHelper = new ethers.Contract(networkAddresses.misc.ETHREPAYHELPER, abis$7.abi, networkConnection.provider);
3395
3811
  return _this3;
3396
3812
  }
3397
3813
 
3398
3814
  var _proto2 = MoneyMarketReadWrite.prototype;
3399
3815
 
3400
3816
  _proto2.deposit = /*#__PURE__*/function () {
3401
- var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(amount) {
3402
- return runtime_1.wrap(function _callee12$(_context12) {
3817
+ var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(amount) {
3818
+ return runtime_1.wrap(function _callee14$(_context14) {
3403
3819
  while (1) {
3404
- switch (_context12.prev = _context12.next) {
3820
+ switch (_context14.prev = _context14.next) {
3405
3821
  case 0:
3406
3822
  if (!isSameAddress(amount.token.address, ETHAddress)) {
3407
- _context12.next = 4;
3823
+ _context14.next = 4;
3408
3824
  break;
3409
3825
  }
3410
3826
 
3411
- return _context12.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
3827
+ return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
3412
3828
  value: amount.rawAmount()
3413
3829
  }));
3414
3830
 
3415
3831
  case 4:
3416
- return _context12.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint(amount.rawAmount()));
3832
+ return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint(amount.rawAmount()));
3417
3833
 
3418
3834
  case 5:
3419
3835
  case "end":
3420
- return _context12.stop();
3836
+ return _context14.stop();
3421
3837
  }
3422
3838
  }
3423
- }, _callee12, this);
3839
+ }, _callee14, this);
3424
3840
  }));
3425
3841
 
3426
3842
  function deposit(_x3) {
@@ -3431,19 +3847,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
3431
3847
  }();
3432
3848
 
3433
3849
  _proto2.borrow = /*#__PURE__*/function () {
3434
- var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(amount) {
3435
- return runtime_1.wrap(function _callee13$(_context13) {
3850
+ var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15(amount) {
3851
+ return runtime_1.wrap(function _callee15$(_context15) {
3436
3852
  while (1) {
3437
- switch (_context13.prev = _context13.next) {
3853
+ switch (_context15.prev = _context15.next) {
3438
3854
  case 0:
3439
- return _context13.abrupt("return", this.auToken.connect(this._networkConnection.signer).borrow(amount.rawAmount()));
3855
+ return _context15.abrupt("return", this.auToken.connect(this._networkConnection.signer).borrow(amount.rawAmount()));
3440
3856
 
3441
3857
  case 1:
3442
3858
  case "end":
3443
- return _context13.stop();
3859
+ return _context15.stop();
3444
3860
  }
3445
3861
  }
3446
- }, _callee13, this);
3862
+ }, _callee15, this);
3447
3863
  }));
3448
3864
 
3449
3865
  function borrow(_x4) {
@@ -3454,27 +3870,27 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
3454
3870
  }();
3455
3871
 
3456
3872
  _proto2.withdraw = /*#__PURE__*/function () {
3457
- var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(amount) {
3458
- return runtime_1.wrap(function _callee14$(_context14) {
3873
+ var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16(amount) {
3874
+ return runtime_1.wrap(function _callee16$(_context16) {
3459
3875
  while (1) {
3460
- switch (_context14.prev = _context14.next) {
3876
+ switch (_context16.prev = _context16.next) {
3461
3877
  case 0:
3462
3878
  if (!new BigNumber(amount.rawAmount()).lt(0)) {
3463
- _context14.next = 2;
3879
+ _context16.next = 2;
3464
3880
  break;
3465
3881
  }
3466
3882
 
3467
- return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(INF));
3883
+ return _context16.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(INF));
3468
3884
 
3469
3885
  case 2:
3470
- return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
3886
+ return _context16.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
3471
3887
 
3472
3888
  case 3:
3473
3889
  case "end":
3474
- return _context14.stop();
3890
+ return _context16.stop();
3475
3891
  }
3476
3892
  }
3477
- }, _callee14, this);
3893
+ }, _callee16, this);
3478
3894
  }));
3479
3895
 
3480
3896
  function withdraw(_x5) {
@@ -3485,37 +3901,37 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
3485
3901
  }();
3486
3902
 
3487
3903
  _proto2.repay = /*#__PURE__*/function () {
3488
- var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15(amount) {
3489
- return runtime_1.wrap(function _callee15$(_context15) {
3904
+ var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee17(amount) {
3905
+ return runtime_1.wrap(function _callee17$(_context17) {
3490
3906
  while (1) {
3491
- switch (_context15.prev = _context15.next) {
3907
+ switch (_context17.prev = _context17.next) {
3492
3908
  case 0:
3493
3909
  if (!isSameAddress(amount.token.address, ETHAddress)) {
3494
- _context15.next = 4;
3910
+ _context17.next = 4;
3495
3911
  break;
3496
3912
  }
3497
3913
 
3498
- return _context15.abrupt("return", this._EthRepayHelper.connect(this._networkConnection.signer).repayBorrow({
3914
+ return _context17.abrupt("return", this._EthRepayHelper.connect(this._networkConnection.signer).repayBorrow({
3499
3915
  value: amount.rawAmount()
3500
3916
  }));
3501
3917
 
3502
3918
  case 4:
3503
3919
  if (!new BigNumber(amount.rawAmount()).lt(0)) {
3504
- _context15.next = 8;
3920
+ _context17.next = 8;
3505
3921
  break;
3506
3922
  }
3507
3923
 
3508
- return _context15.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(INF));
3924
+ return _context17.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(INF));
3509
3925
 
3510
3926
  case 8:
3511
- return _context15.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(amount.rawAmount()));
3927
+ return _context17.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(amount.rawAmount()));
3512
3928
 
3513
3929
  case 9:
3514
3930
  case "end":
3515
- return _context15.stop();
3931
+ return _context17.stop();
3516
3932
  }
3517
3933
  }
3518
- }, _callee15, this);
3934
+ }, _callee17, this);
3519
3935
  }));
3520
3936
 
3521
3937
  function repay(_x6) {
@@ -3526,19 +3942,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
3526
3942
  }();
3527
3943
 
3528
3944
  _proto2.enableCollateral = /*#__PURE__*/function () {
3529
- var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16() {
3530
- return runtime_1.wrap(function _callee16$(_context16) {
3945
+ var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee18() {
3946
+ return runtime_1.wrap(function _callee18$(_context18) {
3531
3947
  while (1) {
3532
- switch (_context16.prev = _context16.next) {
3948
+ switch (_context18.prev = _context18.next) {
3533
3949
  case 0:
3534
- return _context16.abrupt("return", this.env.comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));
3950
+ return _context18.abrupt("return", this.env.comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));
3535
3951
 
3536
3952
  case 1:
3537
3953
  case "end":
3538
- return _context16.stop();
3954
+ return _context18.stop();
3539
3955
  }
3540
3956
  }
3541
- }, _callee16, this);
3957
+ }, _callee18, this);
3542
3958
  }));
3543
3959
 
3544
3960
  function enableCollateral() {
@@ -3549,19 +3965,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
3549
3965
  }();
3550
3966
 
3551
3967
  _proto2.disableCollateral = /*#__PURE__*/function () {
3552
- var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee17() {
3553
- return runtime_1.wrap(function _callee17$(_context17) {
3968
+ var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee19() {
3969
+ return runtime_1.wrap(function _callee19$(_context19) {
3554
3970
  while (1) {
3555
- switch (_context17.prev = _context17.next) {
3971
+ switch (_context19.prev = _context19.next) {
3556
3972
  case 0:
3557
- return _context17.abrupt("return", this.env.comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));
3973
+ return _context19.abrupt("return", this.env.comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));
3558
3974
 
3559
3975
  case 1:
3560
3976
  case "end":
3561
- return _context17.stop();
3977
+ return _context19.stop();
3562
3978
  }
3563
3979
  }
3564
- }, _callee17, this);
3980
+ }, _callee19, this);
3565
3981
  }));
3566
3982
 
3567
3983
  function disableCollateral() {
@@ -3605,7 +4021,7 @@ var MulticallRead = /*#__PURE__*/function (_BlockchainEntityRead) {
3605
4021
  var _this;
3606
4022
 
3607
4023
  _this = _BlockchainEntityRead.call(this, networkConnection) || this;
3608
- _this.multicall = new ethers.Contract(networkAddresses.misc.MULTICALL, abis$b.abi, networkConnection.provider);
4024
+ _this.multicall = new ethers.Contract(networkAddresses.misc.MULTICALL, abis$a.abi, networkConnection.provider);
3609
4025
  return _this;
3610
4026
  }
3611
4027
  /**
@@ -4177,7 +4593,7 @@ var StakingRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4177
4593
  while (1) {
4178
4594
  switch (_context3.prev = _context3.next) {
4179
4595
  case 0:
4180
- lpContract = new ethers.Contract(networkAddresses.tokens.PLYWNEAR, abis$9.abi, this._networkConnection.provider);
4596
+ lpContract = new ethers.Contract(networkAddresses.tokens.PLYWNEAR, abis$8.abi, this._networkConnection.provider);
4181
4597
  _context3.next = 3;
4182
4598
  return lpContract.balanceOf(user);
4183
4599
 
@@ -4657,9 +5073,9 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4657
5073
  }
4658
5074
 
4659
5075
  _1E18 = ethers.BigNumber.from(10).pow(18);
4660
- oracle = this.env.getContract(networkAddresses.misc.oracle, abis$5.abi);
5076
+ oracle = this.env.getContract(networkAddresses.misc.oracle, AuriOracleABI.abi);
4661
5077
  tokens = tokenAddresses.map(function (addr) {
4662
- return _this3.env.getContract(addr, abis$6.abi);
5078
+ return _this3.env.getContract(addr, abis$5.abi);
4663
5079
  });
4664
5080
  _context5.next = 6;
4665
5081
  return oracle.getUnderlyingPrices(tokenAddresses);
@@ -5476,16 +5892,14 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5476
5892
  _proto.slotsInUse =
5477
5893
  /*#__PURE__*/
5478
5894
  function () {
5479
- var _slotsInUse = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(referralCode) {
5895
+ var _slotsInUse = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
5480
5896
  var result;
5481
5897
  return runtime_1.wrap(function _callee7$(_context7) {
5482
5898
  while (1) {
5483
5899
  switch (_context7.prev = _context7.next) {
5484
5900
  case 0:
5485
5901
  _context7.next = 2;
5486
- return getApi('/referral/slotsInUse', {
5487
- referralCode: referralCode
5488
- });
5902
+ return getApi('/referral/slotsInUse');
5489
5903
 
5490
5904
  case 2:
5491
5905
  result = _context7.sent;
@@ -5499,7 +5913,7 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5499
5913
  }, _callee7);
5500
5914
  }));
5501
5915
 
5502
- function slotsInUse(_x7) {
5916
+ function slotsInUse() {
5503
5917
  return _slotsInUse.apply(this, arguments);
5504
5918
  }
5505
5919
 
@@ -5508,7 +5922,38 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5508
5922
 
5509
5923
  _proto.totalReferralSlots = function totalReferralSlots() {
5510
5924
  return 500;
5511
- }
5925
+ };
5926
+
5927
+ _proto.queuePosition = /*#__PURE__*/function () {
5928
+ var _queuePosition = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(address) {
5929
+ var result;
5930
+ return runtime_1.wrap(function _callee8$(_context8) {
5931
+ while (1) {
5932
+ switch (_context8.prev = _context8.next) {
5933
+ case 0:
5934
+ _context8.next = 2;
5935
+ return getApi('/referral/queuePosition', {
5936
+ address: address
5937
+ });
5938
+
5939
+ case 2:
5940
+ result = _context8.sent;
5941
+ return _context8.abrupt("return", result);
5942
+
5943
+ case 4:
5944
+ case "end":
5945
+ return _context8.stop();
5946
+ }
5947
+ }
5948
+ }, _callee8);
5949
+ }));
5950
+
5951
+ function queuePosition(_x7) {
5952
+ return _queuePosition.apply(this, arguments);
5953
+ }
5954
+
5955
+ return queuePosition;
5956
+ }()
5512
5957
  /**
5513
5958
  * a way to determine qualification status of a user. null if not referred yet,
5514
5959
  * qualified if referred + min deposit, notQualified if referred + min deposit
@@ -5519,41 +5964,41 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5519
5964
  _proto.userReferralStatus =
5520
5965
  /*#__PURE__*/
5521
5966
  function () {
5522
- var _userReferralStatus = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(userAddr) {
5967
+ var _userReferralStatus = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(userAddr) {
5523
5968
  var result;
5524
- return runtime_1.wrap(function _callee8$(_context8) {
5969
+ return runtime_1.wrap(function _callee9$(_context9) {
5525
5970
  while (1) {
5526
- switch (_context8.prev = _context8.next) {
5971
+ switch (_context9.prev = _context9.next) {
5527
5972
  case 0:
5528
- _context8.next = 2;
5973
+ _context9.next = 2;
5529
5974
  return getApi('/referral/referralStatus', {
5530
5975
  address: userAddr
5531
5976
  });
5532
5977
 
5533
5978
  case 2:
5534
- result = _context8.sent;
5535
- _context8.t0 = result;
5536
- _context8.next = _context8.t0 === -1 ? 6 : _context8.t0 === 0 ? 7 : _context8.t0 === 1 ? 8 : 9;
5979
+ result = _context9.sent;
5980
+ _context9.t0 = result;
5981
+ _context9.next = _context9.t0 === -1 ? 6 : _context9.t0 === 0 ? 7 : _context9.t0 === 1 ? 8 : 9;
5537
5982
  break;
5538
5983
 
5539
5984
  case 6:
5540
- return _context8.abrupt("return", 'notReferred');
5985
+ return _context9.abrupt("return", 'notReferred');
5541
5986
 
5542
5987
  case 7:
5543
- return _context8.abrupt("return", 'notQualified');
5988
+ return _context9.abrupt("return", 'notQualified');
5544
5989
 
5545
5990
  case 8:
5546
- return _context8.abrupt("return", 'Qualified');
5991
+ return _context9.abrupt("return", 'Qualified');
5547
5992
 
5548
5993
  case 9:
5549
- return _context8.abrupt("return", 'Withdrawn');
5994
+ return _context9.abrupt("return", 'Withdrawn');
5550
5995
 
5551
5996
  case 10:
5552
5997
  case "end":
5553
- return _context8.stop();
5998
+ return _context9.stop();
5554
5999
  }
5555
6000
  }
5556
- }, _callee8);
6001
+ }, _callee9);
5557
6002
  }));
5558
6003
 
5559
6004
  function userReferralStatus(_x8) {
@@ -5564,25 +6009,25 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5564
6009
  }();
5565
6010
 
5566
6011
  _proto.isWhitelistedAddress = /*#__PURE__*/function () {
5567
- var _isWhitelistedAddress = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(address) {
6012
+ var _isWhitelistedAddress = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(address) {
5568
6013
  var result;
5569
- return runtime_1.wrap(function _callee9$(_context9) {
6014
+ return runtime_1.wrap(function _callee10$(_context10) {
5570
6015
  while (1) {
5571
- switch (_context9.prev = _context9.next) {
6016
+ switch (_context10.prev = _context10.next) {
5572
6017
  case 0:
5573
- _context9.next = 2;
6018
+ _context10.next = 2;
5574
6019
  return this.env.referralDirectoryV2.isUserWhitelisted(address);
5575
6020
 
5576
6021
  case 2:
5577
- result = _context9.sent;
5578
- return _context9.abrupt("return", result.eq(1));
6022
+ result = _context10.sent;
6023
+ return _context10.abrupt("return", result.eq(1));
5579
6024
 
5580
6025
  case 4:
5581
6026
  case "end":
5582
- return _context9.stop();
6027
+ return _context10.stop();
5583
6028
  }
5584
6029
  }
5585
- }, _callee9, this);
6030
+ }, _callee10, this);
5586
6031
  }));
5587
6032
 
5588
6033
  function isWhitelistedAddress(_x9) {
@@ -5593,25 +6038,25 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5593
6038
  }();
5594
6039
 
5595
6040
  _proto.isOnAuroraPlus = /*#__PURE__*/function () {
5596
- var _isOnAuroraPlus = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(address) {
6041
+ var _isOnAuroraPlus = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(address) {
5597
6042
  var resp;
5598
- return runtime_1.wrap(function _callee10$(_context10) {
6043
+ return runtime_1.wrap(function _callee11$(_context11) {
5599
6044
  while (1) {
5600
- switch (_context10.prev = _context10.next) {
6045
+ switch (_context11.prev = _context11.next) {
5601
6046
  case 0:
5602
- _context10.next = 2;
6047
+ _context11.next = 2;
5603
6048
  return axios.get(AURORA_PLUS_API_PREFIX + address);
5604
6049
 
5605
6050
  case 2:
5606
- resp = _context10.sent;
5607
- return _context10.abrupt("return", resp.data.status == 'active');
6051
+ resp = _context11.sent;
6052
+ return _context11.abrupt("return", resp.data.status == 'active');
5608
6053
 
5609
6054
  case 4:
5610
6055
  case "end":
5611
- return _context10.stop();
6056
+ return _context11.stop();
5612
6057
  }
5613
6058
  }
5614
- }, _callee10);
6059
+ }, _callee11);
5615
6060
  }));
5616
6061
 
5617
6062
  function isOnAuroraPlus(_x10) {
@@ -5622,27 +6067,27 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5622
6067
  }();
5623
6068
 
5624
6069
  _proto.isNewUserAtReferralTime = /*#__PURE__*/function () {
5625
- var _isNewUserAtReferralTime = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(address) {
6070
+ var _isNewUserAtReferralTime = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(address) {
5626
6071
  var result;
5627
- return runtime_1.wrap(function _callee11$(_context11) {
6072
+ return runtime_1.wrap(function _callee12$(_context12) {
5628
6073
  while (1) {
5629
- switch (_context11.prev = _context11.next) {
6074
+ switch (_context12.prev = _context12.next) {
5630
6075
  case 0:
5631
- _context11.next = 2;
6076
+ _context12.next = 2;
5632
6077
  return getApi('/referral/isNewUser', {
5633
6078
  address: address
5634
6079
  });
5635
6080
 
5636
6081
  case 2:
5637
- result = _context11.sent;
5638
- return _context11.abrupt("return", result);
6082
+ result = _context12.sent;
6083
+ return _context12.abrupt("return", result);
5639
6084
 
5640
6085
  case 4:
5641
6086
  case "end":
5642
- return _context11.stop();
6087
+ return _context12.stop();
5643
6088
  }
5644
6089
  }
5645
- }, _callee11);
6090
+ }, _callee12);
5646
6091
  }));
5647
6092
 
5648
6093
  function isNewUserAtReferralTime(_x11) {
@@ -5653,27 +6098,27 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5653
6098
  }();
5654
6099
 
5655
6100
  _proto.depositedMoreThanMinimumAmount = /*#__PURE__*/function () {
5656
- var _depositedMoreThanMinimumAmount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(address) {
6101
+ var _depositedMoreThanMinimumAmount = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(address) {
5657
6102
  var result;
5658
- return runtime_1.wrap(function _callee12$(_context12) {
6103
+ return runtime_1.wrap(function _callee13$(_context13) {
5659
6104
  while (1) {
5660
- switch (_context12.prev = _context12.next) {
6105
+ switch (_context13.prev = _context13.next) {
5661
6106
  case 0:
5662
- _context12.next = 2;
6107
+ _context13.next = 2;
5663
6108
  return getApi('/referral/depositedEnough', {
5664
6109
  address: address
5665
6110
  });
5666
6111
 
5667
6112
  case 2:
5668
- result = _context12.sent;
5669
- return _context12.abrupt("return", result);
6113
+ result = _context13.sent;
6114
+ return _context13.abrupt("return", result);
5670
6115
 
5671
6116
  case 4:
5672
6117
  case "end":
5673
- return _context12.stop();
6118
+ return _context13.stop();
5674
6119
  }
5675
6120
  }
5676
- }, _callee12);
6121
+ }, _callee13);
5677
6122
  }));
5678
6123
 
5679
6124
  function depositedMoreThanMinimumAmount(_x12) {
@@ -5702,21 +6147,21 @@ var ReferralReadWrite = /*#__PURE__*/function (_ReferralRead) {
5702
6147
  _proto2.registerNewReferralCode =
5703
6148
  /*#__PURE__*/
5704
6149
  function () {
5705
- var _registerNewReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13() {
6150
+ var _registerNewReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14() {
5706
6151
  var referralCode;
5707
- return runtime_1.wrap(function _callee13$(_context13) {
6152
+ return runtime_1.wrap(function _callee14$(_context14) {
5708
6153
  while (1) {
5709
- switch (_context13.prev = _context13.next) {
6154
+ switch (_context14.prev = _context14.next) {
5710
6155
  case 0:
5711
6156
  referralCode = ethers.ethers.utils.formatBytes32String(this.generateReferralCode());
5712
- return _context13.abrupt("return", this.env.referralDirectoryV2.connect(this._networkConnection.signer).registerNewUserReferralCode(referralCode));
6157
+ return _context14.abrupt("return", this.env.referralDirectoryV2.connect(this._networkConnection.signer).registerNewUserReferralCode(referralCode));
5713
6158
 
5714
6159
  case 2:
5715
6160
  case "end":
5716
- return _context13.stop();
6161
+ return _context14.stop();
5717
6162
  }
5718
6163
  }
5719
- }, _callee13, this);
6164
+ }, _callee14, this);
5720
6165
  }));
5721
6166
 
5722
6167
  function registerNewReferralCode() {
@@ -5733,21 +6178,21 @@ var ReferralReadWrite = /*#__PURE__*/function (_ReferralRead) {
5733
6178
  _proto2.useReferralCode =
5734
6179
  /*#__PURE__*/
5735
6180
  function () {
5736
- var _useReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(code) {
6181
+ var _useReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15(code) {
5737
6182
  var referralCode;
5738
- return runtime_1.wrap(function _callee14$(_context14) {
6183
+ return runtime_1.wrap(function _callee15$(_context15) {
5739
6184
  while (1) {
5740
- switch (_context14.prev = _context14.next) {
6185
+ switch (_context15.prev = _context15.next) {
5741
6186
  case 0:
5742
6187
  referralCode = ethers.ethers.utils.formatBytes32String(code);
5743
- return _context14.abrupt("return", this.env.referralDirectoryV2.connect(this._networkConnection.signer).registerReferralCodeUsed(referralCode));
6188
+ return _context15.abrupt("return", this.env.referralDirectoryV2.connect(this._networkConnection.signer).registerReferralCodeUsed(referralCode));
5744
6189
 
5745
6190
  case 2:
5746
6191
  case "end":
5747
- return _context14.stop();
6192
+ return _context15.stop();
5748
6193
  }
5749
6194
  }
5750
- }, _callee14, this);
6195
+ }, _callee15, this);
5751
6196
  }));
5752
6197
 
5753
6198
  function useReferralCode(_x13) {
@@ -5764,23 +6209,23 @@ var ReferralReadWrite = /*#__PURE__*/function (_ReferralRead) {
5764
6209
  _proto2.claimReferralRewards =
5765
6210
  /*#__PURE__*/
5766
6211
  function () {
5767
- var _claimReferralRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15() {
6212
+ var _claimReferralRewards = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16() {
5768
6213
  var unclaimedRewards, campaigns, tokens;
5769
- return runtime_1.wrap(function _callee15$(_context15) {
6214
+ return runtime_1.wrap(function _callee16$(_context16) {
5770
6215
  while (1) {
5771
- switch (_context15.prev = _context15.next) {
6216
+ switch (_context16.prev = _context16.next) {
5772
6217
  case 0:
5773
- _context15.t0 = this;
5774
- _context15.next = 3;
6218
+ _context16.t0 = this;
6219
+ _context16.next = 3;
5775
6220
  return this._networkConnection.signer.getAddress();
5776
6221
 
5777
6222
  case 3:
5778
- _context15.t1 = _context15.sent;
5779
- _context15.next = 6;
5780
- return _context15.t0.referralRewards.call(_context15.t0, _context15.t1);
6223
+ _context16.t1 = _context16.sent;
6224
+ _context16.next = 6;
6225
+ return _context16.t0.referralRewards.call(_context16.t0, _context16.t1);
5781
6226
 
5782
6227
  case 6:
5783
- unclaimedRewards = _context15.sent.filter(function (reward) {
6228
+ unclaimedRewards = _context16.sent.filter(function (reward) {
5784
6229
  return reward.transactionHash == null;
5785
6230
  });
5786
6231
  campaigns = unclaimedRewards.map(function (reward) {
@@ -5789,14 +6234,14 @@ var ReferralReadWrite = /*#__PURE__*/function (_ReferralRead) {
5789
6234
  tokens = unclaimedRewards.map(function (reward) {
5790
6235
  return reward.rewardTokenAmount.token.address;
5791
6236
  });
5792
- return _context15.abrupt("return", new AirdropReadWrite(this._networkConnection).redeemMultiple(campaigns, tokens));
6237
+ return _context16.abrupt("return", new AirdropReadWrite(this._networkConnection).redeemMultiple(campaigns, tokens));
5793
6238
 
5794
6239
  case 10:
5795
6240
  case "end":
5796
- return _context15.stop();
6241
+ return _context16.stop();
5797
6242
  }
5798
6243
  }
5799
- }, _callee15, this);
6244
+ }, _callee16, this);
5800
6245
  }));
5801
6246
 
5802
6247
  function claimReferralRewards() {
@@ -6276,6 +6721,12 @@ exports.dummyTokenAmount2 = dummyTokenAmount2;
6276
6721
  exports.dummyTokenAmount3 = dummyTokenAmount3;
6277
6722
  exports.dummyUserMarketDetails = dummyUserMarketDetails;
6278
6723
  exports.dummyZeroTokenAmount = dummyZeroTokenAmount;
6724
+ exports.fetchHistoricalLPPositions = fetchHistoricalLPPositions;
6725
+ exports.fetchHistoricalLPPrice = fetchHistoricalLPPrice;
6726
+ exports.fetchHistoricalPULPPrice = fetchHistoricalPULPPrice;
6727
+ exports.fetchHistoricalPrice = fetchHistoricalPrice;
6728
+ exports.fetchHistoricalPriceByLP = fetchHistoricalPriceByLP;
6729
+ exports.fetchHistoricalPriceFromOracle = fetchHistoricalPriceFromOracle;
6279
6730
  exports.fetchLPPositions = fetchLPPositions;
6280
6731
  exports.fetchLPPrice = fetchLPPrice;
6281
6732
  exports.fetchPLYPrice = fetchPLYPrice;