ccxt 4.2.69 → 4.2.71

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.
@@ -229,6 +229,8 @@ export default class coinbase extends Exchange {
229
229
  'brokerage/intx/portfolio/{portfolio_uuid}': 1,
230
230
  'brokerage/intx/positions/{portfolio_uuid}': 1,
231
231
  'brokerage/intx/positions/{portfolio_uuid}/{symbol}': 1,
232
+ 'brokerage/payment_methods': 1,
233
+ 'brokerage/payment_methods/{payment_method_id}': 1,
232
234
  },
233
235
  'post': {
234
236
  'brokerage/orders': 1,
@@ -381,7 +383,7 @@ export default class coinbase extends Exchange {
381
383
  // }
382
384
  // }
383
385
  //
384
- response = this.safeValue(response, 'data', {});
386
+ response = this.safeDict(response, 'data', {});
385
387
  }
386
388
  else {
387
389
  response = await this.v3PublicGetBrokerageTime(params);
@@ -473,7 +475,7 @@ export default class coinbase extends Exchange {
473
475
  const accounts = this.safeList(response, 'data', []);
474
476
  const length = accounts.length;
475
477
  const lastIndex = length - 1;
476
- const last = this.safeValue(accounts, lastIndex);
478
+ const last = this.safeDict(accounts, lastIndex);
477
479
  if ((cursor !== undefined) && (cursor !== '')) {
478
480
  last['next_starting_after'] = cursor;
479
481
  accounts[lastIndex] = last;
@@ -524,7 +526,7 @@ export default class coinbase extends Exchange {
524
526
  const accounts = this.safeList(response, 'accounts', []);
525
527
  const length = accounts.length;
526
528
  const lastIndex = length - 1;
527
- const last = this.safeValue(accounts, lastIndex);
529
+ const last = this.safeDict(accounts, lastIndex);
528
530
  const cursor = this.safeString(response, 'cursor');
529
531
  if ((cursor !== undefined) && (cursor !== '')) {
530
532
  last['cursor'] = cursor;
@@ -588,9 +590,9 @@ export default class coinbase extends Exchange {
588
590
  // }
589
591
  // }
590
592
  //
591
- const active = this.safeValue(account, 'active');
593
+ const active = this.safeBool(account, 'active');
592
594
  const currencyIdV3 = this.safeString(account, 'currency');
593
- const currency = this.safeValue(account, 'currency', {});
595
+ const currency = this.safeDict(account, 'currency', {});
594
596
  const currencyId = this.safeString(currency, 'code', currencyIdV3);
595
597
  const typeV3 = this.safeString(account, 'name');
596
598
  const typeV2 = this.safeString(account, 'type');
@@ -667,7 +669,7 @@ export default class coinbase extends Exchange {
667
669
  // }
668
670
  // }
669
671
  //
670
- const data = this.safeValue(response, 'data', {});
672
+ const data = this.safeDict(response, 'data', {});
671
673
  const tag = this.safeString(data, 'destination_tag');
672
674
  const address = this.safeString(data, 'address');
673
675
  return {
@@ -881,24 +883,24 @@ export default class coinbase extends Exchange {
881
883
  let amountAndCurrencyObject = undefined;
882
884
  let feeObject = undefined;
883
885
  if (transactionType === 'send') {
884
- const network = this.safeValue(transaction, 'network', {});
885
- amountAndCurrencyObject = this.safeValue(network, 'transaction_amount', {});
886
- feeObject = this.safeValue(network, 'transaction_fee', {});
886
+ const network = this.safeDict(transaction, 'network', {});
887
+ amountAndCurrencyObject = this.safeDict(network, 'transaction_amount', {});
888
+ feeObject = this.safeDict(network, 'transaction_fee', {});
887
889
  }
888
890
  else {
889
- amountAndCurrencyObject = this.safeValue(transaction, 'subtotal', {});
890
- feeObject = this.safeValue(transaction, 'fee', {});
891
+ amountAndCurrencyObject = this.safeDict(transaction, 'subtotal', {});
892
+ feeObject = this.safeDict(transaction, 'fee', {});
891
893
  }
892
894
  let status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
893
895
  if (status === undefined) {
894
- const committed = this.safeValue(transaction, 'committed');
896
+ const committed = this.safeBool(transaction, 'committed');
895
897
  status = committed ? 'ok' : 'pending';
896
898
  }
897
899
  const id = this.safeString(transaction, 'id');
898
900
  const currencyId = this.safeString(amountAndCurrencyObject, 'currency');
899
901
  const feeCurrencyId = this.safeString(feeObject, 'currency');
900
- const datetime = this.safeValue(transaction, 'created_at');
901
- const toObject = this.safeValue(transaction, 'to', {});
902
+ const datetime = this.safeString(transaction, 'created_at');
903
+ const toObject = this.safeDict(transaction, 'to', {});
902
904
  const toAddress = this.safeString(toObject, 'address');
903
905
  return {
904
906
  'info': transaction,
@@ -917,7 +919,7 @@ export default class coinbase extends Exchange {
917
919
  'amount': this.safeNumber(amountAndCurrencyObject, 'amount'),
918
920
  'currency': this.safeCurrencyCode(currencyId, currency),
919
921
  'status': status,
920
- 'updated': this.parse8601(this.safeValue(transaction, 'updated_at')),
922
+ 'updated': this.parse8601(this.safeString(transaction, 'updated_at')),
921
923
  'fee': {
922
924
  'cost': this.safeNumber(feeObject, 'amount'),
923
925
  'currency': this.safeCurrencyCode(feeCurrencyId),
@@ -987,10 +989,10 @@ export default class coinbase extends Exchange {
987
989
  // }
988
990
  //
989
991
  let symbol = undefined;
990
- const totalObject = this.safeValue(trade, 'total', {});
991
- const amountObject = this.safeValue(trade, 'amount', {});
992
- const subtotalObject = this.safeValue(trade, 'subtotal', {});
993
- const feeObject = this.safeValue(trade, 'fee', {});
992
+ const totalObject = this.safeDict(trade, 'total', {});
993
+ const amountObject = this.safeDict(trade, 'amount', {});
994
+ const subtotalObject = this.safeDict(trade, 'subtotal', {});
995
+ const feeObject = this.safeDict(trade, 'fee', {});
994
996
  const marketId = this.safeString(trade, 'product_id');
995
997
  market = this.safeMarket(marketId, market, '-');
996
998
  if (market !== undefined) {
@@ -1005,7 +1007,7 @@ export default class coinbase extends Exchange {
1005
1007
  symbol = base + '/' + quote;
1006
1008
  }
1007
1009
  }
1008
- const sizeInQuote = this.safeValue(trade, 'size_in_quote');
1010
+ const sizeInQuote = this.safeBool(trade, 'size_in_quote');
1009
1011
  const v3Price = this.safeString(trade, 'price');
1010
1012
  let v3Cost = undefined;
1011
1013
  let v3Amount = this.safeString(trade, 'size');
@@ -1074,11 +1076,11 @@ export default class coinbase extends Exchange {
1074
1076
  }
1075
1077
  async fetchMarketsV2(params = {}) {
1076
1078
  const response = await this.fetchCurrenciesFromCache(params);
1077
- const currencies = this.safeValue(response, 'currencies', {});
1078
- const exchangeRates = this.safeValue(response, 'exchangeRates', {});
1079
- const data = this.safeValue(currencies, 'data', []);
1079
+ const currencies = this.safeDict(response, 'currencies', {});
1080
+ const exchangeRates = this.safeDict(response, 'exchangeRates', {});
1081
+ const data = this.safeList(currencies, 'data', []);
1080
1082
  const dataById = this.indexBy(data, 'id');
1081
- const rates = this.safeValue(this.safeValue(exchangeRates, 'data', {}), 'rates', {});
1083
+ const rates = this.safeDict(this.safeDict(exchangeRates, 'data', {}), 'rates', {});
1082
1084
  const baseIds = Object.keys(rates);
1083
1085
  const result = [];
1084
1086
  for (let i = 0; i < baseIds.length; i++) {
@@ -1200,8 +1202,8 @@ export default class coinbase extends Exchange {
1200
1202
  // "coinbase_pro_fees": 0
1201
1203
  // }
1202
1204
  //
1203
- const feeTier = this.safeValue(fees, 'fee_tier', {});
1204
- const data = this.safeValue(response, 'products', []);
1205
+ const feeTier = this.safeDict(fees, 'fee_tier', {});
1206
+ const data = this.safeList(response, 'products', []);
1205
1207
  const result = [];
1206
1208
  for (let i = 0; i < data.length; i++) {
1207
1209
  const market = data[i];
@@ -1211,8 +1213,8 @@ export default class coinbase extends Exchange {
1211
1213
  const base = this.safeCurrencyCode(baseId);
1212
1214
  const quote = this.safeCurrencyCode(quoteId);
1213
1215
  const marketType = this.safeStringLower(market, 'product_type');
1214
- const tradingDisabled = this.safeValue(market, 'trading_disabled');
1215
- const stablePairs = this.safeValue(this.options, 'stablePairs', []);
1216
+ const tradingDisabled = this.safeBool(market, 'trading_disabled');
1217
+ const stablePairs = this.safeList(this.options, 'stablePairs', []);
1216
1218
  result.push({
1217
1219
  'id': id,
1218
1220
  'symbol': base + '/' + quote,
@@ -1268,7 +1270,7 @@ export default class coinbase extends Exchange {
1268
1270
  return result;
1269
1271
  }
1270
1272
  async fetchCurrenciesFromCache(params = {}) {
1271
- const options = this.safeValue(this.options, 'fetchCurrencies', {});
1273
+ const options = this.safeDict(this.options, 'fetchCurrencies', {});
1272
1274
  const timestamp = this.safeInteger(options, 'timestamp');
1273
1275
  const expires = this.safeInteger(options, 'expires', 1000);
1274
1276
  const now = this.milliseconds();
@@ -1324,7 +1326,7 @@ export default class coinbase extends Exchange {
1324
1326
  * @returns {object} an associative dictionary of currencies
1325
1327
  */
1326
1328
  const response = await this.fetchCurrenciesFromCache(params);
1327
- const currencies = this.safeValue(response, 'currencies', {});
1329
+ const currencies = this.safeDict(response, 'currencies', {});
1328
1330
  //
1329
1331
  // fiat
1330
1332
  //
@@ -1441,8 +1443,8 @@ export default class coinbase extends Exchange {
1441
1443
  // }
1442
1444
  // }
1443
1445
  //
1444
- const data = this.safeValue(response, 'data', {});
1445
- const rates = this.safeValue(data, 'rates', {});
1446
+ const data = this.safeDict(response, 'data', {});
1447
+ const rates = this.safeDict(data, 'rates', {});
1446
1448
  const quoteId = this.safeString(data, 'currency');
1447
1449
  const result = {};
1448
1450
  const baseIds = Object.keys(rates);
@@ -1501,7 +1503,7 @@ export default class coinbase extends Exchange {
1501
1503
  // "num_products": 549
1502
1504
  // }
1503
1505
  //
1504
- const data = this.safeValue(response, 'products', []);
1506
+ const data = this.safeList(response, 'products', []);
1505
1507
  const result = {};
1506
1508
  for (let i = 0; i < data.length; i++) {
1507
1509
  const entry = data[i];
@@ -1549,9 +1551,9 @@ export default class coinbase extends Exchange {
1549
1551
  //
1550
1552
  // {"data":{"base":"BTC","currency":"USD","amount":"48691.23"}}
1551
1553
  //
1552
- const spotData = this.safeValue(spot, 'data', {});
1553
- const askData = this.safeValue(ask, 'data', {});
1554
- const bidData = this.safeValue(bid, 'data', {});
1554
+ const spotData = this.safeDict(spot, 'data', {});
1555
+ const askData = this.safeDict(ask, 'data', {});
1556
+ const bidData = this.safeDict(bid, 'data', {});
1555
1557
  const bidAskLast = {
1556
1558
  'bid': this.safeNumber(bidData, 'amount'),
1557
1559
  'ask': this.safeNumber(askData, 'amount'),
@@ -1585,7 +1587,7 @@ export default class coinbase extends Exchange {
1585
1587
  // "best_ask": "28208.62"
1586
1588
  // }
1587
1589
  //
1588
- const data = this.safeValue(response, 'trades', []);
1590
+ const data = this.safeList(response, 'trades', []);
1589
1591
  const ticker = this.parseTicker(data[0], market);
1590
1592
  ticker['bid'] = this.safeNumber(response, 'best_bid');
1591
1593
  ticker['ask'] = this.safeNumber(response, 'best_ask');
@@ -1677,8 +1679,8 @@ export default class coinbase extends Exchange {
1677
1679
  let bidVolume = undefined;
1678
1680
  let askVolume = undefined;
1679
1681
  if (('bids' in ticker)) {
1680
- const bids = this.safeValue(ticker, 'bids', []);
1681
- const asks = this.safeValue(ticker, 'asks', []);
1682
+ const bids = this.safeList(ticker, 'bids', []);
1683
+ const asks = this.safeList(ticker, 'asks', []);
1682
1684
  bid = this.safeNumber(bids[0], 'price');
1683
1685
  bidVolume = this.safeNumber(bids[0], 'size');
1684
1686
  ask = this.safeNumber(asks[0], 'price');
@@ -1711,21 +1713,21 @@ export default class coinbase extends Exchange {
1711
1713
  }, market);
1712
1714
  }
1713
1715
  parseCustomBalance(response, params = {}) {
1714
- const balances = this.safeValue2(response, 'data', 'accounts', []);
1715
- const accounts = this.safeValue(params, 'type', this.options['accounts']);
1716
- const v3Accounts = this.safeValue(params, 'type', this.options['v3Accounts']);
1716
+ const balances = this.safeList2(response, 'data', 'accounts', []);
1717
+ const accounts = this.safeList(params, 'type', this.options['accounts']);
1718
+ const v3Accounts = this.safeList(params, 'type', this.options['v3Accounts']);
1717
1719
  const result = { 'info': response };
1718
1720
  for (let b = 0; b < balances.length; b++) {
1719
1721
  const balance = balances[b];
1720
1722
  const type = this.safeString(balance, 'type');
1721
1723
  if (this.inArray(type, accounts)) {
1722
- const value = this.safeValue(balance, 'balance');
1724
+ const value = this.safeDict(balance, 'balance');
1723
1725
  if (value !== undefined) {
1724
1726
  const currencyId = this.safeString(value, 'currency');
1725
1727
  const code = this.safeCurrencyCode(currencyId);
1726
1728
  const total = this.safeString(value, 'amount');
1727
1729
  const free = total;
1728
- let account = this.safeValue(result, code);
1730
+ let account = this.safeDict(result, code);
1729
1731
  if (account === undefined) {
1730
1732
  account = this.account();
1731
1733
  account['free'] = free;
@@ -1739,15 +1741,15 @@ export default class coinbase extends Exchange {
1739
1741
  }
1740
1742
  }
1741
1743
  else if (this.inArray(type, v3Accounts)) {
1742
- const available = this.safeValue(balance, 'available_balance');
1743
- const hold = this.safeValue(balance, 'hold');
1744
+ const available = this.safeDict(balance, 'available_balance');
1745
+ const hold = this.safeDict(balance, 'hold');
1744
1746
  if (available !== undefined && hold !== undefined) {
1745
1747
  const currencyId = this.safeString(available, 'currency');
1746
1748
  const code = this.safeCurrencyCode(currencyId);
1747
1749
  const used = this.safeString(hold, 'value');
1748
1750
  const free = this.safeString(available, 'value');
1749
1751
  const total = Precise.stringAdd(used, free);
1750
- let account = this.safeValue(result, code);
1752
+ let account = this.safeDict(result, code);
1751
1753
  if (account === undefined) {
1752
1754
  account = this.account();
1753
1755
  account['free'] = free;
@@ -2155,7 +2157,7 @@ export default class coinbase extends Exchange {
2155
2157
  // }
2156
2158
  // }
2157
2159
  //
2158
- const amountInfo = this.safeValue(item, 'amount', {});
2160
+ const amountInfo = this.safeDict(item, 'amount', {});
2159
2161
  let amount = this.safeString(amountInfo, 'amount');
2160
2162
  let direction = undefined;
2161
2163
  if (Precise.stringLt(amount, '0')) {
@@ -2177,9 +2179,9 @@ export default class coinbase extends Exchange {
2177
2179
  // let txid = undefined;
2178
2180
  //
2179
2181
  let fee = undefined;
2180
- const networkInfo = this.safeValue(item, 'network', {});
2182
+ const networkInfo = this.safeDict(item, 'network', {});
2181
2183
  // txid = network['hash']; // txid does not belong to the unified ledger structure
2182
- const feeInfo = this.safeValue(networkInfo, 'transaction_fee');
2184
+ const feeInfo = this.safeDict(networkInfo, 'transaction_fee');
2183
2185
  if (feeInfo !== undefined) {
2184
2186
  const feeCurrencyId = this.safeString(feeInfo, 'currency');
2185
2187
  const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId, currency);
@@ -2189,7 +2191,7 @@ export default class coinbase extends Exchange {
2189
2191
  'currency': feeCurrencyCode,
2190
2192
  };
2191
2193
  }
2192
- const timestamp = this.parse8601(this.safeValue(item, 'created_at'));
2194
+ const timestamp = this.parse8601(this.safeString(item, 'created_at'));
2193
2195
  const id = this.safeString(item, 'id');
2194
2196
  const type = this.parseLedgerEntryType(this.safeString(item, 'type'));
2195
2197
  const status = this.parseLedgerEntryStatus(this.safeString(item, 'status'));
@@ -2321,7 +2323,7 @@ export default class coinbase extends Exchange {
2321
2323
  const isStopLoss = stopLossPrice !== undefined;
2322
2324
  const isTakeProfit = takeProfitPrice !== undefined;
2323
2325
  const timeInForce = this.safeString(params, 'timeInForce');
2324
- const postOnly = (timeInForce === 'PO') ? true : this.safeValue2(params, 'postOnly', 'post_only', false);
2326
+ const postOnly = (timeInForce === 'PO') ? true : this.safeBool2(params, 'postOnly', 'post_only', false);
2325
2327
  const endTime = this.safeString(params, 'end_time');
2326
2328
  let stopDirection = this.safeString(params, 'stop_direction');
2327
2329
  if (type === 'limit') {
@@ -2391,6 +2393,14 @@ export default class coinbase extends Exchange {
2391
2393
  },
2392
2394
  };
2393
2395
  }
2396
+ else if (timeInForce === 'IOC') {
2397
+ request['order_configuration'] = {
2398
+ 'sor_limit_ioc': {
2399
+ 'base_size': this.amountToPrecision(symbol, amount),
2400
+ 'limit_price': this.priceToPrecision(symbol, price),
2401
+ },
2402
+ };
2403
+ }
2394
2404
  else {
2395
2405
  request['order_configuration'] = {
2396
2406
  'limit_limit_gtc': {
@@ -2444,7 +2454,7 @@ export default class coinbase extends Exchange {
2444
2454
  }
2445
2455
  }
2446
2456
  params = this.omit(params, ['timeInForce', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'stop_price', 'stopDirection', 'stop_direction', 'clientOrderId', 'postOnly', 'post_only', 'end_time']);
2447
- const preview = this.safeValue2(params, 'preview', 'test', false);
2457
+ const preview = this.safeBool2(params, 'preview', 'test', false);
2448
2458
  let response = undefined;
2449
2459
  if (preview) {
2450
2460
  params = this.omit(params, ['preview', 'test']);
@@ -2491,9 +2501,9 @@ export default class coinbase extends Exchange {
2491
2501
  // }
2492
2502
  // }
2493
2503
  //
2494
- const success = this.safeValue(response, 'success');
2504
+ const success = this.safeBool(response, 'success');
2495
2505
  if (success !== true) {
2496
- const errorResponse = this.safeValue(response, 'error_response');
2506
+ const errorResponse = this.safeDict(response, 'error_response');
2497
2507
  const errorTitle = this.safeString(errorResponse, 'error');
2498
2508
  const errorMessage = this.safeString(errorResponse, 'message');
2499
2509
  if (errorResponse !== undefined) {
@@ -2502,7 +2512,7 @@ export default class coinbase extends Exchange {
2502
2512
  throw new ExchangeError(errorMessage);
2503
2513
  }
2504
2514
  }
2505
- const data = this.safeValue(response, 'success_response', {});
2515
+ const data = this.safeDict(response, 'success_response', {});
2506
2516
  return this.parseOrder(data, market);
2507
2517
  }
2508
2518
  parseOrder(order, market = undefined) {
@@ -2573,29 +2583,39 @@ export default class coinbase extends Exchange {
2573
2583
  if (symbol !== undefined) {
2574
2584
  market = this.market(symbol);
2575
2585
  }
2576
- const orderConfiguration = this.safeValue(order, 'order_configuration', {});
2577
- const limitGTC = this.safeValue(orderConfiguration, 'limit_limit_gtc');
2578
- const limitGTD = this.safeValue(orderConfiguration, 'limit_limit_gtd');
2579
- const stopLimitGTC = this.safeValue(orderConfiguration, 'stop_limit_stop_limit_gtc');
2580
- const stopLimitGTD = this.safeValue(orderConfiguration, 'stop_limit_stop_limit_gtd');
2581
- const marketIOC = this.safeValue(orderConfiguration, 'market_market_ioc');
2582
- const isLimit = ((limitGTC !== undefined) || (limitGTD !== undefined));
2586
+ const orderConfiguration = this.safeDict(order, 'order_configuration', {});
2587
+ const limitGTC = this.safeDict(orderConfiguration, 'limit_limit_gtc');
2588
+ const limitGTD = this.safeDict(orderConfiguration, 'limit_limit_gtd');
2589
+ const limitIOC = this.safeDict(orderConfiguration, 'sor_limit_ioc');
2590
+ const stopLimitGTC = this.safeDict(orderConfiguration, 'stop_limit_stop_limit_gtc');
2591
+ const stopLimitGTD = this.safeDict(orderConfiguration, 'stop_limit_stop_limit_gtd');
2592
+ const marketIOC = this.safeDict(orderConfiguration, 'market_market_ioc');
2593
+ const isLimit = ((limitGTC !== undefined) || (limitGTD !== undefined) || (limitIOC !== undefined));
2583
2594
  const isStop = ((stopLimitGTC !== undefined) || (stopLimitGTD !== undefined));
2584
2595
  let price = undefined;
2585
2596
  let amount = undefined;
2586
2597
  let postOnly = undefined;
2587
2598
  let triggerPrice = undefined;
2588
2599
  if (isLimit) {
2589
- const target = (limitGTC !== undefined) ? limitGTC : limitGTD;
2600
+ let target = undefined;
2601
+ if (limitGTC !== undefined) {
2602
+ target = limitGTC;
2603
+ }
2604
+ else if (limitGTD !== undefined) {
2605
+ target = limitGTD;
2606
+ }
2607
+ else {
2608
+ target = limitIOC;
2609
+ }
2590
2610
  price = this.safeString(target, 'limit_price');
2591
2611
  amount = this.safeString(target, 'base_size');
2592
- postOnly = this.safeValue(target, 'post_only');
2612
+ postOnly = this.safeBool(target, 'post_only');
2593
2613
  }
2594
2614
  else if (isStop) {
2595
2615
  const stopTarget = (stopLimitGTC !== undefined) ? stopLimitGTC : stopLimitGTD;
2596
2616
  price = this.safeString(stopTarget, 'limit_price');
2597
2617
  amount = this.safeString(stopTarget, 'base_size');
2598
- postOnly = this.safeValue(stopTarget, 'post_only');
2618
+ postOnly = this.safeBool(stopTarget, 'post_only');
2599
2619
  triggerPrice = this.safeString(stopTarget, 'stop_price');
2600
2620
  }
2601
2621
  else {
@@ -2681,7 +2701,7 @@ export default class coinbase extends Exchange {
2681
2701
  */
2682
2702
  await this.loadMarkets();
2683
2703
  const orders = await this.cancelOrders([id], symbol, params);
2684
- return this.safeValue(orders, 0, {});
2704
+ return this.safeDict(orders, 0, {});
2685
2705
  }
2686
2706
  async cancelOrders(ids, symbol = undefined, params = {}) {
2687
2707
  /**
@@ -2714,9 +2734,9 @@ export default class coinbase extends Exchange {
2714
2734
  // ]
2715
2735
  // }
2716
2736
  //
2717
- const orders = this.safeValue(response, 'results', []);
2737
+ const orders = this.safeList(response, 'results', []);
2718
2738
  for (let i = 0; i < orders.length; i++) {
2719
- const success = this.safeValue(orders[i], 'success');
2739
+ const success = this.safeBool(orders[i], 'success');
2720
2740
  if (success !== true) {
2721
2741
  throw new BadRequest(this.id + ' cancelOrders() has failed, check your arguments and parameters');
2722
2742
  }
@@ -2750,7 +2770,7 @@ export default class coinbase extends Exchange {
2750
2770
  if (price !== undefined) {
2751
2771
  request['price'] = this.priceToPrecision(symbol, price);
2752
2772
  }
2753
- const preview = this.safeValue2(params, 'preview', 'test', false);
2773
+ const preview = this.safeBool2(params, 'preview', 'test', false);
2754
2774
  let response = undefined;
2755
2775
  if (preview) {
2756
2776
  params = this.omit(params, ['preview', 'test']);
@@ -2829,7 +2849,7 @@ export default class coinbase extends Exchange {
2829
2849
  // }
2830
2850
  // }
2831
2851
  //
2832
- const order = this.safeValue(response, 'order', {});
2852
+ const order = this.safeDict(response, 'order', {});
2833
2853
  return this.parseOrder(order, market);
2834
2854
  }
2835
2855
  async fetchOrders(symbol = undefined, since = undefined, limit = 100, params = {}) {
@@ -2866,7 +2886,7 @@ export default class coinbase extends Exchange {
2866
2886
  if (since !== undefined) {
2867
2887
  request['start_date'] = this.iso8601(since);
2868
2888
  }
2869
- const until = this.safeValueN(params, ['until', 'till']);
2889
+ const until = this.safeIntegerN(params, ['until', 'till']);
2870
2890
  if (until !== undefined) {
2871
2891
  params = this.omit(params, ['until', 'till']);
2872
2892
  request['end_date'] = this.iso8601(until);
@@ -2914,8 +2934,8 @@ export default class coinbase extends Exchange {
2914
2934
  // "cursor": ""
2915
2935
  // }
2916
2936
  //
2917
- const orders = this.safeValue(response, 'orders', []);
2918
- const first = this.safeValue(orders, 0);
2937
+ const orders = this.safeList(response, 'orders', []);
2938
+ const first = this.safeDict(orders, 0);
2919
2939
  const cursor = this.safeString(response, 'cursor');
2920
2940
  if ((cursor !== undefined) && (cursor !== '')) {
2921
2941
  first['cursor'] = cursor;
@@ -2942,7 +2962,7 @@ export default class coinbase extends Exchange {
2942
2962
  if (since !== undefined) {
2943
2963
  request['start_date'] = this.iso8601(since);
2944
2964
  }
2945
- const until = this.safeValueN(params, ['until', 'till']);
2965
+ const until = this.safeIntegerN(params, ['until', 'till']);
2946
2966
  if (until !== undefined) {
2947
2967
  params = this.omit(params, ['until', 'till']);
2948
2968
  request['end_date'] = this.iso8601(until);
@@ -2990,8 +3010,8 @@ export default class coinbase extends Exchange {
2990
3010
  // "cursor": ""
2991
3011
  // }
2992
3012
  //
2993
- const orders = this.safeValue(response, 'orders', []);
2994
- const first = this.safeValue(orders, 0);
3013
+ const orders = this.safeList(response, 'orders', []);
3014
+ const first = this.safeDict(orders, 0);
2995
3015
  const cursor = this.safeString(response, 'cursor');
2996
3016
  if ((cursor !== undefined) && (cursor !== '')) {
2997
3017
  first['cursor'] = cursor;
@@ -3085,7 +3105,7 @@ export default class coinbase extends Exchange {
3085
3105
  'product_id': market['id'],
3086
3106
  'granularity': this.safeString(this.timeframes, timeframe, timeframe),
3087
3107
  };
3088
- const until = this.safeValueN(params, ['until', 'till', 'end']);
3108
+ const until = this.safeIntegerN(params, ['until', 'till', 'end']);
3089
3109
  params = this.omit(params, ['until', 'till']);
3090
3110
  const duration = this.parseTimeframe(timeframe);
3091
3111
  const requestedDuration = limit * duration;
@@ -3119,7 +3139,7 @@ export default class coinbase extends Exchange {
3119
3139
  // ]
3120
3140
  // }
3121
3141
  //
3122
- const candles = this.safeValue(response, 'candles', []);
3142
+ const candles = this.safeList(response, 'candles', []);
3123
3143
  return this.parseOHLCVs(candles, market, timeframe, since, limit);
3124
3144
  }
3125
3145
  parseOHLCV(ohlcv, market = undefined) {
@@ -3192,7 +3212,7 @@ export default class coinbase extends Exchange {
3192
3212
  // ]
3193
3213
  // }
3194
3214
  //
3195
- const trades = this.safeValue(response, 'trades', []);
3215
+ const trades = this.safeList(response, 'trades', []);
3196
3216
  return this.parseTrades(trades, market, since, limit);
3197
3217
  }
3198
3218
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -3229,7 +3249,7 @@ export default class coinbase extends Exchange {
3229
3249
  if (since !== undefined) {
3230
3250
  request['start_sequence_timestamp'] = this.iso8601(since);
3231
3251
  }
3232
- const until = this.safeValueN(params, ['until', 'till']);
3252
+ const until = this.safeIntegerN(params, ['until', 'till']);
3233
3253
  if (until !== undefined) {
3234
3254
  params = this.omit(params, ['until', 'till']);
3235
3255
  request['end_sequence_timestamp'] = this.iso8601(until);
@@ -3258,8 +3278,8 @@ export default class coinbase extends Exchange {
3258
3278
  // "cursor": ""
3259
3279
  // }
3260
3280
  //
3261
- const trades = this.safeValue(response, 'fills', []);
3262
- const first = this.safeValue(trades, 0);
3281
+ const trades = this.safeList(response, 'fills', []);
3282
+ const first = this.safeDict(trades, 0);
3263
3283
  const cursor = this.safeString(response, 'cursor');
3264
3284
  if ((cursor !== undefined) && (cursor !== '')) {
3265
3285
  first['cursor'] = cursor;
@@ -3351,7 +3371,7 @@ export default class coinbase extends Exchange {
3351
3371
  // ]
3352
3372
  // }
3353
3373
  //
3354
- const tickers = this.safeValue(response, 'pricebooks', []);
3374
+ const tickers = this.safeList(response, 'pricebooks', []);
3355
3375
  return this.parseTickers(tickers, symbols);
3356
3376
  }
3357
3377
  async withdraw(code, amount, address, tag = undefined, params = {}) {
@@ -3445,7 +3465,7 @@ export default class coinbase extends Exchange {
3445
3465
  // }
3446
3466
  // }
3447
3467
  //
3448
- const data = this.safeValue(response, 'data', {});
3468
+ const data = this.safeDict(response, 'data', {});
3449
3469
  return this.parseTransaction(data, currency);
3450
3470
  }
3451
3471
  async fetchDepositAddressesByNetwork(code, params = {}) {
@@ -3718,7 +3738,7 @@ export default class coinbase extends Exchange {
3718
3738
  // }
3719
3739
  // }
3720
3740
  //
3721
- const data = this.safeValue(response, 'data', {});
3741
+ const data = this.safeDict(response, 'data', {});
3722
3742
  return this.parseTransaction(data);
3723
3743
  }
3724
3744
  sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
@@ -3818,7 +3838,7 @@ export default class coinbase extends Exchange {
3818
3838
  this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessage, feedback);
3819
3839
  throw new ExchangeError(feedback);
3820
3840
  }
3821
- const errors = this.safeValue(response, 'errors');
3841
+ const errors = this.safeList(response, 'errors');
3822
3842
  if (errors !== undefined) {
3823
3843
  if (Array.isArray(errors)) {
3824
3844
  const numErrors = errors.length;
@@ -3834,8 +3854,7 @@ export default class coinbase extends Exchange {
3834
3854
  }
3835
3855
  }
3836
3856
  const advancedTrade = this.options['advanced'];
3837
- const data = this.safeValue(response, 'data');
3838
- if ((data === undefined) && (!advancedTrade)) {
3857
+ if (!('data' in response) && (!advancedTrade)) {
3839
3858
  throw new ExchangeError(this.id + ' failed due to a malformed response ' + this.json(response));
3840
3859
  }
3841
3860
  return undefined;
@@ -1526,7 +1526,8 @@ export default class digifinex extends Exchange {
1526
1526
  else if (limit !== undefined) {
1527
1527
  const endTime = this.seconds();
1528
1528
  const duration = this.parseTimeframe(timeframe);
1529
- request['start_time'] = this.sum(endTime, -limit * duration);
1529
+ const auxLimit = limit; // in c# -limit is mutating the arg
1530
+ request['start_time'] = this.sum(endTime, -auxLimit * duration);
1530
1531
  }
1531
1532
  response = await this.publicSpotGetKline(this.extend(request, params));
1532
1533
  }
package/js/src/gate.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/gate.js';
2
- import type { Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OpenInterest, Order, Balances, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OpenInterest, Order, Balances, OrderRequest, FundingHistory, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Leverage, Leverages } from './base/types.js';
3
3
  /**
4
4
  * @class gate
5
5
  * @augments Exchange
@@ -361,5 +361,8 @@ export default class gate extends Exchange {
361
361
  info: any;
362
362
  };
363
363
  closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
364
+ fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
365
+ fetchLeverages(symbols?: string[], params?: {}): Promise<Leverages>;
366
+ parseLeverage(leverage: any, market?: any): Leverage;
364
367
  handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
365
368
  }