ccxt 4.3.4 → 4.3.5

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.
@@ -1149,8 +1149,10 @@ class kucoin extends kucoin$1 {
1149
1149
  // "chains":[
1150
1150
  // {
1151
1151
  // "chainName":"ERC20",
1152
- // "chain":"eth",
1152
+ // "chainId": "eth"
1153
1153
  // "withdrawalMinSize":"2999",
1154
+ // "depositMinSize":null,
1155
+ // "withdrawFeeRate":"0",
1154
1156
  // "withdrawalMinFee":"2999",
1155
1157
  // "isWithdrawEnabled":false,
1156
1158
  // "isDepositEnabled":false,
@@ -1258,7 +1260,7 @@ class kucoin extends kucoin$1 {
1258
1260
  'max': undefined,
1259
1261
  },
1260
1262
  'deposit': {
1261
- 'min': this.safeNumber(chainExtraData, 'depositMinSize'),
1263
+ 'min': this.safeNumber(chain, 'depositMinSize'),
1262
1264
  'max': undefined,
1263
1265
  },
1264
1266
  },
@@ -3201,7 +3203,6 @@ class kucoin extends kucoin$1 {
3201
3203
  const request = {
3202
3204
  'currency': currency['id'],
3203
3205
  'address': address,
3204
- 'amount': amount,
3205
3206
  // 'memo': tag,
3206
3207
  // 'isInner': false, // internal transfer or external withdrawal
3207
3208
  // 'remark': 'optional',
@@ -3215,6 +3216,8 @@ class kucoin extends kucoin$1 {
3215
3216
  if (networkCode !== undefined) {
3216
3217
  request['chain'] = this.networkCodeToId(networkCode).toLowerCase();
3217
3218
  }
3219
+ await this.loadCurrencyPrecision(currency, networkCode);
3220
+ request['amount'] = this.currencyToPrecision(code, amount, networkCode);
3218
3221
  let includeFee = undefined;
3219
3222
  [includeFee, params] = this.handleOptionAndParams(params, 'withdraw', 'includeFee', false);
3220
3223
  if (includeFee) {
@@ -3234,6 +3237,53 @@ class kucoin extends kucoin$1 {
3234
3237
  const data = this.safeDict(response, 'data', {});
3235
3238
  return this.parseTransaction(data, currency);
3236
3239
  }
3240
+ async loadCurrencyPrecision(currency, networkCode = undefined) {
3241
+ // as kucoin might not have network specific precisions defined in fetchCurrencies (because of webapi failure)
3242
+ // we should check and refetch precision once-per-instance for that specific currency & network
3243
+ // so avoids thorwing exceptions and burden to users
3244
+ // Note: this needs to be executed only if networkCode was provided
3245
+ if (networkCode !== undefined) {
3246
+ const networks = currency['networks'];
3247
+ const network = this.safeDict(networks, networkCode);
3248
+ if (this.safeNumber(network, 'precision') !== undefined) {
3249
+ // if precision exists, no need to refetch
3250
+ return;
3251
+ }
3252
+ // otherwise try to fetch and store in instance
3253
+ const request = {
3254
+ 'currency': currency['id'],
3255
+ 'chain': this.networkCodeToId(networkCode).toLowerCase(),
3256
+ };
3257
+ const response = await this.privateGetWithdrawalsQuotas(request);
3258
+ //
3259
+ // {
3260
+ // "code": "200000",
3261
+ // "data": {
3262
+ // "currency": "USDT",
3263
+ // "limitBTCAmount": "14.24094850",
3264
+ // "usedBTCAmount": "0.00000000",
3265
+ // "quotaCurrency": "USDT",
3266
+ // "limitQuotaCurrencyAmount": "999999.00000000",
3267
+ // "usedQuotaCurrencyAmount": "0",
3268
+ // "remainAmount": "999999.0000",
3269
+ // "availableAmount": "10.77545071",
3270
+ // "withdrawMinFee": "1",
3271
+ // "innerWithdrawMinFee": "0",
3272
+ // "withdrawMinSize": "10",
3273
+ // "isWithdrawEnabled": true,
3274
+ // "precision": 4,
3275
+ // "chain": "EOS",
3276
+ // "reason": null,
3277
+ // "lockedAmount": "0"
3278
+ // }
3279
+ // }
3280
+ //
3281
+ const data = this.safeDict(response, 'data', {});
3282
+ const precision = this.parseNumber(this.parsePrecision(this.safeString(data, 'precision')));
3283
+ const code = currency['code'];
3284
+ this.currencies[code]['networks'][networkCode]['precision'] = precision;
3285
+ }
3286
+ }
3237
3287
  parseTransactionStatus(status) {
3238
3288
  const statuses = {
3239
3289
  'SUCCESS': 'ok',