@yuants/vendor-binance 0.14.4 → 0.14.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/client.js +32 -28
- package/dist/api/client.js.map +1 -1
- package/dist/api/private-api.js +82 -82
- package/dist/api/private-api.js.map +1 -1
- package/dist/api/public-api.js +26 -26
- package/dist/api/public-api.js.map +1 -1
- package/lib/api/client.d.ts +4 -1
- package/lib/api/client.d.ts.map +1 -1
- package/lib/api/client.js +32 -27
- package/lib/api/client.js.map +1 -1
- package/lib/api/private-api.d.ts.map +1 -1
- package/lib/api/private-api.js +81 -81
- package/lib/api/private-api.js.map +1 -1
- package/lib/api/public-api.d.ts.map +1 -1
- package/lib/api/public-api.js +25 -25
- package/lib/api/public-api.js.map +1 -1
- package/package.json +6 -6
- package/temp/build/typescript/ts_tQj2bmGB.json +1 -1
- package/temp/package-deps.json +8 -8
- package/temp/test/jest/haste-map-f37bc94525b36254e573de220443d250-dc922b21f2d35e7315abf4c3159e25a5-63b40dbcff306581344a73f9073894a1 +0 -0
package/dist/api/private-api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { scopeError, tokenBucket } from '@yuants/utils';
|
|
2
|
-
import { buildTokenBucketKey, createRequestContext, getDefaultCredential, requestPrivate, } from './client';
|
|
2
|
+
import { buildTokenBucketKey, createRequestContext, getDefaultCredential, getTokenBucketOptions, requestPrivate, } from './client';
|
|
3
3
|
/**
|
|
4
4
|
* 查询账户信息(USER_DATA)
|
|
5
5
|
*
|
|
@@ -9,13 +9,13 @@ import { buildTokenBucketKey, createRequestContext, getDefaultCredential, reques
|
|
|
9
9
|
*
|
|
10
10
|
* https://developers.binance.com/docs/zh-CN/derivatives/portfolio-margin/account/Account-Information
|
|
11
11
|
*/
|
|
12
|
-
export const getUnifiedAccountInfo = (credential) => {
|
|
12
|
+
export const getUnifiedAccountInfo = async (credential) => {
|
|
13
13
|
const endpoint = 'https://papi.binance.com/papi/v1/account';
|
|
14
14
|
const url = new URL(endpoint);
|
|
15
15
|
const weight = 20;
|
|
16
|
-
const requestContext = createRequestContext();
|
|
16
|
+
const requestContext = await createRequestContext();
|
|
17
17
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
18
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
18
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions('order/unified/minute')).acquireSync(weight));
|
|
19
19
|
return requestPrivate(credential, 'GET', endpoint, undefined, requestContext);
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
@@ -27,13 +27,13 @@ export const getUnifiedAccountInfo = (credential) => {
|
|
|
27
27
|
*
|
|
28
28
|
* https://developers.binance.com/docs/zh-CN/derivatives/portfolio-margin/account/Get-UM-Account-Detail
|
|
29
29
|
*/
|
|
30
|
-
export const getUnifiedUmAccount = (credential) => {
|
|
30
|
+
export const getUnifiedUmAccount = async (credential) => {
|
|
31
31
|
const endpoint = 'https://papi.binance.com/papi/v1/um/account';
|
|
32
32
|
const url = new URL(endpoint);
|
|
33
33
|
const weight = 5;
|
|
34
|
-
const requestContext = createRequestContext();
|
|
34
|
+
const requestContext = await createRequestContext();
|
|
35
35
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
36
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
36
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions('order/unified/minute')).acquireSync(weight));
|
|
37
37
|
return requestPrivate(credential, 'GET', endpoint, undefined, requestContext);
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
@@ -45,11 +45,11 @@ export const getUnifiedUmAccount = (credential) => {
|
|
|
45
45
|
*
|
|
46
46
|
* https://developers.binance.com/docs/zh-CN/derivatives/portfolio-margin/trade/Query-All-Current-UM-Open-Orders
|
|
47
47
|
*/
|
|
48
|
-
export const getUnifiedUmOpenOrders = (credential, params) => {
|
|
48
|
+
export const getUnifiedUmOpenOrders = async (credential, params) => {
|
|
49
49
|
const endpoint = 'https://papi.binance.com/papi/v1/um/openOrders';
|
|
50
50
|
const url = new URL(endpoint);
|
|
51
51
|
const weight = (params === null || params === void 0 ? void 0 : params.symbol) ? 1 : 40;
|
|
52
|
-
const requestContext = createRequestContext();
|
|
52
|
+
const requestContext = await createRequestContext();
|
|
53
53
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
54
54
|
scopeError('BINANCE_API_RATE_LIMIT', {
|
|
55
55
|
method: 'GET',
|
|
@@ -59,7 +59,7 @@ export const getUnifiedUmOpenOrders = (credential, params) => {
|
|
|
59
59
|
bucketId: bucketKey,
|
|
60
60
|
weight,
|
|
61
61
|
hasSymbol: !!(params === null || params === void 0 ? void 0 : params.symbol),
|
|
62
|
-
}, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
62
|
+
}, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
63
63
|
return requestPrivate(credential, 'GET', endpoint, params, requestContext);
|
|
64
64
|
};
|
|
65
65
|
/**
|
|
@@ -71,13 +71,13 @@ export const getUnifiedUmOpenOrders = (credential, params) => {
|
|
|
71
71
|
*
|
|
72
72
|
* https://developers.binance.com/docs/zh-CN/derivatives/portfolio-margin/account/Account-Balance
|
|
73
73
|
*/
|
|
74
|
-
export const getUnifiedAccountBalance = (credential, params) => {
|
|
74
|
+
export const getUnifiedAccountBalance = async (credential, params) => {
|
|
75
75
|
const endpoint = 'https://papi.binance.com/papi/v1/balance';
|
|
76
76
|
const url = new URL(endpoint);
|
|
77
77
|
const weight = 20;
|
|
78
|
-
const requestContext = createRequestContext();
|
|
78
|
+
const requestContext = await createRequestContext();
|
|
79
79
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
80
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
80
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
81
81
|
return requestPrivate(credential, 'GET', endpoint, params, requestContext);
|
|
82
82
|
};
|
|
83
83
|
/**
|
|
@@ -87,13 +87,13 @@ export const getUnifiedAccountBalance = (credential, params) => {
|
|
|
87
87
|
*
|
|
88
88
|
* https://developers.binance.com/docs/zh-CN/binance-spot-api-docs/rest-api#%E8%B4%A6%E6%88%B7%E4%BF%A1%E6%81%AF-user_data
|
|
89
89
|
*/
|
|
90
|
-
export const getSpotAccountInfo = (credential, params) => {
|
|
90
|
+
export const getSpotAccountInfo = async (credential, params) => {
|
|
91
91
|
const endpoint = 'https://api.binance.com/api/v3/account';
|
|
92
92
|
const url = new URL(endpoint);
|
|
93
93
|
const weight = 20;
|
|
94
|
-
const requestContext = createRequestContext();
|
|
94
|
+
const requestContext = await createRequestContext();
|
|
95
95
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
96
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
96
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
97
97
|
return requestPrivate(credential, 'GET', endpoint, params, requestContext);
|
|
98
98
|
};
|
|
99
99
|
/**
|
|
@@ -103,11 +103,11 @@ export const getSpotAccountInfo = (credential, params) => {
|
|
|
103
103
|
*
|
|
104
104
|
* https://developers.binance.com/docs/zh-CN/binance-spot-api-docs/rest-api/account-endpoints#%E6%9F%A5%E7%9C%8B%E8%B4%A6%E6%88%B7%E5%BD%93%E5%89%8D%E6%8C%82%E5%8D%95-user_data
|
|
105
105
|
*/
|
|
106
|
-
export const getSpotOpenOrders = (credential, params) => {
|
|
106
|
+
export const getSpotOpenOrders = async (credential, params) => {
|
|
107
107
|
const endpoint = 'https://api.binance.com/api/v3/openOrders';
|
|
108
108
|
const url = new URL(endpoint);
|
|
109
109
|
const weight = (params === null || params === void 0 ? void 0 : params.symbol) ? 6 : 80;
|
|
110
|
-
const requestContext = createRequestContext();
|
|
110
|
+
const requestContext = await createRequestContext();
|
|
111
111
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
112
112
|
scopeError('BINANCE_API_RATE_LIMIT', {
|
|
113
113
|
method: 'GET',
|
|
@@ -117,7 +117,7 @@ export const getSpotOpenOrders = (credential, params) => {
|
|
|
117
117
|
bucketId: bucketKey,
|
|
118
118
|
weight,
|
|
119
119
|
hasSymbol: !!(params === null || params === void 0 ? void 0 : params.symbol),
|
|
120
|
-
}, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
120
|
+
}, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
121
121
|
return requestPrivate(credential, 'GET', endpoint, params, requestContext);
|
|
122
122
|
};
|
|
123
123
|
/**
|
|
@@ -127,13 +127,13 @@ export const getSpotOpenOrders = (credential, params) => {
|
|
|
127
127
|
*
|
|
128
128
|
* https://developers.binance.com/docs/zh-CN/binance-spot-api-docs/rest-api/trading-endpoints#%E4%B8%8B%E5%8D%95-trade
|
|
129
129
|
*/
|
|
130
|
-
export const postSpotOrder = (credential, params) => {
|
|
130
|
+
export const postSpotOrder = async (credential, params) => {
|
|
131
131
|
const endpoint = 'https://api.binance.com/api/v3/order';
|
|
132
132
|
const url = new URL(endpoint);
|
|
133
133
|
const weight = 1;
|
|
134
|
-
const requestContext = createRequestContext();
|
|
134
|
+
const requestContext = await createRequestContext();
|
|
135
135
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
136
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
136
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
137
137
|
return requestPrivate(credential, 'POST', endpoint, params, requestContext);
|
|
138
138
|
};
|
|
139
139
|
/**
|
|
@@ -143,13 +143,13 @@ export const postSpotOrder = (credential, params) => {
|
|
|
143
143
|
*
|
|
144
144
|
* https://developers.binance.com/docs/zh-CN/binance-spot-api-docs/rest-api/trading-endpoints#%E6%92%A4%E9%94%80%E8%AE%A2%E5%8D%95-trade
|
|
145
145
|
*/
|
|
146
|
-
export const deleteSpotOrder = (credential, params) => {
|
|
146
|
+
export const deleteSpotOrder = async (credential, params) => {
|
|
147
147
|
const endpoint = 'https://api.binance.com/api/v3/order';
|
|
148
148
|
const url = new URL(endpoint);
|
|
149
149
|
const weight = 1;
|
|
150
|
-
const requestContext = createRequestContext();
|
|
150
|
+
const requestContext = await createRequestContext();
|
|
151
151
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
152
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'DELETE', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
152
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'DELETE', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
153
153
|
return requestPrivate(credential, 'DELETE', endpoint, params, requestContext);
|
|
154
154
|
};
|
|
155
155
|
/**
|
|
@@ -163,13 +163,13 @@ export const deleteSpotOrder = (credential, params) => {
|
|
|
163
163
|
*
|
|
164
164
|
* https://developers.binance.com/docs/zh-CN/wallet/asset/user-universal-transfer
|
|
165
165
|
*/
|
|
166
|
-
export const postAssetTransfer = (credential, params) => {
|
|
166
|
+
export const postAssetTransfer = async (credential, params) => {
|
|
167
167
|
const endpoint = 'https://api.binance.com/sapi/v1/asset/transfer';
|
|
168
168
|
const url = new URL(endpoint);
|
|
169
169
|
const weight = 900;
|
|
170
|
-
const requestContext = createRequestContext();
|
|
170
|
+
const requestContext = await createRequestContext();
|
|
171
171
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
172
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
172
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
173
173
|
return requestPrivate(credential, 'POST', endpoint, params, requestContext);
|
|
174
174
|
};
|
|
175
175
|
/**
|
|
@@ -183,13 +183,13 @@ export const postAssetTransfer = (credential, params) => {
|
|
|
183
183
|
*
|
|
184
184
|
* ISSUE(2024-07-18): 目前这是唯一能够将资金从原 U 本位合约账户转入统一账户的接口。
|
|
185
185
|
*/
|
|
186
|
-
export const postUnifiedAccountAutoCollection = (credential) => {
|
|
186
|
+
export const postUnifiedAccountAutoCollection = async (credential) => {
|
|
187
187
|
const endpoint = 'https://papi.binance.com/papi/v1/auto-collection';
|
|
188
188
|
const url = new URL(endpoint);
|
|
189
189
|
const weight = 750;
|
|
190
|
-
const requestContext = createRequestContext();
|
|
190
|
+
const requestContext = await createRequestContext();
|
|
191
191
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
192
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
192
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
193
193
|
return requestPrivate(credential, 'POST', endpoint, undefined, requestContext);
|
|
194
194
|
};
|
|
195
195
|
/**
|
|
@@ -201,13 +201,13 @@ export const postUnifiedAccountAutoCollection = (credential) => {
|
|
|
201
201
|
*
|
|
202
202
|
* https://developers.binance.com/docs/zh-CN/wallet/capital/deposite-address
|
|
203
203
|
*/
|
|
204
|
-
export const getDepositAddress = (credential, params) => {
|
|
204
|
+
export const getDepositAddress = async (credential, params) => {
|
|
205
205
|
const endpoint = 'https://api.binance.com/sapi/v1/capital/deposit/address';
|
|
206
206
|
const url = new URL(endpoint);
|
|
207
207
|
const weight = 10;
|
|
208
|
-
const requestContext = createRequestContext();
|
|
208
|
+
const requestContext = await createRequestContext();
|
|
209
209
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
210
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
210
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
211
211
|
return requestPrivate(credential, 'GET', endpoint, params, requestContext);
|
|
212
212
|
};
|
|
213
213
|
/**
|
|
@@ -217,13 +217,13 @@ export const getDepositAddress = (credential, params) => {
|
|
|
217
217
|
*
|
|
218
218
|
* https://developers.binance.com/docs/zh-CN/sub_account/account-management/Query-Sub-account-List
|
|
219
219
|
*/
|
|
220
|
-
export const getSubAccountList = (credential, params) => {
|
|
220
|
+
export const getSubAccountList = async (credential, params) => {
|
|
221
221
|
const endpoint = 'https://api.binance.com/sapi/v1/sub-account/list';
|
|
222
222
|
const url = new URL(endpoint);
|
|
223
223
|
const weight = 1;
|
|
224
|
-
const requestContext = createRequestContext();
|
|
224
|
+
const requestContext = await createRequestContext();
|
|
225
225
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
226
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
226
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
227
227
|
return requestPrivate(credential, 'GET', endpoint, params, requestContext);
|
|
228
228
|
};
|
|
229
229
|
/**
|
|
@@ -233,13 +233,13 @@ export const getSubAccountList = (credential, params) => {
|
|
|
233
233
|
*
|
|
234
234
|
* https://developers.binance.com/docs/zh-CN/wallet/capital/withdraw
|
|
235
235
|
*/
|
|
236
|
-
export const postWithdraw = (credential, params) => {
|
|
236
|
+
export const postWithdraw = async (credential, params) => {
|
|
237
237
|
const endpoint = 'https://api.binance.com/sapi/v1/capital/withdraw/apply';
|
|
238
238
|
const url = new URL(endpoint);
|
|
239
239
|
const weight = 600;
|
|
240
|
-
const requestContext = createRequestContext();
|
|
240
|
+
const requestContext = await createRequestContext();
|
|
241
241
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
242
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
242
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
243
243
|
return requestPrivate(credential, 'POST', endpoint, params, requestContext);
|
|
244
244
|
};
|
|
245
245
|
/**
|
|
@@ -254,13 +254,13 @@ export const postWithdraw = (credential, params) => {
|
|
|
254
254
|
*
|
|
255
255
|
* https://developers.binance.com/docs/zh-CN/wallet/capital/withdraw-history
|
|
256
256
|
*/
|
|
257
|
-
export const getWithdrawHistory = (credential, params) => {
|
|
257
|
+
export const getWithdrawHistory = async (credential, params) => {
|
|
258
258
|
const endpoint = 'https://api.binance.com/sapi/v1/capital/withdraw/history';
|
|
259
259
|
const url = new URL(endpoint);
|
|
260
260
|
const weight = 1;
|
|
261
|
-
const requestContext = createRequestContext();
|
|
261
|
+
const requestContext = await createRequestContext();
|
|
262
262
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
263
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
263
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
264
264
|
return requestPrivate(credential, 'GET', endpoint, params, requestContext);
|
|
265
265
|
};
|
|
266
266
|
/**
|
|
@@ -270,13 +270,13 @@ export const getWithdrawHistory = (credential, params) => {
|
|
|
270
270
|
*
|
|
271
271
|
* https://developers.binance.com/docs/zh-CN/wallet/capital/deposite-history
|
|
272
272
|
*/
|
|
273
|
-
export const getDepositHistory = (credential, params) => {
|
|
273
|
+
export const getDepositHistory = async (credential, params) => {
|
|
274
274
|
const endpoint = 'https://api.binance.com/sapi/v1/capital/deposit/hisrec';
|
|
275
275
|
const url = new URL(endpoint);
|
|
276
276
|
const weight = 1;
|
|
277
|
-
const requestContext = createRequestContext();
|
|
277
|
+
const requestContext = await createRequestContext();
|
|
278
278
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
279
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
279
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
280
280
|
return requestPrivate(credential, 'GET', endpoint, params, requestContext);
|
|
281
281
|
};
|
|
282
282
|
/**
|
|
@@ -286,22 +286,22 @@ export const getDepositHistory = (credential, params) => {
|
|
|
286
286
|
*
|
|
287
287
|
* https://developers.binance.com/docs/zh-CN/derivatives/portfolio-margin/trade/New-UM-Order
|
|
288
288
|
*/
|
|
289
|
-
export const postUmOrder = (credential, params) => {
|
|
289
|
+
export const postUmOrder = async (credential, params) => {
|
|
290
290
|
const endpoint = 'https://papi.binance.com/papi/v1/um/order';
|
|
291
291
|
const url = new URL(endpoint);
|
|
292
292
|
const weight = 1;
|
|
293
|
-
const requestContext = createRequestContext();
|
|
293
|
+
const requestContext = await createRequestContext();
|
|
294
294
|
const bucketKey = buildTokenBucketKey('order/unified/minute', requestContext.ip);
|
|
295
|
-
scopeError('BINANCE_UNIFIED_ORDER_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
295
|
+
scopeError('BINANCE_UNIFIED_ORDER_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
296
296
|
return requestPrivate(credential, 'POST', endpoint, params, requestContext);
|
|
297
297
|
};
|
|
298
|
-
export const deleteUmOrder = (credential, params) => {
|
|
298
|
+
export const deleteUmOrder = async (credential, params) => {
|
|
299
299
|
const endpoint = 'https://papi.binance.com/papi/v1/um/order';
|
|
300
300
|
const url = new URL(endpoint);
|
|
301
301
|
const weight = 1;
|
|
302
|
-
const requestContext = createRequestContext();
|
|
302
|
+
const requestContext = await createRequestContext();
|
|
303
303
|
const bucketKey = buildTokenBucketKey('order/unified/minute', requestContext.ip);
|
|
304
|
-
scopeError('BINANCE_UNIFIED_ORDER_API_RATE_LIMIT', { method: 'DELETE', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
304
|
+
scopeError('BINANCE_UNIFIED_ORDER_API_RATE_LIMIT', { method: 'DELETE', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
305
305
|
return requestPrivate(credential, 'DELETE', endpoint, params, requestContext);
|
|
306
306
|
};
|
|
307
307
|
/**
|
|
@@ -311,13 +311,13 @@ export const deleteUmOrder = (credential, params) => {
|
|
|
311
311
|
*
|
|
312
312
|
* https://developers.binance.com/docs/zh-CN/derivatives/portfolio-margin/account/Get-UM-Income-History
|
|
313
313
|
*/
|
|
314
|
-
export const getUMIncome = (credential, params) => {
|
|
314
|
+
export const getUMIncome = async (credential, params) => {
|
|
315
315
|
const endpoint = 'https://papi.binance.com/papi/v1/um/income';
|
|
316
316
|
const url = new URL(endpoint);
|
|
317
317
|
const weight = 30;
|
|
318
|
-
const requestContext = createRequestContext();
|
|
318
|
+
const requestContext = await createRequestContext();
|
|
319
319
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
320
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
320
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
321
321
|
return requestPrivate(credential, 'GET', endpoint, params, requestContext);
|
|
322
322
|
};
|
|
323
323
|
/**
|
|
@@ -327,13 +327,13 @@ export const getUMIncome = (credential, params) => {
|
|
|
327
327
|
*
|
|
328
328
|
* https://developers.binance.com/docs/zh-CN/derivatives/usds-margined-futures/account/rest-api/Get-Income-History
|
|
329
329
|
*/
|
|
330
|
-
export const getAccountIncome = (credential, params) => {
|
|
330
|
+
export const getAccountIncome = async (credential, params) => {
|
|
331
331
|
const endpoint = 'https://fapi.binance.com/fapi/v1/income';
|
|
332
332
|
const url = new URL(endpoint);
|
|
333
333
|
const weight = 30;
|
|
334
|
-
const requestContext = createRequestContext();
|
|
334
|
+
const requestContext = await createRequestContext();
|
|
335
335
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
336
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
336
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
337
337
|
return requestPrivate(credential, 'GET', endpoint, params, requestContext);
|
|
338
338
|
};
|
|
339
339
|
/**
|
|
@@ -343,13 +343,13 @@ export const getAccountIncome = (credential, params) => {
|
|
|
343
343
|
*
|
|
344
344
|
* https://developers.binance.com/docs/zh-CN/binance-spot-api-docs/rest-api/trading-endpoints#%E6%92%A4%E9%94%80%E5%B9%B6%E9%87%8D%E6%96%B0%E4%B8%8B%E5%8D%95-trade
|
|
345
345
|
*/
|
|
346
|
-
export const postSpotOrderCancelReplace = (credential, params) => {
|
|
346
|
+
export const postSpotOrderCancelReplace = async (credential, params) => {
|
|
347
347
|
const endpoint = 'https://api.binance.com/api/v3/order/cancelReplace';
|
|
348
348
|
const url = new URL(endpoint);
|
|
349
349
|
const weight = 1;
|
|
350
|
-
const requestContext = createRequestContext();
|
|
350
|
+
const requestContext = await createRequestContext();
|
|
351
351
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
352
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
352
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
353
353
|
return requestPrivate(credential, 'POST', endpoint, params, requestContext);
|
|
354
354
|
};
|
|
355
355
|
/**
|
|
@@ -359,13 +359,13 @@ export const postSpotOrderCancelReplace = (credential, params) => {
|
|
|
359
359
|
*
|
|
360
360
|
* https://developers.binance.com/docs/zh-CN/derivatives/portfolio-margin/trade/Modify-UM-Order
|
|
361
361
|
*/
|
|
362
|
-
export const putUmOrder = (credential, params) => {
|
|
362
|
+
export const putUmOrder = async (credential, params) => {
|
|
363
363
|
const endpoint = 'https://papi.binance.com/papi/v1/um/order';
|
|
364
364
|
const url = new URL(endpoint);
|
|
365
365
|
const weight = 1;
|
|
366
|
-
const requestContext = createRequestContext();
|
|
366
|
+
const requestContext = await createRequestContext();
|
|
367
367
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
368
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'PUT', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
368
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'PUT', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
369
369
|
return requestPrivate(credential, 'PUT', endpoint, params, requestContext);
|
|
370
370
|
};
|
|
371
371
|
/**
|
|
@@ -375,14 +375,14 @@ export const putUmOrder = (credential, params) => {
|
|
|
375
375
|
*
|
|
376
376
|
* https://developers.binance.com/docs/zh-CN/margin_trading/market-data/Get-All-Cross-Margin-Pairs
|
|
377
377
|
*/
|
|
378
|
-
export const getMarginAllPairs = (params) => {
|
|
378
|
+
export const getMarginAllPairs = async (params) => {
|
|
379
379
|
const credential = getDefaultCredential();
|
|
380
380
|
const endpoint = 'https://api.binance.com/sapi/v1/margin/allPairs';
|
|
381
381
|
const url = new URL(endpoint);
|
|
382
382
|
const weight = 1;
|
|
383
|
-
const requestContext = createRequestContext();
|
|
383
|
+
const requestContext = await createRequestContext();
|
|
384
384
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
385
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
385
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
386
386
|
return requestPrivate(credential, 'GET', endpoint, params, requestContext);
|
|
387
387
|
};
|
|
388
388
|
/**
|
|
@@ -390,14 +390,14 @@ export const getMarginAllPairs = (params) => {
|
|
|
390
390
|
*
|
|
391
391
|
* https://developers.binance.com/docs/zh-CN/margin_trading/borrow-and-repay/Get-a-future-hourly-interest-rate
|
|
392
392
|
*/
|
|
393
|
-
export const getMarginNextHourlyInterestRate = (params) => {
|
|
393
|
+
export const getMarginNextHourlyInterestRate = async (params) => {
|
|
394
394
|
const credential = getDefaultCredential();
|
|
395
395
|
const endpoint = 'https://api.binance.com/sapi/v1/margin/next-hourly-interest-rate';
|
|
396
396
|
const url = new URL(endpoint);
|
|
397
397
|
const weight = 1;
|
|
398
|
-
const requestContext = createRequestContext();
|
|
398
|
+
const requestContext = await createRequestContext();
|
|
399
399
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
400
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
400
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
401
401
|
return requestPrivate(credential, 'GET', endpoint, params, requestContext);
|
|
402
402
|
};
|
|
403
403
|
/**
|
|
@@ -405,14 +405,14 @@ export const getMarginNextHourlyInterestRate = (params) => {
|
|
|
405
405
|
*
|
|
406
406
|
* https://developers.binance.com/docs/zh-CN/margin_trading/borrow-and-repay/Query-Margin-Interest-Rate-History
|
|
407
407
|
*/
|
|
408
|
-
export const getMarginInterestRateHistory = (params) => {
|
|
408
|
+
export const getMarginInterestRateHistory = async (params) => {
|
|
409
409
|
const credential = getDefaultCredential();
|
|
410
410
|
const endpoint = 'https://api.binance.com/sapi/v1/margin/interestRateHistory';
|
|
411
411
|
const url = new URL(endpoint);
|
|
412
412
|
const weight = 1;
|
|
413
|
-
const requestContext = createRequestContext();
|
|
413
|
+
const requestContext = await createRequestContext();
|
|
414
414
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
415
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
415
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
416
416
|
return requestPrivate(credential, 'GET', endpoint, params, requestContext);
|
|
417
417
|
};
|
|
418
418
|
/**
|
|
@@ -422,13 +422,13 @@ export const getMarginInterestRateHistory = (params) => {
|
|
|
422
422
|
* @param params
|
|
423
423
|
* @returns
|
|
424
424
|
*/
|
|
425
|
-
export const getUserAsset = (credential, params) => {
|
|
425
|
+
export const getUserAsset = async (credential, params) => {
|
|
426
426
|
const endpoint = 'https://api.binance.com/sapi/v3/asset/getUserAsset';
|
|
427
427
|
const url = new URL(endpoint);
|
|
428
428
|
const weight = 1;
|
|
429
|
-
const requestContext = createRequestContext();
|
|
429
|
+
const requestContext = await createRequestContext();
|
|
430
430
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
431
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
431
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
432
432
|
return requestPrivate(credential, 'POST', endpoint, params, requestContext);
|
|
433
433
|
};
|
|
434
434
|
/**
|
|
@@ -438,13 +438,13 @@ export const getUserAsset = (credential, params) => {
|
|
|
438
438
|
* @param params
|
|
439
439
|
* @returns
|
|
440
440
|
*/
|
|
441
|
-
export const getFundingAsset = (credential, params) => {
|
|
441
|
+
export const getFundingAsset = async (credential, params) => {
|
|
442
442
|
const endpoint = 'https://api.binance.com/sapi/v1/asset/get-funding-asset';
|
|
443
443
|
const url = new URL(endpoint);
|
|
444
444
|
const weight = 1;
|
|
445
|
-
const requestContext = createRequestContext();
|
|
445
|
+
const requestContext = await createRequestContext();
|
|
446
446
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
447
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
447
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'POST', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
448
448
|
return requestPrivate(credential, 'POST', endpoint, params, requestContext);
|
|
449
449
|
};
|
|
450
450
|
/**
|
|
@@ -454,13 +454,13 @@ export const getFundingAsset = (credential, params) => {
|
|
|
454
454
|
* @param params
|
|
455
455
|
* @returns
|
|
456
456
|
*/
|
|
457
|
-
export const getUmAccountTradeList = (credential, params) => {
|
|
457
|
+
export const getUmAccountTradeList = async (credential, params) => {
|
|
458
458
|
const endpoint = 'https://papi.binance.com/papi/v1/um/userTrades';
|
|
459
459
|
const url = new URL(endpoint);
|
|
460
460
|
const weight = 5;
|
|
461
|
-
const requestContext = createRequestContext();
|
|
461
|
+
const requestContext = await createRequestContext();
|
|
462
462
|
const bucketKey = buildTokenBucketKey(url.host, requestContext.ip);
|
|
463
|
-
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey).acquireSync(weight));
|
|
463
|
+
scopeError('BINANCE_API_RATE_LIMIT', { method: 'GET', endpoint, host: url.host, path: url.pathname, bucketId: bucketKey, weight }, () => tokenBucket(bucketKey, getTokenBucketOptions(url.host)).acquireSync(weight));
|
|
464
464
|
return requestPrivate(credential, 'GET', endpoint, params, requestContext);
|
|
465
465
|
};
|
|
466
466
|
//# sourceMappingURL=private-api.js.map
|