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