aftermath-ts-sdk 1.1.97 → 1.2.0-refactor.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.
Files changed (136) hide show
  1. package/dist/general/historicalData/historicalData.d.ts +1 -1
  2. package/dist/general/historicalData/historicalData.d.ts.map +1 -1
  3. package/dist/general/nfts/nftsApi.d.ts +1 -5
  4. package/dist/general/nfts/nftsApi.d.ts.map +1 -1
  5. package/dist/general/nfts/nftsApi.js +15 -29
  6. package/dist/general/nfts/nftsApiCasting.d.ts +0 -1
  7. package/dist/general/nfts/nftsApiCasting.d.ts.map +1 -1
  8. package/dist/general/nfts/nftsApiCasting.js +0 -10
  9. package/dist/general/nfts/nftsTypes.d.ts +0 -1
  10. package/dist/general/nfts/nftsTypes.d.ts.map +1 -1
  11. package/dist/general/prices/{coingecko/coinGeckoTypes.d.ts → coinGeckoTypes.d.ts} +1 -1
  12. package/dist/general/prices/coinGeckoTypes.d.ts.map +1 -0
  13. package/dist/general/providers/aftermath.d.ts.map +1 -1
  14. package/dist/general/providers/aftermath.js +1 -2
  15. package/dist/general/providers/aftermathApi.d.ts +1 -34
  16. package/dist/general/providers/aftermathApi.d.ts.map +1 -1
  17. package/dist/general/providers/aftermathApi.js +2 -90
  18. package/dist/general/types/castingTypes.d.ts +0 -7
  19. package/dist/general/types/castingTypes.d.ts.map +1 -1
  20. package/dist/general/types/configTypes.d.ts +0 -6
  21. package/dist/general/types/configTypes.d.ts.map +1 -1
  22. package/dist/general/types/generalTypes.d.ts +0 -3
  23. package/dist/general/types/generalTypes.d.ts.map +1 -1
  24. package/dist/general/types/index.d.ts +1 -0
  25. package/dist/general/types/index.d.ts.map +1 -1
  26. package/dist/general/types/index.js +1 -0
  27. package/dist/general/utils/helpers.d.ts +1 -16
  28. package/dist/general/utils/helpers.d.ts.map +1 -1
  29. package/dist/general/utils/helpers.js +2 -32
  30. package/dist/general/utils/index.d.ts +0 -1
  31. package/dist/general/utils/index.d.ts.map +1 -1
  32. package/dist/general/utils/index.js +0 -1
  33. package/dist/packages/coin/api/coinApi.d.ts +1 -12
  34. package/dist/packages/coin/api/coinApi.d.ts.map +1 -1
  35. package/dist/packages/coin/api/coinApi.js +0 -123
  36. package/dist/packages/dca/api/dcaApi.d.ts +1 -28
  37. package/dist/packages/dca/api/dcaApi.d.ts.map +1 -1
  38. package/dist/packages/dca/api/dcaApi.js +0 -172
  39. package/dist/packages/farms/api/farmsApi.d.ts +1 -24
  40. package/dist/packages/farms/api/farmsApi.d.ts.map +1 -1
  41. package/dist/packages/farms/api/farmsApi.js +0 -69
  42. package/dist/packages/farms/api/farmsApiCasting.d.ts +2 -3
  43. package/dist/packages/farms/api/farmsApiCasting.d.ts.map +1 -1
  44. package/dist/packages/farms/api/farmsApiCasting.js +0 -45
  45. package/dist/packages/farms/api/farmsApiCastingTypes.d.ts +0 -9
  46. package/dist/packages/farms/api/farmsApiCastingTypes.d.ts.map +1 -1
  47. package/dist/packages/faucet/api/faucetApi.d.ts +0 -5
  48. package/dist/packages/faucet/api/faucetApi.d.ts.map +1 -1
  49. package/dist/packages/faucet/api/faucetApi.js +2 -29
  50. package/dist/packages/faucet/faucet.d.ts +3 -2
  51. package/dist/packages/faucet/faucet.d.ts.map +1 -1
  52. package/dist/packages/faucet/faucet.js +2 -2
  53. package/dist/packages/leveragedStaking/api/leveragedStakingApi.d.ts.map +1 -1
  54. package/dist/packages/leveragedStaking/api/leveragedStakingApi.js +383 -298
  55. package/dist/packages/nftAmm/nftAmmMarket.d.ts +9 -5
  56. package/dist/packages/nftAmm/nftAmmMarket.d.ts.map +1 -1
  57. package/dist/packages/nftAmm/nftAmmMarket.js +34 -6
  58. package/dist/packages/oracle/api/oracleApi.d.ts +1 -10
  59. package/dist/packages/oracle/api/oracleApi.d.ts.map +1 -1
  60. package/dist/packages/oracle/api/oracleApi.js +0 -38
  61. package/dist/packages/perpetuals/api/perpetualsApi.d.ts +2 -58
  62. package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +1 -1
  63. package/dist/packages/perpetuals/api/perpetualsApi.js +0 -735
  64. package/dist/packages/pools/api/poolsApi.d.ts +2 -217
  65. package/dist/packages/pools/api/poolsApi.d.ts.map +1 -1
  66. package/dist/packages/pools/api/poolsApi.js +0 -752
  67. package/dist/packages/pools/api/poolsApiCasting.d.ts +3 -15
  68. package/dist/packages/pools/api/poolsApiCasting.d.ts.map +1 -1
  69. package/dist/packages/pools/api/poolsApiCasting.js +0 -86
  70. package/dist/packages/pools/api/poolsApiCastingTypes.d.ts +1 -15
  71. package/dist/packages/pools/api/poolsApiCastingTypes.d.ts.map +1 -1
  72. package/dist/packages/pools/pools.d.ts +4 -1
  73. package/dist/packages/pools/pools.d.ts.map +1 -1
  74. package/dist/packages/pools/pools.js +5 -0
  75. package/dist/packages/router/api/routerApi.d.ts +2 -116
  76. package/dist/packages/router/api/routerApi.d.ts.map +1 -1
  77. package/dist/packages/router/api/routerApi.js +3 -345
  78. package/dist/packages/router/api/routerApiCasting.d.ts +2 -5
  79. package/dist/packages/router/api/routerApiCasting.d.ts.map +1 -1
  80. package/dist/packages/router/api/routerApiCasting.js +0 -104
  81. package/dist/packages/router/api/routerApiCastingTypes.d.ts +1 -13
  82. package/dist/packages/router/api/routerApiCastingTypes.d.ts.map +1 -1
  83. package/dist/packages/router/routerTypes.d.ts +3 -35
  84. package/dist/packages/router/routerTypes.d.ts.map +1 -1
  85. package/dist/packages/staking/api/stakingApi.d.ts +2 -50
  86. package/dist/packages/staking/api/stakingApi.d.ts.map +1 -1
  87. package/dist/packages/staking/api/stakingApi.js +0 -226
  88. package/dist/packages/staking/api/stakingApiCasting.d.ts +2 -4
  89. package/dist/packages/staking/api/stakingApiCasting.d.ts.map +1 -1
  90. package/dist/packages/staking/api/stakingApiCasting.js +0 -21
  91. package/dist/packages/staking/api/stakingApiCastingTypes.d.ts +1 -8
  92. package/dist/packages/staking/api/stakingApiCastingTypes.d.ts.map +1 -1
  93. package/dist/packages/staking/stakingTypes.d.ts +2 -0
  94. package/dist/packages/staking/stakingTypes.d.ts.map +1 -1
  95. package/dist/packages/sui/api/suiApi.d.ts +1 -2
  96. package/dist/packages/sui/api/suiApi.d.ts.map +1 -1
  97. package/dist/packages/sui/api/suiApi.js +0 -3
  98. package/package.json +1 -1
  99. package/dist/general/dynamicGas/dynamicGasApi.d.ts +0 -15
  100. package/dist/general/dynamicGas/dynamicGasApi.d.ts.map +0 -1
  101. package/dist/general/dynamicGas/dynamicGasApi.js +0 -87
  102. package/dist/general/historicalData/historicalDataApi.d.ts +0 -9
  103. package/dist/general/historicalData/historicalDataApi.d.ts.map +0 -1
  104. package/dist/general/historicalData/historicalDataApi.js +0 -13
  105. package/dist/general/historicalData/historicalDataApiInterface.d.ts +0 -12
  106. package/dist/general/historicalData/historicalDataApiInterface.d.ts.map +0 -1
  107. package/dist/general/historicalData/historicalDataApiInterface.js +0 -2
  108. package/dist/general/historicalData/placeholderHistoricalDataApi.d.ts +0 -13
  109. package/dist/general/historicalData/placeholderHistoricalDataApi.d.ts.map +0 -1
  110. package/dist/general/historicalData/placeholderHistoricalDataApi.js +0 -26
  111. package/dist/general/prices/coingecko/coinGeckoApiHelpers.d.ts +0 -22
  112. package/dist/general/prices/coingecko/coinGeckoApiHelpers.d.ts.map +0 -1
  113. package/dist/general/prices/coingecko/coinGeckoApiHelpers.js +0 -179
  114. package/dist/general/prices/coingecko/coinGeckoPricesApi.d.ts +0 -23
  115. package/dist/general/prices/coingecko/coinGeckoPricesApi.d.ts.map +0 -1
  116. package/dist/general/prices/coingecko/coinGeckoPricesApi.js +0 -113
  117. package/dist/general/prices/coingecko/coinGeckoTypes.d.ts.map +0 -1
  118. package/dist/general/prices/placeholder/placeholderPricesApi.d.ts +0 -20
  119. package/dist/general/prices/placeholder/placeholderPricesApi.d.ts.map +0 -1
  120. package/dist/general/prices/placeholder/placeholderPricesApi.js +0 -85
  121. package/dist/general/prices/pricesApiInterface.d.ts +0 -13
  122. package/dist/general/prices/pricesApiInterface.d.ts.map +0 -1
  123. package/dist/general/prices/pricesApiInterface.js +0 -2
  124. package/dist/general/prices/pyth/pythPricesApi.d.ts +0 -2
  125. package/dist/general/prices/pyth/pythPricesApi.d.ts.map +0 -1
  126. package/dist/general/prices/pyth/pythPricesApi.js +0 -52
  127. package/dist/general/prices/pyth/pythPricesApiHelpers.d.ts +0 -13
  128. package/dist/general/prices/pyth/pythPricesApiHelpers.d.ts.map +0 -1
  129. package/dist/general/prices/pyth/pythPricesApiHelpers.js +0 -77
  130. package/dist/general/prices/router/routerPricesApi.d.ts +0 -18
  131. package/dist/general/prices/router/routerPricesApi.d.ts.map +0 -1
  132. package/dist/general/prices/router/routerPricesApi.js +0 -126
  133. package/dist/general/utils/indexerCaller.d.ts +0 -14
  134. package/dist/general/utils/indexerCaller.d.ts.map +0 -1
  135. package/dist/general/utils/indexerCaller.js +0 -129
  136. /package/dist/general/prices/{coingecko/coinGeckoTypes.js → coinGeckoTypes.js} +0 -0
@@ -1,12 +0,0 @@
1
- import { CoinSymbol, CoinType } from "../../types";
2
- import { CoinGeckoCoinData, CoinGeckoCoinSymbolData } from "../prices/coingecko/coinGeckoTypes";
3
- import { CoinHistoricalData } from "./historicalDataTypes";
4
- export interface HistoricalDataApiInterface {
5
- fetchAllSuiCoinData: () => Promise<Record<CoinType, CoinGeckoCoinData>>;
6
- fetchAllCoinData: () => Promise<Record<CoinSymbol, CoinGeckoCoinSymbolData>>;
7
- fetchHistoricalData: (inputs: {
8
- coinApiId: string;
9
- daysAgo: number;
10
- }) => Promise<CoinHistoricalData>;
11
- }
12
- //# sourceMappingURL=historicalDataApiInterface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"historicalDataApiInterface.d.ts","sourceRoot":"","sources":["../../../src/general/historicalData/historicalDataApiInterface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACN,iBAAiB,EACjB,uBAAuB,EACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,WAAW,0BAA0B;IAC1C,mBAAmB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAExE,gBAAgB,EAAE,MAAM,OAAO,CAC9B,MAAM,CAAC,UAAU,EAAE,uBAAuB,CAAC,CAC3C,CAAC;IAEF,mBAAmB,EAAE,CAAC,MAAM,EAAE;QAC7B,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KAChB,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAClC"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,13 +0,0 @@
1
- import { CoinType } from "../../types";
2
- import { CoinGeckoCoinData } from "../prices/coingecko/coinGeckoTypes";
3
- import { HistoricalDataApiInterface } from "./historicalDataApiInterface";
4
- import { CoinHistoricalData } from "./historicalDataTypes";
5
- export declare class PlaceholderHistoricalDataApi implements HistoricalDataApiInterface {
6
- fetchAllSuiCoinData: () => Promise<Record<CoinType, CoinGeckoCoinData>>;
7
- fetchAllCoinData: () => Promise<Record<CoinType, CoinGeckoCoinData>>;
8
- fetchHistoricalData: (inputs: {
9
- coinApiId: string;
10
- daysAgo: number;
11
- }) => Promise<CoinHistoricalData>;
12
- }
13
- //# sourceMappingURL=placeholderHistoricalDataApi.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"placeholderHistoricalDataApi.d.ts","sourceRoot":"","sources":["../../../src/general/historicalData/placeholderHistoricalDataApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACN,iBAAiB,EAEjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,qBAAa,4BACZ,YAAW,0BAA0B;IAE9B,mBAAmB,QAAa,QACtC,OAAO,QAAQ,EAAE,iBAAiB,CAAC,CACnC,CAEC;IAEK,gBAAgB,QAAa,QACnC,OAAO,QAAQ,EAAE,iBAAiB,CAAC,CACnC,CAEC;IAEK,mBAAmB,WAAkB;QAC3C,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KAChB,KAAG,QAAQ,kBAAkB,CAAC,CAE7B;CACF"}
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
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
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PlaceholderHistoricalDataApi = void 0;
13
- class PlaceholderHistoricalDataApi {
14
- constructor() {
15
- this.fetchAllSuiCoinData = () => __awaiter(this, void 0, void 0, function* () {
16
- return {};
17
- });
18
- this.fetchAllCoinData = () => __awaiter(this, void 0, void 0, function* () {
19
- return {};
20
- });
21
- this.fetchHistoricalData = (inputs) => __awaiter(this, void 0, void 0, function* () {
22
- throw new Error("no placeholder historical data");
23
- });
24
- }
25
- }
26
- exports.PlaceholderHistoricalDataApi = PlaceholderHistoricalDataApi;
@@ -1,22 +0,0 @@
1
- import { CoinPriceInfo, CoinSymbol, CoinType } from "../../../types";
2
- import { CoinHistoricalData } from "../../historicalData/historicalDataTypes";
3
- import { AftermathApi } from "../../providers";
4
- import { CoinGeckoCoinApiId, CoinGeckoCoinData, CoinGeckoCoinSymbolData } from "./coinGeckoTypes";
5
- export declare class CoinGeckoApiHelpers {
6
- protected readonly Provider: AftermathApi;
7
- private readonly coinGeckoApiKey;
8
- private readonly coinApiIdsToCoinTypes;
9
- constructor(Provider: AftermathApi, coinGeckoApiKey: string, coinApiIdsToCoinTypes: Record<CoinGeckoCoinApiId, CoinType[]>);
10
- fetchAllSuiCoinData: () => Promise<Record<CoinType, CoinGeckoCoinData>>;
11
- fetchAllCoinData: () => Promise<Record<CoinSymbol, CoinGeckoCoinSymbolData>>;
12
- fetchHistoricalData: (...inputs: {
13
- coinApiId: CoinGeckoCoinApiId;
14
- daysAgo: number;
15
- }[]) => Promise<CoinHistoricalData>;
16
- fetchCoinsToPriceInfoInternal: (...inputs: {
17
- coinsToApiId: Record<CoinType, CoinGeckoCoinApiId>;
18
- }[]) => Promise<Record<string, CoinPriceInfo>>;
19
- private callApi;
20
- private fetchRawCoinData;
21
- }
22
- //# sourceMappingURL=coinGeckoApiHelpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"coinGeckoApiHelpers.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/coingecko/coinGeckoApiHelpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EACN,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,mBAAmB;IAM9B,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY;IACzC,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,qBAAqB;gBAFnB,QAAQ,EAAE,YAAY,EACxB,eAAe,EAAE,MAAM,EACvB,qBAAqB,EAAE,MAAM,CAC7C,kBAAkB,EAClB,QAAQ,EAAE,CACV;IAWK,mBAAmB,QAAa,QACtC,OAAO,QAAQ,EAAE,iBAAiB,CAAC,CACnC,CAsEC;IAEK,gBAAgB,QAAa,QACnC,OAAO,UAAU,EAAE,uBAAuB,CAAC,CAC3C,CAYC;IAMK,mBAAmB;mBAIb,kBAAkB;iBACpB,MAAM;wCA2Bd;IAMI,6BAA6B;sBAIpB,OAAO,QAAQ,EAAE,kBAAkB,CAAC;mDAmFjD;IAUH,OAAO,CAAC,OAAO,CAeb;IAEF,OAAO,CAAC,gBAAgB,CAerB;CACH"}
@@ -1,179 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
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
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.CoinGeckoApiHelpers = void 0;
13
- const packages_1 = require("../../../packages");
14
- const utils_1 = require("../../utils");
15
- class CoinGeckoApiHelpers {
16
- // =========================================================================
17
- // Constructor
18
- // =========================================================================
19
- constructor(Provider, coinGeckoApiKey, coinApiIdsToCoinTypes) {
20
- this.Provider = Provider;
21
- this.coinGeckoApiKey = coinGeckoApiKey;
22
- this.coinApiIdsToCoinTypes = coinApiIdsToCoinTypes;
23
- // =========================================================================
24
- // Public
25
- // =========================================================================
26
- // =========================================================================
27
- // Coin Data
28
- // =========================================================================
29
- this.fetchAllSuiCoinData = () => __awaiter(this, void 0, void 0, function* () {
30
- const coinData = yield this.fetchRawCoinData();
31
- const suiCoinData = coinData
32
- .filter((data) => "sui" in data.platforms || data.id === "sui")
33
- .map((data) => {
34
- const coinType = data.id === "sui"
35
- ? packages_1.Coin.constants.suiCoinType
36
- : data.platforms.sui;
37
- try {
38
- if (!coinType)
39
- throw new Error("no coin type found");
40
- return {
41
- apiId: data.id,
42
- name: data.name,
43
- symbol: data.symbol,
44
- coinType: utils_1.Helpers.addLeadingZeroesToType(coinType),
45
- };
46
- }
47
- catch (e) {
48
- return undefined;
49
- }
50
- })
51
- .filter((data) => data !== undefined);
52
- const partialCoinDataObject = suiCoinData.reduce((acc, data) => {
53
- return Object.assign({ [data.coinType]: data }, acc);
54
- }, {});
55
- const coinDataObject = Object.entries(this.coinApiIdsToCoinTypes).reduce((acc, [coinApiId, coinTypes]) => {
56
- const foundSuiData = Object.values(partialCoinDataObject).find((data) => data.apiId === coinApiId);
57
- let foundData = foundSuiData;
58
- if (!foundData) {
59
- const foundCoinData = coinData.find((data) => data.id === coinApiId);
60
- if (!foundCoinData)
61
- return acc;
62
- foundData = {
63
- apiId: coinApiId,
64
- name: foundCoinData.name,
65
- symbol: foundCoinData.symbol,
66
- coinType: "",
67
- };
68
- }
69
- if (!foundData)
70
- return acc;
71
- const dataToDuplicate = foundData;
72
- const newData = coinTypes.reduce((acc, coinType) => (Object.assign({ [coinType]: Object.assign(Object.assign({}, dataToDuplicate), { coinType }) }, acc)), acc);
73
- return newData;
74
- }, partialCoinDataObject);
75
- return coinDataObject;
76
- });
77
- this.fetchAllCoinData = () => __awaiter(this, void 0, void 0, function* () {
78
- const coinData = yield this.fetchRawCoinData();
79
- return coinData.reduce((acc, data) => {
80
- return Object.assign({ [data.symbol.toLowerCase()]: {
81
- apiId: data.id,
82
- name: data.name,
83
- symbol: data.symbol.toLowerCase(),
84
- } }, acc);
85
- }, {});
86
- });
87
- // =========================================================================
88
- // Historical Data
89
- // =========================================================================
90
- this.fetchHistoricalData = this.Provider.withCache({
91
- key: "coinGeckoApiHelpers.fetchHistoricalData",
92
- expirationSeconds: 3600,
93
- callback: (inputs) => __awaiter(this, void 0, void 0, function* () {
94
- const { coinApiId, daysAgo } = inputs;
95
- const allData = yield this.callApi(`coins/${coinApiId}/market_chart?vs_currency=USD&days=${daysAgo}`);
96
- const formattedData = {
97
- prices: allData.prices,
98
- marketCaps: allData.market_caps,
99
- volumes24Hours: allData.total_volumes,
100
- time: inputs.daysAgo,
101
- timeUnit: "D",
102
- };
103
- if (allData.prices.some((val) => val[0] <= 0))
104
- throw new Error("invalid historical data for coin api id: " + coinApiId);
105
- return formattedData;
106
- }),
107
- });
108
- // =========================================================================
109
- // Current Prices
110
- // =========================================================================
111
- this.fetchCoinsToPriceInfoInternal = this.Provider.withCache({
112
- key: "coinGeckoApiHelpers.fetchCoinsToPriceInfoInternal",
113
- expirationSeconds: 300,
114
- callback: (inputs) => __awaiter(this, void 0, void 0, function* () {
115
- const { coinsToApiId } = inputs;
116
- if (Object.keys(coinsToApiId).length <= 0)
117
- return {};
118
- const singleCacheKey = "coinGeckoApiHelpers.fetchCoinsToPriceInfoInternal_coin";
119
- const cachedCoinsToPriceInfo = Object.entries(coinsToApiId).reduce((acc, [coin]) => {
120
- const cachedData = this.Provider.getCache({
121
- key: singleCacheKey,
122
- inputs: [coin],
123
- });
124
- if (cachedData === "NO_CACHED_DATA")
125
- return acc;
126
- return Object.assign(Object.assign({}, acc), { [coin]: cachedData });
127
- }, {});
128
- const nonCachedCoinsToApiId = utils_1.Helpers.filterObject(coinsToApiId, (coin) => !Object.keys(cachedCoinsToPriceInfo).includes(coin));
129
- const rawCoinsInfo = yield this.callApi(`simple/price?ids=${utils_1.Helpers.uniqueArray(Object.values(nonCachedCoinsToApiId)).reduce((acc, apiId) => `${acc},${apiId}`, "")}&vs_currencies=USD&include_24hr_change=true&precision=full`);
130
- const nonCachedCoinsInfo = Object.entries(nonCachedCoinsToApiId).reduce((acc, [coinType, coinApiId]) => {
131
- var _a, _b;
132
- const info = (_a = Object.entries(rawCoinsInfo).find(([id]) => id === coinApiId)) === null || _a === void 0 ? void 0 : _a[1];
133
- if (!info)
134
- throw new Error(`coin type: '${coinType}' not found for coingecko coin api id: '${coinApiId}'`);
135
- return Object.assign(Object.assign({}, acc), { [coinType]: {
136
- price: (_b = info.usd) !== null && _b !== void 0 ? _b : -1,
137
- priceChange24HoursPercentage: info.usd_24h_change === undefined
138
- ? 0
139
- : info.usd_24h_change / 100,
140
- } });
141
- }, {});
142
- for (const [coin, coinsInfo] of Object.entries(nonCachedCoinsInfo)) {
143
- this.Provider.setCache({
144
- key: singleCacheKey,
145
- data: coinsInfo,
146
- inputs: [coin],
147
- expirationSeconds: 300, // 5 minutes
148
- });
149
- }
150
- return Object.assign(Object.assign({}, cachedCoinsToPriceInfo), nonCachedCoinsInfo);
151
- }),
152
- });
153
- // =========================================================================
154
- // Private
155
- // =========================================================================
156
- // =========================================================================
157
- // Helpers
158
- // =========================================================================
159
- this.callApi = (endpoint) => __awaiter(this, void 0, void 0, function* () {
160
- const someJson = yield (yield fetch("https://pro-api.coingecko.com/api/v3/" +
161
- (endpoint[0] === "/"
162
- ? endpoint.replace("/", "")
163
- : endpoint) +
164
- (this.coinGeckoApiKey === ""
165
- ? ""
166
- : `&x_cg_pro_api_key=${this.coinGeckoApiKey}`))).json();
167
- const castedRes = someJson;
168
- return castedRes;
169
- });
170
- this.fetchRawCoinData = this.Provider.withCache({
171
- key: "coinGeckoApiHelpers.fetchAllSuiCoinData",
172
- expirationSeconds: 86400,
173
- callback: () => {
174
- return this.callApi("coins/list?include_platform=true");
175
- },
176
- });
177
- }
178
- }
179
- exports.CoinGeckoApiHelpers = CoinGeckoApiHelpers;
@@ -1,23 +0,0 @@
1
- import { CoinPriceInfo, CoinType } from "../../../types";
2
- import { AftermathApi } from "../../providers";
3
- import { PricesApiInterface } from "../pricesApiInterface";
4
- import { CoinGeckoApiHelpers } from "./coinGeckoApiHelpers";
5
- import { CoinGeckoCoinApiId } from "./coinGeckoTypes";
6
- export declare class CoinGeckoPricesApi extends CoinGeckoApiHelpers implements PricesApiInterface {
7
- constructor(Provider: AftermathApi, coinGeckoApiKey: string, coinApiIdsToCoinTypes: Record<CoinGeckoCoinApiId, CoinType[]>);
8
- fetchPrice: (inputs: {
9
- coin: CoinType;
10
- }) => Promise<number>;
11
- fetchCoinsToPrice: (...inputs: {
12
- coins: CoinType[];
13
- }[]) => Promise<{
14
- [x: string]: number;
15
- }>;
16
- fetchCoinsToPriceInfo: (...inputs: {
17
- coins: CoinType[];
18
- }[]) => Promise<Record<string, CoinPriceInfo>>;
19
- fetchCoinsToPriceGivenApiIds: (inputs: {
20
- coinsToApiId: Record<CoinType, CoinGeckoCoinApiId>;
21
- }) => Promise<Record<CoinType, number>>;
22
- }
23
- //# sourceMappingURL=coinGeckoPricesApi.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,113 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
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
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.CoinGeckoPricesApi = void 0;
13
- const utils_1 = require("../../utils");
14
- const routerPricesApi_1 = require("../router/routerPricesApi");
15
- const coinGeckoApiHelpers_1 = require("./coinGeckoApiHelpers");
16
- class CoinGeckoPricesApi extends coinGeckoApiHelpers_1.CoinGeckoApiHelpers {
17
- // =========================================================================
18
- // Constructor
19
- // =========================================================================
20
- constructor(Provider, coinGeckoApiKey, coinApiIdsToCoinTypes) {
21
- super(Provider, coinGeckoApiKey, coinApiIdsToCoinTypes);
22
- // =========================================================================
23
- // Fetching
24
- // =========================================================================
25
- // =========================================================================
26
- // Public
27
- // =========================================================================
28
- // =========================================================================
29
- // Interface Methods
30
- // =========================================================================
31
- this.fetchPrice = (inputs) => __awaiter(this, void 0, void 0, function* () {
32
- return Object.values(yield this.fetchCoinsToPrice({
33
- coins: [inputs.coin],
34
- }))[0];
35
- });
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
- }),
66
- });
67
- // TODO: add single cache by coin type ?
68
- this.fetchCoinsToPriceInfo = this.Provider.withCache({
69
- key: "coinGeckoPricesApi.fetchCoinsToPriceInfo",
70
- expirationSeconds: 300,
71
- callback: (inputs) => __awaiter(this, void 0, void 0, function* () {
72
- const { coins } = inputs;
73
- // filter regular vs LP coins
74
- const [lpCoins, regularCoins] = yield utils_1.Helpers.bifilterAsync(coins, (coin) => __awaiter(this, void 0, void 0, function* () {
75
- return this.Provider.Pools().fetchIsLpCoinType({
76
- lpCoinType: coin,
77
- });
78
- }));
79
- const allSuiCoinData = yield this.fetchAllSuiCoinData();
80
- const neededCoinData = utils_1.Helpers.filterObject(allSuiCoinData, (coin) => regularCoins
81
- .map(utils_1.Helpers.addLeadingZeroesToType)
82
- .includes(utils_1.Helpers.addLeadingZeroesToType(coin)));
83
- const coinsToApiId = Object.entries(neededCoinData).reduce((acc, [coin, data]) => (Object.assign(Object.assign({}, acc), { [coin]: data.apiId })), {});
84
- // get coin price info for regular coins and calc info for LP coins
85
- const [regularCoinsToPriceInfo, lpCoinsToPrice, missingRegularCoins,] = yield Promise.all([
86
- this.fetchCoinsToPriceInfoInternal({ coinsToApiId }),
87
- this.Provider.Pools().fetchLpCoinsToPrice({ lpCoins }),
88
- new routerPricesApi_1.RouterPricesApi(this.Provider).fetchCoinsToPriceInfo({
89
- coins: coins.filter((coin) => !Object.keys(neededCoinData)
90
- .map(utils_1.Helpers.addLeadingZeroesToType)
91
- .includes(utils_1.Helpers.addLeadingZeroesToType(coin))),
92
- }),
93
- ]);
94
- const lpCoinsToPriceInfo = Object.entries(lpCoinsToPrice).reduce((acc, [coin, price]) => (Object.assign(Object.assign({}, acc), { [coin]: {
95
- price,
96
- priceChange24HoursPercentage: 0,
97
- } })), {});
98
- // merge all collected data
99
- const allInfo = Object.assign(Object.assign(Object.assign({}, missingRegularCoins), lpCoinsToPriceInfo), regularCoinsToPriceInfo);
100
- return allInfo;
101
- }),
102
- });
103
- // =========================================================================
104
- // Non-Interface Methods
105
- // =========================================================================
106
- this.fetchCoinsToPriceGivenApiIds = (inputs) => __awaiter(this, void 0, void 0, function* () {
107
- const coinsToPriceInfo = yield this.fetchCoinsToPriceInfoInternal(inputs);
108
- const coinsToPrice = Object.entries(coinsToPriceInfo).reduce((acc, [coinType, info]) => (Object.assign(Object.assign({}, acc), { [coinType]: info.price })), {});
109
- return coinsToPrice;
110
- });
111
- }
112
- }
113
- exports.CoinGeckoPricesApi = CoinGeckoPricesApi;
@@ -1 +0,0 @@
1
- {"version":3,"file":"coinGeckoTypes.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/coingecko/coinGeckoTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAc,MAAM,gBAAgB,CAAC;AAUlE,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAMxC,MAAM,WAAW,iBAAiB;IACjC,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;CACnB;AAED,MAAM,WAAW,uBAAuB;IACvC,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;CACnB"}
@@ -1,20 +0,0 @@
1
- import { CoinPriceInfo, CoinSymbol, CoinSymbolsToPriceInfo, CoinType } from "../../../types";
2
- import { CoinGeckoCoinApiId } from "../coingecko/coinGeckoTypes";
3
- import { PricesApiInterface } from "../pricesApiInterface";
4
- export declare class PlaceholderPricesApi implements PricesApiInterface {
5
- private static readonly constants;
6
- fetchPrice: (inputs: {
7
- coin: CoinType;
8
- }) => Promise<number>;
9
- fetchCoinsToPrice: (inputs: {
10
- coins: CoinType[];
11
- }) => Promise<Record<string, number>>;
12
- fetchCoinsToPriceInfo: (inputs: {
13
- coins: CoinType[];
14
- }) => Promise<Record<CoinType, CoinPriceInfo>>;
15
- fetchCoinSymbolsToPriceInfo(inputs: {
16
- coinSymbolsToApiId: Record<CoinSymbol, CoinGeckoCoinApiId>;
17
- }): Promise<CoinSymbolsToPriceInfo>;
18
- private fetchPrices;
19
- }
20
- //# sourceMappingURL=placeholderPricesApi.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"placeholderPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/placeholder/placeholderPricesApi.ts"],"names":[],"mappings":"AACA,OAAO,EACN,aAAa,EACb,UAAU,EACV,sBAAsB,EACtB,QAAQ,EAER,MAAM,gBAAgB,CAAC;AACxB,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,CAU/B;IAcK,UAAU,WAAkB;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,qBAEnD;IAEK,iBAAiB,WAAkB;QAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;KAAE,qCAe7D;IAEK,qBAAqB,WAAkB;QAC7C,KAAK,EAAE,QAAQ,EAAE,CAAC;KAClB,KAAG,QAAQ,OAAO,QAAQ,EAAE,aAAa,CAAC,CAAC,CAoB1C;IAEW,2BAA2B,CAAC,MAAM,EAAE;QAChD,kBAAkB,EAAE,MAAM,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;KAC3D,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAmBnC,OAAO,CAAC,WAAW,CAUjB;CACF"}
@@ -1,85 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
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
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PlaceholderPricesApi = void 0;
13
- const coin_1 = require("../../../packages/coin/coin");
14
- class PlaceholderPricesApi {
15
- constructor() {
16
- // =========================================================================
17
- // Constants
18
- // =========================================================================
19
- // =========================================================================
20
- // Fetching
21
- // =========================================================================
22
- // =========================================================================
23
- // Public
24
- // =========================================================================
25
- // =========================================================================
26
- // Interface Methods
27
- // =========================================================================
28
- this.fetchPrice = (inputs) => __awaiter(this, void 0, void 0, function* () {
29
- return (yield this.fetchPrices([inputs.coin]))[0];
30
- });
31
- this.fetchCoinsToPrice = (inputs) => __awaiter(this, void 0, void 0, function* () {
32
- const { coins } = inputs;
33
- const prices = yield this.fetchPrices(coins);
34
- const coinsToPrice = coins.reduce((acc, coin, index) => {
35
- return Object.assign(Object.assign({}, acc), { [coin]: prices[index] });
36
- }, {});
37
- return coinsToPrice;
38
- });
39
- this.fetchCoinsToPriceInfo = (inputs) => __awaiter(this, void 0, void 0, function* () {
40
- const { coins } = inputs;
41
- if (coins.length <= 0)
42
- return {};
43
- const coinsToPrice = yield this.fetchCoinsToPrice({
44
- coins,
45
- });
46
- const coinsInfo = Object.entries(coinsToPrice).reduce((acc, [coin, price]) => (Object.assign(Object.assign({}, acc), { [coin]: {
47
- price,
48
- priceChange24HoursPercentage: Math.random() > 0.5 ? 0 : (Math.random() - 0.5) / 10,
49
- } })), {});
50
- return coinsInfo;
51
- });
52
- // =========================================================================
53
- // Private
54
- // =========================================================================
55
- this.fetchPrices = (coins) => __awaiter(this, void 0, void 0, function* () {
56
- const prices = coins.map((coin) => {
57
- var _a;
58
- const foundPrice = Object.entries(PlaceholderPricesApi.constants.prices).find(([coinSymbol, price]) => new coin_1.Coin(coin).coinTypeSymbol.toLowerCase().includes(coinSymbol));
59
- return (_a = foundPrice === null || foundPrice === void 0 ? void 0 : foundPrice[1]) !== null && _a !== void 0 ? _a : -1;
60
- });
61
- return prices;
62
- });
63
- }
64
- fetchCoinSymbolsToPriceInfo(inputs) {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- // TODO: check constants for better fake data ?
67
- return Object.keys(inputs.coinSymbolsToApiId).reduce((acc, symbol) => (Object.assign(Object.assign({}, acc), { [symbol]: {
68
- price: Math.random() * 1000,
69
- priceChange24HoursPercentage: Math.random() > 0.5 ? 0 : (Math.random() - 0.5) / 10,
70
- } })), {});
71
- });
72
- }
73
- }
74
- exports.PlaceholderPricesApi = PlaceholderPricesApi;
75
- PlaceholderPricesApi.constants = {
76
- prices: {
77
- usd: 1,
78
- dai: 1,
79
- sui: 0.6179,
80
- eth: 1754.5,
81
- btc: 25957,
82
- af: 5.19,
83
- buck: 1,
84
- },
85
- };
@@ -1,13 +0,0 @@
1
- import { CoinPriceInfo, CoinType } from "../../types";
2
- export interface PricesApiInterface {
3
- fetchPrice: (inputs: {
4
- coin: CoinType;
5
- }) => Promise<number>;
6
- fetchCoinsToPrice: (inputs: {
7
- coins: CoinType[];
8
- }) => Promise<Record<CoinType, number>>;
9
- fetchCoinsToPriceInfo: (inputs: {
10
- coins: CoinType[];
11
- }) => Promise<Record<CoinType, CoinPriceInfo>>;
12
- }
13
- //# sourceMappingURL=pricesApiInterface.d.ts.map
@@ -1 +0,0 @@
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;AAEtD,MAAM,WAAW,kBAAkB;IAClC,UAAU,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAE5D,iBAAiB,EAAE,CAAC,MAAM,EAAE;QAC3B,KAAK,EAAE,QAAQ,EAAE,CAAC;KAClB,KAAK,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAExC,qBAAqB,EAAE,CAAC,MAAM,EAAE;QAC/B,KAAK,EAAE,QAAQ,EAAE,CAAC;KAClB,KAAK,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;CAC/C"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=pythPricesApi.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pythPricesApi.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/pyth/pythPricesApi.ts"],"names":[],"mappings":""}
@@ -1,52 +0,0 @@
1
- "use strict";
2
- // import { CoinSymbolToCoinTypes, CoinType } from "../../../types";
3
- // import { PricesApiInterface } from "../pricesApiInterface";
4
- // import { PythPricesApiHelpers } from "./pythPricesApiHelpers";
5
- Object.defineProperty(exports, "__esModule", { value: true });
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
- // }
@@ -1,13 +0,0 @@
1
- import { SuiPriceServiceConnection } from "@pythnetwork/pyth-sui-js";
2
- import { CoinSymbol, CoinSymbolToCoinTypes, CoinType, UniqueId, Url } from "../../../types";
3
- export declare class PythPricesApiHelpers {
4
- private readonly coinSymbolToCoinTypes;
5
- static readonly constants: {
6
- priceFeedsEndpoint: Url;
7
- priceFeedIds: Record<CoinSymbol, UniqueId>;
8
- };
9
- protected readonly connection: SuiPriceServiceConnection;
10
- constructor(coinSymbolToCoinTypes: CoinSymbolToCoinTypes);
11
- protected fetchPriceFeeds: (coins: CoinType[]) => Promise<(import("@pythnetwork/price-service-sdk").Price | undefined)[]>;
12
- }
13
- //# sourceMappingURL=pythPricesApiHelpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pythPricesApiHelpers.d.ts","sourceRoot":"","sources":["../../../../src/general/prices/pyth/pythPricesApiHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EACN,UAAU,EACV,qBAAqB,EACrB,QAAQ,EACR,QAAQ,EACR,GAAG,EACH,MAAM,gBAAgB,CAAC;AAIxB,qBAAa,oBAAoB;IAoCpB,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IA/BlD,gBAAuB,SAAS,EAAE;QACjC,kBAAkB,EAAE,GAAG,CAAC;QACxB,YAAY,EAAE,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;KAC3C,CAgBC;IAMF,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,yBAAyB,CAAC;gBAM5B,qBAAqB,EAAE,qBAAqB;IAgBzE,SAAS,CAAC,eAAe,UAAiB,QAAQ,EAAE,6EAmClD;CACF"}