@riocrypto/common-server 1.0.746 → 1.0.748

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.
@@ -54,7 +54,11 @@ const getPlatformAndPartnerFees = (mongoose, amountFiat, fiat, processor, countr
54
54
  if (partner.feesComped) {
55
55
  feesComped = true;
56
56
  }
57
- platformFeeFiat = amountFiat * partner.platformFee;
57
+ if (discount > partner.platformFee) {
58
+ throw new Error("Discount cannot be greater than platform fee");
59
+ }
60
+ const netPlatformFee = partner.platformFee - discount;
61
+ platformFeeFiat = amountFiat * netPlatformFee;
58
62
  partnerFeeFiat = amountFiat * partner.partnerFee;
59
63
  }
60
64
  else if (user === null || user === void 0 ? void 0 : user.platformFeeRanges) {
@@ -85,12 +89,20 @@ const getPlatformAndPartnerFees = (mongoose, amountFiat, fiat, processor, countr
85
89
  }
86
90
  // @ts-ignore
87
91
  if (platformFeeFiat === undefined) {
88
- platformFeeFiat = amountFiat * rioSettings.platformFee;
92
+ const netPlatformFee = rioSettings.platformFee - discount;
93
+ if (netPlatformFee < 0) {
94
+ throw new Error("Discount cannot be greater than platform fee");
95
+ }
96
+ platformFeeFiat = amountFiat * netPlatformFee;
89
97
  }
90
98
  partnerFeeFiat = 0;
91
99
  }
92
100
  else {
93
- platformFeeFiat = amountFiat * rioSettings.platformFee;
101
+ const netPlatformFee = rioSettings.platformFee - discount;
102
+ if (netPlatformFee < 0) {
103
+ throw new Error("Discount cannot be greater than platform fee");
104
+ }
105
+ platformFeeFiat = amountFiat * netPlatformFee;
94
106
  partnerFeeFiat = 0;
95
107
  }
96
108
  if (brokerId) {
@@ -102,7 +114,18 @@ const getPlatformAndPartnerFees = (mongoose, amountFiat, fiat, processor, countr
102
114
  if (brokerCustomer === null || brokerCustomer === void 0 ? void 0 : brokerCustomer.platformFeeRanges) {
103
115
  for (const range of brokerCustomer.platformFeeRanges) {
104
116
  if (range.min <= Number(amountUSD) && range.max >= Number(amountUSD)) {
105
- platformFeeFiat = amountFiat * range.fee;
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
+ }
106
129
  break;
107
130
  }
108
131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.746",
3
+ "version": "1.0.748",
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.663",
27
+ "@riocrypto/common": "^1.0.664",
28
28
  "@types/express": "^4.17.13",
29
29
  "axios": "^0.27.2",
30
30
  "ccxt": "^3.0.30",