@aurigami/sdk 1.8.6 → 1.9.1

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.
Files changed (30) hide show
  1. package/dist/SDK.d.ts +1 -1
  2. package/dist/helpers/priceFetcher.d.ts +1 -0
  3. package/dist/index.d.ts +1 -1
  4. package/dist/sdk.cjs.development.js +171 -97
  5. package/dist/sdk.cjs.development.js.map +1 -1
  6. package/dist/sdk.cjs.production.min.js +1 -1
  7. package/dist/sdk.cjs.production.min.js.map +1 -1
  8. package/dist/sdk.esm.js +171 -98
  9. package/dist/sdk.esm.js.map +1 -1
  10. package/package.json +1 -1
  11. package/src/SDK.ts +1 -1
  12. package/src/helpers/helpers.ts +1 -1
  13. package/src/helpers/priceFetcher.ts +40 -4
  14. package/src/index.ts +1 -1
  15. package/src/{contracts → interactors}/MoneyMarket.ts +1 -1
  16. /package/dist/{contracts → interactors}/Airdrop.d.ts +0 -0
  17. /package/dist/{contracts → interactors}/MoneyMarket.d.ts +0 -0
  18. /package/dist/{contracts → interactors}/Multicall.d.ts +0 -0
  19. /package/dist/{contracts → interactors}/Papermill.d.ts +0 -0
  20. /package/dist/{contracts → interactors}/Referral.d.ts +0 -0
  21. /package/dist/{contracts → interactors}/Staking.d.ts +0 -0
  22. /package/dist/{contracts → interactors}/index.d.ts +0 -0
  23. /package/dist/{contracts → interactors}/misc.d.ts +0 -0
  24. /package/src/{contracts → interactors}/Airdrop.ts +0 -0
  25. /package/src/{contracts → interactors}/Multicall.ts +0 -0
  26. /package/src/{contracts → interactors}/Papermill.ts +0 -0
  27. /package/src/{contracts → interactors}/Referral.ts +0 -0
  28. /package/src/{contracts → interactors}/Staking.ts +0 -0
  29. /package/src/{contracts → interactors}/index.ts +0 -0
  30. /package/src/{contracts → interactors}/misc.ts +0 -0
package/dist/SDK.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { TransactionResponse } from '@ethersproject/abstract-provider';
2
2
  import BigNumber from 'bignumber.js';
3
- import { MiscRead, StakingRead } from './contracts';
4
3
  import { AuriEnv, BlockchainEntity, BlockchainEntityRead, Token, TokenAmount } from './entities';
4
+ import { MiscRead, StakingRead } from './interactors';
5
5
  import * as types from './types';
6
6
  export declare class SdkRead extends BlockchainEntityRead {
7
7
  protected env: AuriEnv;
@@ -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 fetchStNEARPrice(): Promise<BigNumber>;
15
16
  export declare function fetchPriceFromOracle(auTokenAddress: Address, underlyingDecimal: number, provider: providers.Provider): Promise<BigNumber>;
16
17
  export declare function fetchUnderlyingTokensPrices(provider: providers.Provider): Promise<{
17
18
  auToken: string;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export * as abis from './abis';
2
2
  export * from './consts';
3
- export * from './contracts';
4
3
  export * from './entities';
5
4
  export * from './helpers';
5
+ export * from './interactors';
6
6
  export * from './SDK';
7
7
  export * from './types';
@@ -1618,7 +1618,7 @@ function devLog(message) {
1618
1618
  optionalParams[_key - 1] = arguments[_key];
1619
1619
  }
1620
1620
 
1621
- (_console = console).log.apply(_console, [message].concat(optionalParams));
1621
+ (_console = console).log.apply(_console, ['[DEV LOG]', message].concat(optionalParams));
1622
1622
  }
1623
1623
  }
1624
1624
 
@@ -1812,12 +1812,17 @@ function _fetchPriceFromCoingeckoAPI() {
1812
1812
  case 0:
1813
1813
  _context.next = 2;
1814
1814
  return axios.get("https://api.coingecko.com/api/v3/simple/price?ids=" + id + "&vs_currencies=usd").then(function (res) {
1815
- return res.data;
1815
+ return res.data[id];
1816
+ })["catch"](function (err) {
1817
+ console.log("Unable to fetch price from Coingecko API for " + id);
1818
+ return {
1819
+ usd: 0
1820
+ };
1816
1821
  });
1817
1822
 
1818
1823
  case 2:
1819
1824
  price = _context.sent;
1820
- return _context.abrupt("return", new BigNumber(price[id].usd));
1825
+ return _context.abrupt("return", new BigNumber(price.usd));
1821
1826
 
1822
1827
  case 4:
1823
1828
  case "end":
@@ -1911,7 +1916,7 @@ function fetchLPPrice(_x5, _x6) {
1911
1916
 
1912
1917
  function _fetchLPPrice() {
1913
1918
  _fetchLPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(address, provider) {
1914
- var LPInfo, LPDecimal, fetchLPPriceBy, _fetchLPPriceBy;
1919
+ var LPInfo, LPDecimal, fetchLPPriceBy, _fetchLPPriceBy, lpPrice;
1915
1920
 
1916
1921
  return runtime_1.wrap(function _callee5$(_context5) {
1917
1922
  while (1) {
@@ -1970,38 +1975,84 @@ function _fetchLPPrice() {
1970
1975
  });
1971
1976
 
1972
1977
  case 9:
1973
- return _context5.abrupt("return", _context5.sent);
1978
+ lpPrice = _context5.sent;
1979
+
1980
+ if (!lpPrice.isZero()) {
1981
+ _context5.next = 12;
1982
+ break;
1983
+ }
1984
+
1985
+ throw Error("Price is zero");
1974
1986
 
1975
1987
  case 12:
1976
- _context5.prev = 12;
1988
+ return _context5.abrupt("return", lpPrice);
1989
+
1990
+ case 15:
1991
+ _context5.prev = 15;
1977
1992
  _context5.t0 = _context5["catch"](6);
1978
1993
  devLog("fetchLPPriceBy " + LPInfo.token0 + " failed", _context5.t0);
1979
- _context5.prev = 15;
1980
- _context5.next = 18;
1994
+ _context5.prev = 18;
1995
+ _context5.next = 21;
1981
1996
  return fetchLPPriceBy({
1982
1997
  address: LPInfo.token1,
1983
1998
  reserve: LPInfo.reserve1
1984
1999
  });
1985
2000
 
1986
- case 18:
2001
+ case 21:
1987
2002
  return _context5.abrupt("return", _context5.sent);
1988
2003
 
1989
- case 21:
1990
- _context5.prev = 21;
1991
- _context5.t1 = _context5["catch"](15);
2004
+ case 24:
2005
+ _context5.prev = 24;
2006
+ _context5.t1 = _context5["catch"](18);
1992
2007
  devLog("fetchLPPriceBy " + LPInfo.token1 + " failed", _context5.t1);
1993
2008
  throw Error("Unable to fetch price for both tokens of LP " + address);
1994
2009
 
1995
- case 25:
2010
+ case 28:
1996
2011
  case "end":
1997
2012
  return _context5.stop();
1998
2013
  }
1999
2014
  }
2000
- }, _callee5, null, [[6, 12], [15, 21]]);
2015
+ }, _callee5, null, [[6, 15], [18, 24]]);
2001
2016
  }));
2002
2017
  return _fetchLPPrice.apply(this, arguments);
2003
2018
  }
2004
2019
 
2020
+ function fetchStNEARPrice() {
2021
+ return _fetchStNEARPrice.apply(this, arguments);
2022
+ }
2023
+
2024
+ function _fetchStNEARPrice() {
2025
+ _fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6() {
2026
+ var ratioPromise, nearPricePromise, _yield$Promise$all, ratioRes, nearPrice, ratio;
2027
+
2028
+ return runtime_1.wrap(function _callee6$(_context6) {
2029
+ while (1) {
2030
+ switch (_context6.prev = _context6.next) {
2031
+ case 0:
2032
+ ratioPromise = axios.get('https://validators.narwallets.com/metrics_json').then(function (res) {
2033
+ return res.data;
2034
+ });
2035
+ nearPricePromise = fetchPriceFromCoingeckoAPI('near');
2036
+ _context6.next = 4;
2037
+ return Promise.all([ratioPromise, nearPricePromise]);
2038
+
2039
+ case 4:
2040
+ _yield$Promise$all = _context6.sent;
2041
+ ratioRes = _yield$Promise$all[0];
2042
+ nearPrice = _yield$Promise$all[1];
2043
+ ratio = new BigNumber(ratioRes.st_near_price);
2044
+ return _context6.abrupt("return", ratio.multipliedBy(nearPrice));
2045
+
2046
+ case 9:
2047
+ case "end":
2048
+ return _context6.stop();
2049
+ }
2050
+ }
2051
+ }, _callee6);
2052
+ }));
2053
+ return _fetchStNEARPrice.apply(this, arguments);
2054
+ }
2055
+
2005
2056
  function processPriceFromOracle(rawPrice, underlyingDecimal) {
2006
2057
  return new BigNumber(rawPrice.toString()).div(decimalFactor(36 - underlyingDecimal));
2007
2058
  }
@@ -2011,26 +2062,47 @@ function fetchPriceFromOracle(_x7, _x8, _x9) {
2011
2062
  }
2012
2063
 
2013
2064
  function _fetchPriceFromOracle() {
2014
- _fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(auTokenAddress, underlyingDecimal, provider) {
2015
- var oracleContract, rawPrice;
2016
- return runtime_1.wrap(function _callee6$(_context6) {
2065
+ _fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(auTokenAddress, underlyingDecimal, provider) {
2066
+ var oracleContract, rawPrice, matchingAuToken;
2067
+ return runtime_1.wrap(function _callee7$(_context7) {
2017
2068
  while (1) {
2018
- switch (_context6.prev = _context6.next) {
2069
+ switch (_context7.prev = _context7.next) {
2019
2070
  case 0:
2020
2071
  oracleContract = new ethers.Contract(networkAddresses.misc.oracle, AuriOracleABI.abi, provider);
2021
- _context6.next = 3;
2022
- return oracleContract.getUnderlyingPrice(auTokenAddress);
2072
+ _context7.next = 3;
2073
+ return oracleContract.getUnderlyingPrice(auTokenAddress)["catch"](function (e) {
2074
+ console.log("Unable to fetch price from oracle for " + auTokenAddress);
2075
+ return ethers.BigNumber.from(0);
2076
+ });
2023
2077
 
2024
2078
  case 3:
2025
- rawPrice = _context6.sent;
2026
- return _context6.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
2079
+ rawPrice = _context7.sent;
2027
2080
 
2028
- case 5:
2081
+ if (!rawPrice.isZero()) {
2082
+ _context7.next = 8;
2083
+ break;
2084
+ }
2085
+
2086
+ matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
2087
+ return isSameAddress(auToken.address, auTokenAddress);
2088
+ });
2089
+
2090
+ if (!((matchingAuToken == null ? void 0 : matchingAuToken.name) == 'auSTNEAR')) {
2091
+ _context7.next = 8;
2092
+ break;
2093
+ }
2094
+
2095
+ return _context7.abrupt("return", fetchStNEARPrice());
2096
+
2097
+ case 8:
2098
+ return _context7.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
2099
+
2100
+ case 9:
2029
2101
  case "end":
2030
- return _context6.stop();
2102
+ return _context7.stop();
2031
2103
  }
2032
2104
  }
2033
- }, _callee6);
2105
+ }, _callee7);
2034
2106
  }));
2035
2107
  return _fetchPriceFromOracle.apply(this, arguments);
2036
2108
  }
@@ -2040,11 +2112,11 @@ function fetchUnderlyingTokensPrices(_x10) {
2040
2112
  }
2041
2113
 
2042
2114
  function _fetchUnderlyingTokensPrices() {
2043
- _fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(provider) {
2115
+ _fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(provider) {
2044
2116
  var auriLens, auTokenAddresses, underlyingDecimals, rawPrices;
2045
- return runtime_1.wrap(function _callee7$(_context7) {
2117
+ return runtime_1.wrap(function _callee8$(_context8) {
2046
2118
  while (1) {
2047
- switch (_context7.prev = _context7.next) {
2119
+ switch (_context8.prev = _context8.next) {
2048
2120
  case 0:
2049
2121
  auriLens = new ethers.Contract(networkAddresses.misc.AURILENS, abis$4.abi, provider);
2050
2122
  auTokenAddresses = networkAddresses.auTokens.map(function (auToken) {
@@ -2053,12 +2125,12 @@ function _fetchUnderlyingTokensPrices() {
2053
2125
  underlyingDecimals = networkAddresses.auTokens.map(function (auToken) {
2054
2126
  return getDecimal(auToken.underlying);
2055
2127
  });
2056
- _context7.next = 5;
2128
+ _context8.next = 5;
2057
2129
  return auriLens.auTokenUnderlyingPriceAll(auTokenAddresses);
2058
2130
 
2059
2131
  case 5:
2060
- rawPrices = _context7.sent;
2061
- return _context7.abrupt("return", rawPrices.map(function (res, ind) {
2132
+ rawPrices = _context8.sent;
2133
+ return _context8.abrupt("return", rawPrices.map(function (res, ind) {
2062
2134
  return {
2063
2135
  auToken: res.auToken,
2064
2136
  underlyingPrice: processPriceFromOracle(res.underlyingPrice, underlyingDecimals[ind])
@@ -2067,10 +2139,10 @@ function _fetchUnderlyingTokensPrices() {
2067
2139
 
2068
2140
  case 7:
2069
2141
  case "end":
2070
- return _context7.stop();
2142
+ return _context8.stop();
2071
2143
  }
2072
2144
  }
2073
- }, _callee7);
2145
+ }, _callee8);
2074
2146
  }));
2075
2147
  return _fetchUnderlyingTokensPrices.apply(this, arguments);
2076
2148
  }
@@ -2089,20 +2161,20 @@ function _fetchPrice(_x11, _x12) {
2089
2161
  }
2090
2162
 
2091
2163
  function _fetchPrice2() {
2092
- _fetchPrice2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(address, provider) {
2164
+ _fetchPrice2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(address, provider) {
2093
2165
  var matchingAuToken;
2094
- return runtime_1.wrap(function _callee8$(_context8) {
2166
+ return runtime_1.wrap(function _callee9$(_context9) {
2095
2167
  while (1) {
2096
- switch (_context8.prev = _context8.next) {
2168
+ switch (_context9.prev = _context9.next) {
2097
2169
  case 0:
2098
2170
  assert(PRICE_WHITELISTED.has(address.toLocaleLowerCase()), "Address " + address + " is not whitelisted for price fetching");
2099
2171
 
2100
2172
  if (!shouldFetchFromCoingecko(address)) {
2101
- _context8.next = 3;
2173
+ _context9.next = 3;
2102
2174
  break;
2103
2175
  }
2104
2176
 
2105
- return _context8.abrupt("return", fetchPriceFromCoingecko(address));
2177
+ return _context9.abrupt("return", fetchPriceFromCoingecko(address));
2106
2178
 
2107
2179
  case 3:
2108
2180
  matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
@@ -2110,21 +2182,21 @@ function _fetchPrice2() {
2110
2182
  });
2111
2183
 
2112
2184
  if (!(matchingAuToken !== undefined)) {
2113
- _context8.next = 8;
2185
+ _context9.next = 8;
2114
2186
  break;
2115
2187
  }
2116
2188
 
2117
- return _context8.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
2189
+ return _context9.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
2118
2190
 
2119
2191
  case 8:
2120
2192
  throw Error("Unable to fetch price for " + address);
2121
2193
 
2122
2194
  case 9:
2123
2195
  case "end":
2124
- return _context8.stop();
2196
+ return _context9.stop();
2125
2197
  }
2126
2198
  }
2127
- }, _callee8);
2199
+ }, _callee9);
2128
2200
  }));
2129
2201
  return _fetchPrice2.apply(this, arguments);
2130
2202
  }
@@ -2134,51 +2206,51 @@ function fetchPrice(_x13, _x14) {
2134
2206
  }
2135
2207
 
2136
2208
  function _fetchPrice3() {
2137
- _fetchPrice3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(address, provider) {
2138
- return runtime_1.wrap(function _callee9$(_context9) {
2209
+ _fetchPrice3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(address, provider) {
2210
+ return runtime_1.wrap(function _callee10$(_context10) {
2139
2211
  while (1) {
2140
- switch (_context9.prev = _context9.next) {
2212
+ switch (_context10.prev = _context10.next) {
2141
2213
  case 0:
2142
2214
  if (!(address.toLowerCase() in HARDCODE_PRICE_TOKENS)) {
2143
- _context9.next = 4;
2215
+ _context10.next = 4;
2144
2216
  break;
2145
2217
  }
2146
2218
 
2147
- return _context9.abrupt("return", new BigNumber(HARDCODE_PRICE_TOKENS[address.toLowerCase()]));
2219
+ return _context10.abrupt("return", new BigNumber(HARDCODE_PRICE_TOKENS[address.toLowerCase()]));
2148
2220
 
2149
2221
  case 4:
2150
2222
  if (!isSameAddress(address, networkAddresses.tokens.PLYWNEAR)) {
2151
- _context9.next = 8;
2223
+ _context10.next = 8;
2152
2224
  break;
2153
2225
  }
2154
2226
 
2155
- return _context9.abrupt("return", fetchLPPrice(address, provider));
2227
+ return _context10.abrupt("return", fetchLPPrice(address, provider));
2156
2228
 
2157
2229
  case 8:
2158
2230
  if (!isSameAddress(address, networkAddresses.tokens.PLY)) {
2159
- _context9.next = 12;
2231
+ _context10.next = 12;
2160
2232
  break;
2161
2233
  }
2162
2234
 
2163
- return _context9.abrupt("return", fetchPLYPrice(provider));
2235
+ return _context10.abrupt("return", fetchPLYPrice(provider));
2164
2236
 
2165
2237
  case 12:
2166
2238
  if (!isSameAddress(address, networkAddresses.tokens.PULP)) {
2167
- _context9.next = 14;
2239
+ _context10.next = 14;
2168
2240
  break;
2169
2241
  }
2170
2242
 
2171
- return _context9.abrupt("return", fetchPULPPrice(provider));
2243
+ return _context10.abrupt("return", fetchPULPPrice(provider));
2172
2244
 
2173
2245
  case 14:
2174
- return _context9.abrupt("return", _fetchPrice(address, provider));
2246
+ return _context10.abrupt("return", _fetchPrice(address, provider));
2175
2247
 
2176
2248
  case 15:
2177
2249
  case "end":
2178
- return _context9.stop();
2250
+ return _context10.stop();
2179
2251
  }
2180
2252
  }
2181
- }, _callee9);
2253
+ }, _callee10);
2182
2254
  }));
2183
2255
  return _fetchPrice3.apply(this, arguments);
2184
2256
  }
@@ -2188,19 +2260,19 @@ function fetchPLYPrice(_x15) {
2188
2260
  }
2189
2261
 
2190
2262
  function _fetchPLYPrice() {
2191
- _fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(provider) {
2192
- return runtime_1.wrap(function _callee10$(_context10) {
2263
+ _fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(provider) {
2264
+ return runtime_1.wrap(function _callee11$(_context11) {
2193
2265
  while (1) {
2194
- switch (_context10.prev = _context10.next) {
2266
+ switch (_context11.prev = _context11.next) {
2195
2267
  case 0:
2196
- return _context10.abrupt("return", fetchToken0PriceByLP(networkAddresses.tokens.PLYWNEAR, provider));
2268
+ return _context11.abrupt("return", fetchToken0PriceByLP(networkAddresses.tokens.PLYWNEAR, provider));
2197
2269
 
2198
2270
  case 1:
2199
2271
  case "end":
2200
- return _context10.stop();
2272
+ return _context11.stop();
2201
2273
  }
2202
2274
  }
2203
- }, _callee10);
2275
+ }, _callee11);
2204
2276
  }));
2205
2277
  return _fetchPLYPrice.apply(this, arguments);
2206
2278
  }
@@ -2210,19 +2282,19 @@ function fetchPULPPrice(_x16) {
2210
2282
  }
2211
2283
 
2212
2284
  function _fetchPULPPrice() {
2213
- _fetchPULPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(provider) {
2214
- return runtime_1.wrap(function _callee11$(_context11) {
2285
+ _fetchPULPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(provider) {
2286
+ return runtime_1.wrap(function _callee12$(_context12) {
2215
2287
  while (1) {
2216
- switch (_context11.prev = _context11.next) {
2288
+ switch (_context12.prev = _context12.next) {
2217
2289
  case 0:
2218
- return _context11.abrupt("return", new BigNumber(0));
2290
+ return _context12.abrupt("return", new BigNumber(0));
2219
2291
 
2220
2292
  case 1:
2221
2293
  case "end":
2222
- return _context11.stop();
2294
+ return _context12.stop();
2223
2295
  }
2224
2296
  }
2225
- }, _callee11);
2297
+ }, _callee12);
2226
2298
  }));
2227
2299
  return _fetchPULPPrice.apply(this, arguments);
2228
2300
  }
@@ -2232,42 +2304,42 @@ function fetchToken0PriceByLP(_x17, _x18) {
2232
2304
  }
2233
2305
 
2234
2306
  function _fetchToken0PriceByLP() {
2235
- _fetchToken0PriceByLP = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(LP, provider) {
2307
+ _fetchToken0PriceByLP = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(LP, provider) {
2236
2308
  var LPInfo, token0Decimal, token1Decimal;
2237
- return runtime_1.wrap(function _callee12$(_context12) {
2309
+ return runtime_1.wrap(function _callee13$(_context13) {
2238
2310
  while (1) {
2239
- switch (_context12.prev = _context12.next) {
2311
+ switch (_context13.prev = _context13.next) {
2240
2312
  case 0:
2241
- _context12.next = 2;
2313
+ _context13.next = 2;
2242
2314
  return fetchLPPositions(LP, provider);
2243
2315
 
2244
2316
  case 2:
2245
- LPInfo = _context12.sent;
2317
+ LPInfo = _context13.sent;
2246
2318
 
2247
2319
  if (!LPInfo.reserve1.isZero()) {
2248
- _context12.next = 5;
2320
+ _context13.next = 5;
2249
2321
  break;
2250
2322
  }
2251
2323
 
2252
- return _context12.abrupt("return", new BigNumber(0));
2324
+ return _context13.abrupt("return", new BigNumber(0));
2253
2325
 
2254
2326
  case 5:
2255
2327
  token0Decimal = getDecimal(LPInfo.token0);
2256
2328
  token1Decimal = getDecimal(LPInfo.token1); // (token0Price * reserve0) / 10^decimal0 = (token1Price * reserve1) / 10^decimal1
2257
2329
  // token0Price = (token1Price * reserve1) * 10^decimal0 / 10^decimal1 / reserve0
2258
2330
 
2259
- _context12.next = 9;
2331
+ _context13.next = 9;
2260
2332
  return fetchPrice(LPInfo.token1, provider);
2261
2333
 
2262
2334
  case 9:
2263
- return _context12.abrupt("return", _context12.sent.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(decimalFactor(token0Decimal)).dividedBy(decimalFactor(token1Decimal)).dividedBy(LPInfo.reserve0.toString()));
2335
+ return _context13.abrupt("return", _context13.sent.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(decimalFactor(token0Decimal)).dividedBy(decimalFactor(token1Decimal)).dividedBy(LPInfo.reserve0.toString()));
2264
2336
 
2265
2337
  case 10:
2266
2338
  case "end":
2267
- return _context12.stop();
2339
+ return _context13.stop();
2268
2340
  }
2269
2341
  }
2270
- }, _callee12);
2342
+ }, _callee13);
2271
2343
  }));
2272
2344
  return _fetchToken0PriceByLP.apply(this, arguments);
2273
2345
  }
@@ -2277,33 +2349,33 @@ function fetchValuation(_x19, _x20) {
2277
2349
  }
2278
2350
 
2279
2351
  function _fetchValuation() {
2280
- _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(tokenAmount, provider) {
2352
+ _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(tokenAmount, provider) {
2281
2353
  var price;
2282
- return runtime_1.wrap(function _callee13$(_context13) {
2354
+ return runtime_1.wrap(function _callee14$(_context14) {
2283
2355
  while (1) {
2284
- switch (_context13.prev = _context13.next) {
2356
+ switch (_context14.prev = _context14.next) {
2285
2357
  case 0:
2286
2358
  if (!(tokenAmount.rawAmount() == '0')) {
2287
- _context13.next = 2;
2359
+ _context14.next = 2;
2288
2360
  break;
2289
2361
  }
2290
2362
 
2291
- return _context13.abrupt("return", new BigNumber(0));
2363
+ return _context14.abrupt("return", new BigNumber(0));
2292
2364
 
2293
2365
  case 2:
2294
- _context13.next = 4;
2366
+ _context14.next = 4;
2295
2367
  return fetchPrice(tokenAmount.token.address, provider);
2296
2368
 
2297
2369
  case 4:
2298
- price = _context13.sent;
2299
- return _context13.abrupt("return", calcValuation(tokenAmount, price));
2370
+ price = _context14.sent;
2371
+ return _context14.abrupt("return", calcValuation(tokenAmount, price));
2300
2372
 
2301
2373
  case 6:
2302
2374
  case "end":
2303
- return _context13.stop();
2375
+ return _context14.stop();
2304
2376
  }
2305
2377
  }
2306
- }, _callee13);
2378
+ }, _callee14);
2307
2379
  }));
2308
2380
  return _fetchValuation.apply(this, arguments);
2309
2381
  }
@@ -2316,18 +2388,18 @@ function valuateToken(_x21, _x22) {
2316
2388
  }
2317
2389
 
2318
2390
  function _valuateToken() {
2319
- _valuateToken = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(tokenAmount, provider) {
2391
+ _valuateToken = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15(tokenAmount, provider) {
2320
2392
  var tokenValuation;
2321
- return runtime_1.wrap(function _callee14$(_context14) {
2393
+ return runtime_1.wrap(function _callee15$(_context15) {
2322
2394
  while (1) {
2323
- switch (_context14.prev = _context14.next) {
2395
+ switch (_context15.prev = _context15.next) {
2324
2396
  case 0:
2325
- _context14.next = 2;
2397
+ _context15.next = 2;
2326
2398
  return fetchValuation(tokenAmount, provider);
2327
2399
 
2328
2400
  case 2:
2329
- tokenValuation = _context14.sent;
2330
- return _context14.abrupt("return", {
2401
+ tokenValuation = _context15.sent;
2402
+ return _context15.abrupt("return", {
2331
2403
  tokenAmount: tokenAmount,
2332
2404
  currencyAmount: {
2333
2405
  currency: 'USD',
@@ -2337,10 +2409,10 @@ function _valuateToken() {
2337
2409
 
2338
2410
  case 4:
2339
2411
  case "end":
2340
- return _context14.stop();
2412
+ return _context15.stop();
2341
2413
  }
2342
2414
  }
2343
- }, _callee14);
2415
+ }, _callee15);
2344
2416
  }));
2345
2417
  return _valuateToken.apply(this, arguments);
2346
2418
  }
@@ -2473,6 +2545,7 @@ var helpers = {
2473
2545
  fetchPriceFromCoingecko: fetchPriceFromCoingecko,
2474
2546
  fetchLPPositions: fetchLPPositions,
2475
2547
  fetchLPPrice: fetchLPPrice,
2548
+ fetchStNEARPrice: fetchStNEARPrice,
2476
2549
  fetchPriceFromOracle: fetchPriceFromOracle,
2477
2550
  fetchUnderlyingTokensPrices: fetchUnderlyingTokensPrices,
2478
2551
  fetchPrice: fetchPrice,
@@ -5387,6 +5460,7 @@ exports.fetchPrice = fetchPrice;
5387
5460
  exports.fetchPriceFromCoingecko = fetchPriceFromCoingecko;
5388
5461
  exports.fetchPriceFromCoingeckoAPI = fetchPriceFromCoingeckoAPI;
5389
5462
  exports.fetchPriceFromOracle = fetchPriceFromOracle;
5463
+ exports.fetchStNEARPrice = fetchStNEARPrice;
5390
5464
  exports.fetchToken0PriceByLP = fetchToken0PriceByLP;
5391
5465
  exports.fetchUnderlyingTokensPrices = fetchUnderlyingTokensPrices;
5392
5466
  exports.fetchValuation = fetchValuation;