ccxt 4.1.90 → 4.1.91

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.
package/js/src/phemex.js CHANGED
@@ -460,6 +460,7 @@ export default class phemex extends Exchange {
460
460
  'networks': {
461
461
  'TRC20': 'TRX',
462
462
  'ERC20': 'ETH',
463
+ 'BEP20': 'BNB',
463
464
  },
464
465
  'defaultNetworks': {
465
466
  'USDT': 'ETH',
@@ -3398,6 +3399,19 @@ export default class phemex extends Exchange {
3398
3399
  const statuses = {
3399
3400
  'Success': 'ok',
3400
3401
  'Succeed': 'ok',
3402
+ 'Rejected': 'failed',
3403
+ 'Security check failed': 'failed',
3404
+ 'SecurityCheckFailed': 'failed',
3405
+ 'Expired': 'failed',
3406
+ 'Address Risk': 'failed',
3407
+ 'Security Checking': 'pending',
3408
+ 'SecurityChecking': 'pending',
3409
+ 'Pending Review': 'pending',
3410
+ 'Pending Transfer': 'pending',
3411
+ 'AmlCsApporve': 'pending',
3412
+ 'New': 'pending',
3413
+ 'Confirmed': 'pending',
3414
+ 'Cancelled': 'canceled',
3401
3415
  };
3402
3416
  return this.safeString(statuses, status, status);
3403
3417
  }
@@ -3405,36 +3419,68 @@ export default class phemex extends Exchange {
3405
3419
  //
3406
3420
  // withdraw
3407
3421
  //
3408
- // ...
3422
+ // {
3423
+ // "id": "10000001",
3424
+ // "freezeId": null,
3425
+ // "address": "44exxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
3426
+ // "amountRv": "100",
3427
+ // "chainCode": "11",
3428
+ // "chainName": "TRX",
3429
+ // "currency": "USDT",
3430
+ // "currencyCode": 3,
3431
+ // "email": "abc@gmail.com",
3432
+ // "expiredTime": "0",
3433
+ // "feeRv": "1",
3434
+ // "nickName": null,
3435
+ // "phone": null,
3436
+ // "rejectReason": "",
3437
+ // "submitedAt": "1670000000000",
3438
+ // "submittedAt": "1670000000000",
3439
+ // "txHash": null,
3440
+ // "userId": "10000001",
3441
+ // "status": "Success"
3409
3442
  //
3410
3443
  // fetchDeposits
3411
3444
  //
3412
3445
  // {
3413
- // "id":29200,
3414
- // "currency":"USDT",
3415
- // "currencyCode":3,
3416
- // "txHash":"0x0bdbdc47807769a03b158d5753f54dfc58b92993d2f5e818db21863e01238e5d",
3417
- // "address":"0x5bfbf60e0fa7f63598e6cfd8a7fd3ffac4ccc6ad",
3418
- // "amountEv":3000000000,
3419
- // "confirmations":13,
3420
- // "type":"Deposit",
3421
- // "status":"Success",
3422
- // "createdAt":1592722565000
3446
+ // "id": "29200",
3447
+ // "currency": "USDT",
3448
+ // "currencyCode": "3",
3449
+ // "chainName": "ETH",
3450
+ // "chainCode": "4",
3451
+ // "txHash": "0x0bdbdc47807769a03b158d5753f54dfc58b92993d2f5e818db21863e01238e5d",
3452
+ // "address": "0x5bfbf60e0fa7f63598e6cfd8a7fd3ffac4ccc6ad",
3453
+ // "amountEv": "3000000000",
3454
+ // "confirmations": "13",
3455
+ // "type": "Deposit",
3456
+ // "status": "Success",
3457
+ // "createdAt": "1592722565000",
3423
3458
  // }
3424
3459
  //
3425
3460
  // fetchWithdrawals
3426
3461
  //
3427
3462
  // {
3428
- // "address": "1Lxxxxxxxxxxx"
3429
- // "amountEv": 200000
3430
- // "currency": "BTC"
3431
- // "currencyCode": 1
3432
- // "expiredTime": 0
3433
- // "feeEv": 50000
3434
- // "rejectReason": null
3435
- // "status": "Succeed"
3436
- // "txHash": "44exxxxxxxxxxxxxxxxxxxxxx"
3437
- // "withdrawStatus: ""
3463
+ // "id": "10000001",
3464
+ // "userId": "10000001",
3465
+ // "freezeId": "10000002",
3466
+ // "phone": null,
3467
+ // "email": "abc@gmail.com",
3468
+ // "nickName": null,
3469
+ // "currency": "USDT",
3470
+ // "currencyCode": "3",
3471
+ // "status": "Succeed",
3472
+ // "withdrawStatus": "Succeed",
3473
+ // "amountEv": "8800000000",
3474
+ // "feeEv": "1200000000",
3475
+ // "address": "0x5xxxad",
3476
+ // "txHash: "0x0xxxx5d",
3477
+ // "submitedAt": "1702571922000",
3478
+ // "submittedAt": "1702571922000",
3479
+ // "expiredTime": "0",
3480
+ // "rejectReason": null,
3481
+ // "chainName": "ETH",
3482
+ // "chainCode": "4",
3483
+ // "proxyAddress": null
3438
3484
  // }
3439
3485
  //
3440
3486
  const id = this.safeString(transaction, 'id');
@@ -3444,9 +3490,13 @@ export default class phemex extends Exchange {
3444
3490
  const currencyId = this.safeString(transaction, 'currency');
3445
3491
  currency = this.safeCurrency(currencyId, currency);
3446
3492
  const code = currency['code'];
3447
- const timestamp = this.safeInteger2(transaction, 'createdAt', 'submitedAt');
3493
+ const networkId = this.safeString(transaction, 'chainName');
3494
+ const timestamp = this.safeIntegerN(transaction, ['createdAt', 'submitedAt', 'submittedAt']);
3448
3495
  let type = this.safeStringLower(transaction, 'type');
3449
- const feeCost = this.parseNumber(this.fromEn(this.safeString(transaction, 'feeEv'), currency['valueScale']));
3496
+ let feeCost = this.parseNumber(this.fromEn(this.safeString(transaction, 'feeEv'), currency['valueScale']));
3497
+ if (feeCost === undefined) {
3498
+ feeCost = this.safeNumber(transaction, 'feeRv');
3499
+ }
3450
3500
  let fee = undefined;
3451
3501
  if (feeCost !== undefined) {
3452
3502
  type = 'withdrawal';
@@ -3456,14 +3506,17 @@ export default class phemex extends Exchange {
3456
3506
  };
3457
3507
  }
3458
3508
  const status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
3459
- const amount = this.parseNumber(this.fromEn(this.safeString(transaction, 'amountEv'), currency['valueScale']));
3509
+ let amount = this.parseNumber(this.fromEn(this.safeString(transaction, 'amountEv'), currency['valueScale']));
3510
+ if (amount === undefined) {
3511
+ amount = this.safeNumber(transaction, 'amountRv');
3512
+ }
3460
3513
  return {
3461
3514
  'info': transaction,
3462
3515
  'id': id,
3463
3516
  'txid': txid,
3464
3517
  'timestamp': timestamp,
3465
3518
  'datetime': this.iso8601(timestamp),
3466
- 'network': undefined,
3519
+ 'network': this.networkIdToCode(networkId),
3467
3520
  'address': address,
3468
3521
  'addressTo': address,
3469
3522
  'addressFrom': undefined,
@@ -4605,10 +4658,38 @@ export default class phemex extends Exchange {
4605
4658
  'chainName': networkId.toUpperCase(),
4606
4659
  };
4607
4660
  if (tag !== undefined) {
4608
- request['tag'] = tag;
4661
+ request['addressTag'] = tag;
4609
4662
  }
4610
4663
  const response = await this.privatePostPhemexWithdrawWalletsApiCreateWithdraw(this.extend(request, params));
4611
- return this.parseTransaction(response, currency);
4664
+ //
4665
+ // {
4666
+ // "code": 0,
4667
+ // "msg": "OK",
4668
+ // "data": {
4669
+ // "id": "10000001",
4670
+ // "freezeId": null,
4671
+ // "address": "44exxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
4672
+ // "amountRv": "100",
4673
+ // "chainCode": "11",
4674
+ // "chainName": "TRX",
4675
+ // "currency": "USDT",
4676
+ // "currencyCode": 3,
4677
+ // "email": "abc@gmail.com",
4678
+ // "expiredTime": "0",
4679
+ // "feeRv": "1",
4680
+ // "nickName": null,
4681
+ // "phone": null,
4682
+ // "rejectReason": "",
4683
+ // "submitedAt": "1670000000000",
4684
+ // "submittedAt": "1670000000000",
4685
+ // "txHash": null,
4686
+ // "userId": "10000001",
4687
+ // "status": "Success"
4688
+ // }
4689
+ // }
4690
+ //
4691
+ const data = this.safeValue(response, 'data', {});
4692
+ return this.parseTransaction(data, currency);
4612
4693
  }
4613
4694
  handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
4614
4695
  if (response === undefined) {
@@ -5,7 +5,7 @@ export default class bitmart extends bitmartRest {
5
5
  describe(): any;
6
6
  subscribe(channel: any, symbol: any, type: any, params?: {}): Promise<any>;
7
7
  watchBalance(params?: {}): Promise<Balances>;
8
- setBalanceCache(client: Client, type: any): any;
8
+ setBalanceCache(client: Client, type: any, subscribeHash: any): void;
9
9
  loadBalanceSnapshot(client: any, messageHash: any, type: any): Promise<void>;
10
10
  handleBalance(client: Client, message: any): void;
11
11
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
@@ -51,7 +51,7 @@ export default class bitmart extends bitmartRest {
51
51
  'defaultType': 'spot',
52
52
  'watchBalance': {
53
53
  'fetchBalanceSnapshot': true,
54
- 'awaitBalanceSnapshot': true, // whether to wait for the balance snapshot before providing updates
54
+ 'awaitBalanceSnapshot': false, // whether to wait for the balance snapshot before providing updates
55
55
  },
56
56
  'watchOrderBook': {
57
57
  'depth': 'depth50', // depth5, depth20, depth50
@@ -131,30 +131,31 @@ export default class bitmart extends bitmartRest {
131
131
  const messageHash = 'balance:' + type;
132
132
  const url = this.implodeHostname(this.urls['api']['ws'][type]['private']);
133
133
  const client = this.client(url);
134
- this.setBalanceCache(client, type);
135
- const fetchBalanceSnapshot = this.handleOptionAndParams(this.options, 'watchBalance', 'fetchBalanceSnapshot', true);
136
- const awaitBalanceSnapshot = this.handleOptionAndParams(this.options, 'watchBalance', 'awaitBalanceSnapshot', false);
134
+ this.setBalanceCache(client, type, messageHash);
135
+ let fetchBalanceSnapshot = undefined;
136
+ let awaitBalanceSnapshot = undefined;
137
+ [fetchBalanceSnapshot, params] = this.handleOptionAndParams(this.options, 'watchBalance', 'fetchBalanceSnapshot', true);
138
+ [awaitBalanceSnapshot, params] = this.handleOptionAndParams(this.options, 'watchBalance', 'awaitBalanceSnapshot', false);
137
139
  if (fetchBalanceSnapshot && awaitBalanceSnapshot) {
138
140
  await client.future(type + ':fetchBalanceSnapshot');
139
141
  }
140
142
  return await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
141
143
  }
142
- setBalanceCache(client, type) {
143
- if (type in client.subscriptions) {
144
- return undefined;
144
+ setBalanceCache(client, type, subscribeHash) {
145
+ if (subscribeHash in client.subscriptions) {
146
+ return;
145
147
  }
146
148
  const options = this.safeValue(this.options, 'watchBalance');
147
- const fetchBalanceSnapshot = this.handleOptionAndParams(options, 'watchBalance', 'fetchBalanceSnapshot', true);
148
- if (fetchBalanceSnapshot) {
149
- const messageHash = type + ':fetchBalanceSnapshot';
149
+ const snapshot = this.safeValue(options, 'fetchBalanceSnapshot', true);
150
+ if (snapshot) {
151
+ const messageHash = type + ':' + 'fetchBalanceSnapshot';
150
152
  if (!(messageHash in client.futures)) {
151
153
  client.future(messageHash);
152
154
  this.spawn(this.loadBalanceSnapshot, client, messageHash, type);
153
155
  }
154
156
  }
155
- else {
156
- this.balance[type] = {};
157
- }
157
+ this.balance[type] = {};
158
+ // without this comment, transpilation breaks for some reason...
158
159
  }
159
160
  async loadBalanceSnapshot(client, messageHash, type) {
160
161
  const response = await this.fetchBalance({ 'type': type });
@@ -201,15 +202,15 @@ export default class bitmart extends bitmartRest {
201
202
  }
202
203
  const isSpot = (channel.indexOf('spot') >= 0);
203
204
  const type = isSpot ? 'spot' : 'swap';
204
- this.balance['info'] = message;
205
+ this.balance[type]['info'] = message;
205
206
  if (isSpot) {
206
207
  if (!Array.isArray(data)) {
207
208
  return;
208
209
  }
209
210
  for (let i = 0; i < data.length; i++) {
210
211
  const timestamp = this.safeInteger(message, 'event_time');
211
- this.balance['timestamp'] = timestamp;
212
- this.balance['datetime'] = this.iso8601(timestamp);
212
+ this.balance[type]['timestamp'] = timestamp;
213
+ this.balance[type]['datetime'] = this.iso8601(timestamp);
213
214
  const balanceDetails = this.safeValue(data[i], 'balance_details', []);
214
215
  for (let ii = 0; ii < balanceDetails.length; ii++) {
215
216
  const rawBalance = balanceDetails[i];
@@ -217,8 +218,8 @@ export default class bitmart extends bitmartRest {
217
218
  const currencyId = this.safeString(rawBalance, 'ccy');
218
219
  const code = this.safeCurrencyCode(currencyId);
219
220
  account['free'] = this.safeString(rawBalance, 'av_bal');
220
- account['total'] = this.safeString(rawBalance, 'fz_bal');
221
- this.balance[code] = account;
221
+ account['used'] = this.safeString(rawBalance, 'fz_bal');
222
+ this.balance[type][code] = account;
222
223
  }
223
224
  }
224
225
  }
package/js/src/zaif.js CHANGED
@@ -302,15 +302,14 @@ export default class zaif extends Exchange {
302
302
  // }
303
303
  //
304
304
  const symbol = this.safeSymbol(undefined, market);
305
- const timestamp = this.milliseconds();
306
305
  const vwap = this.safeString(ticker, 'vwap');
307
306
  const baseVolume = this.safeString(ticker, 'volume');
308
307
  const quoteVolume = Precise.stringMul(baseVolume, vwap);
309
308
  const last = this.safeString(ticker, 'last');
310
309
  return this.safeTicker({
311
310
  'symbol': symbol,
312
- 'timestamp': timestamp,
313
- 'datetime': this.iso8601(timestamp),
311
+ 'timestamp': undefined,
312
+ 'datetime': undefined,
314
313
  'high': this.safeString(ticker, 'high'),
315
314
  'low': this.safeString(ticker, 'low'),
316
315
  'bid': this.safeString(ticker, 'bid'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.1.90",
3
+ "version": "4.1.91",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",