ccxt 4.2.85 → 4.2.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/js/src/coinex.js CHANGED
@@ -31,6 +31,7 @@ export default class coinex extends Exchange {
31
31
  // 60 per 2 seconds => 30 per second => weight = 13.334
32
32
  // 40 per 2 seconds => 20 per second => weight = 20
33
33
  // 20 per 2 seconds => 10 per second => weight = 40
34
+ // v1 is per 2 seconds and v2 is per 1 second
34
35
  'rateLimit': 2.5,
35
36
  'pro': true,
36
37
  'certified': true,
@@ -137,156 +138,279 @@ export default class coinex extends Exchange {
137
138
  'perpetualPrivate': 'https://api.coinex.com/perpetual',
138
139
  },
139
140
  'www': 'https://www.coinex.com',
140
- 'doc': 'https://viabtc.github.io/coinex_api_en_doc',
141
+ 'doc': 'https://docs.coinex.com/api/v2',
141
142
  'fees': 'https://www.coinex.com/fees',
142
143
  'referral': 'https://www.coinex.com/register?refer_code=yw5fz',
143
144
  },
144
145
  'api': {
145
- 'public': {
146
- 'get': {
147
- 'amm/market': 1,
148
- 'common/currency/rate': 1,
149
- 'common/asset/config': 1,
150
- 'common/maintain/info': 1,
151
- 'common/temp-maintain/info': 1,
152
- 'margin/market': 1,
153
- 'market/info': 1,
154
- 'market/list': 1,
155
- 'market/ticker': 1,
156
- 'market/ticker/all': 1,
157
- 'market/depth': 1,
158
- 'market/deals': 1,
159
- 'market/kline': 1,
160
- 'market/detail': 1,
161
- },
162
- },
163
- 'private': {
164
- 'get': {
165
- 'account/amm/balance': 40,
166
- 'account/investment/balance': 40,
167
- 'account/balance/history': 40,
168
- 'account/market/fee': 40,
169
- 'balance/coin/deposit': 40,
170
- 'balance/coin/withdraw': 40,
171
- 'balance/info': 40,
172
- 'balance/deposit/address/{coin_type}': 40,
173
- 'contract/transfer/history': 40,
174
- 'credit/info': 40,
175
- 'credit/balance': 40,
176
- 'investment/transfer/history': 40,
177
- 'margin/account': 1,
178
- 'margin/config': 1,
179
- 'margin/loan/history': 40,
180
- 'margin/transfer/history': 40,
181
- 'order/deals': 40,
182
- 'order/finished': 40,
183
- 'order/pending': 8,
184
- 'order/status': 8,
185
- 'order/status/batch': 8,
186
- 'order/user/deals': 40,
187
- 'order/stop/finished': 40,
188
- 'order/stop/pending': 8,
189
- 'order/user/trade/fee': 1,
190
- 'order/market/trade/info': 1,
191
- 'sub_account/balance': 1,
192
- 'sub_account/transfer/history': 40,
193
- 'sub_account/auth/api': 40,
194
- 'sub_account/auth/api/{user_auth_id}': 40,
195
- },
196
- 'post': {
197
- 'balance/coin/withdraw': 40,
198
- 'contract/balance/transfer': 40,
199
- 'margin/flat': 40,
200
- 'margin/loan': 40,
201
- 'margin/transfer': 40,
202
- 'order/limit/batch': 40,
203
- 'order/ioc': 13.334,
204
- 'order/limit': 13.334,
205
- 'order/market': 13.334,
206
- 'order/modify': 13.334,
207
- 'order/stop/limit': 13.334,
208
- 'order/stop/market': 13.334,
209
- 'order/stop/modify': 13.334,
210
- 'sub_account/transfer': 40,
211
- 'sub_account/register': 1,
212
- 'sub_account/unfrozen': 40,
213
- 'sub_account/frozen': 40,
214
- 'sub_account/auth/api': 40,
146
+ 'v1': {
147
+ 'public': {
148
+ 'get': {
149
+ 'amm/market': 1,
150
+ 'common/currency/rate': 1,
151
+ 'common/asset/config': 1,
152
+ 'common/maintain/info': 1,
153
+ 'common/temp-maintain/info': 1,
154
+ 'margin/market': 1,
155
+ 'market/info': 1,
156
+ 'market/list': 1,
157
+ 'market/ticker': 1,
158
+ 'market/ticker/all': 1,
159
+ 'market/depth': 1,
160
+ 'market/deals': 1,
161
+ 'market/kline': 1,
162
+ 'market/detail': 1,
163
+ },
215
164
  },
216
- 'put': {
217
- 'balance/deposit/address/{coin_type}': 40,
218
- 'sub_account/unfrozen': 40,
219
- 'sub_account/frozen': 40,
220
- 'sub_account/auth/api/{user_auth_id}': 40,
221
- 'v1/account/settings': 40,
165
+ 'private': {
166
+ 'get': {
167
+ 'account/amm/balance': 40,
168
+ 'account/investment/balance': 40,
169
+ 'account/balance/history': 40,
170
+ 'account/market/fee': 40,
171
+ 'balance/coin/deposit': 40,
172
+ 'balance/coin/withdraw': 40,
173
+ 'balance/info': 40,
174
+ 'balance/deposit/address/{coin_type}': 40,
175
+ 'contract/transfer/history': 40,
176
+ 'credit/info': 40,
177
+ 'credit/balance': 40,
178
+ 'investment/transfer/history': 40,
179
+ 'margin/account': 1,
180
+ 'margin/config': 1,
181
+ 'margin/loan/history': 40,
182
+ 'margin/transfer/history': 40,
183
+ 'order/deals': 40,
184
+ 'order/finished': 40,
185
+ 'order/pending': 8,
186
+ 'order/status': 8,
187
+ 'order/status/batch': 8,
188
+ 'order/user/deals': 40,
189
+ 'order/stop/finished': 40,
190
+ 'order/stop/pending': 8,
191
+ 'order/user/trade/fee': 1,
192
+ 'order/market/trade/info': 1,
193
+ 'sub_account/balance': 1,
194
+ 'sub_account/transfer/history': 40,
195
+ 'sub_account/auth/api': 40,
196
+ 'sub_account/auth/api/{user_auth_id}': 40,
197
+ },
198
+ 'post': {
199
+ 'balance/coin/withdraw': 40,
200
+ 'contract/balance/transfer': 40,
201
+ 'margin/flat': 40,
202
+ 'margin/loan': 40,
203
+ 'margin/transfer': 40,
204
+ 'order/limit/batch': 40,
205
+ 'order/ioc': 13.334,
206
+ 'order/limit': 13.334,
207
+ 'order/market': 13.334,
208
+ 'order/modify': 13.334,
209
+ 'order/stop/limit': 13.334,
210
+ 'order/stop/market': 13.334,
211
+ 'order/stop/modify': 13.334,
212
+ 'sub_account/transfer': 40,
213
+ 'sub_account/register': 1,
214
+ 'sub_account/unfrozen': 40,
215
+ 'sub_account/frozen': 40,
216
+ 'sub_account/auth/api': 40,
217
+ },
218
+ 'put': {
219
+ 'balance/deposit/address/{coin_type}': 40,
220
+ 'sub_account/unfrozen': 40,
221
+ 'sub_account/frozen': 40,
222
+ 'sub_account/auth/api/{user_auth_id}': 40,
223
+ 'v1/account/settings': 40,
224
+ },
225
+ 'delete': {
226
+ 'balance/coin/withdraw': 40,
227
+ 'order/pending/batch': 40,
228
+ 'order/pending': 13.334,
229
+ 'order/stop/pending': 40,
230
+ 'order/stop/pending/{id}': 13.334,
231
+ 'order/pending/by_client_id': 40,
232
+ 'order/stop/pending/by_client_id': 40,
233
+ 'sub_account/auth/api/{user_auth_id}': 40,
234
+ 'sub_account/authorize/{id}': 40,
235
+ },
222
236
  },
223
- 'delete': {
224
- 'balance/coin/withdraw': 40,
225
- 'order/pending/batch': 40,
226
- 'order/pending': 13.334,
227
- 'order/stop/pending': 40,
228
- 'order/stop/pending/{id}': 13.334,
229
- 'order/pending/by_client_id': 40,
230
- 'order/stop/pending/by_client_id': 40,
231
- 'sub_account/auth/api/{user_auth_id}': 40,
232
- 'sub_account/authorize/{id}': 40,
237
+ 'perpetualPublic': {
238
+ 'get': {
239
+ 'ping': 1,
240
+ 'time': 1,
241
+ 'market/list': 1,
242
+ 'market/limit_config': 1,
243
+ 'market/ticker': 1,
244
+ 'market/ticker/all': 1,
245
+ 'market/depth': 1,
246
+ 'market/deals': 1,
247
+ 'market/funding_history': 1,
248
+ 'market/kline': 1,
249
+ },
233
250
  },
234
- },
235
- 'perpetualPublic': {
236
- 'get': {
237
- 'ping': 1,
238
- 'time': 1,
239
- 'market/list': 1,
240
- 'market/limit_config': 1,
241
- 'market/ticker': 1,
242
- 'market/ticker/all': 1,
243
- 'market/depth': 1,
244
- 'market/deals': 1,
245
- 'market/funding_history': 1,
246
- 'market/kline': 1,
251
+ 'perpetualPrivate': {
252
+ 'get': {
253
+ 'market/user_deals': 1,
254
+ 'asset/query': 40,
255
+ 'order/pending': 8,
256
+ 'order/finished': 40,
257
+ 'order/stop_finished': 40,
258
+ 'order/stop_pending': 8,
259
+ 'order/status': 8,
260
+ 'order/stop_status': 8,
261
+ 'position/finished': 40,
262
+ 'position/pending': 40,
263
+ 'position/funding': 40,
264
+ 'position/adl_history': 40,
265
+ 'market/preference': 40,
266
+ 'position/margin_history': 40,
267
+ 'position/settle_history': 40,
268
+ },
269
+ 'post': {
270
+ 'market/adjust_leverage': 1,
271
+ 'market/position_expect': 1,
272
+ 'order/put_limit': 20,
273
+ 'order/put_market': 20,
274
+ 'order/put_stop_limit': 20,
275
+ 'order/put_stop_market': 20,
276
+ 'order/modify': 20,
277
+ 'order/modify_stop': 20,
278
+ 'order/cancel': 20,
279
+ 'order/cancel_all': 40,
280
+ 'order/cancel_batch': 40,
281
+ 'order/cancel_stop': 20,
282
+ 'order/cancel_stop_all': 40,
283
+ 'order/close_limit': 20,
284
+ 'order/close_market': 20,
285
+ 'position/adjust_margin': 20,
286
+ 'position/stop_loss': 20,
287
+ 'position/take_profit': 20,
288
+ 'position/market_close': 20,
289
+ 'order/cancel/by_client_id': 20,
290
+ 'order/cancel_stop/by_client_id': 20,
291
+ 'market/preference': 20,
292
+ },
247
293
  },
248
294
  },
249
- 'perpetualPrivate': {
250
- 'get': {
251
- 'market/user_deals': 1,
252
- 'asset/query': 40,
253
- 'order/pending': 8,
254
- 'order/finished': 40,
255
- 'order/stop_finished': 40,
256
- 'order/stop_pending': 8,
257
- 'order/status': 8,
258
- 'order/stop_status': 8,
259
- 'position/finished': 40,
260
- 'position/pending': 40,
261
- 'position/funding': 40,
262
- 'position/adl_history': 40,
263
- 'market/preference': 40,
264
- 'position/margin_history': 40,
265
- 'position/settle_history': 40,
295
+ 'v2': {
296
+ 'public': {
297
+ 'get': {
298
+ 'maintain-info': 1,
299
+ 'ping': 1,
300
+ 'time': 1,
301
+ 'spot/market': 1,
302
+ 'spot/ticker': 1,
303
+ 'spot/depth': 1,
304
+ 'spot/deals': 1,
305
+ 'spot/kline': 1,
306
+ 'spot/index': 1,
307
+ 'futures/market': 1,
308
+ 'futures/ticker': 1,
309
+ 'futures/depth': 1,
310
+ 'futures/deals': 1,
311
+ 'futures/kline': 1,
312
+ 'futures/index': 1,
313
+ 'futures/funding-rate': 1,
314
+ 'futures/funding-rate-history': 1,
315
+ 'futures/position-level': 1,
316
+ 'futures/liquidation-history': 1,
317
+ 'futures/basis-history': 1,
318
+ },
266
319
  },
267
- 'post': {
268
- 'market/adjust_leverage': 1,
269
- 'market/position_expect': 1,
270
- 'order/put_limit': 20,
271
- 'order/put_market': 20,
272
- 'order/put_stop_limit': 20,
273
- 'order/put_stop_market': 20,
274
- 'order/modify': 20,
275
- 'order/modify_stop': 20,
276
- 'order/cancel': 20,
277
- 'order/cancel_all': 40,
278
- 'order/cancel_batch': 40,
279
- 'order/cancel_stop': 20,
280
- 'order/cancel_stop_all': 40,
281
- 'order/close_limit': 20,
282
- 'order/close_market': 20,
283
- 'position/adjust_margin': 20,
284
- 'position/stop_loss': 20,
285
- 'position/take_profit': 20,
286
- 'position/market_close': 20,
287
- 'order/cancel/by_client_id': 20,
288
- 'order/cancel_stop/by_client_id': 20,
289
- 'market/preference': 20,
320
+ 'private': {
321
+ 'get': {
322
+ 'account/subs': 1,
323
+ 'account/subs/api-detail': 40,
324
+ 'account/subs/info': 1,
325
+ 'account/subs/api': 40,
326
+ 'account/subs/transfer-history': 40,
327
+ 'account/subs/spot-balance': 1,
328
+ 'account/trade-fee-rate': 40,
329
+ 'assets/spot/balance': 40,
330
+ 'assets/futures/balance': 40,
331
+ 'assets/margin/balance': 1,
332
+ 'assets/financial/balance': 40,
333
+ 'assets/amm/liquidity': 40,
334
+ 'assets/credit/info': 40,
335
+ 'assets/margin/borrow-history': 40,
336
+ 'assets/margin/interest-limit': 1,
337
+ 'assets/deposit-address': 40,
338
+ 'assets/deposit-history': 40,
339
+ 'assets/withdraw': 40,
340
+ 'assets/deposit-withdraw-config': 1,
341
+ 'assets/transfer-history': 40,
342
+ 'spot/order-status': 8,
343
+ 'spot/batch-order-status': 8,
344
+ 'spot/pending-order': 8,
345
+ 'spot/finished-order': 40,
346
+ 'spot/pending-stop-order': 8,
347
+ 'spot/finished-stop-order': 40,
348
+ 'spot/user-deals': 40,
349
+ 'spot/order-deals': 40,
350
+ 'futures/order-status': 8,
351
+ 'futures/batch-order-status': 1,
352
+ 'futures/pending-order': 8,
353
+ 'futures/finished-order': 40,
354
+ 'futures/pending-stop-order': 8,
355
+ 'futures/finished-stop-order': 40,
356
+ 'futures/user-deals': 1,
357
+ 'futures/order-deals': 1,
358
+ 'futures/pending-position': 40,
359
+ 'futures/finished-position': 1,
360
+ 'futures/position-margin-history': 1,
361
+ 'futures/position-funding-history': 40,
362
+ 'futures/position-adl-history': 1,
363
+ 'futures/position-settle-history': 1,
364
+ },
365
+ 'post': {
366
+ 'account/subs': 40,
367
+ 'account/subs/frozen': 40,
368
+ 'account/subs/unfrozen': 40,
369
+ 'account/subs/api': 40,
370
+ 'account/subs/edit-api': 40,
371
+ 'account/subs/delete-api': 40,
372
+ 'account/subs/transfer': 40,
373
+ 'account/settings': 40,
374
+ 'assets/margin/borrow': 40,
375
+ 'assets/margin/repay': 40,
376
+ 'assets/renewal-deposit-address': 40,
377
+ 'assets/withdraw': 40,
378
+ 'assets/cancel-withdraw': 40,
379
+ 'assets/transfer': 40,
380
+ 'assets/amm/add-liquidity': 1,
381
+ 'assets/amm/remove-liquidity': 1,
382
+ 'spot/order': 13.334,
383
+ 'spot/stop-order': 13.334,
384
+ 'spot/batch-order': 40,
385
+ 'spot/batch-stop-order': 1,
386
+ 'spot/modify-order': 13.334,
387
+ 'spot/modify-stop-order': 13.334,
388
+ 'spot/cancel-all-order': 1,
389
+ 'spot/cancel-order': 6.667,
390
+ 'spot/cancel-stop-order': 6.667,
391
+ 'spot/cancel-batch-order': 10,
392
+ 'spot/cancel-batch-stop-order': 10,
393
+ 'spot/cancel-order-by-client-id': 1,
394
+ 'spot/cancel-stop-order-by-client-id': 1,
395
+ 'futures/order': 20,
396
+ 'futures/stop-order': 20,
397
+ 'futures/batch-order': 1,
398
+ 'futures/batch-stop-order': 1,
399
+ 'futures/modify-order': 20,
400
+ 'futures/modify-stop-order': 20,
401
+ 'futures/cancel-all-order': 1,
402
+ 'futures/cancel-order': 10,
403
+ 'futures/cancel-stop-order': 10,
404
+ 'futures/cancel-batch-order': 20,
405
+ 'futures/cancel-batch-stop-order': 20,
406
+ 'futures/cancel-order-by-client-id': 1,
407
+ 'futures/cancel-stop-order-by-client-id': 1,
408
+ 'futures/close-position': 20,
409
+ 'futures/adjust-position-margin': 20,
410
+ 'futures/adjust-position-leverage': 20,
411
+ 'futures/set-position-stop-loss': 20,
412
+ 'futures/set-position-take-profit': 20,
413
+ },
290
414
  },
291
415
  },
292
416
  },
@@ -357,7 +481,7 @@ export default class coinex extends Exchange {
357
481
  });
358
482
  }
359
483
  async fetchCurrencies(params = {}) {
360
- const response = await this.publicGetCommonAssetConfig(params);
484
+ const response = await this.v1PublicGetCommonAssetConfig(params);
361
485
  // {
362
486
  // "code": 0,
363
487
  // "data": {
@@ -505,7 +629,7 @@ export default class coinex extends Exchange {
505
629
  return this.arrayConcat(spotMarkets, swapMarkets);
506
630
  }
507
631
  async fetchSpotMarkets(params) {
508
- const response = await this.publicGetMarketInfo(params);
632
+ const response = await this.v1PublicGetMarketInfo(params);
509
633
  //
510
634
  // {
511
635
  // "code": 0,
@@ -594,7 +718,7 @@ export default class coinex extends Exchange {
594
718
  return result;
595
719
  }
596
720
  async fetchContractMarkets(params) {
597
- const response = await this.perpetualPublicGetMarketList(params);
721
+ const response = await this.v1PerpetualPublicGetMarketList(params);
598
722
  //
599
723
  // {
600
724
  // "code": 0,
@@ -776,10 +900,10 @@ export default class coinex extends Exchange {
776
900
  };
777
901
  let response = undefined;
778
902
  if (market['swap']) {
779
- response = await this.perpetualPublicGetMarketTicker(this.extend(request, params));
903
+ response = await this.v1PerpetualPublicGetMarketTicker(this.extend(request, params));
780
904
  }
781
905
  else {
782
- response = await this.publicGetMarketTicker(this.extend(request, params));
906
+ response = await this.v1PublicGetMarketTicker(this.extend(request, params));
783
907
  }
784
908
  //
785
909
  // Spot
@@ -858,10 +982,10 @@ export default class coinex extends Exchange {
858
982
  const [marketType, query] = this.handleMarketTypeAndParams('fetchTickers', market, params);
859
983
  let response = undefined;
860
984
  if (marketType === 'swap') {
861
- response = await this.perpetualPublicGetMarketTickerAll(query);
985
+ response = await this.v1PerpetualPublicGetMarketTickerAll(query);
862
986
  }
863
987
  else {
864
- response = await this.publicGetMarketTickerAll();
988
+ response = await this.v1PublicGetMarketTickerAll();
865
989
  }
866
990
  //
867
991
  // Spot
@@ -948,7 +1072,7 @@ export default class coinex extends Exchange {
948
1072
  * @param {object} [params] extra parameters specific to the exchange API endpoint
949
1073
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
950
1074
  */
951
- const response = await this.perpetualPublicGetTime(params);
1075
+ const response = await this.v1PerpetualPublicGetTime(params);
952
1076
  //
953
1077
  // {
954
1078
  // "code": "0",
@@ -982,10 +1106,10 @@ export default class coinex extends Exchange {
982
1106
  };
983
1107
  let response = undefined;
984
1108
  if (market['swap']) {
985
- response = await this.perpetualPublicGetMarketDepth(this.extend(request, params));
1109
+ response = await this.v1PerpetualPublicGetMarketDepth(this.extend(request, params));
986
1110
  }
987
1111
  else {
988
- response = await this.publicGetMarketDepth(this.extend(request, params));
1112
+ response = await this.v1PublicGetMarketDepth(this.extend(request, params));
989
1113
  }
990
1114
  //
991
1115
  // Spot
@@ -1186,10 +1310,10 @@ export default class coinex extends Exchange {
1186
1310
  }
1187
1311
  let response = undefined;
1188
1312
  if (market['swap']) {
1189
- response = await this.perpetualPublicGetMarketDeals(this.extend(request, params));
1313
+ response = await this.v1PerpetualPublicGetMarketDeals(this.extend(request, params));
1190
1314
  }
1191
1315
  else {
1192
- response = await this.publicGetMarketDeals(this.extend(request, params));
1316
+ response = await this.v1PublicGetMarketDeals(this.extend(request, params));
1193
1317
  }
1194
1318
  //
1195
1319
  // Spot and Swap
@@ -1226,7 +1350,7 @@ export default class coinex extends Exchange {
1226
1350
  const request = {
1227
1351
  'market': market['id'],
1228
1352
  };
1229
- const response = await this.publicGetMarketDetail(this.extend(request, params));
1353
+ const response = await this.v1PublicGetMarketDetail(this.extend(request, params));
1230
1354
  //
1231
1355
  // {
1232
1356
  // "code": 0,
@@ -1256,7 +1380,7 @@ export default class coinex extends Exchange {
1256
1380
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
1257
1381
  */
1258
1382
  await this.loadMarkets();
1259
- const response = await this.publicGetMarketInfo(params);
1383
+ const response = await this.v1PublicGetMarketInfo(params);
1260
1384
  //
1261
1385
  // {
1262
1386
  // "code": 0,
@@ -1344,10 +1468,10 @@ export default class coinex extends Exchange {
1344
1468
  }
1345
1469
  let response = undefined;
1346
1470
  if (market['swap']) {
1347
- response = await this.perpetualPublicGetMarketKline(this.extend(request, params));
1471
+ response = await this.v1PerpetualPublicGetMarketKline(this.extend(request, params));
1348
1472
  }
1349
1473
  else {
1350
- response = await this.publicGetMarketKline(this.extend(request, params));
1474
+ response = await this.v1PublicGetMarketKline(this.extend(request, params));
1351
1475
  }
1352
1476
  //
1353
1477
  // Spot
@@ -1393,7 +1517,7 @@ export default class coinex extends Exchange {
1393
1517
  const request = {
1394
1518
  'market': marketId,
1395
1519
  };
1396
- const response = await this.privateGetMarginAccount(this.extend(request, params));
1520
+ const response = await this.v1PrivateGetMarginAccount(this.extend(request, params));
1397
1521
  //
1398
1522
  // {
1399
1523
  // "code": 0,
@@ -1460,7 +1584,7 @@ export default class coinex extends Exchange {
1460
1584
  }
1461
1585
  async fetchSpotBalance(params = {}) {
1462
1586
  await this.loadMarkets();
1463
- const response = await this.privateGetBalanceInfo(params);
1587
+ const response = await this.v1PrivateGetBalanceInfo(params);
1464
1588
  //
1465
1589
  // {
1466
1590
  // "code": 0,
@@ -1497,7 +1621,7 @@ export default class coinex extends Exchange {
1497
1621
  }
1498
1622
  async fetchSwapBalance(params = {}) {
1499
1623
  await this.loadMarkets();
1500
- const response = await this.perpetualPrivateGetAssetQuery(params);
1624
+ const response = await this.v1PerpetualPrivateGetAssetQuery(params);
1501
1625
  //
1502
1626
  // {
1503
1627
  // "code": 0,
@@ -1531,7 +1655,7 @@ export default class coinex extends Exchange {
1531
1655
  }
1532
1656
  async fetchFinancialBalance(params = {}) {
1533
1657
  await this.loadMarkets();
1534
- const response = await this.privateGetAccountInvestmentBalance(params);
1658
+ const response = await this.v1PrivateGetAccountInvestmentBalance(params);
1535
1659
  //
1536
1660
  // {
1537
1661
  // "code": 0,
@@ -2171,53 +2295,53 @@ export default class coinex extends Exchange {
2171
2295
  if (market['spot']) {
2172
2296
  if (isTriggerOrder) {
2173
2297
  if (type === 'limit') {
2174
- response = await this.privatePostOrderStopLimit(request);
2298
+ response = await this.v1PrivatePostOrderStopLimit(request);
2175
2299
  }
2176
2300
  else {
2177
- response = await this.privatePostOrderStopMarket(request);
2301
+ response = await this.v1PrivatePostOrderStopMarket(request);
2178
2302
  }
2179
2303
  }
2180
2304
  else {
2181
2305
  if (type === 'limit') {
2182
- response = await this.privatePostOrderLimit(request);
2306
+ response = await this.v1PrivatePostOrderLimit(request);
2183
2307
  }
2184
2308
  else {
2185
- response = await this.privatePostOrderMarket(request);
2309
+ response = await this.v1PrivatePostOrderMarket(request);
2186
2310
  }
2187
2311
  }
2188
2312
  }
2189
2313
  else {
2190
2314
  if (isTriggerOrder) {
2191
2315
  if (type === 'limit') {
2192
- response = await this.perpetualPrivatePostOrderPutStopLimit(request);
2316
+ response = await this.v1PerpetualPrivatePostOrderPutStopLimit(request);
2193
2317
  }
2194
2318
  else {
2195
- response = await this.perpetualPrivatePostOrderPutStopMarket(request);
2319
+ response = await this.v1PerpetualPrivatePostOrderPutStopMarket(request);
2196
2320
  }
2197
2321
  }
2198
2322
  else if (isStopLossOrTakeProfitTrigger) {
2199
2323
  if (isStopLossTriggerOrder) {
2200
- response = await this.perpetualPrivatePostPositionStopLoss(request);
2324
+ response = await this.v1PerpetualPrivatePostPositionStopLoss(request);
2201
2325
  }
2202
2326
  else if (isTakeProfitTriggerOrder) {
2203
- response = await this.perpetualPrivatePostPositionTakeProfit(request);
2327
+ response = await this.v1PerpetualPrivatePostPositionTakeProfit(request);
2204
2328
  }
2205
2329
  }
2206
2330
  else {
2207
2331
  if (reduceOnly) {
2208
2332
  if (type === 'limit') {
2209
- response = await this.perpetualPrivatePostOrderCloseLimit(request);
2333
+ response = await this.v1PerpetualPrivatePostOrderCloseLimit(request);
2210
2334
  }
2211
2335
  else {
2212
- response = await this.perpetualPrivatePostOrderCloseMarket(request);
2336
+ response = await this.v1PerpetualPrivatePostOrderCloseMarket(request);
2213
2337
  }
2214
2338
  }
2215
2339
  else {
2216
2340
  if (type === 'limit') {
2217
- response = await this.perpetualPrivatePostOrderPutLimit(request);
2341
+ response = await this.v1PerpetualPrivatePostOrderPutLimit(request);
2218
2342
  }
2219
2343
  else {
2220
- response = await this.perpetualPrivatePostOrderPutMarket(request);
2344
+ response = await this.v1PerpetualPrivatePostOrderPutMarket(request);
2221
2345
  }
2222
2346
  }
2223
2347
  }
@@ -2345,7 +2469,7 @@ export default class coinex extends Exchange {
2345
2469
  'market': market['id'],
2346
2470
  'batch_orders': this.json(ordersRequests),
2347
2471
  };
2348
- const response = await this.privatePostOrderLimitBatch(request);
2472
+ const response = await this.v1PrivatePostOrderLimitBatch(request);
2349
2473
  //
2350
2474
  // {
2351
2475
  // "code": 0,
@@ -2428,11 +2552,11 @@ export default class coinex extends Exchange {
2428
2552
  let response = undefined;
2429
2553
  if (market['spot']) {
2430
2554
  request['batch_ids'] = idsString;
2431
- response = await this.privateDeleteOrderPendingBatch(this.extend(request, params));
2555
+ response = await this.v1PrivateDeleteOrderPendingBatch(this.extend(request, params));
2432
2556
  }
2433
2557
  else {
2434
2558
  request['order_ids'] = idsString;
2435
- response = await this.perpetualPrivatePostOrderCancelBatch(this.extend(request, params));
2559
+ response = await this.v1PerpetualPrivatePostOrderCancelBatch(this.extend(request, params));
2436
2560
  }
2437
2561
  //
2438
2562
  // spot
@@ -2569,7 +2693,7 @@ export default class coinex extends Exchange {
2569
2693
  if (price !== undefined) {
2570
2694
  request['price'] = this.priceToPrecision(symbol, price);
2571
2695
  }
2572
- const response = await this.privatePostOrderModify(this.extend(request, params));
2696
+ const response = await this.v1PrivatePostOrderModify(this.extend(request, params));
2573
2697
  //
2574
2698
  // {
2575
2699
  // "code": 0,
@@ -2650,18 +2774,18 @@ export default class coinex extends Exchange {
2650
2774
  request['client_id'] = clientOrderId;
2651
2775
  if (stop) {
2652
2776
  if (swap) {
2653
- response = await this.perpetualPrivatePostOrderCancelStopByClientId(this.extend(request, query));
2777
+ response = await this.v1PerpetualPrivatePostOrderCancelStopByClientId(this.extend(request, query));
2654
2778
  }
2655
2779
  else {
2656
- response = await this.privateDeleteOrderStopPendingByClientId(this.extend(request, query));
2780
+ response = await this.v1PrivateDeleteOrderStopPendingByClientId(this.extend(request, query));
2657
2781
  }
2658
2782
  }
2659
2783
  else {
2660
2784
  if (swap) {
2661
- response = await this.perpetualPrivatePostOrderCancelByClientId(this.extend(request, query));
2785
+ response = await this.v1PerpetualPrivatePostOrderCancelByClientId(this.extend(request, query));
2662
2786
  }
2663
2787
  else {
2664
- response = await this.privateDeleteOrderPendingByClientId(this.extend(request, query));
2788
+ response = await this.v1PrivateDeleteOrderPendingByClientId(this.extend(request, query));
2665
2789
  }
2666
2790
  }
2667
2791
  }
@@ -2670,18 +2794,18 @@ export default class coinex extends Exchange {
2670
2794
  request[idRequest] = id;
2671
2795
  if (stop) {
2672
2796
  if (swap) {
2673
- response = await this.perpetualPrivatePostOrderCancelStop(this.extend(request, query));
2797
+ response = await this.v1PerpetualPrivatePostOrderCancelStop(this.extend(request, query));
2674
2798
  }
2675
2799
  else {
2676
- response = await this.privateDeleteOrderStopPendingId(this.extend(request, query));
2800
+ response = await this.v1PrivateDeleteOrderStopPendingId(this.extend(request, query));
2677
2801
  }
2678
2802
  }
2679
2803
  else {
2680
2804
  if (swap) {
2681
- response = await this.perpetualPrivatePostOrderCancel(this.extend(request, query));
2805
+ response = await this.v1PerpetualPrivatePostOrderCancel(this.extend(request, query));
2682
2806
  }
2683
2807
  else {
2684
- response = await this.privateDeleteOrderPending(this.extend(request, query));
2808
+ response = await this.v1PrivateDeleteOrderPending(this.extend(request, query));
2685
2809
  }
2686
2810
  }
2687
2811
  }
@@ -2825,19 +2949,19 @@ export default class coinex extends Exchange {
2825
2949
  let response = undefined;
2826
2950
  if (swap) {
2827
2951
  if (stop) {
2828
- response = await this.perpetualPrivatePostOrderCancelStopAll(this.extend(request, params));
2952
+ response = await this.v1PerpetualPrivatePostOrderCancelStopAll(this.extend(request, params));
2829
2953
  }
2830
2954
  else {
2831
- response = await this.perpetualPrivatePostOrderCancelAll(this.extend(request, params));
2955
+ response = await this.v1PerpetualPrivatePostOrderCancelAll(this.extend(request, params));
2832
2956
  }
2833
2957
  }
2834
2958
  else {
2835
2959
  request['account_id'] = accountId;
2836
2960
  if (stop) {
2837
- response = await this.privateDeleteOrderStopPending(this.extend(request, params));
2961
+ response = await this.v1PrivateDeleteOrderStopPending(this.extend(request, params));
2838
2962
  }
2839
2963
  else {
2840
- response = await this.privateDeleteOrderPending(this.extend(request, params));
2964
+ response = await this.v1PrivateDeleteOrderPending(this.extend(request, params));
2841
2965
  }
2842
2966
  }
2843
2967
  //
@@ -2881,14 +3005,14 @@ export default class coinex extends Exchange {
2881
3005
  let response = undefined;
2882
3006
  if (swap) {
2883
3007
  if (stop) {
2884
- response = await this.perpetualPrivateGetOrderStopStatus(this.extend(request, params));
3008
+ response = await this.v1PerpetualPrivateGetOrderStopStatus(this.extend(request, params));
2885
3009
  }
2886
3010
  else {
2887
- response = await this.perpetualPrivateGetOrderStatus(this.extend(request, params));
3011
+ response = await this.v1PerpetualPrivateGetOrderStatus(this.extend(request, params));
2888
3012
  }
2889
3013
  }
2890
3014
  else {
2891
- response = await this.privateGetOrderStatus(this.extend(request, params));
3015
+ response = await this.v1PrivateGetOrderStatus(this.extend(request, params));
2892
3016
  }
2893
3017
  //
2894
3018
  // Spot
@@ -3032,14 +3156,14 @@ export default class coinex extends Exchange {
3032
3156
  }
3033
3157
  request['offset'] = 0;
3034
3158
  if (stop) {
3035
- response = await this.perpetualPrivateGetOrderStopPending(this.extend(request, params));
3159
+ response = await this.v1PerpetualPrivateGetOrderStopPending(this.extend(request, params));
3036
3160
  }
3037
3161
  else {
3038
3162
  if (status === 'finished') {
3039
- response = await this.perpetualPrivateGetOrderFinished(this.extend(request, params));
3163
+ response = await this.v1PerpetualPrivateGetOrderFinished(this.extend(request, params));
3040
3164
  }
3041
3165
  else if (status === 'pending') {
3042
- response = await this.perpetualPrivateGetOrderPending(this.extend(request, params));
3166
+ response = await this.v1PerpetualPrivateGetOrderPending(this.extend(request, params));
3043
3167
  }
3044
3168
  }
3045
3169
  }
@@ -3047,18 +3171,18 @@ export default class coinex extends Exchange {
3047
3171
  request['page'] = 1;
3048
3172
  if (status === 'finished') {
3049
3173
  if (stop) {
3050
- response = await this.privateGetOrderStopFinished(this.extend(request, params));
3174
+ response = await this.v1PrivateGetOrderStopFinished(this.extend(request, params));
3051
3175
  }
3052
3176
  else {
3053
- response = await this.privateGetOrderFinished(this.extend(request, params));
3177
+ response = await this.v1PrivateGetOrderFinished(this.extend(request, params));
3054
3178
  }
3055
3179
  }
3056
3180
  else if (status === 'pending') {
3057
3181
  if (stop) {
3058
- response = await this.privateGetOrderStopPending(this.extend(request, params));
3182
+ response = await this.v1PrivateGetOrderStopPending(this.extend(request, params));
3059
3183
  }
3060
3184
  else {
3061
- response = await this.privateGetOrderPending(this.extend(request, params));
3185
+ response = await this.v1PrivateGetOrderPending(this.extend(request, params));
3062
3186
  }
3063
3187
  }
3064
3188
  }
@@ -3270,7 +3394,7 @@ export default class coinex extends Exchange {
3270
3394
  params = this.omit(params, 'network');
3271
3395
  request['smart_contract_name'] = network;
3272
3396
  }
3273
- const response = await this.privatePutBalanceDepositAddressCoinType(this.extend(request, params));
3397
+ const response = await this.v1PrivatePutBalanceDepositAddressCoinType(this.extend(request, params));
3274
3398
  //
3275
3399
  // {
3276
3400
  // "code": 0,
@@ -3314,7 +3438,7 @@ export default class coinex extends Exchange {
3314
3438
  if (network !== undefined) {
3315
3439
  request['smart_contract_name'] = network;
3316
3440
  }
3317
- const response = await this.privateGetBalanceDepositAddressCoinType(this.extend(request, params));
3441
+ const response = await this.v1PrivateGetBalanceDepositAddressCoinType(this.extend(request, params));
3318
3442
  //
3319
3443
  // {
3320
3444
  // "code": 0,
@@ -3430,11 +3554,11 @@ export default class coinex extends Exchange {
3430
3554
  request['start_time'] = since;
3431
3555
  }
3432
3556
  request['side'] = 0;
3433
- response = await this.perpetualPrivateGetMarketUserDeals(this.extend(request, params));
3557
+ response = await this.v1PerpetualPrivateGetMarketUserDeals(this.extend(request, params));
3434
3558
  }
3435
3559
  else {
3436
3560
  request['page'] = 1;
3437
- response = await this.privateGetOrderUserDeals(this.extend(request, params));
3561
+ response = await this.v1PrivateGetOrderUserDeals(this.extend(request, params));
3438
3562
  }
3439
3563
  //
3440
3564
  // Spot and Margin
@@ -3528,8 +3652,8 @@ export default class coinex extends Exchange {
3528
3652
  */
3529
3653
  await this.loadMarkets();
3530
3654
  let defaultMethod = undefined;
3531
- [defaultMethod, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method', 'perpetualPrivateGetPositionPending');
3532
- const isHistory = (defaultMethod === 'perpetualPrivateGetPositionFinished');
3655
+ [defaultMethod, params] = this.handleOptionAndParams(params, 'fetchPositions', 'method', 'v1PerpetualPrivateGetPositionPending');
3656
+ const isHistory = (defaultMethod === 'v1PerpetualPrivateGetPositionFinished');
3533
3657
  symbols = this.marketSymbols(symbols);
3534
3658
  const request = {};
3535
3659
  let market = undefined;
@@ -3558,11 +3682,11 @@ export default class coinex extends Exchange {
3558
3682
  request['side'] = this.safeInteger(params, 'side', 0); // 0: All, 1: Sell, 2: Buy
3559
3683
  }
3560
3684
  let response = undefined;
3561
- if (defaultMethod === 'perpetualPrivateGetPositionPending') {
3562
- response = await this.perpetualPrivateGetPositionPending(this.extend(request, params));
3685
+ if (defaultMethod === 'v1PerpetualPrivateGetPositionPending') {
3686
+ response = await this.v1PerpetualPrivateGetPositionPending(this.extend(request, params));
3563
3687
  }
3564
3688
  else {
3565
- response = await this.perpetualPrivateGetPositionFinished(this.extend(request, params));
3689
+ response = await this.v1PerpetualPrivateGetPositionFinished(this.extend(request, params));
3566
3690
  }
3567
3691
  //
3568
3692
  // {
@@ -3645,7 +3769,7 @@ export default class coinex extends Exchange {
3645
3769
  const request = {
3646
3770
  'market': market['id'],
3647
3771
  };
3648
- const response = await this.perpetualPrivateGetPositionPending(this.extend(request, params));
3772
+ const response = await this.v1PerpetualPrivateGetPositionPending(this.extend(request, params));
3649
3773
  //
3650
3774
  // {
3651
3775
  // "code": 0,
@@ -3859,7 +3983,7 @@ export default class coinex extends Exchange {
3859
3983
  'leverage': leverage.toString(),
3860
3984
  'position_type': positionType, // 1: isolated, 2: cross
3861
3985
  };
3862
- return await this.perpetualPrivatePostMarketAdjustLeverage(this.extend(request, params));
3986
+ return await this.v1PerpetualPrivatePostMarketAdjustLeverage(this.extend(request, params));
3863
3987
  }
3864
3988
  async setLeverage(leverage, symbol = undefined, params = {}) {
3865
3989
  /**
@@ -3900,7 +4024,7 @@ export default class coinex extends Exchange {
3900
4024
  'leverage': leverage.toString(),
3901
4025
  'position_type': positionType, // 1: isolated, 2: cross
3902
4026
  };
3903
- return await this.perpetualPrivatePostMarketAdjustLeverage(this.extend(request, params));
4027
+ return await this.v1PerpetualPrivatePostMarketAdjustLeverage(this.extend(request, params));
3904
4028
  }
3905
4029
  async fetchLeverageTiers(symbols = undefined, params = {}) {
3906
4030
  /**
@@ -3913,7 +4037,7 @@ export default class coinex extends Exchange {
3913
4037
  * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
3914
4038
  */
3915
4039
  await this.loadMarkets();
3916
- const response = await this.perpetualPublicGetMarketLimitConfig(params);
4040
+ const response = await this.v1PerpetualPublicGetMarketLimitConfig(params);
3917
4041
  //
3918
4042
  // {
3919
4043
  // "code": 0,
@@ -3991,7 +4115,7 @@ export default class coinex extends Exchange {
3991
4115
  'amount': this.amountToPrecision(symbol, amount),
3992
4116
  'type': addOrReduce,
3993
4117
  };
3994
- const response = await this.perpetualPrivatePostPositionAdjustMargin(this.extend(request, params));
4118
+ const response = await this.v1PerpetualPrivatePostPositionAdjustMargin(this.extend(request, params));
3995
4119
  //
3996
4120
  // {
3997
4121
  // "code": 0,
@@ -4121,7 +4245,7 @@ export default class coinex extends Exchange {
4121
4245
  if (since !== undefined) {
4122
4246
  request['start_time'] = since;
4123
4247
  }
4124
- const response = await this.perpetualPrivateGetPositionFunding(this.extend(request, params));
4248
+ const response = await this.v1PerpetualPrivateGetPositionFunding(this.extend(request, params));
4125
4249
  //
4126
4250
  // {
4127
4251
  // "code": 0,
@@ -4187,7 +4311,7 @@ export default class coinex extends Exchange {
4187
4311
  const request = {
4188
4312
  'market': market['id'],
4189
4313
  };
4190
- const response = await this.perpetualPublicGetMarketTicker(this.extend(request, params));
4314
+ const response = await this.v1PerpetualPublicGetMarketTicker(this.extend(request, params));
4191
4315
  //
4192
4316
  // {
4193
4317
  // "code": 0,
@@ -4298,7 +4422,7 @@ export default class coinex extends Exchange {
4298
4422
  throw new BadSymbol(this.id + ' fetchFundingRates() supports swap contracts only');
4299
4423
  }
4300
4424
  }
4301
- const response = await this.perpetualPublicGetMarketTickerAll(params);
4425
+ const response = await this.v1PerpetualPublicGetMarketTickerAll(params);
4302
4426
  //
4303
4427
  // {
4304
4428
  // "code": 0,
@@ -4380,7 +4504,7 @@ export default class coinex extends Exchange {
4380
4504
  if (networkCode !== undefined) {
4381
4505
  request['smart_contract_name'] = this.networkCodeToId(networkCode);
4382
4506
  }
4383
- const response = await this.privatePostBalanceCoinWithdraw(this.extend(request, params));
4507
+ const response = await this.v1PrivatePostBalanceCoinWithdraw(this.extend(request, params));
4384
4508
  //
4385
4509
  // {
4386
4510
  // "code": 0,
@@ -4452,7 +4576,7 @@ export default class coinex extends Exchange {
4452
4576
  request['start_time'] = since;
4453
4577
  }
4454
4578
  [request, params] = this.handleUntilOption('end_time', request, params);
4455
- const response = await this.perpetualPublicGetMarketFundingHistory(this.extend(request, params));
4579
+ const response = await this.v1PerpetualPublicGetMarketFundingHistory(this.extend(request, params));
4456
4580
  //
4457
4581
  // {
4458
4582
  // "code": 0,
@@ -4629,11 +4753,11 @@ export default class coinex extends Exchange {
4629
4753
  let response = undefined;
4630
4754
  if ((fromAccount === 'spot') && (toAccount === 'swap')) {
4631
4755
  request['transfer_side'] = 'in'; // 'in' spot to swap, 'out' swap to spot
4632
- response = await this.privatePostContractBalanceTransfer(this.extend(request, params));
4756
+ response = await this.v1PrivatePostContractBalanceTransfer(this.extend(request, params));
4633
4757
  }
4634
4758
  else if ((fromAccount === 'swap') && (toAccount === 'spot')) {
4635
4759
  request['transfer_side'] = 'out'; // 'in' spot to swap, 'out' swap to spot
4636
- response = await this.privatePostContractBalanceTransfer(this.extend(request, params));
4760
+ response = await this.v1PrivatePostContractBalanceTransfer(this.extend(request, params));
4637
4761
  }
4638
4762
  else {
4639
4763
  const accountsById = this.safeValue(this.options, 'accountsById', {});
@@ -4643,7 +4767,7 @@ export default class coinex extends Exchange {
4643
4767
  // spot is 0, use fetchBalance() to find the margin account id
4644
4768
  request['from_account'] = parseInt(fromId);
4645
4769
  request['to_account'] = parseInt(toId);
4646
- response = await this.privatePostMarginTransfer(this.extend(request, params));
4770
+ response = await this.v1PrivatePostMarginTransfer(this.extend(request, params));
4647
4771
  }
4648
4772
  //
4649
4773
  // {"code": 0, "data": null, "message": "Success"}
@@ -4766,10 +4890,10 @@ export default class coinex extends Exchange {
4766
4890
  [marginMode, params] = this.handleMarginModeAndParams('fetchTransfers', params);
4767
4891
  let response = undefined;
4768
4892
  if (marginMode !== undefined) {
4769
- response = await this.privateGetMarginTransferHistory(this.extend(request, params));
4893
+ response = await this.v1PrivateGetMarginTransferHistory(this.extend(request, params));
4770
4894
  }
4771
4895
  else {
4772
- response = await this.privateGetContractTransferHistory(this.extend(request, params));
4896
+ response = await this.v1PrivateGetContractTransferHistory(this.extend(request, params));
4773
4897
  }
4774
4898
  //
4775
4899
  // Swap
@@ -4841,7 +4965,7 @@ export default class coinex extends Exchange {
4841
4965
  if (limit !== undefined) {
4842
4966
  request['Limit'] = limit;
4843
4967
  }
4844
- const response = await this.privateGetBalanceCoinWithdraw(this.extend(request, params));
4968
+ const response = await this.v1PrivateGetBalanceCoinWithdraw(this.extend(request, params));
4845
4969
  //
4846
4970
  // {
4847
4971
  // "code": 0,
@@ -4908,7 +5032,7 @@ export default class coinex extends Exchange {
4908
5032
  if (limit !== undefined) {
4909
5033
  request['Limit'] = limit;
4910
5034
  }
4911
- const response = await this.privateGetBalanceCoinDeposit(this.extend(request, params));
5035
+ const response = await this.v1PrivateGetBalanceCoinDeposit(this.extend(request, params));
4912
5036
  //
4913
5037
  // {
4914
5038
  // "code": 0,
@@ -5001,7 +5125,7 @@ export default class coinex extends Exchange {
5001
5125
  const request = {
5002
5126
  'market': market['id'],
5003
5127
  };
5004
- const response = await this.privateGetMarginConfig(this.extend(request, params));
5128
+ const response = await this.v1PrivateGetMarginConfig(this.extend(request, params));
5005
5129
  //
5006
5130
  // {
5007
5131
  // "code": 0,
@@ -5035,7 +5159,7 @@ export default class coinex extends Exchange {
5035
5159
  * @returns {object} a list of [isolated borrow rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#isolated-borrow-rate-structure}
5036
5160
  */
5037
5161
  await this.loadMarkets();
5038
- const response = await this.privateGetMarginConfig(params);
5162
+ const response = await this.v1PrivateGetMarginConfig(params);
5039
5163
  //
5040
5164
  // {
5041
5165
  // "code": 0,
@@ -5076,7 +5200,7 @@ export default class coinex extends Exchange {
5076
5200
  if (limit !== undefined) {
5077
5201
  request['limit'] = limit;
5078
5202
  }
5079
- const response = await this.privateGetMarginLoanHistory(this.extend(request, params));
5203
+ const response = await this.v1PrivateGetMarginLoanHistory(this.extend(request, params));
5080
5204
  //
5081
5205
  // {
5082
5206
  // "code": 0,
@@ -5172,7 +5296,7 @@ export default class coinex extends Exchange {
5172
5296
  'coin_type': currency['id'],
5173
5297
  'amount': this.currencyToPrecision(code, amount),
5174
5298
  };
5175
- const response = await this.privatePostMarginLoan(this.extend(request, params));
5299
+ const response = await this.v1PrivatePostMarginLoan(this.extend(request, params));
5176
5300
  //
5177
5301
  // {
5178
5302
  // "code": 0,
@@ -5210,7 +5334,7 @@ export default class coinex extends Exchange {
5210
5334
  'coin_type': currency['id'],
5211
5335
  'amount': this.currencyToPrecision(code, amount),
5212
5336
  };
5213
- const response = await this.privatePostMarginFlat(this.extend(request, params));
5337
+ const response = await this.v1PrivatePostMarginFlat(this.extend(request, params));
5214
5338
  //
5215
5339
  // {
5216
5340
  // "code": 0,
@@ -5268,7 +5392,7 @@ export default class coinex extends Exchange {
5268
5392
  request['coin_type'] = this.safeValue(codes, 0);
5269
5393
  }
5270
5394
  }
5271
- const response = await this.publicGetCommonAssetConfig(this.extend(request, params));
5395
+ const response = await this.v1PublicGetCommonAssetConfig(this.extend(request, params));
5272
5396
  //
5273
5397
  // {
5274
5398
  // "code": 0,
@@ -5368,7 +5492,7 @@ export default class coinex extends Exchange {
5368
5492
  if (marketType !== 'spot') {
5369
5493
  throw new NotSupported(this.id + ' fetchLeverages() supports spot margin markets only');
5370
5494
  }
5371
- const response = await this.privateGetMarginConfig(params);
5495
+ const response = await this.v1PrivateGetMarginConfig(params);
5372
5496
  //
5373
5497
  // {
5374
5498
  // "code": 0,
@@ -5427,9 +5551,11 @@ export default class coinex extends Exchange {
5427
5551
  nonce() {
5428
5552
  return this.milliseconds();
5429
5553
  }
5430
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
5554
+ sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
5431
5555
  path = this.implodeParams(path, params);
5432
- let url = this.urls['api'][api] + '/' + this.version + '/' + path;
5556
+ const version = api[0];
5557
+ const requestUrl = api[1];
5558
+ let url = this.urls['api'][requestUrl] + '/' + version + '/' + path;
5433
5559
  let query = this.omit(params, this.extractParams(path));
5434
5560
  const nonce = this.nonce().toString();
5435
5561
  if (method === 'POST') {
@@ -5458,7 +5584,7 @@ export default class coinex extends Exchange {
5458
5584
  }
5459
5585
  }
5460
5586
  }
5461
- if (api === 'perpetualPrivate') {
5587
+ if (requestUrl === 'perpetualPrivate') {
5462
5588
  this.checkRequiredCredentials();
5463
5589
  query = this.extend({
5464
5590
  'access_id': this.apiKey,
@@ -5479,29 +5605,49 @@ export default class coinex extends Exchange {
5479
5605
  body = urlencoded;
5480
5606
  }
5481
5607
  }
5482
- else if (api === 'public' || api === 'perpetualPublic') {
5608
+ else if (requestUrl === 'public' || requestUrl === 'perpetualPublic') {
5483
5609
  if (Object.keys(query).length) {
5484
5610
  url += '?' + this.urlencode(query);
5485
5611
  }
5486
5612
  }
5487
5613
  else {
5488
- this.checkRequiredCredentials();
5489
- query = this.extend({
5490
- 'access_id': this.apiKey,
5491
- 'tonce': nonce,
5492
- }, query);
5493
- query = this.keysort(query);
5494
- const urlencoded = this.rawencode(query);
5495
- const signature = this.hash(this.encode(urlencoded + '&secret_key=' + this.secret), md5);
5496
- headers = {
5497
- 'Authorization': signature.toUpperCase(),
5498
- 'Content-Type': 'application/json',
5499
- };
5500
- if ((method === 'GET') || (method === 'DELETE') || (method === 'PUT')) {
5501
- url += '?' + urlencoded;
5614
+ if (version === 'v1') {
5615
+ this.checkRequiredCredentials();
5616
+ query = this.extend({
5617
+ 'access_id': this.apiKey,
5618
+ 'tonce': nonce,
5619
+ }, query);
5620
+ query = this.keysort(query);
5621
+ const urlencoded = this.rawencode(query);
5622
+ const signature = this.hash(this.encode(urlencoded + '&secret_key=' + this.secret), md5);
5623
+ headers = {
5624
+ 'Authorization': signature.toUpperCase(),
5625
+ 'Content-Type': 'application/json',
5626
+ };
5627
+ if ((method === 'GET') || (method === 'DELETE') || (method === 'PUT')) {
5628
+ url += '?' + urlencoded;
5629
+ }
5630
+ else {
5631
+ body = this.json(query);
5632
+ }
5502
5633
  }
5503
- else {
5504
- body = this.json(query);
5634
+ else if (version === 'v2') {
5635
+ this.checkRequiredCredentials();
5636
+ query = this.keysort(query);
5637
+ const urlencoded = this.rawencode(query);
5638
+ const preparedString = method + '/' + version + '/' + path + '?' + urlencoded + nonce + this.secret;
5639
+ const signature = this.hash(this.encode(preparedString), sha256);
5640
+ headers = {
5641
+ 'X-COINEX-KEY': this.apiKey,
5642
+ 'X-COINEX-SIGN': signature,
5643
+ 'X-COINEX-TIMESTAMP': nonce,
5644
+ };
5645
+ if ((method === 'GET') || (method === 'DELETE') || (method === 'PUT')) {
5646
+ url += '?' + urlencoded;
5647
+ }
5648
+ else {
5649
+ body = this.json(query);
5650
+ }
5505
5651
  }
5506
5652
  }
5507
5653
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };