ccxt 4.2.70 → 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.
package/dist/cjs/ccxt.js CHANGED
@@ -152,6 +152,7 @@ var hollaex$1 = require('./src/pro/hollaex.js');
152
152
  var htx$1 = require('./src/pro/htx.js');
153
153
  var huobi$1 = require('./src/pro/huobi.js');
154
154
  var huobijp$1 = require('./src/pro/huobijp.js');
155
+ var hyperliquid$1 = require('./src/pro/hyperliquid.js');
155
156
  var idex$1 = require('./src/pro/idex.js');
156
157
  var independentreserve$1 = require('./src/pro/independentreserve.js');
157
158
  var kraken$1 = require('./src/pro/kraken.js');
@@ -177,7 +178,7 @@ var woo$1 = require('./src/pro/woo.js');
177
178
 
178
179
  //-----------------------------------------------------------------------------
179
180
  // this is updated by vss.js when building
180
- const version = '4.2.70';
181
+ const version = '4.2.71';
181
182
  Exchange["default"].ccxtVersion = version;
182
183
  const exchanges = {
183
184
  'ace': ace,
@@ -322,6 +323,7 @@ const pro = {
322
323
  'htx': htx$1,
323
324
  'huobi': huobi$1,
324
325
  'huobijp': huobijp$1,
326
+ 'hyperliquid': hyperliquid$1,
325
327
  'idex': idex$1,
326
328
  'independentreserve': independentreserve$1,
327
329
  'kraken': kraken$1,
@@ -6308,11 +6308,13 @@ class bitget extends bitget$1 {
6308
6308
  * @description fetch all open positions
6309
6309
  * @see https://www.bitget.com/api-doc/contract/position/get-all-position
6310
6310
  * @see https://www.bitget.com/api-doc/contract/position/Get-History-Position
6311
- * @param {string[]|undefined} symbols list of unified market symbols
6311
+ * @param {string[]} [symbols] list of unified market symbols
6312
6312
  * @param {object} [params] extra parameters specific to the exchange API endpoint
6313
6313
  * @param {string} [params.marginCoin] the settle currency of the positions, needs to match the productType
6314
6314
  * @param {string} [params.productType] 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
6315
6315
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
6316
+ * @param {boolean} [params.useHistoryEndpoint] default false, when true will use the historic endpoint to fetch positions
6317
+ * @param {string} [params.method] either (default) 'privateMixGetV2MixPositionAllPosition' or 'privateMixGetV2MixPositionHistoryPosition'
6316
6318
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
6317
6319
  */
6318
6320
  await this.loadMarkets();
@@ -6321,8 +6323,14 @@ class bitget extends bitget$1 {
6321
6323
  if (paginate) {
6322
6324
  return await this.fetchPaginatedCallCursor('fetchPositions', undefined, undefined, undefined, params, 'endId', 'idLessThan');
6323
6325
  }
6324
- const fetchPositionsOptions = this.safeValue(this.options, 'fetchPositions', {});
6325
- const method = this.safeString(fetchPositionsOptions, 'method', 'privateMixGetV2MixPositionAllPosition');
6326
+ let method = undefined;
6327
+ const useHistoryEndpoint = this.safeBool(params, 'useHistoryEndpoint', false);
6328
+ if (useHistoryEndpoint) {
6329
+ method = 'privateMixGetV2MixPositionHistoryPosition';
6330
+ }
6331
+ else {
6332
+ [method, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method', 'privateMixGetV2MixPositionAllPosition');
6333
+ }
6326
6334
  let market = undefined;
6327
6335
  if (symbols !== undefined) {
6328
6336
  const first = this.safeString(symbols, 0);
@@ -6438,11 +6446,11 @@ class bitget extends bitget$1 {
6438
6446
  //
6439
6447
  let position = [];
6440
6448
  if (!isHistory) {
6441
- position = this.safeValue(response, 'data', []);
6449
+ position = this.safeList(response, 'data', []);
6442
6450
  }
6443
6451
  else {
6444
- const data = this.safeValue(response, 'data', {});
6445
- position = this.safeValue(data, 'list', []);
6452
+ const data = this.safeDict(response, 'data', {});
6453
+ position = this.safeList(data, 'list', []);
6446
6454
  }
6447
6455
  const result = [];
6448
6456
  for (let i = 0; i < position.length; i++) {
@@ -226,6 +226,8 @@ class coinbase extends coinbase$1 {
226
226
  'brokerage/intx/portfolio/{portfolio_uuid}': 1,
227
227
  'brokerage/intx/positions/{portfolio_uuid}': 1,
228
228
  'brokerage/intx/positions/{portfolio_uuid}/{symbol}': 1,
229
+ 'brokerage/payment_methods': 1,
230
+ 'brokerage/payment_methods/{payment_method_id}': 1,
229
231
  },
230
232
  'post': {
231
233
  'brokerage/orders': 1,
@@ -378,7 +380,7 @@ class coinbase extends coinbase$1 {
378
380
  // }
379
381
  // }
380
382
  //
381
- response = this.safeValue(response, 'data', {});
383
+ response = this.safeDict(response, 'data', {});
382
384
  }
383
385
  else {
384
386
  response = await this.v3PublicGetBrokerageTime(params);
@@ -470,7 +472,7 @@ class coinbase extends coinbase$1 {
470
472
  const accounts = this.safeList(response, 'data', []);
471
473
  const length = accounts.length;
472
474
  const lastIndex = length - 1;
473
- const last = this.safeValue(accounts, lastIndex);
475
+ const last = this.safeDict(accounts, lastIndex);
474
476
  if ((cursor !== undefined) && (cursor !== '')) {
475
477
  last['next_starting_after'] = cursor;
476
478
  accounts[lastIndex] = last;
@@ -521,7 +523,7 @@ class coinbase extends coinbase$1 {
521
523
  const accounts = this.safeList(response, 'accounts', []);
522
524
  const length = accounts.length;
523
525
  const lastIndex = length - 1;
524
- const last = this.safeValue(accounts, lastIndex);
526
+ const last = this.safeDict(accounts, lastIndex);
525
527
  const cursor = this.safeString(response, 'cursor');
526
528
  if ((cursor !== undefined) && (cursor !== '')) {
527
529
  last['cursor'] = cursor;
@@ -585,9 +587,9 @@ class coinbase extends coinbase$1 {
585
587
  // }
586
588
  // }
587
589
  //
588
- const active = this.safeValue(account, 'active');
590
+ const active = this.safeBool(account, 'active');
589
591
  const currencyIdV3 = this.safeString(account, 'currency');
590
- const currency = this.safeValue(account, 'currency', {});
592
+ const currency = this.safeDict(account, 'currency', {});
591
593
  const currencyId = this.safeString(currency, 'code', currencyIdV3);
592
594
  const typeV3 = this.safeString(account, 'name');
593
595
  const typeV2 = this.safeString(account, 'type');
@@ -664,7 +666,7 @@ class coinbase extends coinbase$1 {
664
666
  // }
665
667
  // }
666
668
  //
667
- const data = this.safeValue(response, 'data', {});
669
+ const data = this.safeDict(response, 'data', {});
668
670
  const tag = this.safeString(data, 'destination_tag');
669
671
  const address = this.safeString(data, 'address');
670
672
  return {
@@ -878,24 +880,24 @@ class coinbase extends coinbase$1 {
878
880
  let amountAndCurrencyObject = undefined;
879
881
  let feeObject = undefined;
880
882
  if (transactionType === 'send') {
881
- const network = this.safeValue(transaction, 'network', {});
882
- amountAndCurrencyObject = this.safeValue(network, 'transaction_amount', {});
883
- feeObject = this.safeValue(network, 'transaction_fee', {});
883
+ const network = this.safeDict(transaction, 'network', {});
884
+ amountAndCurrencyObject = this.safeDict(network, 'transaction_amount', {});
885
+ feeObject = this.safeDict(network, 'transaction_fee', {});
884
886
  }
885
887
  else {
886
- amountAndCurrencyObject = this.safeValue(transaction, 'subtotal', {});
887
- feeObject = this.safeValue(transaction, 'fee', {});
888
+ amountAndCurrencyObject = this.safeDict(transaction, 'subtotal', {});
889
+ feeObject = this.safeDict(transaction, 'fee', {});
888
890
  }
889
891
  let status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
890
892
  if (status === undefined) {
891
- const committed = this.safeValue(transaction, 'committed');
893
+ const committed = this.safeBool(transaction, 'committed');
892
894
  status = committed ? 'ok' : 'pending';
893
895
  }
894
896
  const id = this.safeString(transaction, 'id');
895
897
  const currencyId = this.safeString(amountAndCurrencyObject, 'currency');
896
898
  const feeCurrencyId = this.safeString(feeObject, 'currency');
897
- const datetime = this.safeValue(transaction, 'created_at');
898
- const toObject = this.safeValue(transaction, 'to', {});
899
+ const datetime = this.safeString(transaction, 'created_at');
900
+ const toObject = this.safeDict(transaction, 'to', {});
899
901
  const toAddress = this.safeString(toObject, 'address');
900
902
  return {
901
903
  'info': transaction,
@@ -914,7 +916,7 @@ class coinbase extends coinbase$1 {
914
916
  'amount': this.safeNumber(amountAndCurrencyObject, 'amount'),
915
917
  'currency': this.safeCurrencyCode(currencyId, currency),
916
918
  'status': status,
917
- 'updated': this.parse8601(this.safeValue(transaction, 'updated_at')),
919
+ 'updated': this.parse8601(this.safeString(transaction, 'updated_at')),
918
920
  'fee': {
919
921
  'cost': this.safeNumber(feeObject, 'amount'),
920
922
  'currency': this.safeCurrencyCode(feeCurrencyId),
@@ -984,10 +986,10 @@ class coinbase extends coinbase$1 {
984
986
  // }
985
987
  //
986
988
  let symbol = undefined;
987
- const totalObject = this.safeValue(trade, 'total', {});
988
- const amountObject = this.safeValue(trade, 'amount', {});
989
- const subtotalObject = this.safeValue(trade, 'subtotal', {});
990
- const feeObject = this.safeValue(trade, 'fee', {});
989
+ const totalObject = this.safeDict(trade, 'total', {});
990
+ const amountObject = this.safeDict(trade, 'amount', {});
991
+ const subtotalObject = this.safeDict(trade, 'subtotal', {});
992
+ const feeObject = this.safeDict(trade, 'fee', {});
991
993
  const marketId = this.safeString(trade, 'product_id');
992
994
  market = this.safeMarket(marketId, market, '-');
993
995
  if (market !== undefined) {
@@ -1002,7 +1004,7 @@ class coinbase extends coinbase$1 {
1002
1004
  symbol = base + '/' + quote;
1003
1005
  }
1004
1006
  }
1005
- const sizeInQuote = this.safeValue(trade, 'size_in_quote');
1007
+ const sizeInQuote = this.safeBool(trade, 'size_in_quote');
1006
1008
  const v3Price = this.safeString(trade, 'price');
1007
1009
  let v3Cost = undefined;
1008
1010
  let v3Amount = this.safeString(trade, 'size');
@@ -1071,11 +1073,11 @@ class coinbase extends coinbase$1 {
1071
1073
  }
1072
1074
  async fetchMarketsV2(params = {}) {
1073
1075
  const response = await this.fetchCurrenciesFromCache(params);
1074
- const currencies = this.safeValue(response, 'currencies', {});
1075
- const exchangeRates = this.safeValue(response, 'exchangeRates', {});
1076
- const data = this.safeValue(currencies, 'data', []);
1076
+ const currencies = this.safeDict(response, 'currencies', {});
1077
+ const exchangeRates = this.safeDict(response, 'exchangeRates', {});
1078
+ const data = this.safeList(currencies, 'data', []);
1077
1079
  const dataById = this.indexBy(data, 'id');
1078
- const rates = this.safeValue(this.safeValue(exchangeRates, 'data', {}), 'rates', {});
1080
+ const rates = this.safeDict(this.safeDict(exchangeRates, 'data', {}), 'rates', {});
1079
1081
  const baseIds = Object.keys(rates);
1080
1082
  const result = [];
1081
1083
  for (let i = 0; i < baseIds.length; i++) {
@@ -1197,8 +1199,8 @@ class coinbase extends coinbase$1 {
1197
1199
  // "coinbase_pro_fees": 0
1198
1200
  // }
1199
1201
  //
1200
- const feeTier = this.safeValue(fees, 'fee_tier', {});
1201
- const data = this.safeValue(response, 'products', []);
1202
+ const feeTier = this.safeDict(fees, 'fee_tier', {});
1203
+ const data = this.safeList(response, 'products', []);
1202
1204
  const result = [];
1203
1205
  for (let i = 0; i < data.length; i++) {
1204
1206
  const market = data[i];
@@ -1208,8 +1210,8 @@ class coinbase extends coinbase$1 {
1208
1210
  const base = this.safeCurrencyCode(baseId);
1209
1211
  const quote = this.safeCurrencyCode(quoteId);
1210
1212
  const marketType = this.safeStringLower(market, 'product_type');
1211
- const tradingDisabled = this.safeValue(market, 'trading_disabled');
1212
- const stablePairs = this.safeValue(this.options, 'stablePairs', []);
1213
+ const tradingDisabled = this.safeBool(market, 'trading_disabled');
1214
+ const stablePairs = this.safeList(this.options, 'stablePairs', []);
1213
1215
  result.push({
1214
1216
  'id': id,
1215
1217
  'symbol': base + '/' + quote,
@@ -1265,7 +1267,7 @@ class coinbase extends coinbase$1 {
1265
1267
  return result;
1266
1268
  }
1267
1269
  async fetchCurrenciesFromCache(params = {}) {
1268
- const options = this.safeValue(this.options, 'fetchCurrencies', {});
1270
+ const options = this.safeDict(this.options, 'fetchCurrencies', {});
1269
1271
  const timestamp = this.safeInteger(options, 'timestamp');
1270
1272
  const expires = this.safeInteger(options, 'expires', 1000);
1271
1273
  const now = this.milliseconds();
@@ -1321,7 +1323,7 @@ class coinbase extends coinbase$1 {
1321
1323
  * @returns {object} an associative dictionary of currencies
1322
1324
  */
1323
1325
  const response = await this.fetchCurrenciesFromCache(params);
1324
- const currencies = this.safeValue(response, 'currencies', {});
1326
+ const currencies = this.safeDict(response, 'currencies', {});
1325
1327
  //
1326
1328
  // fiat
1327
1329
  //
@@ -1438,8 +1440,8 @@ class coinbase extends coinbase$1 {
1438
1440
  // }
1439
1441
  // }
1440
1442
  //
1441
- const data = this.safeValue(response, 'data', {});
1442
- const rates = this.safeValue(data, 'rates', {});
1443
+ const data = this.safeDict(response, 'data', {});
1444
+ const rates = this.safeDict(data, 'rates', {});
1443
1445
  const quoteId = this.safeString(data, 'currency');
1444
1446
  const result = {};
1445
1447
  const baseIds = Object.keys(rates);
@@ -1498,7 +1500,7 @@ class coinbase extends coinbase$1 {
1498
1500
  // "num_products": 549
1499
1501
  // }
1500
1502
  //
1501
- const data = this.safeValue(response, 'products', []);
1503
+ const data = this.safeList(response, 'products', []);
1502
1504
  const result = {};
1503
1505
  for (let i = 0; i < data.length; i++) {
1504
1506
  const entry = data[i];
@@ -1546,9 +1548,9 @@ class coinbase extends coinbase$1 {
1546
1548
  //
1547
1549
  // {"data":{"base":"BTC","currency":"USD","amount":"48691.23"}}
1548
1550
  //
1549
- const spotData = this.safeValue(spot, 'data', {});
1550
- const askData = this.safeValue(ask, 'data', {});
1551
- const bidData = this.safeValue(bid, 'data', {});
1551
+ const spotData = this.safeDict(spot, 'data', {});
1552
+ const askData = this.safeDict(ask, 'data', {});
1553
+ const bidData = this.safeDict(bid, 'data', {});
1552
1554
  const bidAskLast = {
1553
1555
  'bid': this.safeNumber(bidData, 'amount'),
1554
1556
  'ask': this.safeNumber(askData, 'amount'),
@@ -1582,7 +1584,7 @@ class coinbase extends coinbase$1 {
1582
1584
  // "best_ask": "28208.62"
1583
1585
  // }
1584
1586
  //
1585
- const data = this.safeValue(response, 'trades', []);
1587
+ const data = this.safeList(response, 'trades', []);
1586
1588
  const ticker = this.parseTicker(data[0], market);
1587
1589
  ticker['bid'] = this.safeNumber(response, 'best_bid');
1588
1590
  ticker['ask'] = this.safeNumber(response, 'best_ask');
@@ -1674,8 +1676,8 @@ class coinbase extends coinbase$1 {
1674
1676
  let bidVolume = undefined;
1675
1677
  let askVolume = undefined;
1676
1678
  if (('bids' in ticker)) {
1677
- const bids = this.safeValue(ticker, 'bids', []);
1678
- const asks = this.safeValue(ticker, 'asks', []);
1679
+ const bids = this.safeList(ticker, 'bids', []);
1680
+ const asks = this.safeList(ticker, 'asks', []);
1679
1681
  bid = this.safeNumber(bids[0], 'price');
1680
1682
  bidVolume = this.safeNumber(bids[0], 'size');
1681
1683
  ask = this.safeNumber(asks[0], 'price');
@@ -1708,21 +1710,21 @@ class coinbase extends coinbase$1 {
1708
1710
  }, market);
1709
1711
  }
1710
1712
  parseCustomBalance(response, params = {}) {
1711
- const balances = this.safeValue2(response, 'data', 'accounts', []);
1712
- const accounts = this.safeValue(params, 'type', this.options['accounts']);
1713
- const v3Accounts = this.safeValue(params, 'type', this.options['v3Accounts']);
1713
+ const balances = this.safeList2(response, 'data', 'accounts', []);
1714
+ const accounts = this.safeList(params, 'type', this.options['accounts']);
1715
+ const v3Accounts = this.safeList(params, 'type', this.options['v3Accounts']);
1714
1716
  const result = { 'info': response };
1715
1717
  for (let b = 0; b < balances.length; b++) {
1716
1718
  const balance = balances[b];
1717
1719
  const type = this.safeString(balance, 'type');
1718
1720
  if (this.inArray(type, accounts)) {
1719
- const value = this.safeValue(balance, 'balance');
1721
+ const value = this.safeDict(balance, 'balance');
1720
1722
  if (value !== undefined) {
1721
1723
  const currencyId = this.safeString(value, 'currency');
1722
1724
  const code = this.safeCurrencyCode(currencyId);
1723
1725
  const total = this.safeString(value, 'amount');
1724
1726
  const free = total;
1725
- let account = this.safeValue(result, code);
1727
+ let account = this.safeDict(result, code);
1726
1728
  if (account === undefined) {
1727
1729
  account = this.account();
1728
1730
  account['free'] = free;
@@ -1736,15 +1738,15 @@ class coinbase extends coinbase$1 {
1736
1738
  }
1737
1739
  }
1738
1740
  else if (this.inArray(type, v3Accounts)) {
1739
- const available = this.safeValue(balance, 'available_balance');
1740
- const hold = this.safeValue(balance, 'hold');
1741
+ const available = this.safeDict(balance, 'available_balance');
1742
+ const hold = this.safeDict(balance, 'hold');
1741
1743
  if (available !== undefined && hold !== undefined) {
1742
1744
  const currencyId = this.safeString(available, 'currency');
1743
1745
  const code = this.safeCurrencyCode(currencyId);
1744
1746
  const used = this.safeString(hold, 'value');
1745
1747
  const free = this.safeString(available, 'value');
1746
1748
  const total = Precise["default"].stringAdd(used, free);
1747
- let account = this.safeValue(result, code);
1749
+ let account = this.safeDict(result, code);
1748
1750
  if (account === undefined) {
1749
1751
  account = this.account();
1750
1752
  account['free'] = free;
@@ -2152,7 +2154,7 @@ class coinbase extends coinbase$1 {
2152
2154
  // }
2153
2155
  // }
2154
2156
  //
2155
- const amountInfo = this.safeValue(item, 'amount', {});
2157
+ const amountInfo = this.safeDict(item, 'amount', {});
2156
2158
  let amount = this.safeString(amountInfo, 'amount');
2157
2159
  let direction = undefined;
2158
2160
  if (Precise["default"].stringLt(amount, '0')) {
@@ -2174,9 +2176,9 @@ class coinbase extends coinbase$1 {
2174
2176
  // let txid = undefined;
2175
2177
  //
2176
2178
  let fee = undefined;
2177
- const networkInfo = this.safeValue(item, 'network', {});
2179
+ const networkInfo = this.safeDict(item, 'network', {});
2178
2180
  // txid = network['hash']; // txid does not belong to the unified ledger structure
2179
- const feeInfo = this.safeValue(networkInfo, 'transaction_fee');
2181
+ const feeInfo = this.safeDict(networkInfo, 'transaction_fee');
2180
2182
  if (feeInfo !== undefined) {
2181
2183
  const feeCurrencyId = this.safeString(feeInfo, 'currency');
2182
2184
  const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId, currency);
@@ -2186,7 +2188,7 @@ class coinbase extends coinbase$1 {
2186
2188
  'currency': feeCurrencyCode,
2187
2189
  };
2188
2190
  }
2189
- const timestamp = this.parse8601(this.safeValue(item, 'created_at'));
2191
+ const timestamp = this.parse8601(this.safeString(item, 'created_at'));
2190
2192
  const id = this.safeString(item, 'id');
2191
2193
  const type = this.parseLedgerEntryType(this.safeString(item, 'type'));
2192
2194
  const status = this.parseLedgerEntryStatus(this.safeString(item, 'status'));
@@ -2318,7 +2320,7 @@ class coinbase extends coinbase$1 {
2318
2320
  const isStopLoss = stopLossPrice !== undefined;
2319
2321
  const isTakeProfit = takeProfitPrice !== undefined;
2320
2322
  const timeInForce = this.safeString(params, 'timeInForce');
2321
- const postOnly = (timeInForce === 'PO') ? true : this.safeValue2(params, 'postOnly', 'post_only', false);
2323
+ const postOnly = (timeInForce === 'PO') ? true : this.safeBool2(params, 'postOnly', 'post_only', false);
2322
2324
  const endTime = this.safeString(params, 'end_time');
2323
2325
  let stopDirection = this.safeString(params, 'stop_direction');
2324
2326
  if (type === 'limit') {
@@ -2388,6 +2390,14 @@ class coinbase extends coinbase$1 {
2388
2390
  },
2389
2391
  };
2390
2392
  }
2393
+ else if (timeInForce === 'IOC') {
2394
+ request['order_configuration'] = {
2395
+ 'sor_limit_ioc': {
2396
+ 'base_size': this.amountToPrecision(symbol, amount),
2397
+ 'limit_price': this.priceToPrecision(symbol, price),
2398
+ },
2399
+ };
2400
+ }
2391
2401
  else {
2392
2402
  request['order_configuration'] = {
2393
2403
  'limit_limit_gtc': {
@@ -2441,7 +2451,7 @@ class coinbase extends coinbase$1 {
2441
2451
  }
2442
2452
  }
2443
2453
  params = this.omit(params, ['timeInForce', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'stop_price', 'stopDirection', 'stop_direction', 'clientOrderId', 'postOnly', 'post_only', 'end_time']);
2444
- const preview = this.safeValue2(params, 'preview', 'test', false);
2454
+ const preview = this.safeBool2(params, 'preview', 'test', false);
2445
2455
  let response = undefined;
2446
2456
  if (preview) {
2447
2457
  params = this.omit(params, ['preview', 'test']);
@@ -2488,9 +2498,9 @@ class coinbase extends coinbase$1 {
2488
2498
  // }
2489
2499
  // }
2490
2500
  //
2491
- const success = this.safeValue(response, 'success');
2501
+ const success = this.safeBool(response, 'success');
2492
2502
  if (success !== true) {
2493
- const errorResponse = this.safeValue(response, 'error_response');
2503
+ const errorResponse = this.safeDict(response, 'error_response');
2494
2504
  const errorTitle = this.safeString(errorResponse, 'error');
2495
2505
  const errorMessage = this.safeString(errorResponse, 'message');
2496
2506
  if (errorResponse !== undefined) {
@@ -2499,7 +2509,7 @@ class coinbase extends coinbase$1 {
2499
2509
  throw new errors.ExchangeError(errorMessage);
2500
2510
  }
2501
2511
  }
2502
- const data = this.safeValue(response, 'success_response', {});
2512
+ const data = this.safeDict(response, 'success_response', {});
2503
2513
  return this.parseOrder(data, market);
2504
2514
  }
2505
2515
  parseOrder(order, market = undefined) {
@@ -2570,29 +2580,39 @@ class coinbase extends coinbase$1 {
2570
2580
  if (symbol !== undefined) {
2571
2581
  market = this.market(symbol);
2572
2582
  }
2573
- const orderConfiguration = this.safeValue(order, 'order_configuration', {});
2574
- const limitGTC = this.safeValue(orderConfiguration, 'limit_limit_gtc');
2575
- const limitGTD = this.safeValue(orderConfiguration, 'limit_limit_gtd');
2576
- const stopLimitGTC = this.safeValue(orderConfiguration, 'stop_limit_stop_limit_gtc');
2577
- const stopLimitGTD = this.safeValue(orderConfiguration, 'stop_limit_stop_limit_gtd');
2578
- const marketIOC = this.safeValue(orderConfiguration, 'market_market_ioc');
2579
- const isLimit = ((limitGTC !== undefined) || (limitGTD !== undefined));
2583
+ const orderConfiguration = this.safeDict(order, 'order_configuration', {});
2584
+ const limitGTC = this.safeDict(orderConfiguration, 'limit_limit_gtc');
2585
+ const limitGTD = this.safeDict(orderConfiguration, 'limit_limit_gtd');
2586
+ const limitIOC = this.safeDict(orderConfiguration, 'sor_limit_ioc');
2587
+ const stopLimitGTC = this.safeDict(orderConfiguration, 'stop_limit_stop_limit_gtc');
2588
+ const stopLimitGTD = this.safeDict(orderConfiguration, 'stop_limit_stop_limit_gtd');
2589
+ const marketIOC = this.safeDict(orderConfiguration, 'market_market_ioc');
2590
+ const isLimit = ((limitGTC !== undefined) || (limitGTD !== undefined) || (limitIOC !== undefined));
2580
2591
  const isStop = ((stopLimitGTC !== undefined) || (stopLimitGTD !== undefined));
2581
2592
  let price = undefined;
2582
2593
  let amount = undefined;
2583
2594
  let postOnly = undefined;
2584
2595
  let triggerPrice = undefined;
2585
2596
  if (isLimit) {
2586
- const target = (limitGTC !== undefined) ? limitGTC : limitGTD;
2597
+ let target = undefined;
2598
+ if (limitGTC !== undefined) {
2599
+ target = limitGTC;
2600
+ }
2601
+ else if (limitGTD !== undefined) {
2602
+ target = limitGTD;
2603
+ }
2604
+ else {
2605
+ target = limitIOC;
2606
+ }
2587
2607
  price = this.safeString(target, 'limit_price');
2588
2608
  amount = this.safeString(target, 'base_size');
2589
- postOnly = this.safeValue(target, 'post_only');
2609
+ postOnly = this.safeBool(target, 'post_only');
2590
2610
  }
2591
2611
  else if (isStop) {
2592
2612
  const stopTarget = (stopLimitGTC !== undefined) ? stopLimitGTC : stopLimitGTD;
2593
2613
  price = this.safeString(stopTarget, 'limit_price');
2594
2614
  amount = this.safeString(stopTarget, 'base_size');
2595
- postOnly = this.safeValue(stopTarget, 'post_only');
2615
+ postOnly = this.safeBool(stopTarget, 'post_only');
2596
2616
  triggerPrice = this.safeString(stopTarget, 'stop_price');
2597
2617
  }
2598
2618
  else {
@@ -2678,7 +2698,7 @@ class coinbase extends coinbase$1 {
2678
2698
  */
2679
2699
  await this.loadMarkets();
2680
2700
  const orders = await this.cancelOrders([id], symbol, params);
2681
- return this.safeValue(orders, 0, {});
2701
+ return this.safeDict(orders, 0, {});
2682
2702
  }
2683
2703
  async cancelOrders(ids, symbol = undefined, params = {}) {
2684
2704
  /**
@@ -2711,9 +2731,9 @@ class coinbase extends coinbase$1 {
2711
2731
  // ]
2712
2732
  // }
2713
2733
  //
2714
- const orders = this.safeValue(response, 'results', []);
2734
+ const orders = this.safeList(response, 'results', []);
2715
2735
  for (let i = 0; i < orders.length; i++) {
2716
- const success = this.safeValue(orders[i], 'success');
2736
+ const success = this.safeBool(orders[i], 'success');
2717
2737
  if (success !== true) {
2718
2738
  throw new errors.BadRequest(this.id + ' cancelOrders() has failed, check your arguments and parameters');
2719
2739
  }
@@ -2747,7 +2767,7 @@ class coinbase extends coinbase$1 {
2747
2767
  if (price !== undefined) {
2748
2768
  request['price'] = this.priceToPrecision(symbol, price);
2749
2769
  }
2750
- const preview = this.safeValue2(params, 'preview', 'test', false);
2770
+ const preview = this.safeBool2(params, 'preview', 'test', false);
2751
2771
  let response = undefined;
2752
2772
  if (preview) {
2753
2773
  params = this.omit(params, ['preview', 'test']);
@@ -2826,7 +2846,7 @@ class coinbase extends coinbase$1 {
2826
2846
  // }
2827
2847
  // }
2828
2848
  //
2829
- const order = this.safeValue(response, 'order', {});
2849
+ const order = this.safeDict(response, 'order', {});
2830
2850
  return this.parseOrder(order, market);
2831
2851
  }
2832
2852
  async fetchOrders(symbol = undefined, since = undefined, limit = 100, params = {}) {
@@ -2863,7 +2883,7 @@ class coinbase extends coinbase$1 {
2863
2883
  if (since !== undefined) {
2864
2884
  request['start_date'] = this.iso8601(since);
2865
2885
  }
2866
- const until = this.safeValueN(params, ['until', 'till']);
2886
+ const until = this.safeIntegerN(params, ['until', 'till']);
2867
2887
  if (until !== undefined) {
2868
2888
  params = this.omit(params, ['until', 'till']);
2869
2889
  request['end_date'] = this.iso8601(until);
@@ -2911,8 +2931,8 @@ class coinbase extends coinbase$1 {
2911
2931
  // "cursor": ""
2912
2932
  // }
2913
2933
  //
2914
- const orders = this.safeValue(response, 'orders', []);
2915
- const first = this.safeValue(orders, 0);
2934
+ const orders = this.safeList(response, 'orders', []);
2935
+ const first = this.safeDict(orders, 0);
2916
2936
  const cursor = this.safeString(response, 'cursor');
2917
2937
  if ((cursor !== undefined) && (cursor !== '')) {
2918
2938
  first['cursor'] = cursor;
@@ -2939,7 +2959,7 @@ class coinbase extends coinbase$1 {
2939
2959
  if (since !== undefined) {
2940
2960
  request['start_date'] = this.iso8601(since);
2941
2961
  }
2942
- const until = this.safeValueN(params, ['until', 'till']);
2962
+ const until = this.safeIntegerN(params, ['until', 'till']);
2943
2963
  if (until !== undefined) {
2944
2964
  params = this.omit(params, ['until', 'till']);
2945
2965
  request['end_date'] = this.iso8601(until);
@@ -2987,8 +3007,8 @@ class coinbase extends coinbase$1 {
2987
3007
  // "cursor": ""
2988
3008
  // }
2989
3009
  //
2990
- const orders = this.safeValue(response, 'orders', []);
2991
- const first = this.safeValue(orders, 0);
3010
+ const orders = this.safeList(response, 'orders', []);
3011
+ const first = this.safeDict(orders, 0);
2992
3012
  const cursor = this.safeString(response, 'cursor');
2993
3013
  if ((cursor !== undefined) && (cursor !== '')) {
2994
3014
  first['cursor'] = cursor;
@@ -3082,7 +3102,7 @@ class coinbase extends coinbase$1 {
3082
3102
  'product_id': market['id'],
3083
3103
  'granularity': this.safeString(this.timeframes, timeframe, timeframe),
3084
3104
  };
3085
- const until = this.safeValueN(params, ['until', 'till', 'end']);
3105
+ const until = this.safeIntegerN(params, ['until', 'till', 'end']);
3086
3106
  params = this.omit(params, ['until', 'till']);
3087
3107
  const duration = this.parseTimeframe(timeframe);
3088
3108
  const requestedDuration = limit * duration;
@@ -3116,7 +3136,7 @@ class coinbase extends coinbase$1 {
3116
3136
  // ]
3117
3137
  // }
3118
3138
  //
3119
- const candles = this.safeValue(response, 'candles', []);
3139
+ const candles = this.safeList(response, 'candles', []);
3120
3140
  return this.parseOHLCVs(candles, market, timeframe, since, limit);
3121
3141
  }
3122
3142
  parseOHLCV(ohlcv, market = undefined) {
@@ -3189,7 +3209,7 @@ class coinbase extends coinbase$1 {
3189
3209
  // ]
3190
3210
  // }
3191
3211
  //
3192
- const trades = this.safeValue(response, 'trades', []);
3212
+ const trades = this.safeList(response, 'trades', []);
3193
3213
  return this.parseTrades(trades, market, since, limit);
3194
3214
  }
3195
3215
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -3226,7 +3246,7 @@ class coinbase extends coinbase$1 {
3226
3246
  if (since !== undefined) {
3227
3247
  request['start_sequence_timestamp'] = this.iso8601(since);
3228
3248
  }
3229
- const until = this.safeValueN(params, ['until', 'till']);
3249
+ const until = this.safeIntegerN(params, ['until', 'till']);
3230
3250
  if (until !== undefined) {
3231
3251
  params = this.omit(params, ['until', 'till']);
3232
3252
  request['end_sequence_timestamp'] = this.iso8601(until);
@@ -3255,8 +3275,8 @@ class coinbase extends coinbase$1 {
3255
3275
  // "cursor": ""
3256
3276
  // }
3257
3277
  //
3258
- const trades = this.safeValue(response, 'fills', []);
3259
- const first = this.safeValue(trades, 0);
3278
+ const trades = this.safeList(response, 'fills', []);
3279
+ const first = this.safeDict(trades, 0);
3260
3280
  const cursor = this.safeString(response, 'cursor');
3261
3281
  if ((cursor !== undefined) && (cursor !== '')) {
3262
3282
  first['cursor'] = cursor;
@@ -3348,7 +3368,7 @@ class coinbase extends coinbase$1 {
3348
3368
  // ]
3349
3369
  // }
3350
3370
  //
3351
- const tickers = this.safeValue(response, 'pricebooks', []);
3371
+ const tickers = this.safeList(response, 'pricebooks', []);
3352
3372
  return this.parseTickers(tickers, symbols);
3353
3373
  }
3354
3374
  async withdraw(code, amount, address, tag = undefined, params = {}) {
@@ -3442,7 +3462,7 @@ class coinbase extends coinbase$1 {
3442
3462
  // }
3443
3463
  // }
3444
3464
  //
3445
- const data = this.safeValue(response, 'data', {});
3465
+ const data = this.safeDict(response, 'data', {});
3446
3466
  return this.parseTransaction(data, currency);
3447
3467
  }
3448
3468
  async fetchDepositAddressesByNetwork(code, params = {}) {
@@ -3715,7 +3735,7 @@ class coinbase extends coinbase$1 {
3715
3735
  // }
3716
3736
  // }
3717
3737
  //
3718
- const data = this.safeValue(response, 'data', {});
3738
+ const data = this.safeDict(response, 'data', {});
3719
3739
  return this.parseTransaction(data);
3720
3740
  }
3721
3741
  sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
@@ -3815,7 +3835,7 @@ class coinbase extends coinbase$1 {
3815
3835
  this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessage, feedback);
3816
3836
  throw new errors.ExchangeError(feedback);
3817
3837
  }
3818
- const errors$1 = this.safeValue(response, 'errors');
3838
+ const errors$1 = this.safeList(response, 'errors');
3819
3839
  if (errors$1 !== undefined) {
3820
3840
  if (Array.isArray(errors$1)) {
3821
3841
  const numErrors = errors$1.length;
@@ -3831,8 +3851,7 @@ class coinbase extends coinbase$1 {
3831
3851
  }
3832
3852
  }
3833
3853
  const advancedTrade = this.options['advanced'];
3834
- const data = this.safeValue(response, 'data');
3835
- if ((data === undefined) && (!advancedTrade)) {
3854
+ if (!('data' in response) && (!advancedTrade)) {
3836
3855
  throw new errors.ExchangeError(this.id + ' failed due to a malformed response ' + this.json(response));
3837
3856
  }
3838
3857
  return undefined;
@@ -1523,7 +1523,8 @@ class digifinex extends digifinex$1 {
1523
1523
  else if (limit !== undefined) {
1524
1524
  const endTime = this.seconds();
1525
1525
  const duration = this.parseTimeframe(timeframe);
1526
- request['start_time'] = this.sum(endTime, -limit * duration);
1526
+ const auxLimit = limit; // in c# -limit is mutating the arg
1527
+ request['start_time'] = this.sum(endTime, -auxLimit * duration);
1527
1528
  }
1528
1529
  response = await this.publicSpotGetKline(this.extend(request, params));
1529
1530
  }