aftermath-ts-sdk 0.0.148 → 0.0.150
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.map +1 -1
- package/dist/general/prices/placeholder/placeholderPricesApi.d.ts +5 -2
- package/dist/general/prices/placeholder/placeholderPricesApi.d.ts.map +1 -1
- package/dist/general/prices/placeholder/placeholderPricesApi.js +32 -6
- package/dist/general/prices/pricesApiInterface.d.ts +5 -1
- package/dist/general/prices/pricesApiInterface.d.ts.map +1 -1
- package/dist/general/prices/pyth/pythPricesApi.d.ts +1 -9
- package/dist/general/prices/pyth/pythPricesApi.d.ts.map +1 -1
- package/dist/general/prices/pyth/pythPricesApi.js +50 -52
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coinGeckoPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/coingecko/coinGeckoPricesApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"coinGeckoPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/coingecko/coinGeckoPricesApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,qBAAa,kBACZ,SAAQ,mBACR,YAAW,kBAAkB;gBAMjB,eAAe,EAAE,MAAM;IAgB5B,UAAU,SAAgB,MAAM,KAAG,QAAQ,MAAM,CAAC,CAEvD;IAEK,iBAAiB,UAAiB,QAAQ,EAAE;;OAkCjD;IAMK,oBAAoB,WAAkB;QAC5C,QAAQ,EAAE,QAAQ,CAAC;QACnB,SAAS,EAAE,kBAAkB,CAAC;KAC9B,KAAG,QAAQ,MAAM,CAAC,CAKjB;IAEK,4BAA4B,WAAkB;QACpD,YAAY,EAAE,OAAO,QAAQ,EAAE,kBAAkB,CAAC,CAAC;KACnD,KAAG,QAAQ,OAAO,QAAQ,EAAE,MAAM,CAAC,CAAC,CAYnC;CACF"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { CoinType } from "../../../types";
|
|
1
|
+
import { CoinPriceInfo, CoinType } from "../../../types";
|
|
2
|
+
import { CoinGeckoCoinApiId } from "../coingecko/coinGeckoTypes";
|
|
2
3
|
import { PricesApiInterface } from "../pricesApiInterface";
|
|
3
4
|
export declare class PlaceholderPricesApi implements PricesApiInterface {
|
|
4
5
|
private static readonly constants;
|
|
5
|
-
constructor();
|
|
6
6
|
fetchPrice: (coin: CoinType) => Promise<number>;
|
|
7
7
|
fetchCoinsToPrice: (coins: CoinType[]) => Promise<Record<string, number>>;
|
|
8
|
+
fetchCoinsToPriceInfo: (inputs: {
|
|
9
|
+
coinsToApiId: Record<CoinType, CoinGeckoCoinApiId>;
|
|
10
|
+
}) => Promise<Record<CoinType, CoinPriceInfo>>;
|
|
8
11
|
private fetchPrices;
|
|
9
12
|
}
|
|
10
13
|
//# sourceMappingURL=placeholderPricesApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placeholderPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/placeholder/placeholderPricesApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"placeholderPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/placeholder/placeholderPricesApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,qBAAa,oBAAqB,YAAW,kBAAkB;IAK9D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAkB/B;IAcK,UAAU,SAAgB,QAAQ,qBAEvC;IAEK,iBAAiB,UAAiB,QAAQ,EAAE,qCAajD;IAEK,qBAAqB,WAAkB;QAC7C,YAAY,EAAE,OAAO,QAAQ,EAAE,kBAAkB,CAAC,CAAC;KACnD,KAAG,QAAQ,OAAO,QAAQ,EAAE,aAAa,CAAC,CAAC,CAqB1C;IAuBF,OAAO,CAAC,WAAW,CAYjB;CACF"}
|
|
@@ -12,16 +12,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.PlaceholderPricesApi = void 0;
|
|
13
13
|
const coin_1 = require("../../../packages/coin/coin");
|
|
14
14
|
class PlaceholderPricesApi {
|
|
15
|
-
/////////////////////////////////////////////////////////////////////
|
|
16
|
-
//// Constructor
|
|
17
|
-
/////////////////////////////////////////////////////////////////////
|
|
18
15
|
constructor() {
|
|
16
|
+
/////////////////////////////////////////////////////////////////////
|
|
17
|
+
//// Constants
|
|
18
|
+
/////////////////////////////////////////////////////////////////////
|
|
19
19
|
/////////////////////////////////////////////////////////////////////
|
|
20
20
|
//// Fetching
|
|
21
21
|
/////////////////////////////////////////////////////////////////////
|
|
22
22
|
/////////////////////////////////////////////////////////////////////
|
|
23
23
|
//// Public
|
|
24
24
|
/////////////////////////////////////////////////////////////////////
|
|
25
|
+
/////////////////////////////////////////////////////////////////////
|
|
26
|
+
//// Interface Methods
|
|
27
|
+
/////////////////////////////////////////////////////////////////////
|
|
25
28
|
this.fetchPrice = (coin) => __awaiter(this, void 0, void 0, function* () {
|
|
26
29
|
return (yield this.fetchPrices([coin]))[0];
|
|
27
30
|
});
|
|
@@ -32,6 +35,32 @@ class PlaceholderPricesApi {
|
|
|
32
35
|
}, {});
|
|
33
36
|
return coinsToPrice;
|
|
34
37
|
});
|
|
38
|
+
this.fetchCoinsToPriceInfo = (inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const { coinsToApiId } = inputs;
|
|
40
|
+
if (Object.keys(coinsToApiId).length <= 0)
|
|
41
|
+
return {};
|
|
42
|
+
const coinsToPrice = yield this.fetchCoinsToPrice(Object.keys(inputs.coinsToApiId));
|
|
43
|
+
const coinsInfo = Object.entries(coinsToPrice).reduce((acc, [coin, price]) => (Object.assign(Object.assign({}, acc), { [coin]: {
|
|
44
|
+
price,
|
|
45
|
+
priceChange24HoursPercentage: Math.random() > 0.5 ? 0 : (Math.random() - 0.5) / 10,
|
|
46
|
+
} })), {});
|
|
47
|
+
return coinsInfo;
|
|
48
|
+
});
|
|
49
|
+
// public fetchPriceGivenApiId = async (inputs: {
|
|
50
|
+
// coinType: CoinType;
|
|
51
|
+
// coinApiId: CoinGeckoCoinApiId;
|
|
52
|
+
// }): Promise<number> => {
|
|
53
|
+
// const charCode = inputs.coinType.charCodeAt(0);
|
|
54
|
+
// return isNaN(charCode) ? 0 : charCode;
|
|
55
|
+
// };
|
|
56
|
+
// public fetchCoinsToPriceGivenApiIds = async (inputs: {
|
|
57
|
+
// coinsToApiId: Record<CoinType, CoinGeckoCoinApiId>;
|
|
58
|
+
// }): Promise<Record<CoinType, number>> => {
|
|
59
|
+
// const coinsToPrice = await this.fetchCoinsToPrice(
|
|
60
|
+
// Object.keys(inputs.coinsToApiId)
|
|
61
|
+
// );
|
|
62
|
+
// return coinsToPrice;
|
|
63
|
+
// };
|
|
35
64
|
/////////////////////////////////////////////////////////////////////
|
|
36
65
|
//// Private
|
|
37
66
|
/////////////////////////////////////////////////////////////////////
|
|
@@ -45,9 +74,6 @@ class PlaceholderPricesApi {
|
|
|
45
74
|
}
|
|
46
75
|
}
|
|
47
76
|
exports.PlaceholderPricesApi = PlaceholderPricesApi;
|
|
48
|
-
/////////////////////////////////////////////////////////////////////
|
|
49
|
-
//// Constants
|
|
50
|
-
/////////////////////////////////////////////////////////////////////
|
|
51
77
|
PlaceholderPricesApi.constants = {
|
|
52
78
|
prices: {
|
|
53
79
|
usdc: 1,
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { CoinType } from "../../types";
|
|
1
|
+
import { CoinPriceInfo, CoinType } from "../../types";
|
|
2
|
+
import { CoinGeckoCoinApiId } from "./coingecko/coinGeckoTypes";
|
|
2
3
|
export interface PricesApiInterface {
|
|
3
4
|
fetchPrice: (coin: CoinType) => Promise<number>;
|
|
4
5
|
fetchCoinsToPrice: (coins: CoinType[]) => Promise<Record<CoinType, number>>;
|
|
6
|
+
fetchCoinsToPriceInfo: (inputs: {
|
|
7
|
+
coinsToApiId: Record<CoinType, CoinGeckoCoinApiId>;
|
|
8
|
+
}) => Promise<Record<CoinType, CoinPriceInfo>>;
|
|
5
9
|
}
|
|
6
10
|
//# sourceMappingURL=pricesApiInterface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricesApiInterface.d.ts","sourceRoot":"","sources":["../../../src/general/prices/pricesApiInterface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"pricesApiInterface.d.ts","sourceRoot":"","sources":["../../../src/general/prices/pricesApiInterface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,MAAM,WAAW,kBAAkB;IAClC,UAAU,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,iBAAiB,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAU5E,qBAAqB,EAAE,CAAC,MAAM,EAAE;QAC/B,YAAY,EAAE,MAAM,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;KACnD,KAAK,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;CAC/C"}
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { PricesApiInterface } from "../pricesApiInterface";
|
|
3
|
-
import { PythPricesApiHelpers } from "./pythPricesApiHelpers";
|
|
4
|
-
export declare class PythPricesApi extends PythPricesApiHelpers implements PricesApiInterface {
|
|
5
|
-
constructor(coinSymbolToCoinTypes: CoinSymbolToCoinTypes);
|
|
6
|
-
fetchPrice: (coin: CoinType) => Promise<number>;
|
|
7
|
-
fetchCoinsToPrice: (coins: CoinType[]) => Promise<Record<string, number>>;
|
|
8
|
-
private fetchPrices;
|
|
9
|
-
}
|
|
1
|
+
export {};
|
|
10
2
|
//# sourceMappingURL=pythPricesApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pythPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/pyth/pythPricesApi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pythPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/pyth/pythPricesApi.ts"],"names":[],"mappings":""}
|
|
@@ -1,54 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
2
|
+
// import { CoinSymbolToCoinTypes, CoinType } from "../../../types";
|
|
3
|
+
// import { PricesApiInterface } from "../pricesApiInterface";
|
|
4
|
+
// import { PythPricesApiHelpers } from "./pythPricesApiHelpers";
|
|
11
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
6
|
+
// export class PythPricesApi
|
|
7
|
+
// extends PythPricesApiHelpers
|
|
8
|
+
// implements PricesApiInterface
|
|
9
|
+
// {
|
|
10
|
+
// /////////////////////////////////////////////////////////////////////
|
|
11
|
+
// //// Constructor
|
|
12
|
+
// /////////////////////////////////////////////////////////////////////
|
|
13
|
+
// constructor(coinSymbolToCoinTypes: CoinSymbolToCoinTypes) {
|
|
14
|
+
// super(coinSymbolToCoinTypes);
|
|
15
|
+
// }
|
|
16
|
+
// /////////////////////////////////////////////////////////////////////
|
|
17
|
+
// //// Fetching
|
|
18
|
+
// /////////////////////////////////////////////////////////////////////
|
|
19
|
+
// /////////////////////////////////////////////////////////////////////
|
|
20
|
+
// //// Public
|
|
21
|
+
// /////////////////////////////////////////////////////////////////////
|
|
22
|
+
// public fetchPrice = async (coin: CoinType) => {
|
|
23
|
+
// return (await this.fetchPrices([coin]))[0];
|
|
24
|
+
// };
|
|
25
|
+
// public fetchCoinsToPrice = async (coins: CoinType[]) => {
|
|
26
|
+
// const prices = await this.fetchPrices(coins);
|
|
27
|
+
// const coinsToPrice: Record<CoinType, number> = coins.reduce(
|
|
28
|
+
// (acc, coin, index) => {
|
|
29
|
+
// return {
|
|
30
|
+
// ...acc,
|
|
31
|
+
// [coin]: prices[index],
|
|
32
|
+
// };
|
|
33
|
+
// },
|
|
34
|
+
// {}
|
|
35
|
+
// );
|
|
36
|
+
// return coinsToPrice;
|
|
37
|
+
// };
|
|
38
|
+
// /////////////////////////////////////////////////////////////////////
|
|
39
|
+
// //// Private
|
|
40
|
+
// /////////////////////////////////////////////////////////////////////
|
|
41
|
+
// private fetchPrices = async (coins: CoinType[]) => {
|
|
42
|
+
// const priceFeeds = await this.fetchPriceFeeds(coins);
|
|
43
|
+
// const prices = priceFeeds.map((priceFeed) => {
|
|
44
|
+
// // TODO: handle this differently ? - will cause breaking changes in FE
|
|
45
|
+
// if (priceFeed === undefined) return -1;
|
|
46
|
+
// const price = priceFeed.getPriceAsNumberUnchecked();
|
|
47
|
+
// if (price <= 0) return -1;
|
|
48
|
+
// return price;
|
|
49
|
+
// });
|
|
50
|
+
// return prices;
|
|
51
|
+
// };
|
|
52
|
+
// }
|