@aurigami/sdk 1.0.3 → 1.1.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.
- package/dist/priceFetcher.d.ts +2 -1
- package/dist/sdk.cjs.development.js +91 -27
- 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 +91 -28
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/package.json +2 -2
- package/src/MoneyMarket.ts +10 -2
- package/src/constants.ts +11 -0
- package/src/deployments/aurora_mainnet.json +4 -2
- package/src/priceFetcher.ts +16 -4
- package/src/types.ts +2 -0
package/dist/priceFetcher.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { providers, BigNumber as BN } from "ethers";
|
|
|
3
3
|
import { TokenAmount } from "./tokenAmount";
|
|
4
4
|
import { Address } from "./types";
|
|
5
5
|
export declare function fetchPriceFromCoingeckoAPI(id: string): Promise<BigNumber>;
|
|
6
|
-
export declare function fetchPriceFromCoingecko(
|
|
6
|
+
export declare function fetchPriceFromCoingecko(id: Address): Promise<BigNumber>;
|
|
7
7
|
export declare function fetchLPPositions(LPAddress: Address, provider: providers.Provider): Promise<{
|
|
8
8
|
token0: Address;
|
|
9
9
|
token1: Address;
|
|
@@ -17,6 +17,7 @@ export declare function fetchUnderlyingTokensPrices(provider: providers.Provider
|
|
|
17
17
|
auToken: string;
|
|
18
18
|
underlyingPrice: BigNumber;
|
|
19
19
|
}[]>;
|
|
20
|
+
export declare function fetchStNEARPrice(): Promise<BigNumber>;
|
|
20
21
|
export declare function fetchPrice(address: Address, provider: providers.Provider): Promise<BigNumber>;
|
|
21
22
|
export declare function fetchValuation(tokenAmount: TokenAmount, provider: providers.Provider): Promise<BigNumber>;
|
|
22
23
|
export declare function calcValuation(tokenAmount: TokenAmount, price: BigNumber): BigNumber;
|
|
@@ -943,6 +943,14 @@ var networkAddresses = {
|
|
|
943
943
|
name: "auWNEAR",
|
|
944
944
|
address: /*#__PURE__*/'0xaE4fac24dCdAE0132C6d04f564dCf059616E9423'.toLowerCase(),
|
|
945
945
|
underlying: /*#__PURE__*/'0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase()
|
|
946
|
+
}, {
|
|
947
|
+
name: "auSTNEAR",
|
|
948
|
+
address: /*#__PURE__*/"0x3195949f267702723bc614cAE037cdc8D1E94786".toLowerCase(),
|
|
949
|
+
underlying: /*#__PURE__*/'0x07f9f7f963c5cd2bbffd30ccfb964be114332e30'.toLowerCase()
|
|
950
|
+
}, {
|
|
951
|
+
name: "auAURORA",
|
|
952
|
+
address: /*#__PURE__*/"0x8888682E24dd4Df7B7Ff2B91fccB575737E433bf".toLowerCase(),
|
|
953
|
+
underlying: /*#__PURE__*/"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase()
|
|
946
954
|
}],
|
|
947
955
|
misc: {
|
|
948
956
|
COMPTROLLER: /*#__PURE__*/"0x817af6cfAF35BdC1A634d6cC94eE9e4c68369Aeb".toLowerCase(),
|
|
@@ -955,6 +963,7 @@ var networkAddresses = {
|
|
|
955
963
|
tokens: {
|
|
956
964
|
AURORA: /*#__PURE__*/"0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase(),
|
|
957
965
|
PLY: /*#__PURE__*/"0x981bD5832EAB9C8F607940E0e9faCBf8C09ee20a".toLowerCase(),
|
|
966
|
+
stNEAR: /*#__PURE__*/"0x07f9f7f963c5cd2bbffd30ccfb964be114332e30".toLowerCase(),
|
|
958
967
|
AURPLY: /*#__PURE__*/dummyAddress.toLowerCase()
|
|
959
968
|
}
|
|
960
969
|
};
|
|
@@ -2048,12 +2057,12 @@ function fetchPriceFromCoingecko(_x2) {
|
|
|
2048
2057
|
}
|
|
2049
2058
|
|
|
2050
2059
|
function _fetchPriceFromCoingecko() {
|
|
2051
|
-
_fetchPriceFromCoingecko = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(
|
|
2060
|
+
_fetchPriceFromCoingecko = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(id) {
|
|
2052
2061
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2053
2062
|
while (1) {
|
|
2054
2063
|
switch (_context2.prev = _context2.next) {
|
|
2055
2064
|
case 0:
|
|
2056
|
-
if (!isSameAddress(
|
|
2065
|
+
if (!isSameAddress(id, networkAddresses.tokens.AURORA)) {
|
|
2057
2066
|
_context2.next = 4;
|
|
2058
2067
|
break;
|
|
2059
2068
|
}
|
|
@@ -2061,7 +2070,7 @@ function _fetchPriceFromCoingecko() {
|
|
|
2061
2070
|
return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('aurora-near'));
|
|
2062
2071
|
|
|
2063
2072
|
case 4:
|
|
2064
|
-
throw Error("Unknown token " +
|
|
2073
|
+
throw Error("Unknown token " + id + " in fetchPriceFromCoingecko");
|
|
2065
2074
|
|
|
2066
2075
|
case 5:
|
|
2067
2076
|
case "end":
|
|
@@ -2239,53 +2248,105 @@ function _fetchUnderlyingTokensPrices() {
|
|
|
2239
2248
|
return _fetchUnderlyingTokensPrices.apply(this, arguments);
|
|
2240
2249
|
}
|
|
2241
2250
|
|
|
2251
|
+
function fetchStNEARPrice() {
|
|
2252
|
+
return _fetchStNEARPrice.apply(this, arguments);
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
function _fetchStNEARPrice() {
|
|
2256
|
+
_fetchStNEARPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
|
|
2257
|
+
var ratioPromise, nearPricePromise, _yield$Promise$all, ratioRes, nearPrice, ratio;
|
|
2258
|
+
|
|
2259
|
+
return runtime_1.wrap(function _callee7$(_context7) {
|
|
2260
|
+
while (1) {
|
|
2261
|
+
switch (_context7.prev = _context7.next) {
|
|
2262
|
+
case 0:
|
|
2263
|
+
ratioPromise = axios.get("https://validators.narwallets.com/metrics_json").then(function (res) {
|
|
2264
|
+
return res.data;
|
|
2265
|
+
});
|
|
2266
|
+
nearPricePromise = fetchPriceFromCoingeckoAPI('near');
|
|
2267
|
+
_context7.next = 4;
|
|
2268
|
+
return Promise.all([ratioPromise, nearPricePromise]);
|
|
2269
|
+
|
|
2270
|
+
case 4:
|
|
2271
|
+
_yield$Promise$all = _context7.sent;
|
|
2272
|
+
ratioRes = _yield$Promise$all[0];
|
|
2273
|
+
nearPrice = _yield$Promise$all[1];
|
|
2274
|
+
ratio = new BigNumber(ratioRes.st_near_price);
|
|
2275
|
+
return _context7.abrupt("return", ratio.multipliedBy(nearPrice));
|
|
2276
|
+
|
|
2277
|
+
case 9:
|
|
2278
|
+
case "end":
|
|
2279
|
+
return _context7.stop();
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
}, _callee7);
|
|
2283
|
+
}));
|
|
2284
|
+
return _fetchStNEARPrice.apply(this, arguments);
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2242
2287
|
function fetchPrice(_x11, _x12) {
|
|
2243
2288
|
return _fetchPrice.apply(this, arguments);
|
|
2244
2289
|
}
|
|
2245
2290
|
|
|
2246
2291
|
function _fetchPrice() {
|
|
2247
|
-
_fetchPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2292
|
+
_fetchPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(address, provider) {
|
|
2248
2293
|
var matchingAuToken;
|
|
2249
|
-
return runtime_1.wrap(function
|
|
2294
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
2250
2295
|
while (1) {
|
|
2251
|
-
switch (
|
|
2296
|
+
switch (_context8.prev = _context8.next) {
|
|
2252
2297
|
case 0:
|
|
2253
2298
|
if (!( isSameAddress(address, networkAddresses.tokens.PLY))) {
|
|
2254
|
-
|
|
2299
|
+
_context8.next = 2;
|
|
2255
2300
|
break;
|
|
2256
2301
|
}
|
|
2257
2302
|
|
|
2258
|
-
return
|
|
2303
|
+
return _context8.abrupt("return", new BigNumber(0));
|
|
2259
2304
|
|
|
2260
2305
|
case 2:
|
|
2306
|
+
if (!isSameAddress(address, networkAddresses.tokens.stNEAR)) {
|
|
2307
|
+
_context8.next = 4;
|
|
2308
|
+
break;
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
return _context8.abrupt("return", fetchStNEARPrice());
|
|
2312
|
+
|
|
2313
|
+
case 4:
|
|
2314
|
+
if (!isSameAddress(address, networkAddresses.tokens.AURORA)) {
|
|
2315
|
+
_context8.next = 6;
|
|
2316
|
+
break;
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
return _context8.abrupt("return", fetchPriceFromCoingecko(address));
|
|
2320
|
+
|
|
2321
|
+
case 6:
|
|
2261
2322
|
matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
|
|
2262
2323
|
return isSameAddress(auToken.underlying, address);
|
|
2263
2324
|
});
|
|
2264
2325
|
|
|
2265
2326
|
if (!(matchingAuToken !== undefined)) {
|
|
2266
|
-
|
|
2327
|
+
_context8.next = 11;
|
|
2267
2328
|
break;
|
|
2268
2329
|
}
|
|
2269
2330
|
|
|
2270
|
-
return
|
|
2331
|
+
return _context8.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
|
|
2271
2332
|
|
|
2272
|
-
case
|
|
2333
|
+
case 11:
|
|
2273
2334
|
if (!isSameAddress(address, networkAddresses.tokens.AUPLYLP)) {
|
|
2274
|
-
|
|
2335
|
+
_context8.next = 15;
|
|
2275
2336
|
break;
|
|
2276
2337
|
}
|
|
2277
2338
|
|
|
2278
|
-
return
|
|
2339
|
+
return _context8.abrupt("return", fetchLPPrice(address, provider));
|
|
2279
2340
|
|
|
2280
|
-
case
|
|
2281
|
-
return
|
|
2341
|
+
case 15:
|
|
2342
|
+
return _context8.abrupt("return", fetchPriceFromCoingecko(address));
|
|
2282
2343
|
|
|
2283
|
-
case
|
|
2344
|
+
case 16:
|
|
2284
2345
|
case "end":
|
|
2285
|
-
return
|
|
2346
|
+
return _context8.stop();
|
|
2286
2347
|
}
|
|
2287
2348
|
}
|
|
2288
|
-
},
|
|
2349
|
+
}, _callee8);
|
|
2289
2350
|
}));
|
|
2290
2351
|
return _fetchPrice.apply(this, arguments);
|
|
2291
2352
|
}
|
|
@@ -2295,25 +2356,25 @@ function fetchValuation(_x13, _x14) {
|
|
|
2295
2356
|
}
|
|
2296
2357
|
|
|
2297
2358
|
function _fetchValuation() {
|
|
2298
|
-
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2359
|
+
_fetchValuation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(tokenAmount, provider) {
|
|
2299
2360
|
var price;
|
|
2300
|
-
return runtime_1.wrap(function
|
|
2361
|
+
return runtime_1.wrap(function _callee9$(_context9) {
|
|
2301
2362
|
while (1) {
|
|
2302
|
-
switch (
|
|
2363
|
+
switch (_context9.prev = _context9.next) {
|
|
2303
2364
|
case 0:
|
|
2304
|
-
|
|
2365
|
+
_context9.next = 2;
|
|
2305
2366
|
return fetchPrice(tokenAmount.token.address, provider);
|
|
2306
2367
|
|
|
2307
2368
|
case 2:
|
|
2308
|
-
price =
|
|
2309
|
-
return
|
|
2369
|
+
price = _context9.sent;
|
|
2370
|
+
return _context9.abrupt("return", calcValuation(tokenAmount, price));
|
|
2310
2371
|
|
|
2311
2372
|
case 4:
|
|
2312
2373
|
case "end":
|
|
2313
|
-
return
|
|
2374
|
+
return _context9.stop();
|
|
2314
2375
|
}
|
|
2315
2376
|
}
|
|
2316
|
-
},
|
|
2377
|
+
}, _callee9);
|
|
2317
2378
|
}));
|
|
2318
2379
|
return _fetchValuation.apply(this, arguments);
|
|
2319
2380
|
}
|
|
@@ -2651,7 +2712,9 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2651
2712
|
depositPlyApy: depositPlyApy.toNumber(),
|
|
2652
2713
|
borrowApy: borrowAPY,
|
|
2653
2714
|
borrowPlyApy: borrowPlyApy.toNumber(),
|
|
2654
|
-
collateralRatio: collateralRatio
|
|
2715
|
+
collateralRatio: collateralRatio,
|
|
2716
|
+
depositPlyPerWeek: new TokenAmount(PLYToken, rewardSpeeds.plyRewardSupplySpeed.mul(ONE_DAY).mul(7).toString()),
|
|
2717
|
+
BorrowPlyPerWeek: new TokenAmount(PLYToken, rewardSpeeds.plyRewardBorrowSpeed.mul(ONE_DAY).mul(7).toString())
|
|
2655
2718
|
});
|
|
2656
2719
|
|
|
2657
2720
|
case 14:
|
|
@@ -3488,6 +3551,7 @@ exports.fetchPrice = fetchPrice;
|
|
|
3488
3551
|
exports.fetchPriceFromCoingecko = fetchPriceFromCoingecko;
|
|
3489
3552
|
exports.fetchPriceFromCoingeckoAPI = fetchPriceFromCoingeckoAPI;
|
|
3490
3553
|
exports.fetchPriceFromOracle = fetchPriceFromOracle;
|
|
3554
|
+
exports.fetchStNEARPrice = fetchStNEARPrice;
|
|
3491
3555
|
exports.fetchUnderlyingTokensPrices = fetchUnderlyingTokensPrices;
|
|
3492
3556
|
exports.fetchValuation = fetchValuation;
|
|
3493
3557
|
exports.formatObject = formatObject;
|