@riocrypto/common-server 1.0.1749 → 1.0.1750

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.
@@ -81,6 +81,7 @@ declare class BitsoClient {
81
81
  }>;
82
82
  getMakerFee(crypto: Crypto): Promise<number>;
83
83
  getMXNBalance(): Promise<number>;
84
+ createCryptoWithdrawal(amount: number, crypto: Crypto, address: string): Promise<Object>;
84
85
  signRequest(requestConfig: AxiosRequestConfig): AxiosRequestConfig;
85
86
  }
86
87
  export declare const buildBitsoClient: () => Promise<BitsoClient>;
@@ -326,6 +326,54 @@ class BitsoClient {
326
326
  return Number(mxn.available || 0);
327
327
  });
328
328
  }
329
+ createCryptoWithdrawal(amount, crypto, address) {
330
+ return __awaiter(this, void 0, void 0, function* () {
331
+ if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
332
+ throw new Error("Bitso withdraw not allowed in sandbox");
333
+ }
334
+ let asset;
335
+ if (crypto.toLocaleLowerCase().includes("usdc")) {
336
+ asset = "usdc";
337
+ }
338
+ else if (crypto.toLocaleLowerCase().includes("usdt")) {
339
+ asset = "usdt";
340
+ }
341
+ if (!asset) {
342
+ throw new Error("Unsupported crypto");
343
+ }
344
+ let network;
345
+ if ([common_1.Crypto.USDC, common_1.Crypto.USDTEthereum].includes(crypto)) {
346
+ network = "eth";
347
+ }
348
+ else if (crypto === common_1.Crypto.USDTTron) {
349
+ network = "tron";
350
+ }
351
+ if (!network) {
352
+ throw new Error("Network not found");
353
+ }
354
+ const requestConfig = {
355
+ method: "POST",
356
+ url: `${this.baseUrl}/api/v3/withdrawals`,
357
+ headers: {
358
+ "Content-Type": "application/json",
359
+ },
360
+ data: {
361
+ amount: amount.toFixed(2),
362
+ address: address,
363
+ chain: network,
364
+ network,
365
+ asset,
366
+ currency: asset,
367
+ },
368
+ };
369
+ const signedRequestConfig = this.signRequest(requestConfig);
370
+ const { data } = yield (0, axios_with_logging_1.default)(signedRequestConfig);
371
+ if (!data.success) {
372
+ throw new Error("Error creating Bitso withdraw");
373
+ }
374
+ return data.payload;
375
+ });
376
+ }
329
377
  signRequest(requestConfig) {
330
378
  var _a;
331
379
  const url = new URL(requestConfig.url || "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1749",
3
+ "version": "1.0.1750",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",