@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/helpers/priceFetcher.d.ts +0 -1
- package/dist/sdk.cjs.development.js +67 -113
- 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 +68 -113
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/priceFetcher.ts +0 -14
|
@@ -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>;
|
|
@@ -1931,42 +1931,6 @@ function _fetchUnderlyingTokensPrices() {
|
|
|
1931
1931
|
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
1932
1932
|
}
|
|
1933
1933
|
|
|
1934
|
-
function fetchStNEARPrice() {
|
|
1935
|
-
return _fetchStNEARPrice.apply(this, arguments);
|
|
1936
|
-
}
|
|
1937
|
-
|
|
1938
|
-
function _fetchStNEARPrice() {
|
|
1939
|
-
_fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
|
|
1940
|
-
var ratioPromise, nearPricePromise, _yield$Promise$all, ratioRes, nearPrice, ratio;
|
|
1941
|
-
|
|
1942
|
-
return runtime_1.wrap(function _callee8$(_context8) {
|
|
1943
|
-
while (1) {
|
|
1944
|
-
switch (_context8.prev = _context8.next) {
|
|
1945
|
-
case 0:
|
|
1946
|
-
ratioPromise = axios.get('https://validators.narwallets.com/metrics_json').then(function (res) {
|
|
1947
|
-
return res.data;
|
|
1948
|
-
});
|
|
1949
|
-
nearPricePromise = fetchPriceFromCoingeckoAPI('near');
|
|
1950
|
-
_context8.next = 4;
|
|
1951
|
-
return Promise.all([ratioPromise, nearPricePromise]);
|
|
1952
|
-
|
|
1953
|
-
case 4:
|
|
1954
|
-
_yield$Promise$all = _context8.sent;
|
|
1955
|
-
ratioRes = _yield$Promise$all[0];
|
|
1956
|
-
nearPrice = _yield$Promise$all[1];
|
|
1957
|
-
ratio = new BigNumber(ratioRes.st_near_price);
|
|
1958
|
-
return _context8.abrupt("return", ratio.multipliedBy(nearPrice));
|
|
1959
|
-
|
|
1960
|
-
case 9:
|
|
1961
|
-
case "end":
|
|
1962
|
-
return _context8.stop();
|
|
1963
|
-
}
|
|
1964
|
-
}
|
|
1965
|
-
}, _callee8);
|
|
1966
|
-
}));
|
|
1967
|
-
return _fetchStNEARPrice.apply(this, arguments);
|
|
1968
|
-
}
|
|
1969
|
-
|
|
1970
1934
|
function shouldFetchFromCoingecko(address) {
|
|
1971
1935
|
address = address.toLowerCase();
|
|
1972
1936
|
return address == networkAddresses.tokens.AURORA || address == networkAddresses.tokens.TRI || address == networkAddresses.tokens.META;
|
|
@@ -1981,50 +1945,42 @@ function _fetchPrice(_x11, _x12) {
|
|
|
1981
1945
|
}
|
|
1982
1946
|
|
|
1983
1947
|
function _fetchPrice2() {
|
|
1984
|
-
_fetchPrice2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1948
|
+
_fetchPrice2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(address, provider) {
|
|
1985
1949
|
var matchingAuToken;
|
|
1986
|
-
return runtime_1.wrap(function
|
|
1950
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
1987
1951
|
while (1) {
|
|
1988
|
-
switch (
|
|
1952
|
+
switch (_context8.prev = _context8.next) {
|
|
1989
1953
|
case 0:
|
|
1990
1954
|
assert(PRICE_WHITELISTED.has(address.toLocaleLowerCase()), "Address " + address + " is not whitelisted for price fetching");
|
|
1991
1955
|
|
|
1992
|
-
if (!isSameAddress(address, networkAddresses.tokens.stNEAR)) {
|
|
1993
|
-
_context9.next = 3;
|
|
1994
|
-
break;
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
|
-
return _context9.abrupt("return", fetchStNEARPrice());
|
|
1998
|
-
|
|
1999
|
-
case 3:
|
|
2000
1956
|
if (!shouldFetchFromCoingecko(address)) {
|
|
2001
|
-
|
|
1957
|
+
_context8.next = 3;
|
|
2002
1958
|
break;
|
|
2003
1959
|
}
|
|
2004
1960
|
|
|
2005
|
-
return
|
|
1961
|
+
return _context8.abrupt("return", fetchPriceFromCoingecko(address));
|
|
2006
1962
|
|
|
2007
|
-
case
|
|
1963
|
+
case 3:
|
|
2008
1964
|
matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
|
|
2009
1965
|
return isSameAddress(auToken.underlying, address);
|
|
2010
1966
|
});
|
|
2011
1967
|
|
|
2012
1968
|
if (!(matchingAuToken !== undefined)) {
|
|
2013
|
-
|
|
1969
|
+
_context8.next = 8;
|
|
2014
1970
|
break;
|
|
2015
1971
|
}
|
|
2016
1972
|
|
|
2017
|
-
return
|
|
1973
|
+
return _context8.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
|
|
2018
1974
|
|
|
2019
|
-
case
|
|
1975
|
+
case 8:
|
|
2020
1976
|
throw Error("Unable to fetch price for " + address);
|
|
2021
1977
|
|
|
2022
|
-
case
|
|
1978
|
+
case 9:
|
|
2023
1979
|
case "end":
|
|
2024
|
-
return
|
|
1980
|
+
return _context8.stop();
|
|
2025
1981
|
}
|
|
2026
1982
|
}
|
|
2027
|
-
},
|
|
1983
|
+
}, _callee8);
|
|
2028
1984
|
}));
|
|
2029
1985
|
return _fetchPrice2.apply(this, arguments);
|
|
2030
1986
|
}
|
|
@@ -2034,51 +1990,51 @@ function fetchPrice(_x13, _x14) {
|
|
|
2034
1990
|
}
|
|
2035
1991
|
|
|
2036
1992
|
function _fetchPrice3() {
|
|
2037
|
-
_fetchPrice3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2038
|
-
return runtime_1.wrap(function
|
|
1993
|
+
_fetchPrice3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(address, provider) {
|
|
1994
|
+
return runtime_1.wrap(function _callee9$(_context9) {
|
|
2039
1995
|
while (1) {
|
|
2040
|
-
switch (
|
|
1996
|
+
switch (_context9.prev = _context9.next) {
|
|
2041
1997
|
case 0:
|
|
2042
1998
|
if (!(address.toLowerCase() in HARDCODE_PRICE_TOKENS)) {
|
|
2043
|
-
|
|
1999
|
+
_context9.next = 4;
|
|
2044
2000
|
break;
|
|
2045
2001
|
}
|
|
2046
2002
|
|
|
2047
|
-
return
|
|
2003
|
+
return _context9.abrupt("return", new BigNumber(HARDCODE_PRICE_TOKENS[address.toLowerCase()]));
|
|
2048
2004
|
|
|
2049
2005
|
case 4:
|
|
2050
2006
|
if (!isSameAddress(address, networkAddresses.tokens.PLYWNEAR)) {
|
|
2051
|
-
|
|
2007
|
+
_context9.next = 8;
|
|
2052
2008
|
break;
|
|
2053
2009
|
}
|
|
2054
2010
|
|
|
2055
|
-
return
|
|
2011
|
+
return _context9.abrupt("return", fetchLPPrice(address, provider));
|
|
2056
2012
|
|
|
2057
2013
|
case 8:
|
|
2058
2014
|
if (!isSameAddress(address, networkAddresses.tokens.PLY)) {
|
|
2059
|
-
|
|
2015
|
+
_context9.next = 12;
|
|
2060
2016
|
break;
|
|
2061
2017
|
}
|
|
2062
2018
|
|
|
2063
|
-
return
|
|
2019
|
+
return _context9.abrupt("return", fetchPLYPrice(provider));
|
|
2064
2020
|
|
|
2065
2021
|
case 12:
|
|
2066
2022
|
if (!isSameAddress(address, networkAddresses.tokens.PULP)) {
|
|
2067
|
-
|
|
2023
|
+
_context9.next = 14;
|
|
2068
2024
|
break;
|
|
2069
2025
|
}
|
|
2070
2026
|
|
|
2071
|
-
return
|
|
2027
|
+
return _context9.abrupt("return", fetchPULPPrice(provider));
|
|
2072
2028
|
|
|
2073
2029
|
case 14:
|
|
2074
|
-
return
|
|
2030
|
+
return _context9.abrupt("return", _fetchPrice(address, provider));
|
|
2075
2031
|
|
|
2076
2032
|
case 15:
|
|
2077
2033
|
case "end":
|
|
2078
|
-
return
|
|
2034
|
+
return _context9.stop();
|
|
2079
2035
|
}
|
|
2080
2036
|
}
|
|
2081
|
-
},
|
|
2037
|
+
}, _callee9);
|
|
2082
2038
|
}));
|
|
2083
2039
|
return _fetchPrice3.apply(this, arguments);
|
|
2084
2040
|
}
|
|
@@ -2088,19 +2044,19 @@ function fetchPLYPrice(_x15) {
|
|
|
2088
2044
|
}
|
|
2089
2045
|
|
|
2090
2046
|
function _fetchPLYPrice() {
|
|
2091
|
-
_fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2092
|
-
return runtime_1.wrap(function
|
|
2047
|
+
_fetchPLYPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(provider) {
|
|
2048
|
+
return runtime_1.wrap(function _callee10$(_context10) {
|
|
2093
2049
|
while (1) {
|
|
2094
|
-
switch (
|
|
2050
|
+
switch (_context10.prev = _context10.next) {
|
|
2095
2051
|
case 0:
|
|
2096
|
-
return
|
|
2052
|
+
return _context10.abrupt("return", fetchToken0PriceByLP(networkAddresses.tokens.PLYWNEAR, provider));
|
|
2097
2053
|
|
|
2098
2054
|
case 1:
|
|
2099
2055
|
case "end":
|
|
2100
|
-
return
|
|
2056
|
+
return _context10.stop();
|
|
2101
2057
|
}
|
|
2102
2058
|
}
|
|
2103
|
-
},
|
|
2059
|
+
}, _callee10);
|
|
2104
2060
|
}));
|
|
2105
2061
|
return _fetchPLYPrice.apply(this, arguments);
|
|
2106
2062
|
}
|
|
@@ -2110,19 +2066,19 @@ function fetchPULPPrice(_x16) {
|
|
|
2110
2066
|
}
|
|
2111
2067
|
|
|
2112
2068
|
function _fetchPULPPrice() {
|
|
2113
|
-
_fetchPULPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2114
|
-
return runtime_1.wrap(function
|
|
2069
|
+
_fetchPULPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(provider) {
|
|
2070
|
+
return runtime_1.wrap(function _callee11$(_context11) {
|
|
2115
2071
|
while (1) {
|
|
2116
|
-
switch (
|
|
2072
|
+
switch (_context11.prev = _context11.next) {
|
|
2117
2073
|
case 0:
|
|
2118
|
-
return
|
|
2074
|
+
return _context11.abrupt("return", new BigNumber(0));
|
|
2119
2075
|
|
|
2120
2076
|
case 1:
|
|
2121
2077
|
case "end":
|
|
2122
|
-
return
|
|
2078
|
+
return _context11.stop();
|
|
2123
2079
|
}
|
|
2124
2080
|
}
|
|
2125
|
-
},
|
|
2081
|
+
}, _callee11);
|
|
2126
2082
|
}));
|
|
2127
2083
|
return _fetchPULPPrice.apply(this, arguments);
|
|
2128
2084
|
}
|
|
@@ -2132,42 +2088,42 @@ function fetchToken0PriceByLP(_x17, _x18) {
|
|
|
2132
2088
|
}
|
|
2133
2089
|
|
|
2134
2090
|
function _fetchToken0PriceByLP() {
|
|
2135
|
-
_fetchToken0PriceByLP = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2091
|
+
_fetchToken0PriceByLP = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12(LP, provider) {
|
|
2136
2092
|
var LPInfo, token0Decimal, token1Decimal;
|
|
2137
|
-
return runtime_1.wrap(function
|
|
2093
|
+
return runtime_1.wrap(function _callee12$(_context12) {
|
|
2138
2094
|
while (1) {
|
|
2139
|
-
switch (
|
|
2095
|
+
switch (_context12.prev = _context12.next) {
|
|
2140
2096
|
case 0:
|
|
2141
|
-
|
|
2097
|
+
_context12.next = 2;
|
|
2142
2098
|
return fetchLPPositions(LP, provider);
|
|
2143
2099
|
|
|
2144
2100
|
case 2:
|
|
2145
|
-
LPInfo =
|
|
2101
|
+
LPInfo = _context12.sent;
|
|
2146
2102
|
|
|
2147
2103
|
if (!LPInfo.reserve1.isZero()) {
|
|
2148
|
-
|
|
2104
|
+
_context12.next = 5;
|
|
2149
2105
|
break;
|
|
2150
2106
|
}
|
|
2151
2107
|
|
|
2152
|
-
return
|
|
2108
|
+
return _context12.abrupt("return", new BigNumber(0));
|
|
2153
2109
|
|
|
2154
2110
|
case 5:
|
|
2155
2111
|
token0Decimal = getDecimal(LPInfo.token0);
|
|
2156
2112
|
token1Decimal = getDecimal(LPInfo.token1); // (token0Price * reserve0) / 10^decimal0 = (token1Price * reserve1) / 10^decimal1
|
|
2157
2113
|
// token0Price = (token1Price * reserve1) * 10^decimal0 / 10^decimal1 / reserve0
|
|
2158
2114
|
|
|
2159
|
-
|
|
2115
|
+
_context12.next = 9;
|
|
2160
2116
|
return fetchPrice(LPInfo.token1, provider);
|
|
2161
2117
|
|
|
2162
2118
|
case 9:
|
|
2163
|
-
return
|
|
2119
|
+
return _context12.abrupt("return", _context12.sent.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(decimalFactor(token0Decimal)).dividedBy(decimalFactor(token1Decimal)).dividedBy(LPInfo.reserve0.toString()));
|
|
2164
2120
|
|
|
2165
2121
|
case 10:
|
|
2166
2122
|
case "end":
|
|
2167
|
-
return
|
|
2123
|
+
return _context12.stop();
|
|
2168
2124
|
}
|
|
2169
2125
|
}
|
|
2170
|
-
},
|
|
2126
|
+
}, _callee12);
|
|
2171
2127
|
}));
|
|
2172
2128
|
return _fetchToken0PriceByLP.apply(this, arguments);
|
|
2173
2129
|
}
|
|
@@ -2177,33 +2133,33 @@ function fetchValuation(_x19, _x20) {
|
|
|
2177
2133
|
}
|
|
2178
2134
|
|
|
2179
2135
|
function _fetchValuation() {
|
|
2180
|
-
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2136
|
+
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13(tokenAmount, provider) {
|
|
2181
2137
|
var price;
|
|
2182
|
-
return runtime_1.wrap(function
|
|
2138
|
+
return runtime_1.wrap(function _callee13$(_context13) {
|
|
2183
2139
|
while (1) {
|
|
2184
|
-
switch (
|
|
2140
|
+
switch (_context13.prev = _context13.next) {
|
|
2185
2141
|
case 0:
|
|
2186
2142
|
if (!(tokenAmount.rawAmount() == '0')) {
|
|
2187
|
-
|
|
2143
|
+
_context13.next = 2;
|
|
2188
2144
|
break;
|
|
2189
2145
|
}
|
|
2190
2146
|
|
|
2191
|
-
return
|
|
2147
|
+
return _context13.abrupt("return", new BigNumber(0));
|
|
2192
2148
|
|
|
2193
2149
|
case 2:
|
|
2194
|
-
|
|
2150
|
+
_context13.next = 4;
|
|
2195
2151
|
return fetchPrice(tokenAmount.token.address, provider);
|
|
2196
2152
|
|
|
2197
2153
|
case 4:
|
|
2198
|
-
price =
|
|
2199
|
-
return
|
|
2154
|
+
price = _context13.sent;
|
|
2155
|
+
return _context13.abrupt("return", calcValuation(tokenAmount, price));
|
|
2200
2156
|
|
|
2201
2157
|
case 6:
|
|
2202
2158
|
case "end":
|
|
2203
|
-
return
|
|
2159
|
+
return _context13.stop();
|
|
2204
2160
|
}
|
|
2205
2161
|
}
|
|
2206
|
-
},
|
|
2162
|
+
}, _callee13);
|
|
2207
2163
|
}));
|
|
2208
2164
|
return _fetchValuation.apply(this, arguments);
|
|
2209
2165
|
}
|
|
@@ -2216,18 +2172,18 @@ function valuateToken(_x21, _x22) {
|
|
|
2216
2172
|
}
|
|
2217
2173
|
|
|
2218
2174
|
function _valuateToken() {
|
|
2219
|
-
_valuateToken = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2175
|
+
_valuateToken = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(tokenAmount, provider) {
|
|
2220
2176
|
var tokenValuation;
|
|
2221
|
-
return runtime_1.wrap(function
|
|
2177
|
+
return runtime_1.wrap(function _callee14$(_context14) {
|
|
2222
2178
|
while (1) {
|
|
2223
|
-
switch (
|
|
2179
|
+
switch (_context14.prev = _context14.next) {
|
|
2224
2180
|
case 0:
|
|
2225
|
-
|
|
2181
|
+
_context14.next = 2;
|
|
2226
2182
|
return fetchValuation(tokenAmount, provider);
|
|
2227
2183
|
|
|
2228
2184
|
case 2:
|
|
2229
|
-
tokenValuation =
|
|
2230
|
-
return
|
|
2185
|
+
tokenValuation = _context14.sent;
|
|
2186
|
+
return _context14.abrupt("return", {
|
|
2231
2187
|
tokenAmount: tokenAmount,
|
|
2232
2188
|
currencyAmount: {
|
|
2233
2189
|
currency: 'USD',
|
|
@@ -2237,10 +2193,10 @@ function _valuateToken() {
|
|
|
2237
2193
|
|
|
2238
2194
|
case 4:
|
|
2239
2195
|
case "end":
|
|
2240
|
-
return
|
|
2196
|
+
return _context14.stop();
|
|
2241
2197
|
}
|
|
2242
2198
|
}
|
|
2243
|
-
},
|
|
2199
|
+
}, _callee14);
|
|
2244
2200
|
}));
|
|
2245
2201
|
return _valuateToken.apply(this, arguments);
|
|
2246
2202
|
}
|
|
@@ -2375,7 +2331,6 @@ var helpers = {
|
|
|
2375
2331
|
fetchLPPrice: fetchLPPrice,
|
|
2376
2332
|
fetchPriceFromOracle: fetchPriceFromOracle,
|
|
2377
2333
|
fetchUnderlyingTokensPrices: fetchUnderlyingTokensPrices,
|
|
2378
|
-
fetchStNEARPrice: fetchStNEARPrice,
|
|
2379
2334
|
fetchPrice: fetchPrice,
|
|
2380
2335
|
fetchPLYPrice: fetchPLYPrice,
|
|
2381
2336
|
fetchPULPPrice: fetchPULPPrice,
|
|
@@ -5159,7 +5114,6 @@ exports.fetchPrice = fetchPrice;
|
|
|
5159
5114
|
exports.fetchPriceFromCoingecko = fetchPriceFromCoingecko;
|
|
5160
5115
|
exports.fetchPriceFromCoingeckoAPI = fetchPriceFromCoingeckoAPI;
|
|
5161
5116
|
exports.fetchPriceFromOracle = fetchPriceFromOracle;
|
|
5162
|
-
exports.fetchStNEARPrice = fetchStNEARPrice;
|
|
5163
5117
|
exports.fetchToken0PriceByLP = fetchToken0PriceByLP;
|
|
5164
5118
|
exports.fetchUnderlyingTokensPrices = fetchUnderlyingTokensPrices;
|
|
5165
5119
|
exports.fetchValuation = fetchValuation;
|