@aurigami/sdk 1.7.4 → 1.7.6-temp

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.
@@ -17,7 +17,6 @@ export declare function fetchUnderlyingTokensPrices(provider: providers.Provider
17
17
  auToken: string;
18
18
  underlyingPrice: BigNumber;
19
19
  }[]>;
20
- export declare function fetchStNEARPrice(): Promise<BigNumber>;
21
20
  export declare function fetchPrice(address: Address, provider: providers.Provider): Promise<BigNumber>;
22
21
  export declare function fetchPLYPrice(provider: providers.Provider): Promise<BigNumber>;
23
22
  export declare function fetchPULPPrice(provider: providers.Provider): Promise<BigNumber>;
@@ -1387,6 +1387,14 @@ function _getBlocksTimestamp() {
1387
1387
  while (1) {
1388
1388
  switch (_context4.prev = _context4.next) {
1389
1389
  case 0:
1390
+ if (!(blockNumbers.length == 0)) {
1391
+ _context4.next = 2;
1392
+ break;
1393
+ }
1394
+
1395
+ return _context4.abrupt("return", []);
1396
+
1397
+ case 2:
1390
1398
  CHUNK_SIZE = 100; // graphql query limit
1391
1399
 
1392
1400
  promises = [];
@@ -1400,10 +1408,10 @@ function _getBlocksTimestamp() {
1400
1408
  } // merge all the json objects
1401
1409
 
1402
1410
 
1403
- _context4.next = 6;
1411
+ _context4.next = 8;
1404
1412
  return Promise.all(promises);
1405
1413
 
1406
- case 6:
1414
+ case 8:
1407
1415
  results = _context4.sent.reduce(function (acc, cur) {
1408
1416
  return _extends({}, acc, cur);
1409
1417
  });
@@ -1415,10 +1423,10 @@ function _getBlocksTimestamp() {
1415
1423
  devLog("These blocks are missing from Aurora GraphQL endpoint: " + missingBlocks.join(', '));
1416
1424
  }
1417
1425
 
1418
- _context4.next = 11;
1426
+ _context4.next = 13;
1419
1427
  return getBlocksTimestampViaRPC(provider, missingBlocks);
1420
1428
 
1421
- case 11:
1429
+ case 13:
1422
1430
  missingBlocksTimestamps = _context4.sent;
1423
1431
  missingBlocksTimestamps.forEach(function (timestamp, index) {
1424
1432
  results["b" + missingBlocks[index]] = {
@@ -1429,7 +1437,7 @@ function _getBlocksTimestamp() {
1429
1437
  return Math.trunc(new Date(results["b" + blockNumber].timestamp).getTime() / 1000);
1430
1438
  }));
1431
1439
 
1432
- case 14:
1440
+ case 16:
1433
1441
  case "end":
1434
1442
  return _context4.stop();
1435
1443
  }
@@ -1692,13 +1700,13 @@ function _fetchPriceFromCoingecko() {
1692
1700
  break;
1693
1701
 
1694
1702
  case 3:
1695
- return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('aurora-near'));
1703
+ return _context2.abrupt("return", new BigNumber('4.27'));
1696
1704
 
1697
1705
  case 4:
1698
- return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('trisolaris'));
1706
+ return _context2.abrupt("return", new BigNumber('0.1034'));
1699
1707
 
1700
1708
  case 5:
1701
- return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('meta-pool'));
1709
+ return _context2.abrupt("return", new BigNumber('0.01335'));
1702
1710
 
1703
1711
  case 6:
1704
1712
  throw Error("Unknown token " + id + " in fetchPriceFromCoingecko");
@@ -1923,42 +1931,6 @@ function _fetchUnderlyingTokensPrices() {
1923
1931
  return _fetchUnderlyingTokensPrices.apply(this, arguments);
1924
1932
  }
1925
1933
 
1926
- function fetchStNEARPrice() {
1927
- return _fetchStNEARPrice.apply(this, arguments);
1928
- }
1929
-
1930
- function _fetchStNEARPrice() {
1931
- _fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
1932
- var ratioPromise, nearPricePromise, _yield$Promise$all, ratioRes, nearPrice, ratio;
1933
-
1934
- return runtime_1.wrap(function _callee8$(_context8) {
1935
- while (1) {
1936
- switch (_context8.prev = _context8.next) {
1937
- case 0:
1938
- ratioPromise = axios.get('https://validators.narwallets.com/metrics_json').then(function (res) {
1939
- return res.data;
1940
- });
1941
- nearPricePromise = fetchPriceFromCoingeckoAPI('near');
1942
- _context8.next = 4;
1943
- return Promise.all([ratioPromise, nearPricePromise]);
1944
-
1945
- case 4:
1946
- _yield$Promise$all = _context8.sent;
1947
- ratioRes = _yield$Promise$all[0];
1948
- nearPrice = _yield$Promise$all[1];
1949
- ratio = new BigNumber(ratioRes.st_near_price);
1950
- return _context8.abrupt("return", ratio.multipliedBy(nearPrice));
1951
-
1952
- case 9:
1953
- case "end":
1954
- return _context8.stop();
1955
- }
1956
- }
1957
- }, _callee8);
1958
- }));
1959
- return _fetchStNEARPrice.apply(this, arguments);
1960
- }
1961
-
1962
1934
  function shouldFetchFromCoingecko(address) {
1963
1935
  address = address.toLowerCase();
1964
1936
  return address == networkAddresses.tokens.AURORA || address == networkAddresses.tokens.TRI || address == networkAddresses.tokens.META;
@@ -1973,50 +1945,42 @@ function _fetchPrice(_x11, _x12) {
1973
1945
  }
1974
1946
 
1975
1947
  function _fetchPrice2() {
1976
- _fetchPrice2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(address, provider) {
1948
+ _fetchPrice2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(address, provider) {
1977
1949
  var matchingAuToken;
1978
- return runtime_1.wrap(function _callee9$(_context9) {
1950
+ return runtime_1.wrap(function _callee8$(_context8) {
1979
1951
  while (1) {
1980
- switch (_context9.prev = _context9.next) {
1952
+ switch (_context8.prev = _context8.next) {
1981
1953
  case 0:
1982
1954
  assert(PRICE_WHITELISTED.has(address.toLocaleLowerCase()), "Address " + address + " is not whitelisted for price fetching");
1983
1955
 
1984
- if (!isSameAddress(address, networkAddresses.tokens.stNEAR)) {
1985
- _context9.next = 3;
1986
- break;
1987
- }
1988
-
1989
- return _context9.abrupt("return", fetchStNEARPrice());
1990
-
1991
- case 3:
1992
1956
  if (!shouldFetchFromCoingecko(address)) {
1993
- _context9.next = 5;
1957
+ _context8.next = 3;
1994
1958
  break;
1995
1959
  }
1996
1960
 
1997
- return _context9.abrupt("return", fetchPriceFromCoingecko(address));
1961
+ return _context8.abrupt("return", fetchPriceFromCoingecko(address));
1998
1962
 
1999
- case 5:
1963
+ case 3:
2000
1964
  matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
2001
1965
  return isSameAddress(auToken.underlying, address);
2002
1966
  });
2003
1967
 
2004
1968
  if (!(matchingAuToken !== undefined)) {
2005
- _context9.next = 10;
1969
+ _context8.next = 8;
2006
1970
  break;
2007
1971
  }
2008
1972
 
2009
- return _context9.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
1973
+ return _context8.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
2010
1974
 
2011
- case 10:
1975
+ case 8:
2012
1976
  throw Error("Unable to fetch price for " + address);
2013
1977
 
2014
- case 11:
1978
+ case 9:
2015
1979
  case "end":
2016
- return _context9.stop();
1980
+ return _context8.stop();
2017
1981
  }
2018
1982
  }
2019
- }, _callee9);
1983
+ }, _callee8);
2020
1984
  }));
2021
1985
  return _fetchPrice2.apply(this, arguments);
2022
1986
  }
@@ -2026,51 +1990,51 @@ function fetchPrice(_x13, _x14) {
2026
1990
  }
2027
1991
 
2028
1992
  function _fetchPrice3() {
2029
- _fetchPrice3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(address, provider) {
2030
- return runtime_1.wrap(function _callee10$(_context10) {
1993
+ _fetchPrice3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(address, provider) {
1994
+ return runtime_1.wrap(function _callee9$(_context9) {
2031
1995
  while (1) {
2032
- switch (_context10.prev = _context10.next) {
1996
+ switch (_context9.prev = _context9.next) {
2033
1997
  case 0:
2034
1998
  if (!(address.toLowerCase() in HARDCODE_PRICE_TOKENS)) {
2035
- _context10.next = 4;
1999
+ _context9.next = 4;
2036
2000
  break;
2037
2001
  }
2038
2002
 
2039
- return _context10.abrupt("return", new BigNumber(HARDCODE_PRICE_TOKENS[address.toLowerCase()]));
2003
+ return _context9.abrupt("return", new BigNumber(HARDCODE_PRICE_TOKENS[address.toLowerCase()]));
2040
2004
 
2041
2005
  case 4:
2042
2006
  if (!isSameAddress(address, networkAddresses.tokens.PLYWNEAR)) {
2043
- _context10.next = 8;
2007
+ _context9.next = 8;
2044
2008
  break;
2045
2009
  }
2046
2010
 
2047
- return _context10.abrupt("return", fetchLPPrice(address, provider));
2011
+ return _context9.abrupt("return", fetchLPPrice(address, provider));
2048
2012
 
2049
2013
  case 8:
2050
2014
  if (!isSameAddress(address, networkAddresses.tokens.PLY)) {
2051
- _context10.next = 12;
2015
+ _context9.next = 12;
2052
2016
  break;
2053
2017
  }
2054
2018
 
2055
- return _context10.abrupt("return", fetchPLYPrice(provider));
2019
+ return _context9.abrupt("return", fetchPLYPrice(provider));
2056
2020
 
2057
2021
  case 12:
2058
2022
  if (!isSameAddress(address, networkAddresses.tokens.PULP)) {
2059
- _context10.next = 14;
2023
+ _context9.next = 14;
2060
2024
  break;
2061
2025
  }
2062
2026
 
2063
- return _context10.abrupt("return", fetchPULPPrice(provider));
2027
+ return _context9.abrupt("return", fetchPULPPrice(provider));
2064
2028
 
2065
2029
  case 14:
2066
- return _context10.abrupt("return", _fetchPrice(address, provider));
2030
+ return _context9.abrupt("return", _fetchPrice(address, provider));
2067
2031
 
2068
2032
  case 15:
2069
2033
  case "end":
2070
- return _context10.stop();
2034
+ return _context9.stop();
2071
2035
  }
2072
2036
  }
2073
- }, _callee10);
2037
+ }, _callee9);
2074
2038
  }));
2075
2039
  return _fetchPrice3.apply(this, arguments);
2076
2040
  }
@@ -2080,19 +2044,19 @@ function fetchPLYPrice(_x15) {
2080
2044
  }
2081
2045
 
2082
2046
  function _fetchPLYPrice() {
2083
- _fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(provider) {
2084
- return runtime_1.wrap(function _callee11$(_context11) {
2047
+ _fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(provider) {
2048
+ return runtime_1.wrap(function _callee10$(_context10) {
2085
2049
  while (1) {
2086
- switch (_context11.prev = _context11.next) {
2050
+ switch (_context10.prev = _context10.next) {
2087
2051
  case 0:
2088
- return _context11.abrupt("return", fetchToken0PriceByLP(networkAddresses.tokens.PLYWNEAR, provider));
2052
+ return _context10.abrupt("return", fetchToken0PriceByLP(networkAddresses.tokens.PLYWNEAR, provider));
2089
2053
 
2090
2054
  case 1:
2091
2055
  case "end":
2092
- return _context11.stop();
2056
+ return _context10.stop();
2093
2057
  }
2094
2058
  }
2095
- }, _callee11);
2059
+ }, _callee10);
2096
2060
  }));
2097
2061
  return _fetchPLYPrice.apply(this, arguments);
2098
2062
  }
@@ -2102,19 +2066,19 @@ function fetchPULPPrice(_x16) {
2102
2066
  }
2103
2067
 
2104
2068
  function _fetchPULPPrice() {
2105
- _fetchPULPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(provider) {
2106
- return runtime_1.wrap(function _callee12$(_context12) {
2069
+ _fetchPULPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(provider) {
2070
+ return runtime_1.wrap(function _callee11$(_context11) {
2107
2071
  while (1) {
2108
- switch (_context12.prev = _context12.next) {
2072
+ switch (_context11.prev = _context11.next) {
2109
2073
  case 0:
2110
- return _context12.abrupt("return", new BigNumber(0));
2074
+ return _context11.abrupt("return", new BigNumber(0));
2111
2075
 
2112
2076
  case 1:
2113
2077
  case "end":
2114
- return _context12.stop();
2078
+ return _context11.stop();
2115
2079
  }
2116
2080
  }
2117
- }, _callee12);
2081
+ }, _callee11);
2118
2082
  }));
2119
2083
  return _fetchPULPPrice.apply(this, arguments);
2120
2084
  }
@@ -2124,42 +2088,42 @@ function fetchToken0PriceByLP(_x17, _x18) {
2124
2088
  }
2125
2089
 
2126
2090
  function _fetchToken0PriceByLP() {
2127
- _fetchToken0PriceByLP = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(LP, provider) {
2091
+ _fetchToken0PriceByLP = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(LP, provider) {
2128
2092
  var LPInfo, token0Decimal, token1Decimal;
2129
- return runtime_1.wrap(function _callee13$(_context13) {
2093
+ return runtime_1.wrap(function _callee12$(_context12) {
2130
2094
  while (1) {
2131
- switch (_context13.prev = _context13.next) {
2095
+ switch (_context12.prev = _context12.next) {
2132
2096
  case 0:
2133
- _context13.next = 2;
2097
+ _context12.next = 2;
2134
2098
  return fetchLPPositions(LP, provider);
2135
2099
 
2136
2100
  case 2:
2137
- LPInfo = _context13.sent;
2101
+ LPInfo = _context12.sent;
2138
2102
 
2139
2103
  if (!LPInfo.reserve1.isZero()) {
2140
- _context13.next = 5;
2104
+ _context12.next = 5;
2141
2105
  break;
2142
2106
  }
2143
2107
 
2144
- return _context13.abrupt("return", new BigNumber(0));
2108
+ return _context12.abrupt("return", new BigNumber(0));
2145
2109
 
2146
2110
  case 5:
2147
2111
  token0Decimal = getDecimal(LPInfo.token0);
2148
2112
  token1Decimal = getDecimal(LPInfo.token1); // (token0Price * reserve0) / 10^decimal0 = (token1Price * reserve1) / 10^decimal1
2149
2113
  // token0Price = (token1Price * reserve1) * 10^decimal0 / 10^decimal1 / reserve0
2150
2114
 
2151
- _context13.next = 9;
2115
+ _context12.next = 9;
2152
2116
  return fetchPrice(LPInfo.token1, provider);
2153
2117
 
2154
2118
  case 9:
2155
- return _context13.abrupt("return", _context13.sent.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(decimalFactor(token0Decimal)).dividedBy(decimalFactor(token1Decimal)).dividedBy(LPInfo.reserve0.toString()));
2119
+ return _context12.abrupt("return", _context12.sent.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(decimalFactor(token0Decimal)).dividedBy(decimalFactor(token1Decimal)).dividedBy(LPInfo.reserve0.toString()));
2156
2120
 
2157
2121
  case 10:
2158
2122
  case "end":
2159
- return _context13.stop();
2123
+ return _context12.stop();
2160
2124
  }
2161
2125
  }
2162
- }, _callee13);
2126
+ }, _callee12);
2163
2127
  }));
2164
2128
  return _fetchToken0PriceByLP.apply(this, arguments);
2165
2129
  }
@@ -2169,33 +2133,33 @@ function fetchValuation(_x19, _x20) {
2169
2133
  }
2170
2134
 
2171
2135
  function _fetchValuation() {
2172
- _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(tokenAmount, provider) {
2136
+ _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(tokenAmount, provider) {
2173
2137
  var price;
2174
- return runtime_1.wrap(function _callee14$(_context14) {
2138
+ return runtime_1.wrap(function _callee13$(_context13) {
2175
2139
  while (1) {
2176
- switch (_context14.prev = _context14.next) {
2140
+ switch (_context13.prev = _context13.next) {
2177
2141
  case 0:
2178
2142
  if (!(tokenAmount.rawAmount() == '0')) {
2179
- _context14.next = 2;
2143
+ _context13.next = 2;
2180
2144
  break;
2181
2145
  }
2182
2146
 
2183
- return _context14.abrupt("return", new BigNumber(0));
2147
+ return _context13.abrupt("return", new BigNumber(0));
2184
2148
 
2185
2149
  case 2:
2186
- _context14.next = 4;
2150
+ _context13.next = 4;
2187
2151
  return fetchPrice(tokenAmount.token.address, provider);
2188
2152
 
2189
2153
  case 4:
2190
- price = _context14.sent;
2191
- return _context14.abrupt("return", calcValuation(tokenAmount, price));
2154
+ price = _context13.sent;
2155
+ return _context13.abrupt("return", calcValuation(tokenAmount, price));
2192
2156
 
2193
2157
  case 6:
2194
2158
  case "end":
2195
- return _context14.stop();
2159
+ return _context13.stop();
2196
2160
  }
2197
2161
  }
2198
- }, _callee14);
2162
+ }, _callee13);
2199
2163
  }));
2200
2164
  return _fetchValuation.apply(this, arguments);
2201
2165
  }
@@ -2208,18 +2172,18 @@ function valuateToken(_x21, _x22) {
2208
2172
  }
2209
2173
 
2210
2174
  function _valuateToken() {
2211
- _valuateToken = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15(tokenAmount, provider) {
2175
+ _valuateToken = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(tokenAmount, provider) {
2212
2176
  var tokenValuation;
2213
- return runtime_1.wrap(function _callee15$(_context15) {
2177
+ return runtime_1.wrap(function _callee14$(_context14) {
2214
2178
  while (1) {
2215
- switch (_context15.prev = _context15.next) {
2179
+ switch (_context14.prev = _context14.next) {
2216
2180
  case 0:
2217
- _context15.next = 2;
2181
+ _context14.next = 2;
2218
2182
  return fetchValuation(tokenAmount, provider);
2219
2183
 
2220
2184
  case 2:
2221
- tokenValuation = _context15.sent;
2222
- return _context15.abrupt("return", {
2185
+ tokenValuation = _context14.sent;
2186
+ return _context14.abrupt("return", {
2223
2187
  tokenAmount: tokenAmount,
2224
2188
  currencyAmount: {
2225
2189
  currency: 'USD',
@@ -2229,10 +2193,10 @@ function _valuateToken() {
2229
2193
 
2230
2194
  case 4:
2231
2195
  case "end":
2232
- return _context15.stop();
2196
+ return _context14.stop();
2233
2197
  }
2234
2198
  }
2235
- }, _callee15);
2199
+ }, _callee14);
2236
2200
  }));
2237
2201
  return _valuateToken.apply(this, arguments);
2238
2202
  }
@@ -2367,7 +2331,6 @@ var helpers = {
2367
2331
  fetchLPPrice: fetchLPPrice,
2368
2332
  fetchPriceFromOracle: fetchPriceFromOracle,
2369
2333
  fetchUnderlyingTokensPrices: fetchUnderlyingTokensPrices,
2370
- fetchStNEARPrice: fetchStNEARPrice,
2371
2334
  fetchPrice: fetchPrice,
2372
2335
  fetchPLYPrice: fetchPLYPrice,
2373
2336
  fetchPULPPrice: fetchPULPPrice,
@@ -5151,7 +5114,6 @@ exports.fetchPrice = fetchPrice;
5151
5114
  exports.fetchPriceFromCoingecko = fetchPriceFromCoingecko;
5152
5115
  exports.fetchPriceFromCoingeckoAPI = fetchPriceFromCoingeckoAPI;
5153
5116
  exports.fetchPriceFromOracle = fetchPriceFromOracle;
5154
- exports.fetchStNEARPrice = fetchStNEARPrice;
5155
5117
  exports.fetchToken0PriceByLP = fetchToken0PriceByLP;
5156
5118
  exports.fetchUnderlyingTokensPrices = fetchUnderlyingTokensPrices;
5157
5119
  exports.fetchValuation = fetchValuation;