@riocrypto/common-server 1.0.1008 → 1.0.1010
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,5 @@
|
|
|
1
1
|
import { Fiat } from "@riocrypto/common";
|
|
2
|
-
export declare const getExchangeRates: (from: Fiat, to: Fiat) => Promise<{
|
|
2
|
+
export declare const getExchangeRates: (from: Fiat, to: Fiat, volatilitySafeguard?: boolean) => Promise<{
|
|
3
3
|
conversionRate: number;
|
|
4
4
|
conversionRateWithVolatilityMarkup: number;
|
|
5
5
|
conversionRateWithRioMarkup: number;
|
|
@@ -14,7 +14,7 @@ const common_1 = require("@riocrypto/common");
|
|
|
14
14
|
const currency_api_client_1 = require("../clients/currency-api-client");
|
|
15
15
|
const kapstar_client_1 = require("../clients/kapstar-client");
|
|
16
16
|
const QUOTE_DURATION_MINUTES = 10;
|
|
17
|
-
const getExchangeRates = (from, to) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const getExchangeRates = (from, to, volatilitySafeguard = true) => __awaiter(void 0, void 0, void 0, function* () {
|
|
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());
|
|
@@ -29,6 +29,14 @@ const getExchangeRates = (from, to) => __awaiter(void 0, void 0, void 0, functio
|
|
|
29
29
|
const conversionRate = to === common_1.Fiat.BRL
|
|
30
30
|
? yield kapstarClient.getBRLExchangeRateUSD()
|
|
31
31
|
: yield currencyAPIClient.convert(from, to);
|
|
32
|
+
if (!volatilitySafeguard) {
|
|
33
|
+
return {
|
|
34
|
+
conversionRate,
|
|
35
|
+
conversionRateWithVolatilityMarkup: conversionRate,
|
|
36
|
+
conversionRateWithRioMarkup: conversionRate,
|
|
37
|
+
conversionRateWithAllMarkups: conversionRate,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
32
40
|
let conversionRateWithVolatilityMarkup;
|
|
33
41
|
conversionRateWithVolatilityMarkup = conversionRate - maximumPriceChange;
|
|
34
42
|
let exchangeRateMultiplier = 0.9997;
|
package/build/models/quote.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ interface QuoteAttrs {
|
|
|
17
17
|
fees: Fees;
|
|
18
18
|
price: number;
|
|
19
19
|
createdAt: Date;
|
|
20
|
+
volatilitySafeguard?: boolean;
|
|
20
21
|
partnerId?: string;
|
|
21
22
|
depositAddress?: string;
|
|
22
23
|
brokerId?: string;
|
|
@@ -42,6 +43,7 @@ interface QuoteDoc extends Document {
|
|
|
42
43
|
createdAt: Date;
|
|
43
44
|
fees: Fees;
|
|
44
45
|
price: number;
|
|
46
|
+
volatilitySafeguard?: boolean;
|
|
45
47
|
partnerId?: string;
|
|
46
48
|
depositAddress?: string;
|
|
47
49
|
brokerId?: string;
|
package/build/models/quote.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1010",
|
|
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.871",
|
|
28
28
|
"@types/express": "^4.17.13",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"ccxt": "^3.0.30",
|