@aurigami/sdk 1.8.6 → 1.9.0
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.d.ts +1 -1
- package/dist/helpers/priceFetcher.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/sdk.cjs.development.js +149 -85
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +149 -86
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/SDK.ts +1 -1
- package/src/helpers/priceFetcher.ts +35 -3
- package/src/index.ts +1 -1
- package/src/{contracts → interactors}/MoneyMarket.ts +1 -1
- /package/dist/{contracts → interactors}/Airdrop.d.ts +0 -0
- /package/dist/{contracts → interactors}/MoneyMarket.d.ts +0 -0
- /package/dist/{contracts → interactors}/Multicall.d.ts +0 -0
- /package/dist/{contracts → interactors}/Papermill.d.ts +0 -0
- /package/dist/{contracts → interactors}/Referral.d.ts +0 -0
- /package/dist/{contracts → interactors}/Staking.d.ts +0 -0
- /package/dist/{contracts → interactors}/index.d.ts +0 -0
- /package/dist/{contracts → interactors}/misc.d.ts +0 -0
- /package/src/{contracts → interactors}/Airdrop.ts +0 -0
- /package/src/{contracts → interactors}/Multicall.ts +0 -0
- /package/src/{contracts → interactors}/Papermill.ts +0 -0
- /package/src/{contracts → interactors}/Referral.ts +0 -0
- /package/src/{contracts → interactors}/Staking.ts +0 -0
- /package/src/{contracts → interactors}/index.ts +0 -0
- /package/src/{contracts → interactors}/misc.ts +0 -0
package/dist/sdk.esm.js
CHANGED
|
@@ -1807,12 +1807,17 @@ function _fetchPriceFromCoingeckoAPI() {
|
|
|
1807
1807
|
case 0:
|
|
1808
1808
|
_context.next = 2;
|
|
1809
1809
|
return axios.get("https://api.coingecko.com/api/v3/simple/price?ids=" + id + "&vs_currencies=usd").then(function (res) {
|
|
1810
|
-
return res.data;
|
|
1810
|
+
return res.data[id];
|
|
1811
|
+
})["catch"](function (err) {
|
|
1812
|
+
console.log("Unable to fetch price from Coingecko API for " + id);
|
|
1813
|
+
return {
|
|
1814
|
+
usd: 0
|
|
1815
|
+
};
|
|
1811
1816
|
});
|
|
1812
1817
|
|
|
1813
1818
|
case 2:
|
|
1814
1819
|
price = _context.sent;
|
|
1815
|
-
return _context.abrupt("return", new BigNumber(price
|
|
1820
|
+
return _context.abrupt("return", new BigNumber(price.usd));
|
|
1816
1821
|
|
|
1817
1822
|
case 4:
|
|
1818
1823
|
case "end":
|
|
@@ -1997,6 +2002,42 @@ function _fetchLPPrice() {
|
|
|
1997
2002
|
return _fetchLPPrice.apply(this, arguments);
|
|
1998
2003
|
}
|
|
1999
2004
|
|
|
2005
|
+
function fetchStNEARPrice() {
|
|
2006
|
+
return _fetchStNEARPrice.apply(this, arguments);
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
function _fetchStNEARPrice() {
|
|
2010
|
+
_fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6() {
|
|
2011
|
+
var ratioPromise, nearPricePromise, _yield$Promise$all, ratioRes, nearPrice, ratio;
|
|
2012
|
+
|
|
2013
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2014
|
+
while (1) {
|
|
2015
|
+
switch (_context6.prev = _context6.next) {
|
|
2016
|
+
case 0:
|
|
2017
|
+
ratioPromise = axios.get('https://validators.narwallets.com/metrics_json').then(function (res) {
|
|
2018
|
+
return res.data;
|
|
2019
|
+
});
|
|
2020
|
+
nearPricePromise = fetchPriceFromCoingeckoAPI('near');
|
|
2021
|
+
_context6.next = 4;
|
|
2022
|
+
return Promise.all([ratioPromise, nearPricePromise]);
|
|
2023
|
+
|
|
2024
|
+
case 4:
|
|
2025
|
+
_yield$Promise$all = _context6.sent;
|
|
2026
|
+
ratioRes = _yield$Promise$all[0];
|
|
2027
|
+
nearPrice = _yield$Promise$all[1];
|
|
2028
|
+
ratio = new BigNumber(ratioRes.st_near_price);
|
|
2029
|
+
return _context6.abrupt("return", ratio.multipliedBy(nearPrice));
|
|
2030
|
+
|
|
2031
|
+
case 9:
|
|
2032
|
+
case "end":
|
|
2033
|
+
return _context6.stop();
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
}, _callee6);
|
|
2037
|
+
}));
|
|
2038
|
+
return _fetchStNEARPrice.apply(this, arguments);
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2000
2041
|
function processPriceFromOracle(rawPrice, underlyingDecimal) {
|
|
2001
2042
|
return new BigNumber(rawPrice.toString()).div(decimalFactor(36 - underlyingDecimal));
|
|
2002
2043
|
}
|
|
@@ -2006,26 +2047,47 @@ function fetchPriceFromOracle(_x7, _x8, _x9) {
|
|
|
2006
2047
|
}
|
|
2007
2048
|
|
|
2008
2049
|
function _fetchPriceFromOracle() {
|
|
2009
|
-
_fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2010
|
-
var oracleContract, rawPrice;
|
|
2011
|
-
return runtime_1.wrap(function
|
|
2050
|
+
_fetchPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(auTokenAddress, underlyingDecimal, provider) {
|
|
2051
|
+
var oracleContract, rawPrice, matchingAuToken;
|
|
2052
|
+
return runtime_1.wrap(function _callee7$(_context7) {
|
|
2012
2053
|
while (1) {
|
|
2013
|
-
switch (
|
|
2054
|
+
switch (_context7.prev = _context7.next) {
|
|
2014
2055
|
case 0:
|
|
2015
2056
|
oracleContract = new Contract(networkAddresses.misc.oracle, AuriOracleABI.abi, provider);
|
|
2016
|
-
|
|
2017
|
-
return oracleContract.getUnderlyingPrice(auTokenAddress)
|
|
2057
|
+
_context7.next = 3;
|
|
2058
|
+
return oracleContract.getUnderlyingPrice(auTokenAddress)["catch"](function (e) {
|
|
2059
|
+
console.log("Unable to fetch price from oracle for " + auTokenAddress);
|
|
2060
|
+
return BigNumber$1.from(0);
|
|
2061
|
+
});
|
|
2018
2062
|
|
|
2019
2063
|
case 3:
|
|
2020
|
-
rawPrice =
|
|
2021
|
-
return _context6.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
|
|
2064
|
+
rawPrice = _context7.sent;
|
|
2022
2065
|
|
|
2023
|
-
|
|
2066
|
+
if (!rawPrice.isZero()) {
|
|
2067
|
+
_context7.next = 8;
|
|
2068
|
+
break;
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
|
|
2072
|
+
return isSameAddress(auToken.address, auTokenAddress);
|
|
2073
|
+
});
|
|
2074
|
+
|
|
2075
|
+
if (!((matchingAuToken == null ? void 0 : matchingAuToken.name) == 'auSTNEAR')) {
|
|
2076
|
+
_context7.next = 8;
|
|
2077
|
+
break;
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
return _context7.abrupt("return", fetchStNEARPrice());
|
|
2081
|
+
|
|
2082
|
+
case 8:
|
|
2083
|
+
return _context7.abrupt("return", processPriceFromOracle(rawPrice, underlyingDecimal));
|
|
2084
|
+
|
|
2085
|
+
case 9:
|
|
2024
2086
|
case "end":
|
|
2025
|
-
return
|
|
2087
|
+
return _context7.stop();
|
|
2026
2088
|
}
|
|
2027
2089
|
}
|
|
2028
|
-
},
|
|
2090
|
+
}, _callee7);
|
|
2029
2091
|
}));
|
|
2030
2092
|
return _fetchPriceFromOracle.apply(this, arguments);
|
|
2031
2093
|
}
|
|
@@ -2035,11 +2097,11 @@ function fetchUnderlyingTokensPrices(_x10) {
|
|
|
2035
2097
|
}
|
|
2036
2098
|
|
|
2037
2099
|
function _fetchUnderlyingTokensPrices() {
|
|
2038
|
-
_fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2100
|
+
_fetchUnderlyingTokensPrices = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(provider) {
|
|
2039
2101
|
var auriLens, auTokenAddresses, underlyingDecimals, rawPrices;
|
|
2040
|
-
return runtime_1.wrap(function
|
|
2102
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
2041
2103
|
while (1) {
|
|
2042
|
-
switch (
|
|
2104
|
+
switch (_context8.prev = _context8.next) {
|
|
2043
2105
|
case 0:
|
|
2044
2106
|
auriLens = new Contract(networkAddresses.misc.AURILENS, abis$3.abi, provider);
|
|
2045
2107
|
auTokenAddresses = networkAddresses.auTokens.map(function (auToken) {
|
|
@@ -2048,12 +2110,12 @@ function _fetchUnderlyingTokensPrices() {
|
|
|
2048
2110
|
underlyingDecimals = networkAddresses.auTokens.map(function (auToken) {
|
|
2049
2111
|
return getDecimal(auToken.underlying);
|
|
2050
2112
|
});
|
|
2051
|
-
|
|
2113
|
+
_context8.next = 5;
|
|
2052
2114
|
return auriLens.auTokenUnderlyingPriceAll(auTokenAddresses);
|
|
2053
2115
|
|
|
2054
2116
|
case 5:
|
|
2055
|
-
rawPrices =
|
|
2056
|
-
return
|
|
2117
|
+
rawPrices = _context8.sent;
|
|
2118
|
+
return _context8.abrupt("return", rawPrices.map(function (res, ind) {
|
|
2057
2119
|
return {
|
|
2058
2120
|
auToken: res.auToken,
|
|
2059
2121
|
underlyingPrice: processPriceFromOracle(res.underlyingPrice, underlyingDecimals[ind])
|
|
@@ -2062,10 +2124,10 @@ function _fetchUnderlyingTokensPrices() {
|
|
|
2062
2124
|
|
|
2063
2125
|
case 7:
|
|
2064
2126
|
case "end":
|
|
2065
|
-
return
|
|
2127
|
+
return _context8.stop();
|
|
2066
2128
|
}
|
|
2067
2129
|
}
|
|
2068
|
-
},
|
|
2130
|
+
}, _callee8);
|
|
2069
2131
|
}));
|
|
2070
2132
|
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
2071
2133
|
}
|
|
@@ -2084,20 +2146,20 @@ function _fetchPrice(_x11, _x12) {
|
|
|
2084
2146
|
}
|
|
2085
2147
|
|
|
2086
2148
|
function _fetchPrice2() {
|
|
2087
|
-
_fetchPrice2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2149
|
+
_fetchPrice2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(address, provider) {
|
|
2088
2150
|
var matchingAuToken;
|
|
2089
|
-
return runtime_1.wrap(function
|
|
2151
|
+
return runtime_1.wrap(function _callee9$(_context9) {
|
|
2090
2152
|
while (1) {
|
|
2091
|
-
switch (
|
|
2153
|
+
switch (_context9.prev = _context9.next) {
|
|
2092
2154
|
case 0:
|
|
2093
2155
|
assert(PRICE_WHITELISTED.has(address.toLocaleLowerCase()), "Address " + address + " is not whitelisted for price fetching");
|
|
2094
2156
|
|
|
2095
2157
|
if (!shouldFetchFromCoingecko(address)) {
|
|
2096
|
-
|
|
2158
|
+
_context9.next = 3;
|
|
2097
2159
|
break;
|
|
2098
2160
|
}
|
|
2099
2161
|
|
|
2100
|
-
return
|
|
2162
|
+
return _context9.abrupt("return", fetchPriceFromCoingecko(address));
|
|
2101
2163
|
|
|
2102
2164
|
case 3:
|
|
2103
2165
|
matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
|
|
@@ -2105,21 +2167,21 @@ function _fetchPrice2() {
|
|
|
2105
2167
|
});
|
|
2106
2168
|
|
|
2107
2169
|
if (!(matchingAuToken !== undefined)) {
|
|
2108
|
-
|
|
2170
|
+
_context9.next = 8;
|
|
2109
2171
|
break;
|
|
2110
2172
|
}
|
|
2111
2173
|
|
|
2112
|
-
return
|
|
2174
|
+
return _context9.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
|
|
2113
2175
|
|
|
2114
2176
|
case 8:
|
|
2115
2177
|
throw Error("Unable to fetch price for " + address);
|
|
2116
2178
|
|
|
2117
2179
|
case 9:
|
|
2118
2180
|
case "end":
|
|
2119
|
-
return
|
|
2181
|
+
return _context9.stop();
|
|
2120
2182
|
}
|
|
2121
2183
|
}
|
|
2122
|
-
},
|
|
2184
|
+
}, _callee9);
|
|
2123
2185
|
}));
|
|
2124
2186
|
return _fetchPrice2.apply(this, arguments);
|
|
2125
2187
|
}
|
|
@@ -2129,51 +2191,51 @@ function fetchPrice(_x13, _x14) {
|
|
|
2129
2191
|
}
|
|
2130
2192
|
|
|
2131
2193
|
function _fetchPrice3() {
|
|
2132
|
-
_fetchPrice3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2133
|
-
return runtime_1.wrap(function
|
|
2194
|
+
_fetchPrice3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(address, provider) {
|
|
2195
|
+
return runtime_1.wrap(function _callee10$(_context10) {
|
|
2134
2196
|
while (1) {
|
|
2135
|
-
switch (
|
|
2197
|
+
switch (_context10.prev = _context10.next) {
|
|
2136
2198
|
case 0:
|
|
2137
2199
|
if (!(address.toLowerCase() in HARDCODE_PRICE_TOKENS)) {
|
|
2138
|
-
|
|
2200
|
+
_context10.next = 4;
|
|
2139
2201
|
break;
|
|
2140
2202
|
}
|
|
2141
2203
|
|
|
2142
|
-
return
|
|
2204
|
+
return _context10.abrupt("return", new BigNumber(HARDCODE_PRICE_TOKENS[address.toLowerCase()]));
|
|
2143
2205
|
|
|
2144
2206
|
case 4:
|
|
2145
2207
|
if (!isSameAddress(address, networkAddresses.tokens.PLYWNEAR)) {
|
|
2146
|
-
|
|
2208
|
+
_context10.next = 8;
|
|
2147
2209
|
break;
|
|
2148
2210
|
}
|
|
2149
2211
|
|
|
2150
|
-
return
|
|
2212
|
+
return _context10.abrupt("return", fetchLPPrice(address, provider));
|
|
2151
2213
|
|
|
2152
2214
|
case 8:
|
|
2153
2215
|
if (!isSameAddress(address, networkAddresses.tokens.PLY)) {
|
|
2154
|
-
|
|
2216
|
+
_context10.next = 12;
|
|
2155
2217
|
break;
|
|
2156
2218
|
}
|
|
2157
2219
|
|
|
2158
|
-
return
|
|
2220
|
+
return _context10.abrupt("return", fetchPLYPrice(provider));
|
|
2159
2221
|
|
|
2160
2222
|
case 12:
|
|
2161
2223
|
if (!isSameAddress(address, networkAddresses.tokens.PULP)) {
|
|
2162
|
-
|
|
2224
|
+
_context10.next = 14;
|
|
2163
2225
|
break;
|
|
2164
2226
|
}
|
|
2165
2227
|
|
|
2166
|
-
return
|
|
2228
|
+
return _context10.abrupt("return", fetchPULPPrice(provider));
|
|
2167
2229
|
|
|
2168
2230
|
case 14:
|
|
2169
|
-
return
|
|
2231
|
+
return _context10.abrupt("return", _fetchPrice(address, provider));
|
|
2170
2232
|
|
|
2171
2233
|
case 15:
|
|
2172
2234
|
case "end":
|
|
2173
|
-
return
|
|
2235
|
+
return _context10.stop();
|
|
2174
2236
|
}
|
|
2175
2237
|
}
|
|
2176
|
-
},
|
|
2238
|
+
}, _callee10);
|
|
2177
2239
|
}));
|
|
2178
2240
|
return _fetchPrice3.apply(this, arguments);
|
|
2179
2241
|
}
|
|
@@ -2183,19 +2245,19 @@ function fetchPLYPrice(_x15) {
|
|
|
2183
2245
|
}
|
|
2184
2246
|
|
|
2185
2247
|
function _fetchPLYPrice() {
|
|
2186
|
-
_fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2187
|
-
return runtime_1.wrap(function
|
|
2248
|
+
_fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(provider) {
|
|
2249
|
+
return runtime_1.wrap(function _callee11$(_context11) {
|
|
2188
2250
|
while (1) {
|
|
2189
|
-
switch (
|
|
2251
|
+
switch (_context11.prev = _context11.next) {
|
|
2190
2252
|
case 0:
|
|
2191
|
-
return
|
|
2253
|
+
return _context11.abrupt("return", fetchToken0PriceByLP(networkAddresses.tokens.PLYWNEAR, provider));
|
|
2192
2254
|
|
|
2193
2255
|
case 1:
|
|
2194
2256
|
case "end":
|
|
2195
|
-
return
|
|
2257
|
+
return _context11.stop();
|
|
2196
2258
|
}
|
|
2197
2259
|
}
|
|
2198
|
-
},
|
|
2260
|
+
}, _callee11);
|
|
2199
2261
|
}));
|
|
2200
2262
|
return _fetchPLYPrice.apply(this, arguments);
|
|
2201
2263
|
}
|
|
@@ -2205,19 +2267,19 @@ function fetchPULPPrice(_x16) {
|
|
|
2205
2267
|
}
|
|
2206
2268
|
|
|
2207
2269
|
function _fetchPULPPrice() {
|
|
2208
|
-
_fetchPULPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2209
|
-
return runtime_1.wrap(function
|
|
2270
|
+
_fetchPULPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(provider) {
|
|
2271
|
+
return runtime_1.wrap(function _callee12$(_context12) {
|
|
2210
2272
|
while (1) {
|
|
2211
|
-
switch (
|
|
2273
|
+
switch (_context12.prev = _context12.next) {
|
|
2212
2274
|
case 0:
|
|
2213
|
-
return
|
|
2275
|
+
return _context12.abrupt("return", new BigNumber(0));
|
|
2214
2276
|
|
|
2215
2277
|
case 1:
|
|
2216
2278
|
case "end":
|
|
2217
|
-
return
|
|
2279
|
+
return _context12.stop();
|
|
2218
2280
|
}
|
|
2219
2281
|
}
|
|
2220
|
-
},
|
|
2282
|
+
}, _callee12);
|
|
2221
2283
|
}));
|
|
2222
2284
|
return _fetchPULPPrice.apply(this, arguments);
|
|
2223
2285
|
}
|
|
@@ -2227,42 +2289,42 @@ function fetchToken0PriceByLP(_x17, _x18) {
|
|
|
2227
2289
|
}
|
|
2228
2290
|
|
|
2229
2291
|
function _fetchToken0PriceByLP() {
|
|
2230
|
-
_fetchToken0PriceByLP = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2292
|
+
_fetchToken0PriceByLP = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(LP, provider) {
|
|
2231
2293
|
var LPInfo, token0Decimal, token1Decimal;
|
|
2232
|
-
return runtime_1.wrap(function
|
|
2294
|
+
return runtime_1.wrap(function _callee13$(_context13) {
|
|
2233
2295
|
while (1) {
|
|
2234
|
-
switch (
|
|
2296
|
+
switch (_context13.prev = _context13.next) {
|
|
2235
2297
|
case 0:
|
|
2236
|
-
|
|
2298
|
+
_context13.next = 2;
|
|
2237
2299
|
return fetchLPPositions(LP, provider);
|
|
2238
2300
|
|
|
2239
2301
|
case 2:
|
|
2240
|
-
LPInfo =
|
|
2302
|
+
LPInfo = _context13.sent;
|
|
2241
2303
|
|
|
2242
2304
|
if (!LPInfo.reserve1.isZero()) {
|
|
2243
|
-
|
|
2305
|
+
_context13.next = 5;
|
|
2244
2306
|
break;
|
|
2245
2307
|
}
|
|
2246
2308
|
|
|
2247
|
-
return
|
|
2309
|
+
return _context13.abrupt("return", new BigNumber(0));
|
|
2248
2310
|
|
|
2249
2311
|
case 5:
|
|
2250
2312
|
token0Decimal = getDecimal(LPInfo.token0);
|
|
2251
2313
|
token1Decimal = getDecimal(LPInfo.token1); // (token0Price * reserve0) / 10^decimal0 = (token1Price * reserve1) / 10^decimal1
|
|
2252
2314
|
// token0Price = (token1Price * reserve1) * 10^decimal0 / 10^decimal1 / reserve0
|
|
2253
2315
|
|
|
2254
|
-
|
|
2316
|
+
_context13.next = 9;
|
|
2255
2317
|
return fetchPrice(LPInfo.token1, provider);
|
|
2256
2318
|
|
|
2257
2319
|
case 9:
|
|
2258
|
-
return
|
|
2320
|
+
return _context13.abrupt("return", _context13.sent.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(decimalFactor(token0Decimal)).dividedBy(decimalFactor(token1Decimal)).dividedBy(LPInfo.reserve0.toString()));
|
|
2259
2321
|
|
|
2260
2322
|
case 10:
|
|
2261
2323
|
case "end":
|
|
2262
|
-
return
|
|
2324
|
+
return _context13.stop();
|
|
2263
2325
|
}
|
|
2264
2326
|
}
|
|
2265
|
-
},
|
|
2327
|
+
}, _callee13);
|
|
2266
2328
|
}));
|
|
2267
2329
|
return _fetchToken0PriceByLP.apply(this, arguments);
|
|
2268
2330
|
}
|
|
@@ -2272,33 +2334,33 @@ function fetchValuation(_x19, _x20) {
|
|
|
2272
2334
|
}
|
|
2273
2335
|
|
|
2274
2336
|
function _fetchValuation() {
|
|
2275
|
-
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2337
|
+
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(tokenAmount, provider) {
|
|
2276
2338
|
var price;
|
|
2277
|
-
return runtime_1.wrap(function
|
|
2339
|
+
return runtime_1.wrap(function _callee14$(_context14) {
|
|
2278
2340
|
while (1) {
|
|
2279
|
-
switch (
|
|
2341
|
+
switch (_context14.prev = _context14.next) {
|
|
2280
2342
|
case 0:
|
|
2281
2343
|
if (!(tokenAmount.rawAmount() == '0')) {
|
|
2282
|
-
|
|
2344
|
+
_context14.next = 2;
|
|
2283
2345
|
break;
|
|
2284
2346
|
}
|
|
2285
2347
|
|
|
2286
|
-
return
|
|
2348
|
+
return _context14.abrupt("return", new BigNumber(0));
|
|
2287
2349
|
|
|
2288
2350
|
case 2:
|
|
2289
|
-
|
|
2351
|
+
_context14.next = 4;
|
|
2290
2352
|
return fetchPrice(tokenAmount.token.address, provider);
|
|
2291
2353
|
|
|
2292
2354
|
case 4:
|
|
2293
|
-
price =
|
|
2294
|
-
return
|
|
2355
|
+
price = _context14.sent;
|
|
2356
|
+
return _context14.abrupt("return", calcValuation(tokenAmount, price));
|
|
2295
2357
|
|
|
2296
2358
|
case 6:
|
|
2297
2359
|
case "end":
|
|
2298
|
-
return
|
|
2360
|
+
return _context14.stop();
|
|
2299
2361
|
}
|
|
2300
2362
|
}
|
|
2301
|
-
},
|
|
2363
|
+
}, _callee14);
|
|
2302
2364
|
}));
|
|
2303
2365
|
return _fetchValuation.apply(this, arguments);
|
|
2304
2366
|
}
|
|
@@ -2311,18 +2373,18 @@ function valuateToken(_x21, _x22) {
|
|
|
2311
2373
|
}
|
|
2312
2374
|
|
|
2313
2375
|
function _valuateToken() {
|
|
2314
|
-
_valuateToken = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2376
|
+
_valuateToken = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15(tokenAmount, provider) {
|
|
2315
2377
|
var tokenValuation;
|
|
2316
|
-
return runtime_1.wrap(function
|
|
2378
|
+
return runtime_1.wrap(function _callee15$(_context15) {
|
|
2317
2379
|
while (1) {
|
|
2318
|
-
switch (
|
|
2380
|
+
switch (_context15.prev = _context15.next) {
|
|
2319
2381
|
case 0:
|
|
2320
|
-
|
|
2382
|
+
_context15.next = 2;
|
|
2321
2383
|
return fetchValuation(tokenAmount, provider);
|
|
2322
2384
|
|
|
2323
2385
|
case 2:
|
|
2324
|
-
tokenValuation =
|
|
2325
|
-
return
|
|
2386
|
+
tokenValuation = _context15.sent;
|
|
2387
|
+
return _context15.abrupt("return", {
|
|
2326
2388
|
tokenAmount: tokenAmount,
|
|
2327
2389
|
currencyAmount: {
|
|
2328
2390
|
currency: 'USD',
|
|
@@ -2332,10 +2394,10 @@ function _valuateToken() {
|
|
|
2332
2394
|
|
|
2333
2395
|
case 4:
|
|
2334
2396
|
case "end":
|
|
2335
|
-
return
|
|
2397
|
+
return _context15.stop();
|
|
2336
2398
|
}
|
|
2337
2399
|
}
|
|
2338
|
-
},
|
|
2400
|
+
}, _callee15);
|
|
2339
2401
|
}));
|
|
2340
2402
|
return _valuateToken.apply(this, arguments);
|
|
2341
2403
|
}
|
|
@@ -2468,6 +2530,7 @@ var helpers = {
|
|
|
2468
2530
|
fetchPriceFromCoingecko: fetchPriceFromCoingecko,
|
|
2469
2531
|
fetchLPPositions: fetchLPPositions,
|
|
2470
2532
|
fetchLPPrice: fetchLPPrice,
|
|
2533
|
+
fetchStNEARPrice: fetchStNEARPrice,
|
|
2471
2534
|
fetchPriceFromOracle: fetchPriceFromOracle,
|
|
2472
2535
|
fetchUnderlyingTokensPrices: fetchUnderlyingTokensPrices,
|
|
2473
2536
|
fetchPrice: fetchPrice,
|
|
@@ -5310,5 +5373,5 @@ BigNumber.config({
|
|
|
5310
5373
|
DECIMAL_PLACES: 50
|
|
5311
5374
|
});
|
|
5312
5375
|
|
|
5313
|
-
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, REFERRAL_CAMPAIGNS, 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, referralRewardDummy1, referralRewardDummy2, symbolRecords, validateAndParseAddress, valuateToken };
|
|
5376
|
+
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, REFERRAL_CAMPAIGNS, 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, referralRewardDummy1, referralRewardDummy2, symbolRecords, validateAndParseAddress, valuateToken };
|
|
5314
5377
|
//# sourceMappingURL=sdk.esm.js.map
|