@riocrypto/common-server 1.0.777 → 1.0.779
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.
|
@@ -16,10 +16,16 @@ const ccxt_client_1 = require("../clients/ccxt-client");
|
|
|
16
16
|
const getNetworkFees = (crypto, cryptoPrice, conversionRateToUSD) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
let withdrawFee;
|
|
18
18
|
const fireblocksClient = yield (0, fireblocks_client_1.buildFireblocksClient)();
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
if ([
|
|
20
|
+
common_1.Crypto.USDTEthereum,
|
|
21
|
+
common_1.Crypto.USDCPolygon,
|
|
22
|
+
common_1.Crypto.USDTPolygon,
|
|
23
|
+
common_1.Crypto.USDTEthereum,
|
|
24
|
+
common_1.Crypto.USDTEthereum,
|
|
25
|
+
].includes(crypto)) {
|
|
26
|
+
const address = crypto === common_1.Crypto.USDCSolana
|
|
27
|
+
? "HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH"
|
|
28
|
+
: "0x66ECBd38905CC32249ddd6f4f0B4A3DdDDCbd608";
|
|
23
29
|
withdrawFee = yield fireblocksClient.estimateWithdrawFee(crypto, address, 100);
|
|
24
30
|
if (!withdrawFee) {
|
|
25
31
|
throw new Error("Withdraw fee not set");
|
|
@@ -61,6 +61,32 @@ const getPlatformAndPartnerFees = (mongoose, amountFiat, fiat, processor, countr
|
|
|
61
61
|
platformFeeFiat = amountFiat * netPlatformFee;
|
|
62
62
|
partnerFeeFiat = amountFiat * partner.partnerFee;
|
|
63
63
|
}
|
|
64
|
+
else if (brokerId) {
|
|
65
|
+
const User = (0, user_1.buildUser)(mongoose);
|
|
66
|
+
const brokerCustomer = yield User.findById(brokerId);
|
|
67
|
+
if (!brokerCustomer) {
|
|
68
|
+
throw new Error("Broker customer not found");
|
|
69
|
+
}
|
|
70
|
+
if (brokerCustomer === null || brokerCustomer === void 0 ? void 0 : brokerCustomer.platformFeeRanges) {
|
|
71
|
+
for (const range of brokerCustomer.platformFeeRanges) {
|
|
72
|
+
if (range.min <= Number(amountUSD) && range.max >= Number(amountUSD)) {
|
|
73
|
+
if (discount) {
|
|
74
|
+
if (discount > range.fee) {
|
|
75
|
+
throw new Error("Discount cannot be greater than platform fee");
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
const netFee = range.fee - discount;
|
|
79
|
+
platformFeeFiat = amountFiat * netFee;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
platformFeeFiat = amountFiat * range.fee;
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
64
90
|
else if (user === null || user === void 0 ? void 0 : user.platformFeeRanges) {
|
|
65
91
|
let volume;
|
|
66
92
|
if ((_a = user === null || user === void 0 ? void 0 : user.attributes) === null || _a === void 0 ? void 0 : _a.includes(common_1.UserAttribute.summedVolumeFees)) {
|
|
@@ -105,32 +131,6 @@ const getPlatformAndPartnerFees = (mongoose, amountFiat, fiat, processor, countr
|
|
|
105
131
|
platformFeeFiat = amountFiat * netPlatformFee;
|
|
106
132
|
partnerFeeFiat = 0;
|
|
107
133
|
}
|
|
108
|
-
if (brokerId && !platformFeeFiat) {
|
|
109
|
-
const User = (0, user_1.buildUser)(mongoose);
|
|
110
|
-
const brokerCustomer = yield User.findById(brokerId);
|
|
111
|
-
if (!brokerCustomer) {
|
|
112
|
-
throw new Error("Broker customer not found");
|
|
113
|
-
}
|
|
114
|
-
if (brokerCustomer === null || brokerCustomer === void 0 ? void 0 : brokerCustomer.platformFeeRanges) {
|
|
115
|
-
for (const range of brokerCustomer.platformFeeRanges) {
|
|
116
|
-
if (range.min <= Number(amountUSD) && range.max >= Number(amountUSD)) {
|
|
117
|
-
if (discount) {
|
|
118
|
-
if (discount > range.fee) {
|
|
119
|
-
throw new Error("Discount cannot be greater than platform fee");
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
const netFee = range.fee - discount;
|
|
123
|
-
platformFeeFiat = amountFiat * netFee;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
platformFeeFiat = amountFiat * range.fee;
|
|
128
|
-
}
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
134
|
if ((fiat === common_1.Fiat.MXN && processor === common_1.Processor.SPEI) ||
|
|
135
135
|
(fiat === common_1.Fiat.USD && processor === common_1.Processor.SPID)) {
|
|
136
136
|
if (country === common_1.Country.Mexico) {
|
|
@@ -143,7 +143,7 @@ const getPlatformAndPartnerFees = (mongoose, amountFiat, fiat, processor, countr
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
return {
|
|
146
|
-
platformFeeFiat,
|
|
146
|
+
platformFeeFiat: platformFeeFiat,
|
|
147
147
|
platformFeeFiatTax,
|
|
148
148
|
partnerFeeFiat,
|
|
149
149
|
feesComped,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.779",
|
|
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.687",
|
|
28
28
|
"@types/express": "^4.17.13",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"ccxt": "^3.0.30",
|