@aurigami/sdk 1.7.5 → 1.7.6

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.
package/dist/sdk.esm.js CHANGED
@@ -1926,42 +1926,6 @@ function _fetchUnderlyingTokensPrices() {
1926
1926
  return _fetchUnderlyingTokensPrices.apply(this, arguments);
1927
1927
  }
1928
1928
 
1929
- function fetchStNEARPrice() {
1930
- return _fetchStNEARPrice.apply(this, arguments);
1931
- }
1932
-
1933
- function _fetchStNEARPrice() {
1934
- _fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
1935
- var ratioPromise, nearPricePromise, _yield$Promise$all, ratioRes, nearPrice, ratio;
1936
-
1937
- return runtime_1.wrap(function _callee8$(_context8) {
1938
- while (1) {
1939
- switch (_context8.prev = _context8.next) {
1940
- case 0:
1941
- ratioPromise = axios.get('https://validators.narwallets.com/metrics_json').then(function (res) {
1942
- return res.data;
1943
- });
1944
- nearPricePromise = fetchPriceFromCoingeckoAPI('near');
1945
- _context8.next = 4;
1946
- return Promise.all([ratioPromise, nearPricePromise]);
1947
-
1948
- case 4:
1949
- _yield$Promise$all = _context8.sent;
1950
- ratioRes = _yield$Promise$all[0];
1951
- nearPrice = _yield$Promise$all[1];
1952
- ratio = new BigNumber(ratioRes.st_near_price);
1953
- return _context8.abrupt("return", ratio.multipliedBy(nearPrice));
1954
-
1955
- case 9:
1956
- case "end":
1957
- return _context8.stop();
1958
- }
1959
- }
1960
- }, _callee8);
1961
- }));
1962
- return _fetchStNEARPrice.apply(this, arguments);
1963
- }
1964
-
1965
1929
  function shouldFetchFromCoingecko(address) {
1966
1930
  address = address.toLowerCase();
1967
1931
  return address == networkAddresses.tokens.AURORA || address == networkAddresses.tokens.TRI || address == networkAddresses.tokens.META;
@@ -1976,50 +1940,42 @@ function _fetchPrice(_x11, _x12) {
1976
1940
  }
1977
1941
 
1978
1942
  function _fetchPrice2() {
1979
- _fetchPrice2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(address, provider) {
1943
+ _fetchPrice2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(address, provider) {
1980
1944
  var matchingAuToken;
1981
- return runtime_1.wrap(function _callee9$(_context9) {
1945
+ return runtime_1.wrap(function _callee8$(_context8) {
1982
1946
  while (1) {
1983
- switch (_context9.prev = _context9.next) {
1947
+ switch (_context8.prev = _context8.next) {
1984
1948
  case 0:
1985
1949
  assert(PRICE_WHITELISTED.has(address.toLocaleLowerCase()), "Address " + address + " is not whitelisted for price fetching");
1986
1950
 
1987
- if (!isSameAddress(address, networkAddresses.tokens.stNEAR)) {
1988
- _context9.next = 3;
1989
- break;
1990
- }
1991
-
1992
- return _context9.abrupt("return", fetchStNEARPrice());
1993
-
1994
- case 3:
1995
1951
  if (!shouldFetchFromCoingecko(address)) {
1996
- _context9.next = 5;
1952
+ _context8.next = 3;
1997
1953
  break;
1998
1954
  }
1999
1955
 
2000
- return _context9.abrupt("return", fetchPriceFromCoingecko(address));
1956
+ return _context8.abrupt("return", fetchPriceFromCoingecko(address));
2001
1957
 
2002
- case 5:
1958
+ case 3:
2003
1959
  matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
2004
1960
  return isSameAddress(auToken.underlying, address);
2005
1961
  });
2006
1962
 
2007
1963
  if (!(matchingAuToken !== undefined)) {
2008
- _context9.next = 10;
1964
+ _context8.next = 8;
2009
1965
  break;
2010
1966
  }
2011
1967
 
2012
- return _context9.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
1968
+ return _context8.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
2013
1969
 
2014
- case 10:
1970
+ case 8:
2015
1971
  throw Error("Unable to fetch price for " + address);
2016
1972
 
2017
- case 11:
1973
+ case 9:
2018
1974
  case "end":
2019
- return _context9.stop();
1975
+ return _context8.stop();
2020
1976
  }
2021
1977
  }
2022
- }, _callee9);
1978
+ }, _callee8);
2023
1979
  }));
2024
1980
  return _fetchPrice2.apply(this, arguments);
2025
1981
  }
@@ -2029,51 +1985,51 @@ function fetchPrice(_x13, _x14) {
2029
1985
  }
2030
1986
 
2031
1987
  function _fetchPrice3() {
2032
- _fetchPrice3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(address, provider) {
2033
- return runtime_1.wrap(function _callee10$(_context10) {
1988
+ _fetchPrice3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(address, provider) {
1989
+ return runtime_1.wrap(function _callee9$(_context9) {
2034
1990
  while (1) {
2035
- switch (_context10.prev = _context10.next) {
1991
+ switch (_context9.prev = _context9.next) {
2036
1992
  case 0:
2037
1993
  if (!(address.toLowerCase() in HARDCODE_PRICE_TOKENS)) {
2038
- _context10.next = 4;
1994
+ _context9.next = 4;
2039
1995
  break;
2040
1996
  }
2041
1997
 
2042
- return _context10.abrupt("return", new BigNumber(HARDCODE_PRICE_TOKENS[address.toLowerCase()]));
1998
+ return _context9.abrupt("return", new BigNumber(HARDCODE_PRICE_TOKENS[address.toLowerCase()]));
2043
1999
 
2044
2000
  case 4:
2045
2001
  if (!isSameAddress(address, networkAddresses.tokens.PLYWNEAR)) {
2046
- _context10.next = 8;
2002
+ _context9.next = 8;
2047
2003
  break;
2048
2004
  }
2049
2005
 
2050
- return _context10.abrupt("return", fetchLPPrice(address, provider));
2006
+ return _context9.abrupt("return", fetchLPPrice(address, provider));
2051
2007
 
2052
2008
  case 8:
2053
2009
  if (!isSameAddress(address, networkAddresses.tokens.PLY)) {
2054
- _context10.next = 12;
2010
+ _context9.next = 12;
2055
2011
  break;
2056
2012
  }
2057
2013
 
2058
- return _context10.abrupt("return", fetchPLYPrice(provider));
2014
+ return _context9.abrupt("return", fetchPLYPrice(provider));
2059
2015
 
2060
2016
  case 12:
2061
2017
  if (!isSameAddress(address, networkAddresses.tokens.PULP)) {
2062
- _context10.next = 14;
2018
+ _context9.next = 14;
2063
2019
  break;
2064
2020
  }
2065
2021
 
2066
- return _context10.abrupt("return", fetchPULPPrice(provider));
2022
+ return _context9.abrupt("return", fetchPULPPrice(provider));
2067
2023
 
2068
2024
  case 14:
2069
- return _context10.abrupt("return", _fetchPrice(address, provider));
2025
+ return _context9.abrupt("return", _fetchPrice(address, provider));
2070
2026
 
2071
2027
  case 15:
2072
2028
  case "end":
2073
- return _context10.stop();
2029
+ return _context9.stop();
2074
2030
  }
2075
2031
  }
2076
- }, _callee10);
2032
+ }, _callee9);
2077
2033
  }));
2078
2034
  return _fetchPrice3.apply(this, arguments);
2079
2035
  }
@@ -2083,19 +2039,19 @@ function fetchPLYPrice(_x15) {
2083
2039
  }
2084
2040
 
2085
2041
  function _fetchPLYPrice() {
2086
- _fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(provider) {
2087
- return runtime_1.wrap(function _callee11$(_context11) {
2042
+ _fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(provider) {
2043
+ return runtime_1.wrap(function _callee10$(_context10) {
2088
2044
  while (1) {
2089
- switch (_context11.prev = _context11.next) {
2045
+ switch (_context10.prev = _context10.next) {
2090
2046
  case 0:
2091
- return _context11.abrupt("return", fetchToken0PriceByLP(networkAddresses.tokens.PLYWNEAR, provider));
2047
+ return _context10.abrupt("return", fetchToken0PriceByLP(networkAddresses.tokens.PLYWNEAR, provider));
2092
2048
 
2093
2049
  case 1:
2094
2050
  case "end":
2095
- return _context11.stop();
2051
+ return _context10.stop();
2096
2052
  }
2097
2053
  }
2098
- }, _callee11);
2054
+ }, _callee10);
2099
2055
  }));
2100
2056
  return _fetchPLYPrice.apply(this, arguments);
2101
2057
  }
@@ -2105,19 +2061,19 @@ function fetchPULPPrice(_x16) {
2105
2061
  }
2106
2062
 
2107
2063
  function _fetchPULPPrice() {
2108
- _fetchPULPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(provider) {
2109
- return runtime_1.wrap(function _callee12$(_context12) {
2064
+ _fetchPULPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(provider) {
2065
+ return runtime_1.wrap(function _callee11$(_context11) {
2110
2066
  while (1) {
2111
- switch (_context12.prev = _context12.next) {
2067
+ switch (_context11.prev = _context11.next) {
2112
2068
  case 0:
2113
- return _context12.abrupt("return", new BigNumber(0));
2069
+ return _context11.abrupt("return", new BigNumber(0));
2114
2070
 
2115
2071
  case 1:
2116
2072
  case "end":
2117
- return _context12.stop();
2073
+ return _context11.stop();
2118
2074
  }
2119
2075
  }
2120
- }, _callee12);
2076
+ }, _callee11);
2121
2077
  }));
2122
2078
  return _fetchPULPPrice.apply(this, arguments);
2123
2079
  }
@@ -2127,42 +2083,42 @@ function fetchToken0PriceByLP(_x17, _x18) {
2127
2083
  }
2128
2084
 
2129
2085
  function _fetchToken0PriceByLP() {
2130
- _fetchToken0PriceByLP = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(LP, provider) {
2086
+ _fetchToken0PriceByLP = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(LP, provider) {
2131
2087
  var LPInfo, token0Decimal, token1Decimal;
2132
- return runtime_1.wrap(function _callee13$(_context13) {
2088
+ return runtime_1.wrap(function _callee12$(_context12) {
2133
2089
  while (1) {
2134
- switch (_context13.prev = _context13.next) {
2090
+ switch (_context12.prev = _context12.next) {
2135
2091
  case 0:
2136
- _context13.next = 2;
2092
+ _context12.next = 2;
2137
2093
  return fetchLPPositions(LP, provider);
2138
2094
 
2139
2095
  case 2:
2140
- LPInfo = _context13.sent;
2096
+ LPInfo = _context12.sent;
2141
2097
 
2142
2098
  if (!LPInfo.reserve1.isZero()) {
2143
- _context13.next = 5;
2099
+ _context12.next = 5;
2144
2100
  break;
2145
2101
  }
2146
2102
 
2147
- return _context13.abrupt("return", new BigNumber(0));
2103
+ return _context12.abrupt("return", new BigNumber(0));
2148
2104
 
2149
2105
  case 5:
2150
2106
  token0Decimal = getDecimal(LPInfo.token0);
2151
2107
  token1Decimal = getDecimal(LPInfo.token1); // (token0Price * reserve0) / 10^decimal0 = (token1Price * reserve1) / 10^decimal1
2152
2108
  // token0Price = (token1Price * reserve1) * 10^decimal0 / 10^decimal1 / reserve0
2153
2109
 
2154
- _context13.next = 9;
2110
+ _context12.next = 9;
2155
2111
  return fetchPrice(LPInfo.token1, provider);
2156
2112
 
2157
2113
  case 9:
2158
- return _context13.abrupt("return", _context13.sent.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(decimalFactor(token0Decimal)).dividedBy(decimalFactor(token1Decimal)).dividedBy(LPInfo.reserve0.toString()));
2114
+ return _context12.abrupt("return", _context12.sent.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(decimalFactor(token0Decimal)).dividedBy(decimalFactor(token1Decimal)).dividedBy(LPInfo.reserve0.toString()));
2159
2115
 
2160
2116
  case 10:
2161
2117
  case "end":
2162
- return _context13.stop();
2118
+ return _context12.stop();
2163
2119
  }
2164
2120
  }
2165
- }, _callee13);
2121
+ }, _callee12);
2166
2122
  }));
2167
2123
  return _fetchToken0PriceByLP.apply(this, arguments);
2168
2124
  }
@@ -2172,33 +2128,33 @@ function fetchValuation(_x19, _x20) {
2172
2128
  }
2173
2129
 
2174
2130
  function _fetchValuation() {
2175
- _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(tokenAmount, provider) {
2131
+ _fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(tokenAmount, provider) {
2176
2132
  var price;
2177
- return runtime_1.wrap(function _callee14$(_context14) {
2133
+ return runtime_1.wrap(function _callee13$(_context13) {
2178
2134
  while (1) {
2179
- switch (_context14.prev = _context14.next) {
2135
+ switch (_context13.prev = _context13.next) {
2180
2136
  case 0:
2181
2137
  if (!(tokenAmount.rawAmount() == '0')) {
2182
- _context14.next = 2;
2138
+ _context13.next = 2;
2183
2139
  break;
2184
2140
  }
2185
2141
 
2186
- return _context14.abrupt("return", new BigNumber(0));
2142
+ return _context13.abrupt("return", new BigNumber(0));
2187
2143
 
2188
2144
  case 2:
2189
- _context14.next = 4;
2145
+ _context13.next = 4;
2190
2146
  return fetchPrice(tokenAmount.token.address, provider);
2191
2147
 
2192
2148
  case 4:
2193
- price = _context14.sent;
2194
- return _context14.abrupt("return", calcValuation(tokenAmount, price));
2149
+ price = _context13.sent;
2150
+ return _context13.abrupt("return", calcValuation(tokenAmount, price));
2195
2151
 
2196
2152
  case 6:
2197
2153
  case "end":
2198
- return _context14.stop();
2154
+ return _context13.stop();
2199
2155
  }
2200
2156
  }
2201
- }, _callee14);
2157
+ }, _callee13);
2202
2158
  }));
2203
2159
  return _fetchValuation.apply(this, arguments);
2204
2160
  }
@@ -2211,18 +2167,18 @@ function valuateToken(_x21, _x22) {
2211
2167
  }
2212
2168
 
2213
2169
  function _valuateToken() {
2214
- _valuateToken = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15(tokenAmount, provider) {
2170
+ _valuateToken = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(tokenAmount, provider) {
2215
2171
  var tokenValuation;
2216
- return runtime_1.wrap(function _callee15$(_context15) {
2172
+ return runtime_1.wrap(function _callee14$(_context14) {
2217
2173
  while (1) {
2218
- switch (_context15.prev = _context15.next) {
2174
+ switch (_context14.prev = _context14.next) {
2219
2175
  case 0:
2220
- _context15.next = 2;
2176
+ _context14.next = 2;
2221
2177
  return fetchValuation(tokenAmount, provider);
2222
2178
 
2223
2179
  case 2:
2224
- tokenValuation = _context15.sent;
2225
- return _context15.abrupt("return", {
2180
+ tokenValuation = _context14.sent;
2181
+ return _context14.abrupt("return", {
2226
2182
  tokenAmount: tokenAmount,
2227
2183
  currencyAmount: {
2228
2184
  currency: 'USD',
@@ -2232,10 +2188,10 @@ function _valuateToken() {
2232
2188
 
2233
2189
  case 4:
2234
2190
  case "end":
2235
- return _context15.stop();
2191
+ return _context14.stop();
2236
2192
  }
2237
2193
  }
2238
- }, _callee15);
2194
+ }, _callee14);
2239
2195
  }));
2240
2196
  return _valuateToken.apply(this, arguments);
2241
2197
  }
@@ -2370,7 +2326,6 @@ var helpers = {
2370
2326
  fetchLPPrice: fetchLPPrice,
2371
2327
  fetchPriceFromOracle: fetchPriceFromOracle,
2372
2328
  fetchUnderlyingTokensPrices: fetchUnderlyingTokensPrices,
2373
- fetchStNEARPrice: fetchStNEARPrice,
2374
2329
  fetchPrice: fetchPrice,
2375
2330
  fetchPLYPrice: fetchPLYPrice,
2376
2331
  fetchPULPPrice: fetchPULPPrice,
@@ -5083,5 +5038,5 @@ BigNumber.config({
5083
5038
  DECIMAL_PLACES: 50
5084
5039
  });
5085
5040
 
5086
- export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, ALL_STAKING_POOLS, AURORA_CHAINID, Airdrop, AirdropRead, AirdropReadWrite, AuriEnv, BORROW_LIMIT_BUFFER, BORROW_NEAR_REWARDS_PER_WEEK, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, DEPOSIT_NEAR_REWARDS_PER_WEEK, DEPOSIT_ONLY_TOKENS, ETHAddress, HARDCODE_PRICE_TOKENS, INF, MarketAction, MiscRead, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, ONE_WEEK, ONE_YEAR, PLYToken, PLYWNEARToken, PLYWNEAR_POOL_ID, PLYWNEAR_REWARD_TOKENS, PRICE_WHITELISTED, Papermill, PapermillRead, PapermillReadWrite, REWARD_CLAIM_START, Referral, ReferralRead, ReferralReadWrite, SDK, SdkRead, SdkReadWrite, Staking, StakingRead, StakingReadWrite, Token, TokenAmount, TransferEventQuery, index as abis, assert, calcLMRewardApr, calcValuation, decimalFactor, decimalRecords, devLog, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchLPPositions, fetchLPPrice, fetchPLYPrice, fetchPULPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromOracle, fetchStNEARPrice, fetchToken0PriceByLP, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getApi, getBlockBeforeTimestamp, getBlockTimestamp, getBlocksTimestamp, getBlocksTimestampViaRPC, getCurrentTimestamp, getDecimal, getPaginatedApi, getQuery, getSymbol, getUnderlying, isSameAddress, networkAddresses, queryGraphQL, symbolRecords, validateAndParseAddress, valuateToken };
5041
+ export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, ALL_STAKING_POOLS, AURORA_CHAINID, Airdrop, AirdropRead, AirdropReadWrite, AuriEnv, BORROW_LIMIT_BUFFER, BORROW_NEAR_REWARDS_PER_WEEK, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, DEPOSIT_NEAR_REWARDS_PER_WEEK, DEPOSIT_ONLY_TOKENS, ETHAddress, HARDCODE_PRICE_TOKENS, INF, MarketAction, MiscRead, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, ONE_WEEK, ONE_YEAR, PLYToken, PLYWNEARToken, PLYWNEAR_POOL_ID, PLYWNEAR_REWARD_TOKENS, PRICE_WHITELISTED, Papermill, PapermillRead, PapermillReadWrite, REWARD_CLAIM_START, Referral, ReferralRead, ReferralReadWrite, SDK, SdkRead, SdkReadWrite, Staking, StakingRead, StakingReadWrite, Token, TokenAmount, TransferEventQuery, index as abis, assert, calcLMRewardApr, calcValuation, decimalFactor, decimalRecords, devLog, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchLPPositions, fetchLPPrice, fetchPLYPrice, fetchPULPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromOracle, fetchToken0PriceByLP, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getApi, getBlockBeforeTimestamp, getBlockTimestamp, getBlocksTimestamp, getBlocksTimestampViaRPC, getCurrentTimestamp, getDecimal, getPaginatedApi, getQuery, getSymbol, getUnderlying, isSameAddress, networkAddresses, queryGraphQL, symbolRecords, validateAndParseAddress, valuateToken };
5087
5042
  //# sourceMappingURL=sdk.esm.js.map