@riocrypto/common-server 1.0.1171 → 1.0.1174

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,6 +16,8 @@ declare class FireblocksClient {
16
16
  createWallet(vaultId: string, crypto: Crypto): Promise<string>;
17
17
  internalTransfer(crypto: Crypto, sourceVaultId: string, destinationVaultId: string, amountCrypto: number, notes?: string): Promise<string>;
18
18
  externalTransfer(crypto: Crypto, sourceVaultId: string, destinationAddress: string, amountCrypto: number, notes?: string): Promise<string>;
19
+ transferToExchange(crypto: Crypto, sourceVaultId: string, destinationExchangeId: string, amountCrypto: number, notes?: string): Promise<string>;
20
+ transferFromExchange(crypto: Crypto, sourceExchangeId: string, destinationVaultId: string, amountCrypto: number, notes?: string): Promise<string>;
19
21
  sweep(vaultId: string, assetId: string, amount: number): Promise<void>;
20
22
  }
21
23
  export declare const buildFireblocksClient: () => Promise<FireblocksClient>;
@@ -200,6 +200,44 @@ class FireblocksClient {
200
200
  return response.id;
201
201
  });
202
202
  }
203
+ transferToExchange(crypto, sourceVaultId, destinationExchangeId, amountCrypto, notes) {
204
+ return __awaiter(this, void 0, void 0, function* () {
205
+ const response = yield this.fireblocks.createTransaction({
206
+ assetId: crypto,
207
+ source: {
208
+ type: fireblocks_sdk_1.PeerType.VAULT_ACCOUNT,
209
+ id: sourceVaultId,
210
+ },
211
+ destination: {
212
+ type: fireblocks_sdk_1.PeerType.EXCHANGE_ACCOUNT,
213
+ id: destinationExchangeId,
214
+ },
215
+ amount: amountCrypto,
216
+ operation: fireblocks_sdk_1.TransactionOperation.TRANSFER,
217
+ note: notes,
218
+ });
219
+ return response.id;
220
+ });
221
+ }
222
+ transferFromExchange(crypto, sourceExchangeId, destinationVaultId, amountCrypto, notes) {
223
+ return __awaiter(this, void 0, void 0, function* () {
224
+ const response = yield this.fireblocks.createTransaction({
225
+ assetId: crypto,
226
+ source: {
227
+ type: fireblocks_sdk_1.PeerType.EXCHANGE_ACCOUNT,
228
+ id: sourceExchangeId,
229
+ },
230
+ destination: {
231
+ type: fireblocks_sdk_1.PeerType.VAULT_ACCOUNT,
232
+ id: destinationVaultId,
233
+ },
234
+ amount: amountCrypto,
235
+ operation: fireblocks_sdk_1.TransactionOperation.TRANSFER,
236
+ note: notes,
237
+ });
238
+ return response.id;
239
+ });
240
+ }
203
241
  sweep(vaultId, assetId, amount) {
204
242
  return __awaiter(this, void 0, void 0, function* () {
205
243
  yield this.fireblocks.createTransaction({
@@ -46,8 +46,8 @@ const getPlatformFees = (mongoose, conversionRateToUSD, amountFiat, fiat, proces
46
46
  else {
47
47
  volume = Number(amountUSD);
48
48
  }
49
- if (broker.platformFeeRanges) {
50
- for (const range of broker.platformFeeRanges) {
49
+ if (broker.platformFeeRanges && broker.platformFeeRanges[country]) {
50
+ for (const range of broker.platformFeeRanges[country]) {
51
51
  if (range.min <= Number(volume) && range.max >= Number(volume)) {
52
52
  if (discount) {
53
53
  if (discount > range.fee) {
@@ -84,7 +84,7 @@ const getPlatformFees = (mongoose, conversionRateToUSD, amountFiat, fiat, proces
84
84
  platformFeeFiat = amountFiat * netPlatformFee;
85
85
  }
86
86
  }
87
- else if (user === null || user === void 0 ? void 0 : user.platformFeeRanges) {
87
+ else if ((user === null || user === void 0 ? void 0 : user.platformFeeRanges) && user.platformFeeRanges[country]) {
88
88
  let volume;
89
89
  if ((_b = user === null || user === void 0 ? void 0 : user.attributes) === null || _b === void 0 ? void 0 : _b.includes(common_1.UserAttribute.summedVolumeFees)) {
90
90
  const volumeAndRevenue = yield (0, calculate_aggregate_volume_and_revenue_1.calculateAggregateVolumeAndRevenue)(mongoose, 14, user);
@@ -93,7 +93,7 @@ const getPlatformFees = (mongoose, conversionRateToUSD, amountFiat, fiat, proces
93
93
  else {
94
94
  volume = Number(amountUSD);
95
95
  }
96
- for (const range of user.platformFeeRanges) {
96
+ for (const range of user.platformFeeRanges[country]) {
97
97
  if (range.min <= Number(volume) && range.max >= Number(volume)) {
98
98
  if (discount) {
99
99
  if (discount > range.fee) {
@@ -25,7 +25,13 @@ interface UserAttrs {
25
25
  curp?: string;
26
26
  ruc?: string;
27
27
  economicActivity?: string;
28
- platformFeeRanges?: PlatformFeeRange[];
28
+ platformFeeRanges?: {
29
+ MX?: PlatformFeeRange[];
30
+ PE?: PlatformFeeRange[];
31
+ CO?: PlatformFeeRange[];
32
+ BR?: PlatformFeeRange[];
33
+ US?: PlatformFeeRange[];
34
+ };
29
35
  COIFile?: string;
30
36
  KYCReportFile?: string;
31
37
  CSFFile?: string;
@@ -67,7 +73,13 @@ interface UserDoc extends Document {
67
73
  language?: Language;
68
74
  attributes?: UserAttribute[];
69
75
  brokerId?: string;
70
- platformFeeRanges?: PlatformFeeRange[];
76
+ platformFeeRanges?: {
77
+ MX?: PlatformFeeRange[];
78
+ PE?: PlatformFeeRange[];
79
+ CO?: PlatformFeeRange[];
80
+ BR?: PlatformFeeRange[];
81
+ US?: PlatformFeeRange[];
82
+ };
71
83
  COIFile?: string;
72
84
  KYCReportFile?: string;
73
85
  CSFFile?: string;
@@ -103,22 +103,88 @@ const buildUser = (mongoose) => {
103
103
  proofOfAddressFile: {
104
104
  type: String,
105
105
  },
106
- platformFeeRanges: [
107
- {
108
- min: {
109
- type: Number,
110
- required: true,
106
+ platformFeeRanges: {
107
+ MX: [
108
+ {
109
+ min: {
110
+ type: Number,
111
+ required: true,
112
+ },
113
+ max: {
114
+ type: Number,
115
+ required: true,
116
+ },
117
+ fee: {
118
+ type: Number,
119
+ required: true,
120
+ },
111
121
  },
112
- max: {
113
- type: Number,
114
- required: true,
122
+ ],
123
+ US: [
124
+ {
125
+ min: {
126
+ type: Number,
127
+ required: true,
128
+ },
129
+ max: {
130
+ type: Number,
131
+ required: true,
132
+ },
133
+ fee: {
134
+ type: Number,
135
+ required: true,
136
+ },
115
137
  },
116
- fee: {
117
- type: Number,
118
- required: true,
138
+ ],
139
+ PE: [
140
+ {
141
+ min: {
142
+ type: Number,
143
+ required: true,
144
+ },
145
+ max: {
146
+ type: Number,
147
+ required: true,
148
+ },
149
+ fee: {
150
+ type: Number,
151
+ required: true,
152
+ },
119
153
  },
120
- },
121
- ],
154
+ ],
155
+ CO: [
156
+ {
157
+ min: {
158
+ type: Number,
159
+ required: true,
160
+ },
161
+ max: {
162
+ type: Number,
163
+ required: true,
164
+ },
165
+ fee: {
166
+ type: Number,
167
+ required: true,
168
+ },
169
+ },
170
+ ],
171
+ BR: [
172
+ {
173
+ min: {
174
+ type: Number,
175
+ required: true,
176
+ },
177
+ max: {
178
+ type: Number,
179
+ required: true,
180
+ },
181
+ fee: {
182
+ type: Number,
183
+ required: true,
184
+ },
185
+ },
186
+ ],
187
+ },
122
188
  authorizedPhoneNumbers: [
123
189
  {
124
190
  type: String,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1171",
3
+ "version": "1.0.1174",
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.1050",
29
+ "@riocrypto/common": "^1.0.1054",
30
30
  "@types/express": "^4.17.13",
31
31
  "axios": "^0.27.2",
32
32
  "ccxt": "^3.0.30",