From d4e07013e37c3c828a03214fb97494a98eb3b063 Mon Sep 17 00:00:00 2001 From: alplabin <122352306+alplabin@users.noreply.github.com> Date: Wed, 27 Nov 2024 09:57:33 +0900 Subject: [PATCH] Release v0.3.14 --- .github/workflows/tspackage.yaml | 2 +- CHANGELOG.md | 32 ++ .../margin/crossMarginCollateralRatio.ts | 13 + .../restful/margin/getAllCrossMarginPairs.ts | 3 +- examples/restful/margin/getAllMarginAssets.ts | 9 +- .../restful/margin/getMarginPriceindex.ts | 3 +- .../restful/margin/marginAccountNewOto.ts | 31 ++ .../restful/margin/marginAccountNewOtoco.ts | 32 ++ .../portfolioMargin/getAccountBalance.ts | 19 + .../portfolioMargin/getSpanAccountInfo.ts | 19 + .../getTieredCollateralRate.ts | 19 + .../simpleEarn/setLockedRedeemOption.ts | 17 + examples/restful/wallet/accountInfo.ts | 14 + examples/restful/wallet/depositAddressList.ts | 14 + .../wallet/getSymbolsDelistSchedule.ts | 14 + .../wallet/queryUserDelegationHistory.ts | 14 + .../restful/wallet/queryUserWalletBalance.ts | 14 + package-lock.json | 421 +++++++----------- package.json | 6 +- src/index.ts | 8 +- src/modules/enum.ts | 17 +- src/modules/restful/margin/margin.ts | 116 ++++- src/modules/restful/margin/methods.ts | 45 +- src/modules/restful/margin/types.ts | 104 ++++- src/modules/restful/market/market.ts | 32 +- src/modules/restful/market/types.ts | 4 + .../restful/portfolioMargin/methods.ts | 9 + .../portfolioMargin/portfolioMargin.ts | 49 ++ src/modules/restful/portfolioMargin/types.ts | 60 +++ src/modules/restful/simpleEarn/methods.ts | 4 + src/modules/restful/simpleEarn/simpleEarn.ts | 26 ++ src/modules/restful/simpleEarn/types.ts | 45 +- src/modules/restful/subAccount/types.ts | 8 +- src/modules/restful/trade/methods.ts | 6 +- src/modules/restful/trade/trade.ts | 56 +-- src/modules/restful/wallet/methods.ts | 75 ++-- src/modules/restful/wallet/types.ts | 63 +++ src/modules/restful/wallet/wallet.ts | 157 +++++-- .../websocket/websocketAPI/account/account.ts | 14 +- .../websocket/websocketAPI/market/market.ts | 28 +- .../websocket/websocketAPI/trade/trade.ts | 26 +- .../websocketAPI/userData/userData.ts | 6 +- .../margin/crossMarginCollateralRatio.ts | 39 ++ .../margin/getCrossMarginAccountDetails.ts | 50 ++- .../restful/margin/marginAccountNewOto.ts | 67 +++ .../restful/margin/marginAccountNewOtoco.ts | 89 ++++ .../portfolioMargin/getAccountBalance.ts | 21 + .../portfolioMargin/getSpanAccountInfo.ts | 18 + .../getTieredCollateralRate.ts | 38 ++ .../getFlexibleSubscriptionRecord.ts | 1 + .../simpleEarn/getLockedProductPosition.ts | 28 +- .../simpleEarn/getLockedRedemptionRecord.ts | 9 +- .../simpleEarn/getLockedSubscriptionRecord.ts | 1 + .../simpleEarn/setLockedRedeemOption.ts | 5 + .../getSubAccountAssetsForMasterAccount.ts | 30 +- .../restful/subAccount/getSubaccountAssets.ts | 41 +- .../mock_values/restful/wallet/accountInfo.ts | 9 + .../restful/wallet/depositAddressList.ts | 22 + .../wallet/getSymbolsDelistSchedule.ts | 17 + .../wallet/queryUserDelegationHistory.ts | 21 + .../restful/wallet/queryUserWalletBalance.ts | 44 ++ .../margin/crossMarginCollateralRatio.test.ts | 20 + .../margin/marginAccountNewOto.test.ts | 43 ++ .../margin/marginAccountNewOtoco.test.ts | 44 ++ .../getAccountBalance.test.ts | 23 + .../getSpanAccountInfo.test.ts | 23 + .../getTieredCollateralRate.test.ts | 23 + .../simpleEarn/setLockedRedeemOption.test.ts | 23 + tests/restful/trade/newOto.test.ts | 4 +- tests/restful/trade/newOtoco.test.ts | 4 +- tests/restful/wallet/accountInfo.test.ts | 20 + .../restful/wallet/depositAddressList.test.ts | 20 + .../wallet/getSymbolsDelistSchedule.test.ts | 20 + .../wallet/queryUserDelegationHistory.test.ts | 20 + .../wallet/queryUserWalletBalance.test.ts | 20 + 75 files changed, 2015 insertions(+), 496 deletions(-) create mode 100644 examples/restful/margin/crossMarginCollateralRatio.ts create mode 100644 examples/restful/margin/marginAccountNewOto.ts create mode 100644 examples/restful/margin/marginAccountNewOtoco.ts create mode 100644 examples/restful/portfolioMargin/getAccountBalance.ts create mode 100644 examples/restful/portfolioMargin/getSpanAccountInfo.ts create mode 100644 examples/restful/portfolioMargin/getTieredCollateralRate.ts create mode 100644 examples/restful/simpleEarn/setLockedRedeemOption.ts create mode 100644 examples/restful/wallet/accountInfo.ts create mode 100644 examples/restful/wallet/depositAddressList.ts create mode 100644 examples/restful/wallet/getSymbolsDelistSchedule.ts create mode 100644 examples/restful/wallet/queryUserDelegationHistory.ts create mode 100644 examples/restful/wallet/queryUserWalletBalance.ts create mode 100644 tests/mock_values/restful/margin/crossMarginCollateralRatio.ts create mode 100644 tests/mock_values/restful/margin/marginAccountNewOto.ts create mode 100644 tests/mock_values/restful/margin/marginAccountNewOtoco.ts create mode 100644 tests/mock_values/restful/portfolioMargin/getAccountBalance.ts create mode 100644 tests/mock_values/restful/portfolioMargin/getSpanAccountInfo.ts create mode 100644 tests/mock_values/restful/portfolioMargin/getTieredCollateralRate.ts create mode 100644 tests/mock_values/restful/simpleEarn/setLockedRedeemOption.ts create mode 100644 tests/mock_values/restful/wallet/accountInfo.ts create mode 100644 tests/mock_values/restful/wallet/depositAddressList.ts create mode 100644 tests/mock_values/restful/wallet/getSymbolsDelistSchedule.ts create mode 100644 tests/mock_values/restful/wallet/queryUserDelegationHistory.ts create mode 100644 tests/mock_values/restful/wallet/queryUserWalletBalance.ts create mode 100644 tests/restful/margin/crossMarginCollateralRatio.test.ts create mode 100644 tests/restful/margin/marginAccountNewOto.test.ts create mode 100644 tests/restful/margin/marginAccountNewOtoco.test.ts create mode 100644 tests/restful/portfolio_margin/getAccountBalance.test.ts create mode 100644 tests/restful/portfolio_margin/getSpanAccountInfo.test.ts create mode 100644 tests/restful/portfolio_margin/getTieredCollateralRate.test.ts create mode 100644 tests/restful/simpleEarn/setLockedRedeemOption.test.ts create mode 100644 tests/restful/wallet/accountInfo.test.ts create mode 100644 tests/restful/wallet/depositAddressList.test.ts create mode 100644 tests/restful/wallet/getSymbolsDelistSchedule.test.ts create mode 100644 tests/restful/wallet/queryUserDelegationHistory.test.ts create mode 100644 tests/restful/wallet/queryUserWalletBalance.test.ts diff --git a/.github/workflows/tspackage.yaml b/.github/workflows/tspackage.yaml index 051443f..4c366f3 100644 --- a/.github/workflows/tspackage.yaml +++ b/.github/workflows/tspackage.yaml @@ -10,7 +10,7 @@ jobs: build: strategy: matrix: - node-version: [16.x, 18.x, 20.x] + node-version: [18.x, 20.x, 22.x] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index e5fbc5b..058b558 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ # Changelog +## 0.3.14 - 2024-11-27 +### Added +- `Margin`: + - `POST /sapi/v1/margin/order/oto` + - `POST /sapi/v1/margin/order/otoco` +- `Portfolio`: + - `GET /sapi/v1/portfolio/balance` + - `GET /sapi/v2/portfolio/account` + - `GET /sapi/v2/portfolio/collateralRate` +- `Simple Earn`: + - `POST /sapi/v1/simple-earn/locked/setRedeemOption` +- `Wallet`: + - `GET /sapi/v1/account/info` + - `GET /sapi/v1/asset/custody/transfer-history` + - `GET /sapi/v1/asset/wallet/balance` + - `GET /sapi/v1/capital/deposit/address/list` + - `GET /sapi/v1/spot/delist-schedule` + +### Changed +- Updated dependencies +- Added optional parameters `showPermissionSets` and `symbolStatus` to endpoint `GET /api/v3/exchangeInfo` +- Fixed response type issue in `GET /sapi/v1/margin/crossMarginCollateralRatio` +- `POST /sapi/v1/simple-earn/locked/subscribe` new parameter: `redeemTo` +- Updated fields in response for the following endpoints: + - `GET /sapi/v1/margin/account` + - `GET /sapi/v1/simple-earn/locked/position` + - `GET /sapi/v1/simple-earn/flexible/history/subscriptionRecord` + - `GET /sapi/v1/simple-earn/locked/history/subscriptionRecord` + - `GET /sapi/v1/simple-earn/locked/history/redemptionRecord` + - `GET /sapi/v4/sub-account/assets` + - `GET /sapi/v3/sub-account/assets` + ## 0.3.13 - 2024-10-11 ### Added - `Dual Investment`: diff --git a/examples/restful/margin/crossMarginCollateralRatio.ts b/examples/restful/margin/crossMarginCollateralRatio.ts new file mode 100644 index 0000000..5671ca0 --- /dev/null +++ b/examples/restful/margin/crossMarginCollateralRatio.ts @@ -0,0 +1,13 @@ +import dotenv from 'dotenv'; +import { RestMarginTypes, Spot } from '../../../src/index'; + +dotenv.config(); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; +const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + +client.crossMarginCollateralRatio().then((res: RestMarginTypes.crossMarginCollateralRatioResponse[]) => { + console.log(res); +}).catch(err => { console.log(err); }); diff --git a/examples/restful/margin/getAllCrossMarginPairs.ts b/examples/restful/margin/getAllCrossMarginPairs.ts index 4a18909..1181604 100644 --- a/examples/restful/margin/getAllCrossMarginPairs.ts +++ b/examples/restful/margin/getAllCrossMarginPairs.ts @@ -4,8 +4,9 @@ import { RestMarginTypes, Spot } from '../../../src/index'; dotenv.config(); const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; const baseURL = process.env.BINANCE_BASE_URL || ''; -const client = new Spot(apiKey, '', { baseURL: baseURL }); +const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); client.getAllCrossMarginPairs().then((res: RestMarginTypes.getAllCrossMarginPairsResponse[]) => { console.log(res); diff --git a/examples/restful/margin/getAllMarginAssets.ts b/examples/restful/margin/getAllMarginAssets.ts index ad8d485..d72a098 100644 --- a/examples/restful/margin/getAllMarginAssets.ts +++ b/examples/restful/margin/getAllMarginAssets.ts @@ -4,9 +4,14 @@ import { RestMarginTypes, Spot } from '../../../src/index'; dotenv.config(); const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; const baseURL = process.env.BINANCE_BASE_URL || ''; -const client = new Spot(apiKey, '', { baseURL: baseURL }); +const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); -client.getAllMarginAssets().then((res: RestMarginTypes.getAllMarginAssetsResponse[]) => { +const options = { + asset: 'BNB', +}; + +client.getAllMarginAssets(options).then((res: RestMarginTypes.getAllMarginAssetsResponse[]) => { console.log(res); }).catch(err => { console.log(err); }); diff --git a/examples/restful/margin/getMarginPriceindex.ts b/examples/restful/margin/getMarginPriceindex.ts index 098f265..0f4962c 100644 --- a/examples/restful/margin/getMarginPriceindex.ts +++ b/examples/restful/margin/getMarginPriceindex.ts @@ -4,8 +4,9 @@ import { RestMarginTypes, Spot } from '../../../src/index'; dotenv.config(); const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; const baseURL = process.env.BINANCE_BASE_URL || ''; -const client = new Spot(apiKey, '', { baseURL: baseURL }); +const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); client.getMarginPriceIndex('BNBUSDT').then((res: RestMarginTypes.getMarginPriceIndexResponse) => { diff --git a/examples/restful/margin/marginAccountNewOto.ts b/examples/restful/margin/marginAccountNewOto.ts new file mode 100644 index 0000000..3f81159 --- /dev/null +++ b/examples/restful/margin/marginAccountNewOto.ts @@ -0,0 +1,31 @@ +import dotenv from 'dotenv'; +import { OtoPendingType, OrderListWorkingType, RestMarginTypes, Side, Spot, TimeInForce } from '../../../src/index'; + +dotenv.config(); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; +const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + +const options: RestMarginTypes.marginAccountNewOtoOptions = { + workingTimeInForce: TimeInForce.GTC, + pendingPrice: 595, + pendingTimeInForce: TimeInForce.GTC, + workingIcebergQty: 0.1, + recvWindow: 5000, +}; + +client.marginAccountNewOto( + 'BNBUSDT', + OrderListWorkingType.LIMIT, + Side.SELL, + 600, + 1, + OtoPendingType.LIMIT, + Side.BUY, + 1, + options +).then((res: RestMarginTypes.marginAccountNewOtoResponse) => { + console.log(res); +}).catch(err => { console.log(err); }); diff --git a/examples/restful/margin/marginAccountNewOtoco.ts b/examples/restful/margin/marginAccountNewOtoco.ts new file mode 100644 index 0000000..429ce30 --- /dev/null +++ b/examples/restful/margin/marginAccountNewOtoco.ts @@ -0,0 +1,32 @@ +import dotenv from 'dotenv'; +import { OrderListAboveBelowType, OrderListWorkingType, RestMarginTypes, Side, Spot, TimeInForce } from '../../../src/index'; + +dotenv.config(); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; +const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + +const options: RestMarginTypes.marginAccountNewOtocoOptions = { + workingTimeInForce: TimeInForce.GTC, + pendingAbovePrice: 605, + pendingBelowType: OrderListAboveBelowType.LIMIT_MAKER, + pendingBelowPrice: 595, + workingIcebergQty: 0.1, + recvWindow: 5000, +}; + +client.marginAccountNewOtoco( + 'BNBUSDT', + OrderListWorkingType.LIMIT, + Side.BUY, + 600, + 1, + Side.SELL, + 1, + OrderListAboveBelowType.LIMIT_MAKER, + options +).then((res: RestMarginTypes.marginAccountNewOtocoResponse) => { + console.log(res); +}).catch(err => { console.log(err); }); diff --git a/examples/restful/portfolioMargin/getAccountBalance.ts b/examples/restful/portfolioMargin/getAccountBalance.ts new file mode 100644 index 0000000..06a1f2d --- /dev/null +++ b/examples/restful/portfolioMargin/getAccountBalance.ts @@ -0,0 +1,19 @@ +import { Spot } from '../../../src/index'; +import dotenv from 'dotenv'; +import { getAccountBalanceOptions, getAccountBalanceResponse } from '../../../src/modules/restful/portfolioMargin/types'; + + +dotenv.config(); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; +const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + +const options: getAccountBalanceOptions = { + recvWindow: 5000, +}; + +client.getAccountBalance(options).then((res: getAccountBalanceResponse[]) => { + console.log(res); +}).catch(err => { console.log(err); }); diff --git a/examples/restful/portfolioMargin/getSpanAccountInfo.ts b/examples/restful/portfolioMargin/getSpanAccountInfo.ts new file mode 100644 index 0000000..0a1393f --- /dev/null +++ b/examples/restful/portfolioMargin/getSpanAccountInfo.ts @@ -0,0 +1,19 @@ +import { Spot } from '../../../src/index'; +import dotenv from 'dotenv'; +import { getSpanAccountInfoOptions, getSpanAccountInfoResponse } from '../../../src/modules/restful/portfolioMargin/types'; + + +dotenv.config(); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; +const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + +const options: getSpanAccountInfoOptions = { + recvWindow: 5000, +}; + +client.getSpanAccountInfo(options).then((res: getSpanAccountInfoResponse) => { + console.log(res); +}).catch(err => { console.log(err); }); diff --git a/examples/restful/portfolioMargin/getTieredCollateralRate.ts b/examples/restful/portfolioMargin/getTieredCollateralRate.ts new file mode 100644 index 0000000..4d50ba4 --- /dev/null +++ b/examples/restful/portfolioMargin/getTieredCollateralRate.ts @@ -0,0 +1,19 @@ +import { Spot } from '../../../src/index'; +import dotenv from 'dotenv'; +import { getTieredCollateralRateOptions, getTieredCollateralRateResponse } from '../../../src/modules/restful/portfolioMargin/types'; + + +dotenv.config(); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; +const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + +const options: getTieredCollateralRateOptions = { + recvWindow: 5000, +}; + +client.getTieredCollateralRate(options).then((res: getTieredCollateralRateResponse[]) => { + console.log(res); +}).catch(err => { console.log(err); }); diff --git a/examples/restful/simpleEarn/setLockedRedeemOption.ts b/examples/restful/simpleEarn/setLockedRedeemOption.ts new file mode 100644 index 0000000..4aef8ae --- /dev/null +++ b/examples/restful/simpleEarn/setLockedRedeemOption.ts @@ -0,0 +1,17 @@ +import dotenv from 'dotenv'; +import { RedeemOption, RestSimpleEarnTypes, Spot } from '../../../src/index'; + +dotenv.config(); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; +const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + +const options: RestSimpleEarnTypes.setLockedRedeemOptionOptions = { + recvWindow: 5000, +}; + +client.setLockedRedeemOption('1', RedeemOption.SPOT, options).then((res: RestSimpleEarnTypes.setLockedRedeemOptionResponse) => { + console.log(res); +}).catch(err => { console.log(err); }); diff --git a/examples/restful/wallet/accountInfo.ts b/examples/restful/wallet/accountInfo.ts new file mode 100644 index 0000000..f1f7bfb --- /dev/null +++ b/examples/restful/wallet/accountInfo.ts @@ -0,0 +1,14 @@ +import dotenv from 'dotenv'; +import { RestWalletTypes, Spot } from '../../../src/index'; + +dotenv.config(); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; +const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + + +client.accountInfo().then((res: RestWalletTypes.accountInfoResponse) => { + console.log(res); +}).catch(err => { console.log(err); }); diff --git a/examples/restful/wallet/depositAddressList.ts b/examples/restful/wallet/depositAddressList.ts new file mode 100644 index 0000000..f9d9d84 --- /dev/null +++ b/examples/restful/wallet/depositAddressList.ts @@ -0,0 +1,14 @@ +import dotenv from 'dotenv'; +import { RestWalletTypes, Spot } from '../../../src/index'; + +dotenv.config(); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; +const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + + +client.depositAddressList('BNB').then((res: RestWalletTypes.depositAddressListResponse[]) => { + console.log(res); +}).catch(err => { console.log(err); }); diff --git a/examples/restful/wallet/getSymbolsDelistSchedule.ts b/examples/restful/wallet/getSymbolsDelistSchedule.ts new file mode 100644 index 0000000..81162c6 --- /dev/null +++ b/examples/restful/wallet/getSymbolsDelistSchedule.ts @@ -0,0 +1,14 @@ +import dotenv from 'dotenv'; +import { RestWalletTypes, Spot } from '../../../src/index'; + +dotenv.config(); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; +const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + + +client.getSymbolsDelistSchedule().then((res: RestWalletTypes.getSymbolsDelistScheduleResponse[]) => { + console.log(res); +}).catch(err => { console.log(err); }); diff --git a/examples/restful/wallet/queryUserDelegationHistory.ts b/examples/restful/wallet/queryUserDelegationHistory.ts new file mode 100644 index 0000000..0811875 --- /dev/null +++ b/examples/restful/wallet/queryUserDelegationHistory.ts @@ -0,0 +1,14 @@ +import dotenv from 'dotenv'; +import { RestWalletTypes, Spot } from '../../../src/index'; + +dotenv.config(); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; +const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + + +client.queryUserDelegationHistory('email', 1695205000000, 1695205999999).then((res: RestWalletTypes.queryUserDelegationHistoryResponse) => { + console.log(res); +}).catch(err => { console.log(err); }); diff --git a/examples/restful/wallet/queryUserWalletBalance.ts b/examples/restful/wallet/queryUserWalletBalance.ts new file mode 100644 index 0000000..f939c8c --- /dev/null +++ b/examples/restful/wallet/queryUserWalletBalance.ts @@ -0,0 +1,14 @@ +import dotenv from 'dotenv'; +import { RestWalletTypes, Spot } from '../../../src/index'; + +dotenv.config(); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; +const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + + +client.queryUserWalletBalance().then((res: RestWalletTypes.queryUserWalletBalanceResponse[]) => { + console.log(res); +}).catch(err => { console.log(err); }); diff --git a/package-lock.json b/package-lock.json index 27687c9..b7752f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@binance/connector-typescript", - "version": "0.3.13", + "version": "0.3.14", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@binance/connector-typescript", - "version": "0.3.13", + "version": "0.3.14", "license": "MIT", "dependencies": { "axios": "^1.7.4", @@ -14,7 +14,7 @@ }, "devDependencies": { "@types/jest": "^29.5.4", - "@types/node": "^20.5.0", + "@types/node": "22.9.0", "@types/ws": "^8.5.5", "@typescript-eslint/eslint-plugin": "7.17.0", "@typescript-eslint/parser": "7.17.0", @@ -24,7 +24,7 @@ "ts-jest": "^29.1.1", "ts-node": "^10.9.1", "tsup": "^7.2.0", - "typescript": "^5.5.4" + "typescript": "^5.7.2" } }, "node_modules/@ampproject/remapping": { @@ -42,13 +42,14 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.25.7.tgz", - "integrity": "sha512-0xZJFNE5XMpENsgfHYTw8FbX4kv53mFLn2i3XPoq69LyhYSCBJtitaHx9QnsVTrsogI4Z3+HtEfZ2/GFPOtf5g==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz", + "integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/highlight": "^7.25.7", + "@babel/helper-validator-identifier": "^7.25.9", + "js-tokens": "^4.0.0", "picocolors": "^1.0.0" }, "engines": { @@ -56,9 +57,9 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.7.tgz", - "integrity": "sha512-9ickoLz+hcXCeh7jrcin+/SLWm+GkxE2kTvoYyp38p4WkdFXfQJxDFGWp/YHjiKLPx06z2A7W8XKuqbReXDzsw==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.2.tgz", + "integrity": "sha512-Z0WgzSEa+aUcdiJuCIqgujCshpMWgUpgOxXotrYPSA53hA3qopNaqcJpyr0hVb1FeWdnqFA35/fUtXgBK8srQg==", "dev": true, "license": "MIT", "engines": { @@ -66,22 +67,22 @@ } }, "node_modules/@babel/core": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.25.7.tgz", - "integrity": "sha512-yJ474Zv3cwiSOO9nXJuqzvwEeM+chDuQ8GJirw+pZ91sCGCyOZ3dJkVE09fTV0VEVzXyLWhh3G/AolYTPX7Mow==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.26.0.tgz", + "integrity": "sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg==", "dev": true, "license": "MIT", "dependencies": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.25.7", - "@babel/generator": "^7.25.7", - "@babel/helper-compilation-targets": "^7.25.7", - "@babel/helper-module-transforms": "^7.25.7", - "@babel/helpers": "^7.25.7", - "@babel/parser": "^7.25.7", - "@babel/template": "^7.25.7", - "@babel/traverse": "^7.25.7", - "@babel/types": "^7.25.7", + "@babel/code-frame": "^7.26.0", + "@babel/generator": "^7.26.0", + "@babel/helper-compilation-targets": "^7.25.9", + "@babel/helper-module-transforms": "^7.26.0", + "@babel/helpers": "^7.26.0", + "@babel/parser": "^7.26.0", + "@babel/template": "^7.25.9", + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.26.0", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -107,13 +108,14 @@ } }, "node_modules/@babel/generator": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.7.tgz", - "integrity": "sha512-5Dqpl5fyV9pIAD62yK9P7fcA768uVPUyrQmqpqstHWgMma4feF1x/oFysBCVZLY5wJ2GkMUCdsNDnGZrPoR6rA==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.2.tgz", + "integrity": "sha512-zevQbhbau95nkoxSq3f/DC/SC+EEOUZd3DYqfSkMhY2/wfSeaHV1Ew4vk8e+x8lja31IbyuUa2uQ3JONqKbysw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.25.7", + "@babel/parser": "^7.26.2", + "@babel/types": "^7.26.0", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^3.0.2" @@ -123,14 +125,14 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.7.tgz", - "integrity": "sha512-DniTEax0sv6isaw6qSQSfV4gVRNtw2rte8HHM45t9ZR0xILaufBRNkpMifCRiAPyvL4ACD6v0gfCwCmtOQaV4A==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.9.tgz", + "integrity": "sha512-j9Db8Suy6yV/VHa4qzrj9yZfZxhLWQdVnRlXxmKLYlhWUVB1sB2G5sxuWYXk/whHD9iW76PmNzxZ4UCnTQTVEQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.25.7", - "@babel/helper-validator-option": "^7.25.7", + "@babel/compat-data": "^7.25.9", + "@babel/helper-validator-option": "^7.25.9", "browserslist": "^4.24.0", "lru-cache": "^5.1.1", "semver": "^6.3.1" @@ -150,30 +152,29 @@ } }, "node_modules/@babel/helper-module-imports": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.25.7.tgz", - "integrity": "sha512-o0xCgpNmRohmnoWKQ0Ij8IdddjyBFE4T2kagL/x6M3+4zUgc+4qTOUBoNe4XxDskt1HPKO007ZPiMgLDq2s7Kw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.25.9.tgz", + "integrity": "sha512-tnUA4RsrmflIM6W6RFTLFSXITtl0wKjgpnLgXyowocVPrbYrLUXSBXDgTs8BlbmIzIdlBySRQjINYs2BAkiLtw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/traverse": "^7.25.7", - "@babel/types": "^7.25.7" + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.25.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.25.7.tgz", - "integrity": "sha512-k/6f8dKG3yDz/qCwSM+RKovjMix563SLxQFo0UhRNo239SP6n9u5/eLtKD6EAjwta2JHJ49CsD8pms2HdNiMMQ==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.26.0.tgz", + "integrity": "sha512-xO+xu6B5K2czEnQye6BHA7DolFFmS3LB7stHZFaOLb1pAwO1HWLS8fXA+eh0A2yIvltPVmx3eNNDBJA2SLHXFw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-module-imports": "^7.25.7", - "@babel/helper-simple-access": "^7.25.7", - "@babel/helper-validator-identifier": "^7.25.7", - "@babel/traverse": "^7.25.7" + "@babel/helper-module-imports": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9", + "@babel/traverse": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -183,33 +184,19 @@ } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.7.tgz", - "integrity": "sha512-eaPZai0PiqCi09pPs3pAFfl/zYgGaE6IdXtYvmf0qlcDTd3WCtO7JWCcRd64e0EQrcYgiHibEZnOGsSY4QSgaw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz", + "integrity": "sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw==", "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/helper-simple-access": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.25.7.tgz", - "integrity": "sha512-FPGAkJmyoChQeM+ruBGIDyrT2tKfZJO8NcxdC+CWNJi7N8/rZpSxK7yvBJ5O/nF1gfu5KzN7VKG3YVSLFfRSxQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/traverse": "^7.25.7", - "@babel/types": "^7.25.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-string-parser": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.7.tgz", - "integrity": "sha512-CbkjYdsJNHFk8uqpEkpCvRs3YRp9tY6FmFY7wLMSYuGYkrdUi7r2lc4/wqsvlHoMznX3WJ9IP8giGPq68T/Y6g==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", "dev": true, "license": "MIT", "engines": { @@ -217,9 +204,9 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.7.tgz", - "integrity": "sha512-AM6TzwYqGChO45oiuPqwL2t20/HdMC1rTPAesnBCgPCSF1x3oN9MVUwQV2iyz4xqWrctwK5RNC8LV22kaQCNYg==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", "dev": true, "license": "MIT", "engines": { @@ -227,9 +214,9 @@ } }, "node_modules/@babel/helper-validator-option": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.25.7.tgz", - "integrity": "sha512-ytbPLsm+GjArDYXJ8Ydr1c/KJuutjF2besPNbIZnZ6MKUxi/uTA22t2ymmA4WFjZFpjiAMO0xuuJPqK2nvDVfQ==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.25.9.tgz", + "integrity": "sha512-e/zv1co8pp55dNdEcCynfj9X7nyUKUXoUEwfXqaZt0omVOmDe9oOTdKStH4GmAw6zxMFs50ZayuMfHDKlO7Tfw==", "dev": true, "license": "MIT", "engines": { @@ -237,121 +224,27 @@ } }, "node_modules/@babel/helpers": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.25.7.tgz", - "integrity": "sha512-Sv6pASx7Esm38KQpF/U/OXLwPPrdGHNKoeblRxgZRLXnAtnkEe4ptJPDtAZM7fBLadbc1Q07kQpSiGQ0Jg6tRA==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.0.tgz", + "integrity": "sha512-tbhNuIxNcVb21pInl3ZSjksLCvgdZy9KwJ8brv993QtIVKJBBkYXz4q4ZbAv31GdnC+R90np23L5FbEBlthAEw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/template": "^7.25.7", - "@babel/types": "^7.25.7" + "@babel/template": "^7.25.9", + "@babel/types": "^7.26.0" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/highlight": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.25.7.tgz", - "integrity": "sha512-iYyACpW3iW8Fw+ZybQK+drQre+ns/tKpXbNESfrhNnPLIklLbXr7MYJ6gPEd0iETGLOK+SxMjVvKb/ffmk+FEw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/helper-validator-identifier": "^7.25.7", - "chalk": "^2.4.2", - "js-tokens": "^4.0.0", - "picocolors": "^1.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight/node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/@babel/highlight/node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@babel/highlight/node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/@babel/highlight/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/@babel/parser": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.7.tgz", - "integrity": "sha512-aZn7ETtQsjjGG5HruveUK06cU3Hljuhd9Iojm4M8WWv3wLE6OkE5PWbDUkItmMgegmccaITudyuW5RPYrYlgWw==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.2.tgz", + "integrity": "sha512-DWMCZH9WA4Maitz2q21SRKHo9QXZxkDsbNZoVD62gusNtNBBqDg9i7uOhASfTfIGNzW+O+r7+jAlM8dwphcJKQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.25.7" + "@babel/types": "^7.26.0" }, "bin": { "parser": "bin/babel-parser.js" @@ -416,13 +309,13 @@ } }, "node_modules/@babel/plugin-syntax-import-attributes": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.25.7.tgz", - "integrity": "sha512-AqVo+dguCgmpi/3mYBdu9lkngOBlQ2w2vnNpa6gfiCxQZLzV4ZbhsXitJ2Yblkoe1VQwtHSaNmIaGll/26YWRw==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.26.0.tgz", + "integrity": "sha512-e2dttdsJ1ZTpi3B9UYGLw41hifAubg19AtCu/2I/F1QNVclOBr1dYpTdmdyZ84Xiz43BS/tCUkMAZNLv12Pi+A==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" + "@babel/helper-plugin-utils": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -458,13 +351,13 @@ } }, "node_modules/@babel/plugin-syntax-jsx": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.25.7.tgz", - "integrity": "sha512-ruZOnKO+ajVL/MVx+PwNBPOkrnXTXoWMtte1MBpegfCArhqOe3Bj52avVj1huLLxNKYKXYaSxZ2F+woK1ekXfw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.25.9.tgz", + "integrity": "sha512-ld6oezHQMZsZfp6pWtbjaNDF2tiiCYYDqQszHt5VV437lewP9aSi2Of99CK0D0XB21k7FLgnLcmQKyKzynfeAA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" + "@babel/helper-plugin-utils": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -584,13 +477,13 @@ } }, "node_modules/@babel/plugin-syntax-typescript": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.7.tgz", - "integrity": "sha512-rR+5FDjpCHqqZN2bzZm18bVYGaejGq5ZkpVCJLXor/+zlSrSoc4KWcHI0URVWjl/68Dyr1uwZUz/1njycEAv9g==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.9.tgz", + "integrity": "sha512-hjMgRy5hb8uJJjUcdWunWVcoi9bGpJp8p5Ol1229PoN6aytsLwNMgmdftO23wnCLMfVmTwZDWMPNq/D1SY60JQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" + "@babel/helper-plugin-utils": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -600,32 +493,32 @@ } }, "node_modules/@babel/template": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.7.tgz", - "integrity": "sha512-wRwtAgI3bAS+JGU2upWNL9lSlDcRCqD05BZ1n3X2ONLH1WilFP6O1otQjeMK/1g0pvYcXC7b/qVUB1keofjtZA==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.9.tgz", + "integrity": "sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg==", "dev": true, "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.25.7", - "@babel/parser": "^7.25.7", - "@babel/types": "^7.25.7" + "@babel/code-frame": "^7.25.9", + "@babel/parser": "^7.25.9", + "@babel/types": "^7.25.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.7.tgz", - "integrity": "sha512-jatJPT1Zjqvh/1FyJs6qAHL+Dzb7sTb+xr7Q+gM1b+1oBsMsQQ4FkVKb6dFlJvLlVssqkRzV05Jzervt9yhnzg==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.9.tgz", + "integrity": "sha512-ZCuvfwOwlz/bawvAuvcj8rrithP2/N55Tzz342AkTvq4qaWbGfmCk/tKhNaV2cthijKrPAA8SRJV5WWe7IBMJw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.25.7", - "@babel/generator": "^7.25.7", - "@babel/parser": "^7.25.7", - "@babel/template": "^7.25.7", - "@babel/types": "^7.25.7", + "@babel/code-frame": "^7.25.9", + "@babel/generator": "^7.25.9", + "@babel/parser": "^7.25.9", + "@babel/template": "^7.25.9", + "@babel/types": "^7.25.9", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -644,15 +537,14 @@ } }, "node_modules/@babel/types": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.7.tgz", - "integrity": "sha512-vwIVdXG+j+FOpkwqHRcBgHLYNL7XMkufrlaFvL9o6Ai9sJn9+PdyIL5qa0XzTZw084c+u9LOls53eoZWP/W5WQ==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.0.tgz", + "integrity": "sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.25.7", - "@babel/helper-validator-identifier": "^7.25.7", - "to-fast-properties": "^2.0.0" + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -1064,25 +956,28 @@ } }, "node_modules/@eslint-community/eslint-utils": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", - "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz", + "integrity": "sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==", "dev": true, "license": "MIT", "dependencies": { - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.3" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, + "funding": { + "url": "https://opencollective.com/eslint" + }, "peerDependencies": { "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" } }, "node_modules/@eslint-community/regexpp": { - "version": "4.11.1", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.11.1.tgz", - "integrity": "sha512-m4DVN9ZqskZoLU5GlWZadwDnYo3vAEydiUayB9widCl9ffWx2IvPnp6n3on5rJmziJSw9Bv+Z3ChDVdMwXCY8Q==", + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", + "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", "dev": true, "license": "MIT", "engines": { @@ -1961,9 +1856,9 @@ } }, "node_modules/@types/jest": { - "version": "29.5.13", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.13.tgz", - "integrity": "sha512-wd+MVEZCHt23V0/L642O5APvspWply/rGY5BcW4SUETo2UzPU3Z26qr8jC2qxpimI2jjx9h7+2cj2FwIr01bXg==", + "version": "29.5.14", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.14.tgz", + "integrity": "sha512-ZN+4sdnLUbo8EVvVc2ao0GFW6oVrQRPn4K2lglySj7APvSrgzxHiNNK99us4WDMi57xxA2yggblIAMNhXOotLQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1972,13 +1867,13 @@ } }, "node_modules/@types/node": { - "version": "20.16.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.11.tgz", - "integrity": "sha512-y+cTCACu92FyA5fgQSAI8A1H429g7aSK2HsO7K4XYUWc4dY5IUz55JSDIYT6/VsOLfGy8vmvQYC2hfb0iF16Uw==", + "version": "22.9.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.0.tgz", + "integrity": "sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": "~6.19.2" + "undici-types": "~6.19.8" } }, "node_modules/@types/stack-utils": { @@ -1989,9 +1884,9 @@ "license": "MIT" }, "node_modules/@types/ws": { - "version": "8.5.12", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.12.tgz", - "integrity": "sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==", + "version": "8.5.13", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.13.tgz", + "integrity": "sha512-osM/gWBTPKgHV8XkTunnegTRIsvF6owmf5w+JtAfOw472dptdm0dlGv4xCt6GwQRcC2XVOvvRE/0bAoQcL2QkA==", "dev": true, "license": "MIT", "dependencies": { @@ -2216,9 +2111,9 @@ "license": "ISC" }, "node_modules/acorn": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", - "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", + "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", "dev": true, "license": "MIT", "bin": { @@ -2382,9 +2277,9 @@ "license": "MIT" }, "node_modules/axios": { - "version": "1.7.7", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", - "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", + "version": "1.7.8", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.8.tgz", + "integrity": "sha512-Uu0wb7KNqK2t5K+YQyVCLM76prD5sRFjKHbJYCP1J7JFGEQ6nN7HWn9+04LAeiJ3ji54lgS/gZCH1oxyrf1SPw==", "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", @@ -2562,9 +2457,9 @@ } }, "node_modules/browserslist": { - "version": "4.24.0", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.0.tgz", - "integrity": "sha512-Rmb62sR1Zpjql25eSanFGEhAxcFwfA1K0GuQcLoaJBAcENegrQut3hYdhXFF1obQfiDyqIW/cLM5HSJ/9k884A==", + "version": "4.24.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.2.tgz", + "integrity": "sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg==", "dev": true, "funding": [ { @@ -2582,10 +2477,10 @@ ], "license": "MIT", "dependencies": { - "caniuse-lite": "^1.0.30001663", - "electron-to-chromium": "^1.5.28", + "caniuse-lite": "^1.0.30001669", + "electron-to-chromium": "^1.5.41", "node-releases": "^2.0.18", - "update-browserslist-db": "^1.1.0" + "update-browserslist-db": "^1.1.1" }, "bin": { "browserslist": "cli.js" @@ -2671,9 +2566,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001667", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001667.tgz", - "integrity": "sha512-7LTwJjcRkzKFmtqGsibMeuXmvFDfZq/nzIjnmgCGzKKRVzjD72selLDK1oPF/Oxzmt4fNcPvTDvGqSDG4tCALw==", + "version": "1.0.30001684", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001684.tgz", + "integrity": "sha512-G1LRwLIQjBQoyq0ZJGqGIJUXzJ8irpbjHLpVRXDvBEScFJ9b17sgK6vlx0GAJFE21okD7zXl08rRRUfq6HdoEQ==", "dev": true, "funding": [ { @@ -2898,9 +2793,9 @@ "license": "MIT" }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "license": "MIT", "dependencies": { @@ -3064,9 +2959,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.35", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.35.tgz", - "integrity": "sha512-hOSRInrIDm0Brzp4IHW2F/VM+638qOL2CzE0DgpnGzKW27C95IqqeqgKz/hxHGnvPxvQGpHUGD5qRVC9EZY2+A==", + "version": "1.5.65", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.65.tgz", + "integrity": "sha512-PWVzBjghx7/wop6n22vS2MLU8tKGd4Q91aCEGhG/TYmW6PP5OcSXcdnxTe1NNt0T66N8D6jxh4kC8UsdzOGaIw==", "dev": true, "license": "ISC" }, @@ -3553,9 +3448,9 @@ } }, "node_modules/flatted": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", - "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.2.tgz", + "integrity": "sha512-AiwGJM8YcNOaobumgtng+6NHuOqC3A7MixFeDafM3X9cIUM+xUXoS5Vfgf+OihAYe20fxqNM9yPBXJzRtZ/4eA==", "dev": true, "license": "ISC" }, @@ -5352,9 +5247,9 @@ } }, "node_modules/picocolors": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", - "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", "dev": true, "license": "ISC" }, @@ -6114,16 +6009,6 @@ "dev": true, "license": "BSD-3-Clause" }, - "node_modules/to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -6158,9 +6043,9 @@ } }, "node_modules/ts-api-utils": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", - "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.4.1.tgz", + "integrity": "sha512-5RU2/lxTA3YUZxju61HO2U6EoZLvBLtmV2mbTvqyu4a/7s7RmJPT+1YekhMVsQhznRWk/czIwDUg+V8Q9ZuG4w==", "dev": true, "license": "MIT", "engines": { @@ -6376,9 +6261,9 @@ } }, "node_modules/typescript": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", - "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", "dev": true, "license": "Apache-2.0", "bin": { @@ -6611,9 +6496,9 @@ "license": "ISC" }, "node_modules/yaml": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.1.tgz", - "integrity": "sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.1.tgz", + "integrity": "sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==", "dev": true, "license": "ISC", "bin": { diff --git a/package.json b/package.json index f3de2f0..9f2ea58 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@binance/connector-typescript", - "version": "0.3.13", + "version": "0.3.14", "description": "This is a lightweight library that works as a connector to the Binance public API.", "main": "./dist/index.js", "module": "./dist/index.mjs", @@ -22,7 +22,7 @@ ], "devDependencies": { "@types/jest": "^29.5.4", - "@types/node": "^20.5.0", + "@types/node": "22.9.0", "@types/ws": "^8.5.5", "@typescript-eslint/eslint-plugin": "7.17.0", "@typescript-eslint/parser": "7.17.0", @@ -32,7 +32,7 @@ "ts-jest": "^29.1.1", "ts-node": "^10.9.1", "tsup": "^7.2.0", - "typescript": "^5.5.4" + "typescript": "^5.7.2" }, "dependencies": { "axios": "^1.7.4", diff --git a/src/index.ts b/src/index.ts index c27a38c..0bd04b2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -76,7 +76,7 @@ import { OrderListAboveBelowType, OrderListOrderStatus, OrderListStatusType, - orderListWorkingType, + OrderListWorkingType, OrderStatus, OrderType, OtoPendingType, @@ -88,6 +88,7 @@ import { PositionStatus, QuerySubAccountList, RedeemDestAccount, + RedeemOption, RemoveLiquidityPreviewType, SelfTradePreventionMode, Side, @@ -106,6 +107,7 @@ import { SubscribeSourceAccount, SubUserHistoryType, SwapStatus, + SymbolStatus, TimeInForce, ToAccountType, TradeType, @@ -185,7 +187,7 @@ export { OrderStatus, OrderType, OtoPendingType, - orderListWorkingType, + OrderListWorkingType, Permissions, PortfolioAccountStatus, PortfolioAccountType, @@ -195,6 +197,7 @@ export { QuerySubAccountList, RemoveLiquidityPreviewType, RedeemDestAccount, + RedeemOption, SelfTradePreventionMode, Side, SideEffectType, @@ -213,6 +216,7 @@ export { SubscribeSourceAccount, SubUserHistoryType, SwapStatus, + SymbolStatus, TimeInForce, ToAccountType, TradeType, diff --git a/src/modules/enum.ts b/src/modules/enum.ts index 834c752..f4e7c66 100644 --- a/src/modules/enum.ts +++ b/src/modules/enum.ts @@ -61,8 +61,8 @@ export enum CrossMarginAccountTransferType { } export enum CrossMarginAccountType { - Margin_1 = 'Margin_1', - Margin_2 = 'Margin_2', + MARGIN_1 = 'MARGIN_1', + MARGIN_2 = 'MARGIN_2', } export enum CrossMarginTrans { @@ -391,7 +391,7 @@ export enum OtoPendingType { TAKE_PROFIT_LIMIT = 'TAKE_PROFIT_LIMIT', } -export enum orderListWorkingType { +export enum OrderListWorkingType { LIMIT = 'LIMIT', LIMIT_MAKER = 'LIMIT_MAKER', } @@ -462,6 +462,11 @@ export enum RedeemDestAccount { ALL = 'ALL' } +export enum RedeemOption { + SPOT = 'SPOT', + FLEXIBLE = 'FLEXIBLE', +} + export enum SelfTradePreventionMode { EXPIRE_TAKER = 'EXPIRE_TAKER', EXPIRE_MAKER = 'EXPIRE_MAKER', @@ -568,6 +573,12 @@ export enum SwapStatus { Failed = 2, } +export enum SymbolStatus { + TRADING = 'TRADING', + HALT = 'HALT', + BREAK = 'BREAK ', +} + export enum TimeInForce { GTC = 'GTC', IOC = 'IOC', diff --git a/src/modules/restful/margin/margin.ts b/src/modules/restful/margin/margin.ts index 4653acc..033d91e 100644 --- a/src/modules/restful/margin/margin.ts +++ b/src/modules/restful/margin/margin.ts @@ -83,6 +83,10 @@ import { getMarginAvailableInventoryResponse, marginManualLiquidationOptions, marginManualLiquidationResponse, + marginAccountNewOtoOptions, + marginAccountNewOtoResponse, + marginAccountNewOtocoOptions, + marginAccountNewOtocoResponse, getLeverageBracketResponse, marginAccountBorrowRepayOptions, marginAccountBorrowRepayResponse, @@ -90,7 +94,7 @@ import { getBorrowRepayRecordsResponse } from './types'; import { MarginMethods } from './methods'; -import { Side, OrderType, IsIsolatedMargin, MarginBorrowRepayType } from '../../enum'; +import { Side, OrderType, IsIsolatedMargin, MarginBorrowRepayType, OrderListAboveBelowType, OtoPendingType, OrderListWorkingType } from '../../enum'; export function mixinMargin(base: T): Constructor & T { return class extends base { @@ -801,7 +805,7 @@ export function mixinMargin(base: T): Constructor { + async crossMarginCollateralRatio(): Promise { return await this.makeRequest('GET', '/sapi/v1/margin/crossMarginCollateralRatio'); } @@ -938,6 +942,114 @@ export function mixinMargin(base: T): Constructor { + validateRequiredParameters({ symbol, workingType, workingSide, workingPrice, workingQuantity, pendingType, pendingSide, pendingQuantity }); + const url = this.prepareSignedPath('/sapi/v1/margin/order/oto', + Object.assign( + options ? options : {}, + { + symbol: symbol.toUpperCase(), + workingType: workingType, + workingSide: workingSide, + workingPrice: workingPrice, + workingQuantity: workingQuantity, + pendingType: pendingType, + pendingSide: pendingSide, + pendingQuantity: pendingQuantity + } + ) + ); + return await this.makeRequest('POST', url); + } + + + /** + * New Order List - OTOCO (TRADE) {@link https://developers.binance.com/docs/margin_trading/trade/Margin-Account-New-OTOCO} + * + * @param {string} symbol + * @param {OrderListWorkingType} workingType - Supported values: `LIMIT`, `LIMIT_MAKER` + * @param {Side} workingSide - Supported values: `BUY`, `SELL` + * @param {number} workingPrice + * @param {number} workingQuantity + * @param {Side} pendingSide - Supported values: `BUY`, `SELL` + * @param {number} pendingQuantity - Sets the quantity for the pending order. + * @param {OrderListAboveBelowType} pendingAboveType - Supported values: LIMIT_MAKER, STOP_LOSS, and STOP_LOSS_LIMIT + * @param {object} [options] + * @param {string} [options.isIsolated] - for isolated margin or not: TRUE, FALSE. Default: FALSE + * @param {SideEffectType} [options.sideEffectType] - Default `NO_SIDE_EFFECT` + * @param {boolean} [options.autoRepayAtCancel] - Only when MARGIN_BUY order takes effect, true means that the debt generated by the order needs to be repay after the order is cancelled. The default is true + * @param {string} [options.listClientOrderId] - Arbitrary unique ID among open order lists. Automatically generated if not sent. A new order list with the same listClientOrderId is accepted only when the previous one is filled or completely expired. `listClientOrderId` is distinct from the `workingClientOrderId` and the `pendingClientOrderId`. + * @param {NewOrderRespType} [options.newOrderRespType] - Format of the JSON response. Supported values: `ACK`, `FULL`, `RESULT` + * @param {string} [options.selfTradePreventionMode] - The allowed values are dependent on what is configured on the symbol + * @param {string} [options.workingClientOrderId] - Arbitrary unique ID among open orders for the working order. Automatically generated if not sent. + * @param {number} [options.workingIcebergQty] - This can only be used if workingTimeInForce is `GTC` or if workingType is `LIMIT_MAKER` + * @param {TimeInForce} [options.workingTimeInForce] - Supported values: `FOK`, `IOC`, `GTC` + * @param {string} [options.pendingAboveClientOrderId] - Arbitrary unique ID among open orders for the pending above order. Automatically generated if not sent. + * @param {number} [options.pendingAbovePrice] + * @param {number} [options.pendingAboveStopPrice] + * @param {number} [options.pendingAboveTrailingDelta] + * @param {number} [options.pendingAboveIcebergQty] - This can only be used if pendingAboveTimeInForce is GTC or if pendingAboveType is LIMIT_MAKER. + * @param {TimeInForce} [options.pendingAboveTimeInForce] + * @param {OrderListAboveBelowType} [options.pendingBelowType] - Supported values: LIMIT_MAKER, STOP_LOSS, and STOP_LOSS_LIMIT + * @param {string} [options.pendingBelowClientOrderId] - Arbitrary unique ID among open orders for the pending below order. Automatically generated if not sent. + * @param {number} [options.pendingBelowPrice] + * @param {number} [options.pendingBelowStopPrice] + * @param {number} [options.pendingBelowTrailingDelta] + * @param {number} [options.pendingBelowIcebergQty] - This can only be used if pendingBelowTimeInForce is GTC or if pendingBelowType is LIMIT_MAKER. + * @param {TimeInForce} [options.pendingBelowTimeInForce] + * @param {number} [options.recvWindow] - The value cannot be greater than 60000. + */ + async marginAccountNewOtoco(symbol: string, workingType: OrderListWorkingType, workingSide: Side, workingPrice: number, workingQuantity: number, pendingSide: Side, pendingQuantity: number, pendingAboveType: OrderListAboveBelowType, options?: marginAccountNewOtocoOptions): Promise { + validateRequiredParameters({ symbol, workingType, workingSide, workingPrice, workingQuantity, pendingSide, pendingQuantity, pendingAboveType }); + const url = this.prepareSignedPath('/sapi/v1/margin/order/otoco', + Object.assign( + options ? options : {}, + { + symbol: symbol.toUpperCase(), + workingType: workingType, + workingSide: workingSide, + workingPrice: workingPrice, + workingQuantity: workingQuantity, + pendingSide: pendingSide, + pendingQuantity: pendingQuantity, + pendingAboveType: pendingAboveType + } + ) + ); + return await this.makeRequest('POST', url); + } + + /** * Get the liability assets leverage bracket in Cross Margin Pro Mode (MARKET_DATA) {@link https://developers.binance.com/docs/margin_trading/market-data/Query-Liability-Coin-Leverage-Bracket-in-Cross-Margin-Pro-Mode} */ diff --git a/src/modules/restful/margin/methods.ts b/src/modules/restful/margin/methods.ts index 56c3010..d40e285 100644 --- a/src/modules/restful/margin/methods.ts +++ b/src/modules/restful/margin/methods.ts @@ -6,32 +6,32 @@ import { } from '../../enum'; import { - getCrossMarginTransferHistoryOptions, - getCrossMarginTransferHistoryResponse, - getAllMarginAssetsOptions, - getAllMarginAssetsResponse, + adjustCrossMarginMaxLeverageResponse, getAllCrossMarginPairsOptions, getAllCrossMarginPairsResponse, - getMarginPriceIndexResponse, - adjustCrossMarginMaxLeverageResponse, - getMarginAccountOrderOptions, - getMarginAccountOrderResponse, - marginAccountNewOrderOptions, - marginAccountNewOrderResponse, - marginAccountCancelOrderOptions, - marginAccountCancelOrderResponse, - getInterestHistoryOptions, - getInterestHistoryResponse, - getForceLiquidationRecordOptions, - getForceLiquidationRecordResponse, + getAllMarginAssetsOptions, + getAllMarginAssetsResponse, getCrossMarginAccountDetailsOptions, getCrossMarginAccountDetailsResponse, + getCrossMarginTransferHistoryOptions, + getCrossMarginTransferHistoryResponse, + getForceLiquidationRecordOptions, + getForceLiquidationRecordResponse, + getInterestHistoryOptions, + getInterestHistoryResponse, + getMarginPriceIndexResponse, + getMarginAccountAllOrdersOptions, + getMarginAccountAllOrdersResponse, getMarginAccountOpenOrdersOptions, getMarginAccountOpenOrdersResponse, + getMarginAccountOrderOptions, + getMarginAccountOrderResponse, marginAccountCancelAllOpenOrdersOnASymbolOptions, marginAccountCancelAllOpenOrdersOnASymbolResponse, - getMarginAccountAllOrdersOptions, - getMarginAccountAllOrdersResponse, + marginAccountCancelOrderOptions, + marginAccountCancelOrderResponse, + marginAccountNewOrderOptions, + marginAccountNewOrderResponse, marginAccountNewOcoOptions, marginAccountNewOcoResponse, getMarginAccountOcoOptions, @@ -88,12 +88,17 @@ import { getMarginAvailableInventoryResponse, marginManualLiquidationOptions, marginManualLiquidationResponse, + marginAccountNewOtoOptions, + marginAccountNewOtoResponse, + marginAccountNewOtocoOptions, + marginAccountNewOtocoResponse, getLeverageBracketResponse, marginAccountBorrowRepayOptions, marginAccountBorrowRepayResponse, getBorrowRepayRecordsOptions, getBorrowRepayRecordsResponse } from './types'; +import { OrderListAboveBelowType, OtoPendingType, OrderListWorkingType } from '../../enum'; export interface MarginMethods { getAllMarginAssets(options?: getAllMarginAssetsOptions): Promise @@ -131,7 +136,7 @@ export interface MarginMethods { getIsolatedMarginFeeData(options?: getIsolatedMarginFeeDataOptions): Promise; getIsolatedMarginTierData(symbol: string, options?: getIsolatedMarginTierDataOptions): Promise; getCurrentMarginOrderCountUsage(options?: getCurrentMarginOrderCountUsageOptions): Promise; - crossMarginCollateralRatio(): Promise; + crossMarginCollateralRatio(): Promise; getSmallLiabilityExchangeCoinList(options?: getSmallLiabilityExchangeCoinListOptions): Promise; smallLiabilityExchange(assetNames: string[], options?: smallLiabilityExchangeOptions): Promise; getSmallLiabilityExchangeHistory(current: number, size: number, options?: getSmallLiabilityExchangeHistoryOptions): Promise; @@ -139,6 +144,8 @@ export interface MarginMethods { getTokensOrSymbolsDelistScheduleForCrossMarginAndIsolatedMargin(options?: getTokensOrSymbolsDelistScheduleForCrossMarginAndIsolatedMarginOptions): Promise; getMarginAvailableInventory(type: string, options?: getMarginAvailableInventoryOptions): Promise; marginManualLiquidation(type: string, options?: marginManualLiquidationOptions): Promise; + marginAccountNewOto(symbol: string, workingType: OrderListWorkingType, workingSide: Side, workingPrice: number, workingQuantity: number, pendingType: OtoPendingType, pendingSide: Side, pendingQuantity: number, options?: marginAccountNewOtoOptions): Promise; + marginAccountNewOtoco(symbol: string, workingType: OrderListWorkingType, workingSide: Side, workingPrice: number, workingQuantity: number, pendingSide: Side, pendingQuantity: number, pendingAboveType: OrderListAboveBelowType, options?: marginAccountNewOtocoOptions): Promise; getLeverageBracket(): Promise; marginAccountBorrowRepay(asset: string, isIsolated: string, symbol: string, amount: string, type: MarginBorrowRepayType, options?: marginAccountBorrowRepayOptions): Promise; getBorrowRepayRecords(type: MarginBorrowRepayType, options?: getBorrowRepayRecordsOptions): Promise; diff --git a/src/modules/restful/margin/types.ts b/src/modules/restful/margin/types.ts index 43c4d37..102281c 100644 --- a/src/modules/restful/margin/types.ts +++ b/src/modules/restful/margin/types.ts @@ -18,7 +18,8 @@ import { MarginInterestHistory, MarginLevelStatus, CrossMarginAccountType, - CrossMarginTrans + CrossMarginTrans, + OrderListAboveBelowType } from '../../enum'; export interface getAllMarginAssetsOptions { @@ -239,13 +240,17 @@ export interface getCrossMarginAccountDetailsOptions { } export interface getCrossMarginAccountDetailsResponse { + created: boolean; borrowEnabled: boolean; marginLevel: string; + collateralMarginLevel: string; totalAssetOfBtc: string; totalLiabilityOfBtc: string; totalNetAssetOfBtc: string; + TotalCollateralValueInUSDT: string; tradeEnabled: boolean; - transferEnabled: boolean; + transferInEnabled: boolean; + transferOutEnabled: boolean; accountType: CrossMarginAccountType; userAssets: getCrossMarginAccountDetailsUserassets[]; } @@ -863,6 +868,101 @@ export interface marginManualLiquidationResponse { liabilityQty: number; } +export interface marginAccountNewOtoOptions { + isIsolated?: string; + listClientOrderId?: string; + newOrderRespType?: NewOrderRespType; + sideEffectType?: SideEffectType; + selfTradePreventionMode?: string; + autoRepayAtCancel?: boolean; + workingClientOrderId?: string; + workingIcebergQty?: number; + workingTimeInForce?: TimeInForce; + pendingClientOrderId?: string; + pendingPrice?: number; + pendingStopPrice?: number; + pendingTrailingDelta?: number; + pendingIcebergQty?: number; + pendingTimeInForce?: TimeInForce; + recvWindow?: number; +} + +export interface marginAccountNewOtoResponse { + orderListId: number; + contingencyType: string; + listStatusType: OrderListStatusType; + listOrderStatus: OrderListOrderStatus; + listClientOrderId: string; + transactionTime: number; + symbol: string; + isIsolated: boolean; + orders: marginAccountOrders[]; + orderReports: marginAccountOrderReports[]; +} + +export interface marginAccountOrders { + symbol: string; + orderId: number; + clientOrderId: string; +} + +export interface marginAccountOrderReports { + symbol: string; + orderId: number; + orderListId: number; + clientOrderId: string; + transactTime: number; + price: string; + origQty: string; + executedQty: string; + cummulativeQuoteQty: string; + status: OrderStatus; + timeInForce: TimeInForce; + type: OrderType; + side: Side; + stopPrice?: string; + selfTradePreventionMode: SelfTradePreventionMode; +} + +export interface marginAccountNewOtocoOptions { + isIsolated?: string; + sideEffectType?: SideEffectType; + autoRepayAtCancel?: boolean; + listClientOrderId?: string; + newOrderRespType?: NewOrderRespType; + selfTradePreventionMode?: string; + workingClientOrderId?: string; + workingIcebergQty?: number; + workingTimeInForce?: TimeInForce; + pendingAboveClientOrderId?: string; + pendingAbovePrice?: number; + pendingAboveStopPrice?: number; + pendingAboveTrailingDelta?: number; + pendingAboveIcebergQty?: number; + pendingAboveTimeInForce?: TimeInForce; + pendingBelowType?: OrderListAboveBelowType; + pendingBelowClientOrderId?: string; + pendingBelowPrice?: number; + pendingBelowStopPrice?: number; + pendingBelowTrailingDelta?: number; + pendingBelowIcebergQty?: number; + pendingBelowTimeInForce?: TimeInForce; + recvWindow?: number; +} + +export interface marginAccountNewOtocoResponse { + orderListId: number; + contingencyType: string; + listStatusType: OrderListStatusType; + listOrderStatus: OrderListOrderStatus; + listClientOrderId: string; + transactionTime: number; + symbol: string; + isIsolated: boolean; + orders: marginAccountOrders[]; + orderReports: marginAccountOrderReports[]; +} + export interface getLeverageBracketResponse { assetNames: string[]; rank: number; diff --git a/src/modules/restful/market/market.ts b/src/modules/restful/market/market.ts index ec79b7d..a874308 100644 --- a/src/modules/restful/market/market.ts +++ b/src/modules/restful/market/market.ts @@ -34,7 +34,7 @@ import { Interval } from '../../enum'; export function mixinMarket(base: T): Constructor & T { return class extends base { /** - * Test Connectivity {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api#test-connectivity} + * Test Connectivity {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/public-api-endpoints#test-connectivity} */ async testConnectivity(): Promise> { return await this.makeRequest('GET', '/api/v3/ping'); @@ -42,7 +42,7 @@ export function mixinMarket(base: T): Constructor { return await this.makeRequest('GET', '/api/v3/time'); @@ -50,12 +50,14 @@ export function mixinMarket(base: T): Constructor { const url = this.preparePath('/api/v3/exchangeInfo', @@ -66,7 +68,7 @@ export function mixinMarket(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor; portfolioMarginCollateralRate(): Promise; + getTieredCollateralRate(options?: getTieredCollateralRateOptions): Promise; portfolioMarginBankruptcyLoanAmount(options?: portfolioMarginBankruptcyLoanAmountOptions): Promise; portfolioMarginBankruptcyLoanRepay(options?: portfolioMarginBankruptcyLoanRepayOptions): Promise; getClassicPortfolioMarginNegativeBalanceInterestHistory(options?: getClassicPortfolioMarginNegativeBalanceInterestHistoryOptions): Promise; + getSpanAccountInfo(options?: getSpanAccountInfoOptions): Promise; + getAccountBalance(options?: getAccountBalanceOptions): Promise; getPortfolioMarginAssetIndexPrice(options?: getPortfolioMarginAssetIndexPriceOptions): Promise; fundAutocollection(options?: fundAutocollectionOptions): Promise; fundCollectionByAsset(asset: string, options?: fundCollectionByAssetOptions): Promise; diff --git a/src/modules/restful/portfolioMargin/portfolioMargin.ts b/src/modules/restful/portfolioMargin/portfolioMargin.ts index 9dcb69a..36dd9af 100644 --- a/src/modules/restful/portfolioMargin/portfolioMargin.ts +++ b/src/modules/restful/portfolioMargin/portfolioMargin.ts @@ -9,6 +9,8 @@ import { fundAutocollectionResponse, fundCollectionByAssetOptions, fundCollectionByAssetResponse, + getAccountBalanceOptions, + getAccountBalanceResponse, getAutorepayfuturesStatusOptions, getAutorepayfuturesStatusResponse, getClassicPortfolioMarginNegativeBalanceInterestHistoryOptions, @@ -16,6 +18,10 @@ import { getPortfolioMarginAssetIndexPriceOptions, getPortfolioMarginAssetIndexPriceResponse, getPortfolioMarginAssetLeverageResponse, + getSpanAccountInfoOptions, + getSpanAccountInfoResponse, + getTieredCollateralRateOptions, + getTieredCollateralRateResponse, portfolioMarginAccountOptions, portfolioMarginAccountResponse, portfolioMarginBankruptcyLoanAmountOptions, @@ -53,6 +59,20 @@ export function mixinPortfolioMargin(base: T): Constructo } + /** + * Portfolio Margin Pro Tiered Collateral Rate (USER_DATA) {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/market-data/Portfolio-Margin-Pro-Tiered-Collateral-Rate} + * + * @param {object} [options] + * @param {number} [options.recvWindow] - The value cannot be greater than 60000 + */ + async getTieredCollateralRate(options?: getTieredCollateralRateOptions): Promise { + const url = this.prepareSignedPath('/sapi/v2/portfolio/collateralRate', + options ? options : {} + ); + return await this.makeRequest('GET', url); + } + + /** * Query Portfolio Margin Pro Bankruptcy Loan Amount (USER_DATA) {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Query-Classic-Portfolio-Margin-Bankruptcy-Loan-Amount} * @@ -100,6 +120,35 @@ export function mixinPortfolioMargin(base: T): Constructo } + /** + * Get Portfolio Margin Pro SPAN Account Info (USER_DATA) {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Get-Classic-Portfolio-Margin-Account-Info-V2} + * + * @param {object} [options] + * @param {number} [options.recvWindow] - The value cannot be greater than 60000 + */ + async getSpanAccountInfo(options?: getSpanAccountInfoOptions): Promise { + const url = this.prepareSignedPath('/sapi/v2/portfolio/account', + options ? options : {} + ); + return await this.makeRequest('GET', url); + } + + + /** + * Get Portfolio Margin Pro Account Balance(USER_DATA) {@link https://developers.binance.com/docs/derivatives/portfolio-margin-pro/account/Get-Classic-Portfolio-Margin-Balance-Info} + * + * @param {object} [options] + * @param {string} [options.asset] + * @param {number} [options.recvWindow] - The value cannot be greater than 60000 + */ + async getAccountBalance(options?: getAccountBalanceOptions): Promise { + const url = this.prepareSignedPath('/sapi/v1/portfolio/balance', + options ? options : {} + ); + return await this.makeRequest('GET', url); + } + + /** * Query Portfolio Margin Asset Index Price (MARKET_DATA) {@link https://developers.binance.com/docs/derivatives/coin-margined-futures/market-data/Index-Price-and-Mark-Price} * diff --git a/src/modules/restful/portfolioMargin/types.ts b/src/modules/restful/portfolioMargin/types.ts index 52b9dcf..7f205f5 100644 --- a/src/modules/restful/portfolioMargin/types.ts +++ b/src/modules/restful/portfolioMargin/types.ts @@ -18,6 +18,22 @@ export interface portfolioMarginCollateralRateResponse { collateralRate: string; } +export interface getTieredCollateralRateOptions { + recvWindow?: number; +} + +export interface getTieredCollateralRateResponse { + asset: string; + collateralInfo: collateralInfo[]; +} + +export interface collateralInfo { + tierFloor: string; + tierCap: string; + collateralRate: string; + cum: string; +} + export interface portfolioMarginBankruptcyLoanAmountOptions { recvWindow?: number; } @@ -52,6 +68,50 @@ export interface getClassicPortfolioMarginNegativeBalanceInterestHistoryResponse principal: string; } +export interface getSpanAccountInfoOptions { + recvWindow?: number; +} + +export interface getSpanAccountInfoResponse { + uniMMR: string; + accountEquity: string; + actualEquity: string; + accountMaintMargin: string; + riskUnitMMList: riskUnitMMList[]; + marginMM: string; + otherMM: string; + accountStatus: string; + accountType: string; +} + +export interface riskUnitMMList{ + asset: string; + uniMaintainUsd: string; +} + +export interface getAccountBalanceOptions { + asset?: string; + recvWindow?: number; +} + +export interface getAccountBalanceResponse { + asset: string; + totalWalletBalance: string; + crossMarginAsset: string; + crossMarginBorrowed: string; + crossMarginFree: string; + crossMarginInterest: string; + crossMarginLocked: string; + umWalletBalance: string; + umUnrealizedPNL: string; + cmWalletBalance: string; + cmUnrealizedPNL: string; + updateTime: number; + negativeBalance: string; + optionWalletBalance: string; + optionEquity: string; +} + export interface getPortfolioMarginAssetIndexPriceOptions{ asset: string; } diff --git a/src/modules/restful/simpleEarn/methods.ts b/src/modules/restful/simpleEarn/methods.ts index 842d147..0daf496 100644 --- a/src/modules/restful/simpleEarn/methods.ts +++ b/src/modules/restful/simpleEarn/methods.ts @@ -41,11 +41,14 @@ import { getFlexibleSubscriptionPreviewResponse, getLockedSubscriptionPreviewOptions, getLockedSubscriptionPreviewResponse, + setLockedRedeemOptionOptions, + setLockedRedeemOptionResponse, getRateHistoryOptions, getRateHistoryResponse, getCollateralRecordOptions, getCollateralRecordResponse } from './types'; +import { RedeemOption } from '../../enum'; export interface SimpleEarnMethods { getSimpleEarnFlexibleProductList(options?: getSimpleEarnFlexibleProductListOptions): Promise; @@ -69,6 +72,7 @@ export interface SimpleEarnMethods { getLockedPersonalLeftQuota(projectId: string, options?: getLockedPersonalLeftQuotaOptions): Promise; getFlexibleSubscriptionPreview(productId: string, amount: number, options?: getFlexibleSubscriptionPreviewOptions): Promise; getLockedSubscriptionPreview(projectId: string, amount: number, options?: getLockedSubscriptionPreviewOptions): Promise; + setLockedRedeemOption(positionId: string, redeemOption: RedeemOption, options?: setLockedRedeemOptionOptions): Promise; getRateHistory(productId: string, options?: getRateHistoryOptions): Promise; getCollateralRecord(options?: getCollateralRecordOptions): Promise; } \ No newline at end of file diff --git a/src/modules/restful/simpleEarn/simpleEarn.ts b/src/modules/restful/simpleEarn/simpleEarn.ts index 5d9c410..a746b5e 100644 --- a/src/modules/restful/simpleEarn/simpleEarn.ts +++ b/src/modules/restful/simpleEarn/simpleEarn.ts @@ -43,11 +43,14 @@ import { getFlexibleSubscriptionPreviewResponse, getLockedSubscriptionPreviewOptions, getLockedSubscriptionPreviewResponse, + setLockedRedeemOptionOptions, + setLockedRedeemOptionResponse, getRateHistoryOptions, getRateHistoryResponse, getCollateralRecordOptions, getCollateralRecordResponse } from './types'; +import { RedeemOption } from '../../enum'; import { SimpleEarnMethods } from './methods'; export function mixinSimpleEarn(base: T): Constructor & T { @@ -119,6 +122,7 @@ export function mixinSimpleEarn(base: T): Constructor { @@ -492,6 +496,28 @@ export function mixinSimpleEarn(base: T): Constructor { + validateRequiredParameters({ positionId, redeemOption }); + const url = this.prepareSignedPath('/sapi/v1/simple-earn/locked/setRedeemOption', + Object.assign( + options ? options : {}, + { + positionId: positionId, + redeemOption: redeemOption + } + ) + ); + return await this.makeRequest('POST', url); + } + /** * Get Rate History (USER_DATA) {@link https://developers.binance.com/docs/simple_earn/history/Get-Rate-History} * diff --git a/src/modules/restful/simpleEarn/types.ts b/src/modules/restful/simpleEarn/types.ts index c83a5fb..f46aa01 100644 --- a/src/modules/restful/simpleEarn/types.ts +++ b/src/modules/restful/simpleEarn/types.ts @@ -166,7 +166,8 @@ export interface getLockedProductPositionResponse { } export interface getLockedProductPositionRows { - positionId: string; + positionId: number; + parentPositionId: 123122, projectId: string; asset: string; amount: string; @@ -175,9 +176,26 @@ export interface getLockedProductPositionRows { accrualDays: string; rewardAsset: string; APY: string; - isRenewable: boolean; - isAutoRenew: boolean; - redeemDate: string; + rewardAmt: string; + extraRewardAsset: string; + extraRewardAPR: string; + estExtraRewardAmt: string; + nextPay: string; + nextPayDate: string; + payPeriod: string; + redeemAmountEarly: string; + rewardsEndDate: string; + deliverDate: string; + redeemPeriod: string; + redeemingAmt: string; + redeemTo: string; + partialAmtDeliverDate: string; + canRedeemEarly: boolean; + canFastRedemption: boolean; + autoSubscribe: boolean; + type: string; + status: string; + canReStake: boolean; } export interface simpleAccountOptions { @@ -214,6 +232,7 @@ export interface getFlexibleSubscriptionRecordRows { asset: string; time: number; purchaseId: number; + productId: string; type: SimpleEarnType; sourceAccount: SimpleEarnSourceAccount; amtFromSpot: string; @@ -239,6 +258,7 @@ export interface getLockedSubscriptionRecordResponse { export interface getLockedSubscriptionRecordRows { positionId: string; purchaseId: number; + projectId: string; time: number; asset: string; amount: string; @@ -292,14 +312,21 @@ export interface getLockedRedemptionRecordResponse { } export interface getLockedRedemptionRecordRows { - positionId: string; + positionId: number; redeemId: number; time: number; asset: string; lockPeriod: string; amount: string; + originalAmount: string; type: SimpleEarnLockedRedemption; deliverDate: string; + lossAmount: string; + isComplete: boolean; + rewardAsset: string; + rewardAmt: string; + extraRewardAsset: string; + estExtraRewardAmt: string; status: string; } @@ -408,6 +435,14 @@ export interface getLockedSubscriptionPreviewResponse { nextSubscriptionDate: string; } +export interface setLockedRedeemOptionOptions { + recvWindow?: number; +} + +export interface setLockedRedeemOptionResponse { + success: boolean; +} + export interface getRateHistoryOptions { startTime?: number; endTime?: number; diff --git a/src/modules/restful/subAccount/types.ts b/src/modules/restful/subAccount/types.ts index 74c8d0e..4f597b5 100644 --- a/src/modules/restful/subAccount/types.ts +++ b/src/modules/restful/subAccount/types.ts @@ -90,6 +90,8 @@ export interface getSubAccountAssetsResponse { } export interface getSubAccountAssetsBalances { + freeze: number; + withdrawing: number; asset: string; free: number; locked: number; @@ -686,9 +688,11 @@ export interface getSubAccountAssetsForMasterAccountResponse { } export interface getSubAccountAssetsForMasterAccountBalances { + freeze: string; + withdrawing: string; asset: string; - free: number; - locked: number; + free: string; + locked: string; } export interface getManagedSubAccountListOptions { diff --git a/src/modules/restful/trade/methods.ts b/src/modules/restful/trade/methods.ts index d80fc23..dd76e67 100644 --- a/src/modules/restful/trade/methods.ts +++ b/src/modules/restful/trade/methods.ts @@ -1,4 +1,4 @@ -import { OrderListAboveBelowType, OrderType, OtoPendingType, orderListWorkingType, Side, CancelReplaceMode } from '../../enum'; +import { OrderListAboveBelowType, OrderType, OtoPendingType, OrderListWorkingType, Side, CancelReplaceMode } from '../../enum'; import { accountInformationOptions, @@ -57,8 +57,8 @@ export interface TradeMethods { cancelAllOpenOrdersOnASymbol(symbol: string, options?: cancelAllOpenOrdersOnASymbolOptions): Promise; allOrders(symbol: string, options?: allOrdersOptions): Promise; newOco(symbol: string, side: Side, quantity: number, aboveType: OrderListAboveBelowType, belowType: OrderListAboveBelowType, options?: newOcoOptions): Promise; - newOto(symbol: string, workingType: orderListWorkingType, workingSide: Side, workingPrice: number, workingQuantity: number, pendingType: OtoPendingType, pendingSide: Side, pendingQuantity: number, options?: newOtoOptions): Promise; - newOtoco(symbol: string, workingType: orderListWorkingType, workingSide: Side, workingPrice: number, workingQuantity: number, pendingSide: Side, pendingQuantity: number, pendingAboveType: OrderListAboveBelowType, options?: newOtocoOptions): Promise + newOto(symbol: string, workingType: OrderListWorkingType, workingSide: Side, workingPrice: number, workingQuantity: number, pendingType: OtoPendingType, pendingSide: Side, pendingQuantity: number, options?: newOtoOptions): Promise; + newOtoco(symbol: string, workingType: OrderListWorkingType, workingSide: Side, workingPrice: number, workingQuantity: number, pendingSide: Side, pendingQuantity: number, pendingAboveType: OrderListAboveBelowType, options?: newOtocoOptions): Promise getOco(options?: getOcoOptions): Promise; cancelOco(symbol: string, options?: cancelOcoOptions): Promise; getAllOco(options?: getAllOcoOptions): Promise; diff --git a/src/modules/restful/trade/trade.ts b/src/modules/restful/trade/trade.ts index 21aecf6..71044f1 100644 --- a/src/modules/restful/trade/trade.ts +++ b/src/modules/restful/trade/trade.ts @@ -47,12 +47,12 @@ import { testNewOrderSOROptions } from './types'; import { TradeMethods } from './methods'; -import { OrderListAboveBelowType, OrderType, OtoPendingType, orderListWorkingType, Side, CancelReplaceMode } from '../../enum'; +import { OrderListAboveBelowType, OrderType, OtoPendingType, OrderListWorkingType, Side, CancelReplaceMode } from '../../enum'; export function mixinTrade(base: T): Constructor & T { return class extends base { /** - * Test New Order (TRADE) {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api#test-new-order-trade} + * Test New Order (TRADE) {@link https://developers.binance.com/docs/binance-spot-api-docs/rest-api/public-api-endpoints#test-new-order-trade} * * @param {string} symbol - Trading symbol, e.g. BNBUSDT * @param {Side} side @@ -90,7 +90,7 @@ export function mixinTrade(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor { + async newOto(symbol: string, workingType: OrderListWorkingType, workingSide: Side, workingPrice: number, workingQuantity: number, pendingType: OtoPendingType, pendingSide: Side, pendingQuantity: number, options?: newOtoOptions): Promise { validateRequiredParameters({ symbol, workingType, workingSide, workingPrice, workingQuantity, pendingType, pendingSide, pendingQuantity}); const url = this.prepareSignedPath('/api/v3/orderList/oto', Object.assign( @@ -376,10 +376,10 @@ export function mixinTrade(base: T): Constructor(base: T): Constructor { + async newOtoco(symbol: string, workingType: OrderListWorkingType, workingSide: Side, workingPrice: number, workingQuantity: number, pendingSide: Side, pendingQuantity: number, pendingAboveType: OrderListAboveBelowType, options?: newOtocoOptions): Promise { validateRequiredParameters({ symbol, workingType, workingSide, workingPrice, workingQuantity, pendingSide, pendingQuantity, pendingAboveType }); const url = this.prepareSignedPath('/api/v3/orderList/otoco', Object.assign( @@ -436,7 +436,7 @@ export function mixinTrade(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor; + getSymbolsDelistSchedule(options?: getSymbolsDelistScheduleOptions): Promise; allCoinsInformation(options?: allCoinsInformationOptions): Promise; dailyAccountSnapshot(type: AccountSnapshotType, options?: dailyAccountSnapshotOptions): Promise; disableFastWithdrawSwitch(options?: disableFastWithdrawSwitchOptions): Promise>; @@ -57,6 +68,7 @@ export interface WalletMethods { depositHistory(options?: depositHistoryOptions): Promise; withdrawHistory(options?: withdrawHistoryOptions): Promise; depositAddress(coin: string, options?: depositAddressOptions): Promise; + depositAddressList(coin: string, options?: depositAddressListOptions): Promise; accountStatus(options?: accountStatusOptions): Promise; accountApiTradingStatus(options?: accountApiTradingStatusOptions): Promise; dustlog(options?: dustlogOptions): Promise; @@ -64,12 +76,15 @@ export interface WalletMethods { dustTransfer(asset: string[], options?: dustTransferOptions): Promise; assetDividendRecord(options?: assetDividendRecordOptions): Promise; assetDetail(options?: assetDetailOptions): Promise; + queryUserWalletBalance(options?: queryUserWalletBalanceOptions): Promise; tradeFee(options?: tradeFeeOptions): Promise; userUniversalTransfer(type: UnivTransferType, asset: string, amount: number, options?: userUniversalTransferOptions): Promise; getUserUniversalTransferHistory(type: UnivTransferType, options?: getUserUniversalTransferHistoryOptions): Promise; fundingWallet(options?: fundingWalletOptions): Promise; userAsset(options?: userAssetOptions): Promise; getCloudminingPaymentAndRefundHistory(startTime: number, endTime: number, options?: getCloudminingPaymentAndRefundHistoryOptions): Promise; + queryUserDelegationHistory(email: string, startTime: number, endTime: number, options?: queryUserDelegationHistoryOptions): Promise; + accountInfo(options?: accountInfoOptions): Promise; getApiKeyPermission(options?: getApiKeyPermissionOptions): Promise; oneClickArrivalDepositApply(options?: oneClickArrivalDepositApplyOptions): Promise; } \ No newline at end of file diff --git a/src/modules/restful/wallet/types.ts b/src/modules/restful/wallet/types.ts index b014244..43d6290 100644 --- a/src/modules/restful/wallet/types.ts +++ b/src/modules/restful/wallet/types.ts @@ -5,6 +5,15 @@ export interface systemStatusResponse { msg: string; } +export interface getSymbolsDelistScheduleOptions { + recvWindow?: number; +} + +export interface getSymbolsDelistScheduleResponse { + delistTime: number; + symbols: string[]; +} + export interface allCoinsInformationOptions { recvWindow?: number; } @@ -177,6 +186,17 @@ export interface depositAddressResponse { url: string; } +export interface depositAddressListOptions { + network?: string; +} + +export interface depositAddressListResponse { + coin: string; + address: string; + tag: string; + isDefault: number; +} + export interface accountStatusOptions { recvWindow?: number; } @@ -310,6 +330,16 @@ export interface assetDetailResponse { SKY?: assetDetail; } +export interface queryUserWalletBalanceOptions { + recvWindow?: number; +} + +export interface queryUserWalletBalanceResponse { + activate: boolean; + balance: string; + walletName: string; +} + export interface assetDetail { minWithdrawAmount: string depositStatus: boolean @@ -407,6 +437,39 @@ export interface getCloudminingPaymentAndRefundHistoryResponse { rows: getCloudminingPaymentAndRefundHistoryRows[]; } +export interface queryUserDelegationHistoryOptions { + type?: string; + asset?: string; + current?: number; + size?: number; + recvWindow?: number; +} + +export interface queryUserDelegationHistoryResponse { + total: number; + rows: queryUserDelegationHistoryRows[]; +} + +export interface queryUserDelegationHistoryRows { + clientTranId: string; + transferType: string; + asset: string; + amount: string; + time: number; +} + +export interface accountInfoOptions { + recvWindow?: number; +} + +export interface accountInfoResponse { + vipLevel: number; + isMarginEnabled: boolean; + isFutureEnabled: boolean; + isOptionsEnabled: boolean; + isPortfolioMarginRetailEnabled: boolean; +} + export interface getCloudminingPaymentAndRefundHistoryRows { createTime: number; tranId: number; diff --git a/src/modules/restful/wallet/wallet.ts b/src/modules/restful/wallet/wallet.ts index 2b243b5..59acd73 100644 --- a/src/modules/restful/wallet/wallet.ts +++ b/src/modules/restful/wallet/wallet.ts @@ -1,51 +1,61 @@ import { Constructor } from '../../../setters/types'; import { validateRequiredParameters } from '../../../helpers/utils'; import { - systemStatusResponse, + accountApiTradingStatusOptions, + accountApiTradingStatusResponse, + accountInfoOptions, + accountInfoResponse, + accountStatusOptions, + accountStatusResponse, allCoinsInformationOptions, allCoinsInformationResponse, + assetDetailOptions, + assetDetailResponse, + assetDividendRecordOptions, + assetDividendRecordResponse, dailyAccountSnapshotOptions, dailyAccountSnapshotResponse, - disableFastWithdrawSwitchOptions, - enableFastWithdrawSwitchOptions, - withdrawOptions, - withdrawResponse, - depositHistoryOptions, - depositHistoryResponse, - withdrawHistoryOptions, - withdrawHistoryResponse, depositAddressOptions, depositAddressResponse, - accountStatusOptions, - accountStatusResponse, - accountApiTradingStatusOptions, - accountApiTradingStatusResponse, + depositAddressListOptions, + depositAddressListResponse, + depositHistoryOptions, + depositHistoryResponse, + disableFastWithdrawSwitchOptions, dustlogOptions, dustlogResponse, - getAssetsThatCanBeConvertedIntoBnbOptions, - getAssetsThatCanBeConvertedIntoBnbResponse, dustTransferOptions, dustTransferResponse, - assetDividendRecordOptions, - assetDividendRecordResponse, - assetDetailOptions, - assetDetailResponse, - tradeFeeOptions, - tradeFeeResponse, - getUserUniversalTransferHistoryOptions, - getUserUniversalTransferHistoryResponse, - userUniversalTransferOptions, - userUniversalTransferResponse, + enableFastWithdrawSwitchOptions, fundingWalletOptions, fundingWalletResponse, - userAssetOptions, - userAssetResponse, - getCloudminingPaymentAndRefundHistoryOptions, - getCloudminingPaymentAndRefundHistoryResponse, getApiKeyPermissionOptions, getApiKeyPermissionResponse, + getAssetsThatCanBeConvertedIntoBnbOptions, + getAssetsThatCanBeConvertedIntoBnbResponse, + getCloudminingPaymentAndRefundHistoryOptions, + getCloudminingPaymentAndRefundHistoryResponse, + getSymbolsDelistScheduleOptions, + getSymbolsDelistScheduleResponse, + getUserUniversalTransferHistoryOptions, + getUserUniversalTransferHistoryResponse, oneClickArrivalDepositApplyOptions, - oneClickArrivalDepositApplyResponse + oneClickArrivalDepositApplyResponse, + queryUserWalletBalanceOptions, + queryUserWalletBalanceResponse, + queryUserDelegationHistoryOptions, + queryUserDelegationHistoryResponse, + systemStatusResponse, + tradeFeeOptions, + tradeFeeResponse, + userAssetOptions, + userAssetResponse, + userUniversalTransferOptions, + userUniversalTransferResponse, + withdrawHistoryOptions, + withdrawHistoryResponse, + withdrawOptions, + withdrawResponse, } from './types'; import { WalletMethods } from './methods'; import { AccountSnapshotType, UnivTransferType } from '../../enum'; @@ -60,6 +70,20 @@ export function mixinWallet(base: T): Constructor { + const url = this.prepareSignedPath('/sapi/v1/spot/delist-schedule', + options ? options : {} + ); + return await this.makeRequest('GET', url); + } + + /** * All Coins' Information (USER_DATA) {@link https://developers.binance.com/docs/wallet/capital/all-coins-info} * @@ -205,6 +229,22 @@ export function mixinWallet(base: T): Constructor { + validateRequiredParameters({ coin }); + const url = this.prepareSignedPath('/sapi/v1/capital/deposit/address/list', + Object.assign(options ? options : {}, { coin: coin }) + ); + return await this.makeRequest('GET', url); + } + + /** * Account Status (USER_DATA) {@link https://developers.binance.com/docs/wallet/account/account-status} * @@ -316,6 +356,20 @@ export function mixinWallet(base: T): Constructor { + const url = this.prepareSignedPath('/sapi/v1/asset/wallet/balance', + options ? options : {} + ); + return await this.makeRequest('GET', url); + } + + /** * Trade Fee (USER_DATA) {@link https://developers.binance.com/docs/wallet/asset/trade-fee} * @@ -432,6 +486,49 @@ export function mixinWallet(base: T): Constructor { + validateRequiredParameters({ email, startTime, endTime }); + const url = this.prepareSignedPath('/sapi/v1/asset/custody/transfer-history', + Object.assign( + options ? options : {}, + { + email: email, + startTime: startTime, + endTime: endTime + } + ) + ); + return await this.makeRequest('GET', url); + } + + + /** + * Account info (USER_DATA) {@link https://developers.binance.com/docs/wallet/account} + * + * @param {object} [options] + * @param {number} [options.recvWindow] - The value cannot be greater than 60000 + */ + async accountInfo(options?: accountInfoOptions): Promise { + const url = this.prepareSignedPath('/sapi/v1/account/info', + options ? options : {} + ); + return await this.makeRequest('GET', url); + } + + /** * Get API Key Permission (USER_DATA) {@link https://developers.binance.com/docs/wallet/account/api-key-permission} * diff --git a/src/modules/websocket/websocketAPI/account/account.ts b/src/modules/websocket/websocketAPI/account/account.ts index 4477873..cfc60b5 100644 --- a/src/modules/websocket/websocketAPI/account/account.ts +++ b/src/modules/websocket/websocketAPI/account/account.ts @@ -20,7 +20,7 @@ export function mixinWsAccount(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor(base: T): Constructor * * - * {@link https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api#start-user-data-stream-user_stream} + * {@link https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/public-api-requests#start-user-data-stream-user_stream} */ startUserDataStream() { this.sendMessageWithAPIKey('userDataStream.start'); @@ -24,7 +24,7 @@ export function mixinWsUserData(base: T): Constructor * * - * {@link https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api#ping-user-data-stream-user_stream} + * {@link https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/public-api-requests#ping-user-data-stream-user_stream} * * @param {string} listenKey */ @@ -38,7 +38,7 @@ export function mixinWsUserData(base: T): Constructor * * - * {@link https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api#stop-user-data-stream-user_stream} + * {@link https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/public-api-requests#stop-user-data-stream-user_stream} */ stopUserDataStream(listenKey: string) { this.sendMessageWithAPIKey('userDataStream.stop', { listenKey }); diff --git a/tests/mock_values/restful/margin/crossMarginCollateralRatio.ts b/tests/mock_values/restful/margin/crossMarginCollateralRatio.ts new file mode 100644 index 0000000..e8cdb1a --- /dev/null +++ b/tests/mock_values/restful/margin/crossMarginCollateralRatio.ts @@ -0,0 +1,39 @@ +import { RestMarginTypes } from '../../../../src/index'; + +export const mockResponse: RestMarginTypes.crossMarginCollateralRatioResponse[] = [ + { + 'collaterals': [ + { + 'minUsdValue': '0', + 'maxUsdValue': '13000000', + 'discountRate': '1' + }, + { + 'minUsdValue': '13000000', + 'maxUsdValue': '20000000', + 'discountRate': '0.975' + }, + { + 'minUsdValue': '20000000', + 'discountRate': '0' + } + ], + 'assetNames': [ + 'BNX' + ] + }, + { + 'collaterals': [ + { + 'minUsdValue': '0', + 'discountRate': '1' + } + ], + 'assetNames': [ + 'BTC', + 'BUSD', + 'ETH', + 'USDT' + ] + } +]; \ No newline at end of file diff --git a/tests/mock_values/restful/margin/getCrossMarginAccountDetails.ts b/tests/mock_values/restful/margin/getCrossMarginAccountDetails.ts index acb8ed4..5c90717 100644 --- a/tests/mock_values/restful/margin/getCrossMarginAccountDetails.ts +++ b/tests/mock_values/restful/margin/getCrossMarginAccountDetails.ts @@ -1,20 +1,50 @@ import { CrossMarginAccountType, RestMarginTypes } from '../../../../src/index'; export const mockResponse: RestMarginTypes.getCrossMarginAccountDetailsResponse = { + 'created' : true, 'borrowEnabled': true, 'marginLevel': '11.64405625', + 'collateralMarginLevel' : '3.2', 'totalAssetOfBtc': '6.82728457', 'totalLiabilityOfBtc': '0.58633215', 'totalNetAssetOfBtc': '6.24095242', + 'TotalCollateralValueInUSDT': '5.82728457', 'tradeEnabled': true, - 'transferEnabled': true, - 'accountType': CrossMarginAccountType.Margin_1, - 'userAssets': [{ - 'asset': 'BTC', - 'borrowed': '0.00000000', - 'free': '0.00499500', - 'interest': '0.00000000', - 'locked': '0.00000000', - 'netAsset': '0.00499500' - }] + 'transferInEnabled': true, + 'transferOutEnabled': true, + 'accountType': CrossMarginAccountType.MARGIN_1, + 'userAssets': [ + { + 'asset': 'BTC', + 'borrowed': '0.00000000', + 'free': '0.00499500', + 'interest': '0.00000000', + 'locked': '0.00000000', + 'netAsset': '0.00499500' + }, + { + 'asset': 'BNB', + 'borrowed': '201.66666672', + 'free': '2346.50000000', + 'interest': '0.00000000', + 'locked': '0.00000000', + 'netAsset': '2144.83333328' + }, + { + 'asset': 'ETH', + 'borrowed': '0.00000000', + 'free': '0.00000000', + 'interest': '0.00000000', + 'locked': '0.00000000', + 'netAsset': '0.00000000' + }, + { + 'asset': 'USDT', + 'borrowed': '0.00000000', + 'free': '0.00000000', + 'interest': '0.00000000', + 'locked': '0.00000000', + 'netAsset': '0.00000000' + } + ] }; diff --git a/tests/mock_values/restful/margin/marginAccountNewOto.ts b/tests/mock_values/restful/margin/marginAccountNewOto.ts new file mode 100644 index 0000000..5607f2f --- /dev/null +++ b/tests/mock_values/restful/margin/marginAccountNewOto.ts @@ -0,0 +1,67 @@ +import { + OrderListOrderStatus, + OrderListStatusType, + OrderStatus, + OrderType, + RestMarginTypes, + SelfTradePreventionMode, + Side, + TimeInForce +} from '../../../../src/index'; + +export const mockResponse: RestMarginTypes.marginAccountNewOtoResponse = { + 'orderListId': 13551, + 'contingencyType': 'OTO', + 'listStatusType': OrderListStatusType.EXEC_STARTED, + 'listOrderStatus': OrderListOrderStatus.EXECUTING, + 'listClientOrderId': 'JDuOrsu0Ge8GTyvx8J7VTD', + 'transactionTime': 1725521998054, + 'symbol': 'BTCUSDT', + 'isIsolated': false, + 'orders': [ + { + 'symbol': 'BTCUSDT', + 'orderId': 29896699, + 'clientOrderId': 'y8RB6tQEMuHUXybqbtzTxk' + }, + { + 'symbol': 'BTCUSDT', + 'orderId': 29896700, + 'clientOrderId': 'dKQEdh5HhXb7Lpp85jz1dQ' + } + ], + 'orderReports': [ + { + 'symbol': 'BTCUSDT', + 'orderId': 29896699, + 'orderListId': 13551, + 'clientOrderId': 'y8RB6tQEMuHUXybqbtzTxk', + 'transactTime': 1725521998054, + 'price': '80000.00000000', + 'origQty': '0.02000000', + 'executedQty': '0', + 'cummulativeQuoteQty': '0', + 'status': OrderStatus.NEW, + 'timeInForce': TimeInForce.GTC, + 'type': OrderType.LIMIT, + 'side': Side.SELL, + 'selfTradePreventionMode': SelfTradePreventionMode.NONE + }, + { + 'symbol': 'BTCUSDT', + 'orderId': 29896700, + 'orderListId': 13551, + 'clientOrderId': 'dKQEdh5HhXb7Lpp85jz1dQ', + 'transactTime': 1725521998054, + 'price': '50000.00000000', + 'origQty': '0.02000000', + 'executedQty': '0', + 'cummulativeQuoteQty': '0', + 'status': OrderStatus.PENDING_NEW, + 'timeInForce': TimeInForce.GTC, + 'type': OrderType.LIMIT, + 'side': Side.BUY, + 'selfTradePreventionMode': SelfTradePreventionMode.NONE + } + ] +}; diff --git a/tests/mock_values/restful/margin/marginAccountNewOtoco.ts b/tests/mock_values/restful/margin/marginAccountNewOtoco.ts new file mode 100644 index 0000000..f4c49a2 --- /dev/null +++ b/tests/mock_values/restful/margin/marginAccountNewOtoco.ts @@ -0,0 +1,89 @@ +import { + OrderListOrderStatus, + OrderListStatusType, + OrderStatus, + OrderType, + RestMarginTypes, + SelfTradePreventionMode, + Side, + TimeInForce +} from '../../../../src/index'; + +export const mockResponse: RestMarginTypes.marginAccountNewOtocoResponse = { + 'orderListId': 13509, + 'contingencyType': 'OTO', + 'listStatusType': OrderListStatusType.EXEC_STARTED, + 'listOrderStatus': OrderListOrderStatus.EXECUTING, + 'listClientOrderId': 'u2AUo48LLef5qVenRtwJZy', + 'transactionTime': 1725521881300, + 'symbol': 'BNBUSDT', + 'isIsolated': false, + 'orders': [ + { + 'symbol': 'BNBUSDT', + 'orderId': 28282534, + 'clientOrderId': 'IfYDxvrZI4kiyqYpRH13iI' + }, + { + 'symbol': 'BNBUSDT', + 'orderId': 28282535, + 'clientOrderId': '0HCSsPRxVfW8BkTUy9z4np' + }, + { + 'symbol': 'BNBUSDT', + 'orderId': 28282536, + 'clientOrderId': 'dypsgdxWnLY75kwT930cbD' + } + ], + 'orderReports': [ + { + 'symbol': 'BNBUSDT', + 'orderId': 28282534, + 'orderListId': 13509, + 'clientOrderId': 'IfYDxvrZI4kiyqYpRH13iI', + 'transactTime': 1725521881300, + 'price': '300.00000000', + 'origQty': '1.00000000', + 'executedQty': '0', + 'cummulativeQuoteQty': '0', + 'status': OrderStatus.NEW, + 'timeInForce': TimeInForce.GTC, + 'type': OrderType.LIMIT, + 'side': Side.BUY, + 'selfTradePreventionMode': SelfTradePreventionMode.NONE + }, + { + 'symbol': 'BNBUSDT', + 'orderId': 28282535, + 'orderListId': 13509, + 'clientOrderId': '0HCSsPRxVfW8BkTUy9z4np', + 'transactTime': 1725521881300, + 'price': '0E-8', + 'origQty': '1.00000000', + 'executedQty': '0', + 'cummulativeQuoteQty': '0', + 'status': OrderStatus.PENDING_NEW, + 'timeInForce': TimeInForce.GTC, + 'type': OrderType.STOP_LOSS, + 'side': Side.SELL, + 'stopPrice': '299.00000000', + 'selfTradePreventionMode': SelfTradePreventionMode.NONE + }, + { + 'symbol': 'BNBUSDT', + 'orderId': 28282536, + 'orderListId': 13509, + 'clientOrderId': 'dypsgdxWnLY75kwT930cbD', + 'transactTime': 1725521881300, + 'price': '301.00000000', + 'origQty': '1.00000000', + 'executedQty': '0', + 'cummulativeQuoteQty': '0', + 'status': OrderStatus.PENDING_NEW, + 'timeInForce': TimeInForce.GTC, + 'type': OrderType.LIMIT_MAKER, + 'side': Side.SELL, + 'selfTradePreventionMode': SelfTradePreventionMode.NONE + } + ] +}; diff --git a/tests/mock_values/restful/portfolioMargin/getAccountBalance.ts b/tests/mock_values/restful/portfolioMargin/getAccountBalance.ts new file mode 100644 index 0000000..356f969 --- /dev/null +++ b/tests/mock_values/restful/portfolioMargin/getAccountBalance.ts @@ -0,0 +1,21 @@ +import { RestPortfolioMarginTypes } from '../../../../src/index'; + +export const mockResponse: RestPortfolioMarginTypes.getAccountBalanceResponse[] = [ + { + 'asset': 'BTC', + 'totalWalletBalance': '100', + 'crossMarginAsset': '100', + 'crossMarginBorrowed': '0', + 'crossMarginFree': '100', + 'crossMarginInterest': '0', + 'crossMarginLocked': '0', + 'umWalletBalance': '0', + 'umUnrealizedPNL': '0', + 'cmWalletBalance': '0', + 'cmUnrealizedPNL': '0', + 'updateTime': 0, + 'negativeBalance': '0', + 'optionWalletBalance': '0', + 'optionEquity': '0' + } +]; diff --git a/tests/mock_values/restful/portfolioMargin/getSpanAccountInfo.ts b/tests/mock_values/restful/portfolioMargin/getSpanAccountInfo.ts new file mode 100644 index 0000000..2849f4b --- /dev/null +++ b/tests/mock_values/restful/portfolioMargin/getSpanAccountInfo.ts @@ -0,0 +1,18 @@ +import { RestPortfolioMarginTypes } from '../../../../src/index'; + +export const mockResponse: RestPortfolioMarginTypes.getSpanAccountInfoResponse = { + 'uniMMR': '5167.92171923', + 'accountEquity': '122607.35137903', + 'actualEquity': '142607.35137903', + 'accountMaintMargin': '23.72469206', + 'riskUnitMMList':[ + { + 'asset': 'BTC', + 'uniMaintainUsd': '23.72469206' + } + ], + 'marginMM': '0.00000000', + 'otherMM': '0.00000000', + 'accountStatus': 'NORMAL', + 'accountType': 'PM_3' +}; diff --git a/tests/mock_values/restful/portfolioMargin/getTieredCollateralRate.ts b/tests/mock_values/restful/portfolioMargin/getTieredCollateralRate.ts new file mode 100644 index 0000000..bec2462 --- /dev/null +++ b/tests/mock_values/restful/portfolioMargin/getTieredCollateralRate.ts @@ -0,0 +1,38 @@ +import { RestPortfolioMarginTypes } from '../../../../src/index'; + +export const mockResponse: RestPortfolioMarginTypes.getTieredCollateralRateResponse[] =[ + { + 'asset': 'BNB', + 'collateralInfo': [ + { + 'tierFloor': '0.0000', + 'tierCap': '1000.0000', + 'collateralRate': '1.0000', + 'cum':'0.0000' + }, + { + 'tierFloor': '1000.0000', + 'tierCap': '2000.0000', + 'collateralRate': '0.9000', + 'cum':'0.0000' + } + ] + }, + { + 'asset': 'USDT', + 'collateralInfo': [ + { + 'tierFloor': '0.0000', + 'tierCap': '1000.0000', + 'collateralRate': '1.0000', + 'cum':'0.0000' + }, + { + 'tierFloor': '1000.0000', + 'tierCap': '2000.0000', + 'collateralRate': '0.9999', + 'cum':'0.0000' + } + ] + } +]; diff --git a/tests/mock_values/restful/simpleEarn/getFlexibleSubscriptionRecord.ts b/tests/mock_values/restful/simpleEarn/getFlexibleSubscriptionRecord.ts index c39b25e..967585e 100644 --- a/tests/mock_values/restful/simpleEarn/getFlexibleSubscriptionRecord.ts +++ b/tests/mock_values/restful/simpleEarn/getFlexibleSubscriptionRecord.ts @@ -7,6 +7,7 @@ export const mockResponse: RestSimpleEarnTypes.getFlexibleSubscriptionRecordResp 'asset': 'USDT', 'time': 1575018510000, 'purchaseId': 26055, + 'productId': 'USDT001', 'type': SimpleEarnType.AUTO, 'sourceAccount': SimpleEarnSourceAccount.SPOT, 'amtFromSpot': '30', diff --git a/tests/mock_values/restful/simpleEarn/getLockedProductPosition.ts b/tests/mock_values/restful/simpleEarn/getLockedProductPosition.ts index fd7be38..ec25577 100644 --- a/tests/mock_values/restful/simpleEarn/getLockedProductPosition.ts +++ b/tests/mock_values/restful/simpleEarn/getLockedProductPosition.ts @@ -3,7 +3,8 @@ import { RestSimpleEarnTypes } from '../../../../src/index'; export const mockResponse: RestSimpleEarnTypes.getLockedProductPositionResponse = { 'rows': [ { - 'positionId': '123123', + 'positionId': 123123, + 'parentPositionId': 123122, 'projectId': 'Axs*90', 'asset': 'AXS', 'amount': '122.09202928', @@ -11,10 +12,27 @@ export const mockResponse: RestSimpleEarnTypes.getLockedProductPositionResponse 'duration': '60', 'accrualDays': '4', 'rewardAsset': 'AXS', - 'APY': '0.23', - 'isRenewable': true, - 'isAutoRenew': true, - 'redeemDate': '1732182276000' + 'APY': '0.2032', + 'rewardAmt': '5.17181528', + 'extraRewardAsset': 'BNB', + 'extraRewardAPR': '0.0203', + 'estExtraRewardAmt': '5.17181528', + 'nextPay': '1.29295383', + 'nextPayDate': '1646697600000', + 'payPeriod': '1', + 'redeemAmountEarly': '2802.24068892', + 'rewardsEndDate': '1651449600000', + 'deliverDate': '1651536000000', + 'redeemPeriod': '1', + 'redeemingAmt': '232.2323', + 'redeemTo':'FLEXIBLE', + 'partialAmtDeliverDate':'1651536000000', + 'canRedeemEarly': true, + 'canFastRedemption': true, + 'autoSubscribe': true, + 'type': 'AUTO', + 'status': 'HOLDING', + 'canReStake': true } ], 'total': 1 diff --git a/tests/mock_values/restful/simpleEarn/getLockedRedemptionRecord.ts b/tests/mock_values/restful/simpleEarn/getLockedRedemptionRecord.ts index 3f15847..e5fe949 100644 --- a/tests/mock_values/restful/simpleEarn/getLockedRedemptionRecord.ts +++ b/tests/mock_values/restful/simpleEarn/getLockedRedemptionRecord.ts @@ -3,14 +3,21 @@ import { RestSimpleEarnTypes, SimpleEarnLockedRedemption } from '../../../../src export const mockResponse: RestSimpleEarnTypes.getLockedRedemptionRecordResponse = { 'rows': [ { - 'positionId': '123123', + 'positionId': 123123, 'redeemId': 40607, 'time': 1575018510000, 'asset': 'BNB', 'lockPeriod': '30', 'amount': '21312.23223', + 'originalAmount': '21312.23223', 'type': SimpleEarnLockedRedemption.MATURE, 'deliverDate': '1575018510000', + 'lossAmount': '0.00001232', + 'isComplete': true, + 'rewardAsset':'AXS', + 'rewardAmt': '5.17181528', + 'extraRewardAsset':'BNB', + 'estExtraRewardAmt': '5.17181528', 'status': 'PAID' } ], diff --git a/tests/mock_values/restful/simpleEarn/getLockedSubscriptionRecord.ts b/tests/mock_values/restful/simpleEarn/getLockedSubscriptionRecord.ts index 7ee39b1..e29cdec 100644 --- a/tests/mock_values/restful/simpleEarn/getLockedSubscriptionRecord.ts +++ b/tests/mock_values/restful/simpleEarn/getLockedSubscriptionRecord.ts @@ -5,6 +5,7 @@ export const mockResponse: RestSimpleEarnTypes.getLockedSubscriptionRecordRespon { 'positionId': '123123', 'purchaseId': 26055, + 'projectId': 'Axs*90', 'time': 1575018510000, 'asset': 'BNB', 'amount': '21312.23223', diff --git a/tests/mock_values/restful/simpleEarn/setLockedRedeemOption.ts b/tests/mock_values/restful/simpleEarn/setLockedRedeemOption.ts new file mode 100644 index 0000000..5c037e9 --- /dev/null +++ b/tests/mock_values/restful/simpleEarn/setLockedRedeemOption.ts @@ -0,0 +1,5 @@ +import { RestSimpleEarnTypes } from '../../../../src/index'; + +export const mockResponse: RestSimpleEarnTypes.setLockedRedeemOptionResponse = { + 'success': true +}; diff --git a/tests/mock_values/restful/subAccount/getSubAccountAssetsForMasterAccount.ts b/tests/mock_values/restful/subAccount/getSubAccountAssetsForMasterAccount.ts index 4860664..bc283f8 100644 --- a/tests/mock_values/restful/subAccount/getSubAccountAssetsForMasterAccount.ts +++ b/tests/mock_values/restful/subAccount/getSubAccountAssetsForMasterAccount.ts @@ -1,31 +1,27 @@ import { RestSubAccountTypes } from '../../../../src/index'; export const mockResponse: RestSubAccountTypes.getSubAccountAssetsForMasterAccountResponse = { - 'balances':[ + 'balances': [ { + 'freeze':'0', + 'withdrawing':'0', 'asset':'ADA', - 'free':10000, - 'locked':0 + 'free':'10000', + 'locked':'0' }, { + 'freeze':'0', + 'withdrawing':'0', 'asset':'BNB', - 'free':10003, - 'locked':0 + 'free':'10003', + 'locked':'0' }, { + 'freeze':'0', + 'withdrawing':'0', 'asset':'BTC', - 'free':11467.6399, - 'locked':0 - }, - { - 'asset':'ETH', - 'free':10004.995, - 'locked':0 - }, - { - 'asset':'USDT', - 'free':11652.14213, - 'locked':0 + 'free':'11467.6399', + 'locked':'0' } ] }; diff --git a/tests/mock_values/restful/subAccount/getSubaccountAssets.ts b/tests/mock_values/restful/subAccount/getSubaccountAssets.ts index b44cc51..f5e25b7 100644 --- a/tests/mock_values/restful/subAccount/getSubaccountAssets.ts +++ b/tests/mock_values/restful/subAccount/getSubaccountAssets.ts @@ -1,9 +1,40 @@ import { RestSubAccountTypes } from '../../../../src/index'; export const mockResponse: RestSubAccountTypes.getSubAccountAssetsResponse = { - 'balances': [{ - 'asset': 'ADA', - 'free': 10000, - 'locked': 0 - }] + 'balances': [ + { + 'freeze':0, + 'withdrawing':0, + 'asset':'ADA', + 'free':10000, + 'locked':0 + }, + { + 'freeze':0, + 'withdrawing':0, + 'asset':'BNB', + 'free':10003, + 'locked':0 + }, + { + 'freeze':0, + 'withdrawing':0, + 'asset':'BTC', + 'free':11467.6399, + 'locked':0 + }, + { + 'freeze':0, + 'withdrawing':0, + 'asset':'ETH', + 'free':10004.995, + 'locked':0 + }, + { + 'freeze':0, + 'withdrawing':0, + 'asset':'USDT', + 'free':11652.14213, + 'locked':0 + }] }; diff --git a/tests/mock_values/restful/wallet/accountInfo.ts b/tests/mock_values/restful/wallet/accountInfo.ts new file mode 100644 index 0000000..d533285 --- /dev/null +++ b/tests/mock_values/restful/wallet/accountInfo.ts @@ -0,0 +1,9 @@ +import { RestWalletTypes } from '../../../../src/index'; + +export const mockResponse: RestWalletTypes.accountInfoResponse = { + 'vipLevel': 0, + 'isMarginEnabled': true, + 'isFutureEnabled': true, + 'isOptionsEnabled': true, + 'isPortfolioMarginRetailEnabled': true +}; diff --git a/tests/mock_values/restful/wallet/depositAddressList.ts b/tests/mock_values/restful/wallet/depositAddressList.ts new file mode 100644 index 0000000..e7b25ad --- /dev/null +++ b/tests/mock_values/restful/wallet/depositAddressList.ts @@ -0,0 +1,22 @@ +import { RestWalletTypes } from '../../../../src/index'; + +export const mockResponse: RestWalletTypes.depositAddressListResponse[] = [ + { + 'coin': 'ETH', + 'address': '0xD316E95Fd9E8E237Cb11f8200Babbc5D8D177BA4', + 'tag':'', + 'isDefault': 0 + }, + { + 'coin': 'ETH', + 'address': '0xD316E95Fd9E8E237Cb11f8200Babbc5D8D177BA4', + 'tag':'', + 'isDefault': 0 + }, + { + 'coin': 'ETH', + 'address': '0x00003ada75e7da97ba0db2fcde72131f712455e2', + 'tag':'', + 'isDefault': 1 + } +]; diff --git a/tests/mock_values/restful/wallet/getSymbolsDelistSchedule.ts b/tests/mock_values/restful/wallet/getSymbolsDelistSchedule.ts new file mode 100644 index 0000000..b418aff --- /dev/null +++ b/tests/mock_values/restful/wallet/getSymbolsDelistSchedule.ts @@ -0,0 +1,17 @@ +import { RestWalletTypes } from '../../../../src/index'; + +export const mockResponse: RestWalletTypes.getSymbolsDelistScheduleResponse[] = [ + { + 'delistTime': 1686161202000, + 'symbols': [ + 'ADAUSDT', + 'BNBUSDT' + ] + }, + { + 'delistTime': 1686222232000, + 'symbols': [ + 'ETHUSDT' + ] + } +]; diff --git a/tests/mock_values/restful/wallet/queryUserDelegationHistory.ts b/tests/mock_values/restful/wallet/queryUserDelegationHistory.ts new file mode 100644 index 0000000..b970c8e --- /dev/null +++ b/tests/mock_values/restful/wallet/queryUserDelegationHistory.ts @@ -0,0 +1,21 @@ +import { RestWalletTypes } from '../../../../src/index'; + +export const mockResponse: RestWalletTypes.queryUserDelegationHistoryResponse = { + 'total': 3316, + 'rows': [ + { + 'clientTranId': '293915932290879488', + 'transferType': 'Undelegate', + 'asset': 'ETH', + 'amount': '1', + 'time': 1695205406000 + }, + { + 'clientTranId': '293915892281413632', + 'transferType': 'Delegate', + 'asset': 'ETH', + 'amount': '1', + 'time': 1695205396000 + } + ] +}; diff --git a/tests/mock_values/restful/wallet/queryUserWalletBalance.ts b/tests/mock_values/restful/wallet/queryUserWalletBalance.ts new file mode 100644 index 0000000..15e46d1 --- /dev/null +++ b/tests/mock_values/restful/wallet/queryUserWalletBalance.ts @@ -0,0 +1,44 @@ +import { RestWalletTypes } from '../../../../src/index'; + +export const mockResponse: RestWalletTypes.queryUserWalletBalanceResponse[] = [ + { + 'activate': true, + 'balance': '0', + 'walletName': 'Spot' + }, + { + 'activate': true, + 'balance': '0', + 'walletName': 'Funding' + }, + { + 'activate': true, + 'balance': '0', + 'walletName': 'Cross Margin' + }, + { + 'activate': true, + 'balance': '0', + 'walletName': 'Isolated Margin' + }, + { + 'activate': true, + 'balance': '0.71842752', + 'walletName': 'USDⓈ-M Futures' + }, + { + 'activate': true, + 'balance': '0', + 'walletName': 'COIN-M Futures' + }, + { + 'activate': true, + 'balance': '0', + 'walletName': 'Earn' + }, + { + 'activate': false, + 'balance': '0', + 'walletName': 'Options' + } +]; diff --git a/tests/restful/margin/crossMarginCollateralRatio.test.ts b/tests/restful/margin/crossMarginCollateralRatio.test.ts new file mode 100644 index 0000000..103bab3 --- /dev/null +++ b/tests/restful/margin/crossMarginCollateralRatio.test.ts @@ -0,0 +1,20 @@ +import { expect } from '@jest/globals'; +import { Spot } from '../../../src/index'; +import { mockResponse } from '../../mock_values/restful/margin/crossMarginCollateralRatio'; + +jest.mock('../../../src/index'); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; + +describe('Cross Margin Collateral Ratio', () => { + const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + it('should return Cross Margin Collateral Ratio', async () => { + const spy = jest.spyOn(client, 'crossMarginCollateralRatio').mockReturnValue(Promise.resolve(mockResponse)); + const res = await client.crossMarginCollateralRatio(); + expect(res).toBeDefined(); + expect(res).toBe(mockResponse); + spy.mockRestore(); + }); +}); diff --git a/tests/restful/margin/marginAccountNewOto.test.ts b/tests/restful/margin/marginAccountNewOto.test.ts new file mode 100644 index 0000000..9e01599 --- /dev/null +++ b/tests/restful/margin/marginAccountNewOto.test.ts @@ -0,0 +1,43 @@ +import { expect } from '@jest/globals'; +import { + OrderListWorkingType, + OtoPendingType, + Side, + TimeInForce, + Spot, + RestMarginTypes +} from '../../../src/index'; +import { mockResponse } from '../../mock_values/restful/margin/marginAccountNewOto'; + +jest.mock('../../../src/index'); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; + +describe('Margin Account New OTO', () => { + const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + const options: RestMarginTypes.marginAccountNewOtoOptions = { + workingTimeInForce: TimeInForce.GTC, + pendingPrice: 50000, + pendingTimeInForce: TimeInForce.GTC, + recvWindow: 5000, + }; + it('should return Margin Account New OTO Order', async () => { + const spy = jest.spyOn(client, 'marginAccountNewOto').mockReturnValue(Promise.resolve(mockResponse)); + const res = await client.marginAccountNewOto( + 'BTCUSDT', + OrderListWorkingType.LIMIT, + Side.SELL, + 80000, + 0.02, + OtoPendingType.LIMIT, + Side.BUY, + 0.02, + options + ); + expect(res).toBeDefined(); + expect(res).toBe(mockResponse); + spy.mockRestore(); + }); +}); diff --git a/tests/restful/margin/marginAccountNewOtoco.test.ts b/tests/restful/margin/marginAccountNewOtoco.test.ts new file mode 100644 index 0000000..f2ffcb0 --- /dev/null +++ b/tests/restful/margin/marginAccountNewOtoco.test.ts @@ -0,0 +1,44 @@ +import { expect } from '@jest/globals'; +import { + OrderListAboveBelowType, + OrderListWorkingType, + Side, + TimeInForce, + Spot, + RestMarginTypes +} from '../../../src/index'; +import { mockResponse } from '../../mock_values/restful/margin/marginAccountNewOtoco'; + +jest.mock('../../../src/index'); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; + +describe('Margin Account New OTOCO', () => { + const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + const options: RestMarginTypes.marginAccountNewOtocoOptions = { + workingTimeInForce: TimeInForce.GTC, + pendingAbovePrice: 301, + pendingBelowType: OrderListAboveBelowType.STOP_LOSS, + pendingBelowPrice: 299, + recvWindow: 5000, + }; + it('should return Margin Account New OTOCO Order', async () => { + const spy = jest.spyOn(client, 'marginAccountNewOtoco').mockReturnValue(Promise.resolve(mockResponse)); + const res = await client.marginAccountNewOtoco( + 'BNBUSDT', + OrderListWorkingType.LIMIT, + Side.BUY, + 300, + 1, + Side.SELL, + 1, + OrderListAboveBelowType.LIMIT_MAKER, + options + ); + expect(res).toBeDefined(); + expect(res).toBe(mockResponse); + spy.mockRestore(); + }); +}); diff --git a/tests/restful/portfolio_margin/getAccountBalance.test.ts b/tests/restful/portfolio_margin/getAccountBalance.test.ts new file mode 100644 index 0000000..ef40e39 --- /dev/null +++ b/tests/restful/portfolio_margin/getAccountBalance.test.ts @@ -0,0 +1,23 @@ + +import { expect } from '@jest/globals'; +import { Spot } from '../../../src/index'; +import { mockResponse } from '../../mock_values/restful/portfolioMargin/getAccountBalance'; + + +jest.mock('../../../src/index'); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; + +describe('Get Account Balance', () => { + const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + + it('should return account balance', async () => { + const spy = jest.spyOn(client, 'getAccountBalance').mockReturnValue(Promise.resolve(mockResponse)); + const res = await client.getAccountBalance(); + expect(res).toBeDefined(); + expect(res).toBe(mockResponse); + spy.mockRestore(); + }); +}); diff --git a/tests/restful/portfolio_margin/getSpanAccountInfo.test.ts b/tests/restful/portfolio_margin/getSpanAccountInfo.test.ts new file mode 100644 index 0000000..dd2dcde --- /dev/null +++ b/tests/restful/portfolio_margin/getSpanAccountInfo.test.ts @@ -0,0 +1,23 @@ + +import { expect } from '@jest/globals'; +import { Spot } from '../../../src/index'; +import { mockResponse } from '../../mock_values/restful/portfolioMargin/getSpanAccountInfo'; + + +jest.mock('../../../src/index'); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; + +describe('Get SPAN Account Info', () => { + const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + + it('should return SPAN account info', async () => { + const spy = jest.spyOn(client, 'getSpanAccountInfo').mockReturnValue(Promise.resolve(mockResponse)); + const res = await client.getSpanAccountInfo(); + expect(res).toBeDefined(); + expect(res).toBe(mockResponse); + spy.mockRestore(); + }); +}); diff --git a/tests/restful/portfolio_margin/getTieredCollateralRate.test.ts b/tests/restful/portfolio_margin/getTieredCollateralRate.test.ts new file mode 100644 index 0000000..2e27ca0 --- /dev/null +++ b/tests/restful/portfolio_margin/getTieredCollateralRate.test.ts @@ -0,0 +1,23 @@ + +import { expect } from '@jest/globals'; +import { Spot } from '../../../src/index'; +import { mockResponse } from '../../mock_values/restful/portfolioMargin/getTieredCollateralRate'; + + +jest.mock('../../../src/index'); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; + +describe('Get Tiered Collateral Rate', () => { + const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + + it('should return tiered collateral rate', async () => { + const spy = jest.spyOn(client, 'getTieredCollateralRate').mockReturnValue(Promise.resolve(mockResponse)); + const res = await client.getTieredCollateralRate(); + expect(res).toBeDefined(); + expect(res).toBe(mockResponse); + spy.mockRestore(); + }); +}); diff --git a/tests/restful/simpleEarn/setLockedRedeemOption.test.ts b/tests/restful/simpleEarn/setLockedRedeemOption.test.ts new file mode 100644 index 0000000..0c218cc --- /dev/null +++ b/tests/restful/simpleEarn/setLockedRedeemOption.test.ts @@ -0,0 +1,23 @@ + +import { expect } from '@jest/globals'; +import { RedeemOption, Spot } from '../../../src/index'; +import { mockResponse } from '../../mock_values/restful/simpleEarn/setLockedRedeemOption'; + +jest.mock('../../../src/index'); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; + +describe('Set Locked Auto Subscribe', () => { + const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + + it('should set locked auto subscribe', async () => { + const spy = jest.spyOn(client, 'setLockedRedeemOption').mockReturnValue(Promise.resolve(mockResponse)); + const res = await client.setLockedRedeemOption('1', RedeemOption.SPOT); + expect(res).toBeDefined(); + expect(res).toBe(mockResponse); + spy.mockRestore(); + }); +}); + diff --git a/tests/restful/trade/newOto.test.ts b/tests/restful/trade/newOto.test.ts index 8c890c4..20c91b8 100644 --- a/tests/restful/trade/newOto.test.ts +++ b/tests/restful/trade/newOto.test.ts @@ -1,5 +1,5 @@ import { expect } from '@jest/globals'; -import { orderListWorkingType, OtoPendingType, Side, Spot, TimeInForce } from '../../../src/index'; +import { OrderListWorkingType, OtoPendingType, Side, Spot, TimeInForce } from '../../../src/index'; import { mockResponse } from '../../mock_values/restful/trade/newOto'; jest.mock('../../../src/index'); @@ -13,7 +13,7 @@ describe('New Oto', () => { it('should return New Oto result', async () => { const options = { workingTimeInForce: TimeInForce.GTC, pendingPrice: 400, pendingTimeInForce: TimeInForce.GTC }; const spy = jest.spyOn(client, 'newOto').mockReturnValue(Promise.resolve(mockResponse)); - const res = await client.newOto('BNBUSDT', orderListWorkingType.LIMIT, Side.BUY, 400, 1, OtoPendingType.LIMIT, Side.BUY, 1, options); + const res = await client.newOto('BNBUSDT', OrderListWorkingType.LIMIT, Side.BUY, 400, 1, OtoPendingType.LIMIT, Side.BUY, 1, options); expect(res).toBeDefined(); expect(res).toBe(mockResponse); spy.mockRestore(); diff --git a/tests/restful/trade/newOtoco.test.ts b/tests/restful/trade/newOtoco.test.ts index bb47f3d..c8eb788 100644 --- a/tests/restful/trade/newOtoco.test.ts +++ b/tests/restful/trade/newOtoco.test.ts @@ -1,5 +1,5 @@ import { expect } from '@jest/globals'; -import { orderListWorkingType, OrderListAboveBelowType, Side, Spot, TimeInForce } from '../../../src/index'; +import { OrderListWorkingType, OrderListAboveBelowType, Side, Spot, TimeInForce } from '../../../src/index'; import { mockResponse } from '../../mock_values/restful/trade/newOto'; jest.mock('../../../src/index'); @@ -13,7 +13,7 @@ describe('New Otoco', () => { it('should return New Otoco result', async () => { const options = { workingTimeInForce: TimeInForce.GTC, pendingAbovePrice: 400, pendingBelowType: OrderListAboveBelowType.LIMIT_MAKER, pendingBelowPrice: 395 }; const spy = jest.spyOn(client, 'newOtoco').mockReturnValue(Promise.resolve(mockResponse)); - const res = await client.newOtoco('BNBUSDT', orderListWorkingType.LIMIT, Side.BUY, 400, 1, Side.BUY, 1, OrderListAboveBelowType.LIMIT_MAKER, options); + const res = await client.newOtoco('BNBUSDT', OrderListWorkingType.LIMIT, Side.BUY, 400, 1, Side.BUY, 1, OrderListAboveBelowType.LIMIT_MAKER, options); expect(res).toBeDefined(); expect(res).toBe(mockResponse); spy.mockRestore(); diff --git a/tests/restful/wallet/accountInfo.test.ts b/tests/restful/wallet/accountInfo.test.ts new file mode 100644 index 0000000..1f0de8d --- /dev/null +++ b/tests/restful/wallet/accountInfo.test.ts @@ -0,0 +1,20 @@ +import { expect } from '@jest/globals'; +import { Spot } from '../../../src/index'; +import { mockResponse } from '../../mock_values/restful/wallet/accountInfo'; + +jest.mock('../../../src/index'); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; + +describe('Fetch Account Info Detail', () => { + const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + it('should return account info detail', async () => { + const spy = jest.spyOn(client, 'accountInfo').mockReturnValue(Promise.resolve(mockResponse)); + const res = await client.accountInfo(); + expect(res).toBeDefined(); + expect(res).toBe(mockResponse); + spy.mockRestore(); + }); +}); diff --git a/tests/restful/wallet/depositAddressList.test.ts b/tests/restful/wallet/depositAddressList.test.ts new file mode 100644 index 0000000..8fb8626 --- /dev/null +++ b/tests/restful/wallet/depositAddressList.test.ts @@ -0,0 +1,20 @@ +import { expect } from '@jest/globals'; +import { Spot } from '../../../src/index'; +import { mockResponse } from '../../mock_values/restful/wallet/depositAddressList'; + +jest.mock('../../../src/index'); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; + +describe('Fetch Deposit Address List With Network', () => { + const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + it('should return deposit address list with network', async () => { + const spy = jest.spyOn(client, 'depositAddressList').mockReturnValue(Promise.resolve(mockResponse)); + const res = await client.depositAddressList('BNB'); + expect(res).toBeDefined(); + expect(res).toBe(mockResponse); + spy.mockRestore(); + }); +}); diff --git a/tests/restful/wallet/getSymbolsDelistSchedule.test.ts b/tests/restful/wallet/getSymbolsDelistSchedule.test.ts new file mode 100644 index 0000000..e05cef6 --- /dev/null +++ b/tests/restful/wallet/getSymbolsDelistSchedule.test.ts @@ -0,0 +1,20 @@ +import { expect } from '@jest/globals'; +import { Spot } from '../../../src/index'; +import { mockResponse } from '../../mock_values/restful/wallet/getSymbolsDelistSchedule'; + +jest.mock('../../../src/index'); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; + +describe('Get Symbols Delist Schedule for Spot', () => { + const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + it('should return symbols delist schedule for spot', async () => { + const spy = jest.spyOn(client, 'getSymbolsDelistSchedule').mockReturnValue(Promise.resolve(mockResponse)); + const res = await client.getSymbolsDelistSchedule(); + expect(res).toBeDefined(); + expect(res).toBe(mockResponse); + spy.mockRestore(); + }); +}); diff --git a/tests/restful/wallet/queryUserDelegationHistory.test.ts b/tests/restful/wallet/queryUserDelegationHistory.test.ts new file mode 100644 index 0000000..8aad75f --- /dev/null +++ b/tests/restful/wallet/queryUserDelegationHistory.test.ts @@ -0,0 +1,20 @@ +import { expect } from '@jest/globals'; +import { Spot } from '../../../src/index'; +import { mockResponse } from '../../mock_values/restful/wallet/queryUserDelegationHistory'; + +jest.mock('../../../src/index'); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; + +describe('Query User Delegation History', () => { + const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + it('should return user delegation history', async () => { + const spy = jest.spyOn(client, 'queryUserDelegationHistory').mockReturnValue(Promise.resolve(mockResponse)); + const res = await client.queryUserDelegationHistory('email', 1695205000000, 1695205999999); + expect(res).toBeDefined(); + expect(res).toBe(mockResponse); + spy.mockRestore(); + }); +}); diff --git a/tests/restful/wallet/queryUserWalletBalance.test.ts b/tests/restful/wallet/queryUserWalletBalance.test.ts new file mode 100644 index 0000000..46ad4a8 --- /dev/null +++ b/tests/restful/wallet/queryUserWalletBalance.test.ts @@ -0,0 +1,20 @@ +import { expect } from '@jest/globals'; +import { Spot } from '../../../src/index'; +import { mockResponse } from '../../mock_values/restful/wallet/queryUserWalletBalance'; + +jest.mock('../../../src/index'); + +const apiKey = process.env.BINANCE_API_KEY || ''; +const apiSecret = process.env.BINANCE_API_SECRET || ''; +const baseURL = process.env.BINANCE_BASE_URL || ''; + +describe('Query User Wallet Balance', () => { + const client = new Spot(apiKey, apiSecret, { baseURL: baseURL }); + it('should return user wallet balance', async () => { + const spy = jest.spyOn(client, 'queryUserWalletBalance').mockReturnValue(Promise.resolve(mockResponse)); + const res = await client.queryUserWalletBalance(); + expect(res).toBeDefined(); + expect(res).toBe(mockResponse); + spy.mockRestore(); + }); +});