ccxt 4.5.53 → 4.5.54

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.
Files changed (69) hide show
  1. package/README.md +144 -145
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -4
  4. package/dist/cjs/src/base/Exchange.js +29 -0
  5. package/dist/cjs/src/bydfi.js +1 -1
  6. package/dist/cjs/src/coinbase.js +1 -1
  7. package/dist/cjs/src/coinbaseinternational.js +0 -38
  8. package/dist/cjs/src/coinex.js +1 -1
  9. package/dist/cjs/src/deepcoin.js +1 -1
  10. package/dist/cjs/src/dydx.js +1 -1
  11. package/dist/cjs/src/hollaex.js +2 -6
  12. package/dist/cjs/src/modetrade.js +1 -1
  13. package/dist/cjs/src/pacifica.js +42 -44
  14. package/dist/cjs/src/paradex.js +1 -1
  15. package/dist/cjs/src/pro/backpack.js +12 -3
  16. package/dist/cjs/src/pro/binance.js +7 -2
  17. package/dist/cjs/src/pro/hashkey.js +7 -4
  18. package/dist/cjs/src/pro/krakenfutures.js +27 -12
  19. package/dist/cjs/src/pro/kucoin.js +3 -3
  20. package/dist/cjs/src/pro/modetrade.js +1 -1
  21. package/dist/cjs/src/pro/weex.js +7 -5
  22. package/dist/cjs/src/pro/woo.js +1 -1
  23. package/dist/cjs/src/pro/woofipro.js +1 -1
  24. package/dist/cjs/src/weex.js +9 -6
  25. package/dist/cjs/src/woo.js +1 -1
  26. package/dist/cjs/src/woofipro.js +1 -1
  27. package/dist/cjs/src/xt.js +2 -2
  28. package/js/ccxt.d.ts +2 -5
  29. package/js/ccxt.js +2 -4
  30. package/js/src/base/Exchange.d.ts +23 -2
  31. package/js/src/base/Exchange.js +29 -0
  32. package/js/src/bydfi.js +1 -1
  33. package/js/src/coinbase.js +1 -1
  34. package/js/src/coinbaseexchange.d.ts +1 -1
  35. package/js/src/coinbaseinternational.d.ts +0 -21
  36. package/js/src/coinbaseinternational.js +0 -38
  37. package/js/src/coinex.js +1 -1
  38. package/js/src/deepcoin.js +1 -1
  39. package/js/src/dydx.js +1 -1
  40. package/js/src/hollaex.js +2 -6
  41. package/js/src/modetrade.js +1 -1
  42. package/js/src/pacifica.js +42 -44
  43. package/js/src/paradex.js +1 -1
  44. package/js/src/pro/backpack.js +12 -3
  45. package/js/src/pro/binance.d.ts +1 -1
  46. package/js/src/pro/binance.js +7 -2
  47. package/js/src/pro/hashkey.js +7 -4
  48. package/js/src/pro/krakenfutures.js +27 -12
  49. package/js/src/pro/kucoin.js +3 -3
  50. package/js/src/pro/modetrade.js +1 -1
  51. package/js/src/pro/weex.d.ts +1 -0
  52. package/js/src/pro/weex.js +7 -5
  53. package/js/src/pro/woo.js +1 -1
  54. package/js/src/pro/woofipro.js +1 -1
  55. package/js/src/protobuf/mexc/compiled.d.cts +0 -6
  56. package/js/src/static_dependencies/dydx-v4-client/long/index.d.cts +0 -6
  57. package/js/src/static_dependencies/fflake/browser.d.ts +5 -5
  58. package/js/src/static_dependencies/noble-curves/abstract/weierstrass.d.ts +0 -1
  59. package/js/src/weex.js +9 -6
  60. package/js/src/woo.js +1 -1
  61. package/js/src/woofipro.js +1 -1
  62. package/js/src/xt.js +2 -2
  63. package/package.json +3 -3
  64. package/dist/cjs/src/abstract/zonda.js +0 -11
  65. package/dist/cjs/src/zonda.js +0 -1998
  66. package/js/src/abstract/zonda.d.ts +0 -56
  67. package/js/src/abstract/zonda.js +0 -11
  68. package/js/src/zonda.d.ts +0 -214
  69. package/js/src/zonda.js +0 -1997
@@ -1,1998 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var zonda$1 = require('./abstract/zonda.js');
6
- var errors = require('./base/errors.js');
7
- var number = require('./base/functions/number.js');
8
- var Precise = require('./base/Precise.js');
9
- var sha512 = require('./static_dependencies/noble-hashes/sha512.js');
10
-
11
- // ----------------------------------------------------------------------------
12
- // ---------------------------------------------------------------------------
13
- /**
14
- * @class zonda
15
- * @augments Exchange
16
- */
17
- class zonda extends zonda$1["default"] {
18
- describe() {
19
- return this.deepExtend(super.describe(), {
20
- 'id': 'zonda',
21
- 'name': 'Zonda',
22
- 'countries': ['EE'],
23
- 'rateLimit': 1000,
24
- 'has': {
25
- 'CORS': true,
26
- 'spot': true,
27
- 'margin': false,
28
- 'swap': false,
29
- 'future': false,
30
- 'option': false,
31
- 'addMargin': false,
32
- 'borrowCrossMargin': false,
33
- 'borrowIsolatedMargin': false,
34
- 'borrowMargin': false,
35
- 'cancelAllOrders': false,
36
- 'cancelOrder': true,
37
- 'cancelOrders': false,
38
- 'closeAllPositions': false,
39
- 'closePosition': false,
40
- 'createDepositAddress': false,
41
- 'createOrder': true,
42
- 'createReduceOnlyOrder': false,
43
- 'fetchAllGreeks': false,
44
- 'fetchBalance': true,
45
- 'fetchBorrowInterest': false,
46
- 'fetchBorrowRate': false,
47
- 'fetchBorrowRateHistories': false,
48
- 'fetchBorrowRateHistory': false,
49
- 'fetchBorrowRates': false,
50
- 'fetchBorrowRatesPerSymbol': false,
51
- 'fetchCrossBorrowRate': false,
52
- 'fetchCrossBorrowRates': false,
53
- 'fetchCurrencies': false,
54
- 'fetchDeposit': false,
55
- 'fetchDepositAddress': true,
56
- 'fetchDepositAddresses': true,
57
- 'fetchDepositAddressesByNetwork': false,
58
- 'fetchDeposits': undefined,
59
- 'fetchFundingHistory': false,
60
- 'fetchFundingInterval': false,
61
- 'fetchFundingIntervals': false,
62
- 'fetchFundingRate': false,
63
- 'fetchFundingRateHistory': false,
64
- 'fetchFundingRates': false,
65
- 'fetchGreeks': false,
66
- 'fetchIndexOHLCV': false,
67
- 'fetchIsolatedBorrowRate': false,
68
- 'fetchIsolatedBorrowRates': false,
69
- 'fetchIsolatedPositions': false,
70
- 'fetchLedger': true,
71
- 'fetchLeverage': false,
72
- 'fetchLeverages': false,
73
- 'fetchLeverageTiers': false,
74
- 'fetchLiquidations': false,
75
- 'fetchLongShortRatio': false,
76
- 'fetchLongShortRatioHistory': false,
77
- 'fetchMarginAdjustmentHistory': false,
78
- 'fetchMarginMode': false,
79
- 'fetchMarginModes': false,
80
- 'fetchMarketLeverageTiers': false,
81
- 'fetchMarkets': true,
82
- 'fetchMarkOHLCV': false,
83
- 'fetchMarkPrice': false,
84
- 'fetchMarkPrices': false,
85
- 'fetchMyLiquidations': false,
86
- 'fetchMySettlementHistory': false,
87
- 'fetchMyTrades': true,
88
- 'fetchOHLCV': true,
89
- 'fetchOpenInterest': false,
90
- 'fetchOpenInterestHistory': false,
91
- 'fetchOpenInterests': false,
92
- 'fetchOpenOrder': false,
93
- 'fetchOpenOrders': true,
94
- 'fetchOption': false,
95
- 'fetchOptionChain': false,
96
- 'fetchOrderBook': true,
97
- 'fetchOrderBooks': false,
98
- 'fetchPosition': false,
99
- 'fetchPositionHistory': false,
100
- 'fetchPositionMode': false,
101
- 'fetchPositions': false,
102
- 'fetchPositionsForSymbol': false,
103
- 'fetchPositionsHistory': false,
104
- 'fetchPositionsRisk': false,
105
- 'fetchPremiumIndexOHLCV': false,
106
- 'fetchSettlementHistory': false,
107
- 'fetchTicker': true,
108
- 'fetchTickers': true,
109
- 'fetchTime': false,
110
- 'fetchTrades': true,
111
- 'fetchTradingFee': false,
112
- 'fetchTradingFees': false,
113
- 'fetchTransactionFee': false,
114
- 'fetchTransactionFees': false,
115
- 'fetchTransactions': undefined,
116
- 'fetchTransfer': false,
117
- 'fetchUnderlyingAssets': false,
118
- 'fetchVolatilityHistory': false,
119
- 'fetchWithdrawal': false,
120
- 'fetchWithdrawals': undefined,
121
- 'reduceMargin': false,
122
- 'repayCrossMargin': false,
123
- 'repayIsolatedMargin': false,
124
- 'repayMargin': false,
125
- 'setLeverage': false,
126
- 'setMargin': false,
127
- 'setMarginMode': false,
128
- 'setPositionMode': false,
129
- 'transfer': true,
130
- 'withdraw': true,
131
- },
132
- 'timeframes': {
133
- '1m': '60',
134
- '3m': '180',
135
- '5m': '300',
136
- '15m': '900',
137
- '30m': '1800',
138
- '1h': '3600',
139
- '2h': '7200',
140
- '4h': '14400',
141
- '6h': '21600',
142
- '12h': '43200',
143
- '1d': '86400',
144
- '3d': '259200',
145
- '1w': '604800',
146
- },
147
- 'hostname': 'zondacrypto.exchange',
148
- 'urls': {
149
- 'referral': 'https://auth.zondaglobal.com/ref/jHlbB4mIkdS1',
150
- 'logo': 'https://user-images.githubusercontent.com/1294454/159202310-a0e38007-5e7c-4ba9-a32f-c8263a0291fe.jpg',
151
- 'www': 'https://zondaglobal.com',
152
- 'api': {
153
- 'public': 'https://{hostname}/API/Public',
154
- 'private': 'https://{hostname}/API/Trading/tradingApi.php',
155
- 'v1_01Public': 'https://api.{hostname}/rest',
156
- 'v1_01Private': 'https://api.{hostname}/rest',
157
- },
158
- 'doc': [
159
- 'https://docs.zondacrypto.exchange/',
160
- 'https://github.com/BitBayNet/API',
161
- ],
162
- 'support': 'https://zondaglobal.com/en/helpdesk/zonda-exchange',
163
- 'fees': 'https://zondaglobal.com/legal/zonda-exchange/fees',
164
- },
165
- 'api': {
166
- 'public': {
167
- 'get': [
168
- '{id}/all',
169
- '{id}/market',
170
- '{id}/orderbook',
171
- '{id}/ticker',
172
- '{id}/trades',
173
- ],
174
- },
175
- 'private': {
176
- 'post': [
177
- 'info',
178
- 'trade',
179
- 'cancel',
180
- 'orderbook',
181
- 'orders',
182
- 'transfer',
183
- 'withdraw',
184
- 'history',
185
- 'transactions',
186
- ],
187
- },
188
- 'v1_01Public': {
189
- 'get': [
190
- 'trading/ticker',
191
- 'trading/ticker/{symbol}',
192
- 'trading/stats',
193
- 'trading/stats/{symbol}',
194
- 'trading/orderbook/{symbol}',
195
- 'trading/transactions/{symbol}',
196
- 'trading/candle/history/{symbol}/{resolution}',
197
- ],
198
- },
199
- 'v1_01Private': {
200
- 'get': [
201
- 'api_payments/deposits/crypto/addresses',
202
- 'payments/withdrawal/{detailId}',
203
- 'payments/deposit/{detailId}',
204
- 'trading/offer',
205
- 'trading/stop/offer',
206
- 'trading/config/{symbol}',
207
- 'trading/history/transactions',
208
- 'balances/BITBAY/history',
209
- 'balances/BITBAY/balance',
210
- 'fiat_cantor/rate/{baseId}/{quoteId}',
211
- 'fiat_cantor/history',
212
- 'client_payments/v2/customer/crypto/{currency}/channels/deposit',
213
- 'client_payments/v2/customer/crypto/{currency}/channels/withdrawal',
214
- 'client_payments/v2/customer/crypto/deposit/fee',
215
- 'client_payments/v2/customer/crypto/withdrawal/fee',
216
- ],
217
- 'post': [
218
- 'trading/offer/{symbol}',
219
- 'trading/stop/offer/{symbol}',
220
- 'trading/config/{symbol}',
221
- 'balances/BITBAY/balance',
222
- 'balances/BITBAY/balance/transfer/{source}/{destination}',
223
- 'fiat_cantor/exchange',
224
- 'api_payments/withdrawals/crypto',
225
- 'api_payments/withdrawals/fiat',
226
- 'client_payments/v2/customer/crypto/deposit',
227
- 'client_payments/v2/customer/crypto/withdrawal',
228
- ],
229
- 'delete': [
230
- 'trading/offer/{symbol}/{id}/{side}/{price}',
231
- 'trading/stop/offer/{symbol}/{id}/{side}/{price}',
232
- ],
233
- 'put': [
234
- 'balances/BITBAY/balance/{id}',
235
- ],
236
- },
237
- },
238
- 'fees': {
239
- 'trading': {
240
- 'maker': this.parseNumber('0.0'),
241
- 'taker': this.parseNumber('0.001'),
242
- 'percentage': true,
243
- 'tierBased': false,
244
- },
245
- 'fiat': {
246
- 'maker': this.parseNumber('0.0030'),
247
- 'taker': this.parseNumber('0.0043'),
248
- 'percentage': true,
249
- 'tierBased': true,
250
- 'tiers': {
251
- 'taker': [
252
- [this.parseNumber('0.0043'), this.parseNumber('0')],
253
- [this.parseNumber('0.0042'), this.parseNumber('1250')],
254
- [this.parseNumber('0.0041'), this.parseNumber('3750')],
255
- [this.parseNumber('0.0040'), this.parseNumber('7500')],
256
- [this.parseNumber('0.0039'), this.parseNumber('10000')],
257
- [this.parseNumber('0.0038'), this.parseNumber('15000')],
258
- [this.parseNumber('0.0037'), this.parseNumber('20000')],
259
- [this.parseNumber('0.0036'), this.parseNumber('25000')],
260
- [this.parseNumber('0.0035'), this.parseNumber('37500')],
261
- [this.parseNumber('0.0034'), this.parseNumber('50000')],
262
- [this.parseNumber('0.0033'), this.parseNumber('75000')],
263
- [this.parseNumber('0.0032'), this.parseNumber('100000')],
264
- [this.parseNumber('0.0031'), this.parseNumber('150000')],
265
- [this.parseNumber('0.0030'), this.parseNumber('200000')],
266
- [this.parseNumber('0.0029'), this.parseNumber('250000')],
267
- [this.parseNumber('0.0028'), this.parseNumber('375000')],
268
- [this.parseNumber('0.0027'), this.parseNumber('500000')],
269
- [this.parseNumber('0.0026'), this.parseNumber('625000')],
270
- [this.parseNumber('0.0025'), this.parseNumber('875000')],
271
- ],
272
- 'maker': [
273
- [this.parseNumber('0.0030'), this.parseNumber('0')],
274
- [this.parseNumber('0.0029'), this.parseNumber('1250')],
275
- [this.parseNumber('0.0028'), this.parseNumber('3750')],
276
- [this.parseNumber('0.0028'), this.parseNumber('7500')],
277
- [this.parseNumber('0.0027'), this.parseNumber('10000')],
278
- [this.parseNumber('0.0026'), this.parseNumber('15000')],
279
- [this.parseNumber('0.0025'), this.parseNumber('20000')],
280
- [this.parseNumber('0.0025'), this.parseNumber('25000')],
281
- [this.parseNumber('0.0024'), this.parseNumber('37500')],
282
- [this.parseNumber('0.0023'), this.parseNumber('50000')],
283
- [this.parseNumber('0.0023'), this.parseNumber('75000')],
284
- [this.parseNumber('0.0022'), this.parseNumber('100000')],
285
- [this.parseNumber('0.0021'), this.parseNumber('150000')],
286
- [this.parseNumber('0.0021'), this.parseNumber('200000')],
287
- [this.parseNumber('0.0020'), this.parseNumber('250000')],
288
- [this.parseNumber('0.0019'), this.parseNumber('375000')],
289
- [this.parseNumber('0.0018'), this.parseNumber('500000')],
290
- [this.parseNumber('0.0018'), this.parseNumber('625000')],
291
- [this.parseNumber('0.0017'), this.parseNumber('875000')],
292
- ],
293
- },
294
- },
295
- 'funding': {
296
- 'withdraw': {},
297
- },
298
- },
299
- 'options': {
300
- 'fetchTickerMethod': 'v1_01PublicGetTradingTickerSymbol',
301
- 'fetchTickersMethod': 'v1_01PublicGetTradingTicker',
302
- 'fiatCurrencies': ['EUR', 'USD', 'GBP', 'PLN'],
303
- 'transfer': {
304
- 'fillResponseFromRequest': true,
305
- },
306
- },
307
- 'features': {
308
- 'spot': {
309
- 'sandbox': false,
310
- 'createOrder': {
311
- 'marginMode': false,
312
- 'triggerPrice': true,
313
- 'triggerDirection': false,
314
- 'triggerPriceType': undefined,
315
- 'stopLossPrice': false,
316
- 'takeProfitPrice': false,
317
- 'attachedStopLossTakeProfit': undefined,
318
- 'timeInForce': {
319
- 'IOC': true,
320
- 'FOK': true,
321
- 'PO': true,
322
- 'GTD': false,
323
- },
324
- 'hedged': false,
325
- 'trailing': false,
326
- 'leverage': false,
327
- 'marketBuyByCost': true,
328
- 'marketBuyRequiresPrice': false,
329
- 'selfTradePrevention': false,
330
- 'iceberg': false,
331
- },
332
- 'createOrders': undefined,
333
- 'fetchMyTrades': {
334
- 'marginMode': false,
335
- 'limit': undefined,
336
- 'daysBack': 100000,
337
- 'untilDays': 100000,
338
- 'symbolRequired': false,
339
- },
340
- 'fetchOrder': undefined,
341
- 'fetchOpenOrders': {
342
- 'marginMode': false,
343
- 'limit': 100,
344
- 'trigger': false,
345
- 'trailing': false,
346
- 'symbolRequired': false,
347
- },
348
- 'fetchOrders': undefined,
349
- 'fetchClosedOrders': undefined,
350
- 'fetchOHLCV': {
351
- 'limit': undefined,
352
- },
353
- },
354
- 'swap': {
355
- 'linear': undefined,
356
- 'inverse': undefined,
357
- },
358
- 'future': {
359
- 'linear': undefined,
360
- 'inverse': undefined,
361
- },
362
- },
363
- 'precisionMode': number.TICK_SIZE,
364
- 'exceptions': {
365
- '400': errors.ExchangeError,
366
- '401': errors.InvalidOrder,
367
- '402': errors.InvalidOrder,
368
- '403': errors.InvalidOrder,
369
- '404': errors.InvalidOrder,
370
- '405': errors.InvalidOrder,
371
- '406': errors.InsufficientFunds,
372
- // code 407 not specified are not specified in their docs
373
- '408': errors.InvalidOrder,
374
- '501': errors.AuthenticationError,
375
- '502': errors.AuthenticationError,
376
- '503': errors.InvalidNonce,
377
- '504': errors.ExchangeError,
378
- '505': errors.AuthenticationError,
379
- '506': errors.AccountSuspended,
380
- // codes 507 and 508 are not specified in their docs
381
- '509': errors.ExchangeError,
382
- '510': errors.BadSymbol,
383
- 'FUNDS_NOT_SUFFICIENT': errors.InsufficientFunds,
384
- 'OFFER_FUNDS_NOT_EXCEEDING_MINIMUMS': errors.InvalidOrder,
385
- 'OFFER_NOT_FOUND': errors.OrderNotFound,
386
- 'OFFER_WOULD_HAVE_BEEN_PARTIALLY_FILLED': errors.OrderImmediatelyFillable,
387
- 'ACTION_LIMIT_EXCEEDED': errors.RateLimitExceeded,
388
- 'UNDER_MAINTENANCE': errors.OnMaintenance,
389
- 'REQUEST_TIMESTAMP_TOO_OLD': errors.InvalidNonce,
390
- 'PERMISSIONS_NOT_SUFFICIENT': errors.PermissionDenied,
391
- 'INVALID_STOP_RATE': errors.InvalidOrder,
392
- 'TIMEOUT': errors.ExchangeError,
393
- 'RESPONSE_TIMEOUT': errors.ExchangeError,
394
- 'ACTION_BLOCKED': errors.PermissionDenied,
395
- 'INVALID_HASH_SIGNATURE': errors.AuthenticationError,
396
- },
397
- 'commonCurrencies': {
398
- 'GGC': 'Global Game Coin',
399
- },
400
- });
401
- }
402
- /**
403
- * @method
404
- * @name zonda#fetchMarkets
405
- * @see https://docs.zondacrypto.exchange/reference/ticker-1
406
- * @description retrieves data on all markets for zonda
407
- * @param {object} [params] extra parameters specific to the exchange API endpoint
408
- * @returns {object[]} an array of objects representing market data
409
- */
410
- async fetchMarkets(params = {}) {
411
- const response = await this.v1_01PublicGetTradingTicker(params);
412
- //
413
- // {
414
- // "status": "Ok",
415
- // "items": {
416
- // "BSV-USD": {
417
- // "market": {
418
- // "code": "BSV-USD",
419
- // "first": { currency: "BSV", minOffer: "0.00035", scale: 8 },
420
- // "second": { currency: "USD", minOffer: "5", scale: 2 }
421
- // },
422
- // "time": "1557569762154",
423
- // "highestBid": "52.31",
424
- // "lowestAsk": "62.99",
425
- // "rate": "63",
426
- // "previousRate": "51.21",
427
- // },
428
- // },
429
- // }
430
- //
431
- const items = this.safeValue(response, 'items', {});
432
- const markets = Object.values(items);
433
- return this.parseMarkets(markets);
434
- }
435
- parseMarket(item) {
436
- const market = this.safeValue(item, 'market', {});
437
- const id = this.safeString(market, 'code');
438
- const first = this.safeValue(market, 'first', {});
439
- const second = this.safeValue(market, 'second', {});
440
- const baseId = this.safeString(first, 'currency');
441
- const quoteId = this.safeString(second, 'currency');
442
- const base = this.safeCurrencyCode(baseId);
443
- const quote = this.safeCurrencyCode(quoteId);
444
- let fees = this.safeValue(this.fees, 'trading', {});
445
- const fiatCurrencies = this.safeValue(this.options, 'fiatCurrencies', []);
446
- if (this.inArray(base, fiatCurrencies) || this.inArray(quote, fiatCurrencies)) {
447
- fees = this.safeValue(this.fees, 'fiat', {});
448
- }
449
- // todo: check that the limits have ben interpreted correctly
450
- return {
451
- 'id': id,
452
- 'symbol': base + '/' + quote,
453
- 'base': base,
454
- 'quote': quote,
455
- 'settle': undefined,
456
- 'baseId': baseId,
457
- 'quoteId': quoteId,
458
- 'settleId': undefined,
459
- 'type': 'spot',
460
- 'spot': true,
461
- 'margin': false,
462
- 'swap': false,
463
- 'future': false,
464
- 'option': false,
465
- 'active': undefined,
466
- 'contract': false,
467
- 'linear': undefined,
468
- 'inverse': undefined,
469
- 'taker': this.safeNumber(fees, 'taker'),
470
- 'maker': this.safeNumber(fees, 'maker'),
471
- 'contractSize': undefined,
472
- 'expiry': undefined,
473
- 'expiryDatetime': undefined,
474
- 'optionType': undefined,
475
- 'strike': undefined,
476
- 'precision': {
477
- 'amount': this.parseNumber(this.parsePrecision(this.safeString(first, 'scale'))),
478
- 'price': this.parseNumber(this.parsePrecision(this.safeString(second, 'scale'))),
479
- },
480
- 'limits': {
481
- 'leverage': {
482
- 'min': undefined,
483
- 'max': undefined,
484
- },
485
- 'amount': {
486
- 'min': this.safeNumber(first, 'minOffer'),
487
- 'max': undefined,
488
- },
489
- 'price': {
490
- 'min': undefined,
491
- 'max': undefined,
492
- },
493
- 'cost': {
494
- 'min': undefined,
495
- 'max': undefined,
496
- },
497
- },
498
- 'created': undefined,
499
- 'info': item,
500
- };
501
- }
502
- /**
503
- * @method
504
- * @name zonda#fetchOpenOrders
505
- * @see https://docs.zondacrypto.exchange/reference/active-orders
506
- * @description fetch all unfilled currently open orders
507
- * @param {string} symbol not used by zonda fetchOpenOrders
508
- * @param {int} [since] the earliest time in ms to fetch open orders for
509
- * @param {int} [limit] the maximum number of open orders structures to retrieve
510
- * @param {object} [params] extra parameters specific to the exchange API endpoint
511
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
512
- */
513
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
514
- await this.loadMarkets();
515
- const request = {};
516
- // todo pair
517
- const response = await this.v1_01PrivateGetTradingOffer(this.extend(request, params));
518
- const items = this.safeList(response, 'items', []);
519
- return this.parseOrders(items, undefined, since, limit, { 'status': 'open' });
520
- }
521
- parseOrder(order, market = undefined) {
522
- //
523
- // {
524
- // "market": "ETH-EUR",
525
- // "offerType": "Sell",
526
- // "id": "93d3657b-d616-11e9-9248-0242ac110005",
527
- // "currentAmount": "0.04",
528
- // "lockedAmount": "0.04",
529
- // "rate": "280",
530
- // "startAmount": "0.04",
531
- // "time": "1568372806924",
532
- // "postOnly": false,
533
- // "hidden": false,
534
- // "mode": "limit",
535
- // "receivedAmount": "0.0",
536
- // "firstBalanceId": "5b816c3e-437c-4e43-9bef-47814ae7ebfc",
537
- // "secondBalanceId": "ab43023b-4079-414c-b340-056e3430a3af"
538
- // }
539
- //
540
- // cancelOrder
541
- //
542
- // {
543
- // status: "Ok",
544
- // errors: []
545
- // }
546
- //
547
- const marketId = this.safeString(order, 'market');
548
- const symbol = this.safeSymbol(marketId, market, '-');
549
- const timestamp = this.safeInteger(order, 'time');
550
- const amount = this.safeString(order, 'startAmount');
551
- const remaining = this.safeString(order, 'currentAmount');
552
- const postOnly = this.safeValue(order, 'postOnly');
553
- return this.safeOrder({
554
- 'id': this.safeString(order, 'id'),
555
- 'clientOrderId': undefined,
556
- 'info': order,
557
- 'timestamp': timestamp,
558
- 'datetime': this.iso8601(timestamp),
559
- 'lastTradeTimestamp': undefined,
560
- 'status': undefined,
561
- 'symbol': symbol,
562
- 'type': this.safeString(order, 'mode'),
563
- 'timeInForce': undefined,
564
- 'postOnly': postOnly,
565
- 'side': this.safeStringLower(order, 'offerType'),
566
- 'price': this.safeString(order, 'rate'),
567
- 'triggerPrice': undefined,
568
- 'amount': amount,
569
- 'cost': undefined,
570
- 'filled': undefined,
571
- 'remaining': remaining,
572
- 'average': undefined,
573
- 'fee': undefined,
574
- 'trades': undefined,
575
- }, market);
576
- }
577
- /**
578
- * @method
579
- * @name zonda#fetchMyTrades
580
- * @see https://docs.zondacrypto.exchange/reference/transactions-history
581
- * @description fetch all trades made by the user
582
- * @param {string} symbol unified market symbol
583
- * @param {int} [since] the earliest time in ms to fetch trades for
584
- * @param {int} [limit] the maximum number of trades structures to retrieve
585
- * @param {object} [params] extra parameters specific to the exchange API endpoint
586
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
587
- */
588
- async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
589
- await this.loadMarkets();
590
- const request = {};
591
- if (symbol) {
592
- const markets = [this.marketId(symbol)];
593
- symbol = this.symbol(symbol);
594
- request['markets'] = markets;
595
- }
596
- const query = { 'query': this.json(this.extend(request, params)) };
597
- const response = await this.v1_01PrivateGetTradingHistoryTransactions(query);
598
- //
599
- // {
600
- // "status": "Ok",
601
- // "totalRows": "67",
602
- // "items": [
603
- // {
604
- // "id": "b54659a0-51b5-42a0-80eb-2ac5357ccee2",
605
- // "market": "BTC-EUR",
606
- // "time": "1541697096247",
607
- // "amount": "0.00003",
608
- // "rate": "4341.44",
609
- // "initializedBy": "Sell",
610
- // "wasTaker": false,
611
- // "userAction": "Buy",
612
- // "offerId": "bd19804a-6f89-4a69-adb8-eb078900d006",
613
- // "commissionValue": null
614
- // },
615
- // ]
616
- // }
617
- //
618
- const items = this.safeValue(response, 'items');
619
- const result = this.parseTrades(items, undefined, since, limit);
620
- if (symbol === undefined) {
621
- return result;
622
- }
623
- return this.filterBySymbol(result, symbol);
624
- }
625
- parseBalance(response) {
626
- const balances = this.safeValue(response, 'balances');
627
- if (balances === undefined) {
628
- throw new errors.ExchangeError(this.id + ' empty balance response ' + this.json(response));
629
- }
630
- const result = { 'info': response };
631
- for (let i = 0; i < balances.length; i++) {
632
- const balance = balances[i];
633
- const currencyId = this.safeString(balance, 'currency');
634
- const code = this.safeCurrencyCode(currencyId);
635
- const account = this.account();
636
- account['used'] = this.safeString(balance, 'lockedFunds');
637
- account['free'] = this.safeString(balance, 'availableFunds');
638
- result[code] = account;
639
- }
640
- return this.safeBalance(result);
641
- }
642
- /**
643
- * @method
644
- * @name zonda#fetchBalance
645
- * @see https://docs.zondacrypto.exchange/reference/list-of-wallets
646
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
647
- * @param {object} [params] extra parameters specific to the exchange API endpoint
648
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
649
- */
650
- async fetchBalance(params = {}) {
651
- await this.loadMarkets();
652
- const response = await this.v1_01PrivateGetBalancesBITBAYBalance(params);
653
- return this.parseBalance(response);
654
- }
655
- /**
656
- * @method
657
- * @name zonda#fetchOrderBook
658
- * @see https://docs.zondacrypto.exchange/reference/orderbook-2
659
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
660
- * @param {string} symbol unified symbol of the market to fetch the order book for
661
- * @param {int} [limit] the maximum amount of order book entries to return
662
- * @param {object} [params] extra parameters specific to the exchange API endpoint
663
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbols
664
- */
665
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
666
- await this.loadMarkets();
667
- const market = this.market(symbol);
668
- const request = {
669
- 'symbol': market['id'],
670
- };
671
- const response = await this.v1_01PublicGetTradingOrderbookSymbol(this.extend(request, params));
672
- //
673
- // {
674
- // "status":"Ok",
675
- // "sell":[
676
- // {"ra":"43988.93","ca":"0.00100525","sa":"0.00100525","pa":"0.00100525","co":1},
677
- // {"ra":"43988.94","ca":"0.00114136","sa":"0.00114136","pa":"0.00114136","co":1},
678
- // {"ra":"43989","ca":"0.010578","sa":"0.010578","pa":"0.010578","co":1},
679
- // ],
680
- // "buy":[
681
- // {"ra":"42157.33","ca":"2.83147881","sa":"2.83147881","pa":"2.83147881","co":2},
682
- // {"ra":"42096.0","ca":"0.00011878","sa":"0.00011878","pa":"0.00011878","co":1},
683
- // {"ra":"42022.0","ca":"0.00011899","sa":"0.00011899","pa":"0.00011899","co":1},
684
- // ],
685
- // "timestamp":"1642299886122",
686
- // "seqNo":"27641254"
687
- // }
688
- //
689
- const rawBids = this.safeValue(response, 'buy', []);
690
- const rawAsks = this.safeValue(response, 'sell', []);
691
- const timestamp = this.safeInteger(response, 'timestamp');
692
- return {
693
- 'symbol': market['symbol'],
694
- 'bids': this.parseBidsAsks(rawBids, 'ra', 'ca'),
695
- 'asks': this.parseBidsAsks(rawAsks, 'ra', 'ca'),
696
- 'timestamp': timestamp,
697
- 'datetime': this.iso8601(timestamp),
698
- 'nonce': this.safeInteger(response, 'seqNo'),
699
- };
700
- }
701
- parseTicker(ticker, market = undefined) {
702
- //
703
- // version 1
704
- //
705
- // {
706
- // "m": "ETH-PLN",
707
- // "h": "13485.13",
708
- // "l": "13100.01",
709
- // "v": "126.10710939",
710
- // "r24h": "13332.72"
711
- // }
712
- //
713
- // version 2
714
- //
715
- // {
716
- // "market": {
717
- // "code": "ADA-USDT",
718
- // "first": {
719
- // "currency": "ADA",
720
- // "minOffer": "0.2",
721
- // "scale": "6"
722
- // },
723
- // "second": {
724
- // "currency": "USDT",
725
- // "minOffer": "0.099",
726
- // "scale": "6"
727
- // },
728
- // "amountPrecision": "6",
729
- // "pricePrecision": "6",
730
- // "ratePrecision": "6"
731
- // },
732
- // "time": "1655812661202",
733
- // "highestBid": "0.492",
734
- // "lowestAsk": "0.499389",
735
- // "rate": "0.50588",
736
- // "previousRate": "0.504981"
737
- // }
738
- //
739
- const tickerMarket = this.safeValue(ticker, 'market');
740
- const marketId = this.safeString2(tickerMarket, 'code', 'm');
741
- market = this.safeMarket(marketId, market);
742
- const timestamp = this.safeInteger(ticker, 'time');
743
- const rate = this.safeValue(ticker, 'rate');
744
- return this.safeTicker({
745
- 'symbol': this.safeSymbol(marketId, market),
746
- 'timestamp': timestamp,
747
- 'datetime': this.iso8601(timestamp),
748
- 'high': this.safeString(ticker, 'h'),
749
- 'low': this.safeString(ticker, 'l'),
750
- 'bid': this.safeNumber(ticker, 'highestBid'),
751
- 'bidVolume': undefined,
752
- 'ask': this.safeNumber(ticker, 'lowestAsk'),
753
- 'askVolume': undefined,
754
- 'vwap': undefined,
755
- 'open': this.safeString(ticker, 'r24h'),
756
- 'close': rate,
757
- 'last': rate,
758
- 'previousClose': this.safeValue(ticker, 'previousRate'),
759
- 'change': undefined,
760
- 'percentage': undefined,
761
- 'average': undefined,
762
- 'baseVolume': this.safeString(ticker, 'v'),
763
- 'quoteVolume': undefined,
764
- 'info': ticker,
765
- }, market);
766
- }
767
- /**
768
- * @method
769
- * @name zonda#fetchTicker
770
- * @description v1_01PublicGetTradingTickerSymbol retrieves timestamp, datetime, bid, ask, close, last, previousClose, v1_01PublicGetTradingStatsSymbol retrieves high, low, volume and opening price of an asset
771
- * @see https://docs.zondacrypto.exchange/reference/market-statistics
772
- * @param {string} symbol unified symbol of the market to fetch the ticker for
773
- * @param {object} [params] extra parameters specific to the exchange API endpoint
774
- * @param {string} [params.method] v1_01PublicGetTradingTickerSymbol (default) or v1_01PublicGetTradingStatsSymbol
775
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
776
- */
777
- async fetchTicker(symbol, params = {}) {
778
- await this.loadMarkets();
779
- const market = this.market(symbol);
780
- const request = {
781
- 'symbol': market['id'],
782
- };
783
- const method = 'v1_01PublicGetTradingTickerSymbol';
784
- const defaultMethod = this.safeString(this.options, 'fetchTickerMethod', method);
785
- const fetchTickerMethod = this.safeString2(params, 'method', 'fetchTickerMethod', defaultMethod);
786
- let response = undefined;
787
- if (fetchTickerMethod === method) {
788
- response = await this.v1_01PublicGetTradingTickerSymbol(this.extend(request, params));
789
- //
790
- // {
791
- // "status": "Ok",
792
- // "ticker": {
793
- // "market": {
794
- // "code": "ADA-USDT",
795
- // "first": {
796
- // "currency": "ADA",
797
- // "minOffer": "0.21",
798
- // "scale": 6
799
- // },
800
- // "second": {
801
- // "currency": "USDT",
802
- // "minOffer": "0.099",
803
- // "scale": 6
804
- // },
805
- // "amountPrecision": 6,
806
- // "pricePrecision": 6,
807
- // "ratePrecision": 6
808
- // },
809
- // "time": "1655810976780",
810
- // "highestBid": "0.498543",
811
- // "lowestAsk": "0.50684",
812
- // "rate": "0.50588",
813
- // "previousRate": "0.504981"
814
- // }
815
- // }
816
- //
817
- }
818
- else if (fetchTickerMethod === 'v1_01PublicGetTradingStatsSymbol') {
819
- response = await this.v1_01PublicGetTradingStatsSymbol(this.extend(request, params));
820
- //
821
- // {
822
- // "status": "Ok",
823
- // "stats": {
824
- // "m": "BTC-USDT",
825
- // "h": "28800",
826
- // "l": "26703.950101",
827
- // "v": "6.72932396",
828
- // "r24h": "27122.2"
829
- // }
830
- // }
831
- //
832
- }
833
- else {
834
- throw new errors.BadRequest(this.id + ' fetchTicker params["method"] must be "v1_01PublicGetTradingTickerSymbol" or "v1_01PublicGetTradingStatsSymbol"');
835
- }
836
- const stats = this.safeValue2(response, 'ticker', 'stats');
837
- return this.parseTicker(stats, market);
838
- }
839
- /**
840
- * @ignore
841
- * @method
842
- * @name zonda#fetchTickersV2
843
- * @description v1_01PublicGetTradingTicker retrieves timestamp, datetime, bid, ask, close, last, previousClose for each market, v1_01PublicGetTradingStats retrieves high, low, volume and opening price of each market
844
- * @see https://docs.zondacrypto.exchange/reference/market-statistics
845
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
846
- * @param {object} [params] extra parameters specific to the exchange API endpoint
847
- * @param {string} [params.method] v1_01PublicGetTradingTicker (default) or v1_01PublicGetTradingStats
848
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
849
- */
850
- async fetchTickers(symbols = undefined, params = {}) {
851
- await this.loadMarkets();
852
- const method = 'v1_01PublicGetTradingTicker';
853
- const defaultMethod = this.safeString(this.options, 'fetchTickersMethod', method);
854
- const fetchTickersMethod = this.safeString2(params, 'method', 'fetchTickersMethod', defaultMethod);
855
- let response = undefined;
856
- if (fetchTickersMethod === method) {
857
- response = await this.v1_01PublicGetTradingTicker(params);
858
- //
859
- // {
860
- // "status": "Ok",
861
- // "items": {
862
- // "DAI-PLN": {
863
- // "market": {
864
- // "code": "DAI-PLN",
865
- // "first": {
866
- // "currency": "DAI",
867
- // "minOffer": "0.99",
868
- // "scale": 8
869
- // },
870
- // "second": {
871
- // "currency": "PLN",
872
- // "minOffer": "5",
873
- // "scale": 2
874
- // },
875
- // "amountPrecision": 8,
876
- // "pricePrecision": 2,
877
- // "ratePrecision": 2
878
- // },
879
- // "time": "1655810825137",
880
- // "highestBid": "4.42",
881
- // "lowestAsk": "4.44",
882
- // "rate": "4.44",
883
- // "previousRate": "4.43"
884
- // },
885
- // ...
886
- // }
887
- // }
888
- //
889
- }
890
- else if (fetchTickersMethod === 'v1_01PublicGetTradingStats') {
891
- response = await this.v1_01PublicGetTradingStats(params);
892
- //
893
- // {
894
- // "status": "Ok",
895
- // "items": {
896
- // "DAI-PLN": {
897
- // "m": "DAI-PLN",
898
- // "h": "4.41",
899
- // "l": "4.37",
900
- // "v": "8.71068087",
901
- // "r24h": "4.36"
902
- // },
903
- // ...
904
- // }
905
- // }
906
- //
907
- }
908
- else {
909
- throw new errors.BadRequest(this.id + ' fetchTickers params["method"] must be "v1_01PublicGetTradingTicker" or "v1_01PublicGetTradingStats"');
910
- }
911
- const items = this.safeDict(response, 'items');
912
- return this.parseTickers(items, symbols);
913
- }
914
- /**
915
- * @method
916
- * @name zonda#fetchLedger
917
- * @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
918
- * @see https://docs.zondacrypto.exchange/reference/operations-history
919
- * @param {string} [code] unified currency code, default is undefined
920
- * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
921
- * @param {int} [limit] max number of ledger entries to return, default is undefined
922
- * @param {object} [params] extra parameters specific to the exchange API endpoint
923
- * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/?id=ledger-entry-structure}
924
- */
925
- async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
926
- const balanceCurrencies = [];
927
- if (code !== undefined) {
928
- const currency = this.currency(code);
929
- balanceCurrencies.push(currency['id']);
930
- }
931
- let request = {
932
- 'balanceCurrencies': balanceCurrencies,
933
- };
934
- if (since !== undefined) {
935
- request['fromTime'] = since;
936
- }
937
- if (limit !== undefined) {
938
- request['limit'] = limit;
939
- }
940
- request = this.extend(request, params);
941
- const response = await this.v1_01PrivateGetBalancesBITBAYHistory({ 'query': this.json(request) });
942
- const items = response['items'];
943
- return this.parseLedger(items, undefined, since, limit);
944
- }
945
- parseLedgerEntry(item, currency = undefined) {
946
- //
947
- // FUNDS_MIGRATION
948
- // {
949
- // "historyId": "84ea7a29-7da5-4de5-b0c0-871e83cad765",
950
- // "balance": {
951
- // "id": "821ec166-cb88-4521-916c-f4eb44db98df",
952
- // "currency": "LTC",
953
- // "type": "CRYPTO",
954
- // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
955
- // "name": "LTC"
956
- // },
957
- // "detailId": null,
958
- // "time": 1506128252968,
959
- // "type": "FUNDS_MIGRATION",
960
- // "value": 0.0009957,
961
- // "fundsBefore": { "total": 0, "available": 0, "locked": 0 },
962
- // "fundsAfter": { "total": 0.0009957, "available": 0.0009957, "locked": 0 },
963
- // "change": { "total": 0.0009957, "available": 0.0009957, "locked": 0 }
964
- // }
965
- //
966
- // CREATE_BALANCE
967
- // {
968
- // "historyId": "d0fabd8d-9107-4b5e-b9a6-3cab8af70d49",
969
- // "balance": {
970
- // "id": "653ffcf2-3037-4ebe-8e13-d5ea1a01d60d",
971
- // "currency": "BTG",
972
- // "type": "CRYPTO",
973
- // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
974
- // "name": "BTG"
975
- // },
976
- // "detailId": null,
977
- // "time": 1508895244751,
978
- // "type": "CREATE_BALANCE",
979
- // "value": 0,
980
- // "fundsBefore": { "total": null, "available": null, "locked": null },
981
- // "fundsAfter": { "total": 0, "available": 0, "locked": 0 },
982
- // "change": { "total": 0, "available": 0, "locked": 0 }
983
- // }
984
- //
985
- // BITCOIN_GOLD_FORK
986
- // {
987
- // "historyId": "2b4d52d3-611c-473d-b92c-8a8d87a24e41",
988
- // "balance": {
989
- // "id": "653ffcf2-3037-4ebe-8e13-d5ea1a01d60d",
990
- // "currency": "BTG",
991
- // "type": "CRYPTO",
992
- // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
993
- // "name": "BTG"
994
- // },
995
- // "detailId": null,
996
- // "time": 1508895244778,
997
- // "type": "BITCOIN_GOLD_FORK",
998
- // "value": 0.00453512,
999
- // "fundsBefore": { "total": 0, "available": 0, "locked": 0 },
1000
- // "fundsAfter": { "total": 0.00453512, "available": 0.00453512, "locked": 0 },
1001
- // "change": { "total": 0.00453512, "available": 0.00453512, "locked": 0 }
1002
- // }
1003
- //
1004
- // ADD_FUNDS
1005
- // {
1006
- // "historyId": "3158236d-dae5-4a5d-81af-c1fa4af340fb",
1007
- // "balance": {
1008
- // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
1009
- // "currency": "BTC",
1010
- // "type": "CRYPTO",
1011
- // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1012
- // "name": "BTC"
1013
- // },
1014
- // "detailId": "8e83a960-e737-4380-b8bb-259d6e236faa",
1015
- // "time": 1520631178816,
1016
- // "type": "ADD_FUNDS",
1017
- // "value": 0.628405,
1018
- // "fundsBefore": { "total": 0.00453512, "available": 0.00453512, "locked": 0 },
1019
- // "fundsAfter": { "total": 0.63294012, "available": 0.63294012, "locked": 0 },
1020
- // "change": { "total": 0.628405, "available": 0.628405, "locked": 0 }
1021
- // }
1022
- //
1023
- // TRANSACTION_PRE_LOCKING
1024
- // {
1025
- // "historyId": "e7d19e0f-03b3-46a8-bc72-dde72cc24ead",
1026
- // "balance": {
1027
- // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
1028
- // "currency": "BTC",
1029
- // "type": "CRYPTO",
1030
- // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1031
- // "name": "BTC"
1032
- // },
1033
- // "detailId": null,
1034
- // "time": 1520706403868,
1035
- // "type": "TRANSACTION_PRE_LOCKING",
1036
- // "value": -0.1,
1037
- // "fundsBefore": { "total": 0.63294012, "available": 0.63294012, "locked": 0 },
1038
- // "fundsAfter": { "total": 0.63294012, "available": 0.53294012, "locked": 0.1 },
1039
- // "change": { "total": 0, "available": -0.1, "locked": 0.1 }
1040
- // }
1041
- //
1042
- // TRANSACTION_POST_OUTCOME
1043
- // {
1044
- // "historyId": "c4010825-231d-4a9c-8e46-37cde1f7b63c",
1045
- // "balance": {
1046
- // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
1047
- // "currency": "BTC",
1048
- // "type": "CRYPTO",
1049
- // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1050
- // "name": "BTC"
1051
- // },
1052
- // "detailId": "bf2876bc-b545-4503-96c8-ef4de8233876",
1053
- // "time": 1520706404032,
1054
- // "type": "TRANSACTION_POST_OUTCOME",
1055
- // "value": -0.01771415,
1056
- // "fundsBefore": { "total": 0.63294012, "available": 0.53294012, "locked": 0.1 },
1057
- // "fundsAfter": { "total": 0.61522597, "available": 0.53294012, "locked": 0.08228585 },
1058
- // "change": { "total": -0.01771415, "available": 0, "locked": -0.01771415 }
1059
- // }
1060
- //
1061
- // TRANSACTION_POST_INCOME
1062
- // {
1063
- // "historyId": "7f18b7af-b676-4125-84fd-042e683046f6",
1064
- // "balance": {
1065
- // "id": "ab43023b-4079-414c-b340-056e3430a3af",
1066
- // "currency": "EUR",
1067
- // "type": "FIAT",
1068
- // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1069
- // "name": "EUR"
1070
- // },
1071
- // "detailId": "f5fcb274-0cc7-4385-b2d3-bae2756e701f",
1072
- // "time": 1520706404035,
1073
- // "type": "TRANSACTION_POST_INCOME",
1074
- // "value": 628.78,
1075
- // "fundsBefore": { "total": 0, "available": 0, "locked": 0 },
1076
- // "fundsAfter": { "total": 628.78, "available": 628.78, "locked": 0 },
1077
- // "change": { "total": 628.78, "available": 628.78, "locked": 0 }
1078
- // }
1079
- //
1080
- // TRANSACTION_COMMISSION_OUTCOME
1081
- // {
1082
- // "historyId": "843177fa-61bc-4cbf-8be5-b029d856c93b",
1083
- // "balance": {
1084
- // "id": "ab43023b-4079-414c-b340-056e3430a3af",
1085
- // "currency": "EUR",
1086
- // "type": "FIAT",
1087
- // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1088
- // "name": "EUR"
1089
- // },
1090
- // "detailId": "f5fcb274-0cc7-4385-b2d3-bae2756e701f",
1091
- // "time": 1520706404050,
1092
- // "type": "TRANSACTION_COMMISSION_OUTCOME",
1093
- // "value": -2.71,
1094
- // "fundsBefore": { "total": 766.06, "available": 766.06, "locked": 0 },
1095
- // "fundsAfter": { "total": 763.35,"available": 763.35, "locked": 0 },
1096
- // "change": { "total": -2.71, "available": -2.71, "locked": 0 }
1097
- // }
1098
- //
1099
- // TRANSACTION_OFFER_COMPLETED_RETURN
1100
- // {
1101
- // "historyId": "cac69b04-c518-4dc5-9d86-e76e91f2e1d2",
1102
- // "balance": {
1103
- // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
1104
- // "currency": "BTC",
1105
- // "type": "CRYPTO",
1106
- // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1107
- // "name": "BTC"
1108
- // },
1109
- // "detailId": null,
1110
- // "time": 1520714886425,
1111
- // "type": "TRANSACTION_OFFER_COMPLETED_RETURN",
1112
- // "value": 0.00000196,
1113
- // "fundsBefore": { "total": 0.00941208, "available": 0.00941012, "locked": 0.00000196 },
1114
- // "fundsAfter": { "total": 0.00941208, "available": 0.00941208, "locked": 0 },
1115
- // "change": { "total": 0, "available": 0.00000196, "locked": -0.00000196 }
1116
- // }
1117
- //
1118
- // WITHDRAWAL_LOCK_FUNDS
1119
- // {
1120
- // "historyId": "03de2271-66ab-4960-a786-87ab9551fc14",
1121
- // "balance": {
1122
- // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
1123
- // "currency": "BTC",
1124
- // "type": "CRYPTO",
1125
- // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1126
- // "name": "BTC"
1127
- // },
1128
- // "detailId": "6ad3dc72-1d6d-4ec2-8436-ca43f85a38a6",
1129
- // "time": 1522245654481,
1130
- // "type": "WITHDRAWAL_LOCK_FUNDS",
1131
- // "value": -0.8,
1132
- // "fundsBefore": { "total": 0.8, "available": 0.8, "locked": 0 },
1133
- // "fundsAfter": { "total": 0.8, "available": 0, "locked": 0.8 },
1134
- // "change": { "total": 0, "available": -0.8, "locked": 0.8 }
1135
- // }
1136
- //
1137
- // WITHDRAWAL_SUBTRACT_FUNDS
1138
- // {
1139
- // "historyId": "b0308c89-5288-438d-a306-c6448b1a266d",
1140
- // "balance": {
1141
- // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
1142
- // "currency": "BTC",
1143
- // "type": "CRYPTO",
1144
- // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1145
- // "name": "BTC"
1146
- // },
1147
- // "detailId": "6ad3dc72-1d6d-4ec2-8436-ca43f85a38a6",
1148
- // "time": 1522246526186,
1149
- // "type": "WITHDRAWAL_SUBTRACT_FUNDS",
1150
- // "value": -0.8,
1151
- // "fundsBefore": { "total": 0.8, "available": 0, "locked": 0.8 },
1152
- // "fundsAfter": { "total": 0, "available": 0, "locked": 0 },
1153
- // "change": { "total": -0.8, "available": 0, "locked": -0.8 }
1154
- // }
1155
- //
1156
- // TRANSACTION_OFFER_ABORTED_RETURN
1157
- // {
1158
- // "historyId": "b1a3c075-d403-4e05-8f32-40512cdd88c0",
1159
- // "balance": {
1160
- // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
1161
- // "currency": "BTC",
1162
- // "type": "CRYPTO",
1163
- // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1164
- // "name": "BTC"
1165
- // },
1166
- // "detailId": null,
1167
- // "time": 1522512298662,
1168
- // "type": "TRANSACTION_OFFER_ABORTED_RETURN",
1169
- // "value": 0.0564931,
1170
- // "fundsBefore": { "total": 0.44951311, "available": 0.39302001, "locked": 0.0564931 },
1171
- // "fundsAfter": { "total": 0.44951311, "available": 0.44951311, "locked": 0 },
1172
- // "change": { "total": 0, "available": 0.0564931, "locked": -0.0564931 }
1173
- // }
1174
- //
1175
- // WITHDRAWAL_UNLOCK_FUNDS
1176
- // {
1177
- // "historyId": "0ed569a2-c330-482e-bb89-4cb553fb5b11",
1178
- // "balance": {
1179
- // "id": "3a7e7a1e-0324-49d5-8f59-298505ebd6c7",
1180
- // "currency": "BTC",
1181
- // "type": "CRYPTO",
1182
- // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1183
- // "name": "BTC"
1184
- // },
1185
- // "detailId": "0c7be256-c336-4111-bee7-4eb22e339700",
1186
- // "time": 1527866360785,
1187
- // "type": "WITHDRAWAL_UNLOCK_FUNDS",
1188
- // "value": 0.05045,
1189
- // "fundsBefore": { "total": 0.86001578, "available": 0.80956578, "locked": 0.05045 },
1190
- // "fundsAfter": { "total": 0.86001578, "available": 0.86001578, "locked": 0 },
1191
- // "change": { "total": 0, "available": 0.05045, "locked": -0.05045 }
1192
- // }
1193
- //
1194
- // TRANSACTION_COMMISSION_RETURN
1195
- // {
1196
- // "historyId": "07c89c27-46f1-4d7a-8518-b73798bf168a",
1197
- // "balance": {
1198
- // "id": "ab43023b-4079-414c-b340-056e3430a3af",
1199
- // "currency": "EUR",
1200
- // "type": "FIAT",
1201
- // "userId": "a34d361d-7bad-49c1-888e-62473b75d877",
1202
- // "name": "EUR"
1203
- // },
1204
- // "detailId": null,
1205
- // "time": 1528304043063,
1206
- // "type": "TRANSACTION_COMMISSION_RETURN",
1207
- // "value": 0.6,
1208
- // "fundsBefore": { "total": 0, "available": 0, "locked": 0 },
1209
- // "fundsAfter": { "total": 0.6, "available": 0.6, "locked": 0 },
1210
- // "change": { "total": 0.6, "available": 0.6, "locked": 0 }
1211
- // }
1212
- //
1213
- const timestamp = this.safeInteger(item, 'time');
1214
- const balance = this.safeValue(item, 'balance', {});
1215
- const currencyId = this.safeString(balance, 'currency');
1216
- currency = this.safeCurrency(currencyId, currency);
1217
- const change = this.safeValue(item, 'change', {});
1218
- let amount = this.safeString(change, 'total');
1219
- let direction = 'in';
1220
- if (Precise["default"].stringLt(amount, '0')) {
1221
- direction = 'out';
1222
- amount = Precise["default"].stringNeg(amount);
1223
- }
1224
- // there are 2 undocumented api calls: (v1_01PrivateGetPaymentsDepositDetailId and v1_01PrivateGetPaymentsWithdrawalDetailId)
1225
- // that can be used to enrich the transfers with txid, address etc (you need to use info.detailId as a parameter)
1226
- const fundsBefore = this.safeValue(item, 'fundsBefore', {});
1227
- const fundsAfter = this.safeValue(item, 'fundsAfter', {});
1228
- return this.safeLedgerEntry({
1229
- 'info': item,
1230
- 'id': this.safeString(item, 'historyId'),
1231
- 'direction': direction,
1232
- 'account': undefined,
1233
- 'referenceId': this.safeString(item, 'detailId'),
1234
- 'referenceAccount': undefined,
1235
- 'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
1236
- 'currency': this.safeCurrencyCode(currencyId),
1237
- 'amount': this.parseNumber(amount),
1238
- 'before': this.safeNumber(fundsBefore, 'total'),
1239
- 'after': this.safeNumber(fundsAfter, 'total'),
1240
- 'status': 'ok',
1241
- 'timestamp': timestamp,
1242
- 'datetime': this.iso8601(timestamp),
1243
- 'fee': undefined,
1244
- }, currency);
1245
- }
1246
- parseLedgerEntryType(type) {
1247
- const types = {
1248
- 'ADD_FUNDS': 'transaction',
1249
- 'BITCOIN_GOLD_FORK': 'transaction',
1250
- 'CREATE_BALANCE': 'transaction',
1251
- 'FUNDS_MIGRATION': 'transaction',
1252
- 'WITHDRAWAL_LOCK_FUNDS': 'transaction',
1253
- 'WITHDRAWAL_SUBTRACT_FUNDS': 'transaction',
1254
- 'WITHDRAWAL_UNLOCK_FUNDS': 'transaction',
1255
- 'TRANSACTION_COMMISSION_OUTCOME': 'fee',
1256
- 'TRANSACTION_COMMISSION_RETURN': 'fee',
1257
- 'TRANSACTION_OFFER_ABORTED_RETURN': 'trade',
1258
- 'TRANSACTION_OFFER_COMPLETED_RETURN': 'trade',
1259
- 'TRANSACTION_POST_INCOME': 'trade',
1260
- 'TRANSACTION_POST_OUTCOME': 'trade',
1261
- 'TRANSACTION_PRE_LOCKING': 'trade',
1262
- };
1263
- return this.safeString(types, type, type);
1264
- }
1265
- parseOHLCV(ohlcv, market = undefined) {
1266
- //
1267
- // [
1268
- // "1582399800000",
1269
- // {
1270
- // "o": "0.0001428",
1271
- // "c": "0.0001428",
1272
- // "h": "0.0001428",
1273
- // "l": "0.0001428",
1274
- // "v": "4",
1275
- // "co": "1"
1276
- // }
1277
- // ]
1278
- //
1279
- const first = this.safeValue(ohlcv, 1, {});
1280
- return [
1281
- this.safeInteger(ohlcv, 0),
1282
- this.safeNumber(first, 'o'),
1283
- this.safeNumber(first, 'h'),
1284
- this.safeNumber(first, 'l'),
1285
- this.safeNumber(first, 'c'),
1286
- this.safeNumber(first, 'v'),
1287
- ];
1288
- }
1289
- /**
1290
- * @method
1291
- * @name zonda#fetchOHLCV
1292
- * @see https://docs.zondacrypto.exchange/reference/candles-chart
1293
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1294
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1295
- * @param {string} timeframe the length of time each candle represents
1296
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
1297
- * @param {int} [limit] the maximum amount of candles to fetch
1298
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1299
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1300
- */
1301
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1302
- await this.loadMarkets();
1303
- const market = this.market(symbol);
1304
- const tradingSymbol = market['baseId'] + '-' + market['quoteId'];
1305
- const request = {
1306
- 'symbol': tradingSymbol,
1307
- 'resolution': this.safeString(this.timeframes, timeframe, timeframe),
1308
- // 'from': 1574709092000, // unix timestamp in milliseconds, required
1309
- // 'to': 1574709092000, // unix timestamp in milliseconds, required
1310
- };
1311
- if (limit === undefined) {
1312
- limit = 100;
1313
- }
1314
- else {
1315
- limit = Math.min(limit, 11000); // supports up to 11k candles diapason
1316
- }
1317
- const duration = this.parseTimeframe(timeframe);
1318
- const timerange = limit * duration * 1000;
1319
- if (since === undefined) {
1320
- request['to'] = this.milliseconds();
1321
- request['from'] = request['to'] - timerange;
1322
- }
1323
- else {
1324
- request['from'] = since;
1325
- request['to'] = this.sum(request['from'], timerange);
1326
- }
1327
- const response = await this.v1_01PublicGetTradingCandleHistorySymbolResolution(this.extend(request, params));
1328
- //
1329
- // {
1330
- // "status":"Ok",
1331
- // "items":[
1332
- // ["1591503060000",{"o":"0.02509572","c":"0.02509438","h":"0.02509664","l":"0.02509438","v":"0.02082165","co":"17"}],
1333
- // ["1591503120000",{"o":"0.02509606","c":"0.02509515","h":"0.02509606","l":"0.02509487","v":"0.04971703","co":"13"}],
1334
- // ["1591503180000",{"o":"0.02509532","c":"0.02509589","h":"0.02509589","l":"0.02509454","v":"0.01332236","co":"7"}],
1335
- // ]
1336
- // }
1337
- //
1338
- const items = this.safeList(response, 'items', []);
1339
- return this.parseOHLCVs(items, market, timeframe, since, limit);
1340
- }
1341
- parseTrade(trade, market = undefined) {
1342
- //
1343
- // createOrder trades
1344
- //
1345
- // {
1346
- // "rate": "0.02195928",
1347
- // "amount": "0.00167952"
1348
- // }
1349
- //
1350
- // fetchMyTrades (private)
1351
- //
1352
- // {
1353
- // "amount": "0.29285199",
1354
- // "commissionValue": "0.00125927",
1355
- // "id": "11c8203a-a267-11e9-b698-0242ac110007",
1356
- // "initializedBy": "Buy",
1357
- // "market": "ETH-EUR",
1358
- // "offerId": "11c82038-a267-11e9-b698-0242ac110007",
1359
- // "rate": "277",
1360
- // "time": "1562689917517",
1361
- // "userAction": "Buy",
1362
- // "wasTaker": true,
1363
- // }
1364
- //
1365
- // fetchTrades (public)
1366
- //
1367
- // {
1368
- // "id": "df00b0da-e5e0-11e9-8c19-0242ac11000a",
1369
- // "t": "1570108958831",
1370
- // "a": "0.04776653",
1371
- // "r": "0.02145854",
1372
- // "ty": "Sell"
1373
- // }
1374
- //
1375
- const timestamp = this.safeInteger2(trade, 'time', 't');
1376
- const side = this.safeStringLower2(trade, 'userAction', 'ty');
1377
- const wasTaker = this.safeValue(trade, 'wasTaker');
1378
- let takerOrMaker = undefined;
1379
- if (wasTaker !== undefined) {
1380
- takerOrMaker = wasTaker ? 'taker' : 'maker';
1381
- }
1382
- const priceString = this.safeString2(trade, 'rate', 'r');
1383
- const amountString = this.safeString2(trade, 'amount', 'a');
1384
- const feeCostString = this.safeString(trade, 'commissionValue');
1385
- const marketId = this.safeString(trade, 'market');
1386
- market = this.safeMarket(marketId, market, '-');
1387
- const symbol = market['symbol'];
1388
- let fee = undefined;
1389
- if (feeCostString !== undefined) {
1390
- const feeCurrency = (side === 'buy') ? market['base'] : market['quote'];
1391
- fee = {
1392
- 'currency': feeCurrency,
1393
- 'cost': feeCostString,
1394
- };
1395
- }
1396
- const order = this.safeString(trade, 'offerId');
1397
- // todo: check this logic
1398
- let type = undefined;
1399
- if (order !== undefined) {
1400
- type = order ? 'limit' : 'market';
1401
- }
1402
- return this.safeTrade({
1403
- 'id': this.safeString(trade, 'id'),
1404
- 'order': order,
1405
- 'timestamp': timestamp,
1406
- 'datetime': this.iso8601(timestamp),
1407
- 'symbol': symbol,
1408
- 'type': type,
1409
- 'side': side,
1410
- 'price': priceString,
1411
- 'amount': amountString,
1412
- 'cost': undefined,
1413
- 'takerOrMaker': takerOrMaker,
1414
- 'fee': fee,
1415
- 'info': trade,
1416
- }, market);
1417
- }
1418
- /**
1419
- * @method
1420
- * @name zonda#fetchTrades
1421
- * @see https://docs.zondacrypto.exchange/reference/last-transactions
1422
- * @description get the list of most recent trades for a particular symbol
1423
- * @param {string} symbol unified symbol of the market to fetch trades for
1424
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
1425
- * @param {int} [limit] the maximum amount of trades to fetch
1426
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1427
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
1428
- */
1429
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1430
- await this.loadMarkets();
1431
- const market = this.market(symbol);
1432
- const tradingSymbol = market['baseId'] + '-' + market['quoteId'];
1433
- const request = {
1434
- 'symbol': tradingSymbol,
1435
- };
1436
- if (since !== undefined) {
1437
- request['fromTime'] = since - 1; // result does not include exactly `since` time therefore decrease by 1
1438
- }
1439
- if (limit !== undefined) {
1440
- request['limit'] = limit; // default - 10, max - 300
1441
- }
1442
- const response = await this.v1_01PublicGetTradingTransactionsSymbol(this.extend(request, params));
1443
- const items = this.safeList(response, 'items');
1444
- return this.parseTrades(items, market, since, limit);
1445
- }
1446
- /**
1447
- * @method
1448
- * @name zonda#createOrder
1449
- * @description create a trade order
1450
- * @see https://docs.zondacrypto.exchange/reference/new-order
1451
- * @param {string} symbol unified symbol of the market to create an order in
1452
- * @param {string} type 'market' or 'limit'
1453
- * @param {string} side 'buy' or 'sell'
1454
- * @param {float} amount how much of currency you want to trade in units of base currency
1455
- * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1456
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1457
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
1458
- */
1459
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1460
- await this.loadMarkets();
1461
- const market = this.market(symbol);
1462
- const tradingSymbol = market['baseId'] + '-' + market['quoteId'];
1463
- amount = parseFloat(this.amountToPrecision(symbol, amount));
1464
- const request = {
1465
- 'symbol': tradingSymbol,
1466
- 'offerType': side.toUpperCase(),
1467
- 'amount': amount,
1468
- };
1469
- const stopLossPrice = this.safeValue2(params, 'stopPrice', 'stopLossPrice');
1470
- const isStopLossPrice = stopLossPrice !== undefined;
1471
- const isLimitOrder = type === 'limit';
1472
- const isMarketOrder = type === 'market';
1473
- const isStopLimit = (type === 'stop-limit') || (isLimitOrder && isStopLossPrice);
1474
- const isStopMarket = type === 'stop-market' || (isMarketOrder && isStopLossPrice);
1475
- const isStopOrder = isStopLimit || isStopMarket;
1476
- if (isLimitOrder || isStopLimit) {
1477
- request['rate'] = this.priceToPrecision(symbol, price);
1478
- request['mode'] = isStopLimit ? 'stop-limit' : 'limit';
1479
- }
1480
- else if (isMarketOrder || isStopMarket) {
1481
- request['mode'] = isStopMarket ? 'stop-market' : 'market';
1482
- }
1483
- else {
1484
- throw new errors.ExchangeError(this.id + ' createOrder() invalid type');
1485
- }
1486
- params = this.omit(params, ['stopPrice', 'stopLossPrice']);
1487
- let response = undefined;
1488
- if (isStopOrder) {
1489
- if (!isStopLossPrice) {
1490
- throw new errors.ExchangeError(this.id + ' createOrder() zonda requires `triggerPrice` parameter for stop-limit or stop-market orders');
1491
- }
1492
- request['stopRate'] = this.priceToPrecision(symbol, stopLossPrice);
1493
- response = await this.v1_01PrivatePostTradingStopOfferSymbol(this.extend(request, params));
1494
- }
1495
- else {
1496
- response = await this.v1_01PrivatePostTradingOfferSymbol(this.extend(request, params));
1497
- }
1498
- //
1499
- // unfilled (open order)
1500
- //
1501
- // {
1502
- // "status": "Ok",
1503
- // "completed": false, // can deduce status from here
1504
- // "offerId": "ce9cc72e-d61c-11e9-9248-0242ac110005",
1505
- // "transactions": [], // can deduce order info from here
1506
- // }
1507
- //
1508
- // filled (closed order)
1509
- //
1510
- // {
1511
- // "status": "Ok",
1512
- // "offerId": "942a4a3e-e922-11e9-8c19-0242ac11000a",
1513
- // "completed": true,
1514
- // "transactions": [
1515
- // {
1516
- // "rate": "0.02195928",
1517
- // "amount": "0.00167952"
1518
- // },
1519
- // {
1520
- // "rate": "0.02195928",
1521
- // "amount": "0.00167952"
1522
- // },
1523
- // {
1524
- // "rate": "0.02196207",
1525
- // "amount": "0.27704177"
1526
- // }
1527
- // ]
1528
- // }
1529
- //
1530
- // partially-filled (open order)
1531
- //
1532
- // {
1533
- // "status": "Ok",
1534
- // "offerId": "d0ebefab-f4d7-11e9-8c19-0242ac11000a",
1535
- // "completed": false,
1536
- // "transactions": [
1537
- // {
1538
- // "rate": "0.02106404",
1539
- // "amount": "0.0019625"
1540
- // },
1541
- // {
1542
- // "rate": "0.02106404",
1543
- // "amount": "0.0019625"
1544
- // },
1545
- // {
1546
- // "rate": "0.02105901",
1547
- // "amount": "0.00975256"
1548
- // }
1549
- // ]
1550
- // }
1551
- //
1552
- const id = this.safeString2(response, 'offerId', 'stopOfferId');
1553
- const completed = this.safeBool(response, 'completed', false);
1554
- const status = completed ? 'closed' : 'open';
1555
- const transactions = this.safeValue(response, 'transactions');
1556
- return this.safeOrder({
1557
- 'id': id,
1558
- 'info': response,
1559
- 'timestamp': undefined,
1560
- 'datetime': undefined,
1561
- 'lastTradeTimestamp': undefined,
1562
- 'status': status,
1563
- 'symbol': symbol,
1564
- 'type': type,
1565
- 'side': side,
1566
- 'price': price,
1567
- 'amount': amount,
1568
- 'cost': undefined,
1569
- 'filled': undefined,
1570
- 'remaining': undefined,
1571
- 'average': undefined,
1572
- 'fee': undefined,
1573
- 'trades': transactions,
1574
- 'clientOrderId': undefined,
1575
- });
1576
- }
1577
- /**
1578
- * @method
1579
- * @name zonda#cancelOrder
1580
- * @see https://docs.zondacrypto.exchange/reference/cancel-order
1581
- * @description cancels an open order
1582
- * @param {string} id order id
1583
- * @param {string} symbol unified symbol of the market the order was made in
1584
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1585
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
1586
- */
1587
- async cancelOrder(id, symbol = undefined, params = {}) {
1588
- const side = this.safeString(params, 'side');
1589
- if (side === undefined) {
1590
- throw new errors.ExchangeError(this.id + ' cancelOrder() requires a `side` parameter ("buy" or "sell")');
1591
- }
1592
- const price = this.safeValue(params, 'price');
1593
- if (price === undefined) {
1594
- throw new errors.ExchangeError(this.id + ' cancelOrder() requires a `price` parameter (float or string)');
1595
- }
1596
- await this.loadMarkets();
1597
- const market = this.market(symbol);
1598
- const tradingSymbol = market['baseId'] + '-' + market['quoteId'];
1599
- const request = {
1600
- 'symbol': tradingSymbol,
1601
- 'id': id,
1602
- 'side': side,
1603
- 'price': price,
1604
- };
1605
- const response = await this.v1_01PrivateDeleteTradingOfferSymbolIdSidePrice(this.extend(request, params));
1606
- // { status: "Fail", errors: [ "NOT_RECOGNIZED_OFFER_TYPE" ] } -- if required params are missing
1607
- // { status: "Ok", errors: [] }
1608
- return this.parseOrder(response);
1609
- }
1610
- isFiat(currency) {
1611
- const fiatCurrencies = {
1612
- 'USD': true,
1613
- 'EUR': true,
1614
- 'PLN': true,
1615
- };
1616
- return this.safeBool(fiatCurrencies, currency, false);
1617
- }
1618
- parseDepositAddress(depositAddress, currency = undefined) {
1619
- //
1620
- // {
1621
- // "address": "33u5YAEhQbYfjHHPsfMfCoSdEjfwYjVcBE",
1622
- // "currency": "BTC",
1623
- // "balanceId": "5d5d19e7-2265-49c7-af9a-047bcf384f21",
1624
- // "balanceEngine": "BITBAY",
1625
- // "tag": null
1626
- // }
1627
- //
1628
- const currencyId = this.safeString(depositAddress, 'currency');
1629
- const address = this.safeString(depositAddress, 'address');
1630
- this.checkAddress(address);
1631
- return {
1632
- 'info': depositAddress,
1633
- 'currency': this.safeCurrencyCode(currencyId, currency),
1634
- 'network': undefined,
1635
- 'address': address,
1636
- 'tag': this.safeString(depositAddress, 'tag'),
1637
- };
1638
- }
1639
- /**
1640
- * @method
1641
- * @name zonda#fetchDepositAddress
1642
- * @see https://docs.zondacrypto.exchange/reference/deposit-addresses-for-crypto
1643
- * @description fetch the deposit address for a currency associated with this account
1644
- * @param {string} code unified currency code
1645
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1646
- * @param {string} [params.walletId] Wallet id to filter deposit adresses.
1647
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
1648
- */
1649
- async fetchDepositAddress(code, params = {}) {
1650
- await this.loadMarkets();
1651
- const currency = this.currency(code);
1652
- const request = {
1653
- 'currency': currency['id'],
1654
- };
1655
- const response = await this.v1_01PrivateGetApiPaymentsDepositsCryptoAddresses(this.extend(request, params));
1656
- //
1657
- // {
1658
- // "status": "Ok",
1659
- // "data": [{
1660
- // "address": "33u5YAEhQbYfjHHPsfMfCoSdEjfwYjVcBE",
1661
- // "currency": "BTC",
1662
- // "balanceId": "5d5d19e7-2265-49c7-af9a-047bcf384f21",
1663
- // "balanceEngine": "BITBAY",
1664
- // "tag": null
1665
- // }
1666
- // ]
1667
- // }
1668
- //
1669
- const data = this.safeValue(response, 'data');
1670
- const first = this.safeDict(data, 0);
1671
- return this.parseDepositAddress(first, currency);
1672
- }
1673
- /**
1674
- * @method
1675
- * @name zonda#fetchDepositAddresses
1676
- * @see https://docs.zondacrypto.exchange/reference/deposit-addresses-for-crypto
1677
- * @description fetch deposit addresses for multiple currencies and chain types
1678
- * @param {string[]|undefined} codes zonda does not support filtering filtering by multiple codes and will ignore this parameter.
1679
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1680
- * @returns {object} a list of [address structures]{@link https://docs.ccxt.com/?id=address-structure}
1681
- */
1682
- async fetchDepositAddresses(codes = undefined, params = {}) {
1683
- await this.loadMarkets();
1684
- const response = await this.v1_01PrivateGetApiPaymentsDepositsCryptoAddresses(params);
1685
- //
1686
- // {
1687
- // "status": "Ok",
1688
- // "data": [{
1689
- // "address": "33u5YAEhQbYfjHHPsfMfCoSdEjfwYjVcBE",
1690
- // "currency": "BTC",
1691
- // "balanceId": "5d5d19e7-2265-49c7-af9a-047bcf384f21",
1692
- // "balanceEngine": "BITBAY",
1693
- // "tag": null
1694
- // }
1695
- // ]
1696
- // }
1697
- //
1698
- const data = this.safeList(response, 'data');
1699
- return this.parseDepositAddresses(data, codes);
1700
- }
1701
- /**
1702
- * @method
1703
- * @name zonda#transfer
1704
- * @see https://docs.zondacrypto.exchange/reference/internal-transfer
1705
- * @description transfer currency internally between wallets on the same account
1706
- * @param {string} code unified currency code
1707
- * @param {float} amount amount to transfer
1708
- * @param {string} fromAccount account to transfer from
1709
- * @param {string} toAccount account to transfer to
1710
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1711
- * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/?id=transfer-structure}
1712
- */
1713
- async transfer(code, amount, fromAccount, toAccount, params = {}) {
1714
- await this.loadMarkets();
1715
- const currency = this.currency(code);
1716
- const request = {
1717
- 'source': fromAccount,
1718
- 'destination': toAccount,
1719
- 'currency': code,
1720
- 'funds': this.currencyToPrecision(code, amount),
1721
- };
1722
- const response = await this.v1_01PrivatePostBalancesBITBAYBalanceTransferSourceDestination(this.extend(request, params));
1723
- //
1724
- // {
1725
- // "status": "Ok",
1726
- // "from": {
1727
- // "id": "ad9397c5-3bd9-4372-82ba-22da6a90cb56",
1728
- // "userId": "4bc43956-423f-47fd-9faa-acd37c58ed9f",
1729
- // "availableFunds": 0.01803472,
1730
- // "totalFunds": 0.01804161,
1731
- // "lockedFunds": 0.00000689,
1732
- // "currency": "BTC",
1733
- // "type": "CRYPTO",
1734
- // "name": "BTC",
1735
- // "balanceEngine": "BITBAY"
1736
- // },
1737
- // "to": {
1738
- // "id": "01931d52-536b-4ca5-a9f4-be28c86d0cc3",
1739
- // "userId": "4bc43956-423f-47fd-9faa-acd37c58ed9f",
1740
- // "availableFunds": 0.0001,
1741
- // "totalFunds": 0.0001,
1742
- // "lockedFunds": 0,
1743
- // "currency": "BTC",
1744
- // "type": "CRYPTO",
1745
- // "name": "Prowizja",
1746
- // "balanceEngine": "BITBAY"
1747
- // },
1748
- // "errors": null
1749
- // }
1750
- //
1751
- const transfer = this.parseTransfer(response, currency);
1752
- const transferOptions = this.safeValue(this.options, 'transfer', {});
1753
- const fillResponseFromRequest = this.safeBool(transferOptions, 'fillResponseFromRequest', true);
1754
- if (fillResponseFromRequest) {
1755
- transfer['amount'] = amount;
1756
- }
1757
- return transfer;
1758
- }
1759
- parseTransfer(transfer, currency = undefined) {
1760
- //
1761
- // {
1762
- // "status": "Ok",
1763
- // "from": {
1764
- // "id": "ad9397c5-3bd9-4372-82ba-22da6a90cb56",
1765
- // "userId": "4bc43956-423f-47fd-9faa-acd37c58ed9f",
1766
- // "availableFunds": 0.01803472,
1767
- // "totalFunds": 0.01804161,
1768
- // "lockedFunds": 0.00000689,
1769
- // "currency": "BTC",
1770
- // "type": "CRYPTO",
1771
- // "name": "BTC",
1772
- // "balanceEngine": "BITBAY"
1773
- // },
1774
- // "to": {
1775
- // "id": "01931d52-536b-4ca5-a9f4-be28c86d0cc3",
1776
- // "userId": "4bc43956-423f-47fd-9faa-acd37c58ed9f",
1777
- // "availableFunds": 0.0001,
1778
- // "totalFunds": 0.0001,
1779
- // "lockedFunds": 0,
1780
- // "currency": "BTC",
1781
- // "type": "CRYPTO",
1782
- // "name": "Prowizja",
1783
- // "balanceEngine": "BITBAY"
1784
- // },
1785
- // "errors": null
1786
- // }
1787
- //
1788
- const status = this.safeString(transfer, 'status');
1789
- const fromAccount = this.safeValue(transfer, 'from', {});
1790
- const fromId = this.safeString(fromAccount, 'id');
1791
- const to = this.safeValue(transfer, 'to', {});
1792
- const toId = this.safeString(to, 'id');
1793
- const currencyId = this.safeString(fromAccount, 'currency');
1794
- return {
1795
- 'info': transfer,
1796
- 'id': undefined,
1797
- 'timestamp': undefined,
1798
- 'datetime': undefined,
1799
- 'currency': this.safeCurrencyCode(currencyId, currency),
1800
- 'amount': undefined,
1801
- 'fromAccount': fromId,
1802
- 'toAccount': toId,
1803
- 'status': this.parseTransferStatus(status),
1804
- };
1805
- }
1806
- parseTransferStatus(status) {
1807
- const statuses = {
1808
- 'Ok': 'ok',
1809
- 'Fail': 'failed',
1810
- };
1811
- return this.safeString(statuses, status, status);
1812
- }
1813
- /**
1814
- * @method
1815
- * @name zonda#withdraw
1816
- * @see https://docs.zondacrypto.exchange/reference/crypto-withdrawal-1
1817
- * @description make a withdrawal
1818
- * @param {string} code unified currency code
1819
- * @param {float} amount the amount to withdraw
1820
- * @param {string} address the address to withdraw to
1821
- * @param {string} tag
1822
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1823
- * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
1824
- */
1825
- async withdraw(code, amount, address, tag = undefined, params = {}) {
1826
- [tag, params] = this.handleWithdrawTagAndParams(tag, params);
1827
- this.checkAddress(address);
1828
- await this.loadMarkets();
1829
- let response = undefined;
1830
- const currency = this.currency(code);
1831
- const request = {
1832
- 'currency': currency['id'],
1833
- 'amount': amount,
1834
- 'address': address,
1835
- // request['balanceId'] = params['balanceId']; // Wallet id used for withdrawal. If not provided, any BITBAY wallet with sufficient funds is used. If BITBAYPAY wallet should be used parameter must be explicitly specified.
1836
- };
1837
- if (this.isFiat(code)) {
1838
- // request['swift'] = params['swift']; // Bank identifier, if required.
1839
- response = await this.v1_01PrivatePostApiPaymentsWithdrawalsFiat(this.extend(request, params));
1840
- }
1841
- else {
1842
- if (tag !== undefined) {
1843
- request['tag'] = tag;
1844
- }
1845
- response = await this.v1_01PrivatePostApiPaymentsWithdrawalsCrypto(this.extend(request, params));
1846
- }
1847
- //
1848
- // {
1849
- // "status": "Ok",
1850
- // "data": {
1851
- // "id": "65e01087-afb0-4ab2-afdb-cc925e360296"
1852
- // }
1853
- // }
1854
- //
1855
- const data = this.safeDict(response, 'data');
1856
- return this.parseTransaction(data, currency);
1857
- }
1858
- parseTransaction(transaction, currency = undefined) {
1859
- //
1860
- // withdraw
1861
- //
1862
- // {
1863
- // "id": "65e01087-afb0-4ab2-afdb-cc925e360296"
1864
- // }
1865
- //
1866
- currency = this.safeCurrency(undefined, currency);
1867
- return {
1868
- 'id': this.safeString(transaction, 'id'),
1869
- 'txid': undefined,
1870
- 'timestamp': undefined,
1871
- 'datetime': undefined,
1872
- 'network': undefined,
1873
- 'addressFrom': undefined,
1874
- 'address': undefined,
1875
- 'addressTo': undefined,
1876
- 'amount': undefined,
1877
- 'type': undefined,
1878
- 'currency': currency['code'],
1879
- 'status': undefined,
1880
- 'updated': undefined,
1881
- 'tagFrom': undefined,
1882
- 'tag': undefined,
1883
- 'tagTo': undefined,
1884
- 'comment': undefined,
1885
- 'internal': undefined,
1886
- 'fee': undefined,
1887
- 'info': transaction,
1888
- };
1889
- }
1890
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1891
- let url = this.implodeHostname(this.urls['api'][api]);
1892
- if (api === 'public') {
1893
- const query = this.omit(params, this.extractParams(path));
1894
- url += '/' + this.implodeParams(path, params) + '.json';
1895
- if (Object.keys(query).length) {
1896
- url += '?' + this.urlencode(query);
1897
- }
1898
- }
1899
- else if (api === 'v1_01Public') {
1900
- const query = this.omit(params, this.extractParams(path));
1901
- url += '/' + this.implodeParams(path, params);
1902
- if (Object.keys(query).length) {
1903
- url += '?' + this.urlencode(query);
1904
- }
1905
- }
1906
- else if (api === 'v1_01Private') {
1907
- this.checkRequiredCredentials();
1908
- const query = this.omit(params, this.extractParams(path));
1909
- url += '/' + this.implodeParams(path, params);
1910
- const nonce = this.milliseconds().toString();
1911
- let payload = undefined;
1912
- if (method !== 'POST') {
1913
- if (Object.keys(query).length) {
1914
- url += '?' + this.urlencode(query);
1915
- }
1916
- payload = this.apiKey + nonce;
1917
- }
1918
- else if (body === undefined) {
1919
- body = this.json(query);
1920
- payload = this.apiKey + nonce + body;
1921
- }
1922
- headers = {
1923
- 'Request-Timestamp': nonce,
1924
- 'Operation-Id': this.uuid(),
1925
- 'API-Key': this.apiKey,
1926
- 'API-Hash': this.hmac(this.encode(payload), this.encode(this.secret), sha512.sha512),
1927
- 'Content-Type': 'application/json',
1928
- };
1929
- }
1930
- else {
1931
- this.checkRequiredCredentials();
1932
- body = this.urlencode(this.extend({
1933
- 'method': path,
1934
- 'moment': this.nonce(),
1935
- }, params));
1936
- headers = {
1937
- 'Content-Type': 'application/x-www-form-urlencoded',
1938
- 'API-Key': this.apiKey,
1939
- 'API-Hash': this.hmac(this.encode(body), this.encode(this.secret), sha512.sha512),
1940
- };
1941
- }
1942
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1943
- }
1944
- handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1945
- if (response === undefined) {
1946
- return undefined; // fallback to default error handler
1947
- }
1948
- if ('code' in response) {
1949
- //
1950
- // bitbay returns the integer "success": 1 key from their private API
1951
- // or an integer "code" value from 0 to 510 and an error message
1952
- //
1953
- // { "success": 1, ... }
1954
- // { 'code': 502, "message": "Invalid sign" }
1955
- // { 'code': 0, "message": "offer funds not exceeding minimums" }
1956
- //
1957
- // 400 At least one parameter wasn't set
1958
- // 401 Invalid order type
1959
- // 402 No orders with specified currencies
1960
- // 403 Invalid payment currency name
1961
- // 404 Error. Wrong transaction type
1962
- // 405 Order with this id doesn't exist
1963
- // 406 No enough money or crypto
1964
- // 408 Invalid currency name
1965
- // 501 Invalid public key
1966
- // 502 Invalid sign
1967
- // 503 Invalid moment parameter. Request time doesn't match current server time
1968
- // 504 Invalid method
1969
- // 505 Key has no permission for this action
1970
- // 506 Account locked. Please contact with customer service
1971
- // 509 The BIC/SWIFT is required for this currency
1972
- // 510 Invalid market name
1973
- //
1974
- const code = this.safeString(response, 'code'); // always an integer
1975
- const feedback = this.id + ' ' + body;
1976
- this.throwExactlyMatchedException(this.exceptions, code, feedback);
1977
- throw new errors.ExchangeError(feedback);
1978
- }
1979
- else if ('status' in response) {
1980
- //
1981
- // {"status":"Fail","errors":["OFFER_FUNDS_NOT_EXCEEDING_MINIMUMS"]}
1982
- //
1983
- const status = this.safeString(response, 'status');
1984
- if (status === 'Fail') {
1985
- const errors$1 = this.safeValue(response, 'errors');
1986
- const feedback = this.id + ' ' + body;
1987
- for (let i = 0; i < errors$1.length; i++) {
1988
- const error = errors$1[i];
1989
- this.throwExactlyMatchedException(this.exceptions, error, feedback);
1990
- }
1991
- throw new errors.ExchangeError(feedback);
1992
- }
1993
- }
1994
- return undefined;
1995
- }
1996
- }
1997
-
1998
- exports["default"] = zonda;