@aurigami/sdk 1.12.1-beta1 → 1.12.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.
@@ -1898,18 +1898,53 @@ function _getPaginatedApi() {
1898
1898
  return _getPaginatedApi.apply(this, arguments);
1899
1899
  }
1900
1900
 
1901
- function fetchPriceFromCoingeckoAPI(_x) {
1902
- return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
1901
+ function fetchPriceFromDefiLlamaAPI(_x) {
1902
+ return _fetchPriceFromDefiLlamaAPI.apply(this, arguments);
1903
1903
  }
1904
1904
 
1905
- function _fetchPriceFromCoingeckoAPI() {
1906
- _fetchPriceFromCoingeckoAPI = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(id) {
1905
+ function _fetchPriceFromDefiLlamaAPI() {
1906
+ _fetchPriceFromDefiLlamaAPI = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(id) {
1907
1907
  var price;
1908
1908
  return runtime_1.wrap(function _callee$(_context) {
1909
1909
  while (1) {
1910
1910
  switch (_context.prev = _context.next) {
1911
1911
  case 0:
1912
1912
  _context.next = 2;
1913
+ return axios.post("https://coins.llama.fi/prices", {
1914
+ coins: [id]
1915
+ }).then(function (res) {
1916
+ return res.data.coins[id].price;
1917
+ })["catch"](function (err) {
1918
+ console.log("unable to fetch price from DefiLlama API: " + err);
1919
+ return 0;
1920
+ });
1921
+
1922
+ case 2:
1923
+ price = _context.sent;
1924
+ return _context.abrupt("return", new BigNumber(price));
1925
+
1926
+ case 4:
1927
+ case "end":
1928
+ return _context.stop();
1929
+ }
1930
+ }
1931
+ }, _callee);
1932
+ }));
1933
+ return _fetchPriceFromDefiLlamaAPI.apply(this, arguments);
1934
+ }
1935
+
1936
+ function fetchPriceFromCoingeckoAPI(_x2) {
1937
+ return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
1938
+ }
1939
+
1940
+ function _fetchPriceFromCoingeckoAPI() {
1941
+ _fetchPriceFromCoingeckoAPI = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(id) {
1942
+ var price;
1943
+ return runtime_1.wrap(function _callee2$(_context2) {
1944
+ while (1) {
1945
+ switch (_context2.prev = _context2.next) {
1946
+ case 0:
1947
+ _context2.next = 2;
1913
1948
  return axios.get("https://api.coingecko.com/api/v3/simple/price?ids=" + id + "&vs_currencies=usd").then(function (res) {
1914
1949
  return res.data[id];
1915
1950
  })["catch"](function (err) {
@@ -1920,65 +1955,95 @@ function _fetchPriceFromCoingeckoAPI() {
1920
1955
  });
1921
1956
 
1922
1957
  case 2:
1923
- price = _context.sent;
1924
- return _context.abrupt("return", new BigNumber(price.usd));
1958
+ price = _context2.sent;
1959
+ return _context2.abrupt("return", new BigNumber(price.usd));
1925
1960
 
1926
1961
  case 4:
1927
1962
  case "end":
1928
- return _context.stop();
1963
+ return _context2.stop();
1929
1964
  }
1930
1965
  }
1931
- }, _callee);
1966
+ }, _callee2);
1932
1967
  }));
1933
1968
  return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
1934
1969
  }
1935
1970
 
1936
- function fetchPriceFromCoingecko(_x2) {
1971
+ function fetchPriceFromDefiLlama(_x3) {
1972
+ return _fetchPriceFromDefiLlama.apply(this, arguments);
1973
+ }
1974
+
1975
+ function _fetchPriceFromDefiLlama() {
1976
+ _fetchPriceFromDefiLlama = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(id) {
1977
+ return runtime_1.wrap(function _callee3$(_context3) {
1978
+ while (1) {
1979
+ switch (_context3.prev = _context3.next) {
1980
+ case 0:
1981
+ if (!(id.toLowerCase() == networkAddresses.tokens.AURORA || id.toLowerCase() == networkAddresses.tokens.TRI || id.toLowerCase() == networkAddresses.tokens.META)) {
1982
+ _context3.next = 2;
1983
+ break;
1984
+ }
1985
+
1986
+ return _context3.abrupt("return", fetchPriceFromDefiLlamaAPI("aurora:" + id.toLowerCase()));
1987
+
1988
+ case 2:
1989
+ throw Error("Unknown token " + id + " in fetchPriceFromDefiLlama");
1990
+
1991
+ case 3:
1992
+ case "end":
1993
+ return _context3.stop();
1994
+ }
1995
+ }
1996
+ }, _callee3);
1997
+ }));
1998
+ return _fetchPriceFromDefiLlama.apply(this, arguments);
1999
+ }
2000
+
2001
+ function fetchPriceFromCoingecko(_x4) {
1937
2002
  return _fetchPriceFromCoingecko.apply(this, arguments);
1938
2003
  }
1939
2004
 
1940
2005
  function _fetchPriceFromCoingecko() {
1941
- _fetchPriceFromCoingecko = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(id) {
1942
- return runtime_1.wrap(function _callee2$(_context2) {
2006
+ _fetchPriceFromCoingecko = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(id) {
2007
+ return runtime_1.wrap(function _callee4$(_context4) {
1943
2008
  while (1) {
1944
- switch (_context2.prev = _context2.next) {
2009
+ switch (_context4.prev = _context4.next) {
1945
2010
  case 0:
1946
- _context2.t0 = id.toLowerCase();
1947
- _context2.next = _context2.t0 === networkAddresses.tokens.AURORA ? 3 : _context2.t0 === networkAddresses.tokens.TRI ? 4 : _context2.t0 === networkAddresses.tokens.META ? 5 : 6;
2011
+ _context4.t0 = id.toLowerCase();
2012
+ _context4.next = _context4.t0 === networkAddresses.tokens.AURORA ? 3 : _context4.t0 === networkAddresses.tokens.TRI ? 4 : _context4.t0 === networkAddresses.tokens.META ? 5 : 6;
1948
2013
  break;
1949
2014
 
1950
2015
  case 3:
1951
- return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('aurora-near'));
2016
+ return _context4.abrupt("return", fetchPriceFromCoingeckoAPI('aurora-near'));
1952
2017
 
1953
2018
  case 4:
1954
- return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('trisolaris'));
2019
+ return _context4.abrupt("return", fetchPriceFromCoingeckoAPI('trisolaris'));
1955
2020
 
1956
2021
  case 5:
1957
- return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('meta-pool'));
2022
+ return _context4.abrupt("return", fetchPriceFromCoingeckoAPI('meta-pool'));
1958
2023
 
1959
2024
  case 6:
1960
2025
  throw Error("Unknown token " + id + " in fetchPriceFromCoingecko");
1961
2026
 
1962
2027
  case 7:
1963
2028
  case "end":
1964
- return _context2.stop();
2029
+ return _context4.stop();
1965
2030
  }
1966
2031
  }
1967
- }, _callee2);
2032
+ }, _callee4);
1968
2033
  }));
1969
2034
  return _fetchPriceFromCoingecko.apply(this, arguments);
1970
2035
  }
1971
2036
 
1972
- function fetchLPPositions(_x3, _x4) {
2037
+ function fetchLPPositions(_x5, _x6) {
1973
2038
  return _fetchLPPositions.apply(this, arguments);
1974
2039
  }
1975
2040
 
1976
2041
  function _fetchLPPositions() {
1977
- _fetchLPPositions = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(LPAddress, provider) {
2042
+ _fetchLPPositions = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(LPAddress, provider) {
1978
2043
  var LPContract, promises, values;
1979
- return runtime_1.wrap(function _callee3$(_context3) {
2044
+ return runtime_1.wrap(function _callee5$(_context5) {
1980
2045
  while (1) {
1981
- switch (_context3.prev = _context3.next) {
2046
+ switch (_context5.prev = _context5.next) {
1982
2047
  case 0:
1983
2048
  LPContract = new ethers.Contract(LPAddress, IUniswapV2PairABI.abi, provider);
1984
2049
  promises = [];
@@ -1986,12 +2051,12 @@ function _fetchLPPositions() {
1986
2051
  promises.push(LPContract.token1());
1987
2052
  promises.push(LPContract.getReserves());
1988
2053
  promises.push(LPContract.totalSupply());
1989
- _context3.next = 8;
2054
+ _context5.next = 8;
1990
2055
  return Promise.all(promises);
1991
2056
 
1992
2057
  case 8:
1993
- values = _context3.sent;
1994
- return _context3.abrupt("return", {
2058
+ values = _context5.sent;
2059
+ return _context5.abrupt("return", {
1995
2060
  token0: values[0],
1996
2061
  token1: values[1],
1997
2062
  reserve0: values[2].reserve0,
@@ -2001,117 +2066,117 @@ function _fetchLPPositions() {
2001
2066
 
2002
2067
  case 10:
2003
2068
  case "end":
2004
- return _context3.stop();
2069
+ return _context5.stop();
2005
2070
  }
2006
2071
  }
2007
- }, _callee3);
2072
+ }, _callee5);
2008
2073
  }));
2009
2074
  return _fetchLPPositions.apply(this, arguments);
2010
2075
  }
2011
2076
 
2012
- function fetchLPPrice(_x5, _x6) {
2077
+ function fetchLPPrice(_x7, _x8) {
2013
2078
  return _fetchLPPrice.apply(this, arguments);
2014
2079
  }
2015
2080
 
2016
2081
  function _fetchLPPrice() {
2017
- _fetchLPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(address, provider) {
2082
+ _fetchLPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(address, provider) {
2018
2083
  var LPInfo, LPDecimal, fetchLPPriceBy, _fetchLPPriceBy, lpPrice;
2019
2084
 
2020
- return runtime_1.wrap(function _callee5$(_context5) {
2085
+ return runtime_1.wrap(function _callee7$(_context7) {
2021
2086
  while (1) {
2022
- switch (_context5.prev = _context5.next) {
2087
+ switch (_context7.prev = _context7.next) {
2023
2088
  case 0:
2024
2089
  _fetchLPPriceBy = function _fetchLPPriceBy3() {
2025
- _fetchLPPriceBy = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(tokenReverse) {
2090
+ _fetchLPPriceBy = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(tokenReverse) {
2026
2091
  var tokenPrice, tokenDecimal, reserveUSD;
2027
- return runtime_1.wrap(function _callee4$(_context4) {
2092
+ return runtime_1.wrap(function _callee6$(_context6) {
2028
2093
  while (1) {
2029
- switch (_context4.prev = _context4.next) {
2094
+ switch (_context6.prev = _context6.next) {
2030
2095
  case 0:
2031
2096
  if (!tokenReverse.reserve.isZero()) {
2032
- _context4.next = 2;
2097
+ _context6.next = 2;
2033
2098
  break;
2034
2099
  }
2035
2100
 
2036
- return _context4.abrupt("return", new BigNumber(0));
2101
+ return _context6.abrupt("return", new BigNumber(0));
2037
2102
 
2038
2103
  case 2:
2039
- _context4.next = 4;
2104
+ _context6.next = 4;
2040
2105
  return _fetchPrice(tokenReverse.address, provider);
2041
2106
 
2042
2107
  case 4:
2043
- tokenPrice = _context4.sent;
2108
+ tokenPrice = _context6.sent;
2044
2109
  tokenDecimal = getDecimal(tokenReverse.address); // reserveUSD will be divided by 10^tokenDecimal later for more precision
2045
2110
 
2046
2111
  reserveUSD = tokenPrice.multipliedBy(tokenReverse.reserve.toString()).multipliedBy(2);
2047
- return _context4.abrupt("return", reserveUSD.multipliedBy(decimalFactor(LPDecimal)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())).dividedBy(decimalFactor(tokenDecimal)));
2112
+ return _context6.abrupt("return", reserveUSD.multipliedBy(decimalFactor(LPDecimal)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())).dividedBy(decimalFactor(tokenDecimal)));
2048
2113
 
2049
2114
  case 8:
2050
2115
  case "end":
2051
- return _context4.stop();
2116
+ return _context6.stop();
2052
2117
  }
2053
2118
  }
2054
- }, _callee4);
2119
+ }, _callee6);
2055
2120
  }));
2056
2121
  return _fetchLPPriceBy.apply(this, arguments);
2057
2122
  };
2058
2123
 
2059
- fetchLPPriceBy = function _fetchLPPriceBy2(_x23) {
2124
+ fetchLPPriceBy = function _fetchLPPriceBy2(_x25) {
2060
2125
  return _fetchLPPriceBy.apply(this, arguments);
2061
2126
  };
2062
2127
 
2063
- _context5.next = 4;
2128
+ _context7.next = 4;
2064
2129
  return fetchLPPositions(address, provider);
2065
2130
 
2066
2131
  case 4:
2067
- LPInfo = _context5.sent;
2132
+ LPInfo = _context7.sent;
2068
2133
  LPDecimal = getDecimal(address);
2069
- _context5.prev = 6;
2070
- _context5.next = 9;
2134
+ _context7.prev = 6;
2135
+ _context7.next = 9;
2071
2136
  return fetchLPPriceBy({
2072
2137
  address: LPInfo.token0,
2073
2138
  reserve: LPInfo.reserve0
2074
2139
  });
2075
2140
 
2076
2141
  case 9:
2077
- lpPrice = _context5.sent;
2142
+ lpPrice = _context7.sent;
2078
2143
 
2079
2144
  if (!lpPrice.isZero()) {
2080
- _context5.next = 12;
2145
+ _context7.next = 12;
2081
2146
  break;
2082
2147
  }
2083
2148
 
2084
2149
  throw Error("Price is zero");
2085
2150
 
2086
2151
  case 12:
2087
- return _context5.abrupt("return", lpPrice);
2152
+ return _context7.abrupt("return", lpPrice);
2088
2153
 
2089
2154
  case 15:
2090
- _context5.prev = 15;
2091
- _context5.t0 = _context5["catch"](6);
2092
- devLog("fetchLPPriceBy " + LPInfo.token0 + " failed", _context5.t0);
2093
- _context5.prev = 18;
2094
- _context5.next = 21;
2155
+ _context7.prev = 15;
2156
+ _context7.t0 = _context7["catch"](6);
2157
+ devLog("fetchLPPriceBy " + LPInfo.token0 + " failed", _context7.t0);
2158
+ _context7.prev = 18;
2159
+ _context7.next = 21;
2095
2160
  return fetchLPPriceBy({
2096
2161
  address: LPInfo.token1,
2097
2162
  reserve: LPInfo.reserve1
2098
2163
  });
2099
2164
 
2100
2165
  case 21:
2101
- return _context5.abrupt("return", _context5.sent);
2166
+ return _context7.abrupt("return", _context7.sent);
2102
2167
 
2103
2168
  case 24:
2104
- _context5.prev = 24;
2105
- _context5.t1 = _context5["catch"](18);
2106
- devLog("fetchLPPriceBy " + LPInfo.token1 + " failed", _context5.t1);
2169
+ _context7.prev = 24;
2170
+ _context7.t1 = _context7["catch"](18);
2171
+ devLog("fetchLPPriceBy " + LPInfo.token1 + " failed", _context7.t1);
2107
2172
  throw Error("Unable to fetch price for both tokens of LP " + address);
2108
2173
 
2109
2174
  case 28:
2110
2175
  case "end":
2111
- return _context5.stop();
2176
+ return _context7.stop();
2112
2177
  }
2113
2178
  }
2114
- }, _callee5, null, [[6, 15], [18, 24]]);
2179
+ }, _callee7, null, [[6, 15], [18, 24]]);
2115
2180
  }));
2116
2181
  return _fetchLPPrice.apply(this, arguments);
2117
2182
  }
@@ -2121,33 +2186,33 @@ function fetchStNEARPrice() {
2121
2186
  }
2122
2187
 
2123
2188
  function _fetchStNEARPrice() {
2124
- _fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6() {
2189
+ _fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
2125
2190
  var ratioPromise, nearPricePromise, _yield$Promise$all, ratioRes, nearPrice, ratio;
2126
2191
 
2127
- return runtime_1.wrap(function _callee6$(_context6) {
2192
+ return runtime_1.wrap(function _callee8$(_context8) {
2128
2193
  while (1) {
2129
- switch (_context6.prev = _context6.next) {
2194
+ switch (_context8.prev = _context8.next) {
2130
2195
  case 0:
2131
2196
  ratioPromise = axios.get('https://validators.narwallets.com/metrics_json').then(function (res) {
2132
2197
  return res.data;
2133
2198
  });
2134
2199
  nearPricePromise = fetchPriceFromCoingeckoAPI('near');
2135
- _context6.next = 4;
2200
+ _context8.next = 4;
2136
2201
  return Promise.all([ratioPromise, nearPricePromise]);
2137
2202
 
2138
2203
  case 4:
2139
- _yield$Promise$all = _context6.sent;
2204
+ _yield$Promise$all = _context8.sent;
2140
2205
  ratioRes = _yield$Promise$all[0];
2141
2206
  nearPrice = _yield$Promise$all[1];
2142
2207
  ratio = new BigNumber(ratioRes.st_near_price);
2143
- return _context6.abrupt("return", ratio.multipliedBy(nearPrice));
2208
+ return _context8.abrupt("return", ratio.multipliedBy(nearPrice));
2144
2209
 
2145
2210
  case 9:
2146
2211
  case "end":
2147
- return _context6.stop();
2212
+ return _context8.stop();
2148
2213
  }
2149
2214
  }
2150
- }, _callee6);
2215
+ }, _callee8);
2151
2216
  }));
2152
2217
  return _fetchStNEARPrice.apply(this, arguments);
2153
2218
  }
@@ -2156,29 +2221,29 @@ function processPriceFromOracle(rawPrice, underlyingDecimal) {
2156
2221
  return new BigNumber(rawPrice.toString()).div(decimalFactor(36 - underlyingDecimal));
2157
2222
  }
2158
2223
 
2159
- function fetchPriceFromOracle(_x7, _x8, _x9) {
2224
+ function fetchPriceFromOracle(_x9, _x10, _x11) {
2160
2225
  return _fetchPriceFromOracle.apply(this, arguments);
2161
2226
  }
2162
2227
 
2163
2228
  function _fetchPriceFromOracle() {
2164
- _fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(auTokenAddress, underlyingDecimal, provider) {
2229
+ _fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(auTokenAddress, underlyingDecimal, provider) {
2165
2230
  var oracleContract, rawPrice, matchingAuToken;
2166
- return runtime_1.wrap(function _callee7$(_context7) {
2231
+ return runtime_1.wrap(function _callee9$(_context9) {
2167
2232
  while (1) {
2168
- switch (_context7.prev = _context7.next) {
2233
+ switch (_context9.prev = _context9.next) {
2169
2234
  case 0:
2170
2235
  oracleContract = new ethers.Contract(networkAddresses.misc.oracle, abis$5.abi, provider);
2171
- _context7.next = 3;
2236
+ _context9.next = 3;
2172
2237
  return oracleContract.getUnderlyingPrice(auTokenAddress)["catch"](function (e) {
2173
2238
  console.log("Unable to fetch price from oracle for " + auTokenAddress);
2174
2239
  return ethers.BigNumber.from(0);
2175
2240
  });
2176
2241
 
2177
2242
  case 3:
2178
- rawPrice = _context7.sent;
2243
+ rawPrice = _context9.sent;
2179
2244
 
2180
2245
  if (!rawPrice.isZero()) {
2181
- _context7.next = 8;
2246
+ _context9.next = 8;
2182
2247
  break;
2183
2248
  }
2184
2249
 
@@ -2187,35 +2252,35 @@ function _fetchPriceFromOracle() {
2187
2252
  });
2188
2253
 
2189
2254
  if (!((matchingAuToken == null ? void 0 : matchingAuToken.name) == 'auSTNEAR')) {
2190
- _context7.next = 8;
2255
+ _context9.next = 8;
2191
2256
  break;
2192
2257
  }
2193
2258
 
2194
- return _context7.abrupt("return", fetchStNEARPrice());
2259
+ return _context9.abrupt("return", fetchStNEARPrice());
2195
2260
 
2196
2261
  case 8:
2197
- return _context7.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
2262
+ return _context9.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
2198
2263
 
2199
2264
  case 9:
2200
2265
  case "end":
2201
- return _context7.stop();
2266
+ return _context9.stop();
2202
2267
  }
2203
2268
  }
2204
- }, _callee7);
2269
+ }, _callee9);
2205
2270
  }));
2206
2271
  return _fetchPriceFromOracle.apply(this, arguments);
2207
2272
  }
2208
2273
 
2209
- function fetchUnderlyingTokensPrices(_x10) {
2274
+ function fetchUnderlyingTokensPrices(_x12) {
2210
2275
  return _fetchUnderlyingTokensPrices.apply(this, arguments);
2211
2276
  }
2212
2277
 
2213
2278
  function _fetchUnderlyingTokensPrices() {
2214
- _fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(provider) {
2279
+ _fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(provider) {
2215
2280
  var auriLens, auTokenAddresses, underlyingDecimals, rawPrices;
2216
- return runtime_1.wrap(function _callee8$(_context8) {
2281
+ return runtime_1.wrap(function _callee10$(_context10) {
2217
2282
  while (1) {
2218
- switch (_context8.prev = _context8.next) {
2283
+ switch (_context10.prev = _context10.next) {
2219
2284
  case 0:
2220
2285
  auriLens = new ethers.Contract(networkAddresses.misc.AURILENS, abis$4.abi, provider);
2221
2286
  auTokenAddresses = networkAddresses.auTokens.map(function (auToken) {
@@ -2224,12 +2289,12 @@ function _fetchUnderlyingTokensPrices() {
2224
2289
  underlyingDecimals = networkAddresses.auTokens.map(function (auToken) {
2225
2290
  return getDecimal(auToken.underlying);
2226
2291
  });
2227
- _context8.next = 5;
2292
+ _context10.next = 5;
2228
2293
  return auriLens.auTokenUnderlyingPriceAll(auTokenAddresses);
2229
2294
 
2230
2295
  case 5:
2231
- rawPrices = _context8.sent;
2232
- return _context8.abrupt("return", rawPrices.map(function (res, ind) {
2296
+ rawPrices = _context10.sent;
2297
+ return _context10.abrupt("return", rawPrices.map(function (res, ind) {
2233
2298
  return {
2234
2299
  auToken: res.auToken,
2235
2300
  underlyingPrice: processPriceFromOracle(res.underlyingPrice, underlyingDecimals[ind])
@@ -2238,15 +2303,15 @@ function _fetchUnderlyingTokensPrices() {
2238
2303
 
2239
2304
  case 7:
2240
2305
  case "end":
2241
- return _context8.stop();
2306
+ return _context10.stop();
2242
2307
  }
2243
2308
  }
2244
- }, _callee8);
2309
+ }, _callee10);
2245
2310
  }));
2246
2311
  return _fetchUnderlyingTokensPrices.apply(this, arguments);
2247
2312
  }
2248
2313
 
2249
- function shouldFetchFromCoingecko(address) {
2314
+ function shouldFetchFromCoingeckoOrDefiLlama(address) {
2250
2315
  address = address.toLowerCase();
2251
2316
  return address == networkAddresses.tokens.AURORA || address == networkAddresses.tokens.TRI || address == networkAddresses.tokens.META;
2252
2317
  }
@@ -2255,226 +2320,236 @@ function shouldFetchFromCoingecko(address) {
2255
2320
  */
2256
2321
 
2257
2322
 
2258
- function _fetchPrice(_x11, _x12) {
2323
+ function _fetchPrice(_x13, _x14) {
2259
2324
  return _fetchPrice2.apply(this, arguments);
2260
2325
  }
2261
2326
 
2262
2327
  function _fetchPrice2() {
2263
- _fetchPrice2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(address, provider) {
2328
+ _fetchPrice2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(address, provider) {
2264
2329
  var matchingAuToken;
2265
- return runtime_1.wrap(function _callee9$(_context9) {
2330
+ return runtime_1.wrap(function _callee11$(_context11) {
2266
2331
  while (1) {
2267
- switch (_context9.prev = _context9.next) {
2332
+ switch (_context11.prev = _context11.next) {
2268
2333
  case 0:
2269
2334
  assert(PRICE_WHITELISTED.has(address.toLocaleLowerCase()), "Address " + address + " is not whitelisted for price fetching");
2270
2335
 
2271
- if (!shouldFetchFromCoingecko(address)) {
2272
- _context9.next = 3;
2336
+ if (!shouldFetchFromCoingeckoOrDefiLlama(address)) {
2337
+ _context11.next = 11;
2273
2338
  break;
2274
2339
  }
2275
2340
 
2276
- return _context9.abrupt("return", fetchPriceFromCoingecko(address));
2341
+ _context11.prev = 2;
2342
+ _context11.next = 5;
2343
+ return fetchPriceFromCoingecko(address);
2277
2344
 
2278
- case 3:
2345
+ case 5:
2346
+ return _context11.abrupt("return", _context11.sent);
2347
+
2348
+ case 8:
2349
+ _context11.prev = 8;
2350
+ _context11.t0 = _context11["catch"](2);
2351
+ return _context11.abrupt("return", fetchPriceFromDefiLlama(address));
2352
+
2353
+ case 11:
2279
2354
  matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
2280
2355
  return isSameAddress(auToken.underlying, address);
2281
2356
  });
2282
2357
 
2283
2358
  if (!(matchingAuToken !== undefined)) {
2284
- _context9.next = 8;
2359
+ _context11.next = 16;
2285
2360
  break;
2286
2361
  }
2287
2362
 
2288
- return _context9.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
2363
+ return _context11.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
2289
2364
 
2290
- case 8:
2365
+ case 16:
2291
2366
  throw Error("Unable to fetch price for " + address);
2292
2367
 
2293
- case 9:
2368
+ case 17:
2294
2369
  case "end":
2295
- return _context9.stop();
2370
+ return _context11.stop();
2296
2371
  }
2297
2372
  }
2298
- }, _callee9);
2373
+ }, _callee11, null, [[2, 8]]);
2299
2374
  }));
2300
2375
  return _fetchPrice2.apply(this, arguments);
2301
2376
  }
2302
2377
 
2303
- function fetchPrice(_x13, _x14) {
2378
+ function fetchPrice(_x15, _x16) {
2304
2379
  return _fetchPrice3.apply(this, arguments);
2305
2380
  }
2306
2381
 
2307
2382
  function _fetchPrice3() {
2308
- _fetchPrice3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(address, provider) {
2309
- return runtime_1.wrap(function _callee10$(_context10) {
2383
+ _fetchPrice3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(address, provider) {
2384
+ return runtime_1.wrap(function _callee12$(_context12) {
2310
2385
  while (1) {
2311
- switch (_context10.prev = _context10.next) {
2386
+ switch (_context12.prev = _context12.next) {
2312
2387
  case 0:
2313
2388
  if (!(address.toLowerCase() in HARDCODE_PRICE_TOKENS)) {
2314
- _context10.next = 4;
2389
+ _context12.next = 4;
2315
2390
  break;
2316
2391
  }
2317
2392
 
2318
- return _context10.abrupt("return", new BigNumber(HARDCODE_PRICE_TOKENS[address.toLowerCase()]));
2393
+ return _context12.abrupt("return", new BigNumber(HARDCODE_PRICE_TOKENS[address.toLowerCase()]));
2319
2394
 
2320
2395
  case 4:
2321
2396
  if (!isSameAddress(address, networkAddresses.tokens.PLYWNEAR)) {
2322
- _context10.next = 8;
2397
+ _context12.next = 8;
2323
2398
  break;
2324
2399
  }
2325
2400
 
2326
- return _context10.abrupt("return", fetchLPPrice(address, provider));
2401
+ return _context12.abrupt("return", fetchLPPrice(address, provider));
2327
2402
 
2328
2403
  case 8:
2329
2404
  if (!isSameAddress(address, networkAddresses.tokens.PLY)) {
2330
- _context10.next = 12;
2405
+ _context12.next = 12;
2331
2406
  break;
2332
2407
  }
2333
2408
 
2334
- return _context10.abrupt("return", fetchPLYPrice(provider));
2409
+ return _context12.abrupt("return", fetchPLYPrice(provider));
2335
2410
 
2336
2411
  case 12:
2337
2412
  if (!isSameAddress(address, networkAddresses.tokens.PULP)) {
2338
- _context10.next = 14;
2413
+ _context12.next = 14;
2339
2414
  break;
2340
2415
  }
2341
2416
 
2342
- return _context10.abrupt("return", fetchPULPPrice(provider));
2417
+ return _context12.abrupt("return", fetchPULPPrice(provider));
2343
2418
 
2344
2419
  case 14:
2345
- return _context10.abrupt("return", _fetchPrice(address, provider));
2420
+ return _context12.abrupt("return", _fetchPrice(address, provider));
2346
2421
 
2347
2422
  case 15:
2348
2423
  case "end":
2349
- return _context10.stop();
2424
+ return _context12.stop();
2350
2425
  }
2351
2426
  }
2352
- }, _callee10);
2427
+ }, _callee12);
2353
2428
  }));
2354
2429
  return _fetchPrice3.apply(this, arguments);
2355
2430
  }
2356
2431
 
2357
- function fetchPLYPrice(_x15) {
2432
+ function fetchPLYPrice(_x17) {
2358
2433
  return _fetchPLYPrice.apply(this, arguments);
2359
2434
  }
2360
2435
 
2361
2436
  function _fetchPLYPrice() {
2362
- _fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(provider) {
2363
- return runtime_1.wrap(function _callee11$(_context11) {
2437
+ _fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(provider) {
2438
+ return runtime_1.wrap(function _callee13$(_context13) {
2364
2439
  while (1) {
2365
- switch (_context11.prev = _context11.next) {
2440
+ switch (_context13.prev = _context13.next) {
2366
2441
  case 0:
2367
- return _context11.abrupt("return", fetchToken0PriceByLP(networkAddresses.tokens.PLYWNEAR, provider));
2442
+ return _context13.abrupt("return", fetchToken0PriceByLP(networkAddresses.tokens.PLYWNEAR, provider));
2368
2443
 
2369
2444
  case 1:
2370
2445
  case "end":
2371
- return _context11.stop();
2446
+ return _context13.stop();
2372
2447
  }
2373
2448
  }
2374
- }, _callee11);
2449
+ }, _callee13);
2375
2450
  }));
2376
2451
  return _fetchPLYPrice.apply(this, arguments);
2377
2452
  }
2378
2453
 
2379
- function fetchPULPPrice(_x16) {
2454
+ function fetchPULPPrice(_x18) {
2380
2455
  return _fetchPULPPrice.apply(this, arguments);
2381
2456
  }
2382
2457
 
2383
2458
  function _fetchPULPPrice() {
2384
- _fetchPULPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(provider) {
2385
- return runtime_1.wrap(function _callee12$(_context12) {
2459
+ _fetchPULPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(provider) {
2460
+ return runtime_1.wrap(function _callee14$(_context14) {
2386
2461
  while (1) {
2387
- switch (_context12.prev = _context12.next) {
2462
+ switch (_context14.prev = _context14.next) {
2388
2463
  case 0:
2389
- return _context12.abrupt("return", new BigNumber(0));
2464
+ return _context14.abrupt("return", new BigNumber(0));
2390
2465
 
2391
2466
  case 1:
2392
2467
  case "end":
2393
- return _context12.stop();
2468
+ return _context14.stop();
2394
2469
  }
2395
2470
  }
2396
- }, _callee12);
2471
+ }, _callee14);
2397
2472
  }));
2398
2473
  return _fetchPULPPrice.apply(this, arguments);
2399
2474
  }
2400
2475
 
2401
- function fetchToken0PriceByLP(_x17, _x18) {
2476
+ function fetchToken0PriceByLP(_x19, _x20) {
2402
2477
  return _fetchToken0PriceByLP.apply(this, arguments);
2403
2478
  }
2404
2479
 
2405
2480
  function _fetchToken0PriceByLP() {
2406
- _fetchToken0PriceByLP = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(LP, provider) {
2481
+ _fetchToken0PriceByLP = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15(LP, provider) {
2407
2482
  var LPInfo, token0Decimal, token1Decimal;
2408
- return runtime_1.wrap(function _callee13$(_context13) {
2483
+ return runtime_1.wrap(function _callee15$(_context15) {
2409
2484
  while (1) {
2410
- switch (_context13.prev = _context13.next) {
2485
+ switch (_context15.prev = _context15.next) {
2411
2486
  case 0:
2412
- _context13.next = 2;
2487
+ _context15.next = 2;
2413
2488
  return fetchLPPositions(LP, provider);
2414
2489
 
2415
2490
  case 2:
2416
- LPInfo = _context13.sent;
2491
+ LPInfo = _context15.sent;
2417
2492
 
2418
2493
  if (!LPInfo.reserve1.isZero()) {
2419
- _context13.next = 5;
2494
+ _context15.next = 5;
2420
2495
  break;
2421
2496
  }
2422
2497
 
2423
- return _context13.abrupt("return", new BigNumber(0));
2498
+ return _context15.abrupt("return", new BigNumber(0));
2424
2499
 
2425
2500
  case 5:
2426
2501
  token0Decimal = getDecimal(LPInfo.token0);
2427
2502
  token1Decimal = getDecimal(LPInfo.token1); // (token0Price * reserve0) / 10^decimal0 = (token1Price * reserve1) / 10^decimal1
2428
2503
  // token0Price = (token1Price * reserve1) * 10^decimal0 / 10^decimal1 / reserve0
2429
2504
 
2430
- _context13.next = 9;
2505
+ _context15.next = 9;
2431
2506
  return fetchPrice(LPInfo.token1, provider);
2432
2507
 
2433
2508
  case 9:
2434
- return _context13.abrupt("return", _context13.sent.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(decimalFactor(token0Decimal)).dividedBy(decimalFactor(token1Decimal)).dividedBy(LPInfo.reserve0.toString()));
2509
+ return _context15.abrupt("return", _context15.sent.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(decimalFactor(token0Decimal)).dividedBy(decimalFactor(token1Decimal)).dividedBy(LPInfo.reserve0.toString()));
2435
2510
 
2436
2511
  case 10:
2437
2512
  case "end":
2438
- return _context13.stop();
2513
+ return _context15.stop();
2439
2514
  }
2440
2515
  }
2441
- }, _callee13);
2516
+ }, _callee15);
2442
2517
  }));
2443
2518
  return _fetchToken0PriceByLP.apply(this, arguments);
2444
2519
  }
2445
2520
 
2446
- function fetchValuation(_x19, _x20) {
2521
+ function fetchValuation(_x21, _x22) {
2447
2522
  return _fetchValuation.apply(this, arguments);
2448
2523
  }
2449
2524
 
2450
2525
  function _fetchValuation() {
2451
- _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(tokenAmount, provider) {
2526
+ _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16(tokenAmount, provider) {
2452
2527
  var price;
2453
- return runtime_1.wrap(function _callee14$(_context14) {
2528
+ return runtime_1.wrap(function _callee16$(_context16) {
2454
2529
  while (1) {
2455
- switch (_context14.prev = _context14.next) {
2530
+ switch (_context16.prev = _context16.next) {
2456
2531
  case 0:
2457
2532
  if (!(tokenAmount.rawAmount() == '0')) {
2458
- _context14.next = 2;
2533
+ _context16.next = 2;
2459
2534
  break;
2460
2535
  }
2461
2536
 
2462
- return _context14.abrupt("return", new BigNumber(0));
2537
+ return _context16.abrupt("return", new BigNumber(0));
2463
2538
 
2464
2539
  case 2:
2465
- _context14.next = 4;
2540
+ _context16.next = 4;
2466
2541
  return fetchPrice(tokenAmount.token.address, provider);
2467
2542
 
2468
2543
  case 4:
2469
- price = _context14.sent;
2470
- return _context14.abrupt("return", calcValuation(tokenAmount, price));
2544
+ price = _context16.sent;
2545
+ return _context16.abrupt("return", calcValuation(tokenAmount, price));
2471
2546
 
2472
2547
  case 6:
2473
2548
  case "end":
2474
- return _context14.stop();
2549
+ return _context16.stop();
2475
2550
  }
2476
2551
  }
2477
- }, _callee14);
2552
+ }, _callee16);
2478
2553
  }));
2479
2554
  return _fetchValuation.apply(this, arguments);
2480
2555
  }
@@ -2482,23 +2557,23 @@ function _fetchValuation() {
2482
2557
  function calcValuation(tokenAmount, price) {
2483
2558
  return new BigNumber(tokenAmount.formattedAmount()).multipliedBy(price);
2484
2559
  }
2485
- function valuateToken(_x21, _x22) {
2560
+ function valuateToken(_x23, _x24) {
2486
2561
  return _valuateToken.apply(this, arguments);
2487
2562
  }
2488
2563
 
2489
2564
  function _valuateToken() {
2490
- _valuateToken = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15(tokenAmount, provider) {
2565
+ _valuateToken = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee17(tokenAmount, provider) {
2491
2566
  var tokenValuation;
2492
- return runtime_1.wrap(function _callee15$(_context15) {
2567
+ return runtime_1.wrap(function _callee17$(_context17) {
2493
2568
  while (1) {
2494
- switch (_context15.prev = _context15.next) {
2569
+ switch (_context17.prev = _context17.next) {
2495
2570
  case 0:
2496
- _context15.next = 2;
2571
+ _context17.next = 2;
2497
2572
  return fetchValuation(tokenAmount, provider);
2498
2573
 
2499
2574
  case 2:
2500
- tokenValuation = _context15.sent;
2501
- return _context15.abrupt("return", {
2575
+ tokenValuation = _context17.sent;
2576
+ return _context17.abrupt("return", {
2502
2577
  tokenAmount: tokenAmount,
2503
2578
  currencyAmount: {
2504
2579
  currency: 'USD',
@@ -2508,10 +2583,10 @@ function _valuateToken() {
2508
2583
 
2509
2584
  case 4:
2510
2585
  case "end":
2511
- return _context15.stop();
2586
+ return _context17.stop();
2512
2587
  }
2513
2588
  }
2514
- }, _callee15);
2589
+ }, _callee17);
2515
2590
  }));
2516
2591
  return _valuateToken.apply(this, arguments);
2517
2592
  }
@@ -2642,7 +2717,9 @@ var helpers = {
2642
2717
  getBlockBeforeTimestamp: getBlockBeforeTimestamp,
2643
2718
  devLog: devLog,
2644
2719
  sortEvents: sortEvents,
2720
+ fetchPriceFromDefiLlamaAPI: fetchPriceFromDefiLlamaAPI,
2645
2721
  fetchPriceFromCoingeckoAPI: fetchPriceFromCoingeckoAPI,
2722
+ fetchPriceFromDefiLlama: fetchPriceFromDefiLlama,
2646
2723
  fetchPriceFromCoingecko: fetchPriceFromCoingecko,
2647
2724
  fetchLPPositions: fetchLPPositions,
2648
2725
  fetchLPPrice: fetchLPPrice,
@@ -5478,13 +5555,19 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
5478
5555
 
5479
5556
  _proto.isOnAuroraPlus = /*#__PURE__*/function () {
5480
5557
  var _isOnAuroraPlus = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(address) {
5558
+ var resp;
5481
5559
  return runtime_1.wrap(function _callee10$(_context10) {
5482
5560
  while (1) {
5483
5561
  switch (_context10.prev = _context10.next) {
5484
5562
  case 0:
5485
- return _context10.abrupt("return", true);
5563
+ _context10.next = 2;
5564
+ return axios.get(AURORA_PLUS_API_PREFIX + address);
5486
5565
 
5487
- case 1:
5566
+ case 2:
5567
+ resp = _context10.sent;
5568
+ return _context10.abrupt("return", resp.data.status == 'active');
5569
+
5570
+ case 4:
5488
5571
  case "end":
5489
5572
  return _context10.stop();
5490
5573
  }
@@ -6161,6 +6244,8 @@ exports.fetchPULPPrice = fetchPULPPrice;
6161
6244
  exports.fetchPrice = fetchPrice;
6162
6245
  exports.fetchPriceFromCoingecko = fetchPriceFromCoingecko;
6163
6246
  exports.fetchPriceFromCoingeckoAPI = fetchPriceFromCoingeckoAPI;
6247
+ exports.fetchPriceFromDefiLlama = fetchPriceFromDefiLlama;
6248
+ exports.fetchPriceFromDefiLlamaAPI = fetchPriceFromDefiLlamaAPI;
6164
6249
  exports.fetchPriceFromOracle = fetchPriceFromOracle;
6165
6250
  exports.fetchStNEARPrice = fetchStNEARPrice;
6166
6251
  exports.fetchToken0PriceByLP = fetchToken0PriceByLP;