Skip to content

Commit

Permalink
v3.1.0 release (#150)
Browse files Browse the repository at this point in the history
* v3.1.0 release

* update pipeline
  • Loading branch information
2pd authored Dec 18, 2023
1 parent b2a6f31 commit 260fdf3
Show file tree
Hide file tree
Showing 51 changed files with 1,301 additions and 554 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- run: npm install
- run: npm run standard
- run: node __tests__/websocket/testingServer.js & sleep 50 && npm run coverage
- uses: artiomtr/jest-coverage-report-action@v2.0-rc.1
- uses: artiomtr/jest-coverage-report-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
threshold: 95
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog


## 3.1.0 - 2023-12-18

### Added
- Add Auto Invest endpoints
- `GET /sapi/v1/margin/available-inventory` Query margin available inventory
- `POST /sapi/v1/margin/manual-liquidation` Margin manual liquidation

### Changed
- Update dependencies

### Removed
- `GET /sapi/v1/futures/loan/borrow/history`
- `GET /sapi/v1/futures/loan/repay/history`
- `GET /sapi/v2/futures/loan/wallet`
- `GET /sapi/v1/futures/loan/adjustCollateral/history`
- `GET /sapi/v1/futures/loan/liquidationHistory`
- `GET /sapi/v1/futures/loan/interestHistory`

## 3.0.0 - 2023-10-20

### Changed
Expand Down
34 changes: 34 additions & 0 deletions __tests__/spot/auto-invest/changePlanStatus.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* global describe, it, expect */
const { nockPostMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')
const MissingParameterError = require('../../../src/error/missingParameterError')

const {
mockResponse,
recvWindow
} = require('../../testUtils/mockData')

const planId = 12345
const status = 'ONGOING'

describe('#changePlanStatus', () => {
it.each([
[null, null],
[null, status],
[planId, null]
])('should throw MissingParameterError given missing params', (planId, status) => {
expect(() => {
SpotClient.changePlanStatus(planId, status)
}).toThrow(MissingParameterError)
})

it('should change plan status', () => {
const parameters = {
recvWindow
}
nockPostMock(`/sapi/v1/lending/auto-invest/plan/edit-status?${buildQueryString({ planId, status, ...parameters })}`)(mockResponse)
return SpotClient.changePlanStatus(planId, status, parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
28 changes: 28 additions & 0 deletions __tests__/spot/auto-invest/getListOfPlans.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* global describe, it, expect */
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')
const MissingParameterError = require('../../../src/error/missingParameterError')

const {
mockResponse,
recvWindow
} = require('../../testUtils/mockData')

const planType = 'SINGLE'

describe('#getListOfPlans', () => {
it('throw MissingParameterError when missing planType', () => {
expect(() => {
SpotClient.getListOfPlans(null)
}).toThrow(MissingParameterError)
})
it('should get list of plans', () => {
const parameters = {
recvWindow
}
nockMock(`/sapi/v1/lending/auto-invest/plan/list?${buildQueryString({ planType, ...parameters })}`)(mockResponse)
return SpotClient.getListOfPlans(planType, parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
33 changes: 33 additions & 0 deletions __tests__/spot/auto-invest/getTargetAssetList.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* global describe, it, expect */
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')

const {
mockResponse,
recvWindow
} = require('../../testUtils/mockData')

const size = 100
const current = 1

describe('#getTargetAssetList', () => {
it('should get target asset list without parameter attached', () => {
nockMock('/sapi/v1/lending/auto-invest/target-asset/list')(mockResponse)
return SpotClient.getTargetAssetList().then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})

it('should get target asset list', () => {
const parameters = {
size,
current,
recvWindow
}
nockMock(`/sapi/v1/lending/auto-invest/target-asset/list?${buildQueryString({ ...parameters })}`)(mockResponse)
return SpotClient.getTargetAssetList(parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
34 changes: 34 additions & 0 deletions __tests__/spot/auto-invest/getTargetAssetRoiData.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* global describe, it, expect */
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')
const MissingParameterError = require('../../../src/error/missingParameterError')

const {
mockResponse,
recvWindow
} = require('../../testUtils/mockData')

const targetAsset = 'BTC'
const hisRoiType = 'FIVE_YEAR'

describe('#getTargetAssetRoiData', () => {
it.each([
[null, null],
[null, hisRoiType],
[targetAsset, null]
])('should throw MissingParameterError given missing params', (targetAsset, hisRoiType) => {
expect(() => {
SpotClient.getTargetAssetRoiData(targetAsset, hisRoiType)
}).toThrow(MissingParameterError)
})

it('should get target asset roi data', () => {
const parameters = {
recvWindow
}
nockMock(`/sapi/v1/lending/auto-invest/target-asset/roi/list?${buildQueryString({ targetAsset, hisRoiType, ...parameters })}`)(mockResponse)
return SpotClient.getTargetAssetRoiData(targetAsset, hisRoiType, parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
33 changes: 33 additions & 0 deletions __tests__/spot/auto-invest/indexLinkedPlanRebalanceDetails.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* global describe, it, expect */
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')

const {
mockResponse,
recvWindow
} = require('../../testUtils/mockData')

const current = 1
const size = 100

describe('#indexLinkedPlanRebalanceDetails', () => {
it('should index linked plan rebalance details without parameter attached', () => {
nockMock('/sapi/v1/lending/auto-invest/rebalance/history')(mockResponse)
return SpotClient.indexLinkedPlanRebalanceDetails().then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})

it('should index linked plan rebalance details', () => {
const parameters = {
current,
size,
recvWindow
}
nockMock(`/sapi/v1/lending/auto-invest/rebalance/history?${buildQueryString({ ...parameters })}`)(mockResponse)
return SpotClient.indexLinkedPlanRebalanceDetails(parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
31 changes: 31 additions & 0 deletions __tests__/spot/auto-invest/indexLinkedPlanRedemption.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* global describe, it, expect */
const { nockPostMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')
const MissingParameterError = require('../../../src/error/missingParameterError')

const {
mockResponse,
recvWindow
} = require('../../testUtils/mockData')

const requestId = 12345
const indexId = 1
const redemptionPercentage = 10

describe('#indexLinkedPlanRedemption', () => {
it('throw MissingParameterError when missing requestId', () => {
expect(() => {
SpotClient.indexLinkedPlanRedemption(null)
}).toThrow(MissingParameterError)
})
it('should index linked plan redemption', () => {
const parameters = {
requestId,
recvWindow
}
nockPostMock(`/sapi/v1/lending/auto-invest/redeem?${buildQueryString({ indexId, redemptionPercentage, ...parameters })}`)(mockResponse)
return SpotClient.indexLinkedPlanRedemption(indexId, redemptionPercentage, parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* global describe, it, expect */
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')
const MissingParameterError = require('../../../src/error/missingParameterError')

const {
mockResponse,
asset,
recvWindow
} = require('../../testUtils/mockData')

const requestId = 12345
const current = 1
const size = 100

describe('#indexLinkedPlanRedemptionHistory', () => {
it('throw MissingParameterError when missing requestId', () => {
expect(() => {
SpotClient.indexLinkedPlanRedemptionHistory(null)
}).toThrow(MissingParameterError)
})
it('should index linked plan redemption history', () => {
const parameters = {
current,
asset,
size,
recvWindow
}
nockMock(`/sapi/v1/lending/auto-invest/redeem/history?${buildQueryString({ requestId, ...parameters })}`)(mockResponse)
return SpotClient.indexLinkedPlanRedemptionHistory(requestId, parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* global describe, it, expect */
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')

const {
mockResponse,
recvWindow
} = require('../../testUtils/mockData')

describe('#queryAllSourceAssetAndTargetAsset', () => {
it('should query all source asset and target asset without parameter attached', () => {
nockMock('/sapi/v1/lending/auto-invest/all/asset')(mockResponse)
return SpotClient.queryAllSourceAssetAndTargetAsset().then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})

it('should query all source asset and target asset', () => {
const parameters = {
recvWindow
}
nockMock(`/sapi/v1/lending/auto-invest/all/asset?${buildQueryString({ ...parameters })}`)(mockResponse)
return SpotClient.queryAllSourceAssetAndTargetAsset(parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,24 @@ const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/test

const {
mockResponse,
coin,
recvWindow
} = require('../../testUtils/mockData')

describe('#futuresLoanBorrowHistory', () => {
it('should get cross-collateral borrow history without parameter attached', () => {
nockMock('/sapi/v1/futures/loan/borrow/history')(mockResponse)

return SpotClient.futuresLoanBorrowHistory().then(response => {
describe('#queryHoldingDetailsOfThePlan', () => {
it('should query holding details of the plan without parameter attached', () => {
nockMock('/sapi/v1/lending/auto-invest/plan/id')(mockResponse)
return SpotClient.queryHoldingDetailsOfThePlan().then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})

it('should get cross-collateral borrow history', () => {
it('should query holding details of the plan', () => {
const parameters = {
coin,
recvWindow
}
nockMock(`/sapi/v1/futures/loan/borrow/history?${buildQueryString({ ...parameters })}`)(mockResponse)

return SpotClient.futuresLoanBorrowHistory(parameters).then(response => {
nockMock(`/sapi/v1/lending/auto-invest/plan/id?${buildQueryString({ ...parameters })}`)(mockResponse)
return SpotClient.queryHoldingDetailsOfThePlan(parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
Expand Down
28 changes: 28 additions & 0 deletions __tests__/spot/auto-invest/queryIndexDetails.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* global describe, it, expect */
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')
const MissingParameterError = require('../../../src/error/missingParameterError')

const {
mockResponse,
recvWindow
} = require('../../testUtils/mockData')

const indexId = 1

describe('#queryIndexDetails', () => {
it('throw MissingParameterError when missing indexId', () => {
expect(() => {
SpotClient.queryIndexDetails(null)
}).toThrow(MissingParameterError)
})
it('should query index details', () => {
const parameters = {
recvWindow
}
nockMock(`/sapi/v1/lending/auto-invest/index/info?${buildQueryString({ indexId, ...parameters })}`)(mockResponse)
return SpotClient.queryIndexDetails(indexId, parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* global describe, it, expect */
const { nockMock, buildQueryString, SpotClient } = require('../../testUtils/testSetup')
const MissingParameterError = require('../../../src/error/missingParameterError')

const {
mockResponse,
recvWindow
} = require('../../testUtils/mockData')

const indexId = 1

describe('#queryIndexLinkedPlanPositionDetails', () => {
it('throw MissingParameterError when missing indexId', () => {
expect(() => {
SpotClient.queryIndexLinkedPlanPositionDetails(null)
}).toThrow(MissingParameterError)
})
it('should query index linked plan position details', () => {
const parameters = {
recvWindow
}
nockMock(`/sapi/v1/lending/auto-invest/index/user-summary?${buildQueryString({ indexId, ...parameters })}`)(mockResponse)
return SpotClient.queryIndexLinkedPlanPositionDetails(indexId, parameters).then(response => {
expect(response).toBeDefined()
expect(response.data).toEqual(mockResponse)
})
})
})
Loading

0 comments on commit 260fdf3

Please sign in to comment.