From 46a6f442ef9b4b5945ea0718f7e3eeee48b4d5ce Mon Sep 17 00:00:00 2001 From: BOTREL Kilian Date: Fri, 10 Sep 2021 17:21:19 +0200 Subject: [PATCH 1/2] Added few futures related methods to http connector --- src/http.js | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/src/http.js b/src/http.js index bd1ce04..e15ec5e 100644 --- a/src/http.js +++ b/src/http.js @@ -168,16 +168,48 @@ module.exports = class LNMarketsHttp { return this.requestAPI(options) } - futuresHistory(params) { + futuresBidOfferHistory(params) { const options = { method: 'GET', - endpoint: '/futures/history', + endpoint: '/futures/history/bid-offer', params, } return this.requestAPI(options) } + futuresIndexHistory(params) { + const options = { + method: 'GET', + endpoint: '/futures/history/index', + params, + } + + return this.requestAPI(options) + } + + + futuresFixingHistory(params) { + const options = { + method: 'GET', + endpoint: '/futures/history/fixing', + params, + } + + return this.requestAPI(options) + } + + futuresCarryFees(params) { + const options = { + method: 'GET', + endpoint: '/futures/carry-fees', + params, + } + + return this.requestAPI(options) + } + + getUser() { const options = { method: 'GET', @@ -275,7 +307,7 @@ module.exports = class LNMarketsHttp { getLeaderboard() { const options = { method: 'GET', - endpoint: '/state/leaderboard', + endpoint: '/futures/leaderboard', } return this.requestAPI(options) From a04e6c1b64b33eaef1af4c02768608e5e863479f Mon Sep 17 00:00:00 2001 From: BOTREL Kilian Date: Fri, 10 Sep 2021 18:03:10 +0200 Subject: [PATCH 2/2] Updated documentation accordingly (misses some links) --- README.md | 192 ++++++++++++++++++++++++++++++++++++---------------- src/http.js | 2 +- 2 files changed, 133 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 3eadb3b..6888257 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,10 @@ These methods are designed to fill the gaps if the API evolves and the future bu - [`futuresCashinPosition`](#futuresCashinPosition) - [`futuresCloseAllPosisitions`](#futuresCloseAllPosisitions) - [`futuresClosePosition`](#futuresClosePosition) +- [`futuresIndexHistory`](#futuresIndexHistory) +- [`futuresBidOfferHistory`](#futuresBidOfferHistory) +- [`futuresFixingHistory`](#futuresFixingHistory) +- [`futuresCarryFeesHistory`](#futuresCarryFeesHistory) - [`deposit`](#deposit) - [`depositHistory`](#depositHistory) - [`futuresHistory`](#futuresHistory) @@ -172,9 +176,19 @@ Retrieve all or a part of user positions. ```yaml type: type: String + required: true + enum: ['open', 'running', 'closed'] + default: 'open' + +from: Integer + required: false + +to: Integer required: false - enum: ['all', 'open', 'running', 'closed'] - default: 'all' + +limit: Integer + required: false + default: 100 ``` Example: @@ -185,6 +199,8 @@ Example: }) ``` +[`GET /futures`](https://docs.lnmarkets.com/api/v1/#history) documentation for more details. + #### futuresUpdatePosition Modify stoploss or takeprofit parameter of an existing position. @@ -336,96 +352,162 @@ Example: [`DELETE /futures`](https://docs.lnmarkets.com/api/v1/#cancel) documentation for more details. -#### deposit +#### futuresIndexHistory -Add funds to your LN Markets balance. +Get index history data. ```yaml -amount: - type: Integer - required: true -unit: - type: String +from: Integer required: false - default: 'sat' + +to: Integer + required: false + +limit: Integer + required: false + default: 100 ``` Example: ```JS - await lnm.deposit({ - amount: 25000 + await lnm.futuresIndexHistory({ + limit: 20 }) ``` -[`POST /user/deposit`](https://docs.lnmarkets.com/api/v1/#deposit) documentation for more details. +[`GET /futures/history/index`]() documentation for more details (Waiting for new link). -#### depositHistory +#### futuresBidOfferHistory -Retrieve deposit history for this user. +Get bid and offer data over time. ```yaml -nbItem: - type: Integer +from: Integer required: false - default: 50 -index: - type: Integer + +to: Integer required: false - default: 0 -getLength: - type: Boolean + +limit: Integer required: false - default: false -start: - type: Integer + default: 100 +``` + +Example: + +```JS + await lnm.futuresBidOfferHistory({ + limit: 20 + }) +``` + +[`GET /futures/history/bid-offer`]() documentation for more details (Waiting for new link). + +#### futuresFixingHistory + +Get fixing data history. + +```yaml +from: Integer required: false -end: - type: Integer + +to: Integer required: false + +limit: Integer + required: false + default: 100 ``` Example: ```JS - await lnm.depositHistory({ - nbItem: 30 + await lnm.futuresFixingHistory({ + limit: 20 }) ``` -[`GET /user/deposit`](https://docs.lnmarkets.com/api/v1/#deposit) documentation for more details. +[`GET /futures/history/fixing`]() documentation for more details (Waiting for new link). -#### futuresHistory +#### futuresCarryFeesHistory -Retrieve the past bid, offer and index data recorded. +Get carry-fees history. ```yaml -table: - type: String +from: Integer + required: false + +to: Integer + required: false + +limit: Integer + required: false + default: 100 +``` + +Example: + +```JS + await lnm.futuresCarryFeesHistory({ + limit: 20 + }) +``` + +[`GET /futures/carry-fees`]() documentation for more details (Waiting for new link). + +#### deposit + +Add funds to your LN Markets balance. + +```yaml +amount: + type: Integer required: true - enum: ['bid_offer', 'index'] +unit: + type: String + required: false + default: 'sat' +``` + +Example: + +```JS + await lnm.deposit({ + amount: 25000 + }) +``` + +[`POST /user/deposit`](https://docs.lnmarkets.com/api/v1/#deposit) documentation for more details. + +#### depositHistory + +Retrieve deposit history for this user. + +```yaml from: type: Integer required: false + to: type: Integer required: false -limit: + +name: limit type: Integer required: false - default: 1000 ``` Example: ```JS - await lnm.futuresHistory({ - table: 'index', - limit: 250 + await lnm.depositHistory({ + limit: 30 }) ``` -[`GET /futures/history`](https://docs.lnmarkets.com/api/v1/#futures-data-history) documentation for more details. +[`GET /user/deposit`](https://docs.lnmarkets.com/api/v1/#deposit) documentation for more details. + #### getAnnouncements @@ -457,9 +539,7 @@ Example: await lnm.getLeaderboard() ``` -[`GET /state/leaderboard`](https://docs.lnmarkets.com/api/v1/#api-leaderboard) documentation for more details. - -[`GET /futures`](https://docs.lnmarkets.com/api/v1/#history) documentation for more details. +[`GET /futures/leaderboard`]() documentation for more details. (Waiting for new link) #### getUser @@ -582,22 +662,15 @@ Example: Retrieve user withdraw history. ```yaml -nbItem: - type: Integer - required: false - default: 50 -index: +from: type: Integer required: false - default: 0 -getLength: - type: Boolean - required: false - default: false -start: + +to: type: Integer required: false -end: + +name: limit type: Integer required: false ``` @@ -606,7 +679,7 @@ Example: ```JS await lnm.withdrawHistory({ - nbItem: 25 + limit: 25 }) ``` @@ -635,7 +708,6 @@ Example: ``` [`POST /lnurl/withdraw`](https://docs.lnmarkets.com/api/v1/#create-a-lnurl-withdraw) documentation for more details. -Use LNURL to withdraw directly from the user balance to the wallet #### requestAPI @@ -675,4 +747,4 @@ Example: ## Examples -You can find some code examples in the `examples`folder ! +You can find some code examples in the `examples` folder ! diff --git a/src/http.js b/src/http.js index e15ec5e..6cbb51c 100644 --- a/src/http.js +++ b/src/http.js @@ -199,7 +199,7 @@ module.exports = class LNMarketsHttp { return this.requestAPI(options) } - futuresCarryFees(params) { + futuresCarryFeesHistory(params) { const options = { method: 'GET', endpoint: '/futures/carry-fees',