ccxt 4.4.88 → 4.4.90
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 +61 -19
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +6 -3
- package/dist/cjs/src/base/functions/encode.js +1 -1
- package/dist/cjs/src/base/functions/generic.js +6 -0
- package/dist/cjs/src/base/functions.js +1 -0
- package/dist/cjs/src/binance.js +1 -1
- package/dist/cjs/src/bingx.js +60 -32
- package/dist/cjs/src/bitget.js +493 -154
- package/dist/cjs/src/bitrue.js +72 -66
- package/dist/cjs/src/bitvavo.js +34 -0
- package/dist/cjs/src/btcalpha.js +35 -0
- package/dist/cjs/src/btcbox.js +35 -0
- package/dist/cjs/src/btcmarkets.js +35 -0
- package/dist/cjs/src/btcturk.js +35 -0
- package/dist/cjs/src/bybit.js +9 -3
- package/dist/cjs/src/coinbase.js +1 -4
- package/dist/cjs/src/cryptocom.js +54 -0
- package/dist/cjs/src/delta.js +2 -2
- package/dist/cjs/src/digifinex.js +40 -109
- package/dist/cjs/src/gate.js +12 -5
- package/dist/cjs/src/hashkey.js +15 -28
- package/dist/cjs/src/hollaex.js +28 -24
- package/dist/cjs/src/kraken.js +30 -53
- package/dist/cjs/src/luno.js +92 -0
- package/dist/cjs/src/okx.js +2 -1
- package/dist/cjs/src/phemex.js +16 -8
- package/dist/cjs/src/pro/coinbase.js +2 -0
- package/dist/cjs/src/pro/cryptocom.js +27 -0
- package/dist/cjs/src/pro/kraken.js +3 -11
- package/dist/cjs/src/tradeogre.js +3 -3
- package/dist/cjs/src/xt.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bitget.d.ts +58 -0
- package/js/src/abstract/cryptocom.d.ts +2 -0
- package/js/src/abstract/luno.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +4 -1
- package/js/src/base/Exchange.js +6 -3
- package/js/src/base/functions/encode.d.ts +1 -1
- package/js/src/base/functions/encode.js +1 -1
- package/js/src/base/functions/generic.d.ts +2 -1
- package/js/src/base/functions/generic.js +6 -1
- package/js/src/binance.js +1 -1
- package/js/src/bingx.d.ts +9 -5
- package/js/src/bingx.js +60 -32
- package/js/src/bitget.d.ts +4 -1
- package/js/src/bitget.js +493 -154
- package/js/src/bitrue.js +72 -66
- package/js/src/bitvavo.js +34 -0
- package/js/src/btcalpha.js +35 -0
- package/js/src/btcbox.js +35 -0
- package/js/src/btcmarkets.js +35 -0
- package/js/src/btcturk.js +35 -0
- package/js/src/bybit.js +9 -3
- package/js/src/coinbase.d.ts +1 -1
- package/js/src/coinbase.js +1 -4
- package/js/src/cryptocom.d.ts +17 -0
- package/js/src/cryptocom.js +54 -0
- package/js/src/delta.js +2 -2
- package/js/src/digifinex.js +40 -109
- package/js/src/gate.d.ts +1 -1
- package/js/src/gate.js +12 -5
- package/js/src/hashkey.d.ts +0 -1
- package/js/src/hashkey.js +15 -28
- package/js/src/hollaex.d.ts +1 -2
- package/js/src/hollaex.js +29 -25
- package/js/src/kraken.d.ts +0 -1
- package/js/src/kraken.js +30 -53
- package/js/src/luno.d.ts +9 -1
- package/js/src/luno.js +92 -0
- package/js/src/okx.js +2 -1
- package/js/src/phemex.d.ts +1 -0
- package/js/src/phemex.js +16 -8
- package/js/src/pro/coinbase.js +2 -0
- package/js/src/pro/cryptocom.d.ts +16 -0
- package/js/src/pro/cryptocom.js +27 -0
- package/js/src/pro/kraken.js +3 -11
- package/js/src/tradeogre.js +3 -3
- package/js/src/xt.js +1 -1
- package/package.json +4 -7
- package/examples/README.md +0 -316
- package/examples/js/README.md +0 -15
- package/examples/js/cli.js +0 -559
package/js/src/base/Exchange.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// ----------------------------------------------------------------------------
|
|
8
8
|
/* eslint-disable */
|
|
9
9
|
import * as functions from './functions.js';
|
|
10
|
-
const { isNode, selfIsDefined, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sortBy2, safeFloat2, groupBy, aggregate, uuid, unCamelCase, precisionFromString, Throttler, capitalize, now, decimalToPrecision, safeValue, safeValue2, safeString, safeString2, seconds, milliseconds, binaryToBase16, numberToBE, base16ToBinary, iso8601, omit, isJsonEncodedObject, safeInteger, sum, omitZero, implodeParams, extractParams, json, merge, binaryConcat, hash, ecdsa, arrayConcat, encode, urlencode, hmac, numberToString, roundTimeframe, parseTimeframe, safeInteger2, safeStringLower, parse8601, yyyymmdd, safeStringUpper, safeTimestamp, binaryConcatArray, uuidv1, numberToLE, ymdhms, stringToBase64, decode, uuid22, safeIntegerProduct2, safeIntegerProduct, safeStringLower2, yymmdd, base58ToBinary, binaryToBase58, safeTimestamp2, rawencode, keysort, inArray, isEmpty, ordered, filterBy, uuid16, safeFloat, base64ToBinary, safeStringUpper2, urlencodeWithArrayRepeat, microseconds, binaryToBase64, strip, toArray, safeFloatN, safeIntegerN, safeIntegerProductN, safeTimestampN, safeValueN, safeStringN, safeStringLowerN, safeStringUpperN, urlencodeNested, urlencodeBase64, parseDate, ymd, base64ToString, crc32, packb, TRUNCATE, ROUND, DECIMAL_PLACES, NO_PADDING, TICK_SIZE, SIGNIFICANT_DIGITS, sleep } = functions;
|
|
10
|
+
const { isNode, selfIsDefined, deepExtend, extend, clone, flatten, unique, indexBy, sortBy, sortBy2, safeFloat2, groupBy, aggregate, uuid, unCamelCase, precisionFromString, Throttler, capitalize, now, decimalToPrecision, safeValue, safeValue2, safeString, safeString2, seconds, milliseconds, binaryToBase16, numberToBE, base16ToBinary, iso8601, omit, isJsonEncodedObject, safeInteger, sum, omitZero, implodeParams, extractParams, json, merge, binaryConcat, hash, ecdsa, arrayConcat, encode, urlencode, hmac, numberToString, roundTimeframe, parseTimeframe, safeInteger2, safeStringLower, parse8601, yyyymmdd, safeStringUpper, safeTimestamp, binaryConcatArray, uuidv1, numberToLE, ymdhms, stringToBase64, decode, uuid22, safeIntegerProduct2, safeIntegerProduct, safeStringLower2, yymmdd, base58ToBinary, binaryToBase58, safeTimestamp2, rawencode, keysort, sort, inArray, isEmpty, ordered, filterBy, uuid16, safeFloat, base64ToBinary, safeStringUpper2, urlencodeWithArrayRepeat, microseconds, binaryToBase64, strip, toArray, safeFloatN, safeIntegerN, safeIntegerProductN, safeTimestampN, safeValueN, safeStringN, safeStringLowerN, safeStringUpperN, urlencodeNested, urlencodeBase64, parseDate, ymd, base64ToString, crc32, packb, TRUNCATE, ROUND, DECIMAL_PLACES, NO_PADDING, TICK_SIZE, SIGNIFICANT_DIGITS, sleep } = functions;
|
|
11
11
|
import { keys as keysFunc, values as valuesFunc, vwap as vwapFunc } from './functions.js';
|
|
12
12
|
// import exceptions from "./errors.js"
|
|
13
13
|
import { // eslint-disable-line object-curly-newline
|
|
@@ -131,6 +131,7 @@ export default class Exchange {
|
|
|
131
131
|
this.streaming = {};
|
|
132
132
|
this.alias = false;
|
|
133
133
|
this.deepExtend = deepExtend;
|
|
134
|
+
this.deepExtendSafe = deepExtend;
|
|
134
135
|
this.isNode = isNode;
|
|
135
136
|
this.keys = keysFunc;
|
|
136
137
|
this.values = valuesFunc;
|
|
@@ -139,6 +140,7 @@ export default class Exchange {
|
|
|
139
140
|
this.flatten = flatten;
|
|
140
141
|
this.unique = unique;
|
|
141
142
|
this.indexBy = indexBy;
|
|
143
|
+
this.indexBySafe = indexBy;
|
|
142
144
|
this.roundTimeframe = roundTimeframe;
|
|
143
145
|
this.sortBy = sortBy;
|
|
144
146
|
this.sortBy2 = sortBy2;
|
|
@@ -202,6 +204,7 @@ export default class Exchange {
|
|
|
202
204
|
this.safeTimestamp2 = safeTimestamp2;
|
|
203
205
|
this.rawencode = rawencode;
|
|
204
206
|
this.keysort = keysort;
|
|
207
|
+
this.sort = sort;
|
|
205
208
|
this.inArray = inArray;
|
|
206
209
|
this.safeStringLower2 = safeStringLower2;
|
|
207
210
|
this.safeStringUpper2 = safeStringUpper2;
|
|
@@ -2771,7 +2774,7 @@ export default class Exchange {
|
|
|
2771
2774
|
}
|
|
2772
2775
|
setMarkets(markets, currencies = undefined) {
|
|
2773
2776
|
const values = [];
|
|
2774
|
-
this.markets_by_id =
|
|
2777
|
+
this.markets_by_id = this.createSafeDictionary();
|
|
2775
2778
|
// handle marketId conflicts
|
|
2776
2779
|
// we insert spot markets first
|
|
2777
2780
|
const marketValues = this.sortBy(this.toArray(markets), 'spot', true, true);
|
|
@@ -2861,7 +2864,7 @@ export default class Exchange {
|
|
|
2861
2864
|
const sortedCurrencies = this.sortBy(resultingCurrencies, 'code');
|
|
2862
2865
|
this.currencies = this.deepExtend(this.currencies, this.indexBy(sortedCurrencies, 'code'));
|
|
2863
2866
|
}
|
|
2864
|
-
this.currencies_by_id = this.
|
|
2867
|
+
this.currencies_by_id = this.indexBySafe(this.currencies, 'id');
|
|
2865
2868
|
const currenciesSortedByCode = this.keysort(this.currencies);
|
|
2866
2869
|
this.codes = Object.keys(currenciesSortedByCode);
|
|
2867
2870
|
return this.markets;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { concatBytes } from '../../static_dependencies/noble-curves/abstract/utils.js';
|
|
2
|
-
declare const json: (data: any, params?: any) => string, isJsonEncodedObject: (object: any) => boolean, binaryToString: (data: Uint8Array) => string, stringToBinary: (str: string) => Uint8Array, stringToBase64: (string: string) => string, base64ToString: (string: string) => string, base64ToBinary: (str: string) => Uint8Array, binaryToBase64: (data: Uint8Array) => string, base16ToBinary: (str: string) => Uint8Array, binaryToBase16: (data: Uint8Array) => string, base58ToBinary: (str: string) => Uint8Array, binaryToBase58: (data: Uint8Array) => string, binaryConcat: typeof concatBytes, binaryConcatArray: (arr: any[]) => Uint8Array, urlencode: (object: object, sort?: boolean) => string, urlencodeNested: (object: object) => string, urlencodeWithArrayRepeat: (object: object) => string, rawencode: (object: object) => string, encode: (str: string) => Uint8Array, decode: (data: Uint8Array) => string, urlencodeBase64: (payload: string | Uint8Array) => string, numberToLE: (n: number, padding: number) => Uint8Array, numberToBE: (n: number, padding: number) => Uint8Array;
|
|
2
|
+
declare const json: (data: any, params?: any) => string, isJsonEncodedObject: (object: any) => boolean, binaryToString: (data: Uint8Array) => string, stringToBinary: (str: string) => Uint8Array, stringToBase64: (string: string) => string, base64ToString: (string: string) => string, base64ToBinary: (str: string) => Uint8Array, binaryToBase64: (data: Uint8Array) => string, base16ToBinary: (str: string) => Uint8Array, binaryToBase16: (data: Uint8Array) => string, base58ToBinary: (str: string) => Uint8Array, binaryToBase58: (data: Uint8Array) => string, binaryConcat: typeof concatBytes, binaryConcatArray: (arr: any[]) => Uint8Array, urlencode: (object: object, sort?: boolean) => string, urlencodeNested: (object: object) => string, urlencodeWithArrayRepeat: (object: object) => string, rawencode: (object: object, sort?: boolean) => string, encode: (str: string) => Uint8Array, decode: (data: Uint8Array) => string, urlencodeBase64: (payload: string | Uint8Array) => string, numberToLE: (n: number, padding: number) => Uint8Array, numberToBE: (n: number, padding: number) => Uint8Array;
|
|
3
3
|
declare function packb(req: any): Uint8Array;
|
|
4
4
|
export { json, isJsonEncodedObject, binaryToString, stringToBinary, stringToBase64, base64ToBinary, base64ToString, binaryToBase64, base16ToBinary, binaryToBase16, binaryConcat, binaryConcatArray, urlencode, urlencodeWithArrayRepeat, rawencode, encode, decode, urlencodeBase64, numberToLE, numberToBE, base58ToBinary, binaryToBase58, urlencodeNested, packb };
|
|
@@ -14,7 +14,7 @@ import qs from '../../static_dependencies/qs/index.cjs';
|
|
|
14
14
|
const json = (data, params = undefined) => JSON.stringify(data), isJsonEncodedObject = (object) => ((typeof object === 'string') &&
|
|
15
15
|
(object.length >= 2) &&
|
|
16
16
|
((object[0] === '{') || (object[0] === '['))), binaryToString = utf8.encode, stringToBinary = utf8.decode, stringToBase64 = (string) => base64.encode(utf8.decode(string)), base64ToString = (string) => utf8.encode(base64.decode(string)), base64ToBinary = base64.decode, binaryToBase64 = base64.encode, base16ToBinary = base16.decode, binaryToBase16 = base16.encode, base58ToBinary = base58.decode, binaryToBase58 = base58.encode, binaryConcat = concatBytes, binaryConcatArray = (arr) => concatBytes(...arr), urlencode = (object, sort = false) => qs.stringify(object), urlencodeNested = (object) => qs.stringify(object) // implemented only in python
|
|
17
|
-
, urlencodeWithArrayRepeat = (object) => qs.stringify(object, { arrayFormat: 'repeat' }), rawencode = (object) => qs.stringify(object, { encode: false }), encode = utf8.decode // lol
|
|
17
|
+
, urlencodeWithArrayRepeat = (object) => qs.stringify(object, { arrayFormat: 'repeat' }), rawencode = (object, sort = false) => qs.stringify(object, { encode: false }), encode = utf8.decode // lol
|
|
18
18
|
, decode = utf8.encode
|
|
19
19
|
// Url-safe-base64 without equals signs, with + replaced by - and slashes replaced by underscores
|
|
20
20
|
, urlencodeBase64 = (payload) => {
|
|
@@ -14,6 +14,7 @@ declare const inArray: (needle: any, haystack: any[]) => boolean;
|
|
|
14
14
|
declare const toArray: (object: Dictionary<any> | any[]) => any[];
|
|
15
15
|
declare const isEmpty: (object: any[] | Dictionary<any>) => boolean;
|
|
16
16
|
declare const keysort: (x: Dictionary<any>, out?: Dictionary<any>) => Dictionary<any>;
|
|
17
|
+
declare const sort: (array: string[] | any) => any;
|
|
17
18
|
declare const groupBy: (x: Dictionary<any>, k: string, out?: Dictionary<any>) => Dictionary<any>;
|
|
18
19
|
declare const indexBy: (x: Dictionary<any>, k: IndexType, out?: Dictionary<any>) => Dictionary<any>;
|
|
19
20
|
declare const filterBy: (x: Dictionary<any>, k: string, value?: any, out?: Dictionary<any>[]) => Dictionary<any>[];
|
|
@@ -25,4 +26,4 @@ declare const omit: (x: Dictionary<any>, ...args: any) => any;
|
|
|
25
26
|
declare const sum: (...xs: any[]) => any;
|
|
26
27
|
declare const deepExtend: (...xs: any) => any;
|
|
27
28
|
declare const merge: (target: Dictionary<any>, ...args: any) => Dictionary<any>;
|
|
28
|
-
export { keys, values, extend, clone, index, ordered, unique, arrayConcat, inArray, toArray, isEmpty, keysort, indexBy, groupBy, filterBy, sortBy, sortBy2, flatten, pluck, omit, sum, deepExtend, merge, };
|
|
29
|
+
export { keys, values, extend, clone, index, ordered, unique, arrayConcat, inArray, toArray, isEmpty, sort, keysort, indexBy, groupBy, filterBy, sortBy, sortBy2, flatten, pluck, omit, sum, deepExtend, merge, };
|
|
@@ -31,6 +31,11 @@ const keysort = (x, out = {}) => {
|
|
|
31
31
|
}
|
|
32
32
|
return out;
|
|
33
33
|
};
|
|
34
|
+
const sort = (array) => {
|
|
35
|
+
const newArray = array.slice();
|
|
36
|
+
newArray.sort();
|
|
37
|
+
return newArray;
|
|
38
|
+
};
|
|
34
39
|
/*
|
|
35
40
|
Accepts a map/array of objects and a key name to be used as an index:
|
|
36
41
|
array = [
|
|
@@ -172,7 +177,7 @@ export { keys, values, extend, clone, index, ordered, unique, arrayConcat
|
|
|
172
177
|
// ------------------------------------------------------------------------
|
|
173
178
|
, inArray, toArray, isEmpty
|
|
174
179
|
// ------------------------------------------------------------------------
|
|
175
|
-
, keysort
|
|
180
|
+
, sort, keysort
|
|
176
181
|
// ------------------------------------------------------------------------
|
|
177
182
|
, indexBy
|
|
178
183
|
// ------------------------------------------------------------------------
|
package/js/src/binance.js
CHANGED
|
@@ -10487,7 +10487,7 @@ export default class binance extends Exchange {
|
|
|
10487
10487
|
else {
|
|
10488
10488
|
throw new NotSupported(this.id + ' loadLeverageBrackets() supports linear and inverse contracts only');
|
|
10489
10489
|
}
|
|
10490
|
-
this.options['leverageBrackets'] =
|
|
10490
|
+
this.options['leverageBrackets'] = this.createSafeDictionary();
|
|
10491
10491
|
for (let i = 0; i < response.length; i++) {
|
|
10492
10492
|
const entry = response[i];
|
|
10493
10493
|
const marketId = this.safeString(entry, 'symbol');
|
package/js/src/bingx.d.ts
CHANGED
|
@@ -475,11 +475,11 @@ export default class bingx extends Exchange {
|
|
|
475
475
|
* @method
|
|
476
476
|
* @name bingx#transfer
|
|
477
477
|
* @description transfer currency internally between wallets on the same account
|
|
478
|
-
* @see https://bingx-api.github.io/docs/#/
|
|
478
|
+
* @see https://bingx-api.github.io/docs/#/en-us/common/account-api.html#Asset%20Transfer
|
|
479
479
|
* @param {string} code unified currency code
|
|
480
480
|
* @param {float} amount amount to transfer
|
|
481
|
-
* @param {string} fromAccount account to transfer from
|
|
482
|
-
* @param {string} toAccount account to transfer to
|
|
481
|
+
* @param {string} fromAccount account to transfer from (spot, swap, futures, or funding)
|
|
482
|
+
* @param {string} toAccount account to transfer to (spot, swap, futures, or funding)
|
|
483
483
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
484
484
|
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
485
485
|
*/
|
|
@@ -491,12 +491,16 @@ export default class bingx extends Exchange {
|
|
|
491
491
|
* @see https://bingx-api.github.io/docs/#/spot/account-api.html#Query%20User%20Universal%20Transfer%20History%20(USER_DATA)
|
|
492
492
|
* @param {string} [code] unified currency code of the currency transferred
|
|
493
493
|
* @param {int} [since] the earliest time in ms to fetch transfers for
|
|
494
|
-
* @param {int} [limit] the maximum number of transfers structures to retrieve
|
|
494
|
+
* @param {int} [limit] the maximum number of transfers structures to retrieve (default 10, max 100)
|
|
495
495
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
496
|
+
* @param {string} params.fromAccount (mandatory) transfer from (spot, swap, futures, or funding)
|
|
497
|
+
* @param {string} params.toAccount (mandatory) transfer to (spot, swap, futures, or funding)
|
|
498
|
+
* @param {boolean} [params.paginate] whether to paginate the results (default false)
|
|
496
499
|
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
497
500
|
*/
|
|
498
501
|
fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<TransferEntry[]>;
|
|
499
502
|
parseTransfer(transfer: Dict, currency?: Currency): TransferEntry;
|
|
503
|
+
parseTransferStatus(status: Str): string;
|
|
500
504
|
/**
|
|
501
505
|
* @method
|
|
502
506
|
* @name bingx#fetchDepositAddressesByNetwork
|
|
@@ -639,7 +643,7 @@ export default class bingx extends Exchange {
|
|
|
639
643
|
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
640
644
|
*/
|
|
641
645
|
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
642
|
-
parseParams(params: any):
|
|
646
|
+
parseParams(params: any): any;
|
|
643
647
|
/**
|
|
644
648
|
* @method
|
|
645
649
|
* @name bingx#fetchMyLiquidations
|
package/js/src/bingx.js
CHANGED
|
@@ -500,7 +500,9 @@ export default class bingx extends Exchange {
|
|
|
500
500
|
'100419': PermissionDenied,
|
|
501
501
|
'100437': BadRequest,
|
|
502
502
|
'101204': InsufficientFunds,
|
|
503
|
-
'110425': InvalidOrder,
|
|
503
|
+
'110425': InvalidOrder,
|
|
504
|
+
'Insufficient assets': InsufficientFunds,
|
|
505
|
+
'illegal transferType': BadRequest, // {"transferErrorMsg":"illegal transferType"}
|
|
504
506
|
},
|
|
505
507
|
'broad': {},
|
|
506
508
|
},
|
|
@@ -514,12 +516,14 @@ export default class bingx extends Exchange {
|
|
|
514
516
|
'options': {
|
|
515
517
|
'defaultType': 'spot',
|
|
516
518
|
'accountsByType': {
|
|
517
|
-
'
|
|
519
|
+
'funding': 'FUND',
|
|
520
|
+
'spot': 'SPOT',
|
|
518
521
|
'swap': 'PFUTURES',
|
|
519
522
|
'future': 'SFUTURES',
|
|
520
523
|
},
|
|
521
524
|
'accountsById': {
|
|
522
|
-
'FUND': '
|
|
525
|
+
'FUND': 'funding',
|
|
526
|
+
'SPOT': 'spot',
|
|
523
527
|
'PFUTURES': 'swap',
|
|
524
528
|
'SFUTURES': 'future',
|
|
525
529
|
},
|
|
@@ -1560,7 +1564,7 @@ export default class bingx extends Exchange {
|
|
|
1560
1564
|
// ]
|
|
1561
1565
|
// }
|
|
1562
1566
|
//
|
|
1563
|
-
const data = this.
|
|
1567
|
+
const data = this.safeDict(response, 'data');
|
|
1564
1568
|
return this.parseFundingRate(data, market);
|
|
1565
1569
|
}
|
|
1566
1570
|
/**
|
|
@@ -4858,11 +4862,11 @@ export default class bingx extends Exchange {
|
|
|
4858
4862
|
* @method
|
|
4859
4863
|
* @name bingx#transfer
|
|
4860
4864
|
* @description transfer currency internally between wallets on the same account
|
|
4861
|
-
* @see https://bingx-api.github.io/docs/#/
|
|
4865
|
+
* @see https://bingx-api.github.io/docs/#/en-us/common/account-api.html#Asset%20Transfer
|
|
4862
4866
|
* @param {string} code unified currency code
|
|
4863
4867
|
* @param {float} amount amount to transfer
|
|
4864
|
-
* @param {string} fromAccount account to transfer from
|
|
4865
|
-
* @param {string} toAccount account to transfer to
|
|
4868
|
+
* @param {string} fromAccount account to transfer from (spot, swap, futures, or funding)
|
|
4869
|
+
* @param {string} toAccount account to transfer to (spot, swap, futures, or funding)
|
|
4866
4870
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4867
4871
|
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
4868
4872
|
*/
|
|
@@ -4879,9 +4883,10 @@ export default class bingx extends Exchange {
|
|
|
4879
4883
|
};
|
|
4880
4884
|
const response = await this.spotV3PrivateGetGetAssetTransfer(this.extend(request, params));
|
|
4881
4885
|
//
|
|
4882
|
-
//
|
|
4883
|
-
//
|
|
4884
|
-
//
|
|
4886
|
+
// {
|
|
4887
|
+
// "tranId": 1933130865269936128,
|
|
4888
|
+
// "transferId": "1051450703949464903736"
|
|
4889
|
+
// }
|
|
4885
4890
|
//
|
|
4886
4891
|
return {
|
|
4887
4892
|
'info': response,
|
|
@@ -4902,8 +4907,11 @@ export default class bingx extends Exchange {
|
|
|
4902
4907
|
* @see https://bingx-api.github.io/docs/#/spot/account-api.html#Query%20User%20Universal%20Transfer%20History%20(USER_DATA)
|
|
4903
4908
|
* @param {string} [code] unified currency code of the currency transferred
|
|
4904
4909
|
* @param {int} [since] the earliest time in ms to fetch transfers for
|
|
4905
|
-
* @param {int} [limit] the maximum number of transfers structures to retrieve
|
|
4910
|
+
* @param {int} [limit] the maximum number of transfers structures to retrieve (default 10, max 100)
|
|
4906
4911
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4912
|
+
* @param {string} params.fromAccount (mandatory) transfer from (spot, swap, futures, or funding)
|
|
4913
|
+
* @param {string} params.toAccount (mandatory) transfer to (spot, swap, futures, or funding)
|
|
4914
|
+
* @param {boolean} [params.paginate] whether to paginate the results (default false)
|
|
4907
4915
|
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
|
|
4908
4916
|
*/
|
|
4909
4917
|
async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -4920,7 +4928,14 @@ export default class bingx extends Exchange {
|
|
|
4920
4928
|
if (fromId === undefined || toId === undefined) {
|
|
4921
4929
|
throw new ExchangeError(this.id + ' fromAccount & toAccount parameter are required');
|
|
4922
4930
|
}
|
|
4923
|
-
|
|
4931
|
+
params = this.omit(params, ['fromAccount', 'toAccount']);
|
|
4932
|
+
const maxLimit = 100;
|
|
4933
|
+
let paginate = false;
|
|
4934
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchTransfers', 'paginate', false);
|
|
4935
|
+
if (paginate) {
|
|
4936
|
+
return await this.fetchPaginatedCallDynamic('fetchTransfers', undefined, since, limit, params, maxLimit);
|
|
4937
|
+
}
|
|
4938
|
+
let request = {
|
|
4924
4939
|
'type': fromId + '_' + toId,
|
|
4925
4940
|
};
|
|
4926
4941
|
if (since !== undefined) {
|
|
@@ -4929,18 +4944,19 @@ export default class bingx extends Exchange {
|
|
|
4929
4944
|
if (limit !== undefined) {
|
|
4930
4945
|
request['size'] = limit;
|
|
4931
4946
|
}
|
|
4947
|
+
[request, params] = this.handleUntilOption('endTime', request, params);
|
|
4932
4948
|
const response = await this.spotV3PrivateGetAssetTransfer(this.extend(request, params));
|
|
4933
4949
|
//
|
|
4934
4950
|
// {
|
|
4935
4951
|
// "total": 3,
|
|
4936
4952
|
// "rows": [
|
|
4937
4953
|
// {
|
|
4938
|
-
// "asset":"USDT",
|
|
4939
|
-
// "amount":"
|
|
4940
|
-
// "type":"FUND_SFUTURES",
|
|
4941
|
-
// "status":"CONFIRMED",
|
|
4942
|
-
// "tranId":1067594500957016069,
|
|
4943
|
-
// "timestamp":1658388859000
|
|
4954
|
+
// "asset": "USDT",
|
|
4955
|
+
// "amount": "100.00000000000000000000",
|
|
4956
|
+
// "type": "FUND_SFUTURES",
|
|
4957
|
+
// "status": "CONFIRMED",
|
|
4958
|
+
// "tranId": 1067594500957016069,
|
|
4959
|
+
// "timestamp": 1658388859000
|
|
4944
4960
|
// },
|
|
4945
4961
|
// ]
|
|
4946
4962
|
// }
|
|
@@ -4957,7 +4973,7 @@ export default class bingx extends Exchange {
|
|
|
4957
4973
|
const typeId = this.safeString(transfer, 'type');
|
|
4958
4974
|
const typeIdSplit = typeId.split('_');
|
|
4959
4975
|
const fromId = this.safeString(typeIdSplit, 0);
|
|
4960
|
-
const toId = this.safeString(
|
|
4976
|
+
const toId = this.safeString(typeIdSplit, 1);
|
|
4961
4977
|
const fromAccount = this.safeString(accountsById, fromId, fromId);
|
|
4962
4978
|
const toAccount = this.safeString(accountsById, toId, toId);
|
|
4963
4979
|
return {
|
|
@@ -4969,9 +4985,15 @@ export default class bingx extends Exchange {
|
|
|
4969
4985
|
'amount': this.safeNumber(transfer, 'amount'),
|
|
4970
4986
|
'fromAccount': fromAccount,
|
|
4971
4987
|
'toAccount': toAccount,
|
|
4972
|
-
'status': status,
|
|
4988
|
+
'status': this.parseTransferStatus(status),
|
|
4973
4989
|
};
|
|
4974
4990
|
}
|
|
4991
|
+
parseTransferStatus(status) {
|
|
4992
|
+
const statuses = {
|
|
4993
|
+
'CONFIRMED': 'ok',
|
|
4994
|
+
};
|
|
4995
|
+
return this.safeString(statuses, status, status);
|
|
4996
|
+
}
|
|
4975
4997
|
/**
|
|
4976
4998
|
* @method
|
|
4977
4999
|
* @name bingx#fetchDepositAddressesByNetwork
|
|
@@ -5817,11 +5839,12 @@ export default class bingx extends Exchange {
|
|
|
5817
5839
|
return this.parseTransaction(data);
|
|
5818
5840
|
}
|
|
5819
5841
|
parseParams(params) {
|
|
5820
|
-
const sortedParams = this.keysort(params);
|
|
5821
|
-
const
|
|
5842
|
+
// const sortedParams = this.keysort (params);
|
|
5843
|
+
const rawKeys = Object.keys(params);
|
|
5844
|
+
const keys = this.sort(rawKeys);
|
|
5822
5845
|
for (let i = 0; i < keys.length; i++) {
|
|
5823
5846
|
const key = keys[i];
|
|
5824
|
-
const value =
|
|
5847
|
+
const value = params[key];
|
|
5825
5848
|
if (Array.isArray(value)) {
|
|
5826
5849
|
let arrStr = '[';
|
|
5827
5850
|
for (let j = 0; j < value.length; j++) {
|
|
@@ -5832,10 +5855,10 @@ export default class bingx extends Exchange {
|
|
|
5832
5855
|
arrStr += arrayElement.toString();
|
|
5833
5856
|
}
|
|
5834
5857
|
arrStr += ']';
|
|
5835
|
-
|
|
5858
|
+
params[key] = arrStr;
|
|
5836
5859
|
}
|
|
5837
5860
|
}
|
|
5838
|
-
return
|
|
5861
|
+
return params;
|
|
5839
5862
|
}
|
|
5840
5863
|
/**
|
|
5841
5864
|
* @method
|
|
@@ -6458,13 +6481,14 @@ export default class bingx extends Exchange {
|
|
|
6458
6481
|
};
|
|
6459
6482
|
}
|
|
6460
6483
|
customEncode(params) {
|
|
6461
|
-
const sortedParams = this.keysort(params);
|
|
6462
|
-
const
|
|
6484
|
+
// const sortedParams = this.keysort (params);
|
|
6485
|
+
const rawKeys = Object.keys(params);
|
|
6486
|
+
const keys = this.sort(rawKeys);
|
|
6463
6487
|
let adjustedValue = undefined;
|
|
6464
6488
|
let result = undefined;
|
|
6465
6489
|
for (let i = 0; i < keys.length; i++) {
|
|
6466
6490
|
const key = keys[i];
|
|
6467
|
-
let value =
|
|
6491
|
+
let value = params[key];
|
|
6468
6492
|
if (Array.isArray(value)) {
|
|
6469
6493
|
let arrStr = undefined;
|
|
6470
6494
|
for (let j = 0; j < value.length; j++) {
|
|
@@ -6541,7 +6565,7 @@ export default class bingx extends Exchange {
|
|
|
6541
6565
|
}
|
|
6542
6566
|
else {
|
|
6543
6567
|
parsedParams = this.parseParams(params);
|
|
6544
|
-
encodeRequest = this.rawencode(parsedParams);
|
|
6568
|
+
encodeRequest = this.rawencode(parsedParams, true);
|
|
6545
6569
|
}
|
|
6546
6570
|
const signature = this.hmac(this.encode(encodeRequest), this.encode(this.secret), sha256);
|
|
6547
6571
|
headers = {
|
|
@@ -6554,7 +6578,7 @@ export default class bingx extends Exchange {
|
|
|
6554
6578
|
body = this.json(params);
|
|
6555
6579
|
}
|
|
6556
6580
|
else {
|
|
6557
|
-
const query = this.urlencode(parsedParams);
|
|
6581
|
+
const query = this.urlencode(parsedParams, true);
|
|
6558
6582
|
url += '?' + query + '&' + 'signature=' + signature;
|
|
6559
6583
|
}
|
|
6560
6584
|
}
|
|
@@ -6580,8 +6604,12 @@ export default class bingx extends Exchange {
|
|
|
6580
6604
|
// }
|
|
6581
6605
|
//
|
|
6582
6606
|
const code = this.safeString(response, 'code');
|
|
6583
|
-
|
|
6584
|
-
|
|
6607
|
+
let message = this.safeString(response, 'msg');
|
|
6608
|
+
const transferErrorMsg = this.safeString(response, 'transferErrorMsg'); // handling with errors from transfer endpoint
|
|
6609
|
+
if ((transferErrorMsg !== undefined) || (code !== undefined && code !== '0')) {
|
|
6610
|
+
if (transferErrorMsg !== undefined) {
|
|
6611
|
+
message = transferErrorMsg;
|
|
6612
|
+
}
|
|
6585
6613
|
const feedback = this.id + ' ' + body;
|
|
6586
6614
|
this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
|
|
6587
6615
|
this.throwExactlyMatchedException(this.exceptions['exact'], code, feedback);
|
package/js/src/bitget.d.ts
CHANGED
|
@@ -24,11 +24,14 @@ export default class bitget extends Exchange {
|
|
|
24
24
|
* @see https://www.bitget.com/api-doc/spot/market/Get-Symbols
|
|
25
25
|
* @see https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
|
|
26
26
|
* @see https://www.bitget.com/api-doc/margin/common/support-currencies
|
|
27
|
+
* @see https://www.bitget.bike/api-doc/uta/public/Instruments
|
|
27
28
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
29
|
+
* @param {string} [params.uta] set to true to fetch markets for the unified trading account (uta), defaults to false
|
|
28
30
|
* @returns {object[]} an array of objects representing market data
|
|
29
31
|
*/
|
|
30
32
|
fetchMarkets(params?: {}): Promise<Market[]>;
|
|
31
|
-
|
|
33
|
+
fetchDefaultMarkets(params: any): Promise<Market[]>;
|
|
34
|
+
fetchUtaMarkets(params: any): Promise<Market[]>;
|
|
32
35
|
/**
|
|
33
36
|
* @method
|
|
34
37
|
* @name bitget#fetchCurrencies
|