From 672d7caf50f68ed388f60005994199198c7d424f Mon Sep 17 00:00:00 2001 From: Daniel1984 Date: Wed, 3 Jun 2020 20:11:43 +0300 Subject: [PATCH 01/10] new submitFundingOffer and cancelFundingOffer ws2 functions --- lib/transports/ws2.js | 80 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/lib/transports/ws2.js b/lib/transports/ws2.js index facba4d0..42ef53aa 100644 --- a/lib/transports/ws2.js +++ b/lib/transports/ws2.js @@ -1931,6 +1931,86 @@ class WSv2 extends EventEmitter { return this._getEventPromise(`order-new-${packet.cid}`) } + /** + * @typedef {object} FundingOffer + * @property {string} type - offer type i.e. LIMIT, FRRDELTAVAR + * @property {string} symbol - symbol i.e. fUSD, fBTC + * @property {string} amount - positive for buy, negative for sell i.e. '50' + * @property {number} period - Time period of offer. Min:2, Max:30 days + * @property {number} flags - flags + */ + + /** + * Sends a new funding offer to the server. Emits an error if not + * authenticated. The funding offer can be either key/value pair object + * literal, an instance of FundingOffer class or an array + * + * @see WSv2#cancelFundingOffer + * + * @param {FundingOffer|Array} payload - funding offer object model or array + * @example + * const fo = new FundingOffer({ + * type: 'LIMIT', + * symbol: 'fUSD', + * amount: '50', + * rate: '0.001', + * period: 2, + * flags: 0 + * }, ws) + * + * ws.submitFundingOffer(fo) + * + * ws.onFundingOfferNew({ symbol: 'fUSD' }, (resp) => { + * console.log('Funding offer status: ', resp.status) + * }) + */ + async submitFundingOffer (payload) { + if (!this._isAuthenticated) { + throw new Error('not authenticated') + } + + const packet = ( + payload instanceof FundingOffer + ? payload + : new FundingOffer(payload) + ).toNewOfferPacket() + + if (this._affCode) { + packet.meta.aff_code = packet.meta.aff_code || this._affCode + } + + this.send([0, 'fon', null, packet]) + } + + /** + * Cancels funding offer by ID. Emits an error if not authenticated. + * The ID can be passed as a number, key/value pair object literal, + * an instance of FundingOffer class or an array + * + * @see WSv2#submitFundingOffer + * + * @param {FundingOffer|object|Array|number} payload - funding offer model, array or ID to cancel + * @example + * ws.cancelFundingOffer({ id: 1234 }) + * + * ws.onFundingOfferClose({ symbol: 'fUSD' }, (resp) => { + * console.log('Funding offer status: ', resp.status) + * }) + */ + cancelFundingOffer (payload) { + if (!this._isAuthenticated) { + throw new Error('not authenticated') + } + + const id = _isNumber(payload) + ? payload + : Array.isArray(payload) + ? payload[0] + : payload.id + + this.send([0, 'foc', null, { id }]) + } + /** * Send a changeset to update an order in-place while maintaining position in * the price queue. The changeset must contain the order ID, and supports a From 09ae0c744491caf0d28f42a1a39a4c422c00160d Mon Sep 17 00:00:00 2001 From: Daniel1984 Date: Thu, 4 Jun 2020 17:36:04 +0300 Subject: [PATCH 02/10] ws2.js updating jsdoc comment --- lib/transports/ws2.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/transports/ws2.js b/lib/transports/ws2.js index 42ef53aa..5df637c2 100644 --- a/lib/transports/ws2.js +++ b/lib/transports/ws2.js @@ -1936,6 +1936,7 @@ class WSv2 extends EventEmitter { * @property {string} type - offer type i.e. LIMIT, FRRDELTAVAR * @property {string} symbol - symbol i.e. fUSD, fBTC * @property {string} amount - positive for buy, negative for sell i.e. '50' + * @property {string} rate - rate of the offer * @property {number} period - Time period of offer. Min:2, Max:30 days * @property {number} flags - flags */ From 5c993c3ab6b0422b57c8a3fd3e8f4077f6b22a81 Mon Sep 17 00:00:00 2001 From: Daniel1984 Date: Thu, 4 Jun 2020 18:21:25 +0300 Subject: [PATCH 03/10] further amending jsdocs comments for cancel and new funding offer --- lib/transports/ws2.js | 2 + test/lib/transports/ws2-integration.js | 122 ++++++++++++++++++++++++- 2 files changed, 123 insertions(+), 1 deletion(-) diff --git a/lib/transports/ws2.js b/lib/transports/ws2.js index 5df637c2..a2920d74 100644 --- a/lib/transports/ws2.js +++ b/lib/transports/ws2.js @@ -1949,6 +1949,7 @@ class WSv2 extends EventEmitter { * @see WSv2#cancelFundingOffer * * @param {FundingOffer|Array} payload - funding offer object model or array + * @throws an error if not authenticated * @example * const fo = new FundingOffer({ * type: 'LIMIT', @@ -1991,6 +1992,7 @@ class WSv2 extends EventEmitter { * @see WSv2#submitFundingOffer * * @param {FundingOffer|object|Array|number} payload - funding offer model, array or ID to cancel + * @throws an error if not authenticated * @example * ws.cancelFundingOffer({ id: 1234 }) * diff --git a/test/lib/transports/ws2-integration.js b/test/lib/transports/ws2-integration.js index 23d58abd..8fbd36c7 100644 --- a/test/lib/transports/ws2-integration.js +++ b/test/lib/transports/ws2-integration.js @@ -4,7 +4,7 @@ const assert = require('assert') const Promise = require('bluebird') const WSv2 = require('../../../lib/transports/ws2') -const { Order } = require('bfx-api-node-models') +const { Order, FundingOffer } = require('bfx-api-node-models') const { MockWSv2Server } = require('bfx-api-mock-srv') const API_KEY = 'dummy' @@ -224,6 +224,126 @@ describe('WSv2 integration', () => { }) }) + describe('submitFundingOffer', () => { + const testCases = { + 'as class instance': { + payload: new FundingOffer({ + type: 'LIMIT', + symbol: 'fUSD', + amount: '50', + rate: '0.001', + period: 2, + flags: 0 + }), + expectedResult: { + type: 'LIMIT', + symbol: 'fUSD', + amount: '50.00000000', + rate: '0.00100000', + period: 2, + flags: 0 + } + }, + 'as object literal': { + payload: { + type: 'LIMIT', + symbol: 'fUSD', + amount: '60', + rate: '0.003', + period: 7, + flags: 0 + }, + expectedResult: { + type: 'LIMIT', + symbol: 'fUSD', + amount: '60.00000000', + rate: '0.00300000', + period: 7, + flags: 0 + } + }, + 'as array': { + payload: [ + null, 'fUSD', null, null, '55', null, 'LIMIT', null, null, 0, + null, null, null, null, '0.002', 4 + ], + expectedResult: { + type: 'LIMIT', + symbol: 'fUSD', + amount: '55.00000000', + rate: '0.00200000', + period: 4, + flags: 0 + } + } + } + + Object.keys(testCases).forEach((scenario) => { + it(scenario, async () => { + let sentPackets = 0 + wss = new MockWSv2Server() + ws = createTestWSv2Instance() + + await ws.open() + await ws.auth() + + ws._ws.send = (msgJSON) => { + const msg = JSON.parse(msgJSON) + assert.strictEqual(msg[1], 'fon') + assert.deepStrictEqual(msg[3], testCases[scenario].expectedResult) + sentPackets++ + wss.close() + } + + ws.submitFundingOffer(testCases[scenario].payload) + assert.strictEqual(sentPackets, 1) + }) + }) + }) + + describe('cancelFundingOffer', () => { + const testCases = { + 'as class instance': { + payload: new FundingOffer({ id: 123 }), + expectedResult: { id: 123 } + }, + 'as object literal': { + payload: { id: 124 }, + expectedResult: { id: 124 } + }, + 'as number': { + payload: 125, + expectedResult: { id: 125 } + }, + 'as array': { + payload: [126], + expectedResult: { id: 126 } + } + } + + Object.keys(testCases).forEach((scenario) => { + it(scenario, async () => { + let sentPackets = 0 + wss = new MockWSv2Server() + ws = createTestWSv2Instance() + + await ws.open() + await ws.auth() + + ws._ws.send = (msgJSON) => { + const msg = JSON.parse(msgJSON) + assert.strictEqual(msg[1], 'foc') + assert.deepStrictEqual(msg[3], testCases[scenario].expectedResult) + sentPackets++ + wss.close() + } + + ws.cancelFundingOffer(testCases[scenario].payload) + assert.strictEqual(sentPackets, 1) + }) + }) + }) + describe('listeners', () => { it('manages listeners by cbGID', () => { ws = createTestWSv2Instance() From 89c0f1e425a5ac0f849d10006e1dc138b9e74418 Mon Sep 17 00:00:00 2001 From: Daniel1984 Date: Thu, 4 Jun 2020 18:22:27 +0300 Subject: [PATCH 04/10] updating docs --- docs/WS2Manager.html | 4 +- docs/WSv2.html | 1006 +++++++++++++++++++++++++++++------ docs/global.html | 240 ++++++++- docs/index.html | 10 +- docs/transports_ws2.js.html | 103 +++- docs/util_precision.js.html | 4 +- docs/util_ws2.js.html | 4 +- docs/ws2_manager.js.html | 4 +- 8 files changed, 1199 insertions(+), 176 deletions(-) diff --git a/docs/WS2Manager.html b/docs/WS2Manager.html index a996742b..50e513aa 100644 --- a/docs/WS2Manager.html +++ b/docs/WS2Manager.html @@ -27,7 +27,7 @@
@@ -5082,7 +5082,7 @@
Parameters:

- Documentation generated by JSDoc 3.6.3 on Tue Mar 10 2020 21:05:28 GMT+0700 (Indochina Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
diff --git a/docs/WSv2.html b/docs/WSv2.html index a2af9c3a..3a21997d 100644 --- a/docs/WSv2.html +++ b/docs/WSv2.html @@ -27,7 +27,7 @@
@@ -739,7 +739,7 @@

(constant)
Source:
@@ -946,7 +946,7 @@

(constant) W
Source:
@@ -1107,7 +1107,7 @@

(constant) WS
Source:
@@ -1389,6 +1389,181 @@

Returns:
+

cancelFundingOffer(payload)

+ + + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
See:
+
+ +
+ + + +
+ + + + + +
+

Cancels funding offer by ID. Emits an error if not authenticated. +The ID can be passed as a number, key/value pair object literal, +an instance of FundingOffer class or an array

+
+ + + + + + + + + +
Example
+ +
ws.cancelFundingOffer({ id: 1234 })
+
+ws.onFundingOfferClose({ symbol: 'fUSD' }, (resp) => {
+  console.log('Funding offer status: ', resp.status)
+})
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
payload + + +FundingOffer +| + +object +| + +Array +| + +number + + + +

funding offer model, array or ID to cancel

+ + + + + + + + + + + + + + +
Throws:
+ + + +
+ +

an error if not authenticated

+ +
+ + + + + + + + + + + + +

(async) cancelOrder(order) → {Promise}

@@ -1401,7 +1576,7 @@

(async) ca
Source:
@@ -1574,7 +1749,7 @@

(async) c
Source:
@@ -4222,7 +4397,7 @@

isAuth
Source:
@@ -4492,7 +4667,7 @@

isOpenSource:
@@ -4597,7 +4772,7 @@

isRecon
Source:
@@ -5125,7 +5300,7 @@

notifyUISource:
@@ -5503,7 +5678,7 @@

on
Source:
@@ -5799,7 +5974,7 @@

o
Source:
@@ -6095,7 +6270,7 @@

on
Source:
@@ -6322,7 +6497,7 @@

onCandleSource:
@@ -6587,7 +6762,7 @@

o
Source:
@@ -6847,7 +7022,7 @@

onF
Source:
@@ -7107,7 +7282,7 @@

Source:
@@ -7370,7 +7545,7 @@

Source:
@@ -7630,7 +7805,7 @@

on
Source:
@@ -7857,7 +8032,7 @@

onF
Source:
@@ -8117,7 +8292,7 @@

onFun
Source:
@@ -8377,7 +8552,7 @@

Source:
@@ -8640,7 +8815,7 @@

on
Source:
@@ -8900,7 +9075,7 @@

on
Source:
@@ -9160,7 +9335,7 @@

onFu
Source:
@@ -9420,7 +9595,7 @@

Source:
@@ -9683,7 +9858,7 @@

o
Source:
@@ -9943,7 +10118,7 @@

on
Source:
@@ -10203,7 +10378,7 @@

o
Source:
@@ -10463,7 +10638,7 @@

onInfoMe
Source:
@@ -10896,7 +11071,7 @@

onM
Source:
@@ -11123,7 +11298,7 @@

onMessageSource:
@@ -11346,7 +11521,7 @@

onNotif
Source:
@@ -11606,7 +11781,7 @@

onOrderBoo
Source:
@@ -11933,7 +12108,7 @@

on
Source:
@@ -12260,7 +12435,7 @@

onOrderCl
Source:
@@ -12621,7 +12796,7 @@

onOrderNew<
Source:
@@ -12982,7 +13157,7 @@

onOrde
Source:
@@ -13346,7 +13521,7 @@

onOrderU
Source:
@@ -13707,7 +13882,7 @@

onPosi
Source:
@@ -13967,7 +14142,7 @@

onPositi
Source:
@@ -14227,7 +14402,7 @@

onP
Source:
@@ -14489,7 +14664,7 @@

onPos
Source:
@@ -14886,7 +15061,7 @@

onStatusSource:
@@ -15148,7 +15323,7 @@

onTickerSource:
@@ -15413,7 +15588,7 @@

onTradeEn
Source:
@@ -15713,7 +15888,7 @@

onTradesSource:
@@ -16014,7 +16189,7 @@

onWal
Source:
@@ -16241,7 +16416,7 @@

onWalle
Source:
@@ -17367,7 +17542,7 @@

Parameters:
-

(async) submitOrder(order) → {Promise}

+

(async) submitFundingOffer(payload)

@@ -17379,7 +17554,7 @@

(async) su
Source:
@@ -17413,11 +17588,7 @@

(async) su
See:
@@ -17430,9 +17601,9 @@

(async) su
-

Sends a new order to the server and resolves the returned promise once the -order submit is confirmed. Emits an error if not authenticated. The order -can be either an array, key/value map, or Order object instance.

+

Sends a new funding offer to the server. Emits an error if not +authenticated. The funding offer can be either key/value pair object +literal, an instance of FundingOffer class or an array

@@ -17445,17 +17616,20 @@

(async) su

Example
-
const o = new Order({
-  type: Order.type.EXCHANGE_LIMIT,
-  amount: 18,
-  price: 0.75,
-  symbol: 'tBTCUSD',
-  hidden: true
+    
const fo = new FundingOffer({
+  type: 'LIMIT',
+  symbol: 'fUSD',
+  amount: '50',
+  rate: '0.001',
+  period: 2,
+  flags: 0
 }, ws)
 
-await ws.submitOrder(o)
+ws.submitFundingOffer(fo)
 
-console.log('order confirmed! status: %s', o.status)
+ws.onFundingOfferNew({ symbol: 'fUSD' }, (resp) => { + console.log('Funding offer status: ', resp.status) +})
@@ -17485,13 +17659,13 @@
Parameters:
- order + payload -object +FundingOffer | Array @@ -17504,7 +17678,7 @@
Parameters:
-

order object model or array

+

funding offer object model or array

@@ -17524,30 +17698,20 @@
Parameters:
- - -
Returns:
+
Throws:
-
-

p - resolves on submit notification

-
- +
+ +

an error if not authenticated

+ +
-
-
- Type -
-
- -Promise + -
-
- @@ -17556,7 +17720,7 @@
Returns:
-

(async) submitOrderMultiOp(opPayloads) → {Promise}

+

(async) submitOrder(order) → {Promise}

@@ -17568,7 +17732,7 @@

(async) Source:
@@ -17598,6 +17762,17 @@

(async) See: +
+ +
@@ -17608,9 +17783,9 @@

(async) -

Sends the op payloads to the server as an 'ox_multi' command. A promise is -returned and resolves immediately if authenticated, as no confirmation is -available for this message type.

+

Sends a new order to the server and resolves the returned promise once the +order submit is confirmed. Emits an error if not authenticated. The order +can be either an array, key/value map, or Order object instance.

@@ -17621,6 +17796,21 @@

(async) Example

+ +
const o = new Order({
+  type: Order.type.EXCHANGE_LIMIT,
+  amount: 18,
+  price: 0.75,
+  symbol: 'tBTCUSD',
+  hidden: true
+}, ws)
+
+await ws.submitOrder(o)
+
+console.log('order confirmed! status: %s', o.status)
+ +
Parameters:
@@ -17648,13 +17838,16 @@
Parameters:
- opPayloads + order -Array.<object> +object +| + +Array @@ -17664,7 +17857,7 @@
Parameters:
-

order operations

+

order object model or array

@@ -17690,7 +17883,7 @@
Returns:
-

p - rejects if not authenticated

+

p - resolves on submit notification

@@ -17716,7 +17909,7 @@
Returns:
-

subscribe(channel, payload)

+

(async) submitOrderMultiOp(opPayloads) → {Promise}

@@ -17728,7 +17921,167 @@

subscribeSource:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Sends the op payloads to the server as an 'ox_multi' command. A promise is +returned and resolves immediately if authenticated, as no confirmation is +available for this message type.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
opPayloads + + +Array.<object> + + + +

order operations

+ + + + + + + + + + + + + + + + +
Returns:
+ + +
+

p - rejects if not authenticated

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + +

subscribe(channel, payload)

+ + + + + + +
+ + +
Source:
+
@@ -20058,7 +20411,7 @@

(async) up
Source:
@@ -20462,7 +20815,7 @@

(constant)
Source:
@@ -20669,7 +21022,7 @@

(constant) W
Source:
@@ -20830,7 +21183,7 @@

(constant) WS
Source:
@@ -21112,6 +21465,181 @@

Returns:
+

cancelFundingOffer(payload)

+ + + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
See:
+
+ +
+ + + +
+ + + + + +
+

Cancels funding offer by ID. Emits an error if not authenticated. +The ID can be passed as a number, key/value pair object literal, +an instance of FundingOffer class or an array

+
+ + + + + + + + + +
Example
+ +
ws.cancelFundingOffer({ id: 1234 })
+
+ws.onFundingOfferClose({ symbol: 'fUSD' }, (resp) => {
+  console.log('Funding offer status: ', resp.status)
+})
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
payload + + +FundingOffer +| + +object +| + +Array +| + +number + + + +

funding offer model, array or ID to cancel

+ + + + + + + + + + + + + + +
Throws:
+ + + +
+ +

an error if not authenticated

+ +
+ + + + + + + + + + + + +

(async) cancelOrder(order) → {Promise}

@@ -21124,7 +21652,7 @@

(async) ca
Source:
@@ -21297,7 +21825,7 @@

(async) c
Source:
@@ -23945,7 +24473,7 @@

isAuth
Source:
@@ -24215,7 +24743,7 @@

isOpenSource:
@@ -24320,7 +24848,7 @@

isRecon
Source:
@@ -24848,7 +25376,7 @@

notifyUISource:
@@ -25226,7 +25754,7 @@

on
Source:
@@ -25522,7 +26050,7 @@

o
Source:
@@ -25818,7 +26346,7 @@

on
Source:
@@ -26045,7 +26573,7 @@

onCandleSource:
@@ -26310,7 +26838,7 @@

o
Source:
@@ -26570,7 +27098,7 @@

onF
Source:
@@ -26830,7 +27358,7 @@

Source:
@@ -27093,7 +27621,7 @@

Source:
@@ -27353,7 +27881,7 @@

on
Source:
@@ -27580,7 +28108,7 @@

onF
Source:
@@ -27840,7 +28368,7 @@

onFun
Source:
@@ -28100,7 +28628,7 @@

Source:
@@ -28363,7 +28891,7 @@

on
Source:
@@ -28623,7 +29151,7 @@

on
Source:
@@ -28883,7 +29411,7 @@

onFu
Source:
@@ -29143,7 +29671,7 @@

Source:
@@ -29406,7 +29934,7 @@

o
Source:
@@ -29666,7 +30194,7 @@

on
Source:
@@ -29926,7 +30454,7 @@

o
Source:
@@ -30186,7 +30714,7 @@

onInfoMe
Source:
@@ -30619,7 +31147,7 @@

onM
Source:
@@ -30846,7 +31374,7 @@

onMessageSource:
@@ -31069,7 +31597,7 @@

onNotif
Source:
@@ -31329,7 +31857,7 @@

onOrderBoo
Source:
@@ -31656,7 +32184,7 @@

on
Source:
@@ -31983,7 +32511,7 @@

onOrderCl
Source:
@@ -32344,7 +32872,7 @@

onOrderNew<
Source:
@@ -32705,7 +33233,7 @@

onOrde
Source:
@@ -33069,7 +33597,7 @@

onOrderU
Source:
@@ -33430,7 +33958,7 @@

onPosi
Source:
@@ -33690,7 +34218,7 @@

onPositi
Source:
@@ -33950,7 +34478,7 @@

onP
Source:
@@ -34212,7 +34740,7 @@

onPos
Source:
@@ -34609,7 +35137,7 @@

onStatusSource:
@@ -34871,7 +35399,7 @@

onTickerSource:
@@ -35136,7 +35664,7 @@

onTradeEn
Source:
@@ -35436,7 +35964,7 @@

onTradesSource:
@@ -35737,7 +36265,7 @@

onWal
Source:
@@ -35964,7 +36492,7 @@

onWalle
Source:
@@ -37086,6 +37614,184 @@

Parameters:
+ + + + +

(async) submitFundingOffer(payload)

+ + + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
See:
+
+ +
+ + + +
+ + + + + +
+

Sends a new funding offer to the server. Emits an error if not +authenticated. The funding offer can be either key/value pair object +literal, an instance of FundingOffer class or an array

+
+ + + + + + + + + +
Example
+ +
const fo = new FundingOffer({
+  type: 'LIMIT',
+  symbol: 'fUSD',
+  amount: '50',
+  rate: '0.001',
+  period: 2,
+  flags: 0
+}, ws)
+
+ws.submitFundingOffer(fo)
+
+ws.onFundingOfferNew({ symbol: 'fUSD' }, (resp) => {
+  console.log('Funding offer status: ', resp.status)
+})
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
payload + + +FundingOffer +| + +Array + + + +

funding offer object model or array

+ + + + + + + + + + + + + + +
Throws:
+ + + +
+ +

an error if not authenticated

+ +
+ + + + + + + + + @@ -37291,7 +37997,7 @@

(async) Source:
@@ -39781,7 +40487,7 @@

(async) up
Source:
@@ -40056,7 +40762,7 @@

Returns:

- Documentation generated by JSDoc 3.6.3 on Tue Mar 10 2020 21:05:28 GMT+0700 (Indochina Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
diff --git a/docs/global.html b/docs/global.html index fe35a918..337e5f97 100644 --- a/docs/global.html +++ b/docs/global.html @@ -27,7 +27,7 @@
@@ -343,6 +343,242 @@

Type Definitions

+

FundingOffer

+ + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
Properties:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +string + + + +

offer type i.e. LIMIT, FRRDELTAVAR

symbol + + +string + + + +

symbol i.e. fUSD, fBTC

amount + + +string + + + +

positive for buy, negative for sell i.e. '50'

rate + + +string + + + +

rate of the offer

period + + +number + + + +

Time period of offer. Min:2, Max:30 days

flags + + +number + + + +

flags

+ + + + + + + + +
Type:
+
    +
  • + +object + + +
  • +
+ + + + + + + +

PromiseThrottle

@@ -484,7 +720,7 @@
Type:

- Documentation generated by JSDoc 3.6.3 on Tue Mar 10 2020 21:05:28 GMT+0700 (Indochina Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
diff --git a/docs/index.html b/docs/index.html index 37ca0cff..5eea30b3 100644 --- a/docs/index.html +++ b/docs/index.html @@ -27,7 +27,7 @@
@@ -77,9 +77,9 @@

Quickstart

// do something with ws client

Docs

-

See docs/ws2.md for WS2 API methods, -and docs/usage.md for a basic usage guide. For executable -examples, refer to the examples/ folder.

+

Refer to the docs/ +folder for JSDoc-generated HTML documentation, and the examples/ +folder for executable examples covering common use cases.

Official API documentation at https://docs.bitfinex.com/v2/reference

Examples

Sending an order & tracking status:

@@ -236,7 +236,7 @@

Contributing


- Documentation generated by JSDoc 3.6.3 on Tue Mar 10 2020 21:05:28 GMT+0700 (Indochina Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
diff --git a/docs/transports_ws2.js.html b/docs/transports_ws2.js.html index 5208ed65..eea0c46d 100644 --- a/docs/transports_ws2.js.html +++ b/docs/transports_ws2.js.html @@ -27,7 +27,7 @@
@@ -1458,11 +1458,11 @@

transports/ws2.js

this._infoListeners[code].forEach(cb => cb(msg)) } - if (code === WSv2.INFO_CODES.SERVER_RESTART) { + if (code === WSv2.info.SERVER_RESTART) { debug('server restarted, please reconnect') - } else if (code === WSv2.INFO_CODES.MAINTENANCE_START) { + } else if (code === WSv2.info.MAINTENANCE_START) { debug('server maintenance period started!') - } else if (code === WSv2.INFO_CODES.MAINTENANCE_END) { + } else if (code === WSv2.info.MAINTENANCE_END) { debug('server maintenance period ended!') } } @@ -1975,6 +1975,89 @@

transports/ws2.js

return this._getEventPromise(`order-new-${packet.cid}`) } + /** + * @typedef {object} FundingOffer + * @property {string} type - offer type i.e. LIMIT, FRRDELTAVAR + * @property {string} symbol - symbol i.e. fUSD, fBTC + * @property {string} amount - positive for buy, negative for sell i.e. '50' + * @property {string} rate - rate of the offer + * @property {number} period - Time period of offer. Min:2, Max:30 days + * @property {number} flags - flags + */ + + /** + * Sends a new funding offer to the server. Emits an error if not + * authenticated. The funding offer can be either key/value pair object + * literal, an instance of FundingOffer class or an array + * + * @see WSv2#cancelFundingOffer + * + * @param {FundingOffer|Array} payload - funding offer object model or array + * @throws an error if not authenticated + * @example + * const fo = new FundingOffer({ + * type: 'LIMIT', + * symbol: 'fUSD', + * amount: '50', + * rate: '0.001', + * period: 2, + * flags: 0 + * }, ws) + * + * ws.submitFundingOffer(fo) + * + * ws.onFundingOfferNew({ symbol: 'fUSD' }, (resp) => { + * console.log('Funding offer status: ', resp.status) + * }) + */ + async submitFundingOffer (payload) { + if (!this._isAuthenticated) { + throw new Error('not authenticated') + } + + const packet = ( + payload instanceof FundingOffer + ? payload + : new FundingOffer(payload) + ).toNewOfferPacket() + + if (this._affCode) { + packet.meta.aff_code = packet.meta.aff_code || this._affCode + } + + this.send([0, 'fon', null, packet]) + } + + /** + * Cancels funding offer by ID. Emits an error if not authenticated. + * The ID can be passed as a number, key/value pair object literal, + * an instance of FundingOffer class or an array + * + * @see WSv2#submitFundingOffer + * + * @param {FundingOffer|object|Array|number} payload - funding offer model, array or ID to cancel + * @throws an error if not authenticated + * @example + * ws.cancelFundingOffer({ id: 1234 }) + * + * ws.onFundingOfferClose({ symbol: 'fUSD' }, (resp) => { + * console.log('Funding offer status: ', resp.status) + * }) + */ + cancelFundingOffer (payload) { + if (!this._isAuthenticated) { + throw new Error('not authenticated') + } + + const id = _isNumber(payload) + ? payload + : Array.isArray(payload) + ? payload[0] + : payload.id + + this.send([0, 'foc', null, { id }]) + } + /** * Send a changeset to update an order in-place while maintaining position in * the price queue. The changeset must contain the order ID, and supports a @@ -2352,9 +2435,8 @@

transports/ws2.js

* @param {Function} cb - callback * @see https://docs.bitfinex.com/v2/reference#ws-public-trades */ - onAccountTradeEntry ({ pair, symbol, cbGID }, cb) { - const id = pair || symbol || '' - this._registerListener('auth-te', { 1: id }, Trade, cbGID, cb) + onAccountTradeEntry ({ symbol, cbGID }, cb) { + this._registerListener('auth-te', { 1: symbol }, Trade, cbGID, cb) } /** @@ -2367,9 +2449,8 @@

transports/ws2.js

* @param {Function} cb - callback * @see https://docs.bitfinex.com/v2/reference#ws-auth-trades */ - onAccountTradeUpdate ({ pair, symbol, cbGID }, cb) { - const id = pair || symbol || '' - this._registerListener('auth-tu', { 1: id }, Trade, cbGID, cb) + onAccountTradeUpdate ({ symbol, cbGID }, cb) { + this._registerListener('auth-tu', { 1: symbol }, Trade, cbGID, cb) } /** @@ -2864,7 +2945,7 @@

transports/ws2.js


- Documentation generated by JSDoc 3.6.3 on Tue Mar 10 2020 21:05:28 GMT+0700 (Indochina Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
diff --git a/docs/util_precision.js.html b/docs/util_precision.js.html index 2c4cc4fa..73b2027c 100644 --- a/docs/util_precision.js.html +++ b/docs/util_precision.js.html @@ -27,7 +27,7 @@
@@ -103,7 +103,7 @@

util/precision.js


- Documentation generated by JSDoc 3.6.3 on Tue Mar 10 2020 21:05:28 GMT+0700 (Indochina Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
diff --git a/docs/util_ws2.js.html b/docs/util_ws2.js.html index 4cb138ee..20a730a0 100644 --- a/docs/util_ws2.js.html +++ b/docs/util_ws2.js.html @@ -27,7 +27,7 @@
@@ -69,7 +69,7 @@

util/ws2.js


- Documentation generated by JSDoc 3.6.3 on Tue Mar 10 2020 21:05:28 GMT+0700 (Indochina Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
diff --git a/docs/ws2_manager.js.html b/docs/ws2_manager.js.html index bd680b80..df909526 100644 --- a/docs/ws2_manager.js.html +++ b/docs/ws2_manager.js.html @@ -27,7 +27,7 @@
@@ -616,7 +616,7 @@

ws2_manager.js


- Documentation generated by JSDoc 3.6.3 on Tue Mar 10 2020 21:05:28 GMT+0700 (Indochina Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
From 19949cc722fe813b866dc54d30f97dd895eac58c Mon Sep 17 00:00:00 2001 From: Daniel1984 Date: Fri, 5 Jun 2020 17:26:59 +0300 Subject: [PATCH 05/10] new closeFundingCredit and closeFundingLoan functions --- lib/transports/ws2.js | 73 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/lib/transports/ws2.js b/lib/transports/ws2.js index a2920d74..6a3cc762 100644 --- a/lib/transports/ws2.js +++ b/lib/transports/ws2.js @@ -1947,6 +1947,8 @@ class WSv2 extends EventEmitter { * literal, an instance of FundingOffer class or an array * * @see WSv2#cancelFundingOffer + * @see WSv2#closeFundingCredit + * @see WSv2#closeFundingLoan * * @param {FundingOffer|Array} payload - funding offer object model or array * @throws an error if not authenticated @@ -1990,8 +1992,11 @@ class WSv2 extends EventEmitter { * an instance of FundingOffer class or an array * * @see WSv2#submitFundingOffer + * @see WSv2#closeFundingCredit + * @see WSv2#closeFundingLoan * - * @param {FundingOffer|object|Array|number} payload - funding offer model, array or ID to cancel + * @param {FundingOffer|object|Array|number} payload - funding offer model, + * array or ID to cancel * @throws an error if not authenticated * @example * ws.cancelFundingOffer({ id: 1234 }) @@ -2014,6 +2019,72 @@ class WSv2 extends EventEmitter { this.send([0, 'foc', null, { id }]) } + /** + * Cancels funding loan by ID. Emits an error if not authenticated. + * The ID can be passed as a number, key/value pair object literal, + * an instance of FundingLoan class or an array + * + * @see WSv2#submitFundingOffer + * @see WSv2#cancelFundingOffer + * @see WSv2#closeFundingCredit + * + * @param {FundingLoan|object|Array|number} payload - funding loan class, + * object literal, array or ID to cancel + * @throws an error if not authenticated + * @example + * ws.closeFundingLoan({ id: 1234 }) + * + * ws.onFundingLoanClose({ symbol: 'fUSD' }, (resp) => { + * console.log('Funding loan status: ', resp.status) + * }) + */ + closeFundingLoan (payload) { + if (!this._isAuthenticated) { + throw new Error('not authenticated') + } + + const id = _isNumber(payload) + ? payload + : Array.isArray(payload) + ? payload[0] + : payload.id + + this.send([0, 'flc', null, { id }]) + } + + /** + * Cancels funding credit by ID. Emits an error if not authenticated. + * The ID can be passed as a number, key/value pair object literal, + * an instance of FundingCredit class or an array + * + * @see WSv2#submitFundingOffer + * @see WSv2#cancelFundingOffer + * @see WSv2#closeFundingLoan + * + * @param {FundingCredit|object|Array|number} payload - funding credit class, + * object literal, array or ID to cancel + * @throws an error if not authenticated + * @example + * ws.closeFundingCredit({ id: 1234 }) + * + * ws.onFundingCreditClose({ symbol: 'fUSD' }, (resp) => { + * console.log('Funding credit status: ', resp.status) + * }) + */ + closeFundingCredit (payload) { + if (!this._isAuthenticated) { + throw new Error('not authenticated') + } + + const id = _isNumber(payload) + ? payload + : Array.isArray(payload) + ? payload[0] + : payload.id + + this.send([0, 'fcc', null, { id }]) + } + /** * Send a changeset to update an order in-place while maintaining position in * the price queue. The changeset must contain the order ID, and supports a From d7a2cb032f142634ba0da0dcac30daa2ee39fe48 Mon Sep 17 00:00:00 2001 From: Daniel1984 Date: Fri, 5 Jun 2020 17:28:51 +0300 Subject: [PATCH 06/10] updating docs --- docs/WS2Manager.html | 4 +- docs/WSv2.html | 1692 +++++++++++++++++++++++++---------- docs/global.html | 4 +- docs/index.html | 4 +- docs/transports_ws2.js.html | 77 +- docs/util_precision.js.html | 4 +- docs/util_ws2.js.html | 4 +- docs/ws2_manager.js.html | 4 +- 8 files changed, 1301 insertions(+), 492 deletions(-) diff --git a/docs/WS2Manager.html b/docs/WS2Manager.html index 50e513aa..19b05789 100644 --- a/docs/WS2Manager.html +++ b/docs/WS2Manager.html @@ -27,7 +27,7 @@
@@ -5082,7 +5082,7 @@
Parameters:

- Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Fri Jun 05 2020 17:26:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
diff --git a/docs/WSv2.html b/docs/WSv2.html index 3a21997d..61e1020d 100644 --- a/docs/WSv2.html +++ b/docs/WSv2.html @@ -27,7 +27,7 @@
@@ -739,7 +739,7 @@

(constant)
Source:
@@ -946,7 +946,7 @@

(constant) W
Source:
@@ -1107,7 +1107,7 @@

(constant) WS
Source:
@@ -1401,7 +1401,7 @@

can
Source:
@@ -1436,6 +1436,10 @@

can
@@ -1522,7 +1526,8 @@

Parameters:
-

funding offer model, array or ID to cancel

+

funding offer model, +array or ID to cancel

@@ -1576,7 +1581,7 @@

(async) ca
Source:
@@ -1749,7 +1754,7 @@

(async) c
Source:
@@ -2092,7 +2097,7 @@

Returns:
-

(async) enableFlag(flag) → {Promise}

+

closeFundingCredit(payload)

@@ -2104,7 +2109,7 @@

(async) ena
Source:
@@ -2138,7 +2143,11 @@

(async) ena
See:
@@ -2151,7 +2160,9 @@

(async) ena
-

Enables a configuration flag.

+

Cancels funding credit by ID. Emits an error if not authenticated. +The ID can be passed as a number, key/value pair object literal, +an instance of FundingCredit class or an array

@@ -2164,14 +2175,11 @@

(async) ena

Example
-
const ws = new WSv2()
-
-ws.on('open', async () => {
-  await ws.enableFlag(WSv2.flags.CHECKSUM)
-  console.log('ob checkums enabled')
-})
+    
ws.closeFundingCredit({ id: 1234 })
 
-await ws.open()
+ws.onFundingCreditClose({ symbol: 'fUSD' }, (resp) => { + console.log('Funding credit status: ', resp.status) +})
@@ -2201,12 +2209,21 @@
Parameters:
- flag + payload +FundingCredit +| + +object +| + +Array +| + number @@ -2217,7 +2234,8 @@
Parameters:
-

flag to update, as numeric value

+

funding credit class, +object literal, array or ID to cancel

@@ -2237,30 +2255,20 @@
Parameters:
- - -
Returns:
+
Throws:
-
-

p

-
+
+ +

an error if not authenticated

+ +
-
-
- Type -
-
- -Promise - + -
-
- @@ -2269,7 +2277,7 @@
Returns:
-

(async) enableSequencing(args) → {Promise}

+

closeFundingLoan(payload)

@@ -2281,7 +2289,7 @@

(async) Source:
@@ -2315,7 +2323,11 @@

(async) See:
@@ -2328,9 +2340,9 @@

(async) -

Configures the seq flag to enable sequencing (packet number) for this -connection. When enabled, the seq number will be the last value of -channel packet arrays.

+

Cancels funding loan by ID. Emits an error if not authenticated. +The ID can be passed as a number, key/value pair object literal, +an instance of FundingLoan class or an array

@@ -2341,53 +2353,20 @@

(async) Parameters:

+
Example
+
ws.closeFundingLoan({ id: 1234 })
 
-
-    
-    
-        
-        
-        
-
-        
+ws.onFundingLoanClose({ symbol: 'fUSD' }, (resp) => {
+  console.log('Funding loan status: ', resp.status)
+})
 
-        
 
-        
 
-        
-    
-    
 
-    
+    
Parameters:
- - - - - - - - - - - - + @@ -2465,30 +2435,20 @@
Properties
- - -
Returns:
+
Throws:
-
-

p

-
- +
+ +

an error if not authenticated

+ +
-
-
- Type -
-
- -Promise + -
-
- @@ -2497,7 +2457,7 @@
Returns:
-

getAuthArgs() → {object}

+

(async) enableFlag(flag) → {Promise}

@@ -2509,7 +2469,7 @@

getAuthArg
Source:
@@ -2543,9 +2503,7 @@

getAuthArg
See:
@@ -2558,7 +2516,7 @@

getAuthArg
-

Fetch the current default auth parameters

+

Enables a configuration flag.

@@ -2569,6 +2527,67 @@

getAuthArg +

Example
+ +
const ws = new WSv2()
+
+ws.on('open', async () => {
+  await ws.enableFlag(WSv2.flags.CHECKSUM)
+  console.log('ob checkums enabled')
+})
+
+await ws.open()
+ + + + +
Parameters:
+ + +
NameTypeDescription
args - - -object - - - -

params

-
Properties
- - @@ -2398,8 +2377,6 @@
Properties
- - @@ -2412,40 +2389,33 @@
Properties
- + +Array +| - - + - - - - - -
TypeAttributes
auditpayload -boolean +FundingLoan +| +object +| - - - - <optional>
- +number - - -

if true, an error is emitted on invalid seq

+ -

funding loan class, +object literal, array or ID to cancel

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
flag + + +number + + + +

flag to update, as numeric value

@@ -2589,7 +2608,7 @@
Returns:
-

authArgs

+

p

@@ -2600,7 +2619,7 @@
Returns:
-object +Promise
@@ -2615,7 +2634,7 @@
Returns:
-

getCandles(key) → {Array}

+

(async) enableSequencing(args) → {Promise}

@@ -2627,7 +2646,7 @@

getCandles<
Source:
@@ -2657,6 +2676,13 @@

getCandles< + +
See:
+
+
    +
  • WSv2#flags
  • +
+
@@ -2667,8 +2693,9 @@

getCandles<
-

Fetch a reference to the full set of synced candles for the specified key. -Set managedCandles: true in the constructor to use.

+

Configures the seq flag to enable sequencing (packet number) for this +connection. When enabled, the seq number will be the last value of +channel packet arrays.

@@ -2679,25 +2706,363 @@

getCandles< -

Example
- -
const ws = new WSv2({ managedCandles: true })
-
-  ws.on('open', async () => {
-      ws.onCandles({ key: 'trade:1m:tBTCUSD' }, () => {
-        const candles = ws.getCandles('trade:1m:tBTCUSD')
-
-        if (!candles) return
-
-        console.log('%d candles in dataset', candles.length)
-      })
-
-      ws.subscribeCandles({ key: 'trade:1m:tBTCUSD' })
-  })
-
-  await ws.open()
- - + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
args + + +object + + + +

params

+
Properties
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
audit + + +boolean + + + + + + <optional>
+ + + + + +

if true, an error is emitted on invalid seq

+ +
+ + + + + + + + + + + + + + + + +
Returns:
+ + +
+

p

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + +

getAuthArgs() → {object}

+ + + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
See:
+
+ +
+ + + +
+ + + + + +
+

Fetch the current default auth parameters

+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Returns:
+ + +
+

authArgs

+
+ + + +
+
+ Type +
+
+ +object + + +
+
+ + + + + + + + + + +

getCandles(key) → {Array}

+ + + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+

Fetch a reference to the full set of synced candles for the specified key. +Set managedCandles: true in the constructor to use.

+
+ + + + + + + + + +
Example
+ +
const ws = new WSv2({ managedCandles: true })
+
+  ws.on('open', async () => {
+      ws.onCandles({ key: 'trade:1m:tBTCUSD' }, () => {
+        const candles = ws.getCandles('trade:1m:tBTCUSD')
+
+        if (!candles) return
+
+        console.log('%d candles in dataset', candles.length)
+      })
+
+      ws.subscribeCandles({ key: 'trade:1m:tBTCUSD' })
+  })
+
+  await ws.open()
+ +
Parameters:
@@ -4397,7 +4762,7 @@

isAuth
Source:
@@ -4667,7 +5032,7 @@

isOpenSource:
@@ -4772,7 +5137,7 @@

isRecon
Source:
@@ -5300,7 +5665,7 @@

notifyUISource:
@@ -5678,7 +6043,7 @@

on
Source:
@@ -5974,7 +6339,7 @@

o
Source:
@@ -6270,7 +6635,7 @@

on
Source:
@@ -6497,7 +6862,7 @@

onCandleSource:
@@ -6762,7 +7127,7 @@

o
Source:
@@ -7022,7 +7387,7 @@

onF
Source:
@@ -7282,7 +7647,7 @@

Source:
@@ -7545,7 +7910,7 @@

Source:
@@ -7805,7 +8170,7 @@

on
Source:
@@ -8032,7 +8397,7 @@

onF
Source:
@@ -8292,7 +8657,7 @@

onFun
Source:
@@ -8552,7 +8917,7 @@

Source:
@@ -8815,7 +9180,7 @@

on
Source:
@@ -9075,7 +9440,7 @@

on
Source:
@@ -9335,7 +9700,7 @@

onFu
Source:
@@ -9595,7 +9960,7 @@

Source:
@@ -9858,7 +10223,7 @@

o
Source:
@@ -10118,7 +10483,7 @@

on
Source:
@@ -10378,7 +10743,7 @@

o
Source:
@@ -10638,7 +11003,7 @@

onInfoMe
Source:
@@ -11071,7 +11436,7 @@

onM
Source:
@@ -11298,7 +11663,7 @@

onMessageSource:
@@ -11521,7 +11886,7 @@

onNotif
Source:
@@ -11781,7 +12146,7 @@

onOrderBoo
Source:
@@ -12108,7 +12473,7 @@

on
Source:
@@ -12435,7 +12800,7 @@

onOrderCl
Source:
@@ -12796,7 +13161,7 @@

onOrderNew<
Source:
@@ -13157,7 +13522,7 @@

onOrde
Source:
@@ -13521,7 +13886,7 @@

onOrderU
Source:
@@ -13882,7 +14247,7 @@

onPosi
Source:
@@ -14142,7 +14507,7 @@

onPositi
Source:
@@ -14402,7 +14767,7 @@

onP
Source:
@@ -14664,7 +15029,7 @@

onPos
Source:
@@ -15061,7 +15426,7 @@

onStatusSource:
@@ -15323,7 +15688,7 @@

onTickerSource:
@@ -15588,7 +15953,7 @@

onTradeEn
Source:
@@ -15888,7 +16253,7 @@

onTradesSource:
@@ -16189,7 +16554,7 @@

onWal
Source:
@@ -16416,7 +16781,7 @@

onWalle
Source:
@@ -17554,7 +17919,7 @@

(async) Source:
@@ -17589,6 +17954,10 @@

(async) @@ -17921,7 +18290,7 @@

(async) Source:
@@ -20411,7 +20780,7 @@

(async) up
Source:
@@ -20815,7 +21184,7 @@

(constant)
Source:
@@ -21022,7 +21391,7 @@

(constant) W
Source:
@@ -21183,7 +21552,7 @@

(constant) WS
Source:
@@ -21477,7 +21846,7 @@

can
Source:
@@ -21512,6 +21881,10 @@

can
@@ -21598,7 +21971,8 @@

Parameters:
-

funding offer model, array or ID to cancel

+

funding offer model, +array or ID to cancel

@@ -21652,7 +22026,7 @@

(async) ca
Source:
@@ -21739,12 +22113,556 @@

Parameters:
- order + order + + + + + +object +| + +Array +| + +number + + + + + + + + + +

order model, array, or ID to be cancelled

+ + + + + + + + + + + + + + + + + + + + + +
Returns:
+ + +
+

p

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + +

(async) cancelOrders(orders) → {Promise}

+ + + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
See:
+
+ +
+ + + +
+ + + + + +
+

Cancels multiple orders, returns a promise that resolves once all +operations are confirmed.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
orders + + +Array.<object> +| + +Array.<Array> +| + +Array.<number> + + + +

array of order models, arrays +or IDs to be cancelled

+ + + + + + + + + + + + + + + + +
Returns:
+ + +
+

p

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + +

(async) close(code, reason) → {Promise}

+ + + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+

Closes the active connection. If there is none, rejects with a promise. +Resolves on success

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
code + + +number + + + +

passed to ws

reason + + +string + + + +

passed to ws

+ + + + + + + + + + + + + + + + +
Returns:
+ + +
+

p

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + +

closeFundingCredit(payload)

+ + + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
See:
+
+ +
+ + + +
+ + + + + +
+

Cancels funding credit by ID. Emits an error if not authenticated. +The ID can be passed as a number, key/value pair object literal, +an instance of FundingCredit class or an array

+
+ + + + + + + + + +
Example
+ +
ws.closeFundingCredit({ id: 1234 })
+
+ws.onFundingCreditClose({ symbol: 'fUSD' }, (resp) => {
+  console.log('Funding credit status: ', resp.status)
+})
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + @@ -21781,30 +22700,20 @@
Parameters:
- - -
Returns:
+
Throws:
-
-

p

-
- +
+ +

an error if not authenticated

+ +
-
-
- Type -
-
- -Promise + -
-
- @@ -21813,7 +22722,7 @@
Returns:
-

(async) cancelOrders(orders) → {Promise}

+

closeFundingLoan(payload)

@@ -21825,7 +22734,7 @@

(async) c
Source:
@@ -21859,7 +22768,11 @@

(async) c
See:
@@ -21872,182 +22785,26 @@

(async) c
-

Cancels multiple orders, returns a promise that resolves once all -operations are confirmed.

-
- - - - - - - - - - - -

Parameters:
- - -
NameTypeDescription
payload +FundingCredit +| + object | @@ -21761,7 +22679,8 @@
Parameters:
-

order model, array, or ID to be cancelled

funding credit class, +object literal, array or ID to cancel

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
orders - - -Array.<object> -| - -Array.<Array> -| - -Array.<number> - - - -

array of order models, arrays -or IDs to be cancelled

- - - - - - - - - - - - - - - - -
Returns:
- - -
-

p

+

Cancels funding loan by ID. Emits an error if not authenticated. +The ID can be passed as a number, key/value pair object literal, +an instance of FundingLoan class or an array

-
-
- Type -
-
- -Promise - - -
-
- - - - - - - -

(async) close(code, reason) → {Promise}

- - - -
- - -
Source:
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
Example
-
- - - - - -
-

Closes the active connection. If there is none, rejects with a promise. -Resolves on success

-
- - - - - - +
ws.closeFundingLoan({ id: 1234 })
 
+ws.onFundingLoanClose({ symbol: 'fUSD' }, (resp) => {
+  console.log('Funding loan status: ', resp.status)
+})
@@ -22077,36 +22834,22 @@
Parameters:
- code + payload -number - - - - - - - - - -

passed to ws

- +FundingLoan +| - +object +| - - - reason - +Array +| - - - -string +number @@ -22116,7 +22859,8 @@
Parameters:
-

passed to ws

+

funding loan class, +object literal, array or ID to cancel

@@ -22136,30 +22880,20 @@
Parameters:
- - -
Returns:
+
Throws:
-
-

p

-
- +
+ +

an error if not authenticated

+ +
-
-
- Type -
-
- -Promise + -
-
- @@ -24473,7 +25207,7 @@

isAuth
Source:
@@ -24743,7 +25477,7 @@

isOpenSource:
@@ -24848,7 +25582,7 @@

isRecon
Source:
@@ -25376,7 +26110,7 @@

notifyUISource:
@@ -25754,7 +26488,7 @@

on
Source:
@@ -26050,7 +26784,7 @@

o
Source:
@@ -26346,7 +27080,7 @@

on
Source:
@@ -26573,7 +27307,7 @@

onCandleSource:
@@ -26838,7 +27572,7 @@

o
Source:
@@ -27098,7 +27832,7 @@

onF
Source:
@@ -27358,7 +28092,7 @@

Source:
@@ -27621,7 +28355,7 @@

Source:
@@ -27881,7 +28615,7 @@

on
Source:
@@ -28108,7 +28842,7 @@

onF
Source:
@@ -28368,7 +29102,7 @@

onFun
Source:
@@ -28628,7 +29362,7 @@

Source:
@@ -28891,7 +29625,7 @@

on
Source:
@@ -29151,7 +29885,7 @@

on
Source:
@@ -29411,7 +30145,7 @@

onFu
Source:
@@ -29671,7 +30405,7 @@

Source:
@@ -29934,7 +30668,7 @@

o
Source:
@@ -30194,7 +30928,7 @@

on
Source:
@@ -30454,7 +31188,7 @@

o
Source:
@@ -30714,7 +31448,7 @@

onInfoMe
Source:
@@ -31147,7 +31881,7 @@

onM
Source:
@@ -31374,7 +32108,7 @@

onMessageSource:
@@ -31597,7 +32331,7 @@

onNotif
Source:
@@ -31857,7 +32591,7 @@

onOrderBoo
Source:
@@ -32184,7 +32918,7 @@

on
Source:
@@ -32511,7 +33245,7 @@

onOrderCl
Source:
@@ -32872,7 +33606,7 @@

onOrderNew<
Source:
@@ -33233,7 +33967,7 @@

onOrde
Source:
@@ -33597,7 +34331,7 @@

onOrderU
Source:
@@ -33958,7 +34692,7 @@

onPosi
Source:
@@ -34218,7 +34952,7 @@

onPositi
Source:
@@ -34478,7 +35212,7 @@

onP
Source:
@@ -34740,7 +35474,7 @@

onPos
Source:
@@ -35137,7 +35871,7 @@

onStatusSource:
@@ -35399,7 +36133,7 @@

onTickerSource:
@@ -35664,7 +36398,7 @@

onTradeEn
Source:
@@ -35964,7 +36698,7 @@

onTradesSource:
@@ -36265,7 +36999,7 @@

onWal
Source:
@@ -36492,7 +37226,7 @@

onWalle
Source:
@@ -37630,7 +38364,7 @@

(async) Source:
@@ -37665,6 +38399,10 @@

(async) @@ -37997,7 +38735,7 @@

(async) Source:
@@ -40487,7 +41225,7 @@

(async) up
Source:
@@ -40762,7 +41500,7 @@

Returns:

- Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Fri Jun 05 2020 17:26:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
diff --git a/docs/global.html b/docs/global.html index 337e5f97..c71737e0 100644 --- a/docs/global.html +++ b/docs/global.html @@ -27,7 +27,7 @@
@@ -720,7 +720,7 @@
Type:

- Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Fri Jun 05 2020 17:26:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
diff --git a/docs/index.html b/docs/index.html index 5eea30b3..3de29ad9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -27,7 +27,7 @@
@@ -236,7 +236,7 @@

Contributing


- Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Fri Jun 05 2020 17:26:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
diff --git a/docs/transports_ws2.js.html b/docs/transports_ws2.js.html index eea0c46d..e1f8fb12 100644 --- a/docs/transports_ws2.js.html +++ b/docs/transports_ws2.js.html @@ -27,7 +27,7 @@
@@ -1991,6 +1991,8 @@

transports/ws2.js

* literal, an instance of FundingOffer class or an array * * @see WSv2#cancelFundingOffer + * @see WSv2#closeFundingCredit + * @see WSv2#closeFundingLoan * * @param {FundingOffer|Array} payload - funding offer object model or array * @throws an error if not authenticated @@ -2034,8 +2036,11 @@

transports/ws2.js

* an instance of FundingOffer class or an array * * @see WSv2#submitFundingOffer + * @see WSv2#closeFundingCredit + * @see WSv2#closeFundingLoan * - * @param {FundingOffer|object|Array|number} payload - funding offer model, array or ID to cancel + * @param {FundingOffer|object|Array|number} payload - funding offer model, + * array or ID to cancel * @throws an error if not authenticated * @example * ws.cancelFundingOffer({ id: 1234 }) @@ -2058,6 +2063,72 @@

transports/ws2.js

this.send([0, 'foc', null, { id }]) } + /** + * Cancels funding loan by ID. Emits an error if not authenticated. + * The ID can be passed as a number, key/value pair object literal, + * an instance of FundingLoan class or an array + * + * @see WSv2#submitFundingOffer + * @see WSv2#cancelFundingOffer + * @see WSv2#closeFundingCredit + * + * @param {FundingLoan|object|Array|number} payload - funding loan class, + * object literal, array or ID to cancel + * @throws an error if not authenticated + * @example + * ws.closeFundingLoan({ id: 1234 }) + * + * ws.onFundingLoanClose({ symbol: 'fUSD' }, (resp) => { + * console.log('Funding loan status: ', resp.status) + * }) + */ + closeFundingLoan (payload) { + if (!this._isAuthenticated) { + throw new Error('not authenticated') + } + + const id = _isNumber(payload) + ? payload + : Array.isArray(payload) + ? payload[0] + : payload.id + + this.send([0, 'flc', null, { id }]) + } + + /** + * Cancels funding credit by ID. Emits an error if not authenticated. + * The ID can be passed as a number, key/value pair object literal, + * an instance of FundingCredit class or an array + * + * @see WSv2#submitFundingOffer + * @see WSv2#cancelFundingOffer + * @see WSv2#closeFundingLoan + * + * @param {FundingCredit|object|Array|number} payload - funding credit class, + * object literal, array or ID to cancel + * @throws an error if not authenticated + * @example + * ws.closeFundingCredit({ id: 1234 }) + * + * ws.onFundingCreditClose({ symbol: 'fUSD' }, (resp) => { + * console.log('Funding credit status: ', resp.status) + * }) + */ + closeFundingCredit (payload) { + if (!this._isAuthenticated) { + throw new Error('not authenticated') + } + + const id = _isNumber(payload) + ? payload + : Array.isArray(payload) + ? payload[0] + : payload.id + + this.send([0, 'fcc', null, { id }]) + } + /** * Send a changeset to update an order in-place while maintaining position in * the price queue. The changeset must contain the order ID, and supports a @@ -2945,7 +3016,7 @@

transports/ws2.js


- Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Fri Jun 05 2020 17:26:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
diff --git a/docs/util_precision.js.html b/docs/util_precision.js.html index 73b2027c..a76def98 100644 --- a/docs/util_precision.js.html +++ b/docs/util_precision.js.html @@ -27,7 +27,7 @@
@@ -103,7 +103,7 @@

util/precision.js


- Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Fri Jun 05 2020 17:26:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
diff --git a/docs/util_ws2.js.html b/docs/util_ws2.js.html index 20a730a0..2ecb8202 100644 --- a/docs/util_ws2.js.html +++ b/docs/util_ws2.js.html @@ -27,7 +27,7 @@
@@ -69,7 +69,7 @@

util/ws2.js


- Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Fri Jun 05 2020 17:26:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
diff --git a/docs/ws2_manager.js.html b/docs/ws2_manager.js.html index df909526..590c028b 100644 --- a/docs/ws2_manager.js.html +++ b/docs/ws2_manager.js.html @@ -27,7 +27,7 @@
@@ -616,7 +616,7 @@

ws2_manager.js


- Documentation generated by JSDoc 3.6.4 on Thu Jun 04 2020 18:20:26 GMT+0300 (Eastern European Summer Time) using the docdash theme. + Documentation generated by JSDoc 3.6.4 on Fri Jun 05 2020 17:26:26 GMT+0300 (Eastern European Summer Time) using the docdash theme.
From fc72bcab01841b2f1886612f944a10633de1c5fc Mon Sep 17 00:00:00 2001 From: Daniel1984 Date: Fri, 5 Jun 2020 17:31:14 +0300 Subject: [PATCH 07/10] closeFundingCredit and closeFundingLoan test coverage --- test/lib/transports/ws2-integration.js | 86 +++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 2 deletions(-) diff --git a/test/lib/transports/ws2-integration.js b/test/lib/transports/ws2-integration.js index 8fbd36c7..714caa00 100644 --- a/test/lib/transports/ws2-integration.js +++ b/test/lib/transports/ws2-integration.js @@ -292,7 +292,6 @@ describe('WSv2 integration', () => { assert.strictEqual(msg[1], 'fon') assert.deepStrictEqual(msg[3], testCases[scenario].expectedResult) sentPackets++ - wss.close() } ws.submitFundingOffer(testCases[scenario].payload) @@ -335,7 +334,6 @@ describe('WSv2 integration', () => { assert.strictEqual(msg[1], 'foc') assert.deepStrictEqual(msg[3], testCases[scenario].expectedResult) sentPackets++ - wss.close() } ws.cancelFundingOffer(testCases[scenario].payload) @@ -344,6 +342,90 @@ describe('WSv2 integration', () => { }) }) + describe('closeFundingLoan', () => { + const testCases = { + 'as class instance': { + payload: new FundingOffer({ id: 123 }), + expectedResult: { id: 123 } + }, + 'as object literal': { + payload: { id: 124 }, + expectedResult: { id: 124 } + }, + 'as number': { + payload: 125, + expectedResult: { id: 125 } + }, + 'as array': { + payload: [126], + expectedResult: { id: 126 } + } + } + + Object.keys(testCases).forEach((scenario) => { + it(scenario, async () => { + let sentPackets = 0 + wss = new MockWSv2Server() + ws = createTestWSv2Instance() + + await ws.open() + await ws.auth() + + ws._ws.send = (msgJSON) => { + const msg = JSON.parse(msgJSON) + assert.strictEqual(msg[1], 'flc') + assert.deepStrictEqual(msg[3], testCases[scenario].expectedResult) + sentPackets++ + } + + ws.closeFundingLoan(testCases[scenario].payload) + assert.strictEqual(sentPackets, 1) + }) + }) + }) + + describe('closeFundingCredit', () => { + const testCases = { + 'as class instance': { + payload: new FundingOffer({ id: 123 }), + expectedResult: { id: 123 } + }, + 'as object literal': { + payload: { id: 124 }, + expectedResult: { id: 124 } + }, + 'as number': { + payload: 125, + expectedResult: { id: 125 } + }, + 'as array': { + payload: [126], + expectedResult: { id: 126 } + } + } + + Object.keys(testCases).forEach((scenario) => { + it(scenario, async () => { + let sentPackets = 0 + wss = new MockWSv2Server() + ws = createTestWSv2Instance() + + await ws.open() + await ws.auth() + + ws._ws.send = (msgJSON) => { + const msg = JSON.parse(msgJSON) + assert.strictEqual(msg[1], 'fcc') + assert.deepStrictEqual(msg[3], testCases[scenario].expectedResult) + sentPackets++ + } + + ws.closeFundingCredit(testCases[scenario].payload) + assert.strictEqual(sentPackets, 1) + }) + }) + }) + describe('listeners', () => { it('manages listeners by cbGID', () => { ws = createTestWSv2Instance() From cc639624bef9a8edda921cae520a3cc65273ee6d Mon Sep 17 00:00:00 2001 From: Daniel1984 Date: Fri, 5 Jun 2020 18:30:20 +0300 Subject: [PATCH 08/10] version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 291d28f2..fbad1c12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bitfinex-api-node", - "version": "4.0.14", + "version": "4.0.15", "description": "Node reference library for Bitfinex API", "engines": { "node": ">=8.3.0" From 23667e930ba7f1fdba3f984b9ce5e209bfd21d0d Mon Sep 17 00:00:00 2001 From: Daniel1984 Date: Fri, 5 Jun 2020 18:31:14 +0300 Subject: [PATCH 09/10] changelog updated --- CHANGELOG | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index edfb5d4d..d020e406 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +4.0.15 +- WSv2: submitFundingOffer function +- WSv2: cancelFundingOffer function +- WSv2: closeFundingLoan function +- WSv2: closeFundingCredit function + 4.0.14 - fix: README docs reference From f823d65ca82534683c51b7b6bc1703fa8c3d9eae Mon Sep 17 00:00:00 2001 From: Daniel1984 Date: Wed, 17 Jun 2020 14:35:29 +0300 Subject: [PATCH 10/10] example usage added for submitFundingOffer, cancelFundingOffer, closeFundingLoan and closeFundingCredit --- examples/ws2/cancel_funding_offer.js | 24 +++++++++++++++++++ examples/ws2/close_funding_credit.js | 24 +++++++++++++++++++ examples/ws2/close_funding_loan.js | 24 +++++++++++++++++++ examples/ws2/submit_funding_offer.js | 32 ++++++++++++++++++++++++++ lib/transports/ws2.js | 4 ++++ test/lib/transports/ws2-integration.js | 6 +++-- 6 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 examples/ws2/cancel_funding_offer.js create mode 100644 examples/ws2/close_funding_credit.js create mode 100644 examples/ws2/close_funding_loan.js create mode 100644 examples/ws2/submit_funding_offer.js diff --git a/examples/ws2/cancel_funding_offer.js b/examples/ws2/cancel_funding_offer.js new file mode 100644 index 00000000..0f374064 --- /dev/null +++ b/examples/ws2/cancel_funding_offer.js @@ -0,0 +1,24 @@ +const { WSv2 } = require('../..') +// from 'bitfinex-api-node' module +// const { WSv2 } = require('bitfinex-api-node') + +;(async () => { + const ws2 = new WSv2({ + apiKey: '', + apiSecret: '' + // you can obtain your keys from https://www.bitfinex.com/api + }) + + try { + await ws2.open() + await ws2.auth() + + ws2.onFundingOfferClose({}, (resp) => { + console.log('onFundingOfferClose: ', resp) + }) + + ws2.cancelFundingOffer('') + } catch (error) { + console.log('error: ', error) + } +})() diff --git a/examples/ws2/close_funding_credit.js b/examples/ws2/close_funding_credit.js new file mode 100644 index 00000000..00d2cf6a --- /dev/null +++ b/examples/ws2/close_funding_credit.js @@ -0,0 +1,24 @@ +const { WSv2 } = require('../..') +// from 'bitfinex-api-node' module +// const { WSv2 } = require('bitfinex-api-node') + +;(async () => { + const ws2 = new WSv2({ + apiKey: '', + apiSecret: '' + // you can obtain your keys from https://www.bitfinex.com/api + }) + + try { + await ws2.open() + await ws2.auth() + + ws2.onFundingCreditClose({}, (resp) => { + console.log('onFundingCreditClose: ', resp) + }) + + ws2.closeFundingCredit('') + } catch (error) { + console.log('error: ', error) + } +})() diff --git a/examples/ws2/close_funding_loan.js b/examples/ws2/close_funding_loan.js new file mode 100644 index 00000000..11228335 --- /dev/null +++ b/examples/ws2/close_funding_loan.js @@ -0,0 +1,24 @@ +const { WSv2 } = require('../..') +// from 'bitfinex-api-node' module +// const { WSv2 } = require('bitfinex-api-node') + +;(async () => { + const ws2 = new WSv2({ + apiKey: '', + apiSecret: '' + // you can obtain your keys from https://www.bitfinex.com/api + }) + + try { + await ws2.open() + await ws2.auth() + + ws2.onFundingLoanClose({}, (resp) => { + console.log('onFundingLoanClose: ', resp) + }) + + ws2.closeFundingLoan('') + } catch (error) { + console.log('error: ', error) + } +})() diff --git a/examples/ws2/submit_funding_offer.js b/examples/ws2/submit_funding_offer.js new file mode 100644 index 00000000..4b79545d --- /dev/null +++ b/examples/ws2/submit_funding_offer.js @@ -0,0 +1,32 @@ +const { FundingOffer } = require('bfx-api-node-models') +const { WSv2 } = require('../..') +// from 'bitfinex-api-node' module +// const { WSv2 } = require('bitfinex-api-node') + +;(async () => { + const ws2 = new WSv2({ + apiKey: '', + apiSecret: '' + // you can obtain your keys from https://www.bitfinex.com/api + }) + + try { + await ws2.open() + await ws2.auth() + + ws2.onFundingOfferNew({ symbol: 'fUSD' }, (resp) => { + console.log('onFundingOfferNew:', resp) + }) + + ws2.submitFundingOffer(new FundingOffer({ + type: 'LIMIT', + symbol: 'fUSD', + amount: '-50', + rate: '0.001', + period: 2, + flags: 0 + })) + } catch (error) { + console.log('error: ', error) + } +})() diff --git a/lib/transports/ws2.js b/lib/transports/ws2.js index 6a3cc762..22dcce78 100644 --- a/lib/transports/ws2.js +++ b/lib/transports/ws2.js @@ -2039,6 +2039,8 @@ class WSv2 extends EventEmitter { * }) */ closeFundingLoan (payload) { + throw new Error('coming soon') // TODO: remove after socket input is implemented + // eslint-disable-next-line if (!this._isAuthenticated) { throw new Error('not authenticated') } @@ -2072,6 +2074,8 @@ class WSv2 extends EventEmitter { * }) */ closeFundingCredit (payload) { + throw new Error('coming soon') // TODO: remove after socket input is implemented + // eslint-disable-next-line if (!this._isAuthenticated) { throw new Error('not authenticated') } diff --git a/test/lib/transports/ws2-integration.js b/test/lib/transports/ws2-integration.js index 714caa00..58bb76ab 100644 --- a/test/lib/transports/ws2-integration.js +++ b/test/lib/transports/ws2-integration.js @@ -342,7 +342,8 @@ describe('WSv2 integration', () => { }) }) - describe('closeFundingLoan', () => { + // TODO: unskip when socket input is implemented + describe.skip('closeFundingLoan', () => { const testCases = { 'as class instance': { payload: new FundingOffer({ id: 123 }), @@ -384,7 +385,8 @@ describe('WSv2 integration', () => { }) }) - describe('closeFundingCredit', () => { + // TODO: unskip when socket input is implemented + describe.skip('closeFundingCredit', () => { const testCases = { 'as class instance': { payload: new FundingOffer({ id: 123 }),