@riocrypto/common-server 1.0.652 → 1.0.654

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.
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.buildCurrencyAPIClient = void 0;
16
+ const common_1 = require("@riocrypto/common");
16
17
  const axios_1 = __importDefault(require("axios"));
17
18
  const secret_manager_client_1 = require("./secret-manager-client");
18
19
  const node_cache_1 = __importDefault(require("node-cache"));
@@ -34,7 +35,17 @@ class CurrencyAPIClient {
34
35
  exchangeRate = currencyAPIResponse.data.data[to].value;
35
36
  cache.set(`v3/latest?apikey=${this.apiKey}&base_currency=${from}&currencies=${to}`, currencyAPIResponse.data);
36
37
  }
37
- const rioExchangeRate = to === from ? exchangeRate : exchangeRate * 0.999;
38
+ let exchangeRateMultiplier = 0.999;
39
+ if (from === common_1.Fiat.PEN || to === common_1.Fiat.PEN) {
40
+ const now = new Date();
41
+ const peruTimezoneOffset = -5; // Peru is in the UTC-5 time zone
42
+ const peruTime = new Date(now.getTime() + peruTimezoneOffset * 60 * 60 * 1000);
43
+ const isPastSixPmInPeru = peruTime.getHours() >= 18;
44
+ if (isPastSixPmInPeru) {
45
+ exchangeRateMultiplier = 0.997;
46
+ }
47
+ }
48
+ const rioExchangeRate = to === from ? exchangeRate : exchangeRate * exchangeRateMultiplier;
38
49
  return rioExchangeRate;
39
50
  }
40
51
  catch (e) {
@@ -43,7 +54,17 @@ class CurrencyAPIClient {
43
54
  throw new Error(`Unable to get exchange rate from currencyAPI for ${from} to ${to}`);
44
55
  }
45
56
  const exchangeRate = cachedResponse.data[to].value;
46
- const rioExchangeRate = to === from ? exchangeRate : exchangeRate * 0.999;
57
+ let exchangeRateMultiplier = 0.999;
58
+ if (from === common_1.Fiat.PEN || to === common_1.Fiat.PEN) {
59
+ const now = new Date();
60
+ const peruTimezoneOffset = -5; // Peru is in the UTC-5 time zone
61
+ const peruTime = new Date(now.getTime() + peruTimezoneOffset * 60 * 60 * 1000);
62
+ const isPastSixPmInPeru = peruTime.getHours() >= 18;
63
+ if (isPastSixPmInPeru) {
64
+ exchangeRateMultiplier = 0.997;
65
+ }
66
+ }
67
+ const rioExchangeRate = to === from ? exchangeRate : exchangeRate * exchangeRateMultiplier;
47
68
  return rioExchangeRate;
48
69
  }
49
70
  });
@@ -8,6 +8,8 @@ interface PartnerAttrs {
8
8
  platformFee: number;
9
9
  color?: string;
10
10
  logo?: string;
11
+ logoDark?: string;
12
+ feesComped?: boolean;
11
13
  }
12
14
  interface PartnerDoc extends Document {
13
15
  authId: string;
@@ -18,6 +20,7 @@ interface PartnerDoc extends Document {
18
20
  color?: string;
19
21
  logo?: string;
20
22
  logoDark?: string;
23
+ feesComped?: boolean;
21
24
  }
22
25
  interface PartnerModel extends Model<PartnerDoc> {
23
26
  build(attrs: PartnerAttrs): PartnerDoc;
@@ -36,6 +36,9 @@ const buildPartner = (mongoose) => {
36
36
  logoDark: {
37
37
  type: String,
38
38
  },
39
+ feesComped: {
40
+ type: Boolean,
41
+ },
39
42
  }, {
40
43
  toJSON: {
41
44
  transform(doc, ret) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.652",
3
+ "version": "1.0.654",
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.595",
27
+ "@riocrypto/common": "^1.0.596",
28
28
  "@types/express": "^4.17.13",
29
29
  "axios": "^0.27.2",
30
30
  "ccxt": "^3.0.30",