Merge branch 'master' into Update181124
This commit is contained in:
84
.eslintrc.cjs
Normal file
84
.eslintrc.cjs
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
module.exports = {
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
parserOptions: {
|
||||||
|
project: 'tsconfig.linting.json',
|
||||||
|
tsconfigRootDir: __dirname,
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
'@typescript-eslint/eslint-plugin',
|
||||||
|
// 'simple-import-sort',
|
||||||
|
// 'require-extensions',
|
||||||
|
],
|
||||||
|
extends: [
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'plugin:prettier/recommended',
|
||||||
|
// 'plugin:require-extensions/recommended',
|
||||||
|
],
|
||||||
|
root: true,
|
||||||
|
env: {
|
||||||
|
node: true,
|
||||||
|
jest: true,
|
||||||
|
},
|
||||||
|
ignorePatterns: ['.eslintrc.js'],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/await-thenable': 'error',
|
||||||
|
'@typescript-eslint/dot-notation': 'off',
|
||||||
|
'@typescript-eslint/no-unused-vars': 'warn',
|
||||||
|
|
||||||
|
'@typescript-eslint/no-unused-expressions': 'error',
|
||||||
|
'@typescript-eslint/no-var-requires': 'error',
|
||||||
|
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
||||||
|
|
||||||
|
'@typescript-eslint/no-explicit-any': 'error',
|
||||||
|
'@typescript-eslint/no-floating-promises': 'off',
|
||||||
|
'@typescript-eslint/no-inferrable-types': 'off',
|
||||||
|
'@typescript-eslint/promise-function-async': 'off',
|
||||||
|
'@typescript-eslint/no-use-before-define': 'off',
|
||||||
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||||
|
'@typescript-eslint/ban-types': 'off',
|
||||||
|
'@typescript-eslint/ban-ts-comment': 'off',
|
||||||
|
|
||||||
|
'no-dupe-class-members': 'off',
|
||||||
|
'no-param-reassign': ['error'],
|
||||||
|
'array-bracket-spacing': ['error', 'never'],
|
||||||
|
indent: ['off'],
|
||||||
|
'linebreak-style': ['error', 'unix'],
|
||||||
|
'lines-between-class-members': ['warn', 'always'],
|
||||||
|
semi: 'off',
|
||||||
|
'@typescript-eslint/semi': ['error'],
|
||||||
|
'new-cap': 'off',
|
||||||
|
'no-console': 'off',
|
||||||
|
'no-debugger': 'off',
|
||||||
|
'no-mixed-spaces-and-tabs': 2,
|
||||||
|
'no-use-before-define': [2, 'nofunc'],
|
||||||
|
'no-unreachable': ['warn'],
|
||||||
|
'no-unused-vars': ['warn'],
|
||||||
|
'no-extra-parens': ['off'],
|
||||||
|
'no-mixed-operators': ['off'],
|
||||||
|
quotes: [2, 'single', 'avoid-escape'],
|
||||||
|
'block-scoped-var': 2,
|
||||||
|
'brace-style': [2, '1tbs', { allowSingleLine: true }],
|
||||||
|
'computed-property-spacing': [2, 'never'],
|
||||||
|
'keyword-spacing': 2,
|
||||||
|
'space-unary-ops': 2,
|
||||||
|
'sort-imports': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
ignoreCase: false,
|
||||||
|
ignoreDeclarationSort: true,
|
||||||
|
ignoreMemberSort: false,
|
||||||
|
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
|
||||||
|
allowSeparatedGroups: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'max-len': ['warn', { code: 140 }],
|
||||||
|
|
||||||
|
// newer rules
|
||||||
|
'@typescript-eslint/interface-name-prefix': 'off',
|
||||||
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||||
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||||
|
// 'simple-import-sort/imports': 'error',
|
||||||
|
// 'simple-import-sort/exports': 'error',
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
{
|
|
||||||
"env": {
|
|
||||||
"es6": true,
|
|
||||||
"node": true
|
|
||||||
},
|
|
||||||
"extends": ["eslint:recommended"],
|
|
||||||
"parser": "@typescript-eslint/parser",
|
|
||||||
"root": true,
|
|
||||||
"plugins": ["@typescript-eslint"],
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"files": ["**/*.ts", "**/*.tsx"],
|
|
||||||
"extends": [
|
|
||||||
"eslint:recommended",
|
|
||||||
"plugin:@typescript-eslint/recommended"
|
|
||||||
],
|
|
||||||
"parserOptions": {
|
|
||||||
"projecasdft": true,
|
|
||||||
"project": [
|
|
||||||
"./tsconfig.json",
|
|
||||||
"./tsconfig.build.json",
|
|
||||||
"./tsconfig.examples.json",
|
|
||||||
"./test/tsconfig.test.json"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"@typescript-eslint/await-thenable": "error",
|
|
||||||
"@typescript-eslint/dot-notation": "off",
|
|
||||||
"@typescript-eslint/no-unused-vars": "warn",
|
|
||||||
|
|
||||||
"@typescript-eslint/no-unused-expressions": "error",
|
|
||||||
"@typescript-eslint/no-var-requires": "error",
|
|
||||||
"@typescript-eslint/prefer-namespace-keyword": "error",
|
|
||||||
|
|
||||||
"@typescript-eslint/no-explicit-any": "error",
|
|
||||||
"@typescript-eslint/no-floating-promises": "off",
|
|
||||||
"@typescript-eslint/no-inferrable-types": "off",
|
|
||||||
"@typescript-eslint/promise-function-async": "off",
|
|
||||||
"@typescript-eslint/no-use-before-define": "off",
|
|
||||||
"@typescript-eslint/no-non-null-assertion": "off",
|
|
||||||
"@typescript-eslint/ban-types": "off",
|
|
||||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
||||||
"@typescript-eslint/ban-ts-comment": "off",
|
|
||||||
|
|
||||||
"no-dupe-class-members": "off",
|
|
||||||
"no-param-reassign": ["error"],
|
|
||||||
"array-bracket-spacing": ["error", "never"],
|
|
||||||
"indent": ["off"],
|
|
||||||
"linebreak-style": ["error", "unix"],
|
|
||||||
"lines-between-class-members": ["warn", "always"],
|
|
||||||
"semi": "off",
|
|
||||||
"@typescript-eslint/semi": ["error"],
|
|
||||||
"new-cap": "off",
|
|
||||||
"no-console": "off",
|
|
||||||
"no-debugger": "off",
|
|
||||||
"no-mixed-spaces-and-tabs": 2,
|
|
||||||
"no-use-before-define": [2, "nofunc"],
|
|
||||||
"no-unreachable": ["warn"],
|
|
||||||
"no-unused-vars": ["warn"],
|
|
||||||
"no-extra-parens": ["off"],
|
|
||||||
"no-mixed-operators": ["off"],
|
|
||||||
"quotes": [2, "single", "avoid-escape"],
|
|
||||||
"block-scoped-var": 2,
|
|
||||||
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
|
|
||||||
"computed-property-spacing": [2, "never"],
|
|
||||||
"keyword-spacing": 2,
|
|
||||||
"space-unary-ops": 2,
|
|
||||||
"sort-imports": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"ignoreCase": false,
|
|
||||||
"ignoreDeclarationSort": true,
|
|
||||||
"ignoreMemberSort": false,
|
|
||||||
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"],
|
|
||||||
"allowSeparatedGroups": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"max-len": ["warn", { "code": 140 }]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"files": ["examples/*.js"],
|
|
||||||
"extends": ["eslint:recommended"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "bybit-api",
|
"name": "bybit-api",
|
||||||
"version": "3.10.23",
|
"version": "3.10.27",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "bybit-api",
|
"name": "bybit-api",
|
||||||
"version": "3.10.23",
|
"version": "3.10.27",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.6.6",
|
"axios": "^1.6.6",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bybit-api",
|
"name": "bybit-api",
|
||||||
"version": "3.10.23",
|
"version": "3.10.27,
|
||||||
"description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.",
|
"description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
|||||||
@@ -43,6 +43,10 @@ import BaseRestClient from './util/BaseRestClient';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* REST API client for Account Asset V3 APIs
|
* REST API client for Account Asset V3 APIs
|
||||||
|
* @deprecated WARNING
|
||||||
|
* These endpoints are being switched off gradually and are expected to be completely turned off by the end of 2024.
|
||||||
|
* They may stop working at any point before then.
|
||||||
|
* Please update your code as soon as possible to use the V5 APIs instead.
|
||||||
*/
|
*/
|
||||||
export class AccountAssetClientV3 extends BaseRestClient {
|
export class AccountAssetClientV3 extends BaseRestClient {
|
||||||
getClientType() {
|
getClientType() {
|
||||||
@@ -67,20 +71,20 @@ export class AccountAssetClientV3 extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
createInternalTransfer(
|
createInternalTransfer(
|
||||||
params: InternalTransferRequestV3
|
params: InternalTransferRequestV3,
|
||||||
): Promise<APIResponseWithTime<{ transferId: string }>> {
|
): Promise<APIResponseWithTime<{ transferId: string }>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/asset/v3/private/transfer/inter-transfer',
|
'/asset/v3/private/transfer/inter-transfer',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getInternalTransfers(
|
getInternalTransfers(
|
||||||
params: QueryInternalTransfersRequestV3
|
params: QueryInternalTransfersRequestV3,
|
||||||
): Promise<APIResponseWithTime<QueryInternalTransferSResponseV3>> {
|
): Promise<APIResponseWithTime<QueryInternalTransferSResponseV3>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/asset/v3/private/transfer/inter-transfer/list/query',
|
'/asset/v3/private/transfer/inter-transfer/list/query',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,16 +97,16 @@ export class AccountAssetClientV3 extends BaseRestClient {
|
|||||||
}): Promise<APIResponseWithTime<{ transferId: string }>> {
|
}): Promise<APIResponseWithTime<{ transferId: string }>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/asset/v3/private/transfer/sub-member-transfer',
|
'/asset/v3/private/transfer/sub-member-transfer',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubAccountTransfers(
|
getSubAccountTransfers(
|
||||||
params?: SubAccountTransferRequestV3
|
params?: SubAccountTransferRequestV3,
|
||||||
): Promise<APIResponseWithTime<SubAccountTransferResponseV3>> {
|
): Promise<APIResponseWithTime<SubAccountTransferResponseV3>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/asset/v3/private/transfer/sub-member-transfer/list/query',
|
'/asset/v3/private/transfer/sub-member-transfer/list/query',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,61 +124,61 @@ export class AccountAssetClientV3 extends BaseRestClient {
|
|||||||
}): Promise<APIResponseWithTime<any>> {
|
}): Promise<APIResponseWithTime<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/asset/v3/private/transfer/transfer-sub-member-save',
|
'/asset/v3/private/transfer/transfer-sub-member-save',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
createUniversalTransfer(
|
createUniversalTransfer(
|
||||||
params: UniversalTransferRequestV3
|
params: UniversalTransferRequestV3,
|
||||||
): Promise<APIResponseWithTime<UniversalTransferCreateResponse>> {
|
): Promise<APIResponseWithTime<UniversalTransferCreateResponse>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/asset/v3/private/transfer/universal-transfer',
|
'/asset/v3/private/transfer/universal-transfer',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUniversalTransfers(
|
getUniversalTransfers(
|
||||||
params: UniversalTransferListRequestV3
|
params: UniversalTransferListRequestV3,
|
||||||
): Promise<APIResponseWithTime<UniversalTransferListResponseV3>> {
|
): Promise<APIResponseWithTime<UniversalTransferListResponseV3>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/asset/v3/private/transfer/universal-transfer/list/query',
|
'/asset/v3/private/transfer/universal-transfer/list/query',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTransferableCoinList(
|
getTransferableCoinList(
|
||||||
params: TransferCoinListRequestV3
|
params: TransferCoinListRequestV3,
|
||||||
): Promise<APIResponseWithTime<{ list: string[] }>> {
|
): Promise<APIResponseWithTime<{ list: string[] }>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/asset/v3/private/transfer/transfer-coin/list/query',
|
'/asset/v3/private/transfer/transfer-coin/list/query',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAccountCoinBalance(
|
getAccountCoinBalance(
|
||||||
params: SingleAccountCoinBalanceRequestV3
|
params: SingleAccountCoinBalanceRequestV3,
|
||||||
): Promise<APIResponseWithTime<AccountCoinBalanceResponseV3>> {
|
): Promise<APIResponseWithTime<AccountCoinBalanceResponseV3>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/asset/v3/private/transfer/account-coin/balance/query',
|
'/asset/v3/private/transfer/account-coin/balance/query',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAccountCoinBalances(
|
getAccountCoinBalances(
|
||||||
params: AccountCoinBalancesRequestV3
|
params: AccountCoinBalancesRequestV3,
|
||||||
): Promise<APIResponseWithTime<AccountCoinBalancesResponseV3>> {
|
): Promise<APIResponseWithTime<AccountCoinBalancesResponseV3>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/asset/v3/private/transfer/account-coins/balance/query',
|
'/asset/v3/private/transfer/account-coins/balance/query',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAssetInfo(
|
getAssetInfo(
|
||||||
params?: AssetInfoRequestV3
|
params?: AssetInfoRequestV3,
|
||||||
): Promise<APIResponseWithTime<AssetInfoResponseV3>> {
|
): Promise<APIResponseWithTime<AssetInfoResponseV3>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/asset/v3/private/transfer/asset-info/query',
|
'/asset/v3/private/transfer/asset-info/query',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,49 +190,49 @@ export class AccountAssetClientV3 extends BaseRestClient {
|
|||||||
|
|
||||||
/** Get Deposit Spec */
|
/** Get Deposit Spec */
|
||||||
getSupportedDepositList(
|
getSupportedDepositList(
|
||||||
params?: SupportedDepositListRequestV3
|
params?: SupportedDepositListRequestV3,
|
||||||
): Promise<APIResponseWithTime<SupportedDepositListResponseV3>> {
|
): Promise<APIResponseWithTime<SupportedDepositListResponseV3>> {
|
||||||
return this.get(
|
return this.get(
|
||||||
'/asset/v3/public/deposit/allowed-deposit-list/query',
|
'/asset/v3/public/deposit/allowed-deposit-list/query',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDepositRecords(
|
getDepositRecords(
|
||||||
params?: DepositRecordQueryRequestV3
|
params?: DepositRecordQueryRequestV3,
|
||||||
): Promise<APIResponseWithTime<DepositRecordQueryResponseV3>> {
|
): Promise<APIResponseWithTime<DepositRecordQueryResponseV3>> {
|
||||||
return this.getPrivate('/asset/v3/private/deposit/record/query', params);
|
return this.getPrivate('/asset/v3/private/deposit/record/query', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubDepositRecords(
|
getSubDepositRecords(
|
||||||
params: SubDepositRecordQueryRequestV3
|
params: SubDepositRecordQueryRequestV3,
|
||||||
): Promise<APIResponseWithTime<DepositRecordQueryResponseV3>> {
|
): Promise<APIResponseWithTime<DepositRecordQueryResponseV3>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/asset/v3/private/deposit/sub-member-record/query',
|
'/asset/v3/private/deposit/sub-member-record/query',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWithdrawRecords(
|
getWithdrawRecords(
|
||||||
params?: WithdrawRecordQueryRequestV3
|
params?: WithdrawRecordQueryRequestV3,
|
||||||
): Promise<APIResponseWithTime<WithdrawRecordsQueryResponseV3>> {
|
): Promise<APIResponseWithTime<WithdrawRecordsQueryResponseV3>> {
|
||||||
return this.getPrivate('/asset/v3/private/withdraw/record/query', params);
|
return this.getPrivate('/asset/v3/private/withdraw/record/query', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getCoinInformation(
|
getCoinInformation(
|
||||||
coin?: string
|
coin?: string,
|
||||||
): Promise<APIResponseWithTime<CoinInfoQueryResponseV3>> {
|
): Promise<APIResponseWithTime<CoinInfoQueryResponseV3>> {
|
||||||
return this.getPrivate('/asset/v3/private/coin-info/query', { coin });
|
return this.getPrivate('/asset/v3/private/coin-info/query', { coin });
|
||||||
}
|
}
|
||||||
|
|
||||||
submitWithdrawal(
|
submitWithdrawal(
|
||||||
params: WithdrawCreateRequestV3
|
params: WithdrawCreateRequestV3,
|
||||||
): Promise<APIResponseWithTime<{ id: string }>> {
|
): Promise<APIResponseWithTime<{ id: string }>> {
|
||||||
return this.postPrivate('/asset/v3/private/withdraw/create', params);
|
return this.postPrivate('/asset/v3/private/withdraw/create', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelWithdrawal(
|
cancelWithdrawal(
|
||||||
withdrawalId: number
|
withdrawalId: number,
|
||||||
): Promise<APIResponseWithTime<{ status: 1 | 0 }>> {
|
): Promise<APIResponseWithTime<{ status: 1 | 0 }>> {
|
||||||
return this.postPrivate('/asset/v3/private/withdraw/create', {
|
return this.postPrivate('/asset/v3/private/withdraw/create', {
|
||||||
withdrawalId,
|
withdrawalId,
|
||||||
@@ -236,28 +240,28 @@ export class AccountAssetClientV3 extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getMasterAccountDepositAddress(
|
getMasterAccountDepositAddress(
|
||||||
params?: QueryDepositAddressRequestV3
|
params?: QueryDepositAddressRequestV3,
|
||||||
): Promise<APIResponseWithTime<DepositAddressResponseV3>> {
|
): Promise<APIResponseWithTime<DepositAddressResponseV3>> {
|
||||||
return this.getPrivate('/asset/v3/private/deposit/address/query', params);
|
return this.getPrivate('/asset/v3/private/deposit/address/query', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getSubAccountDepositAddress(
|
getSubAccountDepositAddress(
|
||||||
params: QuerySubAccountDepositAddressRequestV3
|
params: QuerySubAccountDepositAddressRequestV3,
|
||||||
): Promise<APIResponseWithTime<DepositAddressResponseV3>> {
|
): Promise<APIResponseWithTime<DepositAddressResponseV3>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/asset/v3/private/deposit/sub-member-address/query',
|
'/asset/v3/private/deposit/sub-member-address/query',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
createSubMember(
|
createSubMember(
|
||||||
params: CreateSubMemberRequestV3
|
params: CreateSubMemberRequestV3,
|
||||||
): Promise<APIResponseWithTime<CreateSubMemberResponseV3>> {
|
): Promise<APIResponseWithTime<CreateSubMemberResponseV3>> {
|
||||||
return this.postPrivate('/user/v3/private/create-sub-member', params);
|
return this.postPrivate('/user/v3/private/create-sub-member', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
createSubAPIKey(
|
createSubAPIKey(
|
||||||
params: CreateSubAPIKeyRequestV3
|
params: CreateSubAPIKeyRequestV3,
|
||||||
): Promise<APIResponseWithTime<CreateSubAPIKeyResponseV3>> {
|
): Promise<APIResponseWithTime<CreateSubAPIKeyResponseV3>> {
|
||||||
return this.postPrivate('/user/v3/private/create-sub-api', params);
|
return this.postPrivate('/user/v3/private/create-sub-api', params);
|
||||||
}
|
}
|
||||||
@@ -274,7 +278,7 @@ export class AccountAssetClientV3 extends BaseRestClient {
|
|||||||
*/
|
*/
|
||||||
freezeSubMember(
|
freezeSubMember(
|
||||||
subuid: number,
|
subuid: number,
|
||||||
frozenStatus: 0 | 1
|
frozenStatus: 0 | 1,
|
||||||
): Promise<APIResponseWithTime<{}>> {
|
): Promise<APIResponseWithTime<{}>> {
|
||||||
return this.postPrivate('/user/v3/private/frozen-sub-member', {
|
return this.postPrivate('/user/v3/private/frozen-sub-member', {
|
||||||
subuid,
|
subuid,
|
||||||
@@ -287,13 +291,13 @@ export class AccountAssetClientV3 extends BaseRestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
modifyMasterAPIKey(
|
modifyMasterAPIKey(
|
||||||
params: ModifyAPIKeyRequestV3
|
params: ModifyAPIKeyRequestV3,
|
||||||
): Promise<APIResponseWithTime<APIKeyInfoV3>> {
|
): Promise<APIResponseWithTime<APIKeyInfoV3>> {
|
||||||
return this.postPrivate('/user/v3/private/update-api', params);
|
return this.postPrivate('/user/v3/private/update-api', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
modifySubAPIKey(
|
modifySubAPIKey(
|
||||||
params: ModifyAPIKeyRequestV3
|
params: ModifyAPIKeyRequestV3,
|
||||||
): Promise<APIResponseWithTime<APIKeyInfoV3>> {
|
): Promise<APIResponseWithTime<APIKeyInfoV3>> {
|
||||||
return this.postPrivate('/user/v3/private/update-sub-api', params);
|
return this.postPrivate('/user/v3/private/update-sub-api', params);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ import BaseRestClient from './util/BaseRestClient';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* REST API client for Derivatives V3 Contract APIs
|
* REST API client for Derivatives V3 Contract APIs
|
||||||
|
* @deprecated WARNING
|
||||||
|
* These endpoints are being switched off gradually and are expected to be completely turned off by the end of 2024.
|
||||||
|
* They may stop working at any point before then.
|
||||||
|
* Please update your code as soon as possible to use the V5 APIs instead.
|
||||||
*/
|
*/
|
||||||
export class ContractClient extends BaseRestClient {
|
export class ContractClient extends BaseRestClient {
|
||||||
getClientType() {
|
getClientType() {
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ import BaseRestClient from './util/BaseRestClient';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* REST API client for USDC Perpetual APIs
|
* REST API client for USDC Perpetual APIs
|
||||||
|
* @deprecated WARNING
|
||||||
|
* These endpoints are being switched off gradually and are expected to be completely turned off by the end of 2024.
|
||||||
|
* They may stop working at any point before then.
|
||||||
|
* Please update your code as soon as possible to use the V5 APIs instead.
|
||||||
*/
|
*/
|
||||||
export class CopyTradingClient extends BaseRestClient {
|
export class CopyTradingClient extends BaseRestClient {
|
||||||
getClientType() {
|
getClientType() {
|
||||||
@@ -82,7 +86,10 @@ export class CopyTradingClient extends BaseRestClient {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Close Order. This endpoint's rate_limit will decrease by 10 per request; ie, one request to this endpoint consumes 10 from the limit allowed per minute. */
|
/** Close Order.
|
||||||
|
* This endpoint's rate_limit will decrease by 10 per request;
|
||||||
|
* ie, one request to this endpoint consumes 10 from the limit allowed per minute.
|
||||||
|
*/
|
||||||
closeOrder(
|
closeOrder(
|
||||||
params: CopyTradingCloseOrderRequest,
|
params: CopyTradingCloseOrderRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable max-len */
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import {
|
import {
|
||||||
APIResponseV3,
|
APIResponseV3,
|
||||||
@@ -242,7 +243,7 @@ export class RestClientV5 extends BaseRestClient {
|
|||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`Your approximate latency to exchange server:
|
`Your approximate latency to exchange server:
|
||||||
One way: ${estimatedOneWayLatency}ms.
|
One way: ${estimatedOneWayLatency}ms.
|
||||||
Round trip: ${roundTripTime}ms.
|
Round trip: ${roundTripTime}ms.
|
||||||
`,
|
`,
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ import BaseRestClient from './util/BaseRestClient';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* REST API client for newer Spot V3 APIs.
|
* REST API client for newer Spot V3 APIs.
|
||||||
|
* @deprecated WARNING
|
||||||
|
* These endpoints are being switched off gradually and are expected to be completely turned off by the end of 2024.
|
||||||
|
* They may stop working at any point before then.
|
||||||
|
* Please update your code as soon as possible to use the V5 APIs instead.
|
||||||
*/
|
*/
|
||||||
export class SpotClientV3 extends BaseRestClient {
|
export class SpotClientV3 extends BaseRestClient {
|
||||||
getClientType() {
|
getClientType() {
|
||||||
@@ -49,7 +53,7 @@ export class SpotClientV3 extends BaseRestClient {
|
|||||||
getMergedOrderBook(
|
getMergedOrderBook(
|
||||||
symbol: string,
|
symbol: string,
|
||||||
scale?: number,
|
scale?: number,
|
||||||
limit?: number
|
limit?: number,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.get('/spot/v3/public/quote/depth/merged', {
|
return this.get('/spot/v3/public/quote/depth/merged', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -69,7 +73,7 @@ export class SpotClientV3 extends BaseRestClient {
|
|||||||
interval: KlineInterval,
|
interval: KlineInterval,
|
||||||
limit?: number,
|
limit?: number,
|
||||||
startTime?: number,
|
startTime?: number,
|
||||||
endTime?: number
|
endTime?: number,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.get('/spot/v3/public/quote/kline', {
|
return this.get('/spot/v3/public/quote/kline', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -120,7 +124,7 @@ export class SpotClientV3 extends BaseRestClient {
|
|||||||
|
|
||||||
/** Batch cancel orders */
|
/** Batch cancel orders */
|
||||||
cancelOrderBatch(
|
cancelOrderBatch(
|
||||||
params: SpotCancelOrderBatchRequest
|
params: SpotCancelOrderBatchRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
const orderTypes = params.orderTypes
|
const orderTypes = params.orderTypes
|
||||||
? params.orderTypes.join(',')
|
? params.orderTypes.join(',')
|
||||||
@@ -145,7 +149,7 @@ export class SpotClientV3 extends BaseRestClient {
|
|||||||
symbol?: string,
|
symbol?: string,
|
||||||
orderId?: string,
|
orderId?: string,
|
||||||
limit?: number,
|
limit?: number,
|
||||||
orderCategory?: 0 | 1
|
orderCategory?: 0 | 1,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.getPrivate('/spot/v3/private/open-orders', {
|
return this.getPrivate('/spot/v3/private/open-orders', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -160,7 +164,7 @@ export class SpotClientV3 extends BaseRestClient {
|
|||||||
symbol?: string,
|
symbol?: string,
|
||||||
orderId?: string,
|
orderId?: string,
|
||||||
limit?: number,
|
limit?: number,
|
||||||
orderCategory?: 0 | 1
|
orderCategory?: 0 | 1,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.getPrivate('/spot/v3/private/history-orders', {
|
return this.getPrivate('/spot/v3/private/history-orders', {
|
||||||
symbol,
|
symbol,
|
||||||
@@ -220,7 +224,7 @@ export class SpotClientV3 extends BaseRestClient {
|
|||||||
purchaseLeveragedToken(
|
purchaseLeveragedToken(
|
||||||
ltCode: string,
|
ltCode: string,
|
||||||
ltAmount: string,
|
ltAmount: string,
|
||||||
serialNo?: string
|
serialNo?: string,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate('/spot/v3/private/purchase', {
|
return this.postPrivate('/spot/v3/private/purchase', {
|
||||||
ltCode,
|
ltCode,
|
||||||
@@ -233,7 +237,7 @@ export class SpotClientV3 extends BaseRestClient {
|
|||||||
redeemLeveragedToken(
|
redeemLeveragedToken(
|
||||||
ltCode: string,
|
ltCode: string,
|
||||||
ltAmount: string,
|
ltAmount: string,
|
||||||
serialNo?: string
|
serialNo?: string,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate('/spot/v3/private/redeem', {
|
return this.postPrivate('/spot/v3/private/redeem', {
|
||||||
ltCode,
|
ltCode,
|
||||||
@@ -244,7 +248,7 @@ export class SpotClientV3 extends BaseRestClient {
|
|||||||
|
|
||||||
/** Get leveraged token purchase/redemption history */
|
/** Get leveraged token purchase/redemption history */
|
||||||
getLeveragedTokenPRHistory(
|
getLeveragedTokenPRHistory(
|
||||||
params?: SpotLeveragedTokenPRHistoryRequest
|
params?: SpotLeveragedTokenPRHistoryRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.getPrivate('/spot/v3/private/record', params);
|
return this.getPrivate('/spot/v3/private/record', params);
|
||||||
}
|
}
|
||||||
@@ -258,7 +262,7 @@ export class SpotClientV3 extends BaseRestClient {
|
|||||||
/** Borrow margin loan */
|
/** Borrow margin loan */
|
||||||
borrowCrossMarginLoan(
|
borrowCrossMarginLoan(
|
||||||
coin: string,
|
coin: string,
|
||||||
qty: string
|
qty: string,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate('/spot/v3/private/cross-margin-loan', {
|
return this.postPrivate('/spot/v3/private/cross-margin-loan', {
|
||||||
coin,
|
coin,
|
||||||
@@ -276,7 +280,7 @@ export class SpotClientV3 extends BaseRestClient {
|
|||||||
|
|
||||||
/** Query borrowing info */
|
/** Query borrowing info */
|
||||||
getCrossMarginBorrowingInfo(
|
getCrossMarginBorrowingInfo(
|
||||||
params?: SpotCrossMarginBorrowingInfoRequest
|
params?: SpotCrossMarginBorrowingInfoRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.getPrivate('/spot/v3/private/cross-margin-orders', params);
|
return this.getPrivate('/spot/v3/private/cross-margin-orders', params);
|
||||||
}
|
}
|
||||||
@@ -293,11 +297,11 @@ export class SpotClientV3 extends BaseRestClient {
|
|||||||
|
|
||||||
/** Query repayment history */
|
/** Query repayment history */
|
||||||
getCrossMarginRepaymentHistory(
|
getCrossMarginRepaymentHistory(
|
||||||
params?: SpotCrossMarginRepaymentHistoryRequest
|
params?: SpotCrossMarginRepaymentHistoryRequest,
|
||||||
): Promise<APIResponseV3<any>> {
|
): Promise<APIResponseV3<any>> {
|
||||||
return this.getPrivate(
|
return this.getPrivate(
|
||||||
'/spot/v3/private/cross-margin-repay-history',
|
'/spot/v3/private/cross-margin-repay-history',
|
||||||
params
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,12 +133,12 @@ export interface LinearSetMarginSwitchRequest {
|
|||||||
|
|
||||||
export interface LinearSetPositionModeRequest {
|
export interface LinearSetPositionModeRequest {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
mode: typeof linearPositionModeEnum[keyof typeof linearPositionModeEnum];
|
mode: (typeof linearPositionModeEnum)[keyof typeof linearPositionModeEnum];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LinearSetPositionTpSlModeRequest {
|
export interface LinearSetPositionTpSlModeRequest {
|
||||||
symbol: string;
|
symbol: string;
|
||||||
tp_sl_mode: typeof positionTpSlModeEnum[keyof typeof positionTpSlModeEnum];
|
tp_sl_mode: (typeof positionTpSlModeEnum)[keyof typeof positionTpSlModeEnum];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LinearSetAddReduceMarginRequest {
|
export interface LinearSetAddReduceMarginRequest {
|
||||||
|
|||||||
@@ -293,6 +293,7 @@ export interface RiskLimitV5 {
|
|||||||
section: any;
|
section: any;
|
||||||
isLowestRisk: 0 | 1;
|
isLowestRisk: 0 | 1;
|
||||||
maxLeverage: string;
|
maxLeverage: string;
|
||||||
|
mmDeduction: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @deprecated use DeliveryPriceV5 instead */
|
/** @deprecated use DeliveryPriceV5 instead */
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ export type InstrumentStatusV5 =
|
|||||||
| 'Settling'
|
| 'Settling'
|
||||||
| 'Delivering'
|
| 'Delivering'
|
||||||
| 'Closed';
|
| 'Closed';
|
||||||
|
|
||||||
|
|
||||||
export type MarginTradingV5 = 'none' | 'both' | 'utaOnly' | 'normalSpotOnly';
|
export type MarginTradingV5 = 'none' | 'both' | 'utaOnly' | 'normalSpotOnly';
|
||||||
|
|
||||||
@@ -156,7 +155,7 @@ export type PositionIdx = 0 | 1 | 2;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Position status.
|
* Position status.
|
||||||
*
|
*
|
||||||
* - 'Normal'
|
* - 'Normal'
|
||||||
* - 'Liq' in the liquidation progress
|
* - 'Liq' in the liquidation progress
|
||||||
* - 'Adl' in the auto-deleverage progress
|
* - 'Adl' in the auto-deleverage progress
|
||||||
@@ -175,7 +174,10 @@ export type OptionTypeV5 = 'Call' | 'Put';
|
|||||||
export type TradeModeV5 = 0 | 1;
|
export type TradeModeV5 = 0 | 1;
|
||||||
|
|
||||||
export type TPSLModeV5 = 'Full' | 'Partial';
|
export type TPSLModeV5 = 'Full' | 'Partial';
|
||||||
export type AccountMarginModeV5 = 'ISOLATED_MARGIN' | 'REGULAR_MARGIN' | 'PORTFOLIO_MARGIN';
|
export type AccountMarginModeV5 =
|
||||||
|
| 'ISOLATED_MARGIN'
|
||||||
|
| 'REGULAR_MARGIN'
|
||||||
|
| 'PORTFOLIO_MARGIN';
|
||||||
export type UnifiedUpdateStatusV5 = 'FAIL' | 'PROCESS' | 'SUCCESS';
|
export type UnifiedUpdateStatusV5 = 'FAIL' | 'PROCESS' | 'SUCCESS';
|
||||||
|
|
||||||
export type AccountTypeV5 =
|
export type AccountTypeV5 =
|
||||||
|
|||||||
@@ -60,7 +60,11 @@ export interface WSOrderbookV5 {
|
|||||||
seq: number;
|
seq: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type WSOrderbookEventV5 = WSPublicTopicEventV5<string, 'delta' | 'snapshot', WSOrderbookV5[]>;
|
export type WSOrderbookEventV5 = WSPublicTopicEventV5<
|
||||||
|
string,
|
||||||
|
'delta' | 'snapshot',
|
||||||
|
WSOrderbookV5[]
|
||||||
|
>;
|
||||||
|
|
||||||
export interface WSPositionV5 {
|
export interface WSPositionV5 {
|
||||||
category: string;
|
category: string;
|
||||||
@@ -103,7 +107,10 @@ export interface WSPositionV5 {
|
|||||||
seq: number;
|
seq: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type WSPositionEventV5 = WSPrivateTopicEventV5<'position', WSPositionV5[]>;
|
export type WSPositionEventV5 = WSPrivateTopicEventV5<
|
||||||
|
'position',
|
||||||
|
WSPositionV5[]
|
||||||
|
>;
|
||||||
|
|
||||||
export interface WSAccountOrderV5 {
|
export interface WSAccountOrderV5 {
|
||||||
category: CategoryV5;
|
category: CategoryV5;
|
||||||
@@ -126,6 +133,7 @@ export interface WSAccountOrderV5 {
|
|||||||
cumExecQty: string;
|
cumExecQty: string;
|
||||||
cumExecValue: string;
|
cumExecValue: string;
|
||||||
cumExecFee: string;
|
cumExecFee: string;
|
||||||
|
closedPnl: string;
|
||||||
feeCurrency: string;
|
feeCurrency: string;
|
||||||
timeInForce: OrderTimeInForceV5;
|
timeInForce: OrderTimeInForceV5;
|
||||||
orderType: OrderTypeV5;
|
orderType: OrderTypeV5;
|
||||||
@@ -154,7 +162,10 @@ export interface WSAccountOrderV5 {
|
|||||||
updatedTime: string;
|
updatedTime: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type WSAccountOrderEventV5 = WSPrivateTopicEventV5<'order', WSAccountOrderV5[]>;
|
export type WSAccountOrderEventV5 = WSPrivateTopicEventV5<
|
||||||
|
'order',
|
||||||
|
WSAccountOrderV5[]
|
||||||
|
>;
|
||||||
|
|
||||||
export interface WSExecutionV5 {
|
export interface WSExecutionV5 {
|
||||||
category: CategoryV5;
|
category: CategoryV5;
|
||||||
@@ -189,4 +200,7 @@ export interface WSExecutionV5 {
|
|||||||
marketUnit: string;
|
marketUnit: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type WSExecutionEventV5 = WSPrivateTopicEventV5<'execution', WSExecutionV5[]>;
|
export type WSExecutionEventV5 = WSPrivateTopicEventV5<
|
||||||
|
'execution',
|
||||||
|
WSExecutionV5[]
|
||||||
|
>;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable max-len */
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import {
|
import {
|
||||||
APIResponseV3,
|
APIResponseV3,
|
||||||
@@ -36,6 +37,10 @@ import BaseRestClient from './util/BaseRestClient';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* REST API client for Derivatives V3 unified margin APIs
|
* REST API client for Derivatives V3 unified margin APIs
|
||||||
|
* @deprecated WARNING
|
||||||
|
* These endpoints are being switched off gradually and are expected to be completely turned off by the end of 2024.
|
||||||
|
* They may stop working at any point before then.
|
||||||
|
* Please update your code as soon as possible to use the V5 APIs instead.
|
||||||
*/
|
*/
|
||||||
export class UnifiedMarginClient extends BaseRestClient {
|
export class UnifiedMarginClient extends BaseRestClient {
|
||||||
getClientType() {
|
getClientType() {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable max-len */
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import {
|
import {
|
||||||
APIResponseV3,
|
APIResponseV3,
|
||||||
@@ -133,7 +134,10 @@ export class USDCPerpetualClient extends BaseRestClient {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Active order parameters (such as quantity, price) and stop order parameters cannot be modified in one request at the same time. Please request modification separately. */
|
/**
|
||||||
|
* Active order parameters (such as quantity, price) and stop order parameters cannot be modified in one request at the same time.
|
||||||
|
* Please request modification separately.
|
||||||
|
*/
|
||||||
modifyOrder(params: USDCPerpModifyOrderRequest): Promise<APIResponseV3<any>> {
|
modifyOrder(params: USDCPerpModifyOrderRequest): Promise<APIResponseV3<any>> {
|
||||||
return this.postPrivate(
|
return this.postPrivate(
|
||||||
'/perpetual/usdc/openapi/private/v1/replace-order',
|
'/perpetual/usdc/openapi/private/v1/replace-order',
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export default class WsStore {
|
|||||||
if (this.hasExistingActiveConnection(key)) {
|
if (this.hasExistingActiveConnection(key)) {
|
||||||
this.logger.warning(
|
this.logger.warning(
|
||||||
'WsStore setConnection() overwriting existing open connection: ',
|
'WsStore setConnection() overwriting existing open connection: ',
|
||||||
this.getWs(key)
|
this.getWs(key),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.wsState[key] = {
|
this.wsState[key] = {
|
||||||
@@ -86,7 +86,7 @@ export default class WsStore {
|
|||||||
const ws = this.getWs(key);
|
const ws = this.getWs(key);
|
||||||
this.logger.warning(
|
this.logger.warning(
|
||||||
'WsStore deleting state for connection still open: ',
|
'WsStore deleting state for connection still open: ',
|
||||||
ws
|
ws,
|
||||||
);
|
);
|
||||||
ws?.close();
|
ws?.close();
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ export default class WsStore {
|
|||||||
if (this.isWsOpen(key)) {
|
if (this.isWsOpen(key)) {
|
||||||
this.logger.warning(
|
this.logger.warning(
|
||||||
'WsStore setConnection() overwriting existing open connection: ',
|
'WsStore setConnection() overwriting existing open connection: ',
|
||||||
this.getWs(key)
|
this.getWs(key),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.get(key, true)!.ws = wsConnection;
|
this.get(key, true)!.ws = wsConnection;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export async function signMessage(
|
export async function signMessage(
|
||||||
message: string,
|
message: string,
|
||||||
secret: string
|
secret: string,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
@@ -9,21 +9,21 @@ export async function signMessage(
|
|||||||
encoder.encode(secret),
|
encoder.encode(secret),
|
||||||
{ name: 'HMAC', hash: { name: 'SHA-256' } },
|
{ name: 'HMAC', hash: { name: 'SHA-256' } },
|
||||||
false,
|
false,
|
||||||
['sign']
|
['sign'],
|
||||||
);
|
);
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
const signature = await window.crypto.subtle.sign(
|
const signature = await window.crypto.subtle.sign(
|
||||||
'HMAC',
|
'HMAC',
|
||||||
key,
|
key,
|
||||||
encoder.encode(message)
|
encoder.encode(message),
|
||||||
);
|
);
|
||||||
|
|
||||||
return Array.prototype.map
|
return Array.prototype.map
|
||||||
.call(
|
.call(
|
||||||
new Uint8Array(signature),
|
new Uint8Array(signature),
|
||||||
(x: { toString: (arg0: number) => string }) =>
|
(x: { toString: (arg0: number) => string }) =>
|
||||||
('00' + x.toString(16)).slice(-2)
|
('00' + x.toString(16)).slice(-2),
|
||||||
)
|
)
|
||||||
.join('');
|
.join('');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { createHmac } from 'crypto';
|
|||||||
/** This is async because the browser version uses a promise (browser-support) */
|
/** This is async because the browser version uses a promise (browser-support) */
|
||||||
export async function signMessage(
|
export async function signMessage(
|
||||||
message: string,
|
message: string,
|
||||||
secret: string
|
secret: string,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
return createHmac('sha256', secret).update(message).digest('hex');
|
return createHmac('sha256', secret).update(message).digest('hex');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,12 @@
|
|||||||
* Use type guards to narrow down types with minimal efforts.
|
* Use type guards to narrow down types with minimal efforts.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { WSAccountOrderEventV5, WSExecutionEventV5, WSOrderbookEventV5, WSPositionEventV5 } from '../types/websocket.events';
|
import {
|
||||||
|
WSAccountOrderEventV5,
|
||||||
|
WSExecutionEventV5,
|
||||||
|
WSOrderbookEventV5,
|
||||||
|
WSPositionEventV5,
|
||||||
|
} from '../types/websocket.events';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type guard to detect a V5 orderbook event (delta & snapshots)
|
* Type guard to detect a V5 orderbook event (delta & snapshots)
|
||||||
@@ -30,7 +35,7 @@ export function isWsOrderbookEventV5(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Type guard to detect a V5 position event.
|
* Type guard to detect a V5 position event.
|
||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
@@ -86,4 +91,4 @@ export function isWsExecutionEventV5(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return event['topic'] === 'execution';
|
return event['topic'] === 'execution';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,18 +4,12 @@
|
|||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import WebSocket from 'isomorphic-ws';
|
import WebSocket from 'isomorphic-ws';
|
||||||
|
|
||||||
|
import { ContractClient } from './contract-client';
|
||||||
import { InverseClient } from './inverse-client';
|
import { InverseClient } from './inverse-client';
|
||||||
import { LinearClient } from './linear-client';
|
import { LinearClient } from './linear-client';
|
||||||
import { SpotClientV3 } from './spot-client-v3';
|
import { RestClientV5 } from './rest-client-v5';
|
||||||
import { SpotClient } from './spot-client';
|
import { SpotClient } from './spot-client';
|
||||||
import { USDCOptionClient } from './usdc-option-client';
|
import { SpotClientV3 } from './spot-client-v3';
|
||||||
import { USDCPerpetualClient } from './usdc-perpetual-client';
|
|
||||||
import { UnifiedMarginClient } from './unified-margin-client';
|
|
||||||
import { ContractClient } from './contract-client';
|
|
||||||
|
|
||||||
import { signMessage } from './util/node-support';
|
|
||||||
import WsStore from './util/WsStore';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
APIMarket,
|
APIMarket,
|
||||||
CategoryV5,
|
CategoryV5,
|
||||||
@@ -26,7 +20,10 @@ import {
|
|||||||
WsKey,
|
WsKey,
|
||||||
WsTopic,
|
WsTopic,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
import { WebsocketTopicSubscriptionConfirmationEvent } from './types/ws-events/topic-subscription-confirmation';
|
||||||
|
import { UnifiedMarginClient } from './unified-margin-client';
|
||||||
|
import { USDCOptionClient } from './usdc-option-client';
|
||||||
|
import { USDCPerpetualClient } from './usdc-perpetual-client';
|
||||||
import {
|
import {
|
||||||
DefaultLogger,
|
DefaultLogger,
|
||||||
PUBLIC_WS_KEYS,
|
PUBLIC_WS_KEYS,
|
||||||
@@ -44,8 +41,8 @@ import {
|
|||||||
safeTerminateWs,
|
safeTerminateWs,
|
||||||
serializeParams,
|
serializeParams,
|
||||||
} from './util';
|
} from './util';
|
||||||
import { RestClientV5 } from './rest-client-v5';
|
import { signMessage } from './util/node-support';
|
||||||
import { WebsocketTopicSubscriptionConfirmationEvent } from './types/ws-events/topic-subscription-confirmation';
|
import WsStore from './util/WsStore';
|
||||||
|
|
||||||
const loggerCategory = { category: 'bybit-ws' };
|
const loggerCategory = { category: 'bybit-ws' };
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export function successEmptyResponseObjectV3() {
|
|||||||
export function errorResponseObject(
|
export function errorResponseObject(
|
||||||
result: null | any = null,
|
result: null | any = null,
|
||||||
ret_code: number,
|
ret_code: number,
|
||||||
ret_msg: string
|
ret_msg: string,
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
result,
|
result,
|
||||||
@@ -58,7 +58,7 @@ export function errorResponseObject(
|
|||||||
|
|
||||||
export function errorResponseObjectV3(
|
export function errorResponseObjectV3(
|
||||||
result: null | any = null,
|
result: null | any = null,
|
||||||
retCode: number
|
retCode: number,
|
||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
result,
|
result,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { API_ERROR_CODE, RestClientV5 } from '../../src';
|
import { API_ERROR_CODE, RestClientV5 } from '../../src';
|
||||||
import { successResponseObjectV3 } from '../response.util';
|
|
||||||
import { getTestProxy } from '../proxy.util';
|
import { getTestProxy } from '../proxy.util';
|
||||||
|
import { successResponseObjectV3 } from '../response.util';
|
||||||
|
|
||||||
describe('Private READ V5 REST API Endpoints', () => {
|
describe('Private READ V5 REST API Endpoints', () => {
|
||||||
const API_KEY = process.env.API_KEY_COM;
|
const API_KEY = process.env.API_KEY_COM;
|
||||||
@@ -22,6 +22,7 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
|
|
||||||
const settleCoin = 'USDT';
|
const settleCoin = 'USDT';
|
||||||
const linearSymbol = 'BTCUSDT';
|
const linearSymbol = 'BTCUSDT';
|
||||||
|
const accountType = 'UNIFIED';
|
||||||
|
|
||||||
describe('misc endpoints', () => {
|
describe('misc endpoints', () => {
|
||||||
it('fetchServerTime()', async () => {
|
it('fetchServerTime()', async () => {
|
||||||
@@ -84,21 +85,19 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
describe('Account APIs', () => {
|
describe('Account APIs', () => {
|
||||||
it('getWalletBalance()', async () => {
|
it('getWalletBalance()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.getWalletBalance({ accountType: 'CONTRACT' }),
|
await api.getWalletBalance({ accountType: accountType }),
|
||||||
).toMatchObject({ ...successResponseObjectV3() });
|
).toMatchObject({ ...successResponseObjectV3() });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getBorrowHistory()', async () => {
|
it('getBorrowHistory()', async () => {
|
||||||
expect(await api.getBorrowHistory()).toMatchObject({
|
expect(await api.getBorrowHistory()).toMatchObject({
|
||||||
...successResponseObjectV3(),
|
...successResponseObjectV3(),
|
||||||
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getCollateralInfo()', async () => {
|
it('getCollateralInfo()', async () => {
|
||||||
expect(await api.getCollateralInfo()).toMatchObject({
|
expect(await api.getCollateralInfo()).toMatchObject({
|
||||||
...successResponseObjectV3(),
|
...successResponseObjectV3(),
|
||||||
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -127,7 +126,7 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
it('getTransactionLog()', async () => {
|
it('getTransactionLog()', async () => {
|
||||||
expect(await api.getTransactionLog()).toMatchObject({
|
expect(await api.getTransactionLog()).toMatchObject({
|
||||||
...successResponseObjectV3(),
|
...successResponseObjectV3(),
|
||||||
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
|
// retMsg: '',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -151,7 +150,7 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
expect(await api.getDeliveryRecord({ category: 'option' })).toMatchObject(
|
expect(await api.getDeliveryRecord({ category: 'option' })).toMatchObject(
|
||||||
{
|
{
|
||||||
...successResponseObjectV3(),
|
...successResponseObjectV3(),
|
||||||
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
|
// retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -161,7 +160,7 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
await api.getSettlementRecords({ category: 'linear' }),
|
await api.getSettlementRecords({ category: 'linear' }),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
...successResponseObjectV3(),
|
...successResponseObjectV3(),
|
||||||
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
|
// retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -173,13 +172,19 @@ describe('Private READ V5 REST API Endpoints', () => {
|
|||||||
|
|
||||||
it('getAllCoinsBalance()', async () => {
|
it('getAllCoinsBalance()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.getAllCoinsBalance({ accountType: 'SPOT' }),
|
await api.getAllCoinsBalance({ accountType: accountType }),
|
||||||
).toMatchObject({ ...successResponseObjectV3() });
|
).toMatchObject({
|
||||||
|
...successResponseObjectV3(),
|
||||||
|
// retMsg: '',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getCoinBalance()', async () => {
|
it('getCoinBalance()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.getCoinBalance({ accountType: 'SPOT', coin: settleCoin }),
|
await api.getCoinBalance({
|
||||||
|
accountType: accountType,
|
||||||
|
coin: settleCoin,
|
||||||
|
}),
|
||||||
).toMatchObject({ ...successResponseObjectV3() });
|
).toMatchObject({ ...successResponseObjectV3() });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -199,7 +199,8 @@ describe('Private WRITE V5 REST API Endpoints', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('switchIsolatedMargin()', async () => {
|
// Not compatible with account mode
|
||||||
|
it.skip('switchIsolatedMargin()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.switchIsolatedMargin({
|
await api.switchIsolatedMargin({
|
||||||
category: 'linear',
|
category: 'linear',
|
||||||
@@ -211,7 +212,7 @@ describe('Private WRITE V5 REST API Endpoints', () => {
|
|||||||
}),
|
}),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
// ...successResponseObjectV3(),
|
// ...successResponseObjectV3(),
|
||||||
// retMsg: '',
|
retMsg: '',
|
||||||
retCode: API_ERROR_CODE.V5_CROSS_ISOLATED_MARGIN_NOT_CHANGED,
|
retCode: API_ERROR_CODE.V5_CROSS_ISOLATED_MARGIN_NOT_CHANGED,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -275,7 +276,8 @@ describe('Private WRITE V5 REST API Endpoints', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('setAutoAddMargin()', async () => {
|
// Not compatible with account mode
|
||||||
|
it.skip('setAutoAddMargin()', async () => {
|
||||||
expect(
|
expect(
|
||||||
await api.setAutoAddMargin({
|
await api.setAutoAddMargin({
|
||||||
category: 'linear',
|
category: 'linear',
|
||||||
@@ -284,8 +286,8 @@ describe('Private WRITE V5 REST API Endpoints', () => {
|
|||||||
positionIdx: 0,
|
positionIdx: 0,
|
||||||
}),
|
}),
|
||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
// ...successResponseObjectV3(),
|
...successResponseObjectV3(),
|
||||||
// retMsg: '',
|
retMsg: '',
|
||||||
retCode: API_ERROR_CODE.V5_AUTO_ADD_MARGIN_NOT_CHANGED,
|
retCode: API_ERROR_CODE.V5_AUTO_ADD_MARGIN_NOT_CHANGED,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -294,9 +296,9 @@ describe('Private WRITE V5 REST API Endpoints', () => {
|
|||||||
describe('Account APIs', () => {
|
describe('Account APIs', () => {
|
||||||
it('setMarginMode()', async () => {
|
it('setMarginMode()', async () => {
|
||||||
expect(await api.setMarginMode('REGULAR_MARGIN')).toMatchObject({
|
expect(await api.setMarginMode('REGULAR_MARGIN')).toMatchObject({
|
||||||
// ...successResponseObjectV3(),
|
...successResponseObjectV3(),
|
||||||
// retMsg: '',
|
// retMsg: '',
|
||||||
retCode: API_ERROR_CODE.V5_MARGIN_MODE_NOT_CHANGED,
|
// retCode: API_ERROR_CODE.V5_MARGIN_MODE_NOT_CHANGED,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -468,17 +470,17 @@ describe('Private WRITE V5 REST API Endpoints', () => {
|
|||||||
describe('Spot Margin APIs', () => {
|
describe('Spot Margin APIs', () => {
|
||||||
it('toggleSpotMarginTrade()', async () => {
|
it('toggleSpotMarginTrade()', async () => {
|
||||||
expect(await api.toggleSpotMarginTrade('1')).toMatchObject({
|
expect(await api.toggleSpotMarginTrade('1')).toMatchObject({
|
||||||
// ...successResponseObjectV3(),
|
...successResponseObjectV3(),
|
||||||
// retMsg: '',
|
// retMsg: '',
|
||||||
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
|
// retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('setSpotMarginLeverage()', async () => {
|
it('setSpotMarginLeverage()', async () => {
|
||||||
expect(await api.setSpotMarginLeverage('2')).toMatchObject({
|
expect(await api.setSpotMarginLeverage('2')).toMatchObject({
|
||||||
// ...successResponseObjectV3(),
|
...successResponseObjectV3(),
|
||||||
// retMsg: '',
|
// retMsg: '',
|
||||||
retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
|
// retCode: API_ERROR_CODE.INCORRECT_API_KEY_PERMISSIONS,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
16
tsconfig.linting.json
Normal file
16
tsconfig.linting.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "esnext",
|
||||||
|
"rootDir": "../",
|
||||||
|
"allowJs": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*.*",
|
||||||
|
"test/**/*.*",
|
||||||
|
"examples/**/*.*",
|
||||||
|
".eslintrc.cjs",
|
||||||
|
"jest.config.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user