ccxt 4.4.23 → 4.4.25
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 +110 -110
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +4 -3
- package/dist/cjs/src/binance.js +1 -1
- package/dist/cjs/src/bitmex.js +8 -7
- package/dist/cjs/src/bybit.js +41 -4
- package/dist/cjs/src/coincatch.js +1 -1
- package/dist/cjs/src/coinex.js +46 -25
- package/dist/cjs/src/gate.js +195 -59
- package/dist/cjs/src/hitbtc.js +6 -12
- package/dist/cjs/src/htx.js +16 -16
- package/dist/cjs/src/hyperliquid.js +1 -1
- package/dist/cjs/src/kucoin.js +18 -8
- package/dist/cjs/src/pro/kucoin.js +2 -1
- package/dist/cjs/src/pro/onetrading.js +2 -1
- package/dist/cjs/src/woofipro.js +1 -1
- package/dist/cjs/src/xt.js +5 -1
- package/dist/cjs/src/yobit.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/kucoin.d.ts +1 -0
- package/js/src/abstract/kucoinfutures.d.ts +1 -0
- package/js/src/base/Exchange.js +4 -3
- package/js/src/binance.js +1 -1
- package/js/src/bitmex.js +8 -7
- package/js/src/bybit.js +41 -4
- package/js/src/coincatch.js +1 -1
- package/js/src/coinex.js +46 -25
- package/js/src/gate.d.ts +13 -1
- package/js/src/gate.js +195 -59
- package/js/src/hitbtc.d.ts +0 -1
- package/js/src/hitbtc.js +6 -12
- package/js/src/htx.js +16 -16
- package/js/src/hyperliquid.js +1 -1
- package/js/src/kucoin.js +18 -8
- package/js/src/pro/kucoin.js +2 -1
- package/js/src/pro/onetrading.js +2 -1
- package/js/src/woofipro.js +1 -1
- package/js/src/xt.js +5 -1
- package/js/src/yobit.js +1 -1
- package/package.json +1 -1
package/js/src/gate.js
CHANGED
|
@@ -102,6 +102,7 @@ export default class gate extends Exchange {
|
|
|
102
102
|
'createTriggerOrder': true,
|
|
103
103
|
'editOrder': true,
|
|
104
104
|
'fetchBalance': true,
|
|
105
|
+
'fetchBorrowInterest': true,
|
|
105
106
|
'fetchBorrowRateHistories': false,
|
|
106
107
|
'fetchBorrowRateHistory': false,
|
|
107
108
|
'fetchClosedOrders': true,
|
|
@@ -1539,7 +1540,7 @@ export default class gate extends Exchange {
|
|
|
1539
1540
|
}
|
|
1540
1541
|
return [request, query];
|
|
1541
1542
|
}
|
|
1542
|
-
multiOrderSpotPrepareRequest(market = undefined,
|
|
1543
|
+
multiOrderSpotPrepareRequest(market = undefined, trigger = false, params = {}) {
|
|
1543
1544
|
/**
|
|
1544
1545
|
* @ignore
|
|
1545
1546
|
* @method
|
|
@@ -1550,12 +1551,12 @@ export default class gate extends Exchange {
|
|
|
1550
1551
|
* @param {object} [params] request parameters
|
|
1551
1552
|
* @returns the api request object, and the new params object with non-needed parameters removed
|
|
1552
1553
|
*/
|
|
1553
|
-
const [marginMode, query] = this.getMarginMode(
|
|
1554
|
+
const [marginMode, query] = this.getMarginMode(trigger, params);
|
|
1554
1555
|
const request = {
|
|
1555
1556
|
'account': marginMode,
|
|
1556
1557
|
};
|
|
1557
1558
|
if (market !== undefined) {
|
|
1558
|
-
if (
|
|
1559
|
+
if (trigger) {
|
|
1559
1560
|
// gate spot and margin stop orders use the term market instead of currency_pair, and normal instead of spot. Neither parameter is used when fetching/cancelling a single order. They are used for creating a single stop order, but createOrder does not call this method
|
|
1560
1561
|
request['market'] = market['id'];
|
|
1561
1562
|
}
|
|
@@ -1596,6 +1597,11 @@ export default class gate extends Exchange {
|
|
|
1596
1597
|
throw new BadRequest(this.id + ' getMarginMode() does not support stop orders for cross margin');
|
|
1597
1598
|
}
|
|
1598
1599
|
}
|
|
1600
|
+
let isUnifiedAccount = false;
|
|
1601
|
+
[isUnifiedAccount, params] = this.handleOptionAndParams(params, 'getMarginMode', 'unifiedAccount');
|
|
1602
|
+
if (isUnifiedAccount) {
|
|
1603
|
+
marginMode = 'unified';
|
|
1604
|
+
}
|
|
1599
1605
|
return [marginMode, params];
|
|
1600
1606
|
}
|
|
1601
1607
|
getSettlementCurrencies(type, method) {
|
|
@@ -3371,10 +3377,12 @@ export default class gate extends Exchange {
|
|
|
3371
3377
|
* @param {int} [params.offset] *contract only* list offset, starting from 0
|
|
3372
3378
|
* @param {string} [params.last_id] *contract only* specify list staring point using the id of last record in previous list-query results
|
|
3373
3379
|
* @param {int} [params.count_total] *contract only* whether to return total number matched, default to 0(no return)
|
|
3374
|
-
* @param {
|
|
3380
|
+
* @param {bool} [params.unifiedAccount] set to true for fetching trades in a unified account
|
|
3381
|
+
* @param {bool} [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)
|
|
3375
3382
|
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
3376
3383
|
*/
|
|
3377
3384
|
await this.loadMarkets();
|
|
3385
|
+
await this.loadUnifiedStatus();
|
|
3378
3386
|
let paginate = false;
|
|
3379
3387
|
[paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
|
|
3380
3388
|
if (paginate) {
|
|
@@ -3932,9 +3940,11 @@ export default class gate extends Exchange {
|
|
|
3932
3940
|
* @param {bool} [params.auto_size] *contract only* Set side to close dual-mode position, close_long closes the long side, while close_short the short one, size also needs to be set to 0
|
|
3933
3941
|
* @param {int} [params.price_type] *contract only* 0 latest deal price, 1 mark price, 2 index price
|
|
3934
3942
|
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
3943
|
+
* @param {bool} [params.unifiedAccount] set to true for creating an order in the unified account
|
|
3935
3944
|
* @returns {object|undefined} [An order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3936
3945
|
*/
|
|
3937
3946
|
await this.loadMarkets();
|
|
3947
|
+
await this.loadUnifiedStatus();
|
|
3938
3948
|
const market = this.market(symbol);
|
|
3939
3949
|
const trigger = this.safeValue(params, 'trigger');
|
|
3940
3950
|
const triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
|
|
@@ -4086,6 +4096,7 @@ export default class gate extends Exchange {
|
|
|
4086
4096
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4087
4097
|
*/
|
|
4088
4098
|
await this.loadMarkets();
|
|
4099
|
+
await this.loadUnifiedStatus();
|
|
4089
4100
|
const ordersRequests = this.createOrdersRequest(orders, params);
|
|
4090
4101
|
const firstOrder = orders[0];
|
|
4091
4102
|
const market = this.market(firstOrder['symbol']);
|
|
@@ -4367,9 +4378,11 @@ export default class gate extends Exchange {
|
|
|
4367
4378
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
4368
4379
|
* @param {float} cost how much you want to trade in units of the quote currency
|
|
4369
4380
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4381
|
+
* @param {bool} [params.unifiedAccount] set to true for creating a unified account order
|
|
4370
4382
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4371
4383
|
*/
|
|
4372
4384
|
await this.loadMarkets();
|
|
4385
|
+
await this.loadUnifiedStatus();
|
|
4373
4386
|
const market = this.market(symbol);
|
|
4374
4387
|
if (!market['spot']) {
|
|
4375
4388
|
throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
|
|
@@ -4379,8 +4392,14 @@ export default class gate extends Exchange {
|
|
|
4379
4392
|
}
|
|
4380
4393
|
editOrderRequest(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
4381
4394
|
const market = this.market(symbol);
|
|
4382
|
-
|
|
4383
|
-
|
|
4395
|
+
let marketType = undefined;
|
|
4396
|
+
[marketType, params] = this.handleMarketTypeAndParams('editOrder', market, params);
|
|
4397
|
+
let account = this.convertTypeToAccount(marketType);
|
|
4398
|
+
let isUnifiedAccount = false;
|
|
4399
|
+
[isUnifiedAccount, params] = this.handleOptionAndParams(params, 'editOrder', 'unifiedAccount');
|
|
4400
|
+
if (isUnifiedAccount) {
|
|
4401
|
+
account = 'unified';
|
|
4402
|
+
}
|
|
4384
4403
|
const isLimitOrder = (type === 'limit');
|
|
4385
4404
|
if (account === 'spot') {
|
|
4386
4405
|
if (!isLimitOrder) {
|
|
@@ -4412,7 +4431,7 @@ export default class gate extends Exchange {
|
|
|
4412
4431
|
if (!market['spot']) {
|
|
4413
4432
|
request['settle'] = market['settleId'];
|
|
4414
4433
|
}
|
|
4415
|
-
return this.extend(request,
|
|
4434
|
+
return this.extend(request, params);
|
|
4416
4435
|
}
|
|
4417
4436
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
4418
4437
|
/**
|
|
@@ -4428,9 +4447,11 @@ export default class gate extends Exchange {
|
|
|
4428
4447
|
* @param {float} amount how much of the currency you want to trade in units of the base currency
|
|
4429
4448
|
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
4430
4449
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4450
|
+
* @param {bool} [params.unifiedAccount] set to true for editing an order in a unified account
|
|
4431
4451
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4432
4452
|
*/
|
|
4433
4453
|
await this.loadMarkets();
|
|
4454
|
+
await this.loadUnifiedStatus();
|
|
4434
4455
|
const market = this.market(symbol);
|
|
4435
4456
|
const extendedRequest = this.editOrderRequest(id, symbol, type, side, amount, price, params);
|
|
4436
4457
|
let response = undefined;
|
|
@@ -4692,21 +4713,21 @@ export default class gate extends Exchange {
|
|
|
4692
4713
|
// Everything below this(above return) is related to fees
|
|
4693
4714
|
const fees = [];
|
|
4694
4715
|
const gtFee = this.safeString(order, 'gt_fee');
|
|
4695
|
-
if (gtFee) {
|
|
4716
|
+
if (gtFee !== undefined) {
|
|
4696
4717
|
fees.push({
|
|
4697
4718
|
'currency': 'GT',
|
|
4698
4719
|
'cost': gtFee,
|
|
4699
4720
|
});
|
|
4700
4721
|
}
|
|
4701
4722
|
const fee = this.safeString(order, 'fee');
|
|
4702
|
-
if (fee) {
|
|
4723
|
+
if (fee !== undefined) {
|
|
4703
4724
|
fees.push({
|
|
4704
4725
|
'currency': this.safeCurrencyCode(this.safeString(order, 'fee_currency')),
|
|
4705
4726
|
'cost': fee,
|
|
4706
4727
|
});
|
|
4707
4728
|
}
|
|
4708
4729
|
const rebate = this.safeString(order, 'rebated_fee');
|
|
4709
|
-
if (rebate) {
|
|
4730
|
+
if (rebate !== undefined) {
|
|
4710
4731
|
fees.push({
|
|
4711
4732
|
'currency': this.safeCurrencyCode(this.safeString(order, 'rebated_fee_currency')),
|
|
4712
4733
|
'cost': Precise.stringNeg(rebate),
|
|
@@ -4790,9 +4811,11 @@ export default class gate extends Exchange {
|
|
|
4790
4811
|
* @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for margin trading if not provided this.options['defaultMarginMode'] is used
|
|
4791
4812
|
* @param {string} [params.type] 'spot', 'swap', or 'future', if not provided this.options['defaultMarginMode'] is used
|
|
4792
4813
|
* @param {string} [params.settle] 'btc' or 'usdt' - settle currency for perpetual swap and future - market settle currency is used if symbol !== undefined, default="usdt" for swap and "btc" for future
|
|
4814
|
+
* @param {bool} [params.unifiedAccount] set to true for fetching a unified account order
|
|
4793
4815
|
* @returns An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4794
4816
|
*/
|
|
4795
4817
|
await this.loadMarkets();
|
|
4818
|
+
await this.loadUnifiedStatus();
|
|
4796
4819
|
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
4797
4820
|
const result = this.handleMarketTypeAndParams('fetchOrder', market, params);
|
|
4798
4821
|
const type = this.safeString(result, 0);
|
|
@@ -4845,6 +4868,7 @@ export default class gate extends Exchange {
|
|
|
4845
4868
|
* @param {bool} [params.stop] true for fetching stop orders
|
|
4846
4869
|
* @param {string} [params.type] spot, margin, swap or future, if not provided this.options['defaultType'] is used
|
|
4847
4870
|
* @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for type='margin', if not provided this.options['defaultMarginMode'] is used
|
|
4871
|
+
* @param {bool} [params.unifiedAccount] set to true for fetching unified account orders
|
|
4848
4872
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4849
4873
|
*/
|
|
4850
4874
|
return await this.fetchOrdersByStatus('open', symbol, since, limit, params);
|
|
@@ -4870,9 +4894,11 @@ export default class gate extends Exchange {
|
|
|
4870
4894
|
* @param {string} [params.type] spot, swap or future, if not provided this.options['defaultType'] is used
|
|
4871
4895
|
* @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for margin trading if not provided this.options['defaultMarginMode'] is used
|
|
4872
4896
|
* @param {boolean} [params.historical] *swap only* true for using historical endpoint
|
|
4897
|
+
* @param {bool} [params.unifiedAccount] set to true for fetching unified account orders
|
|
4873
4898
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4874
4899
|
*/
|
|
4875
4900
|
await this.loadMarkets();
|
|
4901
|
+
await this.loadUnifiedStatus();
|
|
4876
4902
|
const until = this.safeInteger(params, 'until');
|
|
4877
4903
|
let market = undefined;
|
|
4878
4904
|
if (symbol !== undefined) {
|
|
@@ -4908,13 +4934,16 @@ export default class gate extends Exchange {
|
|
|
4908
4934
|
market = this.market(symbol);
|
|
4909
4935
|
symbol = market['symbol'];
|
|
4910
4936
|
}
|
|
4911
|
-
|
|
4912
|
-
params = this.
|
|
4937
|
+
let trigger = undefined;
|
|
4938
|
+
[trigger, params] = this.handleParamBool2(params, 'trigger', 'stop');
|
|
4913
4939
|
let type = undefined;
|
|
4914
4940
|
[type, params] = this.handleMarketTypeAndParams('fetchOrdersByStatus', market, params);
|
|
4915
4941
|
const spot = (type === 'spot') || (type === 'margin');
|
|
4916
4942
|
let request = {};
|
|
4917
|
-
[request, params] = spot ? this.multiOrderSpotPrepareRequest(market,
|
|
4943
|
+
[request, params] = spot ? this.multiOrderSpotPrepareRequest(market, trigger, params) : this.prepareRequest(market, type, params);
|
|
4944
|
+
if (spot && trigger) {
|
|
4945
|
+
request = this.omit(request, 'account');
|
|
4946
|
+
}
|
|
4918
4947
|
if (status === 'closed') {
|
|
4919
4948
|
status = 'finished';
|
|
4920
4949
|
}
|
|
@@ -4940,33 +4969,36 @@ export default class gate extends Exchange {
|
|
|
4940
4969
|
}
|
|
4941
4970
|
async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
4942
4971
|
await this.loadMarkets();
|
|
4972
|
+
await this.loadUnifiedStatus();
|
|
4943
4973
|
let market = undefined;
|
|
4944
4974
|
if (symbol !== undefined) {
|
|
4945
4975
|
market = this.market(symbol);
|
|
4946
4976
|
symbol = market['symbol'];
|
|
4947
4977
|
}
|
|
4948
|
-
|
|
4949
|
-
|
|
4978
|
+
// don't omit here, omits done in prepareOrdersByStatusRequest
|
|
4979
|
+
const trigger = this.safeBool2(params, 'trigger', 'stop');
|
|
4950
4980
|
const res = this.handleMarketTypeAndParams('fetchOrdersByStatus', market, params);
|
|
4951
4981
|
const type = this.safeString(res, 0);
|
|
4952
|
-
params['type'] = type;
|
|
4953
4982
|
const [request, requestParams] = this.prepareOrdersByStatusRequest(status, symbol, since, limit, params);
|
|
4954
4983
|
const spot = (type === 'spot') || (type === 'margin');
|
|
4955
|
-
const
|
|
4984
|
+
const openStatus = (status === 'open');
|
|
4985
|
+
const openSpotOrders = spot && openStatus && !trigger;
|
|
4956
4986
|
let response = undefined;
|
|
4957
|
-
if (
|
|
4958
|
-
if (
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4987
|
+
if (spot) {
|
|
4988
|
+
if (!trigger) {
|
|
4989
|
+
if (openStatus) {
|
|
4990
|
+
response = await this.privateSpotGetOpenOrders(this.extend(request, requestParams));
|
|
4991
|
+
}
|
|
4992
|
+
else {
|
|
4993
|
+
response = await this.privateSpotGetOrders(this.extend(request, requestParams));
|
|
4994
|
+
}
|
|
4963
4995
|
}
|
|
4964
4996
|
else {
|
|
4965
|
-
response = await this.
|
|
4997
|
+
response = await this.privateSpotGetPriceOrders(this.extend(request, requestParams));
|
|
4966
4998
|
}
|
|
4967
4999
|
}
|
|
4968
5000
|
else if (type === 'swap') {
|
|
4969
|
-
if (
|
|
5001
|
+
if (trigger) {
|
|
4970
5002
|
response = await this.privateFuturesGetSettlePriceOrders(this.extend(request, requestParams));
|
|
4971
5003
|
}
|
|
4972
5004
|
else {
|
|
@@ -4974,7 +5006,7 @@ export default class gate extends Exchange {
|
|
|
4974
5006
|
}
|
|
4975
5007
|
}
|
|
4976
5008
|
else if (type === 'future') {
|
|
4977
|
-
if (
|
|
5009
|
+
if (trigger) {
|
|
4978
5010
|
response = await this.privateDeliveryGetSettlePriceOrders(this.extend(request, requestParams));
|
|
4979
5011
|
}
|
|
4980
5012
|
else {
|
|
@@ -5157,9 +5189,11 @@ export default class gate extends Exchange {
|
|
|
5157
5189
|
* @param {string} symbol Unified market symbol
|
|
5158
5190
|
* @param {object} [params] Parameters specified by the exchange api
|
|
5159
5191
|
* @param {bool} [params.stop] True if the order to be cancelled is a trigger order
|
|
5192
|
+
* @param {bool} [params.unifiedAccount] set to true for canceling unified account orders
|
|
5160
5193
|
* @returns An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5161
5194
|
*/
|
|
5162
5195
|
await this.loadMarkets();
|
|
5196
|
+
await this.loadUnifiedStatus();
|
|
5163
5197
|
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
5164
5198
|
const stop = this.safeBoolN(params, ['is_stop_order', 'stop', 'trigger'], false);
|
|
5165
5199
|
params = this.omit(params, ['is_stop_order', 'stop', 'trigger']);
|
|
@@ -5290,9 +5324,11 @@ export default class gate extends Exchange {
|
|
|
5290
5324
|
* @param {string[]} ids order ids
|
|
5291
5325
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
5292
5326
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5327
|
+
* @param {bool} [params.unifiedAccount] set to true for canceling unified account orders
|
|
5293
5328
|
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5294
5329
|
*/
|
|
5295
5330
|
await this.loadMarkets();
|
|
5331
|
+
await this.loadUnifiedStatus();
|
|
5296
5332
|
let market = undefined;
|
|
5297
5333
|
if (symbol !== undefined) {
|
|
5298
5334
|
market = this.market(symbol);
|
|
@@ -5336,9 +5372,11 @@ export default class gate extends Exchange {
|
|
|
5336
5372
|
* @param {CancellationRequest[]} orders list of order ids with symbol, example [{"id": "a", "symbol": "BTC/USDT"}, {"id": "b", "symbol": "ETH/USDT"}]
|
|
5337
5373
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5338
5374
|
* @param {string[]} [params.clientOrderIds] client order ids
|
|
5375
|
+
* @param {bool} [params.unifiedAccount] set to true for canceling unified account orders
|
|
5339
5376
|
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5340
5377
|
*/
|
|
5341
5378
|
await this.loadMarkets();
|
|
5379
|
+
await this.loadUnifiedStatus();
|
|
5342
5380
|
const ordersRequests = [];
|
|
5343
5381
|
for (let i = 0; i < orders.length; i++) {
|
|
5344
5382
|
const order = orders[i];
|
|
@@ -5376,9 +5414,11 @@ export default class gate extends Exchange {
|
|
|
5376
5414
|
* @see https://www.gate.io/docs/developers/apiv4/en/#cancel-all-open-orders-matched-3
|
|
5377
5415
|
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
5378
5416
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5417
|
+
* @param {bool} [params.unifiedAccount] set to true for canceling unified account orders
|
|
5379
5418
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5380
5419
|
*/
|
|
5381
5420
|
await this.loadMarkets();
|
|
5421
|
+
await this.loadUnifiedStatus();
|
|
5382
5422
|
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
5383
5423
|
const stop = this.safeBool2(params, 'stop', 'trigger');
|
|
5384
5424
|
params = this.omit(params, ['stop', 'trigger']);
|
|
@@ -6196,38 +6236,50 @@ export default class gate extends Exchange {
|
|
|
6196
6236
|
* @name gate#repayCrossMargin
|
|
6197
6237
|
* @description repay cross margin borrowed margin and interest
|
|
6198
6238
|
* @see https://www.gate.io/docs/developers/apiv4/en/#cross-margin-repayments
|
|
6239
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#borrow-or-repay
|
|
6199
6240
|
* @param {string} code unified currency code of the currency to repay
|
|
6200
6241
|
* @param {float} amount the amount to repay
|
|
6201
6242
|
* @param {string} symbol unified market symbol, required for isolated margin
|
|
6202
6243
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
6203
6244
|
* @param {string} [params.mode] 'all' or 'partial' payment mode, extra parameter required for isolated margin
|
|
6204
6245
|
* @param {string} [params.id] '34267567' loan id, extra parameter required for isolated margin
|
|
6246
|
+
* @param {boolean} [params.unifiedAccount] set to true for repaying in the unified account
|
|
6205
6247
|
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
6206
6248
|
*/
|
|
6207
6249
|
await this.loadMarkets();
|
|
6250
|
+
await this.loadUnifiedStatus();
|
|
6208
6251
|
const currency = this.currency(code);
|
|
6209
6252
|
const request = {
|
|
6210
6253
|
'currency': currency['id'].toUpperCase(),
|
|
6211
6254
|
'amount': this.currencyToPrecision(code, amount),
|
|
6212
6255
|
};
|
|
6213
|
-
let
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6256
|
+
let isUnifiedAccount = false;
|
|
6257
|
+
[isUnifiedAccount, params] = this.handleOptionAndParams(params, 'repayCrossMargin', 'unifiedAccount');
|
|
6258
|
+
let response = undefined;
|
|
6259
|
+
if (isUnifiedAccount) {
|
|
6260
|
+
request['type'] = 'repay';
|
|
6261
|
+
response = await this.privateUnifiedPostLoans(this.extend(request, params));
|
|
6262
|
+
}
|
|
6263
|
+
else {
|
|
6264
|
+
response = await this.privateMarginPostCrossRepayments(this.extend(request, params));
|
|
6265
|
+
response = this.safeDict(response, 0);
|
|
6266
|
+
//
|
|
6267
|
+
// [
|
|
6268
|
+
// {
|
|
6269
|
+
// "id": "17",
|
|
6270
|
+
// "create_time": 1620381696159,
|
|
6271
|
+
// "update_time": 1620381696159,
|
|
6272
|
+
// "currency": "EOS",
|
|
6273
|
+
// "amount": "110.553635",
|
|
6274
|
+
// "text": "web",
|
|
6275
|
+
// "status": 2,
|
|
6276
|
+
// "repaid": "110.506649705159",
|
|
6277
|
+
// "repaid_interest": "0.046985294841",
|
|
6278
|
+
// "unpaid_interest": "0.0000074393366667"
|
|
6279
|
+
// }
|
|
6280
|
+
// ]
|
|
6281
|
+
//
|
|
6282
|
+
}
|
|
6231
6283
|
return this.parseMarginLoan(response, currency);
|
|
6232
6284
|
}
|
|
6233
6285
|
async borrowIsolatedMargin(symbol, code, amount, params = {}) {
|
|
@@ -6281,34 +6333,46 @@ export default class gate extends Exchange {
|
|
|
6281
6333
|
* @name gate#borrowMargin
|
|
6282
6334
|
* @description create a loan to borrow margin
|
|
6283
6335
|
* @see https://www.gate.io/docs/apiv4/en/#create-a-cross-margin-borrow-loan
|
|
6336
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#borrow-or-repay
|
|
6284
6337
|
* @param {string} code unified currency code of the currency to borrow
|
|
6285
6338
|
* @param {float} amount the amount to borrow
|
|
6286
6339
|
* @param {string} symbol unified market symbol, required for isolated margin
|
|
6287
6340
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
6288
6341
|
* @param {string} [params.rate] '0.0002' or '0.002' extra parameter required for isolated margin
|
|
6342
|
+
* @param {boolean} [params.unifiedAccount] set to true for borrowing in the unified account
|
|
6289
6343
|
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
|
|
6290
6344
|
*/
|
|
6291
6345
|
await this.loadMarkets();
|
|
6346
|
+
await this.loadUnifiedStatus();
|
|
6292
6347
|
const currency = this.currency(code);
|
|
6293
6348
|
const request = {
|
|
6294
6349
|
'currency': currency['id'].toUpperCase(),
|
|
6295
6350
|
'amount': this.currencyToPrecision(code, amount),
|
|
6296
6351
|
};
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6352
|
+
let isUnifiedAccount = false;
|
|
6353
|
+
[isUnifiedAccount, params] = this.handleOptionAndParams(params, 'borrowCrossMargin', 'unifiedAccount');
|
|
6354
|
+
let response = undefined;
|
|
6355
|
+
if (isUnifiedAccount) {
|
|
6356
|
+
request['type'] = 'borrow';
|
|
6357
|
+
response = await this.privateUnifiedPostLoans(this.extend(request, params));
|
|
6358
|
+
}
|
|
6359
|
+
else {
|
|
6360
|
+
response = await this.privateMarginPostCrossLoans(this.extend(request, params));
|
|
6361
|
+
//
|
|
6362
|
+
// {
|
|
6363
|
+
// "id": "17",
|
|
6364
|
+
// "create_time": 1620381696159,
|
|
6365
|
+
// "update_time": 1620381696159,
|
|
6366
|
+
// "currency": "EOS",
|
|
6367
|
+
// "amount": "110.553635",
|
|
6368
|
+
// "text": "web",
|
|
6369
|
+
// "status": 2,
|
|
6370
|
+
// "repaid": "110.506649705159",
|
|
6371
|
+
// "repaid_interest": "0.046985294841",
|
|
6372
|
+
// "unpaid_interest": "0.0000074393366667"
|
|
6373
|
+
// }
|
|
6374
|
+
//
|
|
6375
|
+
}
|
|
6312
6376
|
return this.parseMarginLoan(response, currency);
|
|
6313
6377
|
}
|
|
6314
6378
|
parseMarginLoan(info, currency = undefined) {
|
|
@@ -6365,6 +6429,78 @@ export default class gate extends Exchange {
|
|
|
6365
6429
|
'info': info,
|
|
6366
6430
|
};
|
|
6367
6431
|
}
|
|
6432
|
+
async fetchBorrowInterest(code = undefined, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
6433
|
+
/**
|
|
6434
|
+
* @method
|
|
6435
|
+
* @name gate#fetchBorrowInterest
|
|
6436
|
+
* @description fetch the interest owed by the user for borrowing currency for margin trading
|
|
6437
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#list-interest-records
|
|
6438
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#interest-records-for-the-cross-margin-account
|
|
6439
|
+
* @see https://www.gate.io/docs/developers/apiv4/en/#list-interest-records-2
|
|
6440
|
+
* @param {string} [code] unified currency code
|
|
6441
|
+
* @param {string} [symbol] unified market symbol when fetching interest in isolated markets
|
|
6442
|
+
* @param {int} [since] the earliest time in ms to fetch borrow interest for
|
|
6443
|
+
* @param {int} [limit] the maximum number of structures to retrieve
|
|
6444
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
6445
|
+
* @param {boolean} [params.unifiedAccount] set to true for fetching borrow interest in the unified account
|
|
6446
|
+
* @returns {object[]} a list of [borrow interest structures]{@link https://docs.ccxt.com/#/?id=borrow-interest-structure}
|
|
6447
|
+
*/
|
|
6448
|
+
await this.loadMarkets();
|
|
6449
|
+
await this.loadUnifiedStatus();
|
|
6450
|
+
let isUnifiedAccount = false;
|
|
6451
|
+
[isUnifiedAccount, params] = this.handleOptionAndParams(params, 'fetchBorrowInterest', 'unifiedAccount');
|
|
6452
|
+
let request = {};
|
|
6453
|
+
[request, params] = this.handleUntilOption('to', request, params);
|
|
6454
|
+
let currency = undefined;
|
|
6455
|
+
if (code !== undefined) {
|
|
6456
|
+
currency = this.currency(code);
|
|
6457
|
+
request['currency'] = currency['id'];
|
|
6458
|
+
}
|
|
6459
|
+
let market = undefined;
|
|
6460
|
+
if (symbol !== undefined) {
|
|
6461
|
+
market = this.market(symbol);
|
|
6462
|
+
}
|
|
6463
|
+
if (since !== undefined) {
|
|
6464
|
+
request['from'] = since;
|
|
6465
|
+
}
|
|
6466
|
+
if (limit !== undefined) {
|
|
6467
|
+
request['limit'] = limit;
|
|
6468
|
+
}
|
|
6469
|
+
let response = undefined;
|
|
6470
|
+
let marginMode = undefined;
|
|
6471
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchBorrowInterest', params, 'cross');
|
|
6472
|
+
if (isUnifiedAccount) {
|
|
6473
|
+
response = await this.privateUnifiedGetInterestRecords(this.extend(request, params));
|
|
6474
|
+
}
|
|
6475
|
+
else if (marginMode === 'isolated') {
|
|
6476
|
+
if (market !== undefined) {
|
|
6477
|
+
request['currency_pair'] = market['id'];
|
|
6478
|
+
}
|
|
6479
|
+
response = await this.privateMarginGetUniInterestRecords(this.extend(request, params));
|
|
6480
|
+
}
|
|
6481
|
+
else if (marginMode === 'cross') {
|
|
6482
|
+
response = await this.privateMarginGetCrossInterestRecords(this.extend(request, params));
|
|
6483
|
+
}
|
|
6484
|
+
const interest = this.parseBorrowInterests(response, market);
|
|
6485
|
+
return this.filterByCurrencySinceLimit(interest, code, since, limit);
|
|
6486
|
+
}
|
|
6487
|
+
parseBorrowInterest(info, market = undefined) {
|
|
6488
|
+
const marketId = this.safeString(info, 'currency_pair');
|
|
6489
|
+
market = this.safeMarket(marketId, market);
|
|
6490
|
+
const marginMode = (marketId !== undefined) ? 'isolated' : 'cross';
|
|
6491
|
+
const timestamp = this.safeInteger(info, 'create_time');
|
|
6492
|
+
return {
|
|
6493
|
+
'info': info,
|
|
6494
|
+
'timestamp': timestamp,
|
|
6495
|
+
'datetime': this.iso8601(timestamp),
|
|
6496
|
+
'symbol': this.safeString(market, 'symbol'),
|
|
6497
|
+
'currency': this.safeCurrencyCode(this.safeString(info, 'currency')),
|
|
6498
|
+
'marginMode': marginMode,
|
|
6499
|
+
'interest': this.safeNumber(info, 'interest'),
|
|
6500
|
+
'interestRate': this.safeNumber(info, 'actual_rate'),
|
|
6501
|
+
'amountBorrowed': undefined,
|
|
6502
|
+
};
|
|
6503
|
+
}
|
|
6368
6504
|
sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
6369
6505
|
const authentication = api[0]; // public, private
|
|
6370
6506
|
const type = api[1]; // spot, margin, future, delivery
|
package/js/src/hitbtc.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export default class hitbtc extends Exchange {
|
|
|
9
9
|
nonce(): number;
|
|
10
10
|
fetchMarkets(params?: {}): Promise<Market[]>;
|
|
11
11
|
fetchCurrencies(params?: {}): Promise<Currencies>;
|
|
12
|
-
safeNetwork(networkId: any): any;
|
|
13
12
|
createDepositAddress(code: string, params?: {}): Promise<{
|
|
14
13
|
currency: string;
|
|
15
14
|
address: string;
|
package/js/src/hitbtc.js
CHANGED
|
@@ -854,7 +854,8 @@ export default class hitbtc extends Exchange {
|
|
|
854
854
|
for (let j = 0; j < rawNetworks.length; j++) {
|
|
855
855
|
const rawNetwork = rawNetworks[j];
|
|
856
856
|
const networkId = this.safeString2(rawNetwork, 'protocol', 'network');
|
|
857
|
-
|
|
857
|
+
let networkCode = this.networkIdToCode(networkId);
|
|
858
|
+
networkCode = (networkCode !== undefined) ? networkCode.toUpperCase() : undefined;
|
|
858
859
|
fee = this.safeNumber(rawNetwork, 'payout_fee');
|
|
859
860
|
const networkPrecision = this.safeNumber(rawNetwork, 'precision_payout');
|
|
860
861
|
const payinEnabledNetwork = this.safeBool(rawNetwork, 'payin_enabled', false);
|
|
@@ -872,10 +873,10 @@ export default class hitbtc extends Exchange {
|
|
|
872
873
|
else if (!payoutEnabledNetwork) {
|
|
873
874
|
withdrawEnabled = false;
|
|
874
875
|
}
|
|
875
|
-
networks[
|
|
876
|
+
networks[networkCode] = {
|
|
876
877
|
'info': rawNetwork,
|
|
877
878
|
'id': networkId,
|
|
878
|
-
'network':
|
|
879
|
+
'network': networkCode,
|
|
879
880
|
'fee': fee,
|
|
880
881
|
'active': activeNetwork,
|
|
881
882
|
'deposit': payinEnabledNetwork,
|
|
@@ -912,14 +913,6 @@ export default class hitbtc extends Exchange {
|
|
|
912
913
|
}
|
|
913
914
|
return result;
|
|
914
915
|
}
|
|
915
|
-
safeNetwork(networkId) {
|
|
916
|
-
if (networkId === undefined) {
|
|
917
|
-
return undefined;
|
|
918
|
-
}
|
|
919
|
-
else {
|
|
920
|
-
return networkId.toUpperCase();
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
916
|
async createDepositAddress(code, params = {}) {
|
|
924
917
|
/**
|
|
925
918
|
* @method
|
|
@@ -3560,7 +3553,8 @@ export default class hitbtc extends Exchange {
|
|
|
3560
3553
|
for (let j = 0; j < networks.length; j++) {
|
|
3561
3554
|
const networkEntry = networks[j];
|
|
3562
3555
|
const networkId = this.safeString(networkEntry, 'network');
|
|
3563
|
-
|
|
3556
|
+
let networkCode = this.networkIdToCode(networkId);
|
|
3557
|
+
networkCode = (networkCode !== undefined) ? networkCode.toUpperCase() : undefined;
|
|
3564
3558
|
const withdrawFee = this.safeNumber(networkEntry, 'payout_fee');
|
|
3565
3559
|
const isDefault = this.safeValue(networkEntry, 'default');
|
|
3566
3560
|
const withdrawResult = {
|