btc-api-node 1.12.7

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.

Potentially problematic release.


This version of btc-api-node might be problematic. Click here for more details.

Files changed (97) hide show
  1. package/.istanbul.yml +53 -0
  2. package/.travis.yml +5 -0
  3. package/CHANGELOG +33 -0
  4. package/LICENSE.md +21 -0
  5. package/README.md +211 -0
  6. package/doc/order.md +160 -0
  7. package/doc/rest2.md +573 -0
  8. package/doc/ws2.md +925 -0
  9. package/examples/bfx.js +26 -0
  10. package/examples/rest2/order_history.js +29 -0
  11. package/examples/rest2/symbols.js +15 -0
  12. package/examples/rest2/tickers.js +24 -0
  13. package/examples/rest2/trade_history.js +28 -0
  14. package/examples/ws2/auth.js +31 -0
  15. package/examples/ws2/calc.js +33 -0
  16. package/examples/ws2/cancel_all.js +35 -0
  17. package/examples/ws2/cancel_all_buf.js +39 -0
  18. package/examples/ws2/candles.js +36 -0
  19. package/examples/ws2/info_events.js +40 -0
  20. package/examples/ws2/oc_multi.js +50 -0
  21. package/examples/ws2/order_books.js +37 -0
  22. package/examples/ws2/orders.js +67 -0
  23. package/examples/ws2/ox_multi.js +61 -0
  24. package/examples/ws2/sequencing.js +23 -0
  25. package/examples/ws2/ticker.js +20 -0
  26. package/examples/ws2/trades.js +27 -0
  27. package/index.js +24 -0
  28. package/lib/model.js +25 -0
  29. package/lib/models/alert.js +25 -0
  30. package/lib/models/balance_info.js +21 -0
  31. package/lib/models/candle.js +33 -0
  32. package/lib/models/funding_credit.js +61 -0
  33. package/lib/models/funding_info.js +16 -0
  34. package/lib/models/funding_loan.js +64 -0
  35. package/lib/models/funding_offer.js +60 -0
  36. package/lib/models/funding_trade.js +33 -0
  37. package/lib/models/index.js +23 -0
  38. package/lib/models/margin_info.js +29 -0
  39. package/lib/models/notification.js +31 -0
  40. package/lib/models/order.js +288 -0
  41. package/lib/models/order_book.js +214 -0
  42. package/lib/models/position.js +43 -0
  43. package/lib/models/tick.js +83 -0
  44. package/lib/models/trade.js +43 -0
  45. package/lib/models/trade_tick.js +29 -0
  46. package/lib/models/wallet.js +34 -0
  47. package/lib/transports/rest.js +391 -0
  48. package/lib/transports/rest2.js +597 -0
  49. package/lib/transports/ws.js +323 -0
  50. package/lib/transports/ws2.js +1729 -0
  51. package/lib/util/gen_auth_sig.js +23 -0
  52. package/lib/util/index.js +11 -0
  53. package/lib/util/is_snapshot.js +5 -0
  54. package/lib/util/nonce.js +5 -0
  55. package/package.json +39 -0
  56. package/test/fixtures/response-ticker-funding.json +1 -0
  57. package/test/fixtures/response-ticker-pairs.json +1 -0
  58. package/test/fixtures/response-trades-funding.json +1 -0
  59. package/test/fixtures/response-trades-pairs.json +1 -0
  60. package/test/fixtures/response-ws-1-orderbook-R0.json +51 -0
  61. package/test/fixtures/response-ws2-server-order-book-P0.json +1 -0
  62. package/test/fixtures/response-ws2-server-order-book-P1.json +1 -0
  63. package/test/fixtures/response-ws2-server-order-book-R0.json +1 -0
  64. package/test/fixtures/response-ws2-server-ticker-funding.json +1 -0
  65. package/test/fixtures/response-ws2-server-trades.json +1 -0
  66. package/test/helpers/test_model.js +71 -0
  67. package/test/index.js +131 -0
  68. package/test/lib/models/alert.js +12 -0
  69. package/test/lib/models/balance_info.js +12 -0
  70. package/test/lib/models/candle.js +12 -0
  71. package/test/lib/models/funding_credit.js +17 -0
  72. package/test/lib/models/funding_info.js +7 -0
  73. package/test/lib/models/funding_loan.js +17 -0
  74. package/test/lib/models/funding_offer.js +17 -0
  75. package/test/lib/models/funding_trade.js +15 -0
  76. package/test/lib/models/margin_info.js +15 -0
  77. package/test/lib/models/notification.js +14 -0
  78. package/test/lib/models/order.js +395 -0
  79. package/test/lib/models/order_book.js +188 -0
  80. package/test/lib/models/position.js +15 -0
  81. package/test/lib/models/tick.js +34 -0
  82. package/test/lib/models/trade.js +16 -0
  83. package/test/lib/models/trade_tick.js +14 -0
  84. package/test/lib/models/wallet.js +14 -0
  85. package/test/lib/transports/rest-1-integration.js +131 -0
  86. package/test/lib/transports/rest-2-integration.js +80 -0
  87. package/test/lib/transports/rest-2-issue-80-argument-length.js +61 -0
  88. package/test/lib/transports/rest-2-smoke-test.js +49 -0
  89. package/test/lib/transports/rest-2-unit.js +26 -0
  90. package/test/lib/transports/rest1.js +152 -0
  91. package/test/lib/transports/ws-1-handle-channel.js +83 -0
  92. package/test/lib/transports/ws-1-parsing.js +40 -0
  93. package/test/lib/transports/ws-1-test.js +275 -0
  94. package/test/lib/transports/ws2-integration.js +259 -0
  95. package/test/lib/transports/ws2-unit.js +1295 -0
  96. package/test/lib/util/is_snapshot.js +20 -0
  97. package/test/lib/util/nonce.js +20 -0
@@ -0,0 +1,597 @@
1
+ 'use strict'
2
+
3
+ const rp = require('request-promise')
4
+
5
+ const RESTv1 = require('./rest')
6
+ const { genAuthSig, nonce } = require('../util')
7
+ const {
8
+ FundingCredit,
9
+ FundingLoan,
10
+ FundingOffer,
11
+ FundingTrade,
12
+ MarginInfo,
13
+ Order,
14
+ Position,
15
+ Trade,
16
+ Wallet,
17
+ Alert,
18
+ Tick
19
+ } = require('../models')
20
+
21
+ const BASE_TIMEOUT = 15000
22
+ const API_URL = 'https://api.bitfinex.com'
23
+
24
+ /**
25
+ * Communicates with v2 of the Bitfinex HTTP API
26
+ */
27
+ class RESTv2 {
28
+ /**
29
+ * Instantiate a new REST v2 transport.
30
+ *
31
+ * @param {Object} opts
32
+ * @param {string} opts.apiKey
33
+ * @param {string} opts.apiSecret
34
+ * @param {string} opts.url - endpoint URL
35
+ * @param {boolean} opts.transform - default false
36
+ * @param {Object} opts.agent - optional node agent for connection (proxy)
37
+ */
38
+ constructor (opts = {
39
+ apiKey: '',
40
+ apiSecret: '',
41
+ url: API_URL,
42
+ transform: false,
43
+ agent: null
44
+ }) {
45
+ this._url = opts.url || API_URL
46
+ this._apiKey = opts.apiKey || ''
47
+ this._apiSecret = opts.apiSecret || ''
48
+ this._transform = !!opts.transform
49
+ this._agent = opts.agent
50
+
51
+ // Used for methods that are not yet implemented on REST v2
52
+ this._rest1 = new RESTv1(opts)
53
+ }
54
+
55
+ /**
56
+ * @private
57
+ */
58
+ genericCallback (err, result) {
59
+ console.log(err, result)
60
+ }
61
+
62
+ /**
63
+ * @param {string} path
64
+ * @param {Object} payload
65
+ * @param {Method} cb
66
+ * @param {Object} modelClass
67
+ * @private
68
+ */
69
+ _makeAuthRequest (path, payload = {}, cb = this.genericCallback, modelClass) {
70
+ if (!this._apiKey || !this._apiSecret) {
71
+ return cb(new Error('missing api key or secret'))
72
+ }
73
+
74
+ const url = `${this._url}/v2${path}`
75
+ const n = nonce()
76
+ const sigPayload = `/api/v2${path}${n}${JSON.stringify(payload)}`
77
+ const { sig } = genAuthSig(this._apiSecret, sigPayload)
78
+
79
+ return rp({
80
+ url,
81
+ method: 'POST',
82
+ headers: {
83
+ 'bfx-nonce': n,
84
+ 'bfx-apikey': this._apiKey,
85
+ 'bfx-signature': sig
86
+ },
87
+ agent: this._agent,
88
+ body: payload,
89
+ json: true
90
+ })
91
+ .then(this._doTransform.bind(this, modelClass))
92
+ .then(res => cb(null, res))
93
+ .catch((err) => {
94
+ if (err.error && err.error[1] === 10114) {
95
+ err.message += ' see https://github.com/bitfinexcom/bitfinex-api-node/blob/master/README.md#nonce-too-small for help'
96
+ }
97
+
98
+ cb(new Error(err))
99
+ })
100
+ }
101
+
102
+ /**
103
+ * @param {string} path
104
+ * @param {Method} cb
105
+ * @param {Object} modelClass
106
+ * @private
107
+ */
108
+ _makePublicRequest (path, cb = this.genericCallback, modelClass) {
109
+ const url = `${this._url}/v2${path}`
110
+
111
+ return rp({
112
+ url,
113
+ method: 'GET',
114
+ timeout: BASE_TIMEOUT,
115
+ agent: this._agent,
116
+ json: true
117
+ })
118
+ .then(this._doTransform.bind(this, modelClass))
119
+ .then(res => cb(null, res))
120
+ .catch(error => cb(new Error(error)))
121
+ }
122
+
123
+ /**
124
+ * @param {Object} ModelClass
125
+ * @param {Object} data
126
+ * @return {Object|Object[]} finalData
127
+ * @private
128
+ */
129
+ _doTransform (ModelClass, data) {
130
+ if (!data || data.length === 0) return []
131
+ if (!ModelClass || !this._transform) return data
132
+
133
+ if (Array.isArray(data[0])) {
134
+ return data.map(row => new ModelClass(row))
135
+ }
136
+
137
+ return new ModelClass(data)
138
+ }
139
+
140
+ /**
141
+ * @param {string} symbol
142
+ * @param {Method} cb
143
+ * @return {Promise} p
144
+ * @see https://docs.bitfinex.com/v2/reference#rest-public-ticker
145
+ */
146
+ ticker (symbol = 'tBTCUSD', cb) {
147
+ return this._makePublicRequest(`/ticker/${symbol}`, cb, Tick)
148
+ }
149
+
150
+ /**
151
+ * @param {string[]} symbols
152
+ * @param {Method} cb
153
+ * @return {Promise} p
154
+ * @see https://docs.bitfinex.com/v2/reference#rest-public-tickers
155
+ */
156
+ tickers (symbols = [], cb) {
157
+ if (typeof symbols === 'function' || typeof cb === 'undefined') {
158
+ return Promise.reject(new Error('symbols required'))
159
+ }
160
+
161
+ return this._makePublicRequest(`/tickers?symbols=${symbols.join(',')}`, cb, Tick)
162
+ }
163
+
164
+ /**
165
+ * @param {string} key
166
+ * @param {string} context
167
+ * @param {Method} cb
168
+ * @return {Promise} p
169
+ * @see https://docs.bitfinex.com/v2/reference#rest-public-stats
170
+ */
171
+ stats (key = 'pos.size:1m:tBTCUSD:long', context = 'hist', cb) {
172
+ return this._makePublicRequest(`/stats1/${key}/${context}`, cb)
173
+ }
174
+
175
+ /**
176
+ *
177
+ * @param {Object} opts
178
+ * @param {string} opts.timeframe - 1m, 5m, 15m, 30m, 1h, 3h, 6h, 12h, 1D, 7D, 14D, 1M
179
+ * @param {string} opts.symbol
180
+ * @param {string} opts.section - hist, last
181
+ * @param {Method} cb
182
+ * @return {Promise} p
183
+ * @see http://docs.bitfinex.com/v2/reference#rest-public-candles
184
+ */
185
+ candles ({ timeframe = '1m', symbol = 'tBTCUSD', section = 'hist' }, cb) {
186
+ return this._makePublicRequest(`/candles/trade:${timeframe}:${symbol}/${section}`, cb)
187
+ }
188
+
189
+ /**
190
+ * @param {string} type
191
+ * @param {Method} cb
192
+ * @return {Promise} p
193
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-alert-list
194
+ */
195
+ alertList (type = 'price', cb) {
196
+ return this._makeAuthRequest('/auth/r/alerts', { type }, cb, Alert)
197
+ }
198
+
199
+ /**
200
+ * @param {string} type
201
+ * @param {string} symbol
202
+ * @param {number} price
203
+ * @return {Promise} p
204
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-alert-set
205
+ */
206
+ alertSet (type = 'price', symbol = 'tBTCUSD', price = 0, cb) {
207
+ return this._makeAuthRequest('/auth/w/alert/set', { type, symbol, price }, cb, Alert)
208
+ }
209
+
210
+ /**
211
+ * @param {string} symbol
212
+ * @param {number} price
213
+ * @return {Promise} p
214
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-alert-delete
215
+ */
216
+ alertDelete (symbol = 'tBTCUSD', price = 0, cb) {
217
+ return this._makeAuthRequest('/auth/w/alert/del', { symbol, price }, cb)
218
+ }
219
+
220
+ /**
221
+ * @param {string} symbol
222
+ * @param {number} start
223
+ * @param {number} end
224
+ * @param {number} limit
225
+ * @param {Method} cb
226
+ * @return {Promise} p
227
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-trades-hist
228
+ */
229
+ trades (symbol = 'tBTCUSD', start = null, end = null, limit = null, cb) {
230
+ return this._makeAuthRequest(`/auth/r/trades/${symbol}/hist`, {
231
+ start, end, limit
232
+ }, cb, Trade)
233
+ }
234
+
235
+ /**
236
+ * @param {Method} cb
237
+ * @return {Promise} p
238
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-wallets
239
+ */
240
+ wallets (cb) {
241
+ return this._makeAuthRequest('/auth/r/wallets', {}, cb, Wallet)
242
+ }
243
+
244
+ /**
245
+ * @param {Method} cb
246
+ * @return {Promise} p
247
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-orders
248
+ */
249
+ activeOrders (cb) {
250
+ return this._makeAuthRequest('/auth/r/orders', {}, cb, Order)
251
+ }
252
+
253
+ /**
254
+ * @param {string} symbol
255
+ * @param {number} start
256
+ * @param {number} end
257
+ * @param {number} limit
258
+ * @param {Method} cb
259
+ * @return {Promise} p
260
+ * @see https://docs.bitfinex.com/v2/reference#orders-history
261
+ */
262
+ orderHistory (symbol = 'tBTCUSD', start = null, end = null, limit = null, cb) {
263
+ return this._makeAuthRequest(`/auth/r/orders/${symbol}/hist`, {
264
+ start, end, limit
265
+ }, cb, Order)
266
+ }
267
+
268
+ /**
269
+ * @param {string} symbol
270
+ * @param {number} start
271
+ * @param {number} end
272
+ * @param {number} limit
273
+ * @param {number} orderID
274
+ * @param {Method} cb
275
+ * @return {Promise} p
276
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-order-trades
277
+ */
278
+ orderTrades (symbol = 'tBTCUSD', start = null, end = null, limit = null, orderID, cb) {
279
+ return this._makeAuthRequest(`/auth/r/order/${symbol}:${orderID}/trades`, {
280
+ start, end, limit
281
+ }, cb, Trade)
282
+ }
283
+
284
+ /**
285
+ * @param {Method} cb
286
+ * @return {Promise} p
287
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-positions
288
+ */
289
+ positions (cb) {
290
+ return this._makeAuthRequest('/auth/r/positions', {}, cb, Position)
291
+ }
292
+
293
+ /**
294
+ * @param {string} symbol
295
+ * @param {Method} cb
296
+ * @return {Promise} p
297
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-offers
298
+ */
299
+ fundingOffers (symbol = 'fUSD', cb) {
300
+ return this._makeAuthRequest(`/auth/r/funding/offers/${symbol}`, {}, cb, FundingOffer)
301
+ }
302
+
303
+ /**
304
+ * @param {string} symbol
305
+ * @param {number} start
306
+ * @param {number} end
307
+ * @param {number} limit
308
+ * @param {Method} cb
309
+ * @return {Promise} p
310
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-offers-hist
311
+ */
312
+ fundingOfferHistory (symbol = 'tBTCUSD', start = null, end = null, limit = null, cb) {
313
+ return this._makeAuthRequest(`/auth/r/funding/offers/${symbol}/hist`, {
314
+ start, end, limit
315
+ }, cb, FundingOffer)
316
+ }
317
+
318
+ /**
319
+ * @param {string} symbol
320
+ * @param {Method} cb
321
+ * @return {Promise} p
322
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-loans
323
+ */
324
+ fundingLoans (symbol = 'fUSD', cb) {
325
+ return this._makeAuthRequest(`/auth/r/funding/loans/${symbol}`, {}, cb, FundingLoan)
326
+ }
327
+
328
+ /**
329
+ * @param {string} symbol
330
+ * @param {number} start
331
+ * @param {number} end
332
+ * @param {number} limit
333
+ * @param {Method} cb
334
+ * @return {Promise} p
335
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-loans-hist
336
+ */
337
+ fundingLoanHistory (symbol = 'tBTCUSD', start = null, end = null, limit = null, cb) {
338
+ return this._makeAuthRequest(`/auth/r/funding/loans/${symbol}/hist`, {
339
+ start, end, limit
340
+ }, cb, FundingLoan)
341
+ }
342
+
343
+ /**
344
+ * @param {string} symbol
345
+ * @param {Method} cb
346
+ * @return {Promise} p
347
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-credits
348
+ */
349
+ fundingCredits (symbol = 'fUSD', cb) {
350
+ return this._makeAuthRequest(`/auth/r/funding/credits/${symbol}`, {}, cb, FundingCredit)
351
+ }
352
+
353
+ /**
354
+ * @param {string} symbol
355
+ * @param {number} start
356
+ * @param {number} end
357
+ * @param {number} limit
358
+ * @param {Method} cb
359
+ * @return {Promise} p
360
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-credits-hist
361
+ */
362
+ fundingCreditHistory (symbol = 'tBTCUSD', start = null, end = null, limit = null, cb) {
363
+ return this._makeAuthRequest(`/auth/r/funding/credits/${symbol}/hist`, {
364
+ start, end, limit
365
+ }, cb, FundingCredit)
366
+ }
367
+
368
+ /**
369
+ * @param {string} symbol
370
+ * @param {number} start
371
+ * @param {number} end
372
+ * @param {number} limit
373
+ * @param {Method} cb
374
+ * @return {Promise} p
375
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-trades-hist
376
+ */
377
+ fundingTrades (symbol = 'tBTCUSD', start = null, end = null, limit = null, cb) {
378
+ return this._makeAuthRequest(`/auth/r/funding/trades/${symbol}/hist`, {
379
+ start, end, limit
380
+ }, cb, FundingTrade)
381
+ }
382
+
383
+ /**
384
+ * @param {string} key
385
+ * @param {Method} cb
386
+ * @return {Promise} p
387
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-info-margin
388
+ */
389
+ marginInfo (key = 'base', cb) {
390
+ return this._makeAuthRequest(`/auth/r/info/margin/${key}`, {}, cb, MarginInfo)
391
+ }
392
+
393
+ /**
394
+ * @param {string} key
395
+ * @param {Method} cb
396
+ * @return {Promise} p
397
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-info-funding
398
+ */
399
+ fundingInfo (key = 'fUSD', cb) {
400
+ return this._makeAuthRequest(`/auth/r/info/funding/${key}`, {}, cb)
401
+ }
402
+
403
+ /**
404
+ * @param {Method} cb
405
+ * @return {Promise} p
406
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-performance
407
+ */
408
+ performance (cb) {
409
+ return this._makeAuthRequest('/auth/r/stats/perf:1D/hist', {}, cb)
410
+ }
411
+
412
+ /**
413
+ * @param {string} symbol
414
+ * @param {string} dir
415
+ * @param {number} rate
416
+ * @param {string} type
417
+ * @param {Method} cb
418
+ * @return {Promise} p
419
+ * @see https://docs.bitfinex.com/v2/reference#rest-auth-calc-bal-avail
420
+ */
421
+ calcAvailableBalance (symbol = 'tBTCUSD', dir, rate, type, cb) {
422
+ return this._makeAuthRequest('/auth/r/calc/order/avail', {
423
+ symbol,
424
+ dir,
425
+ rate,
426
+ type
427
+ }, cb)
428
+ }
429
+
430
+ /**
431
+ * Get a list of valid symbol names
432
+ *
433
+ * @param {Method} cb
434
+ * @return {Promise} p
435
+ * @deprecated
436
+ * @see https://docs.bitfinex.com/v1/reference#rest-public-symbols
437
+ */
438
+ symbols (cb) {
439
+ return this._rest1.make_public_request('symbols', cb)
440
+ }
441
+
442
+ /**
443
+ * Get a list of valid symbol names and details
444
+ *
445
+ * @param {Method} cb
446
+ * @return {Promise} p
447
+ * @deprecated
448
+ * @see https://docs.bitfinex.com/v1/reference#rest-public-symbol-details
449
+ */
450
+ symbolDetails (cb) {
451
+ return this._rest1.make_public_request('symbols_details', cb)
452
+ }
453
+
454
+ /**
455
+ * Request information about your account
456
+ *
457
+ * @param {Method} cb
458
+ * @return {Promise} p
459
+ * @deprecated
460
+ * @see https://docs.bitfinex.com/v1/reference#rest-auth-account-info
461
+ */
462
+ accountInfo (cb) {
463
+ return this._rest1.make_request('account_infos', {}, cb)
464
+ }
465
+
466
+ /**
467
+ * Request account withdrawl fees
468
+ *
469
+ * @param {Method} cb
470
+ * @return {Promise} p
471
+ * @deprecated
472
+ * @see https://docs.bitfinex.com/v1/reference#rest-auth-fees
473
+ */
474
+ accountFees (cb) {
475
+ return this._rest1.make_request('account_fees', {}, cb)
476
+ }
477
+
478
+ /**
479
+ * Returns a 30-day summary of your trading volume and return on margin
480
+ * funding.
481
+ *
482
+ * @param {Method} cb
483
+ * @return {Promise} p
484
+ * @deprecated
485
+ * @see https://docs.bitfinex.com/v1/reference#rest-auth-summary
486
+ */
487
+ accountSummary (cb) {
488
+ return this._rest1.make_request('summary', {}, cb)
489
+ }
490
+
491
+ /**
492
+ * Request a deposit address
493
+ *
494
+ * @param {Object} params
495
+ * @param {string} params.request
496
+ * @param {string} params.nonce
497
+ * @param {string} params.method - name of currency
498
+ * @param {string} params.wallet_name - 'trading', 'exchange' or 'deposit'
499
+ * @param {number} params.renew - 1 or 0
500
+ * @param {Method} cb
501
+ * @return {Promise} p
502
+ * @deprecated
503
+ * @see https://docs.bitfinex.com/v1/reference#rest-auth-deposit
504
+ */
505
+ deposit (params, cb) {
506
+ return this._rest1.make_request('deposit/new', params, cb)
507
+ }
508
+
509
+ /**
510
+ * Requests a withdrawl from a wallet
511
+ *
512
+ * @param {Object} params
513
+ * @param {string} params.withdraw_type - name of currency
514
+ * @param {string} params.walletselected - 'trading', 'exchange, or 'deposit'
515
+ * @param {string} params.amount
516
+ * @param {string} params.address
517
+ * @param {string} params.payment_id - optional, for monero
518
+ * @param {string} params.account_name
519
+ * @param {string} params.account_number
520
+ * @param {string} params.swift
521
+ * @param {string} params.bank_name
522
+ * @param {string} params.bank_address
523
+ * @param {string} params.bank_city
524
+ * @param {string} params.bank_country
525
+ * @param {string} params.detail_payment - message to beneficiary
526
+ * @param {number} params.expressWire - 1 or 0
527
+ * @param {string} params.intermediary_bank_name
528
+ * @param {string} params.intermediary_bank_address
529
+ * @param {string} params.intermediary_bank_city
530
+ * @param {string} params.intermediary_bank_country
531
+ * @param {string} params.intermediary_bank_account
532
+ * @param {string} params.intermediary_bank_swift
533
+ * @param {Method} cb
534
+ * @return {Promise} p
535
+ * @deprecated
536
+ * @see https://docs.bitfinex.com/v1/reference#rest-auth-withdrawal
537
+ */
538
+ withdraw (params, cb) {
539
+ return this._rest1.make_request('withdraw', params, cb)
540
+ }
541
+
542
+ /**
543
+ * Execute a balance transfer between wallets
544
+ *
545
+ * @param {Object} params
546
+ * @param {number} params.amount - amount to transfer
547
+ * @param {string} params.currency - currency of funds to transfer
548
+ * @param {string} params.walletFrom - wallet to transfer from
549
+ * @param {string} params.walletTo - wallet to transfer to
550
+ * @param {Method} cb
551
+ * @return {Promise} p
552
+ * @deprecated
553
+ * @see https://docs.bitfinex.com/v1/reference#rest-auth-transfer-between-wallets
554
+ */
555
+ transfer (params, cb) {
556
+ return this.make_request('transfer', params, cb)
557
+ }
558
+
559
+ /**
560
+ * Fetch the permissions of the key being used to generate this request
561
+ *
562
+ * @param {Method} cb
563
+ * @return {Promise} p
564
+ * @deprecated
565
+ * @see https://docs.bitfinex.com/v1/reference#auth-key-permissions
566
+ */
567
+ keyPermissions (cb) {
568
+ return this._rest1.make_request('key_info', {}, cb)
569
+ }
570
+
571
+ /**
572
+ * Request your wallet balances
573
+ *
574
+ * @param {Method} cb
575
+ * @return {Promise} p
576
+ * @deprecated
577
+ * @see https://docs.bitfinex.com/v1/reference#rest-auth-wallet-balances
578
+ */
579
+ balances (cb) {
580
+ return this._rest1.make_request('balances', {}, cb)
581
+ }
582
+
583
+ /**
584
+ * @param {Object} params
585
+ * @param {number} params.position_id
586
+ * @param {number} params.amount
587
+ * @param {Method} cb
588
+ * @return {Promise} p
589
+ * @deprecated
590
+ * @see https://docs.bitfinex.com/v1/reference#rest-auth-claim-position
591
+ */
592
+ claimPosition (params, cb) {
593
+ return this._rest1.make_request('positions/claim', params, cb)
594
+ }
595
+ }
596
+
597
+ module.exports = RESTv2