@riocrypto/common-server 1.0.1221 → 1.0.1222
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,6 +1,6 @@
|
|
|
1
|
-
import { Country, Fiat, Processor, User } from "@riocrypto/common";
|
|
1
|
+
import { Country, Fiat, Processor, Side, User } from "@riocrypto/common";
|
|
2
2
|
import { Mongoose } from "mongoose";
|
|
3
|
-
export declare const getPlatformFees: (mongoose: Mongoose, conversionRateToUSD: number, amountFiat: number, fiat: Fiat, processor: Processor, country: Country, brokerId?: string, user?: User, markup?: number, discount?: number) => Promise<{
|
|
3
|
+
export declare const getPlatformFees: (mongoose: Mongoose, conversionRateToUSD: number, amountFiat: number, fiat: Fiat, processor: Processor, side: Side, country: Country, brokerId?: string, user?: User, markup?: number, discount?: number) => Promise<{
|
|
4
4
|
platformFeeFiat: number;
|
|
5
5
|
platformFeeFiatTax: number;
|
|
6
6
|
feesComped: boolean;
|
|
@@ -14,7 +14,7 @@ const rio_settings_1 = require("../models/rio-settings");
|
|
|
14
14
|
const common_1 = require("@riocrypto/common");
|
|
15
15
|
const user_1 = require("../models/user");
|
|
16
16
|
const calculate_aggregate_volume_and_revenue_1 = require("./calculate-aggregate-volume-and-revenue");
|
|
17
|
-
const getPlatformFees = (mongoose, conversionRateToUSD, amountFiat, fiat, processor, country, brokerId, user, markup, discount) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const getPlatformFees = (mongoose, conversionRateToUSD, amountFiat, fiat, processor, side, country, brokerId, user, markup, discount) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
var _a, _b;
|
|
19
19
|
let platformFeeFiat;
|
|
20
20
|
let platformFeeFiatTax = 0;
|
|
@@ -46,8 +46,10 @@ const getPlatformFees = (mongoose, conversionRateToUSD, amountFiat, fiat, proces
|
|
|
46
46
|
else {
|
|
47
47
|
volume = Number(amountUSD);
|
|
48
48
|
}
|
|
49
|
-
if (broker.platformFeeRanges &&
|
|
50
|
-
|
|
49
|
+
if (broker.platformFeeRanges &&
|
|
50
|
+
broker.platformFeeRanges[country] &&
|
|
51
|
+
broker.platformFeeRanges[country][side]) {
|
|
52
|
+
for (const range of broker.platformFeeRanges[country][side]) {
|
|
51
53
|
if (range.min <= Number(volume) && range.max >= Number(volume)) {
|
|
52
54
|
if (discount) {
|
|
53
55
|
if (discount > range.fee) {
|
|
@@ -84,7 +86,9 @@ const getPlatformFees = (mongoose, conversionRateToUSD, amountFiat, fiat, proces
|
|
|
84
86
|
platformFeeFiat = amountFiat * netPlatformFee;
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
|
-
else if ((user === null || user === void 0 ? void 0 : user.platformFeeRanges) &&
|
|
89
|
+
else if ((user === null || user === void 0 ? void 0 : user.platformFeeRanges) &&
|
|
90
|
+
user.platformFeeRanges[country] &&
|
|
91
|
+
user.platformFeeRanges[country][side]) {
|
|
88
92
|
let volume;
|
|
89
93
|
if ((_b = user === null || user === void 0 ? void 0 : user.attributes) === null || _b === void 0 ? void 0 : _b.includes(common_1.UserAttribute.summedVolumeFees)) {
|
|
90
94
|
const volumeAndRevenue = yield (0, calculate_aggregate_volume_and_revenue_1.calculateAggregateVolumeAndRevenue)(mongoose, 14, user);
|
|
@@ -93,7 +97,7 @@ const getPlatformFees = (mongoose, conversionRateToUSD, amountFiat, fiat, proces
|
|
|
93
97
|
else {
|
|
94
98
|
volume = Number(amountUSD);
|
|
95
99
|
}
|
|
96
|
-
for (const range of user.platformFeeRanges[country]) {
|
|
100
|
+
for (const range of user.platformFeeRanges[country][side]) {
|
|
97
101
|
if (range.min <= Number(volume) && range.max >= Number(volume)) {
|
|
98
102
|
if (discount) {
|
|
99
103
|
if (discount > range.fee) {
|
package/build/models/user.d.ts
CHANGED
|
@@ -28,11 +28,26 @@ interface UserAttrs {
|
|
|
28
28
|
ruc?: string;
|
|
29
29
|
economicActivity?: string;
|
|
30
30
|
platformFeeRanges?: {
|
|
31
|
-
MX?:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
MX?: {
|
|
32
|
+
buy?: PlatformFeeRange[];
|
|
33
|
+
sell?: PlatformFeeRange[];
|
|
34
|
+
};
|
|
35
|
+
PE?: {
|
|
36
|
+
buy?: PlatformFeeRange[];
|
|
37
|
+
sell?: PlatformFeeRange[];
|
|
38
|
+
};
|
|
39
|
+
CO?: {
|
|
40
|
+
buy?: PlatformFeeRange[];
|
|
41
|
+
sell?: PlatformFeeRange[];
|
|
42
|
+
};
|
|
43
|
+
BR?: {
|
|
44
|
+
buy?: PlatformFeeRange[];
|
|
45
|
+
sell?: PlatformFeeRange[];
|
|
46
|
+
};
|
|
47
|
+
US?: {
|
|
48
|
+
buy?: PlatformFeeRange[];
|
|
49
|
+
sell?: PlatformFeeRange[];
|
|
50
|
+
};
|
|
36
51
|
};
|
|
37
52
|
COIFile?: string;
|
|
38
53
|
KYCReportFile?: string;
|
|
@@ -80,11 +95,26 @@ interface UserDoc extends Document {
|
|
|
80
95
|
attributes?: UserAttribute[];
|
|
81
96
|
brokerId?: string;
|
|
82
97
|
platformFeeRanges?: {
|
|
83
|
-
MX?:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
MX?: {
|
|
99
|
+
buy?: PlatformFeeRange[];
|
|
100
|
+
sell?: PlatformFeeRange[];
|
|
101
|
+
};
|
|
102
|
+
PE?: {
|
|
103
|
+
buy?: PlatformFeeRange[];
|
|
104
|
+
sell?: PlatformFeeRange[];
|
|
105
|
+
};
|
|
106
|
+
CO?: {
|
|
107
|
+
buy?: PlatformFeeRange[];
|
|
108
|
+
sell?: PlatformFeeRange[];
|
|
109
|
+
};
|
|
110
|
+
BR?: {
|
|
111
|
+
buy?: PlatformFeeRange[];
|
|
112
|
+
sell?: PlatformFeeRange[];
|
|
113
|
+
};
|
|
114
|
+
US?: {
|
|
115
|
+
buy?: PlatformFeeRange[];
|
|
116
|
+
sell?: PlatformFeeRange[];
|
|
117
|
+
};
|
|
88
118
|
};
|
|
89
119
|
COIFile?: string;
|
|
90
120
|
KYCReportFile?: string;
|
package/build/models/user.js
CHANGED
|
@@ -115,86 +115,176 @@ const buildUser = (mongoose) => {
|
|
|
115
115
|
type: String,
|
|
116
116
|
},
|
|
117
117
|
platformFeeRanges: {
|
|
118
|
-
MX:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
MX: {
|
|
119
|
+
buy: [
|
|
120
|
+
{
|
|
121
|
+
min: {
|
|
122
|
+
type: Number,
|
|
123
|
+
required: true,
|
|
124
|
+
},
|
|
125
|
+
max: {
|
|
126
|
+
type: Number,
|
|
127
|
+
required: true,
|
|
128
|
+
},
|
|
129
|
+
fee: {
|
|
130
|
+
type: Number,
|
|
131
|
+
required: true,
|
|
132
|
+
},
|
|
123
133
|
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
134
|
+
],
|
|
135
|
+
sell: [
|
|
136
|
+
{
|
|
137
|
+
min: {
|
|
138
|
+
type: Number,
|
|
139
|
+
required: true,
|
|
140
|
+
},
|
|
141
|
+
max: {
|
|
142
|
+
type: Number,
|
|
143
|
+
required: true,
|
|
144
|
+
},
|
|
145
|
+
fee: {
|
|
146
|
+
type: Number,
|
|
147
|
+
required: true,
|
|
148
|
+
},
|
|
127
149
|
},
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
type: Number,
|
|
146
|
-
required: true,
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
],
|
|
150
|
-
PE: [
|
|
151
|
-
{
|
|
152
|
-
min: {
|
|
153
|
-
type: Number,
|
|
154
|
-
required: true,
|
|
155
|
-
},
|
|
156
|
-
max: {
|
|
157
|
-
type: Number,
|
|
158
|
-
required: true,
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
US: {
|
|
153
|
+
buy: [
|
|
154
|
+
{
|
|
155
|
+
min: {
|
|
156
|
+
type: Number,
|
|
157
|
+
required: true,
|
|
158
|
+
},
|
|
159
|
+
max: {
|
|
160
|
+
type: Number,
|
|
161
|
+
required: true,
|
|
162
|
+
},
|
|
163
|
+
fee: {
|
|
164
|
+
type: Number,
|
|
165
|
+
required: true,
|
|
166
|
+
},
|
|
159
167
|
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
168
|
+
],
|
|
169
|
+
sell: [
|
|
170
|
+
{
|
|
171
|
+
min: {
|
|
172
|
+
type: Number,
|
|
173
|
+
required: true,
|
|
174
|
+
},
|
|
175
|
+
max: {
|
|
176
|
+
type: Number,
|
|
177
|
+
required: true,
|
|
178
|
+
},
|
|
179
|
+
fee: {
|
|
180
|
+
type: Number,
|
|
181
|
+
required: true,
|
|
182
|
+
},
|
|
163
183
|
},
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
PE: {
|
|
187
|
+
buy: [
|
|
188
|
+
{
|
|
189
|
+
min: {
|
|
190
|
+
type: Number,
|
|
191
|
+
required: true,
|
|
192
|
+
},
|
|
193
|
+
max: {
|
|
194
|
+
type: Number,
|
|
195
|
+
required: true,
|
|
196
|
+
},
|
|
197
|
+
fee: {
|
|
198
|
+
type: Number,
|
|
199
|
+
required: true,
|
|
200
|
+
},
|
|
171
201
|
},
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
202
|
+
],
|
|
203
|
+
sell: [
|
|
204
|
+
{
|
|
205
|
+
min: {
|
|
206
|
+
type: Number,
|
|
207
|
+
required: true,
|
|
208
|
+
},
|
|
209
|
+
max: {
|
|
210
|
+
type: Number,
|
|
211
|
+
required: true,
|
|
212
|
+
},
|
|
213
|
+
fee: {
|
|
214
|
+
type: Number,
|
|
215
|
+
required: true,
|
|
216
|
+
},
|
|
175
217
|
},
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
218
|
+
],
|
|
219
|
+
},
|
|
220
|
+
CO: {
|
|
221
|
+
buy: [
|
|
222
|
+
{
|
|
223
|
+
min: {
|
|
224
|
+
type: Number,
|
|
225
|
+
required: true,
|
|
226
|
+
},
|
|
227
|
+
max: {
|
|
228
|
+
type: Number,
|
|
229
|
+
required: true,
|
|
230
|
+
},
|
|
231
|
+
fee: {
|
|
232
|
+
type: Number,
|
|
233
|
+
required: true,
|
|
234
|
+
},
|
|
179
235
|
},
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
236
|
+
],
|
|
237
|
+
sell: [
|
|
238
|
+
{
|
|
239
|
+
min: {
|
|
240
|
+
type: Number,
|
|
241
|
+
required: true,
|
|
242
|
+
},
|
|
243
|
+
max: {
|
|
244
|
+
type: Number,
|
|
245
|
+
required: true,
|
|
246
|
+
},
|
|
247
|
+
fee: {
|
|
248
|
+
type: Number,
|
|
249
|
+
required: true,
|
|
250
|
+
},
|
|
187
251
|
},
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
252
|
+
],
|
|
253
|
+
},
|
|
254
|
+
BR: {
|
|
255
|
+
buy: [
|
|
256
|
+
{
|
|
257
|
+
min: {
|
|
258
|
+
type: Number,
|
|
259
|
+
required: true,
|
|
260
|
+
},
|
|
261
|
+
max: {
|
|
262
|
+
type: Number,
|
|
263
|
+
required: true,
|
|
264
|
+
},
|
|
265
|
+
fee: {
|
|
266
|
+
type: Number,
|
|
267
|
+
required: true,
|
|
268
|
+
},
|
|
191
269
|
},
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
270
|
+
],
|
|
271
|
+
sell: [
|
|
272
|
+
{
|
|
273
|
+
min: {
|
|
274
|
+
type: Number,
|
|
275
|
+
required: true,
|
|
276
|
+
},
|
|
277
|
+
max: {
|
|
278
|
+
type: Number,
|
|
279
|
+
required: true,
|
|
280
|
+
},
|
|
281
|
+
fee: {
|
|
282
|
+
type: Number,
|
|
283
|
+
required: true,
|
|
284
|
+
},
|
|
195
285
|
},
|
|
196
|
-
|
|
197
|
-
|
|
286
|
+
],
|
|
287
|
+
},
|
|
198
288
|
},
|
|
199
289
|
authorizedPhoneNumbers: [
|
|
200
290
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1222",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@aws-sdk/client-s3": "^3.297.0",
|
|
27
27
|
"@everapi/currencyapi-js": "^1.0.6",
|
|
28
28
|
"@google-cloud/storage": "^6.9.5",
|
|
29
|
-
"@riocrypto/common": "^1.0.
|
|
29
|
+
"@riocrypto/common": "^1.0.1115",
|
|
30
30
|
"@types/express": "^4.17.13",
|
|
31
31
|
"axios": "^0.27.2",
|
|
32
32
|
"ccxt": "^3.0.30",
|