@riocrypto/common-server 1.0.1436 → 1.0.1438
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Fiat } from "@riocrypto/common";
|
|
2
|
-
|
|
2
|
+
import { Mongoose } from "mongoose";
|
|
3
|
+
export declare const getExchangeRates: (mongoose: Mongoose, fiat: Fiat) => Promise<{
|
|
3
4
|
conversionRateToUSD: number;
|
|
4
5
|
conversionRateToUSDWithMarkups?: number | undefined;
|
|
5
6
|
conversionRateFromUSD: number;
|
|
@@ -12,7 +12,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.getExchangeRates = void 0;
|
|
13
13
|
const common_1 = require("@riocrypto/common");
|
|
14
14
|
const polygon_client_1 = require("../clients/polygon-client");
|
|
15
|
-
const
|
|
15
|
+
const rio_settings_1 = require("../models/rio-settings");
|
|
16
|
+
const getExchangeRates = (mongoose, fiat) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const RioSettings = (0, rio_settings_1.buildRioSettings)(mongoose);
|
|
18
|
+
const rioSettings = yield RioSettings.findOne();
|
|
19
|
+
if (!rioSettings) {
|
|
20
|
+
throw new Error("Rio settings not found");
|
|
21
|
+
}
|
|
22
|
+
const afterHoursExchangeRateMarkup = rioSettings.afterHoursExchangeRateMarkup;
|
|
16
23
|
const polygonClient = yield (0, polygon_client_1.buildPolygonClient)();
|
|
17
24
|
const conversionRateToUSD = fiat === common_1.Fiat.PEN
|
|
18
25
|
? (yield polygonClient.getExchangeRateData(fiat, common_1.Fiat.USD)).bid
|
|
@@ -30,8 +37,10 @@ const getExchangeRates = (fiat) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
30
37
|
const minutes = peruTime.getMinutes();
|
|
31
38
|
// Check if it's between 2:10 PM and 12:00 AM
|
|
32
39
|
if ((hours === 14 && minutes >= 10) || hours > 14 || hours === 0) {
|
|
33
|
-
conversionRateToUSDWithMarkups =
|
|
34
|
-
|
|
40
|
+
conversionRateToUSDWithMarkups =
|
|
41
|
+
conversionRateToUSD * (1 - afterHoursExchangeRateMarkup);
|
|
42
|
+
conversionRateFromUSDWithMarkups =
|
|
43
|
+
conversionRateFromUSD * (1 - afterHoursExchangeRateMarkup);
|
|
35
44
|
}
|
|
36
45
|
}
|
|
37
46
|
if (fiat === common_1.Fiat.MXN) {
|
|
@@ -42,12 +51,16 @@ const getExchangeRates = (fiat) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
42
51
|
if ((hours === 15 && minutes >= 45) ||
|
|
43
52
|
(hours > 15 && hours < 24) ||
|
|
44
53
|
(hours === 0 && minutes === 0)) {
|
|
45
|
-
conversionRateToUSDWithMarkups =
|
|
46
|
-
|
|
54
|
+
conversionRateToUSDWithMarkups =
|
|
55
|
+
conversionRateToUSD * (1 - afterHoursExchangeRateMarkup);
|
|
56
|
+
conversionRateFromUSDWithMarkups =
|
|
57
|
+
conversionRateFromUSD * (1 - afterHoursExchangeRateMarkup);
|
|
47
58
|
}
|
|
48
59
|
else if (hours >= 0 && hours < 7) {
|
|
49
|
-
conversionRateToUSDWithMarkups =
|
|
50
|
-
|
|
60
|
+
conversionRateToUSDWithMarkups =
|
|
61
|
+
conversionRateToUSD * (1 - afterHoursExchangeRateMarkup);
|
|
62
|
+
conversionRateFromUSDWithMarkups =
|
|
63
|
+
conversionRateFromUSD * (1 - afterHoursExchangeRateMarkup);
|
|
51
64
|
}
|
|
52
65
|
}
|
|
53
66
|
return {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
2
|
interface RioSettingsAttrs {
|
|
3
3
|
platformFee: number;
|
|
4
|
-
|
|
4
|
+
afterHoursExchangeRateMarkup: number;
|
|
5
5
|
}
|
|
6
6
|
interface RioSettingsDoc extends mongoose.Document {
|
|
7
7
|
platformFee: number;
|
|
8
|
-
|
|
8
|
+
afterHoursExchangeRateMarkup: number;
|
|
9
9
|
}
|
|
10
10
|
interface RioSettingsModel extends mongoose.Model<RioSettingsDoc> {
|
|
11
11
|
build(attrs: RioSettingsAttrs): RioSettingsDoc;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1438",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@everapi/currencyapi-js": "^1.0.6",
|
|
28
28
|
"@google-cloud/storage": "^6.9.5",
|
|
29
29
|
"@google-cloud/vision": "^4.0.2",
|
|
30
|
-
"@riocrypto/common": "^1.0.
|
|
30
|
+
"@riocrypto/common": "^1.0.1275",
|
|
31
31
|
"@types/express": "^4.17.13",
|
|
32
32
|
"axios": "^0.27.2",
|
|
33
33
|
"ccxt": "^3.0.30",
|