aftermath-ts-sdk 1.1.44 → 1.1.45
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/general/prices/coingecko/coinGeckoPricesApi.d.ts +2 -2
- package/dist/general/prices/coingecko/coinGeckoPricesApi.d.ts.map +1 -1
- package/dist/general/prices/coingecko/coinGeckoPricesApi.js +30 -18
- package/dist/general/prices/router/routerPricesApi.d.ts +2 -2
- package/dist/general/prices/router/routerPricesApi.d.ts.map +1 -1
- package/dist/general/prices/router/routerPricesApi.js +11 -6
- package/package.json +1 -1
|
@@ -8,9 +8,9 @@ export declare class CoinGeckoPricesApi extends CoinGeckoApiHelpers implements P
|
|
|
8
8
|
fetchPrice: (inputs: {
|
|
9
9
|
coin: CoinType;
|
|
10
10
|
}) => Promise<number>;
|
|
11
|
-
fetchCoinsToPrice: (inputs: {
|
|
11
|
+
fetchCoinsToPrice: (...inputs: {
|
|
12
12
|
coins: CoinType[];
|
|
13
|
-
}) => Promise<{
|
|
13
|
+
}[]) => Promise<{
|
|
14
14
|
[x: string]: number;
|
|
15
15
|
}>;
|
|
16
16
|
fetchCoinsToPriceInfo: (...inputs: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coinGeckoPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/coingecko/coinGeckoPricesApi.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EAGb,QAAQ,EAGR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAA2B,MAAM,kBAAkB,CAAC;AAE/E,qBAAa,kBACZ,SAAQ,mBACR,YAAW,kBAAkB;gBAO5B,QAAQ,EAAE,YAAY,EACtB,eAAe,EAAE,MAAM,EACvB,qBAAqB,EAAE,MAAM,CAAC,kBAAkB,EAAE,QAAQ,EAAE,CAAC;IAiBvD,UAAU,WAAkB;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,KAAG,QAAQ,MAAM,CAAC,CAMrE;
|
|
1
|
+
{"version":3,"file":"coinGeckoPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/coingecko/coinGeckoPricesApi.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EAGb,QAAQ,EAGR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAA2B,MAAM,kBAAkB,CAAC;AAE/E,qBAAa,kBACZ,SAAQ,mBACR,YAAW,kBAAkB;gBAO5B,QAAQ,EAAE,YAAY,EACtB,eAAe,EAAE,MAAM,EACvB,qBAAqB,EAAE,MAAM,CAAC,kBAAkB,EAAE,QAAQ,EAAE,CAAC;IAiBvD,UAAU,WAAkB;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,KAAG,QAAQ,MAAM,CAAC,CAMrE;IAGK,iBAAiB;eAGW,QAAQ,EAAE;;;OAqD1C;IAGI,qBAAqB;eAInB,QAAQ,EAAE;mDAuEhB;IAMI,4BAA4B,WAAkB;QACpD,YAAY,EAAE,OAAO,QAAQ,EAAE,kBAAkB,CAAC,CAAC;KACnD,KAAG,QAAQ,OAAO,QAAQ,EAAE,MAAM,CAAC,CAAC,CAcnC;CACF"}
|
|
@@ -33,24 +33,36 @@ class CoinGeckoPricesApi extends coinGeckoApiHelpers_1.CoinGeckoApiHelpers {
|
|
|
33
33
|
coins: [inputs.coin],
|
|
34
34
|
}))[0];
|
|
35
35
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
36
|
+
// TODO: abstract any duplicate logic with this and price info func below
|
|
37
|
+
this.fetchCoinsToPrice = this.Provider.withCache({
|
|
38
|
+
key: "coinGeckoPricesApi.fetchCoinsToPrice",
|
|
39
|
+
expirationSeconds: 300,
|
|
40
|
+
callback: (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const { coins } = inputs;
|
|
42
|
+
// filter regular vs LP coins
|
|
43
|
+
const [lpCoins, regularCoins] = yield utils_1.Helpers.bifilterAsync(coins, (coin) => __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
return this.Provider.Pools().fetchIsLpCoinType({
|
|
45
|
+
lpCoinType: coin,
|
|
46
|
+
});
|
|
47
|
+
}));
|
|
48
|
+
const allSuiCoinData = yield this.fetchAllSuiCoinData();
|
|
49
|
+
const neededCoinData = utils_1.Helpers.filterObject(allSuiCoinData, (coin) => regularCoins
|
|
50
|
+
.map(utils_1.Helpers.addLeadingZeroesToType)
|
|
51
|
+
.includes(utils_1.Helpers.addLeadingZeroesToType(coin)));
|
|
52
|
+
const coinsToApiId = Object.entries(neededCoinData).reduce((acc, [coin, data]) => (Object.assign(Object.assign({}, acc), { [coin]: data.apiId })), {});
|
|
53
|
+
const [coinsToPrice, lpCoinsToPrice, missingCoinsToPrice] = yield Promise.all([
|
|
54
|
+
this.fetchCoinsToPriceGivenApiIds({
|
|
55
|
+
coinsToApiId,
|
|
56
|
+
}),
|
|
57
|
+
this.Provider.Pools().fetchLpCoinsToPrice({ lpCoins }),
|
|
58
|
+
new routerPricesApi_1.RouterPricesApi(this.Provider).fetchCoinsToPrice({
|
|
59
|
+
coins: coins.filter((coin) => !Object.keys(neededCoinData)
|
|
60
|
+
.map(utils_1.Helpers.addLeadingZeroesToType)
|
|
61
|
+
.includes(utils_1.Helpers.addLeadingZeroesToType(coin))),
|
|
62
|
+
}),
|
|
63
|
+
]);
|
|
64
|
+
return Object.assign(Object.assign(Object.assign({}, coinsToPrice), lpCoinsToPrice), missingCoinsToPrice);
|
|
65
|
+
}),
|
|
54
66
|
});
|
|
55
67
|
// TODO: add single cache by coin type ?
|
|
56
68
|
this.fetchCoinsToPriceInfo = this.Provider.withCache({
|
|
@@ -7,9 +7,9 @@ export declare class RouterPricesApi implements PricesApiInterface {
|
|
|
7
7
|
fetchPrice: (inputs: {
|
|
8
8
|
coin: CoinType;
|
|
9
9
|
}) => Promise<number>;
|
|
10
|
-
fetchCoinsToPrice: (inputs: {
|
|
10
|
+
fetchCoinsToPrice: (...inputs: {
|
|
11
11
|
coins: CoinType[];
|
|
12
|
-
}) => Promise<CoinsToPrice>;
|
|
12
|
+
}[]) => Promise<CoinsToPrice>;
|
|
13
13
|
fetchCoinsToPriceInfo: (...inputs: {
|
|
14
14
|
coins: CoinType[];
|
|
15
15
|
}[]) => Promise<Record<string, CoinPriceInfo>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routerPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/router/routerPricesApi.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EAGb,QAAQ,EACR,YAAY,EAEZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,qBAAa,eAAgB,YAAW,kBAAkB;IAK7C,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,YAAY;IAc5C,UAAU,WAAkB;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,KAAG,QAAQ,MAAM,CAAC,CAMrE;
|
|
1
|
+
{"version":3,"file":"routerPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/router/routerPricesApi.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EAGb,QAAQ,EACR,YAAY,EAEZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,qBAAa,eAAgB,YAAW,kBAAkB;IAK7C,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,YAAY;IAc5C,UAAU,WAAkB;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,KAAG,QAAQ,MAAM,CAAC,CAMrE;IAGK,iBAAiB;eAIf,QAAQ,EAAE;kCAuBhB;IAGI,qBAAqB;eAInB,QAAQ,EAAE;mDA0DhB;IAMH,OAAO,CAAC,6BAA6B,CAgElC;CACH"}
|
|
@@ -31,12 +31,17 @@ class RouterPricesApi {
|
|
|
31
31
|
coins: [inputs.coin],
|
|
32
32
|
}))[0];
|
|
33
33
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
// TODO: add single caches
|
|
35
|
+
this.fetchCoinsToPrice = this.Provider.withCache({
|
|
36
|
+
key: "routerPricesApi.fetchCoinsToPrice",
|
|
37
|
+
expirationSeconds: 300,
|
|
38
|
+
callback: (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const { coins } = inputs;
|
|
40
|
+
const prices = yield this.Provider.indexerCaller.fetchIndexer("prices", undefined, {
|
|
41
|
+
coin_types: coins,
|
|
42
|
+
}, undefined, undefined, true);
|
|
43
|
+
return coins.reduce((acc, coin, index) => (Object.assign(Object.assign({}, acc), { [coin]: prices[index] <= 0 ? -1 : prices[index] })), {});
|
|
44
|
+
}),
|
|
40
45
|
});
|
|
41
46
|
// TODO: add single cache by coin type ?
|
|
42
47
|
this.fetchCoinsToPriceInfo = this.Provider.withCache({
|