@riocrypto/common-server 1.0.1323 → 1.0.1324

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.
@@ -2,7 +2,10 @@ import { Fiat } from "@riocrypto/common";
2
2
  declare class PolygonClient {
3
3
  private apiKey;
4
4
  constructor(apiKey: string);
5
- getExchangeRate(from: Fiat, to: Fiat): Promise<number>;
5
+ getExchangeRateData(from: Fiat, to: Fiat): Promise<{
6
+ ask: number;
7
+ bid: number;
8
+ }>;
6
9
  }
7
10
  export declare const buildPolygonClient: () => Promise<PolygonClient>;
8
11
  export {};
@@ -20,10 +20,10 @@ class PolygonClient {
20
20
  constructor(apiKey) {
21
21
  this.apiKey = apiKey;
22
22
  }
23
- getExchangeRate(from, to) {
23
+ getExchangeRateData(from, to) {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  const { data } = yield axios_1.default.get(`https://api.polygon.io/v1/last_quote/currencies/${from}/${to}?apiKey=${this.apiKey}`);
26
- return data.last.bid;
26
+ return data.last;
27
27
  });
28
28
  }
29
29
  }
@@ -18,10 +18,10 @@ const getExchangeRates = (fiat) => __awaiter(void 0, void 0, void 0, function* (
18
18
  const kapstarClient = yield (0, kapstar_client_1.buildKapstarClient)();
19
19
  const conversionRateToUSD = fiat === common_1.Fiat.BRL
20
20
  ? yield kapstarClient.getBRLExchangeRateUSD()
21
- : yield polygonClient.getExchangeRate(fiat, common_1.Fiat.USD);
21
+ : (yield polygonClient.getExchangeRateData(fiat, common_1.Fiat.USD)).ask;
22
22
  let conversionRateFromUSD = fiat === common_1.Fiat.BRL
23
23
  ? 1 / conversionRateToUSD
24
- : yield polygonClient.getExchangeRate(common_1.Fiat.USD, fiat);
24
+ : (yield polygonClient.getExchangeRateData(common_1.Fiat.USD, fiat)).bid;
25
25
  let conversionRateToUSDWithMarkups = conversionRateToUSD;
26
26
  let conversionRateFromUSDWithMarkups = conversionRateFromUSD;
27
27
  // Time based markups
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1323",
3
+ "version": "1.0.1324",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",