ccxt 4.2.44 → 4.2.45
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/README.md +3 -3
- package/dist/ccxt.browser.js +863 -139
- package/dist/ccxt.browser.min.js +6 -6
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +48 -0
- package/dist/cjs/src/binance.js +373 -9
- package/dist/cjs/src/bingx.js +43 -5
- package/dist/cjs/src/bitstamp.js +1 -1
- package/dist/cjs/src/bybit.js +96 -43
- package/dist/cjs/src/coinbase.js +220 -34
- package/dist/cjs/src/deribit.js +1 -1
- package/dist/cjs/src/pro/gate.js +76 -42
- package/dist/cjs/src/pro/hitbtc.js +1 -0
- package/dist/cjs/src/probit.js +3 -3
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/coinbase.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +4 -0
- package/js/src/base/Exchange.js +48 -0
- package/js/src/binance.d.ts +1 -0
- package/js/src/binance.js +373 -9
- package/js/src/bingx.d.ts +2 -1
- package/js/src/bingx.js +43 -5
- package/js/src/bitstamp.js +1 -1
- package/js/src/bybit.d.ts +4 -1
- package/js/src/bybit.js +96 -43
- package/js/src/coinbase.d.ts +10 -4
- package/js/src/coinbase.js +220 -34
- package/js/src/deribit.js +1 -1
- package/js/src/pro/gate.d.ts +4 -0
- package/js/src/pro/gate.js +76 -42
- package/js/src/pro/hitbtc.js +1 -0
- package/js/src/probit.js +3 -3
- package/package.json +1 -1
package/js/src/bybit.js
CHANGED
|
@@ -59,7 +59,9 @@ export default class bybit extends Exchange {
|
|
|
59
59
|
'fetchBorrowInterest': false,
|
|
60
60
|
'fetchBorrowRateHistories': false,
|
|
61
61
|
'fetchBorrowRateHistory': false,
|
|
62
|
+
'fetchCanceledAndClosedOrders': true,
|
|
62
63
|
'fetchCanceledOrders': true,
|
|
64
|
+
'fetchClosedOrder': true,
|
|
63
65
|
'fetchClosedOrders': true,
|
|
64
66
|
'fetchCrossBorrowRate': true,
|
|
65
67
|
'fetchCrossBorrowRates': false,
|
|
@@ -87,10 +89,11 @@ export default class bybit extends Exchange {
|
|
|
87
89
|
'fetchOHLCV': true,
|
|
88
90
|
'fetchOpenInterest': true,
|
|
89
91
|
'fetchOpenInterestHistory': true,
|
|
92
|
+
'fetchOpenOrder': true,
|
|
90
93
|
'fetchOpenOrders': true,
|
|
91
|
-
'fetchOrder':
|
|
94
|
+
'fetchOrder': false,
|
|
92
95
|
'fetchOrderBook': true,
|
|
93
|
-
'fetchOrders':
|
|
96
|
+
'fetchOrders': false,
|
|
94
97
|
'fetchOrderTrades': true,
|
|
95
98
|
'fetchPosition': true,
|
|
96
99
|
'fetchPositions': true,
|
|
@@ -3444,35 +3447,6 @@ export default class bybit extends Exchange {
|
|
|
3444
3447
|
'trades': undefined,
|
|
3445
3448
|
}, market);
|
|
3446
3449
|
}
|
|
3447
|
-
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
3448
|
-
/**
|
|
3449
|
-
* @method
|
|
3450
|
-
* @name bybit#fetchOrder
|
|
3451
|
-
* @description fetches information on an order made by the user
|
|
3452
|
-
* @see https://bybit-exchange.github.io/docs/v5/order/order-list
|
|
3453
|
-
* @param {string} symbol unified symbol of the market the order was made in
|
|
3454
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3455
|
-
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3456
|
-
*/
|
|
3457
|
-
if (symbol === undefined) {
|
|
3458
|
-
throw new ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
|
|
3459
|
-
}
|
|
3460
|
-
await this.loadMarkets();
|
|
3461
|
-
const request = {
|
|
3462
|
-
'orderId': id,
|
|
3463
|
-
};
|
|
3464
|
-
const result = await this.fetchOrders(symbol, undefined, undefined, this.extend(request, params));
|
|
3465
|
-
const length = result.length;
|
|
3466
|
-
if (length === 0) {
|
|
3467
|
-
const isTrigger = this.safeBoolN(params, ['trigger', 'stop'], false);
|
|
3468
|
-
const extra = isTrigger ? '' : 'If you are trying to fetch SL/TP conditional order, you might try setting params["trigger"] = true';
|
|
3469
|
-
throw new OrderNotFound('Order ' + id.toString() + ' was not found.' + extra);
|
|
3470
|
-
}
|
|
3471
|
-
if (length > 1) {
|
|
3472
|
-
throw new InvalidOrder(this.id + ' returned more than one order');
|
|
3473
|
-
}
|
|
3474
|
-
return this.safeValue(result, 0);
|
|
3475
|
-
}
|
|
3476
3450
|
async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
|
|
3477
3451
|
/**
|
|
3478
3452
|
* @method
|
|
@@ -4508,29 +4482,99 @@ export default class bybit extends Exchange {
|
|
|
4508
4482
|
const data = this.safeValue(result, 'dataList', []);
|
|
4509
4483
|
return this.parseOrders(data, market, since, limit);
|
|
4510
4484
|
}
|
|
4485
|
+
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
4486
|
+
throw new NotSupported(this.id + ' fetchOrder() is not supported after the 5/02 update, please use fetchOpenOrder or fetchClosedOrder');
|
|
4487
|
+
}
|
|
4511
4488
|
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
4489
|
+
throw new NotSupported(this.id + ' fetchOrders() is not supported after the 5/02 update, please use fetchOpenOrders, fetchClosedOrders or fetchCanceledOrders');
|
|
4490
|
+
}
|
|
4491
|
+
async fetchClosedOrder(id, symbol = undefined, params = {}) {
|
|
4492
|
+
/**
|
|
4493
|
+
* @method
|
|
4494
|
+
* @name bybit#fetchClosedOrder
|
|
4495
|
+
* @description fetches information on a closed order made by the user
|
|
4496
|
+
* @see https://bybit-exchange.github.io/docs/v5/order/order-list
|
|
4497
|
+
* @param {string} id order id
|
|
4498
|
+
* @param {string} [symbol] unified symbol of the market the order was made in
|
|
4499
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4500
|
+
* @param {boolean} [params.stop] set to true for fetching a closed stop order
|
|
4501
|
+
* @param {string} [params.type] market type, ['swap', 'option', 'spot']
|
|
4502
|
+
* @param {string} [params.subType] market subType, ['linear', 'inverse']
|
|
4503
|
+
* @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
|
|
4504
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4505
|
+
*/
|
|
4506
|
+
await this.loadMarkets();
|
|
4507
|
+
const request = {
|
|
4508
|
+
'orderId': id,
|
|
4509
|
+
};
|
|
4510
|
+
const result = await this.fetchClosedOrders(symbol, undefined, undefined, this.extend(request, params));
|
|
4511
|
+
const length = result.length;
|
|
4512
|
+
if (length === 0) {
|
|
4513
|
+
const isTrigger = this.safeBoolN(params, ['trigger', 'stop'], false);
|
|
4514
|
+
const extra = isTrigger ? '' : 'If you are trying to fetch SL/TP conditional order, you might try setting params["trigger"] = true';
|
|
4515
|
+
throw new OrderNotFound('Order ' + id.toString() + ' was not found.' + extra);
|
|
4516
|
+
}
|
|
4517
|
+
if (length > 1) {
|
|
4518
|
+
throw new InvalidOrder(this.id + ' returned more than one order');
|
|
4519
|
+
}
|
|
4520
|
+
return this.safeValue(result, 0);
|
|
4521
|
+
}
|
|
4522
|
+
async fetchOpenOrder(id, symbol = undefined, params = {}) {
|
|
4523
|
+
/**
|
|
4524
|
+
* @method
|
|
4525
|
+
* @name bybit#fetchOpenOrder
|
|
4526
|
+
* @description fetches information on an open order made by the user
|
|
4527
|
+
* @see https://bybit-exchange.github.io/docs/v5/order/open-order
|
|
4528
|
+
* @param {string} id order id
|
|
4529
|
+
* @param {string} [symbol] unified symbol of the market the order was made in
|
|
4530
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4531
|
+
* @param {boolean} [params.stop] set to true for fetching an open stop order
|
|
4532
|
+
* @param {string} [params.type] market type, ['swap', 'option', 'spot']
|
|
4533
|
+
* @param {string} [params.subType] market subType, ['linear', 'inverse']
|
|
4534
|
+
* @param {string} [params.baseCoin] Base coin. Supports linear, inverse & option
|
|
4535
|
+
* @param {string} [params.settleCoin] Settle coin. Supports linear, inverse & option
|
|
4536
|
+
* @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
|
|
4537
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4538
|
+
*/
|
|
4539
|
+
await this.loadMarkets();
|
|
4540
|
+
const request = {
|
|
4541
|
+
'orderId': id,
|
|
4542
|
+
};
|
|
4543
|
+
const result = await this.fetchOpenOrders(symbol, undefined, undefined, this.extend(request, params));
|
|
4544
|
+
const length = result.length;
|
|
4545
|
+
if (length === 0) {
|
|
4546
|
+
const isTrigger = this.safeBoolN(params, ['trigger', 'stop'], false);
|
|
4547
|
+
const extra = isTrigger ? '' : 'If you are trying to fetch SL/TP conditional order, you might try setting params["trigger"] = true';
|
|
4548
|
+
throw new OrderNotFound('Order ' + id.toString() + ' was not found.' + extra);
|
|
4549
|
+
}
|
|
4550
|
+
if (length > 1) {
|
|
4551
|
+
throw new InvalidOrder(this.id + ' returned more than one order');
|
|
4552
|
+
}
|
|
4553
|
+
return this.safeValue(result, 0);
|
|
4554
|
+
}
|
|
4555
|
+
async fetchCanceledAndClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
4512
4556
|
/**
|
|
4513
4557
|
* @method
|
|
4514
|
-
* @name bybit#
|
|
4515
|
-
* @description fetches information on multiple orders made by the user
|
|
4558
|
+
* @name bybit#fetchCanceledAndClosedOrders
|
|
4559
|
+
* @description fetches information on multiple canceled and closed orders made by the user
|
|
4516
4560
|
* @see https://bybit-exchange.github.io/docs/v5/order/order-list
|
|
4517
|
-
* @param {string} symbol unified market symbol of the market orders were made in
|
|
4561
|
+
* @param {string} [symbol] unified market symbol of the market orders were made in
|
|
4518
4562
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
4519
4563
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
4520
4564
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4521
|
-
* @param {boolean} [params.stop] true
|
|
4565
|
+
* @param {boolean} [params.stop] set to true for fetching stop orders
|
|
4522
4566
|
* @param {string} [params.type] market type, ['swap', 'option', 'spot']
|
|
4523
4567
|
* @param {string} [params.subType] market subType, ['linear', 'inverse']
|
|
4524
4568
|
* @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
|
|
4525
4569
|
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
4526
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
4570
|
+
* @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)
|
|
4527
4571
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4528
4572
|
*/
|
|
4529
4573
|
await this.loadMarkets();
|
|
4530
4574
|
let paginate = false;
|
|
4531
|
-
[paginate, params] = this.handleOptionAndParams(params, '
|
|
4575
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchCanceledAndClosedOrders', 'paginate');
|
|
4532
4576
|
if (paginate) {
|
|
4533
|
-
return await this.fetchPaginatedCallCursor('
|
|
4577
|
+
return await this.fetchPaginatedCallCursor('fetchCanceledAndClosedOrders', symbol, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
|
|
4534
4578
|
}
|
|
4535
4579
|
const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
|
|
4536
4580
|
const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
|
|
@@ -4543,7 +4587,7 @@ export default class bybit extends Exchange {
|
|
|
4543
4587
|
request['symbol'] = market['id'];
|
|
4544
4588
|
}
|
|
4545
4589
|
let type = undefined;
|
|
4546
|
-
[type, params] = this.getBybitType('
|
|
4590
|
+
[type, params] = this.getBybitType('fetchCanceledAndClosedOrders', market, params);
|
|
4547
4591
|
if (((type === 'option') || isUsdcSettled) && !isUnifiedAccount) {
|
|
4548
4592
|
return await this.fetchUsdcOrders(symbol, since, limit, params);
|
|
4549
4593
|
}
|
|
@@ -4625,17 +4669,23 @@ export default class bybit extends Exchange {
|
|
|
4625
4669
|
* @name bybit#fetchClosedOrders
|
|
4626
4670
|
* @description fetches information on multiple closed orders made by the user
|
|
4627
4671
|
* @see https://bybit-exchange.github.io/docs/v5/order/order-list
|
|
4628
|
-
* @param {string} symbol unified market symbol of the market orders were made in
|
|
4672
|
+
* @param {string} [symbol] unified market symbol of the market orders were made in
|
|
4629
4673
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
4630
4674
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
4631
4675
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4676
|
+
* @param {boolean} [params.stop] set to true for fetching closed stop orders
|
|
4677
|
+
* @param {string} [params.type] market type, ['swap', 'option', 'spot']
|
|
4678
|
+
* @param {string} [params.subType] market subType, ['linear', 'inverse']
|
|
4679
|
+
* @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
|
|
4680
|
+
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
4681
|
+
* @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)
|
|
4632
4682
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4633
4683
|
*/
|
|
4634
4684
|
await this.loadMarkets();
|
|
4635
4685
|
const request = {
|
|
4636
4686
|
'orderStatus': 'Filled',
|
|
4637
4687
|
};
|
|
4638
|
-
return await this.
|
|
4688
|
+
return await this.fetchCanceledAndClosedOrders(symbol, since, limit, this.extend(request, params));
|
|
4639
4689
|
}
|
|
4640
4690
|
async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
4641
4691
|
/**
|
|
@@ -4643,20 +4693,23 @@ export default class bybit extends Exchange {
|
|
|
4643
4693
|
* @name bybit#fetchCanceledOrders
|
|
4644
4694
|
* @description fetches information on multiple canceled orders made by the user
|
|
4645
4695
|
* @see https://bybit-exchange.github.io/docs/v5/order/order-list
|
|
4646
|
-
* @param {string} symbol unified market symbol of the market orders were made in
|
|
4696
|
+
* @param {string} [symbol] unified market symbol of the market orders were made in
|
|
4647
4697
|
* @param {int} [since] timestamp in ms of the earliest order, default is undefined
|
|
4648
4698
|
* @param {int} [limit] max number of orders to return, default is undefined
|
|
4649
4699
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4650
4700
|
* @param {boolean} [params.stop] true if stop order
|
|
4651
4701
|
* @param {string} [params.type] market type, ['swap', 'option', 'spot']
|
|
4652
4702
|
* @param {string} [params.subType] market subType, ['linear', 'inverse']
|
|
4703
|
+
* @param {string} [params.orderFilter] 'Order' or 'StopOrder' or 'tpslOrder'
|
|
4704
|
+
* @param {int} [params.until] the latest time in ms to fetch entries for
|
|
4705
|
+
* @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)
|
|
4653
4706
|
* @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4654
4707
|
*/
|
|
4655
4708
|
await this.loadMarkets();
|
|
4656
4709
|
const request = {
|
|
4657
4710
|
'orderStatus': 'Cancelled',
|
|
4658
4711
|
};
|
|
4659
|
-
return await this.
|
|
4712
|
+
return await this.fetchCanceledAndClosedOrders(symbol, since, limit, this.extend(request, params));
|
|
4660
4713
|
}
|
|
4661
4714
|
async fetchUsdcOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
4662
4715
|
await this.loadMarkets();
|
package/js/src/coinbase.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export default class coinbase extends Exchange {
|
|
|
33
33
|
fetchMarkets(params?: {}): Promise<any>;
|
|
34
34
|
fetchMarketsV2(params?: {}): Promise<any[]>;
|
|
35
35
|
fetchMarketsV3(params?: {}): Promise<any[]>;
|
|
36
|
-
fetchCurrenciesFromCache(params?: {}): Promise<any
|
|
36
|
+
fetchCurrenciesFromCache(params?: {}): Promise<import("./base/types.js").Dictionary<any>>;
|
|
37
37
|
fetchCurrencies(params?: {}): Promise<{}>;
|
|
38
38
|
fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
39
39
|
fetchTickersV2(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Dictionary<Ticker>>;
|
|
@@ -68,9 +68,7 @@ export default class coinbase extends Exchange {
|
|
|
68
68
|
prepareAccountRequest(limit?: Int, params?: {}): {
|
|
69
69
|
account_id: string;
|
|
70
70
|
};
|
|
71
|
-
prepareAccountRequestWithCurrencyCode(code?: Str, limit?: Int, params?: {}): Promise<{
|
|
72
|
-
account_id: string;
|
|
73
|
-
}>;
|
|
71
|
+
prepareAccountRequestWithCurrencyCode(code?: Str, limit?: Int, params?: {}): Promise<{}[]>;
|
|
74
72
|
createMarketBuyOrderWithCost(symbol: string, cost: number, params?: {}): Promise<Order>;
|
|
75
73
|
createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: number, params?: {}): Promise<Order>;
|
|
76
74
|
parseOrder(order: any, market?: Market): Order;
|
|
@@ -93,6 +91,14 @@ export default class coinbase extends Exchange {
|
|
|
93
91
|
fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
|
|
94
92
|
fetchBidsAsks(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Dictionary<Ticker>>;
|
|
95
93
|
withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
|
|
94
|
+
fetchDepositAddressesByNetwork(code: string, params?: {}): Promise<{}>;
|
|
95
|
+
parseDepositAddress(depositAddress: any, currency?: Currency): {
|
|
96
|
+
info: any;
|
|
97
|
+
currency: string;
|
|
98
|
+
address: string;
|
|
99
|
+
tag: string;
|
|
100
|
+
network: string;
|
|
101
|
+
};
|
|
96
102
|
sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
|
|
97
103
|
url: string;
|
|
98
104
|
method: string;
|
package/js/src/coinbase.js
CHANGED
|
@@ -65,6 +65,7 @@ export default class coinbase extends Exchange {
|
|
|
65
65
|
'fetchCrossBorrowRate': false,
|
|
66
66
|
'fetchCrossBorrowRates': false,
|
|
67
67
|
'fetchCurrencies': true,
|
|
68
|
+
'fetchDepositAddressesByNetwork': true,
|
|
68
69
|
'fetchDeposits': true,
|
|
69
70
|
'fetchFundingHistory': false,
|
|
70
71
|
'fetchFundingRate': false,
|
|
@@ -132,6 +133,7 @@ export default class coinbase extends Exchange {
|
|
|
132
133
|
'public': {
|
|
133
134
|
'get': [
|
|
134
135
|
'currencies',
|
|
136
|
+
'currencies/crypto',
|
|
135
137
|
'time',
|
|
136
138
|
'exchange-rates',
|
|
137
139
|
'users/{user_id}',
|
|
@@ -326,6 +328,10 @@ export default class coinbase extends Exchange {
|
|
|
326
328
|
'ACCOUNT_TYPE_CRYPTO',
|
|
327
329
|
'ACCOUNT_TYPE_FIAT',
|
|
328
330
|
],
|
|
331
|
+
'networks': {
|
|
332
|
+
'ERC20': 'ethereum',
|
|
333
|
+
'XLM': 'stellar',
|
|
334
|
+
},
|
|
329
335
|
'createMarketBuyOrderRequiresPrice': true,
|
|
330
336
|
'advanced': true,
|
|
331
337
|
'fetchMarkets': 'fetchMarketsV3',
|
|
@@ -681,10 +687,10 @@ export default class coinbase extends Exchange {
|
|
|
681
687
|
return this.parseTrades(buys['data'], undefined, since, limit);
|
|
682
688
|
}
|
|
683
689
|
async fetchTransactionsWithMethod(method, code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
684
|
-
|
|
690
|
+
let request = undefined;
|
|
691
|
+
[request, params] = await this.prepareAccountRequestWithCurrencyCode(code, limit, params);
|
|
685
692
|
await this.loadMarkets();
|
|
686
|
-
const
|
|
687
|
-
const response = await this[method](this.extend(request, query));
|
|
693
|
+
const response = await this[method](this.extend(request, params));
|
|
688
694
|
return this.parseTransactions(response['data'], undefined, since, limit);
|
|
689
695
|
}
|
|
690
696
|
async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -1236,15 +1242,45 @@ export default class coinbase extends Exchange {
|
|
|
1236
1242
|
const expires = this.safeInteger(options, 'expires', 1000);
|
|
1237
1243
|
const now = this.milliseconds();
|
|
1238
1244
|
if ((timestamp === undefined) || ((now - timestamp) > expires)) {
|
|
1239
|
-
const
|
|
1245
|
+
const promises = [
|
|
1246
|
+
this.v2PublicGetCurrencies(params),
|
|
1247
|
+
this.v2PublicGetCurrenciesCrypto(params),
|
|
1248
|
+
];
|
|
1249
|
+
const promisesResult = await Promise.all(promises);
|
|
1250
|
+
const fiatResponse = this.safeDict(promisesResult, 0, {});
|
|
1251
|
+
//
|
|
1252
|
+
// [
|
|
1253
|
+
// "data": {
|
|
1254
|
+
// id: 'IMP',
|
|
1255
|
+
// name: 'Isle of Man Pound',
|
|
1256
|
+
// min_size: '0.01'
|
|
1257
|
+
// },
|
|
1258
|
+
// ...
|
|
1259
|
+
// ]
|
|
1260
|
+
//
|
|
1261
|
+
const cryptoResponse = this.safeDict(promisesResult, 1, {});
|
|
1262
|
+
//
|
|
1263
|
+
// {
|
|
1264
|
+
// asset_id: '9476e3be-b731-47fa-82be-347fabc573d9',
|
|
1265
|
+
// code: 'AERO',
|
|
1266
|
+
// name: 'Aerodrome Finance',
|
|
1267
|
+
// color: '#0433FF',
|
|
1268
|
+
// sort_index: '340',
|
|
1269
|
+
// exponent: '8',
|
|
1270
|
+
// type: 'crypto',
|
|
1271
|
+
// address_regex: '^(?:0x)?[0-9a-fA-F]{40}$'
|
|
1272
|
+
// }
|
|
1273
|
+
//
|
|
1274
|
+
const fiatData = this.safeList(fiatResponse, 'data', []);
|
|
1275
|
+
const cryptoData = this.safeList(cryptoResponse, 'data', []);
|
|
1240
1276
|
const exchangeRates = await this.v2PublicGetExchangeRates(params);
|
|
1241
1277
|
this.options['fetchCurrencies'] = this.extend(options, {
|
|
1242
|
-
'currencies':
|
|
1278
|
+
'currencies': this.arrayConcat(fiatData, cryptoData),
|
|
1243
1279
|
'exchangeRates': exchangeRates,
|
|
1244
1280
|
'timestamp': now,
|
|
1245
1281
|
});
|
|
1246
1282
|
}
|
|
1247
|
-
return this.
|
|
1283
|
+
return this.safeDict(this.options, 'fetchCurrencies', {});
|
|
1248
1284
|
}
|
|
1249
1285
|
async fetchCurrencies(params = {}) {
|
|
1250
1286
|
/**
|
|
@@ -1259,18 +1295,27 @@ export default class coinbase extends Exchange {
|
|
|
1259
1295
|
const response = await this.fetchCurrenciesFromCache(params);
|
|
1260
1296
|
const currencies = this.safeValue(response, 'currencies', {});
|
|
1261
1297
|
//
|
|
1262
|
-
//
|
|
1263
|
-
//
|
|
1264
|
-
//
|
|
1265
|
-
//
|
|
1266
|
-
//
|
|
1267
|
-
//
|
|
1268
|
-
//
|
|
1269
|
-
//
|
|
1270
|
-
//
|
|
1271
|
-
//
|
|
1298
|
+
// fiat
|
|
1299
|
+
//
|
|
1300
|
+
// {
|
|
1301
|
+
// id: 'IMP',
|
|
1302
|
+
// name: 'Isle of Man Pound',
|
|
1303
|
+
// min_size: '0.01'
|
|
1304
|
+
// },
|
|
1305
|
+
//
|
|
1306
|
+
// crypto
|
|
1307
|
+
//
|
|
1308
|
+
// {
|
|
1309
|
+
// asset_id: '9476e3be-b731-47fa-82be-347fabc573d9',
|
|
1310
|
+
// code: 'AERO',
|
|
1311
|
+
// name: 'Aerodrome Finance',
|
|
1312
|
+
// color: '#0433FF',
|
|
1313
|
+
// sort_index: '340',
|
|
1314
|
+
// exponent: '8',
|
|
1315
|
+
// type: 'crypto',
|
|
1316
|
+
// address_regex: '^(?:0x)?[0-9a-fA-F]{40}$'
|
|
1317
|
+
// }
|
|
1272
1318
|
//
|
|
1273
|
-
const exchangeRates = this.safeValue(response, 'exchangeRates', {});
|
|
1274
1319
|
//
|
|
1275
1320
|
// {
|
|
1276
1321
|
// "data":{
|
|
@@ -1286,24 +1331,23 @@ export default class coinbase extends Exchange {
|
|
|
1286
1331
|
// }
|
|
1287
1332
|
// }
|
|
1288
1333
|
//
|
|
1289
|
-
const data = this.safeValue(currencies, 'data', []);
|
|
1290
|
-
const dataById = this.indexBy(data, 'id');
|
|
1291
|
-
const rates = this.safeValue(this.safeValue(exchangeRates, 'data', {}), 'rates', {});
|
|
1292
|
-
const keys = Object.keys(rates);
|
|
1293
1334
|
const result = {};
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
const currency =
|
|
1298
|
-
const
|
|
1299
|
-
const
|
|
1335
|
+
const networks = {};
|
|
1336
|
+
const networksById = {};
|
|
1337
|
+
for (let i = 0; i < currencies.length; i++) {
|
|
1338
|
+
const currency = currencies[i];
|
|
1339
|
+
const assetId = this.safeString(currency, 'asset_id');
|
|
1340
|
+
const id = this.safeString2(currency, 'id', 'code');
|
|
1300
1341
|
const code = this.safeCurrencyCode(id);
|
|
1342
|
+
const name = this.safeString(currency, 'name');
|
|
1343
|
+
this.options['networks'][code] = name.toLowerCase();
|
|
1344
|
+
this.options['networksById'][code] = name.toLowerCase();
|
|
1301
1345
|
result[code] = {
|
|
1346
|
+
'info': currency,
|
|
1302
1347
|
'id': id,
|
|
1303
1348
|
'code': code,
|
|
1304
|
-
'
|
|
1305
|
-
'
|
|
1306
|
-
'name': name,
|
|
1349
|
+
'type': (assetId !== undefined) ? 'crypto' : 'fiat',
|
|
1350
|
+
'name': this.safeString(currency, 'name'),
|
|
1307
1351
|
'active': true,
|
|
1308
1352
|
'deposit': undefined,
|
|
1309
1353
|
'withdraw': undefined,
|
|
@@ -1320,7 +1364,14 @@ export default class coinbase extends Exchange {
|
|
|
1320
1364
|
},
|
|
1321
1365
|
},
|
|
1322
1366
|
};
|
|
1367
|
+
if (assetId !== undefined) {
|
|
1368
|
+
const lowerCaseName = name.toLowerCase();
|
|
1369
|
+
networks[code] = lowerCaseName;
|
|
1370
|
+
networksById[lowerCaseName] = code;
|
|
1371
|
+
}
|
|
1323
1372
|
}
|
|
1373
|
+
this.options['networks'] = this.extend(networks, this.options['networks']);
|
|
1374
|
+
this.options['networksById'] = this.extend(networksById, this.options['networksById']);
|
|
1324
1375
|
return result;
|
|
1325
1376
|
}
|
|
1326
1377
|
async fetchTickers(symbols = undefined, params = {}) {
|
|
@@ -1798,12 +1849,12 @@ export default class coinbase extends Exchange {
|
|
|
1798
1849
|
if (code !== undefined) {
|
|
1799
1850
|
currency = this.currency(code);
|
|
1800
1851
|
}
|
|
1801
|
-
|
|
1802
|
-
|
|
1852
|
+
let request = undefined;
|
|
1853
|
+
[request, params] = await this.prepareAccountRequestWithCurrencyCode(code, limit, params);
|
|
1803
1854
|
// for pagination use parameter 'starting_after'
|
|
1804
1855
|
// the value for the next page can be obtained from the result of the previous call in the 'pagination' field
|
|
1805
1856
|
// eg: instance.last_json_response.pagination.next_starting_after
|
|
1806
|
-
const response = await this.v2PrivateGetAccountsAccountIdTransactions(this.extend(request,
|
|
1857
|
+
const response = await this.v2PrivateGetAccountsAccountIdTransactions(this.extend(request, params));
|
|
1807
1858
|
return this.parseLedger(response['data'], currency, since, limit);
|
|
1808
1859
|
}
|
|
1809
1860
|
parseLedgerEntryStatus(status) {
|
|
@@ -2161,6 +2212,7 @@ export default class coinbase extends Exchange {
|
|
|
2161
2212
|
}
|
|
2162
2213
|
async prepareAccountRequestWithCurrencyCode(code = undefined, limit = undefined, params = {}) {
|
|
2163
2214
|
let accountId = this.safeString2(params, 'account_id', 'accountId');
|
|
2215
|
+
params = this.omit(params, ['account_id', 'accountId']);
|
|
2164
2216
|
if (accountId === undefined) {
|
|
2165
2217
|
if (code === undefined) {
|
|
2166
2218
|
throw new ArgumentsRequired(this.id + ' prepareAccountRequestWithCurrencyCode() method requires an account_id (or accountId) parameter OR a currency code argument');
|
|
@@ -2176,7 +2228,7 @@ export default class coinbase extends Exchange {
|
|
|
2176
2228
|
if (limit !== undefined) {
|
|
2177
2229
|
request['limit'] = limit;
|
|
2178
2230
|
}
|
|
2179
|
-
return request;
|
|
2231
|
+
return [request, params];
|
|
2180
2232
|
}
|
|
2181
2233
|
async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
|
|
2182
2234
|
/**
|
|
@@ -3349,6 +3401,140 @@ export default class coinbase extends Exchange {
|
|
|
3349
3401
|
const data = this.safeValue(response, 'data', {});
|
|
3350
3402
|
return this.parseTransaction(data, currency);
|
|
3351
3403
|
}
|
|
3404
|
+
async fetchDepositAddressesByNetwork(code, params = {}) {
|
|
3405
|
+
/**
|
|
3406
|
+
* @method
|
|
3407
|
+
* @name ascendex#fetchDepositAddress
|
|
3408
|
+
* @description fetch the deposit address for a currency associated with this account
|
|
3409
|
+
* @see https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postcoinbaseaccountaddresses
|
|
3410
|
+
* @param {string} code unified currency code
|
|
3411
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3412
|
+
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
3413
|
+
*/
|
|
3414
|
+
await this.loadMarkets();
|
|
3415
|
+
const currency = this.currency(code);
|
|
3416
|
+
let request = undefined;
|
|
3417
|
+
[request, params] = await this.prepareAccountRequestWithCurrencyCode(currency['code']);
|
|
3418
|
+
const response = await this.v2PrivateGetAccountsAccountIdAddresses(this.extend(request, params));
|
|
3419
|
+
//
|
|
3420
|
+
// {
|
|
3421
|
+
// pagination: {
|
|
3422
|
+
// ending_before: null,
|
|
3423
|
+
// starting_after: null,
|
|
3424
|
+
// previous_ending_before: null,
|
|
3425
|
+
// next_starting_after: null,
|
|
3426
|
+
// limit: '25',
|
|
3427
|
+
// order: 'desc',
|
|
3428
|
+
// previous_uri: null,
|
|
3429
|
+
// next_uri: null
|
|
3430
|
+
// },
|
|
3431
|
+
// data: [
|
|
3432
|
+
// {
|
|
3433
|
+
// id: '64ceb5f1-5fa2-5310-a4ff-9fd46271003d',
|
|
3434
|
+
// address: '5xjPKeAXpnhA2kHyinvdVeui6RXVdEa3B2J3SCAwiKnk',
|
|
3435
|
+
// address_info: { address: '5xjPKeAXpnhA2kHyinvdVeui6RXVdEa3B2J3SCAwiKnk' },
|
|
3436
|
+
// name: null,
|
|
3437
|
+
// created_at: '2023-05-29T21:12:12Z',
|
|
3438
|
+
// updated_at: '2023-05-29T21:12:12Z',
|
|
3439
|
+
// network: 'solana',
|
|
3440
|
+
// uri_scheme: 'solana',
|
|
3441
|
+
// resource: 'address',
|
|
3442
|
+
// resource_path: '/v2/accounts/a7b3d387-bfb8-5ce7-b8da-1f507e81cf25/addresses/64ceb5f1-5fa2-5310-a4ff-9fd46271003d',
|
|
3443
|
+
// warnings: [
|
|
3444
|
+
// {
|
|
3445
|
+
// type: 'correct_address_warning',
|
|
3446
|
+
// title: 'This is an ERC20 USDC address.',
|
|
3447
|
+
// details: 'Only send ERC20 USD Coin (USDC) to this address.',
|
|
3448
|
+
// image_url: 'https://www.coinbase.com/assets/addresses/global-receive-warning-a3d91807e61c717e5a38d270965003dcc025ca8a3cea40ec3d7835b7c86087fa.png',
|
|
3449
|
+
// options: [ { text: 'I understand', style: 'primary', id: 'dismiss' } ]
|
|
3450
|
+
// }
|
|
3451
|
+
// ],
|
|
3452
|
+
// qr_code_image_url: 'https://static-assets.coinbase.com/p2p/l2/asset_network_combinations/v5/usdc-solana.png',
|
|
3453
|
+
// address_label: 'USDC address (Solana)',
|
|
3454
|
+
// default_receive: true,
|
|
3455
|
+
// deposit_uri: 'solana:5xjPKeAXpnhA2kHyinvdVeui6RXVdEa3B2J3SCAwiKnk?spl-token=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
3456
|
+
// callback_url: null,
|
|
3457
|
+
// share_address_copy: {
|
|
3458
|
+
// line1: '5xjPKeAXpnhA2kHyinvdVeui6RXVdEa3B2J3SCAwiKnk',
|
|
3459
|
+
// line2: 'This address can only receive USDC-SPL from Solana network. Don’t send USDC from other networks, other SPL tokens or NFTs, or it may result in a loss of funds.'
|
|
3460
|
+
// },
|
|
3461
|
+
// receive_subtitle: 'ERC-20',
|
|
3462
|
+
// inline_warning: {
|
|
3463
|
+
// text: 'This address can only receive USDC-SPL from Solana network. Don’t send USDC from other networks, other SPL tokens or NFTs, or it may result in a loss of funds.',
|
|
3464
|
+
// tooltip: {
|
|
3465
|
+
// title: 'USDC (Solana)',
|
|
3466
|
+
// subtitle: 'This address can only receive USDC-SPL from Solana network.'
|
|
3467
|
+
// }
|
|
3468
|
+
// }
|
|
3469
|
+
// },
|
|
3470
|
+
// ...
|
|
3471
|
+
// ]
|
|
3472
|
+
// }
|
|
3473
|
+
//
|
|
3474
|
+
const data = this.safeList(response, 'data', []);
|
|
3475
|
+
const addressStructures = this.parseDepositAddresses(data, undefined, false);
|
|
3476
|
+
return this.indexBy(addressStructures, 'network');
|
|
3477
|
+
}
|
|
3478
|
+
parseDepositAddress(depositAddress, currency = undefined) {
|
|
3479
|
+
//
|
|
3480
|
+
// {
|
|
3481
|
+
// id: '64ceb5f1-5fa2-5310-a4ff-9fd46271003d',
|
|
3482
|
+
// address: '5xjPKeAXpnhA2kHyinvdVeui6RXVdEa3B2J3SCAwiKnk',
|
|
3483
|
+
// address_info: {
|
|
3484
|
+
// address: 'GCF74576I7AQ56SLMKBQAP255EGUOWCRVII3S44KEXVNJEOIFVBDMXVL',
|
|
3485
|
+
// destination_tag: '3722061866'
|
|
3486
|
+
// },
|
|
3487
|
+
// name: null,
|
|
3488
|
+
// created_at: '2023-05-29T21:12:12Z',
|
|
3489
|
+
// updated_at: '2023-05-29T21:12:12Z',
|
|
3490
|
+
// network: 'solana',
|
|
3491
|
+
// uri_scheme: 'solana',
|
|
3492
|
+
// resource: 'address',
|
|
3493
|
+
// resource_path: '/v2/accounts/a7b3d387-bfb8-5ce7-b8da-1f507e81cf25/addresses/64ceb5f1-5fa2-5310-a4ff-9fd46271003d',
|
|
3494
|
+
// warnings: [
|
|
3495
|
+
// {
|
|
3496
|
+
// type: 'correct_address_warning',
|
|
3497
|
+
// title: 'This is an ERC20 USDC address.',
|
|
3498
|
+
// details: 'Only send ERC20 USD Coin (USDC) to this address.',
|
|
3499
|
+
// image_url: 'https://www.coinbase.com/assets/addresses/global-receive-warning-a3d91807e61c717e5a38d270965003dcc025ca8a3cea40ec3d7835b7c86087fa.png',
|
|
3500
|
+
// options: [ { text: 'I understand', style: 'primary', id: 'dismiss' } ]
|
|
3501
|
+
// }
|
|
3502
|
+
// ],
|
|
3503
|
+
// qr_code_image_url: 'https://static-assets.coinbase.com/p2p/l2/asset_network_combinations/v5/usdc-solana.png',
|
|
3504
|
+
// address_label: 'USDC address (Solana)',
|
|
3505
|
+
// default_receive: true,
|
|
3506
|
+
// deposit_uri: 'solana:5xjPKeAXpnhA2kHyinvdVeui6RXVdEa3B2J3SCAwiKnk?spl-token=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
3507
|
+
// callback_url: null,
|
|
3508
|
+
// share_address_copy: {
|
|
3509
|
+
// line1: '5xjPKeAXpnhA2kHyinvdVeui6RXVdEa3B2J3SCAwiKnk',
|
|
3510
|
+
// line2: 'This address can only receive USDC-SPL from Solana network. Don’t send USDC from other networks, other SPL tokens or NFTs, or it may result in a loss of funds.'
|
|
3511
|
+
// },
|
|
3512
|
+
// receive_subtitle: 'ERC-20',
|
|
3513
|
+
// inline_warning: {
|
|
3514
|
+
// text: 'This address can only receive USDC-SPL from Solana network. Don’t send USDC from other networks, other SPL tokens or NFTs, or it may result in a loss of funds.',
|
|
3515
|
+
// tooltip: {
|
|
3516
|
+
// title: 'USDC (Solana)',
|
|
3517
|
+
// subtitle: 'This address can only receive USDC-SPL from Solana network.'
|
|
3518
|
+
// }
|
|
3519
|
+
// }
|
|
3520
|
+
// }
|
|
3521
|
+
//
|
|
3522
|
+
const address = this.safeString(depositAddress, 'address');
|
|
3523
|
+
this.checkAddress(address);
|
|
3524
|
+
const networkId = this.safeString(depositAddress, 'network');
|
|
3525
|
+
const code = this.safeCurrencyCode(undefined, currency);
|
|
3526
|
+
const addressLabel = this.safeString(depositAddress, 'address_label');
|
|
3527
|
+
const splitAddressLabel = addressLabel.split(' ');
|
|
3528
|
+
const marketId = this.safeString(splitAddressLabel, 0);
|
|
3529
|
+
const addressInfo = this.safeDict(depositAddress, 'address_info');
|
|
3530
|
+
return {
|
|
3531
|
+
'info': depositAddress,
|
|
3532
|
+
'currency': this.safeCurrencyCode(marketId, currency),
|
|
3533
|
+
'address': address,
|
|
3534
|
+
'tag': this.safeString(addressInfo, 'destination_tag'),
|
|
3535
|
+
'network': this.networkIdToCode(networkId, code),
|
|
3536
|
+
};
|
|
3537
|
+
}
|
|
3352
3538
|
sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
3353
3539
|
const version = api[0];
|
|
3354
3540
|
const signed = api[1] === 'private';
|
package/js/src/deribit.js
CHANGED
|
@@ -1784,7 +1784,7 @@ export default class deribit extends Exchange {
|
|
|
1784
1784
|
const amount = this.safeString(order, 'amount');
|
|
1785
1785
|
let cost = Precise.stringMul(filledString, averageString);
|
|
1786
1786
|
if (market['inverse']) {
|
|
1787
|
-
if (
|
|
1787
|
+
if (averageString !== '0') {
|
|
1788
1788
|
cost = Precise.stringDiv(amount, averageString);
|
|
1789
1789
|
}
|
|
1790
1790
|
}
|
package/js/src/pro/gate.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ export default class gate extends gateRest {
|
|
|
12
12
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
13
13
|
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
14
14
|
handleTicker(client: Client, message: any): void;
|
|
15
|
+
watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
16
|
+
handleBidAsk(client: Client, message: any): void;
|
|
17
|
+
subscribeWatchTickersAndBidsAsks(symbols?: Strings, callerMethodName?: Str, params?: {}): Promise<Tickers>;
|
|
18
|
+
handleTickerAndBidAsk(objectName: string, client: Client, message: any): void;
|
|
15
19
|
watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
16
20
|
watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
|
17
21
|
handleTrades(client: Client, message: any): void;
|