ccxt 4.1.51 → 4.1.52

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 (182) hide show
  1. package/README.md +110 -113
  2. package/dist/ccxt.browser.js +1361 -2933
  3. package/dist/ccxt.browser.min.js +7 -7
  4. package/dist/cjs/ccxt.js +1 -7
  5. package/dist/cjs/src/alpaca.js +62 -64
  6. package/dist/cjs/src/ascendex.js +3 -1
  7. package/dist/cjs/src/base/Exchange.js +10 -0
  8. package/dist/cjs/src/bigone.js +60 -77
  9. package/dist/cjs/src/binance.js +1 -0
  10. package/dist/cjs/src/bingx.js +4 -11
  11. package/dist/cjs/src/bitbank.js +58 -59
  12. package/dist/cjs/src/bitbns.js +1 -0
  13. package/dist/cjs/src/bitfinex.js +1 -0
  14. package/dist/cjs/src/bitfinex2.js +1 -0
  15. package/dist/cjs/src/bitflyer.js +1 -0
  16. package/dist/cjs/src/bitget.js +3 -8
  17. package/dist/cjs/src/bithumb.js +1 -0
  18. package/dist/cjs/src/bitmart.js +10 -1
  19. package/dist/cjs/src/bitmex.js +114 -119
  20. package/dist/cjs/src/bitopro.js +63 -65
  21. package/dist/cjs/src/bitpanda.js +60 -60
  22. package/dist/cjs/src/bitrue.js +67 -71
  23. package/dist/cjs/src/bitso.js +1 -0
  24. package/dist/cjs/src/bitstamp.js +1 -0
  25. package/dist/cjs/src/bittrex.js +57 -57
  26. package/dist/cjs/src/bitvavo.js +10 -2
  27. package/dist/cjs/src/blockchaincom.js +2 -2
  28. package/dist/cjs/src/btcalpha.js +59 -60
  29. package/dist/cjs/src/btcmarkets.js +68 -69
  30. package/dist/cjs/src/btcturk.js +72 -74
  31. package/dist/cjs/src/bybit.js +3 -1
  32. package/dist/cjs/src/coinbase.js +7 -2
  33. package/dist/cjs/src/coinbasepro.js +1 -0
  34. package/dist/cjs/src/coincheck.js +1 -0
  35. package/dist/cjs/src/coinex.js +4 -0
  36. package/dist/cjs/src/coinlist.js +60 -60
  37. package/dist/cjs/src/coinmate.js +1 -0
  38. package/dist/cjs/src/coinsph.js +2 -4
  39. package/dist/cjs/src/cryptocom.js +1 -0
  40. package/dist/cjs/src/currencycom.js +2 -2
  41. package/dist/cjs/src/deribit.js +2 -0
  42. package/dist/cjs/src/digifinex.js +5 -2
  43. package/dist/cjs/src/exmo.js +1 -0
  44. package/dist/cjs/src/gate.js +2 -0
  45. package/dist/cjs/src/gemini.js +2 -0
  46. package/dist/cjs/src/hitbtc.js +4 -0
  47. package/dist/cjs/src/hollaex.js +2 -0
  48. package/dist/cjs/src/htx.js +4 -0
  49. package/dist/cjs/src/huobijp.js +2 -0
  50. package/dist/cjs/src/idex.js +2 -0
  51. package/dist/cjs/src/indodax.js +1 -0
  52. package/dist/cjs/src/kraken.js +3 -3
  53. package/dist/cjs/src/kucoin.js +6 -5
  54. package/dist/cjs/src/kuna.js +3 -1
  55. package/dist/cjs/src/latoken.js +1 -0
  56. package/dist/cjs/src/lbank.js +1 -0
  57. package/dist/cjs/src/lykke.js +2 -0
  58. package/dist/cjs/src/mercado.js +1 -0
  59. package/dist/cjs/src/mexc.js +2 -0
  60. package/dist/cjs/src/ndax.js +2 -0
  61. package/dist/cjs/src/novadax.js +1 -0
  62. package/dist/cjs/src/okcoin.js +2 -0
  63. package/dist/cjs/src/okx.js +2 -0
  64. package/dist/cjs/src/phemex.js +2 -0
  65. package/dist/cjs/src/poloniex.js +1 -0
  66. package/dist/cjs/src/pro/binance.js +5 -3
  67. package/dist/cjs/src/pro/coinbase.js +12 -3
  68. package/dist/cjs/src/pro/cryptocom.js +17 -17
  69. package/dist/cjs/src/pro/krakenfutures.js +15 -15
  70. package/dist/cjs/src/probit.js +4 -2
  71. package/dist/cjs/src/tidex.js +1 -0
  72. package/dist/cjs/src/timex.js +2 -0
  73. package/dist/cjs/src/upbit.js +2 -0
  74. package/dist/cjs/src/wavesexchange.js +2 -1
  75. package/dist/cjs/src/whitebit.js +1 -0
  76. package/dist/cjs/src/woo.js +1 -0
  77. package/dist/cjs/src/zaif.js +1 -0
  78. package/dist/cjs/src/zonda.js +1 -0
  79. package/js/ccxt.d.ts +2 -8
  80. package/js/ccxt.js +2 -6
  81. package/js/src/alpaca.d.ts +3 -2
  82. package/js/src/alpaca.js +62 -64
  83. package/js/src/ascendex.js +3 -1
  84. package/js/src/base/Exchange.d.ts +2 -0
  85. package/js/src/base/Exchange.js +10 -0
  86. package/js/src/base/types.d.ts +6 -3
  87. package/js/src/bigone.d.ts +3 -3
  88. package/js/src/bigone.js +60 -77
  89. package/js/src/binance.js +1 -0
  90. package/js/src/bingx.d.ts +2 -2
  91. package/js/src/bingx.js +4 -11
  92. package/js/src/bitbank.d.ts +3 -2
  93. package/js/src/bitbank.js +58 -59
  94. package/js/src/bitbns.js +1 -0
  95. package/js/src/bitfinex.js +1 -0
  96. package/js/src/bitfinex2.js +1 -0
  97. package/js/src/bitflyer.js +1 -0
  98. package/js/src/bitget.d.ts +1 -2
  99. package/js/src/bitget.js +3 -8
  100. package/js/src/bithumb.js +1 -0
  101. package/js/src/bitmart.js +10 -1
  102. package/js/src/bitmex.d.ts +3 -2
  103. package/js/src/bitmex.js +114 -119
  104. package/js/src/bitopro.d.ts +3 -2
  105. package/js/src/bitopro.js +63 -65
  106. package/js/src/bitpanda.d.ts +3 -2
  107. package/js/src/bitpanda.js +60 -60
  108. package/js/src/bitrue.d.ts +3 -2
  109. package/js/src/bitrue.js +67 -71
  110. package/js/src/bitso.js +1 -0
  111. package/js/src/bitstamp.js +1 -0
  112. package/js/src/bittrex.d.ts +3 -2
  113. package/js/src/bittrex.js +57 -57
  114. package/js/src/bitvavo.js +10 -2
  115. package/js/src/blockchaincom.js +2 -2
  116. package/js/src/btcalpha.d.ts +3 -2
  117. package/js/src/btcalpha.js +59 -60
  118. package/js/src/btcmarkets.d.ts +3 -2
  119. package/js/src/btcmarkets.js +68 -69
  120. package/js/src/btcturk.d.ts +3 -2
  121. package/js/src/btcturk.js +72 -74
  122. package/js/src/bybit.js +3 -1
  123. package/js/src/coinbase.js +7 -2
  124. package/js/src/coinbasepro.js +1 -0
  125. package/js/src/coincheck.js +1 -0
  126. package/js/src/coinex.js +4 -0
  127. package/js/src/coinlist.d.ts +3 -2
  128. package/js/src/coinlist.js +60 -60
  129. package/js/src/coinmate.js +1 -0
  130. package/js/src/coinsph.js +2 -4
  131. package/js/src/cryptocom.js +1 -0
  132. package/js/src/currencycom.js +2 -2
  133. package/js/src/deribit.js +2 -0
  134. package/js/src/digifinex.js +5 -2
  135. package/js/src/exmo.js +1 -0
  136. package/js/src/gate.js +2 -0
  137. package/js/src/gemini.js +2 -0
  138. package/js/src/hitbtc.js +4 -0
  139. package/js/src/hollaex.js +2 -0
  140. package/js/src/htx.js +4 -0
  141. package/js/src/huobijp.js +2 -0
  142. package/js/src/idex.js +2 -0
  143. package/js/src/indodax.js +1 -0
  144. package/js/src/kraken.js +3 -3
  145. package/js/src/kucoin.js +6 -5
  146. package/js/src/kuna.js +3 -1
  147. package/js/src/latoken.js +1 -0
  148. package/js/src/lbank.js +1 -0
  149. package/js/src/lykke.js +2 -0
  150. package/js/src/mercado.js +1 -0
  151. package/js/src/mexc.js +2 -0
  152. package/js/src/ndax.js +2 -0
  153. package/js/src/novadax.js +1 -0
  154. package/js/src/okcoin.js +2 -0
  155. package/js/src/okx.js +2 -0
  156. package/js/src/phemex.js +2 -0
  157. package/js/src/poloniex.js +1 -0
  158. package/js/src/pro/binance.js +5 -3
  159. package/js/src/pro/coinbase.js +12 -3
  160. package/js/src/pro/cryptocom.js +17 -17
  161. package/js/src/pro/krakenfutures.js +15 -15
  162. package/js/src/probit.js +4 -2
  163. package/js/src/tidex.js +1 -0
  164. package/js/src/timex.js +2 -0
  165. package/js/src/upbit.js +2 -0
  166. package/js/src/wavesexchange.js +2 -1
  167. package/js/src/whitebit.js +1 -0
  168. package/js/src/woo.js +1 -0
  169. package/js/src/zaif.js +1 -0
  170. package/js/src/zonda.js +1 -0
  171. package/package.json +1 -1
  172. package/skip-tests.json +2 -3
  173. package/dist/cjs/src/btctradeua.js +0 -571
  174. package/dist/cjs/src/coinfalcon.js +0 -1012
  175. package/js/src/abstract/btctradeua.d.ts +0 -20
  176. package/js/src/abstract/btctradeua.js +0 -11
  177. package/js/src/abstract/coinfalcon.d.ts +0 -26
  178. package/js/src/abstract/coinfalcon.js +0 -11
  179. package/js/src/btctradeua.d.ts +0 -30
  180. package/js/src/btctradeua.js +0 -572
  181. package/js/src/coinfalcon.d.ts +0 -53
  182. package/js/src/coinfalcon.js +0 -1013
@@ -1,1013 +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/coinfalcon.js';
9
- import { ExchangeError, AuthenticationError, RateLimitExceeded } from './base/errors.js';
10
- import { Precise } from './base/Precise.js';
11
- import { TICK_SIZE } from './base/functions/number.js';
12
- import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
13
- // ---------------------------------------------------------------------------
14
- /**
15
- * @class coinfalcon
16
- * @extends Exchange
17
- */
18
- export default class coinfalcon extends Exchange {
19
- describe() {
20
- return this.deepExtend(super.describe(), {
21
- 'id': 'coinfalcon',
22
- 'name': 'CoinFalcon',
23
- 'countries': ['GB'],
24
- 'rateLimit': 1000,
25
- 'version': 'v1',
26
- 'has': {
27
- 'CORS': undefined,
28
- 'spot': true,
29
- 'margin': false,
30
- 'swap': false,
31
- 'future': false,
32
- 'option': false,
33
- 'addMargin': false,
34
- 'cancelOrder': true,
35
- 'createOrder': true,
36
- 'createReduceOnlyOrder': false,
37
- 'createStopLimitOrder': false,
38
- 'createStopMarketOrder': false,
39
- 'createStopOrder': false,
40
- 'fetchBalance': true,
41
- 'fetchBorrowRate': false,
42
- 'fetchBorrowRateHistories': false,
43
- 'fetchBorrowRateHistory': false,
44
- 'fetchBorrowRates': false,
45
- 'fetchBorrowRatesPerSymbol': false,
46
- 'fetchDepositAddress': true,
47
- 'fetchDepositAddresses': false,
48
- 'fetchDeposits': true,
49
- 'fetchFundingHistory': false,
50
- 'fetchFundingRate': false,
51
- 'fetchFundingRateHistory': false,
52
- 'fetchFundingRates': false,
53
- 'fetchIndexOHLCV': false,
54
- 'fetchLeverage': false,
55
- 'fetchLeverageTiers': false,
56
- 'fetchMarginMode': false,
57
- 'fetchMarkets': true,
58
- 'fetchMarkOHLCV': false,
59
- 'fetchMyTrades': true,
60
- 'fetchOpenInterestHistory': false,
61
- 'fetchOpenOrders': true,
62
- 'fetchOrder': true,
63
- 'fetchOrderBook': true,
64
- 'fetchPosition': false,
65
- 'fetchPositionMode': false,
66
- 'fetchPositions': false,
67
- 'fetchPositionsRisk': false,
68
- 'fetchPremiumIndexOHLCV': false,
69
- 'fetchTicker': true,
70
- 'fetchTickers': true,
71
- 'fetchTrades': true,
72
- 'fetchTradinFee': false,
73
- 'fetchTradingFees': true,
74
- 'fetchTransfer': false,
75
- 'fetchTransfers': false,
76
- 'fetchWithdrawals': true,
77
- 'reduceMargin': false,
78
- 'setLeverage': false,
79
- 'setMarginMode': false,
80
- 'setPositionMode': false,
81
- 'transfer': false,
82
- 'withdraw': true,
83
- },
84
- 'urls': {
85
- 'logo': 'https://user-images.githubusercontent.com/1294454/41822275-ed982188-77f5-11e8-92bb-496bcd14ca52.jpg',
86
- 'api': {
87
- 'rest': 'https://coinfalcon.com',
88
- },
89
- 'www': 'https://coinfalcon.com',
90
- 'doc': 'https://docs.coinfalcon.com',
91
- 'fees': 'https://coinfalcon.com/fees',
92
- 'referral': 'https://coinfalcon.com/?ref=CFJSVGTUPASB',
93
- },
94
- 'api': {
95
- 'public': {
96
- 'get': [
97
- 'markets',
98
- 'markets/{market}',
99
- 'markets/{market}/orders',
100
- 'markets/{market}/trades',
101
- ],
102
- },
103
- 'private': {
104
- 'get': [
105
- 'user/accounts',
106
- 'user/orders',
107
- 'user/orders/{id}',
108
- 'user/orders/{id}/trades',
109
- 'user/trades',
110
- 'user/fees',
111
- 'account/withdrawals/{id}',
112
- 'account/withdrawals',
113
- 'account/deposit/{id}',
114
- 'account/deposits',
115
- 'account/deposit_address',
116
- ],
117
- 'post': [
118
- 'user/orders',
119
- 'account/withdraw',
120
- ],
121
- 'delete': [
122
- 'user/orders/{id}',
123
- 'account/withdrawals/{id}',
124
- ],
125
- },
126
- },
127
- 'fees': {
128
- 'trading': {
129
- 'tierBased': true,
130
- 'maker': 0.0,
131
- 'taker': 0.002, // tiered fee starts at 0.2%
132
- },
133
- },
134
- 'precisionMode': TICK_SIZE,
135
- });
136
- }
137
- async fetchMarkets(params = {}) {
138
- /**
139
- * @method
140
- * @name coinfalcon#fetchMarkets
141
- * @description retrieves data on all markets for coinfalcon
142
- * @param {object} [params] extra parameters specific to the exchange api endpoint
143
- * @returns {object[]} an array of objects representing market data
144
- */
145
- const response = await this.publicGetMarkets(params);
146
- //
147
- // {
148
- // "data": [
149
- // {
150
- // "name": "ETH-BTC",
151
- // "precision": 6,
152
- // "min_volume": "0.00000001",
153
- // "min_price": "0.000001",
154
- // "volume": "0.015713",
155
- // "last_price": "0.069322",
156
- // "highest_bid": "0.063892",
157
- // "lowest_ask": "0.071437",
158
- // "change_in_24h": "2.85",
159
- // "size_precision": 8,
160
- // "price_precision": 6
161
- // },
162
- // ...
163
- // ]
164
- // }
165
- //
166
- const markets = this.safeValue(response, 'data', []);
167
- const result = [];
168
- for (let i = 0; i < markets.length; i++) {
169
- const market = markets[i];
170
- const [baseId, quoteId] = market['name'].split('-');
171
- const base = this.safeCurrencyCode(baseId);
172
- const quote = this.safeCurrencyCode(quoteId);
173
- result.push({
174
- 'id': market['name'],
175
- 'symbol': base + '/' + quote,
176
- 'base': base,
177
- 'quote': quote,
178
- 'settle': undefined,
179
- 'baseId': baseId,
180
- 'quoteId': quoteId,
181
- 'settleId': undefined,
182
- 'type': 'spot',
183
- 'spot': true,
184
- 'margin': false,
185
- 'swap': false,
186
- 'future': false,
187
- 'option': false,
188
- 'active': true,
189
- 'contract': false,
190
- 'linear': undefined,
191
- 'inverse': undefined,
192
- 'contractSize': undefined,
193
- 'expiry': undefined,
194
- 'expiryDatetime': undefined,
195
- 'strike': undefined,
196
- 'optionType': undefined,
197
- 'precision': {
198
- 'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'size_precision'))),
199
- 'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'price_precision'))),
200
- },
201
- 'limits': {
202
- 'leverage': {
203
- 'min': undefined,
204
- 'max': undefined,
205
- },
206
- 'amount': {
207
- 'min': this.safeNumber(market, 'minPrice'),
208
- 'max': undefined,
209
- },
210
- 'price': {
211
- 'min': this.safeNumber(market, 'minVolume'),
212
- 'max': undefined,
213
- },
214
- 'cost': {
215
- 'min': undefined,
216
- 'max': undefined,
217
- },
218
- },
219
- 'created': undefined,
220
- 'info': market,
221
- });
222
- }
223
- return result;
224
- }
225
- parseTicker(ticker, market = undefined) {
226
- //
227
- // {
228
- // "name":"ETH-BTC",
229
- // "precision":6,
230
- // "min_volume":"0.00000001",
231
- // "min_price":"0.000001",
232
- // "volume":"0.000452",
233
- // "last_price":"0.079059",
234
- // "highest_bid":"0.073472",
235
- // "lowest_ask":"0.079059",
236
- // "change_in_24h":"8.9",
237
- // "size_precision":8,
238
- // "price_precision":6
239
- // }
240
- //
241
- const marketId = this.safeString(ticker, 'name');
242
- market = this.safeMarket(marketId, market, '-');
243
- const timestamp = this.milliseconds();
244
- const last = this.safeString(ticker, 'last_price');
245
- return this.safeTicker({
246
- 'symbol': market['symbol'],
247
- 'timestamp': timestamp,
248
- 'datetime': this.iso8601(timestamp),
249
- 'high': undefined,
250
- 'low': undefined,
251
- 'bid': this.safeString(ticker, 'highest_bid'),
252
- 'bidVolume': undefined,
253
- 'ask': this.safeString(ticker, 'lowest_ask'),
254
- 'askVolume': undefined,
255
- 'vwap': undefined,
256
- 'open': undefined,
257
- 'close': last,
258
- 'last': last,
259
- 'previousClose': undefined,
260
- 'change': this.safeString(ticker, 'change_in_24h'),
261
- 'percentage': undefined,
262
- 'average': undefined,
263
- 'baseVolume': undefined,
264
- 'quoteVolume': this.safeString(ticker, 'volume'),
265
- 'info': ticker,
266
- }, market);
267
- }
268
- async fetchTicker(symbol, params = {}) {
269
- /**
270
- * @method
271
- * @name coinfalcon#fetchTicker
272
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
273
- * @param {string} symbol unified symbol of the market to fetch the ticker for
274
- * @param {object} [params] extra parameters specific to the coinfalcon api endpoint
275
- * @returns {object} a [ticker structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
276
- */
277
- await this.loadMarkets();
278
- const tickers = await this.fetchTickers([symbol], params);
279
- return tickers[symbol];
280
- }
281
- async fetchTickers(symbols = undefined, params = {}) {
282
- /**
283
- * @method
284
- * @name coinfalcon#fetchTickers
285
- * @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
286
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
287
- * @param {object} [params] extra parameters specific to the coinfalcon api endpoint
288
- * @returns {object} a dictionary of [ticker structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
289
- */
290
- await this.loadMarkets();
291
- symbols = this.marketSymbols(symbols);
292
- const response = await this.publicGetMarkets(params);
293
- //
294
- // {
295
- // "data":[
296
- // {
297
- // "name":"ETH-BTC",
298
- // "precision":6,
299
- // "min_volume":"0.00000001",
300
- // "min_price":"0.000001",
301
- // "volume":"0.000452",
302
- // "last_price":"0.079059",
303
- // "highest_bid":"0.073472",
304
- // "lowest_ask":"0.079059",
305
- // "change_in_24h":"8.9",
306
- // "size_precision":8,
307
- // "price_precision":6
308
- // }
309
- // ]
310
- // }
311
- //
312
- const tickers = this.safeValue(response, 'data', []);
313
- const result = {};
314
- for (let i = 0; i < tickers.length; i++) {
315
- const ticker = this.parseTicker(tickers[i]);
316
- const symbol = ticker['symbol'];
317
- result[symbol] = ticker;
318
- }
319
- return this.filterByArrayTickers(result, 'symbol', symbols);
320
- }
321
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
322
- /**
323
- * @method
324
- * @name coinfalcon#fetchOrderBook
325
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
326
- * @param {string} symbol unified symbol of the market to fetch the order book for
327
- * @param {int} [limit] the maximum amount of order book entries to return
328
- * @param {object} [params] extra parameters specific to the coinfalcon api endpoint
329
- * @returns {object} A dictionary of [order book structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure} indexed by market symbols
330
- */
331
- await this.loadMarkets();
332
- const market = this.market(symbol);
333
- const request = {
334
- 'market': market['id'],
335
- 'level': '3',
336
- };
337
- const response = await this.publicGetMarketsMarketOrders(this.extend(request, params));
338
- const data = this.safeValue(response, 'data', {});
339
- return this.parseOrderBook(data, market['symbol'], undefined, 'bids', 'asks', 'price', 'size');
340
- }
341
- parseTrade(trade, market = undefined) {
342
- //
343
- // fetchTrades (public)
344
- //
345
- // {
346
- // "id":"5ec36295-5c8d-4874-8d66-2609d4938557",
347
- // "price":"4050.06","size":"0.0044",
348
- // "market_name":"ETH-USDT",
349
- // "side":"sell",
350
- // "created_at":"2021-12-07T17:47:36.811000Z"
351
- // }
352
- //
353
- // fetchMyTrades (private)
354
- //
355
- // {
356
- // "id": "0718d520-c796-4061-a16b-915cd13f20c6",
357
- // "price": "0.00000358",
358
- // "size": "50.0",
359
- // "market_name": "DOGE-BTC",
360
- // "order_id": "ff2616d8-58d4-40fd-87ae-937c73eb6f1c",
361
- // "side": "buy",
362
- // "fee': "0.00000036",
363
- // "fee_currency_code": "btc",
364
- // "liquidity": "T",
365
- // "created_at": "2021-12-08T18:26:33.840000Z"
366
- // }
367
- //
368
- const timestamp = this.parse8601(this.safeString(trade, 'created_at'));
369
- const priceString = this.safeString(trade, 'price');
370
- const amountString = this.safeString(trade, 'size');
371
- const symbol = market['symbol'];
372
- const tradeId = this.safeString(trade, 'id');
373
- const side = this.safeString(trade, 'side');
374
- const orderId = this.safeString(trade, 'order_id');
375
- let fee = undefined;
376
- const feeCostString = this.safeString(trade, 'fee');
377
- if (feeCostString !== undefined) {
378
- const feeCurrencyCode = this.safeString(trade, 'fee_currency_code');
379
- fee = {
380
- 'cost': feeCostString,
381
- 'currency': this.safeCurrencyCode(feeCurrencyCode),
382
- };
383
- }
384
- return this.safeTrade({
385
- 'info': trade,
386
- 'timestamp': timestamp,
387
- 'datetime': this.iso8601(timestamp),
388
- 'symbol': symbol,
389
- 'id': tradeId,
390
- 'order': orderId,
391
- 'type': undefined,
392
- 'side': side,
393
- 'takerOrMaker': undefined,
394
- 'price': priceString,
395
- 'amount': amountString,
396
- 'cost': undefined,
397
- 'fee': fee,
398
- }, market);
399
- }
400
- async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
401
- /**
402
- * @method
403
- * @name coinfalcon#fetchMyTrades
404
- * @description fetch all trades made by the user
405
- * @param {string} symbol unified market symbol
406
- * @param {int} [since] the earliest time in ms to fetch trades for
407
- * @param {int} [limit] the maximum number of trades structures to retrieve
408
- * @param {object} [params] extra parameters specific to the coinfalcon api endpoint
409
- * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
410
- */
411
- this.checkRequiredSymbol('fetchMyTrades', symbol);
412
- await this.loadMarkets();
413
- const market = this.market(symbol);
414
- const request = {
415
- 'market': market['id'],
416
- };
417
- if (since !== undefined) {
418
- request['start_time'] = this.iso8601(since);
419
- }
420
- if (limit !== undefined) {
421
- request['limit'] = limit;
422
- }
423
- const response = await this.privateGetUserTrades(this.extend(request, params));
424
- //
425
- // {
426
- // "data": [
427
- // {
428
- // "id": "0718d520-c796-4061-a16b-915cd13f20c6",
429
- // "price": "0.00000358",
430
- // "size": "50.0",
431
- // "market_name": "DOGE-BTC",
432
- // "order_id": "ff2616d8-58d4-40fd-87ae-937c73eb6f1c",
433
- // "side": "buy",
434
- // "fee': "0.00000036",
435
- // "fee_currency_code": "btc",
436
- // "liquidity": "T",
437
- // "created_at": "2021-12-08T18:26:33.840000Z"
438
- // },
439
- // ]
440
- // }
441
- //
442
- const data = this.safeValue(response, 'data', []);
443
- return this.parseTrades(data, market, since, limit);
444
- }
445
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
446
- /**
447
- * @method
448
- * @name coinfalcon#fetchTrades
449
- * @description get the list of most recent trades for a particular symbol
450
- * @param {string} symbol unified symbol of the market to fetch trades for
451
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
452
- * @param {int} [limit] the maximum amount of trades to fetch
453
- * @param {object} [params] extra parameters specific to the coinfalcon api endpoint
454
- * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
455
- */
456
- await this.loadMarkets();
457
- const market = this.market(symbol);
458
- const request = {
459
- 'market': market['id'],
460
- };
461
- if (since !== undefined) {
462
- request['since'] = this.iso8601(since);
463
- }
464
- const response = await this.publicGetMarketsMarketTrades(this.extend(request, params));
465
- //
466
- // {
467
- // "data":[
468
- // {
469
- // "id":"5ec36295-5c8d-4874-8d66-2609d4938557",
470
- // "price":"4050.06","size":"0.0044",
471
- // "market_name":"ETH-USDT",
472
- // "side":"sell",
473
- // "created_at":"2021-12-07T17:47:36.811000Z"
474
- // },
475
- // ]
476
- // }
477
- //
478
- const data = this.safeValue(response, 'data', []);
479
- return this.parseTrades(data, market, since, limit);
480
- }
481
- async fetchTradingFees(params = {}) {
482
- /**
483
- * @method
484
- * @name coinfalcon#fetchTradingFees
485
- * @description fetch the trading fees for multiple markets
486
- * @param {object} [params] extra parameters specific to the coinfalcon api endpoint
487
- * @returns {object} a dictionary of [fee structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure} indexed by market symbols
488
- */
489
- await this.loadMarkets();
490
- const response = await this.privateGetUserFees(params);
491
- //
492
- // {
493
- // "data": {
494
- // "maker_fee": "0.0",
495
- // "taker_fee": "0.2",
496
- // "btc_volume_30d": "0.0"
497
- // }
498
- // }
499
- //
500
- const data = this.safeValue(response, 'data', {});
501
- const makerString = this.safeString(data, 'maker_fee');
502
- const takerString = this.safeString(data, 'taker_fee');
503
- const maker = this.parseNumber(Precise.stringDiv(makerString, '100'));
504
- const taker = this.parseNumber(Precise.stringDiv(takerString, '100'));
505
- const result = {};
506
- for (let i = 0; i < this.symbols.length; i++) {
507
- const symbol = this.symbols[i];
508
- result[symbol] = {
509
- 'info': response,
510
- 'symbol': symbol,
511
- 'maker': maker,
512
- 'taker': taker,
513
- 'percentage': true,
514
- 'tierBased': true,
515
- };
516
- }
517
- return result;
518
- }
519
- parseBalance(response) {
520
- const result = { 'info': response };
521
- const balances = this.safeValue(response, 'data', []);
522
- for (let i = 0; i < balances.length; i++) {
523
- const balance = balances[i];
524
- const currencyId = this.safeString(balance, 'currency_code');
525
- const code = this.safeCurrencyCode(currencyId);
526
- const account = this.account();
527
- account['free'] = this.safeString(balance, 'available_balance');
528
- account['used'] = this.safeString(balance, 'hold_balance');
529
- account['total'] = this.safeString(balance, 'balance');
530
- result[code] = account;
531
- }
532
- return this.safeBalance(result);
533
- }
534
- async fetchBalance(params = {}) {
535
- /**
536
- * @method
537
- * @name coinfalcon#fetchBalance
538
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
539
- * @param {object} [params] extra parameters specific to the coinfalcon api endpoint
540
- * @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
541
- */
542
- await this.loadMarkets();
543
- const response = await this.privateGetUserAccounts(params);
544
- return this.parseBalance(response);
545
- }
546
- parseDepositAddress(depositAddress, currency = undefined) {
547
- //
548
- // {
549
- // "address":"0x77b5051f97efa9cc52c9ad5b023a53fc15c200d3",
550
- // "tag":"0"
551
- // }
552
- //
553
- const address = this.safeString(depositAddress, 'address');
554
- const tag = this.safeString(depositAddress, 'tag');
555
- this.checkAddress(address);
556
- return {
557
- 'currency': this.safeCurrencyCode(undefined, currency),
558
- 'address': address,
559
- 'tag': tag,
560
- 'network': undefined,
561
- 'info': depositAddress,
562
- };
563
- }
564
- async fetchDepositAddress(code, params = {}) {
565
- /**
566
- * @method
567
- * @name coinfalcon#fetchDepositAddress
568
- * @description fetch the deposit address for a currency associated with this account
569
- * @param {string} code unified currency code
570
- * @param {object} [params] extra parameters specific to the coinfalcon api endpoint
571
- * @returns {object} an [address structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#address-structure}
572
- */
573
- await this.loadMarkets();
574
- const currency = this.safeCurrency(code);
575
- const request = {
576
- 'currency': this.safeStringLower(currency, 'id'),
577
- };
578
- const response = await this.privateGetAccountDepositAddress(this.extend(request, params));
579
- //
580
- // {
581
- // "data": {
582
- // "address": "0x9918987bbe865a1a9301dc736cf6cf3205956694",
583
- // "tag":null
584
- // }
585
- // }
586
- //
587
- const data = this.safeValue(response, 'data', {});
588
- return this.parseDepositAddress(data, currency);
589
- }
590
- parseOrderStatus(status) {
591
- const statuses = {
592
- 'fulfilled': 'closed',
593
- 'canceled': 'canceled',
594
- 'pending': 'open',
595
- 'open': 'open',
596
- 'partially_filled': 'open',
597
- };
598
- return this.safeString(statuses, status, status);
599
- }
600
- parseOrder(order, market = undefined) {
601
- //
602
- // {
603
- // "id":"8bdd79f4-8414-40a2-90c3-e9f4d6d1eef4"
604
- // "market":"IOT-BTC"
605
- // "price":"0.0000003"
606
- // "size":"4.0"
607
- // "size_filled":"3.0"
608
- // "fee":"0.0075"
609
- // "fee_currency_code":"iot"
610
- // "funds":"0.0"
611
- // "status":"canceled"
612
- // "order_type":"buy"
613
- // "post_only":false
614
- // "operation_type":"market_order"
615
- // "created_at":"2018-01-12T21:14:06.747828Z"
616
- // }
617
- //
618
- const marketId = this.safeString(order, 'market');
619
- const symbol = this.safeSymbol(marketId, market, '-');
620
- const timestamp = this.parse8601(this.safeString(order, 'created_at'));
621
- const priceString = this.safeString(order, 'price');
622
- const amountString = this.safeString(order, 'size');
623
- const filledString = this.safeString(order, 'size_filled');
624
- const status = this.parseOrderStatus(this.safeString(order, 'status'));
625
- let type = this.safeString(order, 'operation_type');
626
- if (type !== undefined) {
627
- const typeParts = type.split('_');
628
- type = typeParts[0];
629
- }
630
- const side = this.safeString(order, 'order_type');
631
- const postOnly = this.safeValue(order, 'post_only');
632
- return this.safeOrder({
633
- 'id': this.safeString(order, 'id'),
634
- 'clientOrderId': undefined,
635
- 'datetime': this.iso8601(timestamp),
636
- 'timestamp': timestamp,
637
- 'status': status,
638
- 'symbol': symbol,
639
- 'type': type,
640
- 'timeInForce': undefined,
641
- 'postOnly': postOnly,
642
- 'side': side,
643
- 'price': priceString,
644
- 'stopPrice': undefined,
645
- 'triggerPrice': undefined,
646
- 'cost': undefined,
647
- 'amount': amountString,
648
- 'filled': filledString,
649
- 'remaining': undefined,
650
- 'trades': undefined,
651
- 'fee': undefined,
652
- 'info': order,
653
- 'lastTradeTimestamp': undefined,
654
- 'average': undefined,
655
- }, market);
656
- }
657
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
658
- /**
659
- * @method
660
- * @name coinfalcon#createOrder
661
- * @description create a trade order
662
- * @param {string} symbol unified symbol of the market to create an order in
663
- * @param {string} type 'market' or 'limit'
664
- * @param {string} side 'buy' or 'sell'
665
- * @param {float} amount how much of currency you want to trade in units of base currency
666
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
667
- * @param {object} [params] extra parameters specific to the coinfalcon api endpoint
668
- * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
669
- */
670
- await this.loadMarkets();
671
- const market = this.market(symbol);
672
- // price/size must be string
673
- const request = {
674
- 'market': market['id'],
675
- 'size': this.amountToPrecision(symbol, amount),
676
- 'order_type': side,
677
- };
678
- if (type === 'limit') {
679
- price = this.priceToPrecision(symbol, price);
680
- request['price'] = price.toString();
681
- }
682
- request['operation_type'] = type + '_order';
683
- const response = await this.privatePostUserOrders(this.extend(request, params));
684
- const data = this.safeValue(response, 'data', {});
685
- return this.parseOrder(data, market);
686
- }
687
- async cancelOrder(id, symbol = undefined, params = {}) {
688
- /**
689
- * @method
690
- * @name coinfalcon#cancelOrder
691
- * @description cancels an open order
692
- * @param {string} id order id
693
- * @param {string} symbol unified symbol of the market the order was made in
694
- * @param {object} [params] extra parameters specific to the coinfalcon api endpoint
695
- * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
696
- */
697
- await this.loadMarkets();
698
- const request = {
699
- 'id': id,
700
- };
701
- const response = await this.privateDeleteUserOrdersId(this.extend(request, params));
702
- const market = this.market(symbol);
703
- const data = this.safeValue(response, 'data', {});
704
- return this.parseOrder(data, market);
705
- }
706
- async fetchOrder(id, symbol = undefined, params = {}) {
707
- /**
708
- * @method
709
- * @name coinfalcon#fetchOrder
710
- * @description fetches information on an order made by the user
711
- * @param {string} symbol unified symbol of the market the order was made in
712
- * @param {object} [params] extra parameters specific to the coinfalcon api endpoint
713
- * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
714
- */
715
- await this.loadMarkets();
716
- const request = {
717
- 'id': id,
718
- };
719
- const response = await this.privateGetUserOrdersId(this.extend(request, params));
720
- const data = this.safeValue(response, 'data', {});
721
- return this.parseOrder(data);
722
- }
723
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
724
- /**
725
- * @method
726
- * @name coinfalcon#fetchOpenOrders
727
- * @description fetch all unfilled currently open orders
728
- * @param {string} symbol unified market symbol
729
- * @param {int} [since] the earliest time in ms to fetch open orders for
730
- * @param {int} [limit] the maximum number of open orders structures to retrieve
731
- * @param {object} [params] extra parameters specific to the coinfalcon api endpoint
732
- * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
733
- */
734
- await this.loadMarkets();
735
- const request = {};
736
- let market = undefined;
737
- if (symbol !== undefined) {
738
- market = this.market(symbol);
739
- request['market'] = market['id'];
740
- }
741
- if (since !== undefined) {
742
- request['since_time'] = this.iso8601(since);
743
- }
744
- // TODO: test status=all if it works for closed orders too
745
- const response = await this.privateGetUserOrders(this.extend(request, params));
746
- const data = this.safeValue(response, 'data', []);
747
- const orders = this.filterByArray(data, 'status', ['pending', 'open', 'partially_filled'], false);
748
- return this.parseOrders(orders, market, since, limit);
749
- }
750
- async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
751
- /**
752
- * @method
753
- * @name coinfalcon#fetchDeposits
754
- * @description fetch all deposits made to an account
755
- * @param {string} code unified currency code
756
- * @param {int} [since] the earliest time in ms to fetch deposits for
757
- * @param {int} [limit] the maximum number of deposits structures to retrieve
758
- * @param {object} [params] extra parameters specific to the coinfalcon api endpoint
759
- * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
760
- */
761
- await this.loadMarkets();
762
- const request = {
763
- // currency: 'xrp', // optional: currency code in lowercase
764
- // status: 'completed', // optional: withdrawal status
765
- // since_time // datetime in ISO8601 format (2017-11-06T09:53:08.383210Z)
766
- // end_time // datetime in ISO8601 format (2017-11-06T09:53:08.383210Z)
767
- // start_time // datetime in ISO8601 format (2017-11-06T09:53:08.383210Z)
768
- };
769
- let currency = undefined;
770
- if (code !== undefined) {
771
- currency = this.currency(code);
772
- request['currency'] = this.safeStringLower(currency, 'id');
773
- }
774
- if (since !== undefined) {
775
- request['since_time'] = this.iso8601(since);
776
- }
777
- const response = await this.privateGetAccountDeposits(this.extend(request, params));
778
- //
779
- // "data": [
780
- // {
781
- // "id": "6e2f18b5-f80e-xxx-xxx-xxx",
782
- // "amount": "0.1",
783
- // "status": "completed",
784
- // "currency_code": "eth",
785
- // "txid": "0xxxx",
786
- // "address": "0xxxx",
787
- // "tag": null,
788
- // "type": "deposit"
789
- // },
790
- // ]
791
- //
792
- const transactions = this.safeValue(response, 'data', []);
793
- transactions.reverse(); // no timestamp but in reversed order
794
- return this.parseTransactions(transactions, currency, undefined, limit);
795
- }
796
- async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
797
- /**
798
- * @method
799
- * @name coinfalcon#fetchWithdrawals
800
- * @description fetch all withdrawals made from an account
801
- * @param {string} code unified currency code
802
- * @param {int} [since] the earliest time in ms to fetch withdrawals for
803
- * @param {int} [limit] the maximum number of withdrawals structures to retrieve
804
- * @param {object} [params] extra parameters specific to the coinfalcon api endpoint
805
- * @returns {object[]} a list of [transaction structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
806
- */
807
- await this.loadMarkets();
808
- const request = {
809
- // currency: 'xrp', // optional: currency code in lowercase
810
- // status: 'completed', // optional: withdrawal status
811
- // since_time // datetime in ISO8601 format (2017-11-06T09:53:08.383210Z)
812
- // end_time // datetime in ISO8601 format (2017-11-06T09:53:08.383210Z)
813
- // start_time // datetime in ISO8601 format (2017-11-06T09:53:08.383210Z)
814
- };
815
- let currency = undefined;
816
- if (code !== undefined) {
817
- currency = this.currency(code);
818
- request['currency'] = this.safeStringLower(currency, 'id');
819
- }
820
- if (since !== undefined) {
821
- request['since_time'] = this.iso8601(since);
822
- }
823
- const response = await this.privateGetAccountWithdrawals(this.extend(request, params));
824
- //
825
- // "data": [
826
- // {
827
- // "id": "25f6f144-3666-xxx-xxx-xxx",
828
- // "amount": "0.01",
829
- // "status": "completed",
830
- // "fee": "0.0005",
831
- // "currency_code": "btc",
832
- // "txid": "4xxx",
833
- // "address": "bc1xxx",
834
- // "tag": null,
835
- // "type": "withdraw"
836
- // },
837
- // ]
838
- //
839
- const transactions = this.safeValue(response, 'data', []);
840
- transactions.reverse(); // no timestamp but in reversed order
841
- return this.parseTransactions(transactions, currency, undefined, limit);
842
- }
843
- async withdraw(code, amount, address, tag = undefined, params = {}) {
844
- /**
845
- * @method
846
- * @name coinfalcon#withdraw
847
- * @description make a withdrawal
848
- * @param {string} code unified currency code
849
- * @param {float} amount the amount to withdraw
850
- * @param {string} address the address to withdraw to
851
- * @param {string} tag
852
- * @param {object} [params] extra parameters specific to the coinfalcon api endpoint
853
- * @returns {object} a [transaction structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
854
- */
855
- [tag, params] = this.handleWithdrawTagAndParams(tag, params);
856
- this.checkAddress(address);
857
- await this.loadMarkets();
858
- const currency = this.currency(code);
859
- const request = {
860
- 'currency': this.safeStringLower(currency, 'id'),
861
- 'address': address,
862
- 'amount': amount,
863
- // 'tag': 'string', // withdraw tag/memo
864
- };
865
- if (tag !== undefined) {
866
- request['tag'] = tag;
867
- }
868
- const response = await this.privatePostAccountWithdraw(this.extend(request, params));
869
- //
870
- // "data": [
871
- // {
872
- // "id": "25f6f144-3666-xxx-xxx-xxx",
873
- // "amount": "0.01",
874
- // "status": "approval_pending",
875
- // "fee": "0.0005",
876
- // "currency_code": "btc",
877
- // "txid": null,
878
- // "address": "bc1xxx",
879
- // "tag": null,
880
- // "type": "withdraw"
881
- // },
882
- // ]
883
- //
884
- const transaction = this.safeValue(response, 'data', []);
885
- return this.parseTransaction(transaction, currency);
886
- }
887
- parseTransactionStatus(status) {
888
- const statuses = {
889
- 'completed': 'ok',
890
- 'denied': 'failed',
891
- 'approval_pending': 'pending',
892
- };
893
- return this.safeString(statuses, status, status);
894
- }
895
- parseTransaction(transaction, currency = undefined) {
896
- //
897
- // fetchWithdrawals, withdraw
898
- //
899
- // {
900
- // "id": "25f6f144-3666-xxx-xxx-xxx",
901
- // "amount": "0.01",
902
- // "status": "completed",
903
- // "fee": "0.0005",
904
- // "currency_code": "btc",
905
- // "txid": "4xxx",
906
- // "address": "bc1xxx",
907
- // "tag": null,
908
- // "type": "withdraw"
909
- // },
910
- //
911
- // fetchDeposits
912
- //
913
- // {
914
- // "id": "6e2f18b5-f80e-xxx-xxx-xxx",
915
- // "amount": "0.1",
916
- // "status": "completed",
917
- // "currency_code": "eth",
918
- // "txid": "0xxxx",
919
- // "address": "0xxxx",
920
- // "tag": null,
921
- // "type": "deposit"
922
- // },
923
- //
924
- const id = this.safeString(transaction, 'id');
925
- const address = this.safeString(transaction, 'address');
926
- const tag = this.safeString(transaction, 'tag');
927
- const txid = this.safeString(transaction, 'txid');
928
- const currencyId = this.safeString(transaction, 'currency_code');
929
- const code = this.safeCurrencyCode(currencyId, currency);
930
- let type = this.safeString(transaction, 'type');
931
- if (type === 'withdraw') {
932
- type = 'withdrawal';
933
- }
934
- const status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
935
- const amountString = this.safeString(transaction, 'amount');
936
- const amount = this.parseNumber(amountString);
937
- const feeCostString = this.safeString(transaction, 'fee');
938
- let feeCost = '0';
939
- if (feeCostString !== undefined) {
940
- feeCost = feeCostString;
941
- }
942
- return {
943
- 'info': transaction,
944
- 'id': id,
945
- 'txid': txid,
946
- 'timestamp': undefined,
947
- 'datetime': undefined,
948
- 'network': undefined,
949
- 'address': address,
950
- 'addressTo': undefined,
951
- 'addressFrom': undefined,
952
- 'tag': tag,
953
- 'tagTo': undefined,
954
- 'tagFrom': undefined,
955
- 'type': type,
956
- 'amount': amount,
957
- 'currency': code,
958
- 'status': status,
959
- 'updated': undefined,
960
- 'fee': {
961
- 'currency': code,
962
- 'cost': this.parseNumber(feeCost),
963
- },
964
- };
965
- }
966
- nonce() {
967
- return this.milliseconds();
968
- }
969
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
970
- let request = '/api/' + this.version + '/' + this.implodeParams(path, params);
971
- const query = this.omit(params, this.extractParams(path));
972
- if (api === 'public') {
973
- if (Object.keys(query).length) {
974
- request += '?' + this.urlencode(query);
975
- }
976
- }
977
- else {
978
- this.checkRequiredCredentials();
979
- if (method === 'GET') {
980
- if (Object.keys(query).length) {
981
- request += '?' + this.urlencode(query);
982
- }
983
- }
984
- else {
985
- body = this.json(query);
986
- }
987
- const seconds = this.seconds().toString();
988
- let payload = [seconds, method, request].join('|');
989
- if (body) {
990
- payload += '|' + body;
991
- }
992
- const signature = this.hmac(this.encode(payload), this.encode(this.secret), sha256);
993
- headers = {
994
- 'CF-API-KEY': this.apiKey,
995
- 'CF-API-TIMESTAMP': seconds,
996
- 'CF-API-SIGNATURE': signature,
997
- 'Content-Type': 'application/json',
998
- };
999
- }
1000
- const url = this.urls['api']['rest'] + request;
1001
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1002
- }
1003
- handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1004
- if (code < 400) {
1005
- return undefined;
1006
- }
1007
- const ErrorClass = this.safeValue({
1008
- '401': AuthenticationError,
1009
- '429': RateLimitExceeded,
1010
- }, code, ExchangeError);
1011
- throw new ErrorClass(body);
1012
- }
1013
- }