@riocrypto/common-server 1.0.794 → 1.0.797

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.
@@ -18,37 +18,19 @@ const getExchangeRates = (from, to) => __awaiter(void 0, void 0, void 0, functio
18
18
  const currencyAPIClient = yield (0, currency_api_client_1.buildCurrencyAPIClient)();
19
19
  const { startDate, endDate } = getDateRange();
20
20
  const data = yield currencyAPIClient.getHistoricalExchangeRates(from, to, startDate.toISOString(), endDate.toISOString());
21
- const values = data.map((point) => point.currencies.MXN.value);
21
+ const values = data.map((point) => point.currencies[to].value);
22
22
  const average = values.reduce((sum, value) => sum + value, 0) / values.length;
23
23
  const squaredDeviations = values.map((value) => (value - average) ** 2);
24
24
  const variance = squaredDeviations.reduce((sum, deviation) => sum + deviation, 0) /
25
25
  values.length;
26
26
  const volatility = Math.sqrt(variance);
27
- const currentPrice = values[values.length - 1];
28
- const previousPrice = values[values.length - 2];
29
- const priceChange = currentPrice - previousPrice;
30
- let priceDirection;
31
- if (Math.abs(priceChange) > volatility) {
32
- priceDirection = priceChange > 0 ? "increase" : "decrease";
33
- }
34
- else {
35
- priceDirection = "stable";
36
- }
37
27
  const maximumPriceChange = volatility * QUOTE_DURATION_MINUTES;
38
28
  const kapstarClient = yield (0, kapstar_client_1.buildKapstarClient)();
39
29
  const conversionRate = to === common_1.Fiat.BRL
40
30
  ? yield kapstarClient.getBRLExchangeRateUSD()
41
31
  : yield currencyAPIClient.convert(from, to);
42
32
  let conversionRateWithVolatilityMarkup;
43
- if (priceDirection === "increase") {
44
- conversionRateWithVolatilityMarkup = conversionRate + maximumPriceChange;
45
- }
46
- else if (priceDirection === "decrease") {
47
- conversionRateWithVolatilityMarkup = conversionRate - maximumPriceChange;
48
- }
49
- else {
50
- conversionRateWithVolatilityMarkup = conversionRate;
51
- }
33
+ conversionRateWithVolatilityMarkup = conversionRate + maximumPriceChange;
52
34
  let exchangeRateMultiplier = 0.999;
53
35
  if (from === common_1.Fiat.PEN || to === common_1.Fiat.PEN) {
54
36
  const now = new Date();
package/build/index.d.ts CHANGED
@@ -46,4 +46,4 @@ export * from "./helpers/get-platform-and-partner-fees";
46
46
  export * from "./helpers/get-processor-fees";
47
47
  export * from "./helpers/get-network-fees";
48
48
  export * from "./helpers/calculate-aggregate-volume";
49
- export * from "./helpers/getExchangeRates";
49
+ export * from "./helpers/get-exchange-rates";
package/build/index.js CHANGED
@@ -62,4 +62,4 @@ __exportStar(require("./helpers/get-platform-and-partner-fees"), exports);
62
62
  __exportStar(require("./helpers/get-processor-fees"), exports);
63
63
  __exportStar(require("./helpers/get-network-fees"), exports);
64
64
  __exportStar(require("./helpers/calculate-aggregate-volume"), exports);
65
- __exportStar(require("./helpers/getExchangeRates"), exports);
65
+ __exportStar(require("./helpers/get-exchange-rates"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.794",
3
+ "version": "1.0.797",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "@aws-sdk/client-s3": "^3.297.0",
25
25
  "@everapi/currencyapi-js": "^1.0.6",
26
26
  "@google-cloud/storage": "^6.9.5",
27
- "@riocrypto/common": "^1.0.691",
27
+ "@riocrypto/common": "^1.0.692",
28
28
  "@types/express": "^4.17.13",
29
29
  "axios": "^0.27.2",
30
30
  "ccxt": "^3.0.30",