@riocrypto/common-server 1.0.1936 → 1.0.1938

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,11 @@ declare class BitsoClient {
81
81
  }>;
82
82
  getMakerFee(crypto: Crypto): Promise<number>;
83
83
  getMXNBalance(): Promise<number>;
84
+ get(): Promise<{
85
+ mxn: number;
86
+ usdt: number;
87
+ usdc: number;
88
+ }>;
84
89
  createCryptoWithdrawal(amount: number, crypto: Crypto, address: string): Promise<Object>;
85
90
  signRequest(requestConfig: AxiosRequestConfig): AxiosRequestConfig;
86
91
  }
@@ -325,6 +325,44 @@ class BitsoClient {
325
325
  return Number(mxn.available || 0);
326
326
  });
327
327
  }
328
+ get() {
329
+ return __awaiter(this, void 0, void 0, function* () {
330
+ const requestConfig = {
331
+ method: "GET",
332
+ url: `${this.baseUrl}/v3/balance`,
333
+ headers: {
334
+ "Content-Type": "application/json",
335
+ },
336
+ };
337
+ const signedRequestConfig = this.signRequest(requestConfig);
338
+ const res = yield (0, axios_with_logging_1.default)(signedRequestConfig);
339
+ const data = res.data;
340
+ if (!data.success) {
341
+ throw new Error("Error getting Bitso fees");
342
+ }
343
+ const balances = data.payload.balances;
344
+ if (!balances) {
345
+ throw new Error("Unable to get balances");
346
+ }
347
+ const usdt = balances.find((obj) => obj.currency === "usdt");
348
+ if (!usdt) {
349
+ throw new Error("Unable to get USDT balance");
350
+ }
351
+ const usdc = balances.find((obj) => obj.currency === "usdc");
352
+ if (!usdc) {
353
+ throw new Error("Unable to get USDC balance");
354
+ }
355
+ const mxn = balances.find((obj) => obj.currency === "mxn");
356
+ if (!mxn) {
357
+ throw new Error("Unable to get MXN balance");
358
+ }
359
+ return {
360
+ mxn: Number(mxn.available || 0),
361
+ usdt: Number(usdt.available || 0),
362
+ usdc: Number(usdc.available || 0),
363
+ };
364
+ });
365
+ }
328
366
  createCryptoWithdrawal(amount, crypto, address) {
329
367
  return __awaiter(this, void 0, void 0, function* () {
330
368
  if ([common_1.RioEnv.Sandbox, common_1.RioEnv.Local].includes(process.env.RIO_ENV)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1936",
3
+ "version": "1.0.1938",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",