@riocrypto/common-server 1.0.2183 → 1.0.2185
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.
- package/build/index.d.ts +0 -2
- package/build/index.js +0 -2
- package/build/models/rio-settings.d.ts +1 -1
- package/package.json +1 -1
- package/build/helpers/get-asset-price.d.ts +0 -3
- package/build/helpers/get-asset-price.js +0 -23
- package/build/helpers/get-exchange-rates.d.ts +0 -8
- package/build/helpers/get-exchange-rates.js +0 -85
package/build/index.d.ts
CHANGED
|
@@ -101,14 +101,12 @@ export * from "./helpers/get-processor-fees";
|
|
|
101
101
|
export * from "./helpers/get-network-fees";
|
|
102
102
|
export * from "./helpers/calculate-aggregate-volume-and-revenue";
|
|
103
103
|
export * from "./helpers/calculate-volume-and-revenue";
|
|
104
|
-
export * from "./helpers/get-exchange-rates";
|
|
105
104
|
export * from "./helpers/get-user";
|
|
106
105
|
export * from "./helpers/unescape";
|
|
107
106
|
export * from "./helpers/get-user-transaction-limits";
|
|
108
107
|
export * from "./helpers/sanitize-user-doc";
|
|
109
108
|
export * from "./helpers/get-currency-api-exchange-rates";
|
|
110
109
|
export * from "./helpers/get-tax-rate";
|
|
111
|
-
export * from "./helpers/get-asset-price";
|
|
112
110
|
export * from "./helpers/generate-payment-reference";
|
|
113
111
|
export * from "./helpers/get-order-from-reference";
|
|
114
112
|
export * from "./helpers/send-with-xss-guard";
|
package/build/index.js
CHANGED
|
@@ -117,14 +117,12 @@ __exportStar(require("./helpers/get-processor-fees"), exports);
|
|
|
117
117
|
__exportStar(require("./helpers/get-network-fees"), exports);
|
|
118
118
|
__exportStar(require("./helpers/calculate-aggregate-volume-and-revenue"), exports);
|
|
119
119
|
__exportStar(require("./helpers/calculate-volume-and-revenue"), exports);
|
|
120
|
-
__exportStar(require("./helpers/get-exchange-rates"), exports);
|
|
121
120
|
__exportStar(require("./helpers/get-user"), exports);
|
|
122
121
|
__exportStar(require("./helpers/unescape"), exports);
|
|
123
122
|
__exportStar(require("./helpers/get-user-transaction-limits"), exports);
|
|
124
123
|
__exportStar(require("./helpers/sanitize-user-doc"), exports);
|
|
125
124
|
__exportStar(require("./helpers/get-currency-api-exchange-rates"), exports);
|
|
126
125
|
__exportStar(require("./helpers/get-tax-rate"), exports);
|
|
127
|
-
__exportStar(require("./helpers/get-asset-price"), exports);
|
|
128
126
|
__exportStar(require("./helpers/generate-payment-reference"), exports);
|
|
129
127
|
__exportStar(require("./helpers/get-order-from-reference"), exports);
|
|
130
128
|
__exportStar(require("./helpers/send-with-xss-guard"), exports);
|
|
@@ -100,4 +100,4 @@ interface RioSettingsModel extends mongoose.Model<RioSettingsDoc> {
|
|
|
100
100
|
build(attrs: RioSettingsAttrs): RioSettingsDoc;
|
|
101
101
|
}
|
|
102
102
|
declare const buildRioSettings: (mongoose: typeof mongoose) => RioSettingsModel;
|
|
103
|
-
export { buildRioSettings,
|
|
103
|
+
export { buildRioSettings, RioSettingsDoc, RioSettingsAttrs };
|
package/package.json
CHANGED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getAssetPrice = void 0;
|
|
13
|
-
const market_data_1 = require("../models/market-data");
|
|
14
|
-
const getAssetPrice = (mongoose, crypto) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
const MarketData = (0, market_data_1.buildMarketData)(mongoose);
|
|
16
|
-
const marketData = yield MarketData.findOne();
|
|
17
|
-
if (!marketData) {
|
|
18
|
-
throw new Error("Market data not found");
|
|
19
|
-
}
|
|
20
|
-
const assetPriceInUSD = marketData.assetPricesInUSD[crypto].value;
|
|
21
|
-
return assetPriceInUSD;
|
|
22
|
-
});
|
|
23
|
-
exports.getAssetPrice = getAssetPrice;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Fiat, Side } from "@riocrypto/common";
|
|
2
|
-
import { Mongoose } from "mongoose";
|
|
3
|
-
export declare const getExchangeRates: (mongoose: Mongoose, fiat: Fiat, side: Side) => Promise<{
|
|
4
|
-
conversionRateToUSD: number;
|
|
5
|
-
conversionRateToUSDWithMarkups?: number | undefined;
|
|
6
|
-
conversionRateFromUSD: number;
|
|
7
|
-
conversionRateFromUSDWithMarkups?: number | undefined;
|
|
8
|
-
}>;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getExchangeRates = void 0;
|
|
13
|
-
const common_1 = require("@riocrypto/common");
|
|
14
|
-
const rio_settings_1 = require("../models/rio-settings");
|
|
15
|
-
const market_data_1 = require("../models/market-data");
|
|
16
|
-
const getExchangeRates = (mongoose, fiat, side) => __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 MarketData = (0, market_data_1.buildMarketData)(mongoose);
|
|
23
|
-
const marketData = yield MarketData.findOne();
|
|
24
|
-
if (!marketData) {
|
|
25
|
-
throw new Error("Market data not found");
|
|
26
|
-
}
|
|
27
|
-
const afterHoursExchangeRateMarkup = side === common_1.Side.Buy
|
|
28
|
-
? rioSettings.buyOrderAfterHoursExchangeRateMarkup
|
|
29
|
-
: rioSettings.sellOrderAfterHoursExchangeRateMarkup;
|
|
30
|
-
const generalExchangeRateMarkup = side === common_1.Side.Buy
|
|
31
|
-
? rioSettings.buyOrderGeneralExchangeRateMarkup
|
|
32
|
-
: rioSettings.sellOrderGeneralExchangeRateMarkup;
|
|
33
|
-
const conversionRateToUSD = marketData.conversionRatesToUSD[fiat].value;
|
|
34
|
-
let conversionRateFromUSD = marketData.conversionRatesFromUSD[fiat].value;
|
|
35
|
-
let conversionRateToUSDWithMarkups = conversionRateToUSD;
|
|
36
|
-
let conversionRateFromUSDWithMarkups = conversionRateFromUSD;
|
|
37
|
-
// Time based markups
|
|
38
|
-
if (fiat === common_1.Fiat.PEN) {
|
|
39
|
-
if (rioSettings.isAfterHours[common_1.Country.Peru].value) {
|
|
40
|
-
conversionRateToUSDWithMarkups =
|
|
41
|
-
conversionRateToUSDWithMarkups *
|
|
42
|
-
(1 -
|
|
43
|
-
afterHoursExchangeRateMarkup[common_1.Fiat.PEN] -
|
|
44
|
-
generalExchangeRateMarkup[common_1.Fiat.PEN]);
|
|
45
|
-
conversionRateFromUSDWithMarkups =
|
|
46
|
-
conversionRateFromUSDWithMarkups *
|
|
47
|
-
(1 -
|
|
48
|
-
afterHoursExchangeRateMarkup[common_1.Fiat.PEN] -
|
|
49
|
-
generalExchangeRateMarkup[common_1.Fiat.PEN]);
|
|
50
|
-
}
|
|
51
|
-
if (generalExchangeRateMarkup) {
|
|
52
|
-
conversionRateToUSDWithMarkups =
|
|
53
|
-
conversionRateToUSDWithMarkups *
|
|
54
|
-
(1 - generalExchangeRateMarkup[common_1.Fiat.PEN]);
|
|
55
|
-
conversionRateFromUSDWithMarkups =
|
|
56
|
-
conversionRateFromUSDWithMarkups *
|
|
57
|
-
(1 - generalExchangeRateMarkup[common_1.Fiat.PEN]);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if (fiat === common_1.Fiat.MXN) {
|
|
61
|
-
if (rioSettings.isAfterHours[common_1.Country.Mexico].value) {
|
|
62
|
-
conversionRateToUSDWithMarkups =
|
|
63
|
-
conversionRateToUSDWithMarkups *
|
|
64
|
-
(1 - afterHoursExchangeRateMarkup[common_1.Fiat.MXN]);
|
|
65
|
-
conversionRateFromUSDWithMarkups =
|
|
66
|
-
conversionRateFromUSDWithMarkups *
|
|
67
|
-
(1 - afterHoursExchangeRateMarkup[common_1.Fiat.MXN]);
|
|
68
|
-
}
|
|
69
|
-
if (generalExchangeRateMarkup) {
|
|
70
|
-
conversionRateToUSDWithMarkups =
|
|
71
|
-
conversionRateToUSDWithMarkups *
|
|
72
|
-
(1 - generalExchangeRateMarkup[common_1.Fiat.MXN]);
|
|
73
|
-
conversionRateFromUSDWithMarkups =
|
|
74
|
-
conversionRateFromUSDWithMarkups *
|
|
75
|
-
(1 - generalExchangeRateMarkup[common_1.Fiat.MXN]);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
conversionRateToUSD,
|
|
80
|
-
conversionRateToUSDWithMarkups,
|
|
81
|
-
conversionRateFromUSD,
|
|
82
|
-
conversionRateFromUSDWithMarkups,
|
|
83
|
-
};
|
|
84
|
-
});
|
|
85
|
-
exports.getExchangeRates = getExchangeRates;
|