@riocrypto/common-server 1.0.652 → 1.0.653
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}¤cies=${to}`, currencyAPIResponse.data);
|
|
36
37
|
}
|
|
37
|
-
|
|
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
|
-
|
|
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
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.653",
|
|
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.
|
|
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",
|